Skip to content

Commit

Permalink
bump hifitime to v3.9.0 (#201)
Browse files Browse the repository at this point in the history
* bump hifitime to v3.9.0
* fixes standardized filename generator
* Bump clap as well

---------

Co-authored-by: Guillaume W. Bres <[email protected]>
Co-authored-by: Lars Næsbye Christensen <[email protected]>
  • Loading branch information
gwbres and larsnaesbye authored Jan 5, 2024
1 parent 0741e0e commit 6fabfdd
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 79 deletions.
4 changes: 2 additions & 2 deletions crx2rnx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ edition = "2021"
readme = "README.md"

[dependencies]
clap = { version = "4.4.10", features = ["derive", "color"] }
rinex = { path = "../rinex", version = "=0.15.4", features = ["serde"] }
clap = { version = "4.4.13", features = ["derive", "color"] }
rinex = { path = "../rinex", version = "=0.15.5", features = ["serde"] }
16 changes: 8 additions & 8 deletions rinex-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ map_3d = "0.1.5"
# ndarray = "0.15"
colorous = "1.0"
horrorshow = "0.8"
clap = { version = "4.4.11", features = ["derive", "color"] }
hifitime = { version = "3.8.4", features = ["serde", "std"] }
gnss-rs = { version = "2.1.2" , features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.4", features = ["full"] }
rinex-qc = { path = "../rinex-qc", version = "=0.1.9", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.6", features = ["serde", "flate2"] }
clap = { version = "4.4.13", features = ["derive", "color"] }
hifitime = { version = "3.9.0", features = ["serde", "std"] }
gnss-rs = { version = "2.1.3" , features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.5", features = ["full"] }
rinex-qc = { path = "../rinex-qc", version = "=0.1.10", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.7", features = ["serde", "flate2"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }

# plotly
plotly = "0.8.4"
# plotly = { git = "https://github.com/gwbres/plotly", branch = "density-mapbox" }

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

# cggtts
cggtts = { version = "4.1.2", features = ["serde", "scheduler"] }
cggtts = { version = "4.1.4", features = ["serde", "scheduler"] }
# cggtts = { git = "https://github.com/gwbres/cggtts", branch = "develop", features = ["serde", "scheduler"] }
# cggtts = { path = "../../cggtts/cggtts", features = ["serde", "scheduler"] }
10 changes: 5 additions & 5 deletions rinex-qc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rinex-qc"
version = "0.1.9"
version = "0.1.10"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "RINEX data analysis"
Expand All @@ -20,16 +20,16 @@ rustdoc-args = ["--cfg", "docrs", "--generate-link-to-definition"]

[dependencies]
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
hifitime = "3.8.4"
hifitime = "3.9.0"
strum = "0.25"
strum_macros = "0.25"
horrorshow = "0.8"
itertools = "0.12.0"
statrs = "0.16"
sp3 = { path = "../sp3", version = "=1.0.6", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.7", features = ["serde"] }
rinex-qc-traits = { path = "../qc-traits", version = "=0.1.1" }
rinex = { path = "../rinex", version = "=0.15.4", features = ["full"] }
gnss-rs = { version = "2.1.2", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.5", features = ["full"] }
gnss-rs = { version = "2.1.3", features = ["serde"] }

[dev-dependencies]
serde_json = "1"
8 changes: 4 additions & 4 deletions rinex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rinex"
version = "0.15.4"
version = "0.15.5"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "Package to parse and analyze RINEX data"
Expand Down Expand Up @@ -70,16 +70,16 @@ geo = { version = "0.27", 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 = { version = "3.8.4", features = ["serde", "std"] }
hifitime = { version = "3.9.0", features = ["serde", "std"] }
horrorshow = { version = "0.8", optional = true }
gnss-rs = { version = "2.1.2", features = ["serde"] }
gnss-rs = { version = "2.1.3", features = ["serde"] }

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

# RINEX Context dependencies
walkdir = { version = "2.4.0", optional = true }
sp3 = { path = "../sp3", version = "=1.0.6", optional = true }
sp3 = { path = "../sp3", version = "=1.0.7", optional = true }

[dev-dependencies]
serde_json = "1"
Expand Down
39 changes: 38 additions & 1 deletion rinex/src/epoch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::types::Type;
use hifitime::{Duration, Epoch, TimeScale};
use hifitime::{Duration, Epoch, TimeScale, Unit};
use std::str::FromStr;
use thiserror::Error;

Expand Down Expand Up @@ -254,10 +254,26 @@ pub(crate) fn parse_utc(s: &str) -> Result<(Epoch, EpochFlag), ParsingError> {
parse_in_timescale(s, TimeScale::UTC)
}

/*
* Until Hifitime provides a decomposition method in timescale other than UTC
* we have this tweak to decompose %Y %M %D %HH %MM %SS %NS
*/
pub(crate) fn epoch_decompose(e: Epoch) -> (i32, u8, u8, u8, u8, u8, u32) {
let ts = e.time_scale;
let offset = if ts.is_gnss() {
37 * Unit::Second
} else {
Duration::ZERO
};
(e + offset).to_gregorian_utc()
}

#[cfg(test)]
mod test {
use super::*;
use hifitime::Epoch;
use hifitime::TimeScale;
use std::str::FromStr;
#[test]
fn epoch_parse_nav_v2() {
let e = parse_utc("20 12 31 23 45 0.0");
Expand Down Expand Up @@ -580,4 +596,25 @@ mod test {
assert_eq!(ns, 0);
//assert_eq!(format!("{}", e), "2022 03 04 00 02 30.0000000 0");
}
#[test]
fn epoch_decomposition() {
for (epoch, y, m, d, hh, mm, ss, ns) in [
("2021-01-01T00:00:00 GPST", 2021, 1, 1, 0, 0, 0, 0),
("2021-01-01T00:00:01 GPST", 2021, 1, 1, 0, 0, 1, 0),
("2021-01-01T23:59:58 GPST", 2021, 1, 1, 23, 59, 58, 0),
("2021-01-01T23:59:59 GPST", 2021, 1, 1, 23, 59, 59, 0),
("2021-01-01T00:00:00 GST", 2021, 1, 1, 0, 0, 0, 0),
("2021-01-01T00:00:01 GST", 2021, 1, 1, 0, 0, 1, 0),
("2021-01-01T23:59:58 GST", 2021, 1, 1, 23, 59, 58, 0),
("2021-01-01T23:59:59 GST", 2021, 1, 1, 23, 59, 59, 0),
] {
let e = Epoch::from_str(epoch).unwrap();
assert_eq!(
epoch_decompose(e),
(y, m, d, hh, mm, ss, ns),
"failed for {}",
epoch
);
}
}
}
32 changes: 10 additions & 22 deletions rinex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use std::str::FromStr;
use thiserror::Error;

use antex::{Antenna, AntennaSpecific, FrequencyDependentData};
use epoch::epoch_decompose;
use ionex::TECPlane;
use observable::Observable;
use observation::Crinex;
Expand Down Expand Up @@ -426,15 +427,7 @@ impl Rinex {
Some(ref custom) => format!("{:03}", custom.doy),
None => {
if let Some(epoch) = self.first_epoch() {
//FIXME: hifitime release (DOY+GNSS)
let mut ddd = Epoch::from_duration(
epoch.to_duration_in_time_scale(TimeScale::UTC),
TimeScale::UTC,
)
.day_of_year()
.round() as u32
+ 1;
ddd %= 365;
let ddd = epoch.day_of_year().round() as u32;
format!("{:03}", ddd)
} else {
"DDD".to_string()
Expand All @@ -445,7 +438,8 @@ impl Rinex {
Some(ref custom) => format!("{:02}", custom.year - 2_000),
None => {
if let Some(epoch) = self.first_epoch() {
format!("{:02}", epoch.to_gregorian_utc().0 - 2_000)
let yy = epoch_decompose(epoch).0;
format!("{:02}", yy - 2_000)
} else {
"YY".to_string()
}
Expand All @@ -468,15 +462,7 @@ impl Rinex {
Some(ref custom) => format!("{:03}", custom.doy),
None => {
if let Some(epoch) = self.first_epoch() {
//FIXME: hifitime release (DOY+GNSS)
let mut ddd = Epoch::from_duration(
epoch.to_duration_in_time_scale(TimeScale::UTC),
TimeScale::UTC,
)
.day_of_year()
.round() as u32
+ 1;
ddd %= 365;
let ddd = epoch.day_of_year().round() as u32;
format!("{:03}", ddd)
} else {
"DDD".to_string()
Expand All @@ -488,7 +474,8 @@ impl Rinex {
Some(ref custom) => format!("{:02}", custom.year - 2_000),
None => {
if let Some(epoch) = self.first_epoch() {
format!("{:02}", epoch.to_gregorian_utc().0 - 2_000)
let yy = epoch_decompose(epoch).0;
format!("{:02}", yy - 2_000)
} else {
"YY".to_string()
}
Expand Down Expand Up @@ -550,7 +537,8 @@ impl Rinex {
Some(ref custom) => format!("{:04}", custom.year),
None => {
if let Some(epoch) = self.first_epoch() {
format!("{:04}", epoch.to_gregorian_utc().0)
let yy = epoch_decompose(epoch).0;
format!("{:04}", yy)
} else {
"YYYY".to_string()
}
Expand All @@ -566,7 +554,7 @@ impl Rinex {
},
None => {
if let Some(epoch) = self.first_epoch() {
let (_, _, _, hh, mm, _, _) = epoch.to_gregorian_utc();
let (_, _, _, hh, mm, _, _) = epoch_decompose(epoch);
(format!("{:02}", hh), format!("{:02}", mm))
} else {
("HH".to_string(), "MM".to_string())
Expand Down
51 changes: 22 additions & 29 deletions rinex/src/tests/filename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@ use std::path::Path;
// Test our standardized name generator does follow the specs
#[test]
fn short_filename_conventions() {
for (testfile, expected) in [
//FIXME: slightly wrong due to HIFITIME PB @ DOY(GNSS)
("OBS/V2/AJAC3550.21O", "AJAC3550.21O"),
("OBS/V2/rovn0010.21o", "ROVN0020.20O"),
// FIXME on next hifitime release
("OBS/V3/LARM0010.22O", "LARM0010.21O"),
// FIXME on next hifitime release
("OBS/V3/pdel0010.21o", "PDEL0020.20O"),
// FIXME on next hifitime release
("CRNX/V1/delf0010.21d", "DELF0020.20D"),
// FIXME on next hifitime release
("CRNX/V1/zegv0010.21d", "ZEGV0020.20D"),
// FIXME on next hifitime release
("CRNX/V3/DUTH0630.22D", "DUTH0630.22D"),
// FIXME on next hifitime release
("CRNX/V3/VLNS0010.22D", "VLNS0010.21D"),
("MET/V2/abvi0010.15m", "ABVI0010.15M"),
// FIXME on next hifitime release
("MET/V2/clar0020.00m", "CLAR0020.00M"),
for testfile in [
"OBS/V2/AJAC3550.21O",
"OBS/V2/rovn0010.21o",
"OBS/V3/LARM0010.22O",
"OBS/V3/pdel0010.21o",
"CRNX/V1/delf0010.21d",
"CRNX/V1/zegv0010.21d",
"CRNX/V3/DUTH0630.22D",
"CRNX/V3/VLNS0010.22D",
"MET/V2/abvi0010.15m",
"MET/V2/clar0020.00m",
] {
let fp = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("..")
Expand All @@ -31,11 +23,16 @@ fn short_filename_conventions() {

let rinex = Rinex::from_file(fp.to_string_lossy().as_ref()).unwrap();

let _actual_filename = fp.file_name().unwrap().to_string_lossy().to_string();
// these are all standard names: we only support uppercase formatting
let filename = fp
.file_name()
.unwrap()
.to_string_lossy()
.to_string()
.to_uppercase();

let output = rinex.standard_filename(true, None, None); // force short

assert_eq!(output, expected, "bad short filename generated");
assert_eq!(output, filename, "bad short filename generated");
}
}

Expand All @@ -45,17 +42,17 @@ fn long_filename_conventions() {
for (testfile, expected, custom_suffix) in [
(
"OBS/V3/ACOR00ESP_R_20213550000_01D_30S_MO.rnx",
"ACOR00ESP_R_20213552359_01D_30S_MO.rnx", //FIXME: hifitime DOY(GNSS)
"ACOR00ESP_R_20213550000_01D_30S_MO.rnx",
None,
),
(
"OBS/V3/ALAC00ESP_R_20220090000_01D_30S_MO.rnx",
"ALAC00ESP_R_20220092359_01D_13M_MO.rnx", //FIXME: hifitime DOY(GNSS)
"ALAC00ESP_R_20220090000_01D_13M_MO.rnx",
None,
),
(
"CRNX/V3/ESBC00DNK_R_20201770000_01D_30S_MO.crx.gz",
"ESBC00DNK_R_20201772359_01D_30S_MO.crx.gz", //FIXME: hifitime DOY(GNSS)
"ESBC00DNK_R_20201770000_01D_30S_MO.crx.gz",
Some(".gz"),
),
] {
Expand All @@ -65,10 +62,6 @@ fn long_filename_conventions() {
.join(testfile);

let rinex = Rinex::from_file(fp.to_string_lossy().as_ref()).unwrap();

//FIXME: hifitime DOY(GNSS) : use filename directly
let _standard_filename = fp.file_name().unwrap().to_string_lossy().to_string();

let output = rinex.standard_filename(false, custom_suffix, None);
assert_eq!(output, expected, "bad filename generated");
}
Expand Down
5 changes: 2 additions & 3 deletions rnx2crx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ edition = "2021"
readme = "README.md"

[dependencies]
chrono = "0.4"
thiserror = "1"
clap = { version = "4.4.10", features = ["derive", "color"] }
rinex = { path = "../rinex", version = "=0.15.4", features = ["serde"] }
clap = { version = "4.4.13", features = ["derive", "color"] }
rinex = { path = "../rinex", version = "=0.15.5", features = ["serde"] }
6 changes: 3 additions & 3 deletions sp3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sp3"
version = "1.0.6"
version = "1.0.7"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "IGS SP3 file parser"
Expand All @@ -24,8 +24,8 @@ rustdoc-args = ["--cfg", "docrs", "--generate-link-to-definition"]
[dependencies]
thiserror = "1"
map_3d = "0.1.5"
hifitime = "3.8.4"
gnss-rs = { version = "2.1.2", features = ["serde"] }
hifitime = "3.9.0"
gnss-rs = { version = "2.1.3", features = ["serde"] }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
flate2 = { version = "1.0.24", optional = true, default-features = false, features = ["zlib"] }

Expand Down
4 changes: 2 additions & 2 deletions ublox-rnx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ serde_json = "1.0"
serialport = "4.2.0"
ublox = "0.4.4"
clap = { version = "4.4.10", features = ["derive", "color"] }
gnss-rs = { version = "2.1.2", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.4", features = ["serde", "nav", "obs"] }
gnss-rs = { version = "2.1.3", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.5", features = ["serde", "nav", "obs"] }

0 comments on commit 6fabfdd

Please sign in to comment.