Skip to content

Commit

Permalink
fix(lox-orbits): expose methods for PyElevationMask
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Feb 12, 2025
1 parent b5d632e commit 32c3720
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 6 additions & 2 deletions crates/lox-orbits/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ impl PyElevationMask {
}

fn __getnewargs__(&self) -> (Option<Vec<f64>>, Option<Vec<f64>>, Option<f64>) {
(self.azimuth(), self.elevation(), self.min_elevation())
(self.azimuth(), self.elevation(), self.fixed_elevation())

Check warning on line 909 in crates/lox-orbits/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-orbits/src/python.rs#L909

Added line #L909 was not covered by tests
}

fn azimuth(&self) -> Option<Vec<f64>> {
Expand All @@ -923,12 +923,16 @@ impl PyElevationMask {
}
}

fn min_elevation(&self) -> Option<f64> {
fn fixed_elevation(&self) -> Option<f64> {

Check warning on line 926 in crates/lox-orbits/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-orbits/src/python.rs#L926

Added line #L926 was not covered by tests
match &self.0 {
ElevationMask::Fixed(min_elevation) => Some(*min_elevation),
ElevationMask::Variable(_) => None,
}
}

fn min_elevation(&self, azimuth: f64) -> f64 {
self.0.min_elevation(azimuth)
}

Check warning on line 935 in crates/lox-orbits/src/python.rs

View check run for this annotation

Codecov / codecov/patch

crates/lox-orbits/src/python.rs#L933-L935

Added lines #L933 - L935 were not covered by tests
}

#[pyclass(name = "Observables", module = "lox_space", frozen)]
Expand Down
7 changes: 6 additions & 1 deletion crates/lox-space/lox_space.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ class Ensemble:
def __new__(cls, ensemble: dict[str, Trajectory]): ...

class ElevationMask:
def __new__(cls, azimuth: np.ndarray, elevation: np.ndarray): ...
@classmethod
def variable(cls, azimuth: np.ndarray, elevation: np.ndarray) -> Self: ...
@classmethod
def fixed(cls, min_elevation: float) -> Self: ...
def azimuth(self) -> list[float] | None: ...
def elevation(self) -> list[float] | None: ...
def fixed_elevation(self) -> float | None: ...
def min_elevation(self, azimuth: float) -> float: ...

def find_events(
func: Callable[[float], float], start: Time, times: list[float]
Expand Down
7 changes: 7 additions & 0 deletions crates/lox-space/tests/test_ground.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ def test_observables():
assert observables.range_rate() == pytest.approx(expected_range_rate, rel=1e-2)
assert observables.azimuth() == pytest.approx(expected_azimuth, rel=1e-2)
assert observables.elevation() == pytest.approx(expected_elevation, rel=1e-2)


def test_elevation_mask():
mask = lox.ElevationMask.variable(
np.array([-np.pi, 0.0, np.pi]), np.array([0.0, 5.0, 0.0])
)
assert mask.min_elevation(np.pi / 2) == 2.5

0 comments on commit 32c3720

Please sign in to comment.