Expand description
Meteorological constants and formulas.
This library includes newtype types, or wrapper types, to help with using the proper units when doing calculations, some common meteorological constants, and some functions for basic calculations. It has thus far been developed to support libraries and an application used for displaying and analyzing skew-t data. So you will find the functions and variables are mostly things that would typically be used on a skew-t. Future versions may expand the intended use cases.
I investigated using some sort of dimensional analysis via types with a crate like uom or dimensioned instead of making my own newtype types. However after experimentation, I decided I did not want to make another crate part of the API since choosing to use one would force that library on the users of this library.
I’ve found the optional crate to be very useful when dealing with f64
types in
situations where there may be missing values, so I included a feature use_optional
that enables
the newtypes in this crate to be used in the same manner as an f64
is with optional
.
§Examples
use metfor::{Kelvin, Celsius, HectoPascal, Millibar, potential_temperature};
let t1 = Kelvin(300.0);
let p1 = HectoPascal(1000.0);
let theta1 = potential_temperature(p1, t1);
let t2 = Celsius(0.0);
let p2 = Millibar(700.0);
let theta2 = potential_temperature(p2, t2);
println!("theta1 = {:?} and theta2 = {:?}", theta1, theta2);
Re-exports§
pub use crate::constants::*;
Modules§
- constants
- Meteorlogical constants.
Structs§
- Celsius
- Temperature in Celsius units.
- Celsius
Diff - Temperature difference in Celsius units.
- CelsiusP
Km - Temperature lapse rate in Celsius per kilometer.
- Cm
- Length in centimeters, usually used for precipitation depth or precipitable water.
- Decameters
- Length in decameters, usually used for geopotential height.
- Fahrenheit
- Temperature in Fahrenheit units.
- Fahrenheit
Diff - Temperature difference in Fahrenheit units.
- FahrenheitP
Kft - Temperature lapse rate in Fahrenheit per thousand feet (kft).
- Feet
- Length in feet, usually used for geopotential height and elevation.
- Giga
Watts - Power.
- Hecto
Pascal - Pressure in hPa units.
- Helicity
MpS2 - Helicity in m s-2 units
- HydrolapseGP
KgPKm - Hydrolapse in for mixing ratio in g / kg/ km
- HydrolapseP
Km - Hydrolapse in for mixing ratio in km-1
- Inches
- Length in inches, usually used for precipitation depth or precipitable water.
- IntHelicity
M2pS2 - Vertically integrated helicity in m2 s-2 units
- JpKg
- Specific energy in J kg-1 units. Used for CAPE, CIN, latent heat, etc.
- JpKgpK
- Specific energy per Kelvin in J K-1 kg-1. Used for gas constants and specific heat valus.
- Kelvin
- Temperature in Kelvin units.
- Kelvin
Diff - Temperature difference in Kelvin units.
- Km
- Length in kilometers, usually used for geopotential height above ground level.
- KmPHour
- Speed in Kilometers per hour
- Knots
- Speed in knots.
- Meters
- Length in meters, usually used for geopotential height and elevation.
- MetersP
Sec - Speed in meters per second.
- Micro
BarPS - Pressure vertical velocity in microbar/s
- MilesP
Hour - Speed in miles per hour
- Millibar
- Pressure in mb units.
- Mm
- Length in millimeters, usually used for precipitation depth or precipitable water.
- PaPS
- Pressure vertical velocity in Pa/s
- Pascal
- Pressure in Pa units.
- Statute
Miles - Length in statute miles, usually used for visibility.
- Wind
SpdDir - Wind direction and speed in knots.
- WindUV
- Wind in U and V components in m/s.
Traits§
- Helicity
- Marker trait for helicity.
- Hydrolapse
- Marker trait for hydrolapse.
- IntHelicity
- Marker trait for vertically integrated helicity.
- Length
- Marker trait for elevation/height types.
- PVV
- Marker trait for pressure vertical veclocity types.
- Power
- Marker trait for power types.
- Pressure
- Marker trait for Pressure types.
- Quantity
- A quantity is a common super trait for types that represent units of measurement.
- Specific
Energy - Marker trait for specific energy types.
- Specific
Energy PerKelvin - Marker trait for specific energy per Kelvin types
- Speed
- Marker trait for speed types.
- Temp
Diff - Marker trait for temperature differences.
- TempLR
- Marker trait for temperature lapse rate types.
- Temperature
- Marker trait for temperature types.
- Vector
Quantity - A version of
Quantity
for vectors. - Wind
- Marker trait for Wind types.
Functions§
- dew_
point_ from_ p_ and_ mw - Given a mixing ratio and pressure, calculate the dew point temperature. If saturation is assumed, this is also the temperature.
- dew_
point_ from_ p_ and_ specific_ humidity - Given a specific humidity and pressure, calculate the dew point temperature. If saturation is assumed, this is also the temperature.
- dew_
point_ from_ vapor_ pressure_ water - Get the dew point given the vapor pressure of water over liquid water. This function is the
inverse of
vapor_pressure_liquid_water
. - equiv_
pot_ temperature - Calculate equivalent potential temperature.
- frost_
point_ from_ vapor_ pressure_ over_ ice - Get the frost point given the vapor pressure of water over ice. This function is the inverse of
vapor_pressure_ice
. - latent_
heat_ of_ condensation_ vaporization - Latent heat of condensation/vaporization for water.
- mixing_
ratio - Calculate the mixing ratio of water.
- mixing_
ratio_ from_ specific_ humidity - Convert specific humidity into mixing ratio.
- pft
- Calculate the Pyrocumulonimbus Firepower Threshold (PFT).
- potential_
temperature - Calculate potential temperature assuming a 1000 hPa reference level.
- pressure_
and_ temperature_ at_ lcl - Calculate the temperature and pressure at the lifting condensation level (LCL).
- pressure_
at_ lcl - Approximate pressure of the Lifting Condensation Level (LCL).
- rh
- Calculate the relative humidity with respect to liquid water.
- rh_ice
- Calculate the relative humidity with respect to ice.
- specific_
humidity - Calculate the specific humidity.
- specific_
humidity_ from_ mixing_ ratio - Convert mixing ratio into specific humidity.
- temperature_
from_ equiv_ pot_ temp_ saturated_ and_ pressure - Given the pressure and equivalent potential temperature, assume saturation and calculate the temperature.
- temperature_
from_ pot_ temp - Given a potential temperature and pressure, calculate the temperature.
- vapor_
pressure_ ice - Get the vapor pressure over ice.
- vapor_
pressure_ water - Get the vapor pressure over liquid water.
- virtual_
temperature - Virtual temperature.
- wet_
bulb - Calculate the web bulb temperature.
Type Aliases§
- KelvinP
Km - Temperature lapse rate in Kelvin per kilometer.