Skip to main content

Beam

Struct Beam 

Source
pub struct Beam {
    pub major_deg: f64,
    pub minor_deg: f64,
    pub pa_deg: f64,
}
Expand description

A 2D elliptical Gaussian beam in FITS conventions.

§Examples

use convolve_rs::Beam;

let beam = Beam::from_arcsec(20.0, 10.0, 45.0)?;
assert_eq!(beam.major_arcsec(), 20.0);
assert_eq!(beam.major_deg, 20.0 / 3600.0);

Fields§

§major_deg: f64

FWHM major axis in degrees (FITS BMAJ)

§minor_deg: f64

FWHM minor axis in degrees (FITS BMIN)

§pa_deg: f64

Position angle in degrees East of North (FITS BPA)

Implementations§

Source§

impl Beam

Source

pub fn new( major_deg: f64, minor_deg: f64, pa_deg: f64, ) -> Result<Self, BeamError>

Create a beam from FWHM axes in degrees and a position angle in degrees East of North.

§Errors

Returns BeamError::InvalidAxes if minor_deg > major_deg, and BeamError::NotFinite if any value is NaN or infinite.

§Examples
use convolve_rs::Beam;

let beam = Beam::new(20.0 / 3600.0, 10.0 / 3600.0, 45.0)?;
assert_eq!(beam.pa_deg, 45.0);

// Minor axis larger than major is rejected.
assert!(Beam::new(10.0 / 3600.0, 20.0 / 3600.0, 0.0).is_err());
Source

pub fn from_arcsec( major_arcsec: f64, minor_arcsec: f64, pa_deg: f64, ) -> Result<Self, BeamError>

Create a beam from FWHM axes in arcseconds and a position angle in degrees East of North.

§Examples
use convolve_rs::Beam;

let beam = Beam::from_arcsec(20.0, 10.0, 45.0)?;
assert_eq!(beam.minor_deg, 10.0 / 3600.0);
Source

pub fn zero() -> Self

Source

pub fn major_arcsec(&self) -> f64

Source

pub fn minor_arcsec(&self) -> f64

Source

pub fn is_finite(&self) -> bool

Source

pub fn is_zero(&self) -> bool

Source

pub fn is_circular(&self, rtol: f64) -> bool

Source

pub fn area_sr(&self) -> f64

Source

pub fn deconvolve(&self, other: &Beam) -> Result<Beam, BeamError>

Deconvolve other from self (i.e. self = result ⊛ other).

Subtracts the covariance of other from that of self and reads off the residual ellipse. Fails if the residual is not positive-definite (the source beam is not larger than the PSF). Inputs/outputs in degrees.

§Examples

Deconvolution inverts convolution:

use convolve_rs::Beam;

let a = Beam::from_arcsec(10.0, 8.0, 30.0)?;
let b = Beam::from_arcsec(6.0, 5.0, 15.0)?;
let recovered = a.convolve(&b).deconvolve(&a)?;
assert!((recovered.major_arcsec() - b.major_arcsec()).abs() < 1e-6);
assert!((recovered.minor_arcsec() - b.minor_arcsec()).abs() < 1e-6);

// Deconvolving a larger beam from a smaller one fails.
assert!(b.deconvolve(&a).is_err());
Source

pub fn deconvolve_or_zero(&self, other: &Beam) -> Beam

Like deconvolve but returns a zero beam on failure instead of an error.

Source

pub fn convolve(&self, other: &Beam) -> Beam

Convolve self with other: sum the covariance matrices and read off the resulting ellipse.

§Examples

Convolving two circular beams adds their axes in quadrature:

use convolve_rs::Beam;

let a = Beam::from_arcsec(3.0, 3.0, 0.0)?;
let b = Beam::from_arcsec(4.0, 4.0, 0.0)?;
let c = a.convolve(&b);
assert!((c.major_arcsec() - 5.0).abs() < 1e-9);
Source

pub fn approx_eq(&self, other: &Beam) -> bool

Approximate equality with a tolerance of ~1e-10 degrees (~0.4 nanoarcsec).

Trait Implementations§

Source§

impl Clone for Beam

Source§

fn clone(&self) -> Beam

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Beam

Source§

impl Debug for Beam

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Beam

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Beam

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl Freeze for Beam

§

impl RefUnwindSafe for Beam

§

impl Send for Beam

§

impl Sync for Beam

§

impl Unpin for Beam

§

impl UnsafeUnpin for Beam

§

impl UnwindSafe for Beam

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more