[−][src]Crate metfor
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 skewt data. So you will find the functions and variables are mostly things that would typically be used on a skewt. 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, theta}; let t1 = Kelvin(300.0); let p1 = HectoPascal(1000.0); let theta1 = theta(p1, t1); let t2 = Celsius(0.0); let p2 = Millibar(700.0); let theta2 = theta(p2, t2); println!("theta1 = {:?} and theta2 = {:?}", theta1, theta2);
Reexports
pub use crate::constants::*; 
Modules
constants  Meteorlogical constants. 
Structs
Celsius  Temperature in Celsius units. 
CelsiusDiff  Temperature difference in Celsius units. 
CelsiusPKm  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. 
FahrenheitDiff  Temperature difference in Fahrenheit units. 
FahrenheitPKft  Temperature lapse rate in Fahrenheit per thousand feet (kft). 
Feet  Length in feet, usually used for geopotential height and elevation. 
HectoPascal  Pressure in hPa units. 
HelicityMpS2  Helicity in m s^{2} units 
HydrolapseGPKgPKm  Hydrolapse in for mixing ratio in g / kg/ km 
HydrolapsePKm  Hydrolapse in for mixing ratio in km^{1} 
Inches  Length in inches, usually used for precipitation depth or precipitable water. 
IntHelicityM2pS2  Vertically integrated helicity in m^{2} 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. 
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. 
MetersPSec  Speed in meters per second. 
MicroBarPS  Pressure vertical velocity in microbar/s 
MilesPHour  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 
WindSpdDir  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. 
Pressure  Marker trait for Pressure types. 
Quantity  A quantity is a common super trait for types that represent units of measurement. 
SpecificEnergy  Marker trait for specific energy types. 
SpecificEnergyPerKelvin  Marker trait for specific energy per Kelvin types 
Speed  Marker trait for speed types. 
TempDiff  Marker trait for temperature differences. 
TempLR  Marker trait for temperature lapse rate types. 
Temperature  Marker trait for temperature types. 
VectorQuantity  A version of 
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. 
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

latent_heat_of_condensation  Latent heat of condensation for water. 
mixing_ratio  Calculate the mixing ratio of water. 
pressure_and_temperature_at_lcl  Calculate the temperature and pressure at the lifting condensation level (LCL). 
pressure_hpa_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. 
temperature_from_theta  Given a potential temperature and pressure, calculate the temperature. 
temperature_from_theta_e_saturated_and_pressure  Given the pressure and equivalent potential temperature, assume saturation and calculate the temperature. 
theta  Calculate potential temperature assuming a 1000 hPa reference level. 
theta_e  Calculate equivalent potential temperature. 
vapor_pressure_ice  Get the vapor pressure over ice. 
vapor_pressure_liquid_water  Get the vapor pressure over liquid water. 
virtual_temperature  Virtual temperature. 
wet_bulb  Calculate the web bulb temperature. 
Type Definitions
KelvinDiff  Temperature difference in Kelvin units. 
KelvinPKm  Temperature lapse rate in Kelvin per kilometer. 