Expand description
Functions and data types for analyzing soundings from radiosondes or models.
Library to represent an atmospheric sounding with pressure as the vertical coordinate.
§Examples
use optional::{Optioned, some};
use metfor::{HectoPascal, Celsius, Feet};
use sounding_analysis::{Sounding, StationInfo};
fn main() {
// Create pressure profile
let pressure_profile: Vec<Optioned<HectoPascal>> =
vec![1000.0, 925.0, 850.0, 700.0, 500.0, 300.0, 250.0, 100.0]
.into_iter()
.map(HectoPascal)
.map(some)
.collect();
// Create a temperature profile
let temperature_profile: Vec<Optioned<Celsius>> =
vec![13.0, 7.0, 5.0, -4.5, -20.6, -44.0, -52.0, -56.5]
.into_iter()
.map(Celsius)
.map(some)
.collect();
// Create some station info
let stn = StationInfo::new_with_values(None, None, (45.6789, -115.6789), Feet(992.0));
// Create a valid time. This uses a `chrono::NaiveDateTime`, and you should always assume
// that valid times are in UTC.
let vt = chrono::NaiveDate::from_ymd(2018,3,8).and_hms(12,0,0);
// Use the builder pattern to construct a sounding.
let snd = Sounding::new()
.with_station_info(stn)
.with_valid_time(vt)
.with_lead_time(24) // Lead time in hours for forecast soundings.
.with_pressure_profile(pressure_profile)
.with_temperature_profile(temperature_profile)
.with_station_pressure(some(HectoPascal(1013.25)))
.with_sfc_temperature(some(Celsius(15.0)));
// Top down and bottom up iterators are provided. If surface data is available, it is
// inserted into the profile.
let mut iter = snd.top_down();
let mut data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(100.0)));
assert_eq!(data_row.temperature, some(Celsius(-56.5)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(250.0)));
assert_eq!(data_row.temperature, some(Celsius(-52.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(300.0)));
assert_eq!(data_row.temperature, some(Celsius(-44.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(500.0)));
assert_eq!(data_row.temperature, some(Celsius(-20.6)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(700.0)));
assert_eq!(data_row.temperature, some(Celsius(-4.5)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(850.0)));
assert_eq!(data_row.temperature, some(Celsius(5.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(925.0)));
assert_eq!(data_row.temperature, some(Celsius(7.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(1000.0)));
assert_eq!(data_row.temperature, some(Celsius(13.0)));
// THIS ONE IS THE SURFACE DATA!
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(1013.25)));
assert_eq!(data_row.temperature, some(Celsius(15.0)));
assert_eq!(iter.next(), None);
// Profiles and surface values can also be accessed via getter methods. Read the docs!
}
You probably noticed a lot of optional::Optioned
s in the example. Basically, anything can be
missing, and missing values are common in upper air soundings. For example, at high altitude the
dew point or humidity are often missing (if not totally inaccurate).
Modules§
- experimental
- Functions for analysis functions that I’m experimenting with.
Structs§
- DataRow
- A copy of a row of the sounding data.
- Layer
- A layer in the atmosphere described by the values at the top and bottom.
- PFTAnalysis
- A collection of parameters associated with a Pyrocumulonimbus Firepower Threshold (PFT) analysis. See pft or pft_analysis for details.
- Parcel
- Variables defining a parcel as used in parcel analysis.
- Parcel
Ascent Analysis - Parcel analysis, this is a way to package the analysis of a parcel.
- Parcel
Profile - Hold profiles for a parcel and it’s environment.
- Sounding
- All the variables stored in the sounding.
- Station
Info - Station information including location data and identification number.
Enums§
- Analysis
Error - Error type for the crate.
- Precip
Type - Precipitation type enum. Values are meant to correspond to the code values from table 4680 in the WMO Manual On Codes Vol I.1 Part A, Alphanumeric Codes.
Functions§
- average_
parcel - Get the parcel with mean values for the given layer.
- bourgouin_
precip_ type - Analyze a sounding using the Bourgouin technique for precipitation type.
- bunkers_
storm_ motion - Calculate the super cell storm motion using the “id” method.
- check_
precip_ type_ intensity - Given a
PrecipType
and potentially hourly precipitation, hourly convective precipitation, and visibility, make a best effor to correct the weather type code, or PrecipType. - cold_
surface_ temperature_ layer - Assuming a warm layer aloft given by
warm_layers
, measure the cold surface layer. If there are no warm layers aloft, returnNone
since cold surface layer extends the full depth of the atmosphere and is irrelevant. - convective_
parcel - Get the convective parcel - this is the surface parcel that will rise without any lifting.
- dcape
- Downdraft CAPE.
- dendritic_
snow_ zone - Find the dendtritic growth zones throughout the profile. It is unusual, but possible there is more than one.
- effective_
inflow_ layer - Get the effective inflow layer.
- effective_
layer_ parcel - Get the effective parcel which is the parcel with the mean values (pressure, temperature, etc) of the sounding from the effective layer.
- equivalent_
potential_ temperature - Given a sounding, calculate a profile of the equivalent potential temperature.
- freezing_
levels - Find the freezing/melting levels below 500 hPa.
- hail_
growth_ zone - Find the hail growth zones throughout the profile. It is very unusual, but possible there is more than one.
- haines
- The Haines index for fire weather.
- haines_
high - The high level version of the Haines index for fire weather.
- haines_
low - The low level version of the Haines index for fire weather.
- haines_
mid - The mid level version of the Haines index for fire weather.
- hot_
dry_ windy - The Hot-Dry-Windy index
- hydrolapse
- Get the hydrolapse in (kg/kg)/km
- inversions
- Get all inversion layers up to a specified pressure.
- layer_
agl - Get a layer that has a certain thickness, like 3km or 6km.
- lift_
parcel - Lift a parcel for a convective parcel analysis.
- linear_
interpolate - Interpolate values given two parallel vectors of data and a target value.
- linear_
interpolate_ sounding - Interpolate values from the vertical sounding using pressure as the primary coordinate.
- lowest_
level_ parcel - Get the lowest level parcel. This should be the surface parcel, but some files do not have complete information at the surface, so the first level above the ground is best you can do.
- max_
temperature_ in_ layer - Maximum temperature in a layer.
- max_
temperature_ in_ profile - Maximum temperature aloft.
- max_
wet_ bulb_ in_ layer - Maximum wet bulb temperature in a layer.
- max_
wet_ bulb_ in_ profile - Maximum wet bulb temperature aloft.
- mean_
wind - Calculate the mean wind in a layer.
- melting_
freezing_ energy_ area - Calculate the thermal energy relative to freezing in a layer. This is used in the Bourgouin algorithm for precipitation type.
- mix_
down - Descend a parcel dry adiabatically.
- mixed_
layer_ parcel - Create a mixed layer parcel.
- most_
unstable_ parcel - Get the most unstable parcel.
- nssl_
precip_ type - Analyze a sounding using the NSSL algorithm for precipitation type.
- pft
- Calculate the Pyrocumulonimbus Firepower Threshold (PFT).
- pft_
analysis - Calculate the Pyrocumulonimbus Firepower Threshold (PFT).
- potential_
temperature - Given a sounding, calculate a profile of the potential temperature.
- precipitable_
water - Precipitable water (mm)
- pressure_
layer - Get a layer defined by two pressure levels.
bottom_p
>top_p
- pressure_
parcel - Get the parcel at a specific pressure.
- relative_
humidity - Given a sounding, calculate a profile of relative humidity.
- relative_
humidity_ ice - Given a sounding, calculate a profile of relative humidity with respect to ice.
- robust_
convective_ parcel_ ascent - A more robust convective parcel analysis.
- sfc_
based_ inversion - Get a surface based inversion.
- sfc_
to_ level_ temperature_ lapse_ rate - Get a profile of the average lapse rate from the surface to *, or the level on the y axis.
- sr_
helicity - Storm relative helicity.
- surface_
parcel - Get a surface parcel.
- temperature_
lapse_ rate - Get a profile of the lapse rate between layers in °C / km.
- theta_
e_ lapse_ rate - Get the lapse rate of equivalent potential temperature in °K / km.
- warm_
surface_ temperature_ layer - Find the surface layer above freezing.
- warm_
temperature_ layer_ aloft - This will find the warm layers aloft using the dry bulb temperature.
- warm_
wet_ bulb_ layer_ aloft - This will find the warm layers aloft using the wet bulb temperature.
- wet_
bulb - Given a sounding, calculate a profile of wet bulb temperature.
- wet_
bulb_ zero_ levels - Find the wet bulb zero levels