Skip to content

Commit

Permalink
Exclude anise-py from all but one CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Dec 29, 2023
1 parent 0e03afc commit 4750fc8
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Bench JPL Ephemerides
run: cargo bench --bench "*_jpl_ephemerides"
run: cargo bench --bench "*_jpl_ephemerides" --exclude anise-py

- name: Bench Spacecraft (Hermite type 13)
run: cargo bench --bench "*_spacecraft_ephemeris"
run: cargo bench --bench "*_spacecraft_ephemeris" --exclude anise-py

- name: Bench Binary planetary constants
run: cargo bench --bench "crit_bpc_rotation"
run: cargo bench --bench "crit_bpc_rotation" --exclude anise-py

- name: Save benchmark artifacts
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
execute_install_scripts: true

- name: Build Linux executable
run: cargo build --release --bin anise-gui
run: cargo build --release --bin anise-gui --exclude anise-py

- name: Save executable
uses: actions/upload-artifact@v3
Expand All @@ -54,7 +54,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Build Windows executable
run: cargo build --release --bin anise-gui
run: cargo build --release --bin anise-gui --exclude anise-py

- name: Save executable
uses: actions/upload-artifact@v3
Expand Down
102 changes: 97 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Inspect an Binary PCK file (BPC) ([video link](http://public-data.nyxspace.com/a

![Inspect an SPK file](http://public-data.nyxspace.com/anise/demo/ANISE-BPC.gif)

## Usage
## Rust Usage

Usage as a library is currently only available in Rust. Start using it by adding to your Rust project:
Start using it by adding to your Rust project:

```sh
cargo add anise
Expand Down Expand Up @@ -99,7 +99,7 @@ let orig_state = Orbit::keplerian(

// Transform that orbit into another frame.
let state_itrf93 = almanac
.transform_to(orig_state, EARTH_ITRF93, Aberration::None)
.transform_to(orig_state, EARTH_ITRF93, Aberration::NotSet)
.unwrap();

// The `:x` prints this orbit's Keplerian elements
Expand All @@ -109,7 +109,7 @@ println!("{state_itrf93:X}");

// Convert back
let from_state_itrf93_to_eme2k = almanac
.transform_to(state_itrf93, EARTH_J2000, Aberration::None)
.transform_to(state_itrf93, EARTH_J2000, Aberration::NotSet)
.unwrap();

println!("{from_state_itrf93_to_eme2k}");
Expand Down Expand Up @@ -185,13 +185,105 @@ let state = ctx
VENUS_J2000,
EARTH_MOON_BARYCENTER_J2000,
epoch,
Aberration::None,
Aberration::NotSet,
)
.unwrap();

println!("{state}");
```

## Python Usage

In Python, start by adding anise to your project: `pip install anise`.

```python
from anise import Almanac, Aberration
from anise.astro.constants import Frames
from anise.astro import Orbit
from anise.time import Epoch

from pathlib import Path


def test_state_transformation():
"""
This is the Python equivalent to anise/tests/almanac/mod.rs
"""
data_path = Path(__file__).parent.joinpath("..", "..", "data")
# Must ensure that the path is a string
ctx = Almanac(str(data_path.joinpath("de440s.bsp")))
# Let's add another file here -- note that the Almanac will load into a NEW variable, so we must overwrite it!
# This prevents memory leaks (yes, I promise)
ctx = ctx.load(str(data_path.joinpath("pck08.pca"))).load(
str(data_path.joinpath("earth_latest_high_prec.bpc"))
)
eme2k = ctx.frame_info(Frames.EME2000)
assert eme2k.mu_km3_s2() == 398600.435436096
assert eme2k.shape.polar_radius_km == 6356.75
assert abs(eme2k.shape.flattening() - 0.0033536422844278) < 2e-16

epoch = Epoch("2021-10-29 12:34:56 TDB")

orig_state = Orbit.from_keplerian(
8_191.93,
1e-6,
12.85,
306.614,
314.19,
99.887_7,
epoch,
eme2k,
)

assert orig_state.sma_km() == 8191.93
assert orig_state.ecc() == 1.000000000361619e-06
assert orig_state.inc_deg() == 12.849999999999987
assert orig_state.raan_deg() == 306.614
assert orig_state.tlong_deg() == 0.6916999999999689

state_itrf93 = ctx.transform_to(
orig_state, Frames.EARTH_ITRF93, Aberration.NotSet
)

print(orig_state)
print(state_itrf93)

assert state_itrf93.geodetic_latitude_deg() == 10.549246868302738
assert state_itrf93.geodetic_longitude_deg() == 133.76889100913047
assert state_itrf93.geodetic_height_km() == 1814.503598063825

# Convert back
from_state_itrf93_to_eme2k = ctx.transform_to(
state_itrf93, Frames.EARTH_J2000, Aberration.NotSet
)

print(from_state_itrf93_to_eme2k)

assert orig_state == from_state_itrf93_to_eme2k

# Demo creation of a ground station
mean_earth_angular_velocity_deg_s = 0.004178079012116429
# Grab the loaded frame info
itrf93 = ctx.frame_info(Frames.EARTH_ITRF93)
paris = Orbit.from_latlongalt(
48.8566,
2.3522,
0.4,
mean_earth_angular_velocity_deg_s,
epoch,
itrf93,
)

assert abs(paris.geodetic_latitude_deg() - 48.8566) < 1e-3
assert abs(paris.geodetic_longitude_deg() - 2.3522) < 1e-3
assert abs(paris.geodetic_height_km() - 0.4) < 1e-3


if __name__ == "__main__":
test_state_transformation()

```

## Contributing

Contributions to ANISE are welcome! Whether it's in the form of feature requests, bug reports, code contributions, or documentation improvements, every bit of help is greatly appreciated.
Expand Down

0 comments on commit 4750fc8

Please sign in to comment.