Crate sounding_analysis[][src]

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

Functions for analysis functions that I’m experimenting with.

Structs

A copy of a row of the sounding data.

A layer in the atmosphere described by the values at the top and bottom.

A collection of parameters associated with a Pyrocumulonimbus Firepower Threshold (PFT) analysis. See pft or pft_analysis for details.

Variables defining a parcel as used in parcel analysis.

Parcel analysis, this is a way to package the analysis of a parcel.

Hold profiles for a parcel and it’s environment.

All the variables stored in the sounding.

Station information including location data and identification number.

Enums

Error type for the crate.

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

Get the parcel with mean values for the given layer.

Analyze a sounding using the Bourgouin technique for precipitation type.

Calculate the super cell storm motion using the “id” method.

Given a PrecipType and potentially hourly precipitation, hourly convective precipitation, and visibility, make a best effor to correct the weather type code, or PrecipType.

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.

Get the convective parcel - this is the surface parcel that will rise without any lifting.

Downdraft CAPE.

Find the dendtritic growth zones throughout the profile. It is unusual, but possible there is more than one.

Get the effective inflow layer.

Get the effective parcel which is the parcel with the mean values (pressure, temperature, etc) of the sounding from the effective layer.

Given a sounding, calculate a profile of the equivalent potential temperature.

Find the freezing/melting levels below 500 hPa.

Find the hail growth zones throughout the profile. It is very unusual, but possible there is more than one.

The Haines index for fire weather.

The high level version of the Haines index for fire weather.

The low level version of the Haines index for fire weather.

The mid level version of the Haines index for fire weather.

The Hot-Dry-Windy index

Get the hydrolapse in (kg/kg)/km

Get all inversion layers up to a specified pressure.

Get a layer that has a certain thickness, like 3km or 6km.

Lift a parcel for a convective parcel analysis.

Interpolate values given two parallel vectors of data and a target value.

Interpolate values from the vertical sounding using pressure as the primary coordinate.

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.

Maximum temperature in a layer.

Maximum temperature aloft.

Maximum wet bulb temperature in a layer.

Maximum wet bulb temperature aloft.

Calculate the mean wind in a layer.

Calculate the thermal energy relative to freezing in a layer. This is used in the Bourgouin algorithm for precipitation type.

Descend a parcel dry adiabatically.

Create a mixed layer parcel.

Get the most unstable parcel.

Analyze a sounding using the NSSL algorithm for precipitation type.

Calculate the Pyrocumulonimbus Firepower Threshold (PFT).

Calculate the Pyrocumulonimbus Firepower Threshold (PFT).

Given a sounding, calculate a profile of the potential temperature.

Precipitable water (mm)

Get a layer defined by two pressure levels. bottom_p > top_p

Get the parcel at a specific pressure.

Given a sounding, calculate a profile of relative humidity.

Given a sounding, calculate a profile of relative humidity with respect to ice.

A more robust convective parcel analysis.

Get a surface based inversion.

Get a profile of the average lapse rate from the surface to *, or the level on the y axis.

Storm relative helicity.

Get a surface parcel.

Get a profile of the lapse rate between layers in °C / km.

Get the lapse rate of equivalent potential temperature in °K / km.

Find the surface layer above freezing.

This will find the warm layers aloft using the dry bulb temperature.

This will find the warm layers aloft using the wet bulb temperature.

Given a sounding, calculate a profile of wet bulb temperature.

Find the wet bulb zero levels

Type Definitions

A list of layers.

A level in the atmosphere is described by a DataRow from a sounding.

A list of levels.

Shorthand for results.