nakametpy.thermo module
- nakametpy.thermo.density(pressure, temperature, mixing_ratio, molecular_weight_ratio=0.622)[source]
Calculate density.
This calculation must be given an air parcel’s pressure, temperature, and mixing ratio. The implementation uses the formula outlined in [Hobbs2006] pg.67.
- pressure: numpy.ndarray
Total atmospheric pressure [Pa]
- temperature: numpy.ndarray
air temperature [K]
- mixing_rationumpy.ndarray
dimensionless mass mixing ratio
- molecular_weight_rationumpy.ndarray or float, optional
The ratio of the molecular weight of the constituent gas to that assumed for air. Defaults to the ratio for water vapor to dry air. (\(\varepsilon\approx0.622\)).
- numpy.ndarray
The corresponding density of the parcel
\[\rho = \frac{p}{R_dT_v}\]
- nakametpy.thermo.dewpoint(e)[source]
Calculate the ambient dewpoint given the vapor pressure.
- enumpy.ndarray
Water vapor partial pressure [Pa]
- numpy.ndarray
dewpoint temperature
dewpoint_from_relative_humidity, saturation_vapor_pressure, vapor_pressure
This function inverts the [Bolton1980] formula for saturation vapor pressure to instead calculate the temperature. This yield the following formula for dewpoint in degrees Celsius:
\[T = \frac{243.5 \log(e / 6.112)}{17.67 - \log(e / 6.112)}\]
- nakametpy.thermo.dewpoint_from_relative_humidity(temperature, rh)[source]
Calculate the ambient dewpoint given air temperature and relative humidity.
- temperaturenumpy.ndarray
air temperature [K]
- rhnumpy.ndarray
relative humidity expressed as a ratio in the range 0 < rh <= 1
- numpy.ndarray
The dewpoint temperature
dewpoint, saturation_vapor_pressure
- nakametpy.thermo.dewpoint_from_specific_humidity(pressure, temperature, specific_humidity)[source]
Calculate the dewpoint from specific humidity, temperature, and pressure.
- pressure: numpy.ndarray
Total atmospheric pressure [Pa]
- temperature: numpy.ndarray
Air temperature [K]
- specific_humidity: numpy.ndarray
Specific humidity of air
- numpy.ndarray
Dew point temperature
Changed in version 1.0: Changed signature from
(specific_humidity, temperature, pressure)
relative_humidity_from_mixing_ratio, dewpoint_from_relative_humidity
- nakametpy.thermo.equivalent_potential_temperature(pressure, temperature, dewpoint)[source]
Calculate equivalent potential temperature.
This calculation must be given an air parcel’s pressure, temperature, and dewpoint. The implementation uses the formula outlined in [Bolton1980]:
First, the LCL temperature is calculated:
\[T_{L}=\frac{1}{\frac{1}{T_{D}-56}+\frac{ln(T_{K}/T_{D})}{800}}+56\]Which is then used to calculate the potential temperature at the LCL:
\[\theta_{DL}=T_{K}\left(\frac{1000}{p-e}\right)^\kappa \left(\frac{T_{K}}{T_{L}}\right)^{0.28r}\]Both of these are used to calculate the final equivalent potential temperature:
\[\theta_{E}=\theta_{DL}\exp\left[\left(\frac{3036.}{T_{L}} -1.78\right)\times r(1+0.448r)\right]\]- pressure: numpy.ndarray
Total atmospheric pressure [Pa]
- temperature: numpy.ndarray
Temperature of parcel [K]
- dewpoint: numpy.ndarray
Dewpoint of parcel [K]
- numpy.ndarray
The equivalent potential temperature of the parcel
[Bolton1980] formula for Theta-e is used, since according to [DaviesJones2009] it is the most accurate non-iterative formulation available.
- nakametpy.thermo.exner_function(pressure, reference_pressure=100000)[source]
Calculate the Exner function.
\[\Pi = \left( \frac{p}{p_0} \right)^\kappa\]This can be used to calculate potential temperature from temperature (and visa-versa), since
\[\Pi = \frac{T}{\theta}\]- pressurenumpy.ndarray
total atmospheric pressure [Pa]
- reference_pressurenumpy.ndarray, optional
The reference pressure against which to calculate the Exner function, defaults to metpy.constants.P0
- numpy.ndarray
The value of the Exner function at the given pressure
potential_temperature temperature_from_potential_temperature
- nakametpy.thermo.k_index_2d(t850, t700, t500, rh850, rh700)[source]
相対湿度、気温(およびリファレンスのための気圧)からK指数を計算する.
- pressure: numpy.ndarray
Pressure level value [Pa]
- temperature: numpy.ndarray
Air temperature [K]
- rh: numpy.ndarray
Dimensionless relative humidity
- numpy.ndarray
K Index in Kelvin
Formula based on that from [George1960]
\[KI = T_{850} - T_{500} + Td_{850} - \left(T_{700} - Td_{700}\right)\]\(KI\) is K index
\(T\) is temperature
\(Td\) is dew-point temperature
Subscript means its pressure level
- nakametpy.thermo.k_index_3d(pressure, temperature, rh)[source]
相対湿度、気温(およびリファレンスのための気圧)からK指数を計算する.
- pressure: numpy.ndarray
Pressure level value [Pa]
- temperature: numpy.ndarray
Air temperature [K]
- rh: numpy.ndarray
Dimensionless relative humidity [0<=rh<=1]
- numpy.ndarray
K index
Formula based on that from [George1960]
\[KI = T_{850} - T_{500} + Td_{850} - \left(T_{700} - Td_{700}\right)\]\(KI\) is K index
\(T\) is temperature
\(Td\) is dew-point temperature
Subscript means its pressure level
- nakametpy.thermo.mixing_ratio(part_press, tot_press, molecular_weight_ratio=0.622)[source]
Calculate the mixing ratio of a gas.
This calculates mixing ratio given its partial pressure and the total pressure of the air. There are no required units for the input arrays, other than that they have the same units.
- part_pressnumpy.ndarray
Partial pressure of the constituent gas [Pa]
- tot_pressnumpy.ndarray
Total air pressure Pa
- molecular_weight_rationumpy.ndarray or float, optional
The ratio of the molecular weight of the constituent gas to that assumed for air. Defaults to the ratio for water vapor to dry air (\(\varepsilon\approx0.622\)).
水の分子量と空気の平均の分子量の比=18/28.8
- numpy.ndarray
The (mass) mixing ratio, dimensionless (e.g. Kg/Kg or g/g)
This function is a straightforward implementation of the equation given in many places, such as [Hobbs1977] pg.73:
\[r = \varepsilon \frac{e}{p - e}\]saturation_mixing_ratio, vapor_pressure
- nakametpy.thermo.mixing_ratio_from_relative_humidity(relative_humidity, temperature, pressure)[source]
Calculate the mixing ratio from relative humidity, temperature, and pressure.
- relative_humidity: numpy.ndarray
Relative Humidity [0<=rh<=1]
相対湿度. 値は(0, 1]である必要がある
- temperature: numpy.ndarray
Air temperature [K]
気温
- pressure: numpy.ndarray
Total atmospheric pressure [Pa]
全圧
- numpy.ndarray
Dimensionless mixing ratio
Formula adapted from [Hobbs1977] pg. 74.
\[w = (RH)(w_s)\]\(w\) is mixing ratio
\(RH\) is relative humidity as a unitless ratio
\(w_s\) is the saturation mixing ratio
relative_humidity_from_mixing_ratio, saturation_mixing_ratio
- nakametpy.thermo.mixing_ratio_from_specific_humidity(specific_humidity)[source]
Calculate the mixing ratio from specific humidity.
- specific_humidity: numpy.ndarray
Specific humidity of air
- numpy.ndarray
Mixing ratio
Formula from [Salby1996] pg. 118.
\[w = \frac{q}{1-q}\]\(w\) is mixing ratio
\(q\) is the specific humidity
mixing_ratio, specific_humidity_from_mixing_ratio
- nakametpy.thermo.potential_temperature(pressure, temperature)[source]
Calculate the potential temperature.
Uses the Poisson equation to calculation the potential temperature given pressure and temperature.
- pressurenumpy.ndarray
total atmospheric pressure [Pa]
- temperaturenumpy.ndarray
air temperature [K]
- numpy.ndarray
The potential temperature corresponding to the temperature and pressure.
dry_lapse
Formula:
\[\Theta = T (P_0 / P)^\kappa\]
- nakametpy.thermo.relative_humidity_from_dewpoint(temperature, dewpt)[source]
Calculate the relative humidity.
Uses temperature and dewpoint in celsius to calculate relative humidity using the ratio of vapor pressure to saturation vapor pressures.
- temperaturenumpy.ndarray
air temperature [K]
- dewpointnumpy.ndarray
dewpoint temperature [K]
- numpy.ndarray
relative humidity
saturation_vapor_pressure
- nakametpy.thermo.relative_humidity_from_mixing_ratio(pressure, temperature, mixing_ratio)[source]
Calculate the relative humidity from mixing ratio, temperature, and pressure.
- pressure: numpy.ndarray
Total atmospheric pressure [Pa]
- temperature: numpy.ndarray
Air temperature [K]
- mixing_ratio: numpy.ndarray
Dimensionless mass mixing ratio
- numpy.ndarray
Relative humidity
Formula based on that from [Hobbs1977] pg. 74.
\[RH = \frac{w}{w_s}\]\(relative_humidity\) is relative humidity as a unitless ratio
\(w\) is mixing ratio
\(w_s\) is the saturation mixing ratio
mixing_ratio_from_relative_humidity, saturation_mixing_ratio
- nakametpy.thermo.relative_humidity_from_specific_humidity(pressure, temperature, specific_humidity)[source]
Calculate the relative humidity from specific humidity, temperature, and pressure.
- pressure: numpy.ndarray
Total atmospheric pressure [Pa]
- temperature: numpy.ndarray
Air temperature [K]
- specific_humidity: numpy.ndarray
Specific humidity of air
- numpy.ndarray
Relative humidity
Formula based on that from [Hobbs1977] pg. 74. and [Salby1996] pg. 118.
\[RH = \frac{q}{(1-q)w_s}\]\(relative_humidity\) is relative humidity as a unitless ratio
\(q\) is specific humidity
\(w_s\) is the saturation mixing ratio
relative_humidity_from_mixing_ratio
- nakametpy.thermo.saturation_mixing_ratio(tot_press, temperature)[source]
Calculate the saturation mixing ratio of water vapor.
This calculation is given total pressure and the temperature. The implementation uses the formula outlined in [Hobbs1977] pg.73.
- tot_press: numpy.ndarray
Total atmospheric pressure [Pa]
- temperature: numpy.ndarray
air temperature [K]
- numpy.ndarray
The saturation mixing ratio, dimensionless
- nakametpy.thermo.saturation_vapor_pressure(temperature)[source]
Calculate the saturation water vapor (partial) pressure.
- temperaturenumpy.ndarray
air temperature [K]
- numpy.ndarray
The saturation water vapor (partial) pressure
vapor_pressure, dewpoint
Instead of temperature, dewpoint may be used in order to calculate the actual (ambient) water vapor (partial) pressure.
The formula used is that from [Bolton1980] for T in degrees Celsius:
\[6.112 e^\frac{17.67T}{T + 243.5}\]下記の式は既にケルビンに直してある
- nakametpy.thermo.showalter_stability_index(t850, t500, p850, p500)[source]
500hPaにおける気温から850 hPaから500 hPaに断熱変化させた際の気温を引いた指数.
この計算では乾燥断熱減率のみを考慮しているため、湿潤断熱変化も含めたSSIを 求める方法が必要である.
\[SSI = T_{500} - T_{850\rightarrow 500}^*\]
- nakametpy.thermo.specific_humidity_from_mixing_ratio(mixing_ratio)[source]
Calculate the specific humidity from the mixing ratio.
- mixing_ratio: numpy.ndarray
mixing ratio
- numpy.ndarray
Specific humidity
Formula from [Salby1996] pg. 118.
\[q = \frac{w}{1+w}\]\(w\) is mixing ratio
\(q\) is the specific humidity
mixing_ratio, mixing_ratio_from_specific_humidity
- nakametpy.thermo.virtual_temperature(temperature, mixing_ratio, molecular_weight_ratio=0.622)[source]
Calculate virtual temperature.
This calculation must be given an air parcel’s temperature and mixing ratio. The implementation uses the formula outlined in [Hobbs2006] pg.80.
- temperature: numpy.ndarray
air temperature [K]
- mixing_rationumpy.ndarray
dimensionless mass mixing ratio
- molecular_weight_rationumpy.ndarray or float, optional
The ratio of the molecular weight of the constituent gas to that assumed for air. Defaults to the ratio for water vapor to dry air. (\(\varepsilon\approx0.622\)).
- numpy.ndarray
The corresponding virtual temperature of the parcel
\[T_v = T \frac{\text{w} + \varepsilon}{\varepsilon\,(1 + \text{w})}\]