Struct sounding_analysis::Sounding[][src]

pub struct Sounding { /* fields omitted */ }
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

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);

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);

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());

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);

Get the station info

Examples

use sounding_analysis::StationInfo;

let snd = make_test_sounding();
let stn: &StationInfo = snd.station_info();

println!("{:?}", stn);

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);

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());

Builder method for the temperature profile.

See with_pressure_profile for an example of usage, keeping in mind the units type may be different.

Get the temperature profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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.

Get the dew point profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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.

Get the wet bulb temperature profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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.

Get the equivalent potential temperature profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

Builder method for the wind profile.

See set_pressure_profile for an example of usage, keeping in mind the units type may be different.

Get the wind profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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.

Get the pressure vertical velocity profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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.

Get the geopotential height profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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.

Get the cloud fraction profile.

See pressure_profile for an example of using getters, keeping in mind the units type may be different.

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>());

Get the mean sea level pressure

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>());

Get the mean sea level pressure.

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>());

Get the surface temperature.

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>());

Get the surface dew point.

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>>());

Get the surface wind.

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>());

Get the precipitation.

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());

Get the low cloud

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());

Get the mid cloud

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());

Get the high cloud

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);

Difference in model initialization time and valid_time in hours.

Valid time of the sounding.

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));

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());

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());

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!

Get the surface values in a DataRow format.

Given a target pressure, return the row of data values closest to this one.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.