Crate sounding_analysis

Source
Expand description

Github Actions

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::Optioneds 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.
ParcelAscentAnalysis
Parcel analysis, this is a way to package the analysis of a parcel.
ParcelProfile
Hold profiles for a parcel and it’s environment.
Sounding
All the variables stored in the sounding.
StationInfo
Station information including location data and identification number.

Enums§

AnalysisError
Error type for the crate.
PrecipType
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, return None 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

Type Aliases§

Layers
A list of layers.
Level
A level in the atmosphere is described by a DataRow from a sounding.
Levels
A list of levels.
Result
Shorthand for results.