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§
Source§impl 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_analysis::Sounding;
let snd = Sounding::new();
println!("{:?}", snd);
Sourcepub fn with_source_description<S>(self, desc: S) -> Self
pub fn with_source_description<S>(self, desc: S) -> Self
Add a source description to this sounding.
§Examples
use sounding_analysis::Sounding;
let snd = Sounding::new().with_source_description("An empty sounding.".to_owned());
let snd = snd.with_source_description(
Some("Still empty, just added a description.".to_owned()),
);
let _snd = snd.with_source_description(None);
Sourcepub fn source_description(&self) -> Option<&str>
pub fn source_description(&self) -> Option<&str>
Retrieve a source description for this sounding.
§Examples
use sounding_analysis::Sounding;
let snd = Sounding::new().with_source_description("An empty sounding.".to_owned());
assert_eq!(snd.source_description().unwrap(), "An empty sounding.");
let snd = snd.with_source_description(None);
assert!(snd.source_description().is_none());
Sourcepub fn with_station_info(self, new_value: StationInfo) -> Self
pub fn with_station_info(self, new_value: StationInfo) -> Self
Builder function for setting the station info.
§Examples
use sounding_analysis::{Sounding, StationInfo};
let stn = StationInfo::new();
let _snd = Sounding::new().with_station_info(stn);
Sourcepub fn station_info(&self) -> &StationInfo
pub fn station_info(&self) -> &StationInfo
Get the station info
§Examples
use sounding_analysis::StationInfo;
let snd = make_test_sounding();
let stn: &StationInfo = snd.station_info();
println!("{:?}", stn);
Sourcepub fn with_pressure_profile(self, profile: Vec<Optioned<HectoPascal>>) -> Self
pub fn with_pressure_profile(self, profile: Vec<Optioned<HectoPascal>>) -> Self
Builder method for the pressure profile.
§Examples
use sounding_analysis::Sounding;
use metfor::HectoPascal;
use optional::{some, Optioned};
let data = vec![1000.0, 925.0, 850.0, 700.0, 500.0, 300.0, 250.0, 200.0, 150.0, 100.0];
let pressure_data: Vec<Optioned<HectoPascal>> = data.into_iter()
.map(HectoPascal)
.map(some)
.collect();
let _snd = Sounding::new()
.with_pressure_profile(pressure_data);
Sourcepub fn pressure_profile(&self) -> &[Optioned<HectoPascal>]
pub fn pressure_profile(&self) -> &[Optioned<HectoPascal>]
Get the pressure profile
§Examples
use sounding_analysis::Sounding;
let snd = make_test_sounding();
let data = snd.pressure_profile();
for p in data {
if let Some(p) = p.into_option() {
println!("{:?}", p);
} else {
println!("missing value!");
}
}
// Uninitialized profiles just return an empty vector.
let snd = Sounding::new();
let data = snd.pressure_profile();
assert!(data.is_empty());
Sourcepub fn with_temperature_profile(self, profile: Vec<Optioned<Celsius>>) -> Self
pub fn with_temperature_profile(self, profile: Vec<Optioned<Celsius>>) -> Self
Builder method for the temperature profile.
See with_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn temperature_profile(&self) -> &[Optioned<Celsius>]
pub fn temperature_profile(&self) -> &[Optioned<Celsius>]
Get the temperature profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_dew_point_profile(self, profile: Vec<Optioned<Celsius>>) -> Self
pub fn with_dew_point_profile(self, profile: Vec<Optioned<Celsius>>) -> Self
Builder method for the dew point profile.
See with_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn dew_point_profile(&self) -> &[Optioned<Celsius>]
pub fn dew_point_profile(&self) -> &[Optioned<Celsius>]
Get the dew point profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_wet_bulb_profile(self, profile: Vec<Optioned<Celsius>>) -> Self
pub fn with_wet_bulb_profile(self, profile: Vec<Optioned<Celsius>>) -> Self
Builder method for the wet bulb profile.
See with_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn wet_bulb_profile(&self) -> &[Optioned<Celsius>]
pub fn wet_bulb_profile(&self) -> &[Optioned<Celsius>]
Get the wet bulb temperature profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_theta_e_profile(self, profile: Vec<Optioned<Kelvin>>) -> Self
pub fn with_theta_e_profile(self, profile: Vec<Optioned<Kelvin>>) -> Self
Builder method for the theta e profile.
See with_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn theta_e_profile(&self) -> &[Optioned<Kelvin>]
pub fn theta_e_profile(&self) -> &[Optioned<Kelvin>]
Get the equivalent potential temperature profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_wind_profile(
self,
profile: Vec<Optioned<WindSpdDir<Knots>>>,
) -> Self
pub fn with_wind_profile( self, profile: Vec<Optioned<WindSpdDir<Knots>>>, ) -> Self
Builder method for the wind profile.
See set_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn wind_profile(&self) -> &[Optioned<WindSpdDir<Knots>>]
pub fn wind_profile(&self) -> &[Optioned<WindSpdDir<Knots>>]
Get the wind profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_pvv_profile(self, profile: Vec<Optioned<PaPS>>) -> Self
pub fn with_pvv_profile(self, profile: Vec<Optioned<PaPS>>) -> Self
Builder method for the pressure vertical velocity profile.
See set_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn pvv_profile(&self) -> &[Optioned<PaPS>]
pub fn pvv_profile(&self) -> &[Optioned<PaPS>]
Get the pressure vertical velocity profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_height_profile(self, profile: Vec<Optioned<Meters>>) -> Self
pub fn with_height_profile(self, profile: Vec<Optioned<Meters>>) -> Self
Builder method for the geopotential height profile.
See set_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn height_profile(&self) -> &[Optioned<Meters>]
pub fn height_profile(&self) -> &[Optioned<Meters>]
Get the geopotential height profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_cloud_fraction_profile(self, profile: Vec<Optioned<f64>>) -> Self
pub fn with_cloud_fraction_profile(self, profile: Vec<Optioned<f64>>) -> Self
Builder method for the cloud cover profile.
See set_pressure_profile
for an example of usage, keeping in mind the units type may
be different.
Sourcepub fn cloud_fraction_profile(&self) -> &[Optioned<f64>]
pub fn cloud_fraction_profile(&self) -> &[Optioned<f64>]
Get the cloud fraction profile.
See pressure_profile
for an example of using getters, keeping in mind the units type may
be different.
Sourcepub fn with_mslp<T, U>(self, value: T) -> Self
pub fn with_mslp<T, U>(self, value: T) -> Self
Builder method for the mean sea level pressure.
§Examples
use metfor::{HectoPascal, Millibar};
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_mslp(HectoPascal(1021.5));
let _snd = Sounding::new().with_mslp(some(HectoPascal(1021.5)));
let _snd = Sounding::new().with_mslp(none::<HectoPascal>());
let _snd = Sounding::new().with_mslp(Millibar(1021.5));
let _snd = Sounding::new().with_mslp(some(Millibar(1021.5)));
let _snd = Sounding::new().with_mslp(none::<Millibar>());
Sourcepub fn mslp(&self) -> Optioned<HectoPascal>
pub fn mslp(&self) -> Optioned<HectoPascal>
Get the mean sea level pressure
Sourcepub fn with_station_pressure<T, U>(self, value: T) -> Self
pub fn with_station_pressure<T, U>(self, value: T) -> Self
Biulder method for the station pressure.
§Examples
use metfor::{HectoPascal, Millibar};
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_station_pressure(HectoPascal(1021.5));
let _snd = Sounding::new().with_station_pressure(some(HectoPascal(1021.5)));
let _snd = Sounding::new().with_station_pressure(none::<HectoPascal>());
let _snd = Sounding::new().with_station_pressure(Millibar(1021.5));
let _snd = Sounding::new().with_station_pressure(some(Millibar(1021.5)));
let _snd = Sounding::new().with_station_pressure(none::<Millibar>());
Sourcepub fn station_pressure(&self) -> Optioned<HectoPascal>
pub fn station_pressure(&self) -> Optioned<HectoPascal>
Get the mean sea level pressure.
Sourcepub fn with_sfc_temperature<T, U>(self, value: T) -> Self
pub fn with_sfc_temperature<T, U>(self, value: T) -> Self
Builder method the surface temperature.
§Examples
use metfor::{Fahrenheit, Celsius, Kelvin};
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_sfc_temperature(Celsius(20.0));
let _snd = Sounding::new().with_sfc_temperature(some(Celsius(20.0)));
let _snd = Sounding::new().with_sfc_temperature(none::<Celsius>());
let _snd = Sounding::new().with_sfc_temperature(Kelvin(290.0));
let _snd = Sounding::new().with_sfc_temperature(some(Kelvin(290.0)));
let _snd = Sounding::new().with_sfc_temperature(none::<Kelvin>());
let _snd = Sounding::new().with_sfc_temperature(Fahrenheit(72.1));
let _snd = Sounding::new().with_sfc_temperature(some(Fahrenheit(72.1)));
let _snd = Sounding::new().with_sfc_temperature(none::<Fahrenheit>());
Sourcepub fn sfc_temperature(&self) -> Optioned<Celsius>
pub fn sfc_temperature(&self) -> Optioned<Celsius>
Get the surface temperature.
Sourcepub fn with_sfc_dew_point<T, U>(self, value: T) -> Self
pub fn with_sfc_dew_point<T, U>(self, value: T) -> Self
Set the surface dew point.
§Examples
use metfor::{Fahrenheit, Celsius, Kelvin};
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_sfc_dew_point(Celsius(20.0));
let _snd = Sounding::new().with_sfc_dew_point(some(Celsius(20.0)));
let _snd = Sounding::new().with_sfc_dew_point(none::<Celsius>());
let _snd = Sounding::new().with_sfc_dew_point(Kelvin(290.0));
let _snd = Sounding::new().with_sfc_dew_point(some(Kelvin(290.0)));
let _snd = Sounding::new().with_sfc_dew_point(none::<Kelvin>());
let _snd = Sounding::new().with_sfc_dew_point(Fahrenheit(72.1));
let _snd = Sounding::new().with_sfc_dew_point(some(Fahrenheit(72.1)));
let _snd = Sounding::new().with_sfc_dew_point(none::<Fahrenheit>());
Sourcepub fn sfc_dew_point(&self) -> Optioned<Celsius>
pub fn sfc_dew_point(&self) -> Optioned<Celsius>
Get the surface dew point.
Sourcepub fn with_sfc_wind<T, U>(self, value: T) -> Self
pub fn with_sfc_wind<T, U>(self, value: T) -> Self
Set the surface wind.
§Examples
use sounding_analysis::Sounding;
use metfor::{WindSpdDir, WindUV, Knots, MetersPSec};
use optional::{some, none};
let _snd = Sounding::new()
.with_sfc_wind(WindSpdDir{speed: Knots(10.0), direction: 270.0});
let _snd = Sounding::new()
.with_sfc_wind(some(WindSpdDir{speed: Knots(10.0), direction: 270.0}));
let _snd = Sounding::new().with_sfc_wind(none::<WindSpdDir<_>>());
let _snd = Sounding::new()
.with_sfc_wind(some(WindUV{u: MetersPSec(-7.3), v: MetersPSec(5.2)}));
let _snd = Sounding::new()
.with_sfc_wind(WindUV{u: MetersPSec(-7.3), v: MetersPSec(5.2)});
let _snd = Sounding::new().with_sfc_wind(none::<WindUV<MetersPSec>>());
Sourcepub fn sfc_wind(&self) -> Optioned<WindSpdDir<Knots>>
pub fn sfc_wind(&self) -> Optioned<WindSpdDir<Knots>>
Get the surface wind.
Sourcepub fn with_precipitation<T, U>(self, value: T) -> Self
pub fn with_precipitation<T, U>(self, value: T) -> Self
Builder method for the precipitation.
§Examples
use sounding_analysis::Sounding;
use metfor::{Inches, Mm, Cm};
use optional::{some, none};
let _snd = Sounding::new().with_precipitation(Inches(1.0));
let _snd = Sounding::new().with_precipitation(some(Inches(1.0)));
let _snd = Sounding::new().with_precipitation(none::<Inches>());
let _snd = Sounding::new().with_precipitation(some(Cm(2.5)));
let _snd = Sounding::new().with_precipitation(Cm(2.5));
let _snd = Sounding::new().with_precipitation(none::<Cm>());
let _snd = Sounding::new().with_precipitation(some(Mm(25.0)));
let _snd = Sounding::new().with_precipitation(Mm(25.0));
let _snd = Sounding::new().with_precipitation(none::<Mm>());
Sourcepub fn precipitation(&self) -> Optioned<Mm>
pub fn precipitation(&self) -> Optioned<Mm>
Get the precipitation.
Sourcepub fn with_low_cloud<T>(self, value: T) -> Self
pub fn with_low_cloud<T>(self, value: T) -> Self
Builder method for the low cloud amount in the range 0.0 to 1.0.
§Examples
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_low_cloud(0.5);
let _snd = Sounding::new().with_low_cloud(some(0.5));
let _snd = Sounding::new().with_low_cloud(none());
Sourcepub fn with_mid_cloud<T>(self, value: T) -> Self
pub fn with_mid_cloud<T>(self, value: T) -> Self
Builder method for the mid cloud amount in the range 0.0 to 1.0.
§Examples
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_mid_cloud(0.5);
let _snd = Sounding::new().with_mid_cloud(some(0.5));
let _snd = Sounding::new().with_mid_cloud(none());
Sourcepub fn with_high_cloud<T>(self, value: T) -> Self
pub fn with_high_cloud<T>(self, value: T) -> Self
Builder method for the high cloud amount in the range 0.0 to 1.0.
§Examples
use sounding_analysis::Sounding;
use optional::{some, none};
let _snd = Sounding::new().with_high_cloud(0.5);
let _snd = Sounding::new().with_high_cloud(some(0.5));
let _snd = Sounding::new().with_high_cloud(none());
Sourcepub fn high_cloud(&self) -> Optioned<f64>
pub fn high_cloud(&self) -> Optioned<f64>
Get the high cloud
Sourcepub fn with_lead_time<T>(self, lt: T) -> Self
pub fn with_lead_time<T>(self, lt: T) -> Self
Difference in model initialization time and valid_time
in hours.
§Examples
use sounding_analysis::Sounding;
let _snd = Sounding::new().with_lead_time(24);
let snd = Sounding::new().with_lead_time(Some(24));
assert_eq!(snd.lead_time().unwrap(), 24);
Sourcepub fn lead_time(&self) -> Optioned<i32>
pub fn lead_time(&self) -> Optioned<i32>
Difference in model initialization time and valid_time
in hours.
Sourcepub fn valid_time(&self) -> Option<NaiveDateTime>
pub fn valid_time(&self) -> Option<NaiveDateTime>
Valid time of the sounding.
Sourcepub fn with_valid_time<T>(self, valid_time: T) -> Self
pub fn with_valid_time<T>(self, valid_time: T) -> Self
Builder method to set the valid time of the sounding.
§Examples
use sounding_analysis::Sounding;
use chrono::NaiveDate;
let vtime = NaiveDate::from_ymd(2019, 1, 1).and_hms(12, 0, 0);
let _snd = Sounding::new().with_valid_time(vtime);
let _snd = Sounding::new().with_valid_time(Some(vtime));
Sourcepub fn bottom_up(&self) -> impl Iterator<Item = DataRow> + '_
pub fn bottom_up(&self) -> impl Iterator<Item = DataRow> + '_
Get a bottom up iterator over the data rows. The first value returned from the iterator is surface values.
§Examples
use metfor::{HectoPascal, Millibar, Celsius};
use optional::some;
use sounding_analysis::Sounding;
let pres: Vec<_> = vec![1000.0, 925.0, 850.0].into_iter()
.map(HectoPascal).map(some).collect();
let temps: Vec<_> = vec![20.0, 18.0, 17.0].into_iter()
.map(Celsius).map(some).collect();
let snd = Sounding::new()
.with_pressure_profile(pres)
.with_temperature_profile(temps)
.with_station_pressure(Millibar(1014.0));
let mut iter = snd.bottom_up();
let mut row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(1014.0)); // Surface values first!
assert!(row.temperature.is_none()); // We never set a surface temprature!
assert!(row.wind.is_none()); // We never set wind profile.
row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(1000.0));
assert_eq!(row.temperature.unwrap(), Celsius(20.0));
assert!(row.wind.is_none()); // We never set wind profile.
row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(925.0));
assert_eq!(row.temperature.unwrap(), Celsius(18.0));
assert!(row.wind.is_none()); // We never set wind profile.
row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(850.0));
assert_eq!(row.temperature.unwrap(), Celsius(17.0));
assert!(row.wind.is_none()); // We never set wind profile.
let row_opt = iter.next();
assert!(row_opt.is_none());
Sourcepub fn top_down(&self) -> impl Iterator<Item = DataRow> + '_
pub fn top_down(&self) -> impl Iterator<Item = DataRow> + '_
Get a top down iterator over the data rows. The last value returned is the surface values.
§Examples
use metfor::{HectoPascal, Millibar, Celsius};
use optional::some;
use sounding_analysis::Sounding;
let pres: Vec<_> = vec![1000.0, 925.0, 850.0].into_iter()
.map(HectoPascal).map(some).collect();
let temps: Vec<_> = vec![20.0, 18.0, 17.0].into_iter()
.map(Celsius).map(some).collect();
let snd = Sounding::new()
.with_pressure_profile(pres)
.with_temperature_profile(temps)
.with_station_pressure(Millibar(1014.0));
let mut iter = snd.top_down();
let mut row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(850.0));
assert_eq!(row.temperature.unwrap(), Celsius(17.0));
assert!(row.wind.is_none()); // We never set wind profile.
row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(925.0));
assert_eq!(row.temperature.unwrap(), Celsius(18.0));
assert!(row.wind.is_none()); // We never set wind profile.
row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(1000.0));
assert_eq!(row.temperature.unwrap(), Celsius(20.0));
assert!(row.wind.is_none()); // We never set wind profile.
row = iter.next().unwrap();
assert_eq!(row.pressure.unwrap(), HectoPascal(1014.0)); // Surface values first!
assert!(row.temperature.is_none()); // We never set a surface temprature!
assert!(row.wind.is_none()); // We never set wind profile.
let row_opt = iter.next();
assert!(row_opt.is_none());
Sourcepub fn data_row(&self, idx: usize) -> Option<DataRow>
pub fn data_row(&self, idx: usize) -> Option<DataRow>
Get a row of data values from this sounding.
§Examples
use metfor::{HectoPascal, Millibar, Celsius};
use optional::some;
use sounding_analysis::Sounding;
let pres: Vec<_> = vec![1000.0, 925.0, 850.0].into_iter()
.map(HectoPascal).map(some).collect();
let temps: Vec<_> = vec![20.0, 18.0, 17.0].into_iter()
.map(Celsius).map(some).collect();
let snd = Sounding::new()
.with_pressure_profile(pres)
.with_temperature_profile(temps)
.with_station_pressure(Millibar(1014.0));
let row = snd.data_row(0).unwrap(); // This is the surface
assert_eq!(row.pressure.unwrap(), HectoPascal(1014.0));
assert!(row.temperature.is_none()); // We never set a surface temperature.
let row = snd.data_row(1).unwrap(); // This is the lowest layer above the surface.
assert_eq!(row.pressure.unwrap(), HectoPascal(1000.0));
assert_eq!(row.temperature.unwrap(), Celsius(20.0));
assert!(snd.data_row(4).is_none()); // There weren't that many rows!
Sourcepub fn surface_as_data_row(&self) -> Option<DataRow>
pub fn surface_as_data_row(&self) -> Option<DataRow>
Get the surface values in a DataRow
format.
Sourcepub fn fetch_nearest_pnt<P>(&self, target_p: P) -> DataRow
pub fn fetch_nearest_pnt<P>(&self, target_p: P) -> DataRow
Given a target pressure, return the row of data values closest to this one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sounding
impl RefUnwindSafe for Sounding
impl Send for Sounding
impl Sync for Sounding
impl Unpin for Sounding
impl UnwindSafe for Sounding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more