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: f64FWHM major axis in degrees (FITS BMAJ)
minor_deg: f64FWHM minor axis in degrees (FITS BMIN)
pa_deg: f64Position angle in degrees East of North (FITS BPA)
Implementations§
Source§impl Beam
impl Beam
Sourcepub fn new(
major_deg: f64,
minor_deg: f64,
pa_deg: f64,
) -> Result<Self, BeamError>
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());Sourcepub fn from_arcsec(
major_arcsec: f64,
minor_arcsec: f64,
pa_deg: f64,
) -> Result<Self, BeamError>
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);pub fn zero() -> Self
pub fn major_arcsec(&self) -> f64
pub fn minor_arcsec(&self) -> f64
pub fn is_finite(&self) -> bool
pub fn is_zero(&self) -> bool
pub fn is_circular(&self, rtol: f64) -> bool
pub fn area_sr(&self) -> f64
Sourcepub fn deconvolve(&self, other: &Beam) -> Result<Beam, BeamError>
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());Sourcepub fn deconvolve_or_zero(&self, other: &Beam) -> Beam
pub fn deconvolve_or_zero(&self, other: &Beam) -> Beam
Like deconvolve but returns a zero beam on failure instead of an error.
Sourcepub fn convolve(&self, other: &Beam) -> Beam
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);