Skip to content

Commit 7fd3ac5

Browse files
Switch to ANISE for ECEF (IAU Earth) computation (#252)
* Switch to ANISE for ECEF (IAU Earth) computation * In ephemeris, add the GM value based on the constellation. * hifitime=4.0.0-alpha upgrade * upgrade nyx tools --------- Signed-off-by: Guillaume W. Bres <[email protected]> Co-authored-by: Guillaume W. Bres <[email protected]>
1 parent 01143ef commit 7fd3ac5

File tree

10 files changed

+118
-244
lines changed

10 files changed

+118
-244
lines changed

rinex-cli/Cargo.toml

+15-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ description = "Command line tool parse and analyze RINEX data"
77
homepage = "https://github.com/georust/rinex"
88
repository = "https://github.com/georust/rinex"
99
keywords = ["rinex", "gps", "glonass", "galileo", "timing"]
10-
categories = ["science", "science::geo", "command-line-interface", "command-line-utilities"]
10+
categories = [
11+
"science",
12+
"science::geo",
13+
"command-line-interface",
14+
"command-line-utilities",
15+
]
1116
edition = "2021"
1217
readme = "README.md"
1318
rust-version = "1.64"
@@ -30,20 +35,21 @@ map_3d = "0.1.5"
3035
colorous = "1.0"
3136
horrorshow = "0.8"
3237
clap = { version = "4.4.13", features = ["derive", "color"] }
33-
hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master", features = ["serde", "std"] }
34-
gnss-rs = { git = "https://github.com/rtk-rs/gnss", branch = "main", features = ["serde"] }
35-
rinex = { path = "../rinex", version = "=0.16.1", features = ["full"] }
3638
plotly = { git = "https://github.com/plotly/plotly.rs", branch = "main" }
37-
rinex-qc = { path = "../rinex-qc", version = "=0.1.14", features = ["serde"] }
38-
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde", "flate2"] }
39+
40+
anise = "0.4.0"
41+
gnss-rs = { version = "2.2.0", features = ["serde"] }
42+
hifitime = { version = "4.0.0-alpha", features = ["serde", "std"] }
43+
44+
rinex = { path = "../rinex", version = "=0.16.1", features = ["full"] }
45+
rinex-qc = { path = "../rinex-qc", version = "=0.1.14", features = ["serde"] }
46+
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde", "flate2"] }
3947
serde = { version = "1.0", default-features = false, features = ["derive"] }
4048

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

46-
# cggtts
4753
# cggtts = { version = "4.1.4", features = ["serde", "scheduler"] }
4854
# cggtts = { path = "../../cggtts/cggtts", features = ["serde", "scheduler"] }
49-
cggtts = { git = "https://github.com/gwbres/cggtts", branch = "dev", features = ["serde", "scheduler"] }
55+
cggtts = { git = "https://github.com/gwbres/cggtts", branch = "main", features = ["serde", "scheduler"]}

rinex-cli/src/graph/mod.rs

+17-39
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,13 @@ pub fn build_timedomain_2y_plot(title: &str, y1_title: &str, y2_title: &str) ->
300300
*/
301301
pub fn build_default_polar_plot(title: &str) -> Plot {
302302
let layout = Layout::new()
303-
.title(Title::new(title))
303+
.title(title)
304304
.x_axis(
305-
Axis::new()
306-
.title(Title::new("Latitude [°]").side(Side::Top))
307-
.zero_line(true), //.show_tick_labels(show_tick_labels)
308-
//.dtick(dx_tick)
309-
//.tick_format(tick_fmt)
310-
)
311-
.y_axis(
312-
Axis::new()
313-
.title(Title::new("Longitude [°]"))
314-
.zero_line(true),
305+
Axis::new().title("Latitude [°]").zero_line(true), //.show_tick_labels(show_tick_labels)
306+
//.dtick(dx_tick)
307+
//.tick_format(tick_fmt)
315308
)
309+
.y_axis(Axis::new().title("Longitude [°]").zero_line(true))
316310
.show_legend(true)
317311
.auto_size(true);
318312
let mut p = Plot::new();
@@ -334,7 +328,7 @@ pub fn build_world_map(
334328
) -> Plot {
335329
let mut p = Plot::new();
336330
let layout = Layout::new()
337-
.title(Title::new(title).font(Font::default()))
331+
.title(title)
338332
.drag_mode(DragMode::Zoom)
339333
.margin(Margin::new().top(0).left(0).bottom(0).right(0))
340334
.show_legend(show_legend)
@@ -365,20 +359,16 @@ fn build_plot(
365359
x_tick_fmt: &str,
366360
) -> Plot {
367361
let layout = Layout::new()
368-
.title(Title::new(title).font(title_font))
362+
.title(title)
369363
.x_axis(
370364
Axis::new()
371-
.title(Title::new(x_axis_title).side(title_side))
365+
.title(x_axis_title)
372366
.zero_line(zero_line.0)
373367
.show_tick_labels(show_xtick_labels)
374368
.dtick(dx_tick)
375369
.tick_format(x_tick_fmt),
376370
)
377-
.y_axis(
378-
Axis::new()
379-
.title(Title::new(y_axis_title))
380-
.zero_line(zero_line.0),
381-
)
371+
.y_axis(Axis::new().title(y_axis_title).zero_line(zero_line.0))
382372
.show_legend(show_legend)
383373
.auto_size(auto_size);
384374
let mut p = Plot::new();
@@ -401,23 +391,19 @@ fn build_plot_2y(
401391
xtick_fmt: &str,
402392
) -> Plot {
403393
let layout = Layout::new()
404-
.title(Title::new(title).font(title_font))
394+
.title(title)
405395
.x_axis(
406396
Axis::new()
407-
.title(Title::new(x_title).side(title_side))
397+
.title(x_title)
408398
.zero_line(zero_line.0)
409399
.show_tick_labels(show_xtick_labels)
410400
.dtick(dx_tick)
411401
.tick_format(xtick_fmt),
412402
)
413-
.y_axis(
414-
Axis::new()
415-
.title(Title::new(y1_title))
416-
.zero_line(zero_line.1),
417-
)
403+
.y_axis(Axis::new().title(y1_title).zero_line(zero_line.1))
418404
.y_axis2(
419405
Axis::new()
420-
.title(Title::new(y2_title))
406+
.title(y2_title)
421407
.overlaying("y")
422408
.side(AxisSide::Right)
423409
.zero_line(zero_line.1),
@@ -441,23 +427,15 @@ fn build_3d_plot(
441427
auto_size: bool,
442428
) -> Plot {
443429
let layout = Layout::new()
444-
.title(Title::new(title).font(title_font))
430+
.title(title)
445431
.x_axis(
446432
Axis::new()
447-
.title(Title::new(x_title).side(title_side))
433+
.title(x_title)
448434
.zero_line(zero_line.0)
449435
.show_tick_labels(false),
450436
)
451-
.y_axis(
452-
Axis::new()
453-
.title(Title::new(y_title))
454-
.zero_line(zero_line.1),
455-
)
456-
.z_axis(
457-
Axis::new()
458-
.title(Title::new(z_title))
459-
.zero_line(zero_line.2),
460-
)
437+
.y_axis(Axis::new().title(y_title).zero_line(zero_line.1))
438+
.z_axis(Axis::new().title(z_title).zero_line(zero_line.2))
461439
.show_legend(show_legend)
462440
.auto_size(auto_size);
463441
let mut p = Plot::new();

rinex-cli/src/positioning/orbit/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::cli::Context;
22
use gnss_rtk::prelude::{Epoch, InterpolationResult, SV};
33

4+
// would you mind adapting the includes in ::sp3 ?
45
mod sp3;
56
use sp3::Orbit as SP3Orbit;
67

rinex-cli/src/positioning/orbit/sp3.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ use crate::{cli::Context, positioning::BufferTrait};
22
use std::collections::HashMap;
33

44
use gnss_rtk::prelude::{
5-
Arc, Bodies, Cosm, Epoch, Frame, InterpolationResult as RTKInterpolationResult, LightTimeCalc,
6-
TimeScale, Vector3, SV,
5+
Almanac, Epoch, InterpolationResult as RTKInterpolationResult, TimeScale, Vector3, EARTH_J2000,
6+
SPK, SUN_J2000, SV,
77
};
88

99
use rinex::carrier::Carrier;
1010

11+
use anise::almanac::metaload::MetaFile;
12+
1113
#[derive(Debug)]
1214
struct Buffer {
1315
inner: Vec<(Epoch, (f64, f64, f64))>,
@@ -49,13 +51,13 @@ impl BufferTrait<(f64, f64, f64)> for Buffer {
4951
/*
5052
* Evaluates Sun / Earth vector in meters ECEF at "t"
5153
*/
52-
fn sun_unit_vector(ref_frame: &Frame, cosmic: &Arc<Cosm>, t: Epoch) -> Vector3<f64> {
53-
let sun_body = Bodies::Sun; // This only works in the solar system..
54-
let orbit = cosmic.celestial_state(sun_body.ephem_path(), t, *ref_frame, LightTimeCalc::None);
54+
fn sun_unit_vector(almanac: &Almanac, t: Epoch) -> Vector3<f64> {
55+
let earth2sun = almanac.transform(EARTH_J2000, SUN_J2000, t, None).unwrap();
56+
5557
Vector3::new(
56-
orbit.x_km * 1000.0,
57-
orbit.y_km * 1000.0,
58-
orbit.z_km * 1000.0,
58+
earth2sun.radius_km.x * 1000.0,
59+
earth2sun.radius_km.y * 1000.0,
60+
earth2sun.radius_km.z * 1000.0,
5961
)
6062
}
6163

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

6971
impl<'a> Orbit<'a> {
7072
pub fn from_ctx(ctx: &'a Context, order: usize) -> Self {
71-
let cosmic = Cosm::de438();
73+
let meta = MetaFile {
74+
uri: "http://public-data.nyxspace.com/anise/v0.4/de440s.bsp".to_string(),
75+
crc32: Some(3072159656), // Specifying the CRC allows only downloading the data once.
76+
};
77+
let almanac = Almanac::default()
78+
.load_from_metafile(meta)
79+
.unwrap_or_else(|e| panic!("failed to build Almanac: {}", e));
80+
7281
let sp3 = ctx.data.sp3().unwrap();
73-
let earth_frame = cosmic.frame("EME2000"); // this only works on planet Earth..
7482
Self {
7583
order,
7684
epochs: 0,
@@ -85,7 +93,7 @@ impl<'a> Orbit<'a> {
8593
let k = -r_sat
8694
/ (r_sat[0].powi(2) + r_sat[1].powi(2) + r_sat[3].powi(2)).sqrt();
8795

88-
let r_sun = sun_unit_vector(&earth_frame, &cosmic, t);
96+
let r_sun = sun_unit_vector(&almanac, t);
8997
let norm = ((r_sun[0] - r_sat[0]).powi(2)
9098
+ (r_sun[1] - r_sat[1]).powi(2)
9199
+ (r_sun[2] - r_sat[2]).powi(2))

rinex-qc/Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ all-features = true
1919
rustdoc-args = ["--cfg", "docrs", "--generate-link-to-definition"]
2020

2121
[dependencies]
22-
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
23-
hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master" }
2422
strum = "0.26"
25-
strum_macros = "0.26"
23+
statrs = "0.16"
2624
horrorshow = "0.8"
2725
itertools = "0.13.0"
28-
statrs = "0.16"
26+
strum_macros = "0.26"
27+
hifitime = "4.0.0-alpha"
28+
2929
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde"] }
3030
rinex-qc-traits = { path = "../qc-traits", version = "=0.1.1" }
3131
rinex = { path = "../rinex", version = "=0.16.1", features = ["full"] }
32+
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
3233

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

3636
[dev-dependencies]
3737
serde_json = "1"

rinex/Cargo.toml

+15-7
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ processing = []
4949

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

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

5858
# Unlock all features, all at once
5959
full = [
@@ -87,7 +87,7 @@ num-derive = "0.4"
8787
num-traits = "0.2.15"
8888
regex = "1"
8989
thiserror = "1"
90-
bitflags = { version = "2.3", features = ["serde"] }
90+
bitflags = { version = "2.3", features = ["serde"] }
9191
lazy_static = "1.4"
9292
map_3d = "0.1.5"
9393
strum = "0.26"
@@ -96,12 +96,20 @@ num-integer = "0.1.44"
9696
itertools = "0.13.0"
9797
geo = { version = "0.28", optional = true }
9898
wkt = { version = "0.10.0", default-features = false, optional = true }
99-
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
100-
flate2 = { version = "1.0.24", optional = true, default-features = false, features = ["zlib"] }
101-
hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master", features = ["serde", "std"] }
99+
serde = { version = "1.0", optional = true, default-features = false, features = [
100+
"derive",
101+
] }
102+
flate2 = { version = "1.0.24", optional = true, default-features = false, features = [
103+
"zlib",
104+
] }
105+
hifitime = { version = "4.0.0-alpha", features = [
106+
"serde",
107+
"std",
108+
] }
102109
horrorshow = { version = "0.8", optional = true }
103110
nalgebra = { version = "0.32.3" }
104-
gnss-rs = { git = "https://github.com/rtk-rs/gnss", branch = "main", features = ["serde"] }
111+
gnss-rs = { version = "2.2.0", features = ["serde"] }
112+
anise = { git = "https://github.com/nyx-space/anise.git", branch = "master" }
105113

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

0 commit comments

Comments
 (0)