Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lox-orbits): expose methods for PyElevationMask #211

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

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 @@
}
}

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
Loading