Struct sounding_base::Sounding
source · pub struct Sounding { /* private fields */ }
Expand description
All the variables stored in the sounding.
The upper air profile variables are stored in parallel vectors. If a profile lacks a certain variable, e.g. cloud fraction, that whole vector has length 0 instead of being full of missing values.
Implementations
sourceimpl Sounding
impl Sounding
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new sounding with default values. This is a proxy for default with a clearer name.
Examples
use sounding_base::Sounding;
let snd = Sounding::new();
println!("{:?}", snd);
sourcepub fn set_station_info(self, new_value: StationInfo) -> Self
pub fn set_station_info(self, new_value: StationInfo) -> Self
Set the station info.
Examples
use sounding_base::{Sounding, StationInfo};
let stn = StationInfo::new();
// set station values
let snd = Sounding::new()
.set_station_info(stn);
sourcepub fn get_station_info(&self) -> StationInfo
pub fn get_station_info(&self) -> StationInfo
Get the station info
Examples
use sounding_base::{Sounding, StationInfo};
let snd = make_test_sounding();
let stn: StationInfo = snd.get_station_info();
println!("{:?}", stn);
sourcepub fn set_profile(self, var: Profile, values: Vec<Optioned<f64>>) -> Self
pub fn set_profile(self, var: Profile, values: Vec<Optioned<f64>>) -> Self
Set a profile variable
Examples
extern crate optional;
use optional::some;
let p = vec![some(1000.0), some(925.0), some(850.0), some(700.0)];
let snd = Sounding::new()
.set_profile(Profile::Pressure, p);
println!("{:?}", snd);
sourcepub fn get_profile(&self, var: Profile) -> &[Optioned<f64>]
pub fn get_profile(&self, var: Profile) -> &[Optioned<f64>]
Get a profile variable as a slice
Examples
use sounding_base::{Sounding, Profile};
let snd = make_test_sounding();
let data = snd.get_profile(Profile::Pressure);
for p in data {
if p.is_some() {
println!("{:?}", p);
} else {
println!("missing value!");
}
}
sourcepub fn set_surface_value<T>(self, var: Surface, value: T) -> Selfwhere
Optioned<f64>: From<T>,
pub fn set_surface_value<T>(self, var: Surface, value: T) -> Selfwhere
Optioned<f64>: From<T>,
Set a surface variable
sourcepub fn get_surface_value(&self, var: Surface) -> Optioned<f64>
pub fn get_surface_value(&self, var: Surface) -> Optioned<f64>
Get a surface variable
sourcepub fn set_lead_time<T>(self, lt: T) -> Selfwhere
Optioned<i32>: From<T>,
pub fn set_lead_time<T>(self, lt: T) -> Selfwhere
Optioned<i32>: From<T>,
Difference in model initialization time and valid_time
in hours.
sourcepub fn get_lead_time(&self) -> Optioned<i32>
pub fn get_lead_time(&self) -> Optioned<i32>
Difference in model initialization time and valid_time
in hours.
sourcepub fn get_valid_time(&self) -> Option<NaiveDateTime>
pub fn get_valid_time(&self) -> Option<NaiveDateTime>
Valid time of the sounding
sourcepub fn set_valid_time<T>(self, valid_time: T) -> Selfwhere
Option<NaiveDateTime>: From<T>,
pub fn set_valid_time<T>(self, valid_time: T) -> Selfwhere
Option<NaiveDateTime>: From<T>,
Builder method to set the valid time of the sounding
sourcepub fn bottom_up<'a>(&'a self) -> impl Iterator<Item = DataRow> + 'a
pub fn bottom_up<'a>(&'a self) -> impl Iterator<Item = DataRow> + 'a
Get a bottom up iterator over the data rows. The first value returned from the iterator is surface values.
sourcepub fn top_down<'a>(&'a self) -> impl Iterator<Item = DataRow> + 'a
pub fn top_down<'a>(&'a self) -> impl Iterator<Item = DataRow> + 'a
Get a top down iterator over the data rows. The last value returned is the surface values.
sourcepub fn get_data_row(&self, idx: usize) -> Option<DataRow>
pub fn get_data_row(&self, idx: usize) -> Option<DataRow>
Get a row of data values from this sounding.
sourcepub fn surface_as_data_row(&self) -> DataRow
pub fn surface_as_data_row(&self) -> DataRow
Get the surface values in a DataRow
format.
sourcepub fn fetch_nearest_pnt(&self, target_p: f64) -> DataRow
pub fn fetch_nearest_pnt(&self, target_p: f64) -> DataRow
Given a target pressure, return the row of data values closest to this one.