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.
- Parameters:
pressure (numpy.ndarray) – Total atmospheric pressure [Pa]
temperature (numpy.ndarray) – air temperature [K]
mixing_ratio (numpy.ndarray) – dimensionless mass mixing ratio
molecular_weight_ratio (numpy.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\)).
- Returns:
The corresponding density of the parcel
- Return type:
numpy.ndarray
Note
\[\rho = \frac{p}{R_dT_v}\]
- nakametpy.thermo.dewpoint(e)[source]
Calculate the ambient dewpoint given the vapor pressure.
- Parameters:
e (numpy.ndarray) – Water vapor partial pressure [Pa]
- Returns:
dewpoint temperature
- Return type:
numpy.ndarray
See also
dewpoint_from_relative_humidity
,saturation_vapor_pressure
,vapor_pressure
Note
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.
- Parameters:
temperature (numpy.ndarray) – air temperature [K]
rh (numpy.ndarray) – relative humidity expressed as a ratio in the range 0 < rh <= 1
- Returns:
The dewpoint temperature
- Return type:
numpy.ndarray
See also
- nakametpy.thermo.dewpoint_from_specific_humidity(pressure, temperature, specific_humidity)[source]
Calculate the dewpoint from specific humidity, temperature, and pressure.
- Parameters:
pressure (numpy.ndarray) – Total atmospheric pressure [Pa]
temperature (numpy.ndarray) – Air temperature [K]
specific_humidity (numpy.ndarray) – Specific humidity of air
- Returns:
Dew point temperature
- Return type:
numpy.ndarray
Changed in version 1.0: Changed signature from
(specific_humidity, temperature, pressure)
- 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]\]- Parameters:
pressure (numpy.ndarray) – Total atmospheric pressure [Pa]
temperature (numpy.ndarray) – Temperature of parcel [K]
dewpoint (numpy.ndarray) – Dewpoint of parcel [K]
- Returns:
The equivalent potential temperature of the parcel
- Return type:
numpy.ndarray
Note
[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}\]- Parameters:
pressure (numpy.ndarray) – total atmospheric pressure [Pa]
reference_pressure (numpy.ndarray, optional) – The reference pressure against which to calculate the Exner function, defaults to metpy.constants.P0
- Returns:
The value of the Exner function at the given pressure
- Return type:
numpy.ndarray
See also
potential_temperature
,temperature_from_potential_temperature
- nakametpy.thermo.k_index_2d(t850, t700, t500, rh850, rh700)[source]
相対湿度、気温(およびリファレンスのための気圧)からK指数を計算する.
- Parameters:
pressure (numpy.ndarray) – Pressure level value [Pa]
temperature (numpy.ndarray) – Air temperature [K]
rh (numpy.ndarray) – Dimensionless relative humidity
- Returns:
K Index in Kelvin
- Return type:
numpy.ndarray
Note
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指数を計算する.
- Parameters:
pressure (numpy.ndarray) – Pressure level value [Pa]
temperature (numpy.ndarray) – Air temperature [K]
rh (numpy.ndarray) – Dimensionless relative humidity [0<=rh<=1]
- Returns:
K index
- Return type:
numpy.ndarray
Note
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.
- Parameters:
part_press (numpy.ndarray) – Partial pressure of the constituent gas [Pa]
tot_press (numpy.ndarray) – Total air pressure Pa
molecular_weight_ratio (numpy.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
- Returns:
The (mass) mixing ratio, dimensionless (e.g. Kg/Kg or g/g)
- Return type:
numpy.ndarray
Note
This function is a straightforward implementation of the equation given in many places, such as [Hobbs1977] pg.73:
\[r = \varepsilon \frac{e}{p - e}\]See also
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.
- Parameters:
relative_humidity (numpy.ndarray) –
Relative Humidity [0<=rh<=1]
相対湿度. 値は(0, 1]である必要がある
temperature (numpy.ndarray) –
Air temperature [K]
気温
pressure (numpy.ndarray) –
Total atmospheric pressure [Pa]
全圧
- Returns:
Dimensionless mixing ratio
- Return type:
numpy.ndarray
Note
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
- nakametpy.thermo.mixing_ratio_from_specific_humidity(specific_humidity)[source]
Calculate the mixing ratio from specific humidity.
- Parameters:
specific_humidity (numpy.ndarray) – Specific humidity of air
- Returns:
Mixing ratio
- Return type:
numpy.ndarray
Note
Formula from [Salby1996] pg. 118.
\[w = \frac{q}{1-q}\]\(w\) is mixing ratio
\(q\) is the specific humidity
- nakametpy.thermo.potential_temperature(pressure, temperature)[source]
Calculate the potential temperature.
Uses the Poisson equation to calculation the potential temperature given pressure and temperature.
- Parameters:
pressure (numpy.ndarray) – total atmospheric pressure [Pa]
temperature (numpy.ndarray) – air temperature [K]
- Returns:
The potential temperature corresponding to the temperature and pressure.
- Return type:
numpy.ndarray
See also
dry_lapse
Note
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.
- Parameters:
temperature (numpy.ndarray) – air temperature [K]
dewpoint (numpy.ndarray) – dewpoint temperature [K]
- Returns:
relative humidity
- Return type:
numpy.ndarray
See also
- nakametpy.thermo.relative_humidity_from_mixing_ratio(pressure, temperature, mixing_ratio)[source]
Calculate the relative humidity from mixing ratio, temperature, and pressure.
- Parameters:
pressure (numpy.ndarray) – Total atmospheric pressure [Pa]
temperature (numpy.ndarray) – Air temperature [K]
mixing_ratio (numpy.ndarray) – Dimensionless mass mixing ratio
- Returns:
Relative humidity
- Return type:
numpy.ndarray
Note
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
- nakametpy.thermo.relative_humidity_from_specific_humidity(pressure, temperature, specific_humidity)[source]
Calculate the relative humidity from specific humidity, temperature, and pressure.
- Parameters:
pressure (numpy.ndarray) – Total atmospheric pressure [Pa]
temperature (numpy.ndarray) – Air temperature [K]
specific_humidity (numpy.ndarray) – Specific humidity of air
- Returns:
Relative humidity
- Return type:
numpy.ndarray
Note
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
See also
- 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.
- Parameters:
tot_press (numpy.ndarray) – Total atmospheric pressure [Pa]
temperature (numpy.ndarray) – air temperature [K]
- Returns:
The saturation mixing ratio, dimensionless
- Return type:
numpy.ndarray
- nakametpy.thermo.saturation_vapor_pressure(temperature)[source]
Calculate the saturation water vapor (partial) pressure.
- Parameters:
temperature (numpy.ndarray) – air temperature [K]
- Returns:
The saturation water vapor (partial) pressure
- Return type:
numpy.ndarray
See also
vapor_pressure
,dewpoint
Note
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.
- Parameters:
mixing_ratio (numpy.ndarray) – mixing ratio
- Returns:
Specific humidity
- Return type:
numpy.ndarray
Note
Formula from [Salby1996] pg. 118.
\[q = \frac{w}{1+w}\]\(w\) is mixing ratio
\(q\) is the 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.
- Parameters:
temperature (numpy.ndarray) – air temperature [K]
mixing_ratio (numpy.ndarray) – dimensionless mass mixing ratio
molecular_weight_ratio (numpy.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\)).
- Returns:
The corresponding virtual temperature of the parcel
- Return type:
numpy.ndarray
Note
\[T_v = T \frac{\text{w} + \varepsilon}{\varepsilon\,(1 + \text{w})}\]