Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from f32 to f64 #99

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
346 changes: 147 additions & 199 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tonic = "0.7.2"
tokio = { version = "1.43.0", features = ["full"] }
prost = "0.10.4"
prost-types = "0.10"
olympian = "0.4.2"
olympian = "0.5.0"
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
14 changes: 7 additions & 7 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ pub async fn set_up_rove(
data_switch: DataSwitch,
pipelines: HashMap<String, Pipeline>,
) -> (impl Future<Output = ()>, RoveClient<Channel>) {
let coordintor_socket = NamedTempFile::new().unwrap();
let coordintor_socket = Arc::new(coordintor_socket.into_temp_path());
std::fs::remove_file(&*coordintor_socket).unwrap();
let coordintor_uds = UnixListener::bind(&*coordintor_socket).unwrap();
let coordintor_stream = UnixListenerStream::new(coordintor_uds);
let coordinator_socket = NamedTempFile::new().unwrap();
let coordinator_socket = Arc::new(coordinator_socket.into_temp_path());
std::fs::remove_file(&*coordinator_socket).unwrap();
let coordinator_uds = UnixListener::bind(&*coordinator_socket).unwrap();
let coordinator_stream = UnixListenerStream::new(coordinator_uds);
let coordinator_future = async {
start_server_unix_listener(coordintor_stream, data_switch, pipelines)
start_server_unix_listener(coordinator_stream, data_switch, pipelines)
.await
.unwrap();
};

let coordinator_channel = Endpoint::try_from("http://any.url")
.unwrap()
.connect_with_connector(service_fn(move |_: tonic::transport::Uri| {
let socket = Arc::clone(&coordintor_socket);
let socket = Arc::clone(&coordinator_socket);
async move { UnixStream::connect(&*socket).await }
}))
.await
Expand Down