Crate metfor[−][src]
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. |
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. |
GigaWatts | Power. |
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 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. |
KelvinDiff | 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. |
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 |
Pascal | Pressure in Pa units. |
StatuteMiles | Length in statute miles, usually used for visibility. |
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. |
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. |
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. |
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 |
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
|
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 Definitions
KelvinPKm | Temperature lapse rate in Kelvin per kilometer. |