RADec

Struct RADec 

Source
pub struct RADec {
    pub ra: f64,
    pub dec: f64,
}
Expand description

A struct containing a Right Ascension and Declination. All units are in radians.

Note that the serialised units are degrees and are automatically converted when serialising/deserialising.

Fields§

§ra: f64

Right ascension [radians]

§dec: f64

Declination [radians]

Implementations§

Source§

impl RADec

Source

pub fn from_radians(ra: f64, dec: f64) -> RADec

Make a new RADec struct from values in radians.

Source

pub fn from_degrees(ra: f64, dec: f64) -> RADec

Make a new RADec struct from values in degrees.

Source

pub fn new(ra_rad: f64, dec_rad: f64) -> RADec

👎Deprecated: use RADec::from_radians instead

Make a new RADec struct from values in radians.

Source

pub fn new_degrees(ra_deg: f64, dec_deg: f64) -> RADec

👎Deprecated: use RADec::from_degrees instead

Make a new RADec struct from values in degrees.

Source

pub fn to_hadec(self, lst_rad: f64) -> HADec

Given a local sidereal time, make a new HADec struct from a RADec.

Source

pub fn from_hadec(hadec: HADec, lst_rad: f64) -> Self

Given a local sidereal time, make a new RADec struct from a HADec.

Source

pub fn weighted_average(radecs: &[Self], weights: &[f64]) -> Option<Self>

From a collection of RADec coordinates and weights, find the average RADec position. The lengths of both collection must be the same to get sensible results. Not providing any RADec coordinates will make this function return None.

This function accounts for Right Ascension coordinates that range over 360 degrees. If the right ascension coordinates span a huge range (e.g. 0, 90, 180, 270), None is returned.

The average position is found by converting the RADec coordinates (“spherical coordinates”) to cartesian coordinates (direction cosines), performing the average, then converting the average back to spherical. The results have been verified with scipy.optimize (a sample program is provided at the bottom of this file) and online calculators. When coordinates are widely separated, the average can appear to have strange values due to them falling on great circles.

Source

pub fn to_lmn(self, phase_centre: RADec) -> LMN

Get the LMN direction cosines from an RADec and a phase centre.

Derived using “Coordinate transformations” on page 388 of Synthesis Imaging in Radio Astronomy II.

Source

pub fn separation(&self, b: Self) -> f64

Calculate the distance between two sets of coordinates [radians].

Source

pub fn from_mwalib_phase_center(context: &MetafitsContext) -> Option<RADec>

Given an mwalib::MetafitsContext, make an Option<RADec> from the (ra|dec)_phase_center_degrees if these are available, otherwise None.

Source

pub fn from_mwalib_tile_pointing(context: &MetafitsContext) -> RADec

Given an mwalib::MetafitsContext, make a RADec from the (ra|dec)_tile_pointing_degrees.

Source

pub fn from_mwalib_phase_or_pointing(context: &MetafitsContext) -> RADec

Given an mwalib::MetafitsContext, make a RADec from the (ra|dec)_phase_center_degrees if these are available, otherwise use the (ra|dec)_tile_pointing_degrees.

Trait Implementations§

Source§

impl Clone for RADec

Source§

fn clone(&self) -> RADec

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RADec

Source§

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

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

impl Default for RADec

Source§

fn default() -> RADec

Returns the “default value” for a type. Read more
Source§

impl Display for RADec

Source§

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

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

impl PartialEq for RADec

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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.
Source§

impl Copy for RADec

Source§

impl StructuralPartialEq for RADec

Auto Trait Implementations§

§

impl Freeze for RADec

§

impl RefUnwindSafe for RADec

§

impl Send for RADec

§

impl Sync for RADec

§

impl Unpin for RADec

§

impl UnwindSafe for RADec

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, 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 = 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.