Skip to content

Commit

Permalink
test timescale validity, for both crinex and obsdata
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres committed Sep 29, 2023
1 parent 7786ff6 commit 7ae3d75
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
24 changes: 22 additions & 2 deletions rinex/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,30 @@ impl Header {
// <o repeated for each satellite system
// <o blank field when no corrections applied
} else if marker.contains("TIME OF FIRST OBS") {
let time_of_first_obs = Self::parse_time_of_obs(content)?;
let mut time_of_first_obs = Self::parse_time_of_obs(content)?;
match constellation {
Some(Constellation::Mixed) | None => {},
Some(c) => {
// in case of OLD RINEX : fixed constellation
// use that information, as it may be omitted in the TIME OF OBS header
time_of_first_obs.time_scale = c
.to_timescale()
.ok_or(ParsingError::TimescaleParsing(c.to_string()))?;
},
}
observation = observation.with_time_of_first_obs(time_of_first_obs);
} else if marker.contains("TIME OF LAST OBS") {
let time_of_last_obs = Self::parse_time_of_obs(content)?;
let mut time_of_last_obs = Self::parse_time_of_obs(content)?;
match constellation {
Some(Constellation::Mixed) | None => {},
Some(c) => {
// in case of OLD RINEX : fixed constellation
// use that information, as it may be omitted in the TIME OF OBS header
time_of_last_obs.time_scale = c
.to_timescale()
.ok_or(ParsingError::TimescaleParsing(c.to_string()))?;
},
}
observation = observation.with_time_of_last_obs(time_of_last_obs);
} else if marker.contains("TYPES OF OBS") {
// these observations can serve both Observation & Meteo RINEX
Expand Down
3 changes: 1 addition & 2 deletions rinex/src/observation/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ pub(crate) fn is_new_epoch(line: &str, v: Version) -> bool {
}
}

/// Builds `Record` entry for `ObservationData`
/// from given epoch content
/// Builds `Record` entry for `ObservationData` from given epoch content
pub(crate) fn parse_epoch(
header: &Header,
content: &str,
Expand Down
34 changes: 27 additions & 7 deletions rinex/src/tests/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,39 @@ mod test {
}
}
},
"OBS" => {
"CRNX" | "OBS" => {
assert!(rinex.header.obs.is_some());
let obs_header = rinex.header.obs.clone().unwrap();

assert!(rinex.is_observation_rinex());
assert!(rinex.epoch().count() > 0); // all files have content
assert!(rinex.observation().count() > 0); // all files have content
/*
* test interpreted time scale
* test timescale validity
*/
for ((e, _), _) in rinex.observation() {
let ts = e.time_scale;
if let Some(e0) = obs_header.time_of_first_obs {
assert!(
e0.time_scale == ts,
"interpreted wrong timescale: expecting \"{}\", got \"{}\"",
e0.time_scale,
ts
);
} else {
match rinex.header.constellation {
Some(Constellation::Mixed) | None => {}, // can't test
Some(c) => {
let timescale = c.to_timescale().unwrap();
assert!(ts == timescale,
"interpreted wrong timescale: expecting \"{}\", got \"{}\"",
timescale,
ts
);
},
}
}
}
/*
let gf = rinex.observation_gf_combinations();
let nl = rinex.observation_nl_combinations();
Expand All @@ -211,11 +236,6 @@ mod test {
assert_eq!(wl_combinations, mw_combinations);
*/
},
"CRNX" => {
assert!(rinex.header.obs.is_some());
assert!(rinex.is_observation_rinex());
assert!(rinex.epoch().count() > 0); // all files have content
},
"MET" => {
assert!(rinex.is_meteo_rinex());
assert!(rinex.epoch().count() > 0); // all files have content
Expand Down

0 comments on commit 7ae3d75

Please sign in to comment.