Skip to content

Commit

Permalink
Merge pull request #384 from nyx-space/feat/gh-380-tdm-kvn-support
Browse files Browse the repository at this point in the history
Add CCSDS TDM v 2.0 import/export
  • Loading branch information
ChristopherRabotin authored Dec 14, 2024
2 parents 16c4448 + 442cc4f commit 12ad184
Show file tree
Hide file tree
Showing 14 changed files with 707 additions and 391 deletions.
215 changes: 0 additions & 215 deletions .github/workflows/python.yml

This file was deleted.

4 changes: 2 additions & 2 deletions data/tests/config/tracking_cfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Demo ground station:
cadence: Continuous
min_samples: 10
sample_alignment: null
sampling: 1 min
sampling: 1 s

Canberra:
scheduler:
handoff: Eager
cadence: Continuous
min_samples: 10
sample_alignment: 10 s
sampling: 1 min
sampling: 1 s
10 changes: 8 additions & 2 deletions examples/04_lro_od/plot_msr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import click
import polars as pl
import plotly.express as px

if __name__ == "__main__":
df = pl.read_parquet("./04_lro_simulated_tracking.parquet")
@click.command
@click.option("-p", "--path", type=str, default="./04_lro_simulated_tracking.parquet")
def main(path: str):
df = pl.read_parquet(path)

df = df.with_columns(pl.col("Epoch (UTC)").str.to_datetime("%Y-%m-%dT%H:%M:%S%.f")).sort(
"Epoch (UTC)", descending=False
Expand All @@ -21,3 +24,6 @@
# Plot each measurement kind
for msr_col_name in ["Range (km)", "Doppler (km/s)"]:
px.scatter(df, x="Epoch (UTC)", y=msr_col_name, color="Tracking device").show()

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub enum InputOutputError {
},
#[snafu(display("missing required data {which}"))]
MissingData { which: String },
#[snafu(display("unknown data column `{which}`"))]
#[snafu(display("unknown data `{which}`"))]
UnsupportedData { which: String },
#[snafu(display("{action} encountered a Parquet error: {source}"))]
ParquetError {
Expand Down
2 changes: 1 addition & 1 deletion src/io/watermark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ pub(crate) fn pq_writer(metadata: Option<HashMap<String, String>>) -> Option<Wri
}

pub(crate) fn prj_name_ver() -> String {
format!("Nyx v{}", build::PKG_VERSION)
format!("Nyx Space v{}", build::PKG_VERSION)
}
38 changes: 22 additions & 16 deletions src/md/trajectory/sc_traj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,19 @@ impl Traj<Spacecraft> {

// Write mandatory metadata
writeln!(writer, "CCSDS_OMM_VERS = 2.0").map_err(err_hdlr)?;

writeln!(
writer,
"COMMENT Built by {} -- https://nyxspace.com/\n",
prj_name_ver()
)
.map_err(err_hdlr)?;
writeln!(
writer,
"COMMENT Nyx Space provided under the AGPL v3 open source license -- https://nyxspace.com/pricing\n"
)
.map_err(err_hdlr)?;

writeln!(
writer,
"CREATION_DATE = {}",
Expand All @@ -350,9 +363,9 @@ impl Traj<Spacecraft> {
writeln!(writer, "META_START").map_err(err_hdlr)?;
// Write optional metadata
if let Some(object_name) = metadata.get("object_name") {
writeln!(writer, "OBJECT_NAME = {}", object_name).map_err(err_hdlr)?;
writeln!(writer, "\tOBJECT_NAME = {}", object_name).map_err(err_hdlr)?;
} else if let Some(object_name) = &self.name {
writeln!(writer, "OBJECT_NAME = {}", object_name).map_err(err_hdlr)?;
writeln!(writer, "\tOBJECT_NAME = {}", object_name).map_err(err_hdlr)?;
}

let first_orbit = states[0].orbit;
Expand All @@ -369,52 +382,45 @@ impl Traj<Spacecraft> {
let ref_frame = frame_str.replace(center, " ");
writeln!(
writer,
"REF_FRAME = {}",
"\tREF_FRAME = {}",
match ref_frame.trim() {
"J2000" => "ICRF",
_ => ref_frame.trim(),
}
)
.map_err(err_hdlr)?;

writeln!(writer, "CENTER_NAME = {center}",).map_err(err_hdlr)?;
writeln!(writer, "\tCENTER_NAME = {center}",).map_err(err_hdlr)?;

writeln!(writer, "TIME_SYSTEM = {}", first_orbit.epoch.time_scale).map_err(err_hdlr)?;
writeln!(writer, "\tTIME_SYSTEM = {}", first_orbit.epoch.time_scale).map_err(err_hdlr)?;

writeln!(
writer,
"START_TIME = {}",
"\tSTART_TIME = {}",
Formatter::new(states[0].epoch(), iso8601_no_ts)
)
.map_err(err_hdlr)?;
writeln!(
writer,
"USEABLE_START_TIME = {}",
"\tUSEABLE_START_TIME = {}",
Formatter::new(states[0].epoch(), iso8601_no_ts)
)
.map_err(err_hdlr)?;
writeln!(
writer,
"USEABLE_STOP_TIME = {}",
"\tUSEABLE_STOP_TIME = {}",
Formatter::new(states[states.len() - 1].epoch(), iso8601_no_ts)
)
.map_err(err_hdlr)?;
writeln!(
writer,
"STOP_TIME = {}",
"\tSTOP_TIME = {}",
Formatter::new(states[states.len() - 1].epoch(), iso8601_no_ts)
)
.map_err(err_hdlr)?;

writeln!(writer, "META_STOP\n").map_err(err_hdlr)?;

writeln!(
writer,
"COMMENT Generated by {} provided in AGPLv3 license -- https://nyxspace.com/\n",
prj_name_ver()
)
.map_err(err_hdlr)?;

for sc_state in &states {
let state = sc_state.orbit;
writeln!(
Expand Down
7 changes: 3 additions & 4 deletions src/od/msr/measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

use super::MeasurementType;
use hifitime::Epoch;
use indexmap::IndexSet;
use indexmap::{IndexMap, IndexSet};
use nalgebra::{allocator::Allocator, DefaultAllocator, DimName, OVector};
use std::collections::HashMap;
use std::fmt;

/// A type-agnostic simultaneous measurement storage structure. Allows storing any number of simultaneous measurement of a given taker.
Expand All @@ -31,15 +30,15 @@ pub struct Measurement {
/// Epoch of the measurement
pub epoch: Epoch,
/// All measurements made simultaneously
pub data: HashMap<MeasurementType, f64>,
pub data: IndexMap<MeasurementType, f64>,
}

impl Measurement {
pub fn new(tracker: String, epoch: Epoch) -> Self {
Self {
tracker,
epoch,
data: HashMap::new(),
data: IndexMap::new(),
}
}

Expand Down
Loading

0 comments on commit 12ad184

Please sign in to comment.