Skip to content

Commit

Permalink
code multipath and other combinations
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres committed Nov 26, 2023
1 parent 3d25876 commit 74d3c2c
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 239 deletions.
44 changes: 17 additions & 27 deletions rinex-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod positioning;
//use horrorshow::Template;
use rinex::{
merge::Merge,
observation::{Combine, Dcb},
observation::{Combination, Combine, Dcb},
prelude::*,
split::Split,
};
Expand Down Expand Up @@ -162,29 +162,23 @@ fn naviplot_allowed(ctx: &RnxContext, cli: &Cli) -> bool {
* Plots requested combinations
*/
fn plot_combinations(obs: &Rinex, cli: &Cli, plot_ctx: &mut PlotContext) {
if cli.dcb() {
let data = obs.dcb();
plot::plot_gnss_dcb(
plot_ctx,
"Differential Code Biases",
"Differential Code Bias [s]",
&data,
);
info!("dcb analysis");
}
//if cli.multipath() {
// let data = rnx
// .dcb();
//if cli.dcb() {
// let data = obs.dcb();
// plot::plot_gnss_dcb(
// &mut plot_ctx,
// "Code Multipath",
// "Meters of delay",
// plot_ctx,
// "Differential Code Biases",
// "Differential Code Bias [s]",
// &data,
// );
// info!("multipath analysis");
// info!("dcb analysis");
//}
if cli.multipath() {
let data = obs.code_multipath();
plot::plot_gnss_dcb_mp(&data, plot_ctx, "Code Multipath", "Meters of delay");
info!("code multipath analysis");
}
if cli.if_combination() {
let data = obs.iono_free();
let data = obs.combine(Combination::IonosphereFree);
plot::plot_gnss_combination(
&data,
plot_ctx,
Expand All @@ -194,7 +188,7 @@ fn plot_combinations(obs: &Rinex, cli: &Cli, plot_ctx: &mut PlotContext) {
info!("iono free combination");
}
if cli.gf_combination() {
let data = obs.geo_free();
let data = obs.combine(Combination::GeometryFree);
plot::plot_gnss_combination(
&data,
plot_ctx,
Expand All @@ -204,12 +198,12 @@ fn plot_combinations(obs: &Rinex, cli: &Cli, plot_ctx: &mut PlotContext) {
info!("geo free combination");
}
if cli.wl_combination() {
let data = obs.wide_lane();
let data = obs.combine(Combination::WideLane);
plot::plot_gnss_combination(&data, plot_ctx, "Wide Lane combination", "Meters of delay");
info!("wide lane combination");
}
if cli.nl_combination() {
let data = obs.narrow_lane();
let data = obs.combine(Combination::NarrowLane);
plot::plot_gnss_combination(
&data,
plot_ctx,
Expand All @@ -219,7 +213,7 @@ fn plot_combinations(obs: &Rinex, cli: &Cli, plot_ctx: &mut PlotContext) {
info!("wide lane combination");
}
if cli.mw_combination() {
let data = obs.melbourne_wubbena();
let data = obs.combine(Combination::MelbourneWubbena);
plot::plot_gnss_combination(
&data,
plot_ctx,
Expand Down Expand Up @@ -253,10 +247,6 @@ pub fn main() -> Result<(), Error> {
warn!("position solver currently turned off");
}

if cli.multipath() {
warn!("--mp analysis not available yet");
}

// Initiate plot context
let mut plot_ctx = PlotContext::new();

Expand Down
6 changes: 3 additions & 3 deletions rinex-cli/src/plot/combination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ pub fn plot_gnss_combination(
/*
* Plot DCB analysis
*/
pub fn plot_gnss_dcb(
pub fn plot_gnss_dcb_mp(
data: &HashMap<Observable, BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>,
plot_context: &mut PlotContext,
plot_title: &str,
y_title: &str,
data: &HashMap<String, BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>,
) {
// add a plot
plot_context.add_cartesian2d_plot(plot_title, y_title);
Expand All @@ -57,7 +57,7 @@ pub fn plot_gnss_dcb(
for (_sv, epochs) in vehicles {
let data_x: Vec<Epoch> = epochs.iter().map(|((e, _flag), _v)| *e).collect();
let data_y: Vec<f64> = epochs.iter().map(|(_, v)| *v).collect();
let trace = build_chart_epoch_axis(op, Mode::Markers, data_x, data_y)
let trace = build_chart_epoch_axis(&op.to_string()[1..], Mode::Markers, data_x, data_y)
.marker(Marker::new().symbol(markers[op_index].clone()))
.visible({
if op_index < 2 {
Expand Down
2 changes: 1 addition & 1 deletion rinex-cli/src/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod naviplot;
pub use naviplot::naviplot;

mod combination;
pub use combination::{plot_gnss_combination, plot_gnss_dcb};
pub use combination::{plot_gnss_combination, plot_gnss_dcb_mp};

/*
* Generates N marker symbols to be used
Expand Down
77 changes: 16 additions & 61 deletions rinex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ impl Rinex {
// use std::str::FromStr;

#[cfg(feature = "obs")]
use crate::observation::{LliFlags, SNR};
use crate::observation::{record::code_multipath, LliFlags, SNR};

/*
* OBS RINEX specific methods: only available on crate feature.
Expand Down Expand Up @@ -2075,26 +2075,16 @@ impl Rinex {
.filter(|(_sv, list)| !list.is_empty()),
)
}
/// Returns Multipath bias estimates, per (unique) signal combination
/// and SV. Refer to [Bibliography::ESABookVol1] and [Bibliography::MpTaoglas].
fn multipath(&self) -> HashMap<String, BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
todo!("NOT DONE");
// let mut ret : HashMap<String, BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> = HashMap::new();
// let iono_free = self.iono_free();
// for ((lhs_code, rhs_code), code_if) in &iono_free {
// if !lhs_code.is_pseudorange_observable() {
// continue ;
// }
// // find similar IONO FREE PHASE comb.
// let lhs_phase_obs = Observable::from_str(&format!("L{}", &lhs_code.to_string()[1..])).unwrap();
// let rhs_phase_obs = Observable::from_str(&format!("L{}", &rhs_code.to_string()[1..])).unwrap();
// let phase_if = iono_free.get(&(lhs_phase_obs, rhs_phase_obs));
// if phase_if.is_none() {
// continue ;
// }

// }
// ret
/// Returns Code Multipath bias estimates, for sampled code combination and per SV.
/// Refer to [Bibliography::ESABookVol1] and [Bibliography::MpTaoglas].
pub fn code_multipath(
&self,
) -> HashMap<Observable, BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
code_multipath(r)
} else {
HashMap::new()
}
}
}

Expand Down Expand Up @@ -3100,54 +3090,19 @@ impl Dcb for Rinex {
//}

#[cfg(feature = "obs")]
use observation::Combine;
use observation::{Combination, Combine};

#[cfg(feature = "obs")]
#[cfg_attr(docrs, doc(cfg(feature = "obs")))]
impl Combine for Rinex {
fn geo_free(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
r.geo_free()
} else {
panic!("wrong RINEX type");
}
}
fn iono_free(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
r.iono_free()
} else {
panic!("wrong RINEX type");
}
}
fn wide_lane(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
r.wide_lane()
} else {
panic!("wrong RINEX type");
}
}
fn narrow_lane(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
r.narrow_lane()
} else {
panic!("wrong RINEX type");
}
}
fn melbourne_wubbena(
fn combine(
&self,
c: Combination,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
r.melbourne_wubbena()
r.combine(c)
} else {
panic!("wrong RINEX type");
HashMap::new()
}
}
}
Expand Down
67 changes: 14 additions & 53 deletions rinex/src/observation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,66 +149,27 @@ impl HeaderFields {
#[cfg(feature = "obs")]
use std::collections::BTreeMap;

/// GNSS signal recombination trait.
/// Import this to recombine OBS RINEX with usual recombination methods.
#[cfg(feature = "obs")]
#[cfg_attr(docrs, doc(cfg(feature = "obs")))]
#[derive(Debug, Copy, Clone)]
pub enum Combination {
GeometryFree,
IonosphereFree,
WideLane,
NarrowLane,
MelbourneWubbena,
}

/// GNSS signal combination trait.
/// This only applies to OBS RINEX records.
/// Refer to [Bibliography::ESAGnssCombination] and [Bibliography::ESABookVol1]
/// for more information.
#[cfg(feature = "obs")]
#[cfg_attr(docrs, doc(cfg(feature = "obs")))]
pub trait Combine {
/// Perform Geometry Free signal recombination on all phase
/// and pseudo range observations, for each individual SV
/// and individual Epoch.
/// Geometry Free (Gf) recombination cancels out geometric
/// biases and leaves frequency dependent terms out,
/// like Ionospheric induced time delay.
/// ```
/// use rinex::prelude::*;
/// use rinex::observation::*;
///
/// let rinex = Rinex::from_file("../test_resources/OBS/V3/DUTH0630.22O")
/// .unwrap();
///
/// let gf = rinex.geo_free();
/// for ((ref_observable, rhs_observable), data) in gf {
/// // for each recombination that we were able to form,
/// // a "reference" observable was chosen,
/// // and RHS observable is compared to it.
/// // For example "L2C-L1C" : L1C is the reference observable
/// for (sv, epochs) in data {
/// // applied to all possible SV
/// for ((epoch, _flag), value) in epochs {
/// // value: actual recombination result
/// }
/// }
/// }
/// ```
fn geo_free(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>;

/// Iono free combination
fn iono_free(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>;

/// Perform Wide Lane recombination.
/// See [Self::geo_free] for API example.
fn wide_lane(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>;

/// Perform Narrow Lane recombination.
/// See [Self::geo_free] for API example.
fn narrow_lane(
&self,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>;

/// Perform Melbourne-Wübbena recombination.
/// See [`Self::geo_free`] for API example.
fn melbourne_wubbena(
fn combine(
&self,
combination: Combination,
) -> HashMap<(Observable, Observable), BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>>;
}

Expand Down
Loading

0 comments on commit 74d3c2c

Please sign in to comment.