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

Switch to ANISE for ECEF (IAU Earth) computation #252

Merged
merged 7 commits into from
Jul 9, 2024
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
24 changes: 15 additions & 9 deletions rinex-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ description = "Command line tool parse and analyze RINEX data"
homepage = "https://github.com/georust/rinex"
repository = "https://github.com/georust/rinex"
keywords = ["rinex", "gps", "glonass", "galileo", "timing"]
categories = ["science", "science::geo", "command-line-interface", "command-line-utilities"]
categories = [
"science",
"science::geo",
"command-line-interface",
"command-line-utilities",
]
edition = "2021"
readme = "README.md"
rust-version = "1.64"
Expand All @@ -30,20 +35,21 @@ map_3d = "0.1.5"
colorous = "1.0"
horrorshow = "0.8"
clap = { version = "4.4.13", features = ["derive", "color"] }
hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master", features = ["serde", "std"] }
gnss-rs = { git = "https://github.com/rtk-rs/gnss", branch = "main", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.16.1", features = ["full"] }
plotly = { git = "https://github.com/plotly/plotly.rs", branch = "main" }
rinex-qc = { path = "../rinex-qc", version = "=0.1.14", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde", "flate2"] }

anise = "0.4.0"
gnss-rs = { version = "2.2.0", features = ["serde"] }
hifitime = { version = "4.0.0-alpha", features = ["serde", "std"] }

rinex = { path = "../rinex", version = "=0.16.1", features = ["full"] }
rinex-qc = { path = "../rinex-qc", version = "=0.1.14", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde", "flate2"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }

# solver
# gnss-rtk = { version = "0.4.5", features = ["serde"] }
# gnss-rtk = { path = "../../rtk-rs/gnss-rtk", features = ["serde"] }
gnss-rtk = { git = "https://github.com/rtk-rs/gnss-rtk", branch = "main", features = ["serde"] }

# cggtts
# cggtts = { version = "4.1.4", features = ["serde", "scheduler"] }
# cggtts = { path = "../../cggtts/cggtts", features = ["serde", "scheduler"] }
cggtts = { git = "https://github.com/gwbres/cggtts", branch = "dev", features = ["serde", "scheduler"] }
cggtts = { git = "https://github.com/gwbres/cggtts", branch = "main", features = ["serde", "scheduler"]}
56 changes: 17 additions & 39 deletions rinex-cli/src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,13 @@ pub fn build_timedomain_2y_plot(title: &str, y1_title: &str, y2_title: &str) ->
*/
pub fn build_default_polar_plot(title: &str) -> Plot {
let layout = Layout::new()
.title(Title::new(title))
.title(title)
.x_axis(
Axis::new()
.title(Title::new("Latitude [°]").side(Side::Top))
.zero_line(true), //.show_tick_labels(show_tick_labels)
//.dtick(dx_tick)
//.tick_format(tick_fmt)
)
.y_axis(
Axis::new()
.title(Title::new("Longitude [°]"))
.zero_line(true),
Axis::new().title("Latitude [°]").zero_line(true), //.show_tick_labels(show_tick_labels)
//.dtick(dx_tick)
//.tick_format(tick_fmt)
)
.y_axis(Axis::new().title("Longitude [°]").zero_line(true))
.show_legend(true)
.auto_size(true);
let mut p = Plot::new();
Expand All @@ -334,7 +328,7 @@ pub fn build_world_map(
) -> Plot {
let mut p = Plot::new();
let layout = Layout::new()
.title(Title::new(title).font(Font::default()))
.title(title)
.drag_mode(DragMode::Zoom)
.margin(Margin::new().top(0).left(0).bottom(0).right(0))
.show_legend(show_legend)
Expand Down Expand Up @@ -365,20 +359,16 @@ fn build_plot(
x_tick_fmt: &str,
) -> Plot {
let layout = Layout::new()
.title(Title::new(title).font(title_font))
.title(title)
.x_axis(
Axis::new()
.title(Title::new(x_axis_title).side(title_side))
.title(x_axis_title)
.zero_line(zero_line.0)
.show_tick_labels(show_xtick_labels)
.dtick(dx_tick)
.tick_format(x_tick_fmt),
)
.y_axis(
Axis::new()
.title(Title::new(y_axis_title))
.zero_line(zero_line.0),
)
.y_axis(Axis::new().title(y_axis_title).zero_line(zero_line.0))
.show_legend(show_legend)
.auto_size(auto_size);
let mut p = Plot::new();
Expand All @@ -401,23 +391,19 @@ fn build_plot_2y(
xtick_fmt: &str,
) -> Plot {
let layout = Layout::new()
.title(Title::new(title).font(title_font))
.title(title)
.x_axis(
Axis::new()
.title(Title::new(x_title).side(title_side))
.title(x_title)
.zero_line(zero_line.0)
.show_tick_labels(show_xtick_labels)
.dtick(dx_tick)
.tick_format(xtick_fmt),
)
.y_axis(
Axis::new()
.title(Title::new(y1_title))
.zero_line(zero_line.1),
)
.y_axis(Axis::new().title(y1_title).zero_line(zero_line.1))
.y_axis2(
Axis::new()
.title(Title::new(y2_title))
.title(y2_title)
.overlaying("y")
.side(AxisSide::Right)
.zero_line(zero_line.1),
Expand All @@ -441,23 +427,15 @@ fn build_3d_plot(
auto_size: bool,
) -> Plot {
let layout = Layout::new()
.title(Title::new(title).font(title_font))
.title(title)
.x_axis(
Axis::new()
.title(Title::new(x_title).side(title_side))
.title(x_title)
.zero_line(zero_line.0)
.show_tick_labels(false),
)
.y_axis(
Axis::new()
.title(Title::new(y_title))
.zero_line(zero_line.1),
)
.z_axis(
Axis::new()
.title(Title::new(z_title))
.zero_line(zero_line.2),
)
.y_axis(Axis::new().title(y_title).zero_line(zero_line.1))
.z_axis(Axis::new().title(z_title).zero_line(zero_line.2))
.show_legend(show_legend)
.auto_size(auto_size);
let mut p = Plot::new();
Expand Down
1 change: 1 addition & 0 deletions rinex-cli/src/positioning/orbit/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::cli::Context;
use gnss_rtk::prelude::{Epoch, InterpolationResult, SV};

// would you mind adapting the includes in ::sp3 ?
mod sp3;
use sp3::Orbit as SP3Orbit;

Expand Down
30 changes: 19 additions & 11 deletions rinex-cli/src/positioning/orbit/sp3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ use crate::{cli::Context, positioning::BufferTrait};
use std::collections::HashMap;

use gnss_rtk::prelude::{
Arc, Bodies, Cosm, Epoch, Frame, InterpolationResult as RTKInterpolationResult, LightTimeCalc,
TimeScale, Vector3, SV,
Almanac, Epoch, InterpolationResult as RTKInterpolationResult, TimeScale, Vector3, EARTH_J2000,
SPK, SUN_J2000, SV,
};

use rinex::carrier::Carrier;

use anise::almanac::metaload::MetaFile;

#[derive(Debug)]
struct Buffer {
inner: Vec<(Epoch, (f64, f64, f64))>,
Expand Down Expand Up @@ -49,13 +51,13 @@ impl BufferTrait<(f64, f64, f64)> for Buffer {
/*
* Evaluates Sun / Earth vector in meters ECEF at "t"
*/
fn sun_unit_vector(ref_frame: &Frame, cosmic: &Arc<Cosm>, t: Epoch) -> Vector3<f64> {
let sun_body = Bodies::Sun; // This only works in the solar system..
let orbit = cosmic.celestial_state(sun_body.ephem_path(), t, *ref_frame, LightTimeCalc::None);
fn sun_unit_vector(almanac: &Almanac, t: Epoch) -> Vector3<f64> {
let earth2sun = almanac.transform(EARTH_J2000, SUN_J2000, t, None).unwrap();

Vector3::new(
orbit.x_km * 1000.0,
orbit.y_km * 1000.0,
orbit.z_km * 1000.0,
earth2sun.radius_km.x * 1000.0,
earth2sun.radius_km.y * 1000.0,
earth2sun.radius_km.z * 1000.0,
)
}

Expand All @@ -68,9 +70,15 @@ pub struct Orbit<'a> {

impl<'a> Orbit<'a> {
pub fn from_ctx(ctx: &'a Context, order: usize) -> Self {
let cosmic = Cosm::de438();
let meta = MetaFile {
uri: "http://public-data.nyxspace.com/anise/v0.4/de440s.bsp".to_string(),
crc32: Some(3072159656), // Specifying the CRC allows only downloading the data once.
};
let almanac = Almanac::default()
.load_from_metafile(meta)
.unwrap_or_else(|e| panic!("failed to build Almanac: {}", e));

let sp3 = ctx.data.sp3().unwrap();
let earth_frame = cosmic.frame("EME2000"); // this only works on planet Earth..
Self {
order,
epochs: 0,
Expand All @@ -85,7 +93,7 @@ impl<'a> Orbit<'a> {
let k = -r_sat
/ (r_sat[0].powi(2) + r_sat[1].powi(2) + r_sat[3].powi(2)).sqrt();

let r_sun = sun_unit_vector(&earth_frame, &cosmic, t);
let r_sun = sun_unit_vector(&almanac, t);
let norm = ((r_sun[0] - r_sat[0]).powi(2)
+ (r_sun[1] - r_sat[1]).powi(2)
+ (r_sun[2] - r_sat[2]).powi(2))
Expand Down
12 changes: 6 additions & 6 deletions rinex-qc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ all-features = true
rustdoc-args = ["--cfg", "docrs", "--generate-link-to-definition"]

[dependencies]
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master" }
strum = "0.26"
strum_macros = "0.26"
statrs = "0.16"
horrorshow = "0.8"
itertools = "0.13.0"
statrs = "0.16"
strum_macros = "0.26"
hifitime = "4.0.0-alpha"

sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde"] }
rinex-qc-traits = { path = "../qc-traits", version = "=0.1.1" }
rinex = { path = "../rinex", version = "=0.16.1", features = ["full"] }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }

# gnss-rs = { version = "2.1.3", features = ["serde"] }
gnss-rs = { git = "https://github.com/rtk-rs/gnss", branch = "main", features = ["serde"] }
gnss-rs = { version = "2.2.0", features = ["serde"] }

[dev-dependencies]
serde_json = "1"
22 changes: 15 additions & 7 deletions rinex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ processing = []

# Unlock Quality Check (QC) methods and traits.
# Allows to generate complete QC reports for RINEX or entire contexts.
qc = ["rinex-qc-traits", "horrorshow"]
qc = ["rinex-qc-traits", "horrorshow"]

# Unlock SP3 support to be able to integrate SP3 precise orbits
# into a complete Context.
sp3 = ["dep:sp3", "walkdir"]
sp3 = ["dep:sp3", "walkdir"]

# Unlock all features, all at once
full = [
Expand Down Expand Up @@ -87,7 +87,7 @@ num-derive = "0.4"
num-traits = "0.2.15"
regex = "1"
thiserror = "1"
bitflags = { version = "2.3", features = ["serde"] }
bitflags = { version = "2.3", features = ["serde"] }
lazy_static = "1.4"
map_3d = "0.1.5"
strum = "0.26"
Expand All @@ -96,12 +96,20 @@ num-integer = "0.1.44"
itertools = "0.13.0"
geo = { version = "0.28", optional = true }
wkt = { version = "0.10.0", default-features = false, optional = true }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
flate2 = { version = "1.0.24", optional = true, default-features = false, features = ["zlib"] }
hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master", features = ["serde", "std"] }
serde = { version = "1.0", optional = true, default-features = false, features = [
"derive",
] }
flate2 = { version = "1.0.24", optional = true, default-features = false, features = [
"zlib",
] }
hifitime = { version = "4.0.0-alpha", features = [
"serde",
"std",
] }
horrorshow = { version = "0.8", optional = true }
nalgebra = { version = "0.32.3" }
gnss-rs = { git = "https://github.com/rtk-rs/gnss", branch = "main", features = ["serde"] }
gnss-rs = { version = "2.2.0", features = ["serde"] }
anise = { git = "https://github.com/nyx-space/anise.git", branch = "master" }

# RINEX QC dedicated traits
rinex-qc-traits = { path = "../qc-traits", version = "=0.1.1", optional = true }
Expand Down
Loading
Loading