Atmospheric state
The measured and derived state of the near-surface atmosphere and its vertical structure.
temperature — Temperature
Unit conversion and temperature-derived quantities — dew point, potential and virtual temperature, lapse rates, wet-bulb temperature, and skin temperature from longwave.
convert_temperature
convert_temperature(temp: 'float', input_unit: 'str', output_unit: 'str') -> 'float'
Convert temperature between Celsius, Fahrenheit, and Kelvin.
>>> from atmoflux.temperature import convert_temperature
>>> convert_temperature(100, "C", "F")
212.0
>>> convert_temperature(273.15, "K", "C")
0.0
>>> a, b, c = 80, "F", "C"
>>> temp = convert_temperature(a, b, c)
>>> f"{a}°{b} is equal to {round(temp, 2)}°{c}."
80°F is equal to 26.67°C.dewpoint_temperature
dewpoint_temperature(temp: 'float', rh: 'float', unit: 'str' = 'C') -> 'float'
Calculate dew point temperature from temperature and relative humidity.
>>> from atmoflux.temperature import dewpoint_temperature
>>> round(dewpoint_temperature(30, 50), 2)
18.44
>>> round(dewpoint_temperature(86, 50, unit="F"), 2)
65.19dewpoint_from_avp
dewpoint_from_avp(avp: 'float', unit: 'str' = 'C') -> 'float'
Calculate dew point temperature from actual vapor pressure.
>>> from atmoflux.temperature import dewpoint_from_avp
>>> round(dewpoint_from_avp(2.338), 2)
20.0potential_temperature
potential_temperature(temp: 'float', pressure: 'float', reference_pressure: 'float' = 101.325, unit: 'str' = 'K') -> 'float'
Calculate potential temperature of dry air.
>>> from atmoflux.temperature import potential_temperature
>>> round(potential_temperature(273.15, 80.0), 2)
292.22
>>> round(potential_temperature(0.0, 80.0, unit="C"), 2)
19.07virtual_temperature
virtual_temperature(temp: 'float', mixing_ratio: 'float', unit: 'str' = 'K') -> 'float'
Calculate virtual temperature of moist air.
>>> from atmoflux.temperature import virtual_temperature
>>> round(virtual_temperature(300.0, 0.01), 3)
301.83lapse_rate
lapse_rate(temp_lower: 'float', temp_upper: 'float', height_lower: 'float', height_upper: 'float', unit: 'str' = 'C') -> 'float'
Calculate the environmental lapse rate between two heights.
>>> from atmoflux.temperature import lapse_rate
>>> round(lapse_rate(15.0, 8.5, 0.0, 1000.0) * 1000, 1)
6.5surface_temperature_from_lw
surface_temperature_from_lw(lw_up: 'float', emissivity: 'float' = 1.0, unit: 'str' = 'K') -> 'float'
Retrieve surface temperature from upwelling longwave radiation.
>>> from atmoflux.temperature import surface_temperature_from_lw
>>> round(surface_temperature_from_lw(390.0), 2)
287.98
>>> round(surface_temperature_from_lw(390.0, unit="C"), 2)
14.83wet_bulb_temperature
wet_bulb_temperature(temp: 'float', rh: 'float', unit: 'str' = 'C') -> 'float'
Wet-bulb temperature using Stull's empirical approximation.
>>> from atmoflux.temperature import wet_bulb_temperature
>>> round(wet_bulb_temperature(25, 50), 2)
18.0equivalent_potential_temperature
equivalent_potential_temperature(temp: 'float', mixing_ratio: 'float', pressure: 'float', unit: 'str' = 'K') -> 'float'
Approximate equivalent potential temperature of moist air.
>>> from atmoflux.temperature import equivalent_potential_temperature
>>> round(equivalent_potential_temperature(290.0, 0.01, 90.0), 2)
326.29moist_adiabatic_lapse_rate
moist_adiabatic_lapse_rate(temp: 'float', mixing_ratio: 'float', unit: 'str' = 'C') -> 'float'
Saturated (moist) adiabatic lapse rate.
>>> from atmoflux.temperature import moist_adiabatic_lapse_rate
>>> round(moist_adiabatic_lapse_rate(20, 0.015) * 1000, 3)
4.302humidity — Humidity & moisture
Atmospheric moisture: saturation and actual vapor pressure, the saturation-curve slope, humidity measures, vapor pressure deficit, and precipitable water.
saturation_vp
saturation_vp(temp: 'float', unit: 'str' = 'C') -> 'float'
Saturation vapor pressure of water (kPa) using the Tetens formula.
>>> from atmoflux.humidity import saturation_vp
>>> round(saturation_vp(20), 4)
2.3382actual_vp
actual_vp(dewpoint: 'float', unit: 'str' = 'C') -> 'float'
Actual vapor pressure of water (kPa) from dew point using the Tetens formula.
>>> from atmoflux.humidity import actual_vp
>>> round(actual_vp(10), 4)
1.2279saturation_vp_slope
saturation_vp_slope(temp: 'float', unit: 'str' = 'C') -> 'float'
Slope of the saturation vapor pressure curve (kPa/°C).
>>> from atmoflux.humidity import saturation_vp_slope
>>> round(saturation_vp_slope(20), 4)
0.1447relative_humidity
relative_humidity(temp: 'float', dewpoint: 'float', unit: 'str' = 'C') -> 'float'
Relative humidity (%) from temperature and dew point.
>>> from atmoflux.humidity import relative_humidity
>>> round(relative_humidity(20, 10), 1)
52.5specific_humidity
specific_humidity(vapor_pressure: 'float', pressure: 'float') -> 'float'
Specific humidity (kg/kg) from vapor pressure and total pressure.
>>> from atmoflux.humidity import specific_humidity
>>> round(specific_humidity(1.2279, 101.325), 5)
0.00757mixing_ratio
mixing_ratio(vapor_pressure: 'float', pressure: 'float') -> 'float'
Mixing ratio (kg/kg) from vapor pressure and total pressure.
>>> from atmoflux.humidity import mixing_ratio
>>> round(mixing_ratio(1.2279, 101.325), 5)
0.00763vapor_pressure_deficit
vapor_pressure_deficit(temp: 'float', rh: 'float', unit: 'str' = 'C') -> 'float'
Vapor pressure deficit (kPa) from temperature and relative humidity.
>>> from atmoflux.humidity import vapor_pressure_deficit
>>> round(vapor_pressure_deficit(25, 60), 4)
1.2671absolute_humidity
absolute_humidity(vapor_pressure: 'float', temp: 'float', unit: 'str' = 'C') -> 'float'
Absolute humidity (kg/m³) from vapor pressure and temperature.
>>> from atmoflux.humidity import absolute_humidity
>>> round(absolute_humidity(1.2279, 20), 5)
0.00908saturation_vp_ice
saturation_vp_ice(temp: 'float', unit: 'str' = 'C') -> 'float'
Saturation vapor pressure over ice (kPa) using the Tetens ice formula.
>>> from atmoflux.humidity import saturation_vp_ice
>>> round(saturation_vp_ice(-10), 4)
0.2595specific_humidity_from_dewpoint
specific_humidity_from_dewpoint(dewpoint: 'float', pressure: 'float', unit: 'str' = 'C') -> 'float'
Specific humidity (kg/kg) from dew point and total pressure.
>>> from atmoflux.humidity import specific_humidity_from_dewpoint
>>> round(specific_humidity_from_dewpoint(10, 101.325), 5)
0.00757relative_humidity_from_specific_humidity
relative_humidity_from_specific_humidity(specific_humidity: 'float', temp: 'float', pressure: 'float', unit: 'str' = 'C') -> 'float'
Relative humidity (%) from specific humidity, temperature, and pressure.
>>> from atmoflux.humidity import relative_humidity_from_specific_humidity
>>> round(relative_humidity_from_specific_humidity(0.00757, 20, 101.325), 1)
52.5precipitable_water
precipitable_water(specific_humidity: 'float', pressure: 'float') -> 'float'
Column precipitable water from layer-mean specific humidity.
>>> from atmoflux.humidity import precipitable_water
>>> round(precipitable_water(0.01, 101.325), 2)
103.32wind — Wind
Wind speed and direction from components, logarithmic and power-law height adjustment, friction velocity, shear, power density, and canopy-based roughness.
convert_wind_speed
convert_wind_speed(speed: 'float', from_unit: 'str', to_unit: 'str') -> 'float'
Convert wind speed between m/s, mph, km/h, and knots.
>>> from atmoflux.wind import convert_wind_speed
>>> round(convert_wind_speed(10, "m/s", "km/h"), 1)
36.0
>>> round(convert_wind_speed(20, "mph", "m/s"), 4)
8.9408wind_speed
wind_speed(u: 'float', v: 'float') -> 'float'
Wind speed magnitude from zonal and meridional components.
>>> from atmoflux.wind import wind_speed
>>> wind_speed(3.0, 4.0)
5.0wind_direction
wind_direction(u: 'float', v: 'float') -> 'float'
Meteorological wind direction from zonal and meridional components.
>>> from atmoflux.wind import wind_direction
>>> wind_direction(0.0, -1.0)
0.0
>>> wind_direction(-1.0, 0.0)
90.0log_wind_profile
log_wind_profile(speed_ref: 'float', height_ref: 'float', height: 'float', roughness: 'float', displacement: 'float' = 0.0) -> 'float'
Adjust wind speed to a new height using the logarithmic wind profile.
>>> from atmoflux.wind import log_wind_profile
>>> round(log_wind_profile(5.0, 10.0, 2.0, 0.03), 3)
3.615power_law_profile
power_law_profile(speed_ref: 'float', height_ref: 'float', height: 'float', exponent: 'float') -> 'float'
Adjust wind speed to a new height using the power-law wind profile.
>>> from atmoflux.wind import power_law_profile
>>> round(power_law_profile(5.0, 10.0, 50.0, 0.143), 3)
6.294friction_velocity
friction_velocity(speed: 'float', height: 'float', roughness: 'float', displacement: 'float' = 0.0, karman: 'float' = 0.4) -> 'float'
Friction velocity from a single wind measurement (neutral stability).
>>> from atmoflux.wind import friction_velocity
>>> round(friction_velocity(5.0, 10.0, 0.03), 4)
0.3443wind_shear
wind_shear(speed_lower: 'float', speed_upper: 'float', height_lower: 'float', height_upper: 'float') -> 'float'
Vertical wind shear between two heights.
>>> from atmoflux.wind import wind_shear
>>> round(wind_shear(3.0, 7.0, 10.0, 50.0), 3)
0.1wind_components
wind_components(speed: 'float', direction: 'float') -> 'tuple'
Zonal and meridional wind components from speed and meteorological direction.
>>> from atmoflux.wind import wind_components
>>> u, v = wind_components(10.0, 270.0)
>>> round(float(u), 2), round(float(v), 2)
10.0 0.0wind_power_density
wind_power_density(speed: 'float', density: 'float' = 1.225) -> 'float'
Wind power density of the airflow.
>>> from atmoflux.wind import wind_power_density
>>> round(wind_power_density(8.0), 2)
313.6roughness_from_canopy
roughness_from_canopy(canopy_height: 'float') -> 'float'
Estimate aerodynamic roughness length from vegetation canopy height.
>>> from atmoflux.wind import roughness_from_canopy
>>> round(roughness_from_canopy(2.0), 3)
0.2displacement_from_canopy
displacement_from_canopy(canopy_height: 'float') -> 'float'
Estimate zero-plane displacement height from vegetation canopy height.
>>> from atmoflux.wind import displacement_from_canopy
>>> round(displacement_from_canopy(2.0), 3)
1.34atmosphere — Standard atmosphere
Barometric helpers: pressure scale height, pressure with altitude, hypsometric thickness, density altitude, and the US Standard Atmosphere profile.
scale_height
scale_height(temp: 'float', unit: 'str' = 'C') -> 'float'
Atmospheric pressure scale height for an isothermal layer.
>>> from atmoflux.atmosphere import scale_height
>>> round(scale_height(15), 1)
8434.5pressure_at_altitude
pressure_at_altitude(altitude: 'float', pressure_ref: 'float' = 101.325, temp: 'float' = 15.0, unit: 'str' = 'C') -> 'float'
Pressure at a given altitude using the isothermal barometric formula.
>>> from atmoflux.atmosphere import pressure_at_altitude
>>> round(pressure_at_altitude(1000), 3)
89.997hypsometric_thickness
hypsometric_thickness(pressure_lower: 'float', pressure_upper: 'float', temp: 'float', unit: 'str' = 'C') -> 'float'
Geopotential thickness between two pressure levels (hypsometric equation).
>>> from atmoflux.atmosphere import hypsometric_thickness
>>> round(hypsometric_thickness(101.325, 90.0, 15), 1)
999.7density_altitude
density_altitude(pressure: 'float', temp: 'float', unit: 'str' = 'C') -> 'float'
Density altitude from station pressure and temperature.
>>> from atmoflux.atmosphere import density_altitude
>>> round(density_altitude(101.325, 25), 1)
353.9standard_atmosphere
standard_atmosphere(altitude: 'float', unit: 'str' = 'C') -> 'tuple'
Temperature and pressure of the US Standard Atmosphere (troposphere).
>>> from atmoflux.atmosphere import standard_atmosphere
>>> temp, pres = standard_atmosphere(1000)
>>> round(temp, 2)
8.5
>>> round(pres, 3)
89.875