Skip to content

Commit

Permalink
Switch from f32 to f64
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Feb 6, 2025
1 parent d54f6a8 commit f0f92be
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 133 deletions.
272 changes: 175 additions & 97 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ tonic = "0.7.2"
tokio = { version = "1.43.0", features = ["full"] }
prost = "0.10.4"
prost-types = "0.10"
olympian = "0.4.2"
olympian = {git = "https://github.com/intarga/olympian.git", branch = "64bit"}
# olympian = "0.4.2"
tracing = "0.1.16"
tracing-subscriber = { version = "0.3", features = ["tracing-log"] }
futures = "0.3.31"
Expand Down
2 changes: 1 addition & 1 deletion met_connectors/src/frost/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn json_to_data_cache(

Ok((Timeseries{tag:station_id, values:data}, location))
})
.collect::<Result<Vec<(Timeseries<Option<f32>>, FrostLatLonElev)>, Error>>()?;
.collect::<Result<Vec<(Timeseries<Option<f64>>, FrostLatLonElev)>, Error>>()?;

let lats = processed_ts_vec.iter().map(|ts| ts.1.latitude).collect();
let lons = processed_ts_vec.iter().map(|ts| ts.1.longitude).collect();
Expand Down
10 changes: 5 additions & 5 deletions met_connectors/src/frost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct Frost {
#[derive(Deserialize, Debug)]
struct FrostObsBody {
#[serde(deserialize_with = "des_value")]
value: f32,
value: f64,
}

// TODO: flatten this with FrostObsBody?
Expand All @@ -68,11 +68,11 @@ struct FrostObs {
struct FrostLatLonElev {
#[serde(rename = "elevation(masl/hs)")]
#[serde(deserialize_with = "des_value")]
elevation: f32,
elevation: f64,
#[serde(deserialize_with = "des_value")]
latitude: f32,
latitude: f64,
#[serde(deserialize_with = "des_value")]
longitude: f32,
longitude: f64,
}

#[derive(Deserialize, Debug)]
Expand All @@ -84,7 +84,7 @@ struct FrostLocation {
value: FrostLatLonElev,
}

fn des_value<'de, D>(deserializer: D) -> Result<f32, D::Error>
fn des_value<'de, D>(deserializer: D) -> Result<f64, D::Error>
where
D: Deserializer<'de>,
D::Error: serde::de::Error,
Expand Down
8 changes: 4 additions & 4 deletions met_connectors/src/lustre_netatmo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ pub struct LustreNetatmo;

#[derive(Debug, Deserialize)]
struct Record {
lat: f32,
lon: f32,
elev: f32,
value: f32,
lat: f64,
lon: f64,
elev: f64,
value: f64,
// Provider ID
// 1=WMO stations, 2=MET Non-WMO stations, 3=Netatmo, 4=Foreign WMO, 5=SVV, 6=Bergensværet, 7=FMI, 8=Luftambulansen, 9=Holfuy, 100=Radar precipitation
prid: u32,
Expand Down
4 changes: 2 additions & 2 deletions proto/rove.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ service Rove {
}

message GeoPoint {
float lat = 1;
float lon = 2;
double lat = 1;
double lon = 2;
}

message Polygon {
Expand Down
4 changes: 2 additions & 2 deletions src/data_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ impl TimeSpec {
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct GeoPoint {
/// latitude, in degrees
pub lat: f32,
pub lat: f64,
/// longitude, in degrees
pub lon: f32,
pub lon: f64,
}

/// A geospatial polygon
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ pub mod dev_utils {
self.data_len_spatial
],
(0..self.data_len_spatial)
.map(|i| ((i as f32).powi(2) * 0.001) % 3.)
.map(|i| ((i as f64).powi(2) * 0.001) % 3.)
.collect(),
(0..self.data_len_spatial)
.map(|i| ((i as f32 + 1.).powi(2) * 0.001) % 3.)
.map(|i| ((i as f64 + 1.).powi(2) * 0.001) % 3.)
.collect(),
vec![1.; self.data_len_spatial],
Timestamp(0),
Expand Down
38 changes: 19 additions & 19 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ impl CheckConf {
#[derive(Debug, Deserialize, PartialEq, Clone)]
#[allow(missing_docs)]
pub struct SpecialValueCheckConf {
pub special_values: Vec<f32>,
pub special_values: Vec<f64>,
}

/// See [`olympian::checks::single::range_check`]
#[derive(Debug, Deserialize, PartialEq, Clone)]
#[allow(missing_docs)]
pub struct RangeCheckConf {
pub max: f32,
pub min: f32,
pub max: f64,
pub min: f64,
}

// TODO: document this once we have a concrete impl to base docs on
Expand All @@ -102,14 +102,14 @@ pub struct RangeCheckDynamicConf {
#[derive(Debug, Deserialize, PartialEq, Clone)]
#[allow(missing_docs)]
pub struct StepCheckConf {
pub max: f32,
pub max: f64,
}

/// See [`olympian::checks::series::spike_check`]
#[derive(Debug, Deserialize, PartialEq, Clone)]
#[allow(missing_docs)]
pub struct SpikeCheckConf {
pub max: f32,
pub max: f64,
}

/// See [`olympian::checks::series::flatline_check`]
Expand All @@ -123,12 +123,12 @@ pub struct FlatlineCheckConf {
#[derive(Debug, Deserialize, PartialEq, Clone)]
#[allow(missing_docs)]
pub struct BuddyCheckConf {
pub radii: f32,
pub radii: f64,
pub min_buddies: u32,
pub threshold: f32,
pub max_elev_diff: f32,
pub elev_gradient: f32,
pub min_std: f32,
pub threshold: f64,
pub max_elev_diff: f64,
pub elev_gradient: f64,
pub min_std: f64,
pub num_iterations: u32,
}

Expand All @@ -138,16 +138,16 @@ pub struct BuddyCheckConf {
pub struct SctConf {
pub num_min: usize,
pub num_max: usize,
pub inner_radius: f32,
pub outer_radius: f32,
pub inner_radius: f64,
pub outer_radius: f64,
pub num_iterations: u32,
pub num_min_prof: usize,
pub min_elev_diff: f32,
pub min_horizontal_scale: f32,
pub vertical_scale: f32,
pub pos: f32,
pub neg: f32,
pub eps2: f32,
pub min_elev_diff: f64,
pub min_horizontal_scale: f64,
pub vertical_scale: f64,
pub pos: f64,
pub neg: f64,
pub eps2: f64,
pub obs_to_check: Option<Vec<bool>>,
}

Expand All @@ -157,7 +157,7 @@ pub struct SctConf {
pub struct ModelConsistencyCheckConf {
pub model_source: String,
pub model_args: String,
pub threshold: f32,
pub threshold: f64,
}

/// Errors relating to pipeline deserialization
Expand Down

0 comments on commit f0f92be

Please sign in to comment.