Skip to content

Commit

Permalink
Refactor cio, cip and nutation into earth module (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusGMorrison authored Jan 2, 2024
1 parent 7f637e3 commit 5e0356e
Show file tree
Hide file tree
Showing 28 changed files with 92 additions and 1,447 deletions.
8 changes: 8 additions & 0 deletions crates/lox_core/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions crates/lox_core/.idea/lox_core.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/lox_core/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/lox_core/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions crates/lox_core/src/bodies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ use crate::time::constants::f64::{SECONDS_PER_DAY, SECONDS_PER_JULIAN_CENTURY};
mod generated;
pub use generated::*;

mod cio;
mod cip;
pub mod fundamental;
pub mod nutation;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(transparent)]
Expand Down
702 changes: 0 additions & 702 deletions crates/lox_core/src/bodies/nutation/iau2000/iau2000a/planetary.rs

This file was deleted.

693 changes: 0 additions & 693 deletions crates/lox_core/src/bodies/nutation/iau2000a/luni_solar.rs

This file was deleted.

14 changes: 14 additions & 0 deletions crates/lox_core/src/earth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2023. Helge Eichhorn and the LOX contributors
*
* 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 https://mozilla.org/MPL/2.0/.
*/

// TODO: Remove this once all module components are actively used.
#![allow(dead_code)]

mod cio;
mod cip;
mod nutation;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

// TODO: Remove this once all module components are actively used.
#![allow(dead_code)]

mod s06;
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

mod terms;

use crate::bodies::cip::xy06::XY;
use crate::bodies::fundamental::iers03::{
general_accum_precession_in_longitude_iers03, mean_moon_sun_elongation_iers03,
};
use crate::bodies::{Earth, Moon, Sun, Venus};
use crate::earth::cip::xy06::XY;
use crate::math::arcsec_to_rad;
use crate::time::intervals::TDBJulianCenturiesSinceJ2000;
use crate::types::Radians;
Expand Down Expand Up @@ -75,7 +75,7 @@ fn evaluate_single_order_terms(
#[cfg(test)]
mod tests {
use super::*;
use crate::bodies::cip::xy06::xy;
use crate::earth::cip::xy06::xy;
use float_eq::assert_float_eq;

const TOLERANCE: f64 = 1e-11;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use crate::types::Radians;

pub(super) const COEFFICIENTS: [f64; 6] = [
pub(crate) const COEFFICIENTS: [f64; 6] = [
94.00e-6,
3808.65e-6,
-122.68e-6,
Expand All @@ -18,17 +18,17 @@ pub(super) const COEFFICIENTS: [f64; 6] = [
];

/// Coefficients of l, l', F, D, Ω, LVe, LE and pA.
pub(super) type FundamentalArgCoeffs = [Radians; 8];
pub(crate) type FundamentalArgCoeffs = [Radians; 8];

pub(super) struct Term {
pub(crate) struct Term {
pub fundamental_arg_coeffs: FundamentalArgCoeffs,
pub sin_coeff: f64,
pub cos_coeff: f64,
}

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const ZERO_ORDER: [Term; 33] = [
pub(crate) const ZERO_ORDER: [Term; 33] = [
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0], sin_coeff: -2640.73e-6, cos_coeff: 0.39e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0], sin_coeff: -63.53e-6, cos_coeff: 0.02e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 2.0, -2.0, 3.0, 0.0, 0.0, 0.0], sin_coeff: -11.75e-6, cos_coeff: -0.01e-6 },
Expand Down Expand Up @@ -66,15 +66,15 @@ pub(super) const ZERO_ORDER: [Term; 33] = [

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const FIRST_ORDER: [Term; 3] = [
pub(crate) const FIRST_ORDER: [Term; 3] = [
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0], sin_coeff: -0.07e-6, cos_coeff: 3.57e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0], sin_coeff: 1.73e-6, cos_coeff: -0.03e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 2.0, -2.0, 3.0, 0.0, 0.0, 0.0], sin_coeff: 0.00e-6, cos_coeff: 0.48e-6 },
];

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const SECOND_ORDER: [Term; 25] = [
pub(crate) const SECOND_ORDER: [Term; 25] = [
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0], sin_coeff: 743.52e-6, cos_coeff: -0.17e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 2.0, -2.0, 2.0, 0.0, 0.0, 0.0], sin_coeff: 56.91e-6, cos_coeff: 0.06e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0], sin_coeff: 9.84e-6, cos_coeff: -0.01e-6 },
Expand Down Expand Up @@ -104,7 +104,7 @@ pub(super) const SECOND_ORDER: [Term; 25] = [

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const THIRD_ORDER: [Term; 4] = [
pub(crate) const THIRD_ORDER: [Term; 4] = [
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0], sin_coeff: 0.30e-6, cos_coeff: -23.42e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 2.0, -2.0, 2.0, 0.0, 0.0, 0.0], sin_coeff: -0.03e-6, cos_coeff: -1.46e-6 },
Term{ fundamental_arg_coeffs: [0.0, 0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0], sin_coeff: -0.01e-6, cos_coeff: -0.25e-6 },
Expand All @@ -113,6 +113,6 @@ pub(super) const THIRD_ORDER: [Term; 4] = [

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const FOURTH_ORDER: [Term; 1] = [
pub(crate) const FOURTH_ORDER: [Term; 1] = [
Term{ fundamental_arg_coeffs: [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0], sin_coeff: -0.26e-6, cos_coeff: -0.01e-6 }
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

// TODO: Remove this once all module components are actively used.
#![allow(dead_code)]

pub mod xy06;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::MicroArcsecond;
/// Indices into amplitude [COEFFICIENTS].
#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const INDICES: [usize; 1309] = [
pub(crate) const INDICES: [usize; 1309] = [
1, 21, 37, 51, 65, 79, 91, 103, 115, 127,
139, 151, 163, 172, 184, 196, 207, 219, 231, 240,
252, 261, 273, 285, 297, 309, 318, 327, 339, 351,
Expand Down Expand Up @@ -148,7 +148,7 @@ pub(super) const INDICES: [usize; 1309] = [
#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
#[allow(clippy::approx_constant)]
pub(super) const COEFFICIENTS: [MicroArcsecond; 4755] = [
pub(crate) const COEFFICIENTS: [MicroArcsecond; 4755] = [
-6844318.44, 9205236.26,1328.67,1538.18, 205833.11,
153041.79, -3309.73, 853.32,2037.98, -2301.27,
81.46, 120.56, -20.39, -15.22, 1.73, -1.61, -0.10, 0.11,
Expand Down Expand Up @@ -751,11 +751,11 @@ pub(super) const COEFFICIENTS: [MicroArcsecond; 4755] = [
0.12, 0.00, 0.00, 0.12, 0.12, 0.08, 0.00, 0.04
];

pub(super) const USAGE_XY: [usize; 20] =
pub(crate) const USAGE_XY: [usize; 20] =
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1];

pub(super) const USAGE_SIN_COS: [usize; 20] =
pub(crate) const USAGE_SIN_COS: [usize; 20] =
[0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0];

pub(super) const USAGE_POWER_OF_T: [usize; 20] =
pub(crate) const USAGE_POWER_OF_T: [usize; 20] =
[0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4];
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

pub(super) type LuniSolarFrequencyList = [f64; 5];
pub(crate) type LuniSolarFrequencyList = [f64; 5];

pub(super) const N_FREQUENCY_LISTS: usize = 653;
pub(crate) const N_FREQUENCY_LISTS: usize = 653;

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const FREQUENCY_LISTS: [LuniSolarFrequencyList; N_FREQUENCY_LISTS] = [
pub(crate) const FREQUENCY_LISTS: [LuniSolarFrequencyList; N_FREQUENCY_LISTS] = [
[0.0, 0.0, 0.0, 0.0, 1.0],
[0.0, 0.0, 2.0, -2.0, 2.0],
[0.0, 0.0, 2.0, 0.0, 2.0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

pub(super) type PlanetaryFrequencyList = [f64; 14];
pub(crate) type PlanetaryFrequencyList = [f64; 14];

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const FREQUENCY_LISTS: [PlanetaryFrequencyList; 656] = [
pub(crate) const FREQUENCY_LISTS: [PlanetaryFrequencyList; 656] = [
[0.0, 0.0, 1.0, -1.0, 1.0, 0.0, 0.0, -1.0, 0.0, -2.0, 5.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, -5.0, 0.0, 0.0, -1.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, -2.0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

use super::MAX_POWER_OF_T;

pub(super) struct PolynomialCoefficients {
pub(crate) struct PolynomialCoefficients {
pub x: [f64; MAX_POWER_OF_T + 1],
pub y: [f64; MAX_POWER_OF_T + 1],
}

pub(super) const COEFFICIENTS: PolynomialCoefficients = PolynomialCoefficients {
pub(crate) const COEFFICIENTS: PolynomialCoefficients = PolynomialCoefficients {
x: [
-0.016617,
2004.191898,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::ops::Add;

use crate::bodies::nutation::iau1980::nutation_iau1980;
use crate::bodies::nutation::iau2000::nutation_iau2000a;
use crate::bodies::nutation::iau2000::nutation_iau2000b;
use crate::bodies::nutation::iau2006::nutation_iau2006a;
use crate::earth::nutation::iau1980::nutation_iau1980;
use crate::earth::nutation::iau2000::nutation_iau2000a;
use crate::earth::nutation::iau2000::nutation_iau2000b;
use crate::earth::nutation::iau2006::nutation_iau2006a;
use crate::math::RADIANS_IN_ARCSECOND;
use crate::time::epochs::Epoch;
use crate::time::intervals::tdb_julian_centuries_since_j2000;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::f64::consts::TAU;

use crate::bodies::nutation::{point1_milliarcsec_to_rad, Nutation};
use crate::earth::nutation::{point1_milliarcsec_to_rad, Nutation};
use crate::math::{arcsec_to_rad, normalize_two_pi};
use crate::time::intervals::TDBJulianCenturiesSinceJ2000;
use crate::types::{Arcsec, Radians};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod iau2000a;
mod iau2000b;

use crate::bodies::nutation::{point1_microarcsec_to_rad, Nutation};
use crate::earth::nutation::{point1_microarcsec_to_rad, Nutation};
use crate::time::intervals::TDBJulianCenturiesSinceJ2000;
pub(super) use iau2000a::nutation_iau2000a;
pub(super) use iau2000b::nutation_iau2000b;
pub(crate) use iau2000a::nutation_iau2000a;
pub(crate) use iau2000b::nutation_iau2000b;
use std::f64::consts::TAU;

/// IAU 2000A and 2000B use the same structure for luni-solar coefficients.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::bodies::fundamental::iers03::general_accum_precession_in_longitude_ie
use crate::bodies::fundamental::mhb2000::{
mean_moon_sun_elongation_mhb2000_luni_solar, mean_moon_sun_elongation_mhb2000_planetary,
};
use crate::bodies::nutation::iau2000::{luni_solar_nutation, DelaunayArguments};
use crate::bodies::nutation::{point1_microarcsec_to_rad, Nutation};
use crate::bodies::*;
use crate::earth::nutation::iau2000::{luni_solar_nutation, DelaunayArguments};
use crate::earth::nutation::{point1_microarcsec_to_rad, Nutation};
use crate::time::intervals::TDBJulianCenturiesSinceJ2000;

mod luni_solar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

use crate::bodies::nutation::iau2000::LuniSolarCoefficients;
use crate::earth::nutation::iau2000::LuniSolarCoefficients;

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const COEFFICIENTS: [LuniSolarCoefficients; 678] = [
pub(crate) const COEFFICIENTS: [LuniSolarCoefficients; 678] = [
LuniSolarCoefficients{ l: 0.0, lp: 0.0, f: 0.0, d: 0.0, om: 1.0, sin_psi: -172064161.0, sin_psi_t: -174666.0, cos_psi: 33386.0, cos_eps: 92052331.0, cos_eps_t: 9086.0, sin_eps: 15377.0},
LuniSolarCoefficients{ l: 0.0, lp: 0.0, f: 2.0, d: -2.0, om: 2.0, sin_psi: -13170906.0, sin_psi_t: -1675.0, cos_psi: -13696.0, cos_eps: 5730336.0, cos_eps_t: -3015.0, sin_eps: -4587.0},
LuniSolarCoefficients{ l: 0.0, lp: 0.0, f: 2.0, d: 0.0, om: 2.0, sin_psi: -2276413.0, sin_psi_t: -234.0, cos_psi: 2796.0, cos_eps: 978459.0, cos_eps_t: -485.0, sin_eps: 1374.0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::PlanetaryCoefficients;

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const COEFFICIENTS: [PlanetaryCoefficients; 687] = [
pub(crate) const COEFFICIENTS: [PlanetaryCoefficients; 687] = [
PlanetaryCoefficients{ l: 0.0, f: 0.0, d: 0.0, om: 0.0, mercury: 0.0, venus: 0.0, earth: 8.0, mars: -16.0, jupiter: 4.0, saturn: 5.0, uranus: 0.0, neptune: 0.0, pa: 0.0, sin_psi: 1440.0, cos_psi: 0.0, sin_eps: 0.0, cos_eps: 0.0},
PlanetaryCoefficients{ l: 0.0, f: 0.0, d: 0.0, om: 0.0, mercury: 0.0, venus: 0.0, earth: -8.0, mars: 16.0, jupiter: -4.0, saturn: -5.0, uranus: 0.0, neptune: 0.0, pa: 2.0, sin_psi: 56.0, cos_psi: -117.0, sin_eps: -42.0, cos_eps: -40.0},
PlanetaryCoefficients{ l: 0.0, f: 0.0, d: 0.0, om: 0.0, mercury: 0.0, venus: 0.0, earth: 8.0, mars: -16.0, jupiter: 4.0, saturn: 5.0, uranus: 0.0, neptune: 0.0, pa: 2.0, sin_psi: 125.0, cos_psi: -43.0, sin_eps: 0.0, cos_eps: -54.0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

use crate::bodies::fundamental::simon1994::mean_moon_sun_elongation_simon1994;
use crate::bodies::nutation::iau2000::{luni_solar_nutation, DelaunayArguments};
use crate::bodies::nutation::Nutation;
use crate::bodies::*;
use crate::earth::nutation::iau2000::{luni_solar_nutation, DelaunayArguments};
use crate::earth::nutation::Nutation;
use crate::time::intervals::TDBJulianCenturiesSinceJ2000;

mod luni_solar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

use crate::bodies::nutation::iau2000::LuniSolarCoefficients;
use crate::earth::nutation::iau2000::LuniSolarCoefficients;

#[rustfmt::skip]
// @formatter:off (sometimes RustRover ignores the rustfmt skip)
pub(super) const COEFFICIENTS: [LuniSolarCoefficients; 77] = [
pub(crate) const COEFFICIENTS: [LuniSolarCoefficients; 77] = [
LuniSolarCoefficients{l: 0.0, lp: 0.0, f: 0.0, d: 0.0, om: 1.0, sin_psi: -172064161.0, sin_psi_t: -174666.0, cos_psi: 33386.0, cos_eps: 92052331.0, cos_eps_t: 9086.0, sin_eps: 15377.0},
LuniSolarCoefficients{l: 0.0, lp: 0.0, f: 2.0, d: -2.0, om: 2.0, sin_psi: -13170906.0, sin_psi_t: -1675.0, cos_psi: -13696.0, cos_eps: 5730336.0, cos_eps_t: -3015.0, sin_eps: -4587.0},
LuniSolarCoefficients{l: 0.0, lp: 0.0, f: 2.0, d: 0.0, om: 2.0, sin_psi: -2276413.0, sin_psi_t: -234.0, cos_psi: 2796.0, cos_eps: 978459.0, cos_eps_t: -485.0, sin_eps: 1374.0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

use crate::bodies::nutation::Nutation;
use crate::earth::nutation::Nutation;
use crate::math::RADIANS_IN_ARCSECOND;

const RADIANS_IN_MILLIARCSECOND: f64 = RADIANS_IN_ARCSECOND / 1e3;

/// 2000B uses fixed offsets for ψ and ε in lieu of planetary terms.
pub(super) static OFFSETS: &Nutation = &Nutation {
pub(crate) static OFFSETS: &Nutation = &Nutation {
longitude: -0.135 * RADIANS_IN_MILLIARCSECOND,
obliquity: 0.388 * RADIANS_IN_MILLIARCSECOND,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/

use crate::bodies::nutation::iau2000::nutation_iau2000a;
use crate::bodies::nutation::Nutation;
use crate::bodies::Earth;
use crate::earth::nutation::iau2000::nutation_iau2000a;
use crate::earth::nutation::Nutation;
use crate::time::intervals::TDBJulianCenturiesSinceJ2000;

/// The IAU 2000A nutation model adjusted to match the IAU 2006 precession model per
Expand Down
1 change: 1 addition & 0 deletions crates/lox_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ pub mod time;
pub mod two_body;
pub mod types;

mod earth;
pub(crate) mod math;

0 comments on commit 5e0356e

Please sign in to comment.