Skip to content

Commit

Permalink
Merge pull request #36 from anise-toolkit/30-spice-bsp-files-should-b…
Browse files Browse the repository at this point in the history
…e-usable-without-needing-the-anise-file-equivalent

Read SPK files directly
  • Loading branch information
ChristopherRabotin authored Dec 3, 2022
2 parents c550dbd + 42c4862 commit 6d6d320
Show file tree
Hide file tree
Showing 119 changed files with 8,101 additions and 2,728 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
CSPICE_DIR = {value = "./cspice/", relative = true}
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data/*.bsp filter=lfs diff=lfs merge=lfs -text
data/earth_old_high_prec.bpc filter=lfs diff=lfs merge=lfs -text
data/*.bpc filter=lfs diff=lfs merge=lfs -text
data/de421.anise filter=lfs diff=lfs merge=lfs -text
data/de430.anise filter=lfs diff=lfs merge=lfs -text
data/de438s.anise filter=lfs diff=lfs merge=lfs -text
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Benchmarks

on:
push:
branches:
- master
tags:
- "*"
pull_request:
workflow_dispatch:

jobs:
type2_chebyshev:
name: JPL DE Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Bench
run: cargo bench --bench "*_jpl_ephemerides"

- name: Save benchmark artifacts
uses: actions/upload-artifact@v3
with:
name: jpl-development-ephemerides-benchmark
path: target/criterion/**/report/*

type13_hermite:
name: Hermite Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Bench
run: cargo bench --bench "*_spacecraft_ephemeris"

- name: Save benchmark artifacts
uses: actions/upload-artifact@v3
with:
name: spacecraft-ephemeris-benchmark
path: target/criterion/**/report/*
115 changes: 96 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ jobs:
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

spice-convert-and-test:
name: Converts SPICE BSP files into ANISE files and runs the tests
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -46,17 +49,8 @@ jobs:
toolchain: stable
override: true

- name: Build
run: cargo build --release

- name: Convert DE438s and verify every coefficient (slow)
run: cargo run --release -- convert ./data/de438s.bsp --check

- name: Convert DE421, DE430, DE440
run: |
cargo run --release -- convert ./data/de421.bsp
cargo run --release -- convert ./data/de430.bsp
cargo run --release -- convert ./data/de440.bsp
- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Test debug (default features) # This has overflow checks etc.
run: cargo test
Expand All @@ -70,12 +64,6 @@ jobs:
- name: Test (no default features and release)
run: cargo test --no-default-features --release

- name: Create DE ANISE artifacts # At this stage, all of the tests have passed, so let's store these artifacts
uses: actions/upload-artifact@v3
with:
name: anise-jpl-development-ephemerides
path: data/*.anise

lints:
name: Lints
runs-on: ubuntu-latest
Expand All @@ -102,3 +90,92 @@ jobs:
with:
command: clippy
args: -- -D warnings

validation:
name: Validation
runs-on: ubuntu-latest
needs: [check, test, lints]
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: CLI SPK
run: |
cargo run -- inspect data/gmat-hermite.bsp
cargo run -- inspect data/de440.bsp
- name: Rust-SPICE JPL DE validation
run: RUST_BACKTRACE=full RUST_LOG=debug cargo test validate_jplde_translation --features validation --release -- --nocapture

- name: Rust-SPICE hermite validation
run: RUST_BACKTRACE=full RUST_LOG=debug cargo test validate_hermite_translation --features validation --release -- --nocapture

# Now analyze the results and create pretty plots
- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Validation analysis
run: |
cd analysis
pip install -r requirements.txt
python spk_type2_jplde_val_err.py
python spk_type13_val_err.py
- name: Save validation artifacts
uses: actions/upload-artifact@v3
with:
name: validation-artifacts
path: target/*.html

coverage:
name: Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate coverage report
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov test --no-report --features=std -- --test-threads=1
cargo llvm-cov test --no-report --tests --features=std -- compile_fail
cargo llvm-cov report --lcov > lcov.txt
env:
RUSTFLAGS: --cfg __ui_tests

- name: Upload coverage report
uses: codecov/codecov-action@v3
env:
TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./lcov.txt
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/target
Cargo.lock
*.anis*
*.anis*
cspice
*.parquet
*.svg
perf.data*
analysis/.venv
cspice.tar.Z
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "specs"]
path = specs
url = https://github.com/anise-toolkit/specs.git
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "yapf"
}
5 changes: 5 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Authors

+ Christopher Rabotin <[email protected]>
+ Chris de Claverie <[email protected]>
+ Grégoire Henry <[email protected]>
41 changes: 35 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,49 @@ keywords = ["attitude","navigation","instrument", "spacecraft", "ephemeris"]
categories = ["science", "simulation"]
readme = "README.md"
license = "MPL-2.0"
exclude = ["cspice"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# hifitime = {version = "3.4.0", features = ["asn1der"]}
hifitime = {git = "https://github.com/nyx-space/hifitime", rev= "042599948499086ea4e854727eac885f6cab5d89"} # TODO: Switch to 3.4.1 when published.
memmap2 = "0.5.7"
hifitime = {version = "3.7.0", features = []}
memmap2 = "0.5.8"
crc32fast = "1.3.0"
der = {version = "0.6.0", features = ["derive", "alloc", "real"]}
# der = {version = "0.6.0", features = ["derive", "alloc", "real"]} # Disabled until DER is needed again.
clap = {version = "3.1", features = ["derive"]}
thiserror = "1.0"
log = "0.4"
pretty_env_logger = "0.4"
tabled = "0.8"
tabled = "0.10"
const_format = "0.2"
nalgebra = "0.31"
approx = "0.5.1"
approx = "0.5.1"
zerocopy = "0.6.1"

[dev-dependencies]
rust-spice = "0.7.4"
parquet = "25.0.0"
arrow = "25.0.0"
criterion = "0.3"
iai = "0.1"
polars = {version = "0.25", features = ["lazy", "parquet"]}

[features]
default = ["std"]
std = []
validation = [] # Enabling this flag significantly reduces compilation times due to Arrow and Polars.

[profile.bench]
debug = true

[[bench]]
name = "iai_jpl_ephemerides"
harness = false

[[bench]]
name = "crit_jpl_ephemerides"
harness = false

[[bench]]
name = "iai_spacecraft_ephemeris"
harness = false
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Solar System barycenter
# Development
## Requirements
1. `rustc` version `1.64` or higher (required for the 2021 edition): https://rust-lang.org/ (TODO: Set a minimum compatible rust version)
2. `git`
2. `git`
1. `rust-spice` is used for exhaustive testing of the SPICE interoperability. It requires the cspice library.
10 changes: 10 additions & 0 deletions analysis/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
hifitime==3.7.0
numpy==1.23.4
pandas==1.5.1
plotly==5.10.0
polars==0.14.21
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.5
six==1.16.0
tenacity==8.1.0
36 changes: 36 additions & 0 deletions analysis/spk_type13_val_err.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pandas as pd
import plotly.express as px
from os.path import abspath, join, dirname

if __name__ == '__main__':

target_folder = join(abspath(dirname(__file__)), '..', 'target')

for name, filename in [("validation", "type13-validation-test-results"),
("outliers", "type13-validation-outliers")]:

# Load the parquet file
df = pd.read_parquet(f"{target_folder}/{filename}.parquet")

if name == 'validation':
y = 'relative error'
else:
y = 'absolute error'

for kind, columns in [("Position", ["X", "Y", "Z"]),
("Velocity", ["VX", "VY", "VZ"])]:

print(f"== {kind} {name} ==")

subset = df.loc[df.component.isin(columns)]

print(subset.describe())

plt = px.scatter(subset,
x='File delta T (s)',
y=y,
color='source frame')

plt.write_html(
f"{target_folder}/{name}-{kind}-validation.html")
plt.show()
Loading

0 comments on commit 6d6d320

Please sign in to comment.