Skip to content

Commit 2829003

Browse files
Add beta_angle_deg to Python
1 parent 793033f commit 2829003

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["anise", "anise-cli", "anise-gui", "anise-py", "anise/fuzz"]
44

55
[workspace.package]
6-
version = "0.6.0"
6+
version = "0.6.1"
77
edition = "2021"
88
authors = ["Christopher Rabotin <christopher.rabotin@gmail.com>"]
99
description = "ANISE provides a toolkit and files for Attitude, Navigation, Instrument, Spacecraft, and Ephemeris data. It's a modern replacement of NAIF SPICE file."
@@ -45,7 +45,7 @@ pyo3-log = "0.12"
4545
numpy = "0.25"
4646
ndarray = ">= 0.15, < 0.17"
4747

48-
anise = { version = "0.6.0", path = "anise", default-features = false }
48+
anise = { version = "0.6.1", path = "anise", default-features = false }
4949

5050
[profile.bench]
5151
debug = true

anise-py/anise.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ The obstructing body _should_ be a tri-axial ellipsoid body, e.g. IAU_MOON_FRAME
9292
6. Compute the elevation, and ensure it is between +/- 180 degrees.
9393
7. Compute the azimuth with a quadrant check, and ensure it is between 0 and 360 degrees."""
9494

95+
def beta_angle_deg(self, state: Orbit, ab_corr: Aberration=None) -> float:
96+
"""Computes the Beta angle (β) for a given orbital state, in degrees. A Beta angle of 0° indicates that the orbit plane is edge-on to the Sun, leading to maximum eclipse time. Conversely, a Beta angle of +90° or -90° means the orbit plane is face-on to the Sun, resulting in continuous sunlight exposure and no eclipses.
97+
98+
The Beta angle (β) is defined as the angle between the orbit plane of a spacecraft and the vector from the central body (e.g., Earth) to the Sun. In simpler terms, it measures how much of the time a satellite in orbit is exposed to direct sunlight.
99+
The mathematical formula for the Beta angle is: β=arcsin(h⋅usun\u200b)
100+
Where:
101+
- h is the unit vector of the orbital momentum.
102+
- usun\u200b is the unit vector pointing from the central body to the Sun.
103+
104+
Original code from GMAT, <https://github.com/ChristopherRabotin/GMAT/blob/GMAT-R2022a/src/gmatutil/util/CalculationUtilities.cpp#L209-L219>"""
105+
95106
def bpc_domain(self, id: int) -> typing.Tuple:
96107
"""Returns the applicable domain of the request id, i.e. start and end epoch that the provided id has loaded data."""
97108

anise-py/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use ::anise::almanac::metaload::{MetaAlmanac, MetaFile};
1212
use ::anise::almanac::Almanac;
1313
use ::anise::astro::Aberration;
1414
use hifitime::leap_seconds::{LatestLeapSeconds, LeapSecondsFile};
15-
use hifitime::prelude::*;
15+
use hifitime::python::{PyDurationError, PyHifitimeError, PyParsingError};
1616
use hifitime::ut1::Ut1Provider;
17+
use hifitime::{prelude::*, MonthName, Polynomial};
1718

1819
use pyo3::prelude::*;
1920
use pyo3::py_run;
@@ -50,6 +51,12 @@ fn register_time_module(parent_module: &Bound<'_, PyModule>) -> PyResult<()> {
5051
sm.add_class::<LatestLeapSeconds>()?;
5152
sm.add_class::<LeapSecondsFile>()?;
5253
sm.add_class::<Ut1Provider>()?;
54+
sm.add_class::<MonthName>()?;
55+
sm.add_class::<PyHifitimeError>()?;
56+
sm.add_class::<PyDurationError>()?;
57+
sm.add_class::<PyParsingError>()?;
58+
sm.add_class::<Polynomial>()?;
59+
sm.add_class::<Weekday>()?;
5360

5461
Python::with_gil(|py| {
5562
py_run!(py, sm, "import sys; sys.modules['anise.time'] = sm");

anise/src/almanac/eclipse.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ impl Almanac {
5353
/// - `r1dotr2` is the dot product of `r1` and `r2`.
5454
/// - `tau` is a parameter that determines the intersection point along the line of sight.
5555
/// - The condition `(1.0 - tau) * r1sq + r1dotr2 * tau <= ob_mean_eq_radius_km^2` checks if the line of sight is within the obstructing body's radius, indicating an obstruction.
56-
///
57-
/// :type observer: Orbit
58-
/// :type observed: Orbit
59-
/// :type obstructing_body: Frame
60-
/// :type ab_corr: Aberration, optional
61-
/// :rtype: bool
6256
pub fn line_of_sight_obstructed(
6357
&self,
6458
observer: Orbit,
@@ -115,12 +109,6 @@ impl Almanac {
115109
/// A 100% percent occultation means that the back object is fully hidden from the observer because of the front frame (i.e. _umbra_ if the back object is the Sun).
116110
/// A value in between means that the back object is partially hidden from the observser (i.e. _penumbra_ if the back object is the Sun).
117111
/// Refer to the [MathSpec](https://nyxspace.com/nyxspace/MathSpec/celestial/eclipse/) for modeling details.
118-
///
119-
/// :type back_frame: Frame
120-
/// :type front_frame: Frame
121-
/// :type observer: Orbit
122-
/// :type ab_corr: Aberration, optional
123-
/// :rtype: Occultation
124112
pub fn occultation(
125113
&self,
126114
mut back_frame: Frame,
@@ -311,10 +299,6 @@ impl Almanac {
311299
/// - usun​ is the unit vector pointing from the central body to the Sun.
312300
///
313301
/// Original code from GMAT, <https://github.com/ChristopherRabotin/GMAT/blob/GMAT-R2022a/src/gmatutil/util/CalculationUtilities.cpp#L209-L219>
314-
///
315-
/// :type state: Orbit
316-
/// :type ab_corr: Aberration, optional
317-
/// :rtype: float
318302
pub fn beta_angle_deg(&self, state: Orbit, ab_corr: Option<Aberration>) -> AlmanacResult<f64> {
319303
let u_sun = self.sun_unit_vector(state.epoch, state.frame, ab_corr)?;
320304
let orbit_mom = state.hvec().map_err(|e| AlmanacError::GenericError {

anise/src/almanac/python.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@ impl Almanac {
225225
self.solar_eclipsing(eclipsing_frame, observer, ab_corr)
226226
}
227227

228+
/// Computes the Beta angle (β) for a given orbital state, in degrees. A Beta angle of 0° indicates that the orbit plane is edge-on to the Sun, leading to maximum eclipse time. Conversely, a Beta angle of +90° or -90° means the orbit plane is face-on to the Sun, resulting in continuous sunlight exposure and no eclipses.
229+
///
230+
/// The Beta angle (β) is defined as the angle between the orbit plane of a spacecraft and the vector from the central body (e.g., Earth) to the Sun. In simpler terms, it measures how much of the time a satellite in orbit is exposed to direct sunlight.
231+
/// The mathematical formula for the Beta angle is: β=arcsin(h⋅usun​)
232+
/// Where:
233+
/// - h is the unit vector of the orbital momentum.
234+
/// - usun​ is the unit vector pointing from the central body to the Sun.
235+
///
236+
/// Original code from GMAT, <https://github.com/ChristopherRabotin/GMAT/blob/GMAT-R2022a/src/gmatutil/util/CalculationUtilities.cpp#L209-L219>
237+
///
238+
/// :type state: Orbit
239+
/// :type ab_corr: Aberration, optional
240+
/// :rtype: float
241+
#[pyo3(name = "beta_angle_deg", signature=(
242+
state,
243+
ab_corr=None,
244+
))]
245+
fn py_beta_angle_deg(&self, state: Orbit, ab_corr: Option<Aberration>) -> AlmanacResult<f64> {
246+
self.beta_angle_deg(state, ab_corr)
247+
}
248+
228249
/// Returns the Cartesian state needed to transform the `from_frame` to the `to_frame`.
229250
///
230251
/// # SPICE Compatibility

0 commit comments

Comments
 (0)