Skip to main content

Beam

Struct Beam 

Source
pub struct Beam { /* private fields */ }
Expand description

A 2D elliptical Gaussian beam in FITS conventions: FWHM axes in degrees (BMAJ, BMIN) and position angle in degrees East of North (BPA).

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);

Implementations§

Source§

impl Beam

Source

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

A beam from FWHM axes in degrees and a PA in degrees East of North.

§Errors

If a value is not finite, an axis is negative, or minor_deg > major_deg.

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);
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>

A beam from FWHM axes in arcseconds and a PA in degrees East of North.

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

The zero-size beam, used for masked channels.

Source

pub fn major_deg(&self) -> f64

Source

pub fn minor_deg(&self) -> f64

Source

pub fn pa_deg(&self) -> f64

Source

pub fn major_arcsec(&self) -> f64

Source

pub fn minor_arcsec(&self) -> f64

Source

pub fn has_area(&self) -> bool

True if both axes are positive, so the beam can be convolved.

Source

pub fn is_zero(&self) -> bool

Source

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

Source

pub fn area_sr(&self) -> f64

Solid angle in steradians.

Source

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

The beam that, convolved with other, gives self.

§Errors

BeamError::DeconvolveFailed if the result would not be a beam with positive area, as in radio_beam.

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);
assert!(b.deconvolve(&a).is_err());
Source

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

Like Beam::deconvolve, but a zero beam on failure.

Source

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

True if other can be convolved up to self.

Unlike Beam::deconvolve, this accepts a kernel that is a line or a point (e.g. 20″×10″ inside 20″×20″), which the UV-plane filter handles.

use convolve_rs::Beam;

let target = Beam::from_arcsec(20.0, 20.0, 0.0)?;
assert!(target.contains(&Beam::from_arcsec(20.0, 10.0, 0.0)?));
assert!(!target.contains(&Beam::from_arcsec(21.0, 10.0, 0.0)?));
Source

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

The convolution of two beams.

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)?;
assert!((a.convolve(&b).major_arcsec() - 5.0).abs() < 1e-9);
Source

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

Equal axes to within 1e-10 degrees, and equal PA (mod 180°) unless the beam is circular.

Trait Implementations§

Source§

impl Clone for Beam

Source§

fn clone(&self) -> Self

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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