1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

//! Core code to describe coordinate transformations, Jones matrices, etc.

#![deny(clippy::all)]
#![warn(clippy::missing_safety_doc)]
// #![warn(clippy::missing_errors_doc)]
#![warn(clippy::float_cmp)]
#![warn(clippy::if_not_else)]
#![warn(clippy::explicit_iter_loop)]
#![warn(clippy::wildcard_imports)]
#![warn(clippy::cloned_instead_of_copied)]
#![warn(clippy::cognitive_complexity)]
#![warn(clippy::type_repetition_in_bounds)]
#![warn(clippy::redundant_closure_for_method_calls)]
#![warn(clippy::doc_markdown)]
#![warn(clippy::match_same_arms)]
#![warn(clippy::default_trait_access)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![warn(clippy::explicit_into_iter_loop)]
#![warn(clippy::inefficient_to_string)]
#![warn(clippy::needless_pass_by_value)]
#![warn(clippy::used_underscore_binding)]

#[allow(non_camel_case_types)]
pub type c32 = num_complex::Complex<f32>;
#[allow(non_camel_case_types)]
pub type c64 = num_complex::Complex<f64>;

pub mod averaging;
pub mod constants;
pub mod context;
pub mod jones;
pub mod math;
pub mod pos;
pub mod selection;
pub mod sexagesimal;

pub mod io;
#[cfg(feature = "ms")]
pub use io::ms;
#[cfg(feature = "cfitsio")]
pub use io::uvfits;
pub use io::VisWrite;

// Re-exports.
pub use context::{History, MwaObsContext, ObsContext, VisContext};
pub use jones::Jones;
pub use pos::{
    azel::AzEl,
    earth::LatLngHeight,
    enh::ENH,
    hadec::HADec,
    lmn::{LmnRime, LMN},
    pal, precession,
    radec::RADec,
    uvw::UVW,
    xyz::{XyzGeocentric, XyzGeodetic},
};
pub use selection::{SelectionError, VisSelection};

pub use erfa;
pub use hifitime;
pub use ndarray;
pub use num_complex;
pub use num_complex::Complex;
pub use num_traits;
pub use rayon;

// Include the generated built.rs code into our library
pub mod built_info {
    // The file has been placed there by the build script.
    include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

// If "mwalib" is enabled, re-export the crate here, as well its re-exported
// crates.
cfg_if::cfg_if! {
    if #[cfg(feature = "mwalib")] {
        pub use mwalib;
        pub use mwalib::{fitsio, fitsio_sys};
    }
}

#[cfg(feature = "cfitsio")]
pub use io::{UvfitsWriteError, UvfitsWriter};

// If "ms" is enabled, re-export rubbl_casatables here.
cfg_if::cfg_if! {
    if #[cfg(feature = "ms")] {
        pub use rubbl_casatables;
        pub use io::MeasurementSetWriter;
    }
}

#[cfg(test)]
#[test]
fn hifitime_works_as_expected() {
    use hifitime::Epoch;

    let gps = 1065880128.0;
    let epoch = Epoch::from_gpst_seconds(gps);
    approx::assert_abs_diff_eq!(epoch.to_gpst_seconds(), gps);

    let jd_utc = 2444244.5;
    let epoch = Epoch::from_jde_utc(jd_utc);
    approx::assert_abs_diff_eq!(epoch.to_jde_utc_days(), jd_utc);
    approx::assert_abs_diff_eq!(epoch.to_gpst_seconds(), 0.0);
}