Skip to content

Commit

Permalink
Add initial support for Spice Kernels of Type 10 - TLE (#72)
Browse files Browse the repository at this point in the history
* Add initial version of GenericSegments

* working up to a time conversion error

* tdb cast

* wip
  • Loading branch information
dahlend authored Jul 9, 2024
1 parent 8178651 commit 5ed67a8
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ serde = { version = "^1.0.203", features = ["derive"] }
nalgebra = {version = "^0.33.0"}
itertools = "^0.13.0"
rayon = "^1.10.0"
sgp4 = "2.2.0"

# bincode is pinned to ensure backward compatability with saved files, all updates to
# this version need to be validated that they are forward compatable.
Expand Down
2 changes: 2 additions & 0 deletions src/neospy/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ fn _core(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(spice::daf_header_info_py, m)?)?;
m.add_function(wrap_pyfunction!(spice::obs_codes, m)?)?;

m.add_function(wrap_pyfunction!(spice::load_tle, m)?)?;

m.add_function(wrap_pyfunction!(state_transition::compute_stm_py, m)?)?;

m.add_function(wrap_pyfunction!(fitting::ks_test_py, m)?)?;
Expand Down
2 changes: 2 additions & 0 deletions src/neospy/rust/spice/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod daf;
mod pck;
mod spk;
mod tle;

pub use daf::*;
pub use pck::*;
pub use spk::*;
pub use tle::*;

use pyo3::pyfunction;

Expand Down
10 changes: 10 additions & 0 deletions src/neospy/rust/spice/tle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use pyo3::pyfunction;

#[pyfunction]
#[pyo3(name = "load_tle")]
pub fn load_tle(line1: &str, line2: &str) {
let elm = sgp4::Elements::from_tle(None, line1.as_bytes(), line2.as_bytes()).unwrap();
dbg!("{}", elm.epoch());
let con = sgp4::Constants::from_elements(&elm).unwrap();
dbg!(con);
}
1 change: 1 addition & 0 deletions src/neospy_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rayon = "^1.10.0"
serde = { version = "^1.0.203", features = ["derive"] }
crossbeam = "^0.8.4"
chrono = "0.4.38"
sgp4 = "2.2.0"

# bincode is pinned to ensure backward compatability with saved files, all updates to
# this version need to be validated that they are forward compatable.
Expand Down
8 changes: 7 additions & 1 deletion src/neospy_core/src/spice/daf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use super::pck_segments::PckSegment;
use super::spk_segments::SpkSegment;

use crate::errors::NEOSpyError;
use std::fmt::Debug;
use std::io::{Cursor, Read, Seek};
use std::ops::Index;
use std::slice::SliceIndex;
Expand Down Expand Up @@ -268,7 +269,6 @@ impl DafFile {
///
/// Contents of the structure depends on specific file formats, however they are all
/// made up of floats.
#[derive(Debug)]
pub struct DafArray {
/// DafArray segment summary float information.
pub summary_floats: Box<[f64]>,
Expand All @@ -280,6 +280,12 @@ pub struct DafArray {
pub data: Box<[f64]>,
}

impl Debug for DafArray {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("DafArray({} values)", self.data.len()))
}
}

impl DafArray {
/// Try to load an SPK array from summary data
pub fn try_load_spk_array<T: Read + Seek>(
Expand Down
Loading

0 comments on commit 5ed67a8

Please sign in to comment.