Skip to content

Commit

Permalink
Several improvements (#210)
Browse files Browse the repository at this point in the history
* Improve context definitions and clock usage
* run clippy
* add more comments
* Production environment improvements
  * make parsing smarter
  * propose one method to enhance self, for files that would not follow standard naming conventions
  * add more tests

* introduce fops command line
* unlock one more reciprocal test
* fix help menu
* fixed SSI plot augmentation with SV attitude
* add example
* handle batch # in filename

---------

Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres authored Mar 12, 2024
1 parent e9f9838 commit 418ae3b
Show file tree
Hide file tree
Showing 39 changed files with 2,672 additions and 1,599 deletions.
1 change: 1 addition & 0 deletions rinex-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ geo-types = "0.7.11"
env_logger = "0.11"
rand = "0.8.4"
serde_json = "1"
lazy_static = "1.4"
thiserror = "1"
itertools = "0.12"
map_3d = "0.1.5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// filegen opmode
use clap::Command;
use clap::{
Command,
//ArgAction,
//value_parser,
};

use super::{SHARED_DATA_ARGS, SHARED_GENERAL_ARGS};

pub fn subcommand() -> Command {
Command::new("filegen")
Expand All @@ -10,4 +16,8 @@ pub fn subcommand() -> Command {
modify and dump resulting context in preserved RINEX format.
You can use this for example, to generate a decimated RINEX file from an input Observations file.",
)
.next_help_heading("Production Environment")
.args(SHARED_GENERAL_ARGS.iter())
.next_help_heading("Data context")
.args(SHARED_DATA_ARGS.iter())
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use clap::{value_parser, Arg, ArgAction, Command};
use std::path::PathBuf;

use super::{SHARED_DATA_ARGS, SHARED_GENERAL_ARGS};

pub fn subcommand() -> Command {
Command::new("merge")
.short_flag('m')
Expand All @@ -16,4 +18,8 @@ pub fn subcommand() -> Command {
.required(true)
.help("RINEX file to merge."),
)
.next_help_heading("Production Environment")
.args(SHARED_GENERAL_ARGS.iter())
.next_help_heading("Data context")
.args(SHARED_DATA_ARGS.iter())
}
82 changes: 82 additions & 0 deletions rinex-cli/src/cli/fops/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
pub mod filegen;
pub mod merge;
pub mod split;
pub mod substract;
pub mod time_binning;

use lazy_static::lazy_static;

use ::clap::{value_parser, Arg, ArgAction};

use rinex::prod::{DataSource, FFU, PPU};

/*
* Arguments that are shared by all file operations.
* Mainly [ProductionAttributes] (re)definition opts
*/
lazy_static! {
pub static ref SHARED_GENERAL_ARGS : Vec<Arg> = vec![
Arg::new("batch")
.short('b')
.long("batch")
.required(false)
.value_parser(value_parser!(u8))
.help("Set # (number ID) in case this file is part of a file serie"),
Arg::new("short")
.short('s')
.long("short")
.action(ArgAction::SetTrue)
.help("Prefer (deprecated) short filenames as historically used.
Otherwise, this ecosystem prefers modern (longer) filenames that contain more information."),
Arg::new("gzip")
.long("gzip")
.action(ArgAction::SetTrue)
.help("Append .gz suffix and perform seamless Gzip compression."),
Arg::new("agency")
.short('a')
.long("agency")
.required(false)
.help("Define a custom agency name, possibly overwriting
what the original filename did define (according to conventions)."),
Arg::new("country")
.short('c')
.long("country")
.required(false)
.help("Define a custom (3 letter) country code.
This code should represent where the Agency is located."),
Arg::new("source")
.long("src")
.required(false)
.value_name("[RCVR,STREAM]")
.value_parser(value_parser!(DataSource))
.help("Define the data source.
In RINEX standards, we use \"RCVR\" when data was sampled from a hardware receiver.
Use \"STREAM\" for other stream data source, like RTCM for example.")
];

pub static ref SHARED_DATA_ARGS : Vec<Arg> = vec![
Arg::new("PPU")
.long("ppu")
.required(false)
.value_name("[15M,01H,01D,01Y]")
.value_parser(value_parser!(PPU))
.help("Define custom production periodicity (time between two batch/dataset).
\"15M\": 15' interval, \"01H\": 1 hr interval, \"01D\": 1 day interval, \"01Y\": 1 year interval"),
Arg::new("FFU")
.long("ffu")
.required(false)
.value_name("DDU")
.value_parser(value_parser!(FFU))
.help("Define custom sampling interval.
Note that this only affects the filename to be generated, inner Record should match for consistency.
The sampling interval is the dominant time delta between two Epoch inside the record.
Format is \"DDU\" where DD must be (at most) two valid digits and U is the time Unit.
For example: \"30S\" for 30sec. interval, \"90S\" for 1'30s interval, \"20M\" for 20' interval, \"02H\" for 2hr interval, \"07D\" for weekly interval."),
Arg::new("region")
.long("region")
.value_name("[G]")
.help("Regional code, solely used in IONEX file name.
Use this to accurately (re)define your IONEX context that possibly did not follow standard naming conventions.
Use `G` for Global (World wide) TEC maps."),
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use clap::{value_parser, Arg, ArgAction, Command};
use rinex::prelude::Epoch;

use super::{SHARED_DATA_ARGS, SHARED_GENERAL_ARGS};

pub fn subcommand() -> Command {
Command::new("split")
.short_flag('s')
Expand All @@ -16,4 +18,8 @@ pub fn subcommand() -> Command {
.required(true)
.help("Epoch (instant) to split at."),
)
.next_help_heading("Production Environment")
.args(SHARED_GENERAL_ARGS.iter())
.next_help_heading("Data context")
.args(SHARED_DATA_ARGS.iter())
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use clap::{value_parser, Arg, ArgAction, Command};
use std::path::PathBuf;

use super::{SHARED_DATA_ARGS, SHARED_GENERAL_ARGS};

pub fn subcommand() -> Command {
Command::new("sub")
.long_flag("sub")
Expand All @@ -20,4 +22,8 @@ This is typically used to compare two GNSS receivers together.",
"RINEX(B) to substract to a single RINEX file (A), that was previously loaded.",
),
)
.next_help_heading("Production Environment")
.args(SHARED_GENERAL_ARGS.iter())
.next_help_heading("Data context")
.args(SHARED_DATA_ARGS.iter())
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use clap::{value_parser, Arg, ArgAction, Command};
use rinex::prelude::Duration;

use super::{SHARED_DATA_ARGS, SHARED_GENERAL_ARGS};

pub fn subcommand() -> Command {
Command::new("tbin")
.long_flag("tbin")
Expand All @@ -15,4 +17,8 @@ pub fn subcommand() -> Command {
.required(true)
.help("Duration"),
)
.next_help_heading("Production Environment")
.args(SHARED_GENERAL_ARGS.iter())
.next_help_heading("Data context")
.args(SHARED_DATA_ARGS.iter())
}
2 changes: 1 addition & 1 deletion rinex-cli/src/cli/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ or we post processed determined a CS.",
Arg::new("orbit")
.long("orbit")
.action(ArgAction::SetTrue)
.help("SV position in the sky, on 2D cartesian plots."),
.help("3D projection of SV attitudes in the sky."),
)
.arg(
Arg::new("orbit-residual")
Expand Down
17 changes: 6 additions & 11 deletions rinex-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,23 @@ use std::{
use clap::{value_parser, Arg, ArgAction, ArgMatches, ColorChoice, Command};
use rinex::prelude::*;

use crate::{fops::open_with_web_browser, Error};
use crate::fops::open_with_web_browser;

use map_3d::{geodetic2ecef, Ellipsoid};

// identification mode
mod identify;
// graph mode
mod graph;
// merge mode
mod merge;
// split mode
mod split;
// tbin mode
mod time_binning;
// substraction mode
mod substract;
// QC mode
mod qc;
// positioning mode
mod positioning;
// filegen mode
mod filegen;

// file operations
mod fops;

use fops::{filegen, merge, split, substract, time_binning};

pub struct Cli {
/// Arguments passed by user
Expand Down
Loading

0 comments on commit 418ae3b

Please sign in to comment.