Struct marlu::pos::radec::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 copy 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<RADec> for RADec

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.