|
29 | 29 | exporter = Exporter(globals())
|
30 | 30 |
|
31 | 31 |
|
| 32 | +@exporter.export |
| 33 | +@preprocess_and_wrap(wrap_like='specific_humidity') |
| 34 | +@process_units(input_dimensionalities={'specific_humidity': 'dimensionless'}, |
| 35 | + output_dimensionalities='[specific_heat_capacity]', |
| 36 | + output_to='J K**-1 kg**-1 ') |
| 37 | +def moist_air_gas_constant(specific_humidity): |
| 38 | + r"""Calculate R_m, the specific gas constant for a parcel of moist air. |
| 39 | +
|
| 40 | + Parameters |
| 41 | + ---------- |
| 42 | + specific_humidity : `pint.Quantity` |
| 43 | +
|
| 44 | + Returns |
| 45 | + ------- |
| 46 | + `pint.Quantity` |
| 47 | + Specific gas constant |
| 48 | +
|
| 49 | + Examples |
| 50 | + -------- |
| 51 | + >>> from metpy.calc import moist_air_gas_constant |
| 52 | + >>> from metpy.units import units |
| 53 | + >>> moist_air_gas_constant(11 * units('g/kg')) |
| 54 | + <Quantity(288.966723, 'joule / kelvin / kilogram')> |
| 55 | +
|
| 56 | + See Also |
| 57 | + -------- |
| 58 | + moist_air_specific_heat_pressure, moist_air_poisson_exponent |
| 59 | +
|
| 60 | + Notes |
| 61 | + ----- |
| 62 | + Adapted from |
| 63 | +
|
| 64 | + .. math:: R_m = (1 - q_v) R_a + q_v R_v |
| 65 | +
|
| 66 | + Eq 16, [Romps2017]_ using MetPy-defined constants in place of cited values. |
| 67 | +
|
| 68 | + """ |
| 69 | + return mpconsts.nounit.Rd + specific_humidity * (mpconsts.nounit.Rv - mpconsts.nounit.Rd) |
| 70 | + |
| 71 | + |
| 72 | +@exporter.export |
| 73 | +@preprocess_and_wrap(wrap_like='specific_humidity') |
| 74 | +@process_units(input_dimensionalities={'specific_humidity': 'dimensionless'}, |
| 75 | + output_dimensionalities='[specific_heat_capacity]', |
| 76 | + output_to='J K**-1 kg**-1 ') |
| 77 | +def moist_air_specific_heat_pressure(specific_humidity): |
| 78 | + r"""Calculate C_pm, the specific heat at constant pressure for a moist air parcel. |
| 79 | +
|
| 80 | + Parameters |
| 81 | + ---------- |
| 82 | + specific_humidity : `pint.Quantity` |
| 83 | +
|
| 84 | + Returns |
| 85 | + ------- |
| 86 | + `pint.Quantity` |
| 87 | + Specific heat capacity of air at constant pressure |
| 88 | +
|
| 89 | + Examples |
| 90 | + -------- |
| 91 | + >>> from metpy.calc import moist_air_specific_heat_pressure |
| 92 | + >>> from metpy.units import units |
| 93 | + >>> moist_air_specific_heat_pressure(11 * units('g/kg')) |
| 94 | + <Quantity(1014.07575, 'joule / kelvin / kilogram')> |
| 95 | +
|
| 96 | + See Also |
| 97 | + -------- |
| 98 | + moist_air_gas_constant, moist_air_poisson_exponent |
| 99 | +
|
| 100 | + Notes |
| 101 | + ----- |
| 102 | + Adapted from |
| 103 | +
|
| 104 | + .. math:: c_{pm} = (1 - q_v) c_{pa} + q_v c_{pv} |
| 105 | +
|
| 106 | + Eq 17, [Romps2017]_ using MetPy-defined constants in place of cited values. |
| 107 | +
|
| 108 | + """ |
| 109 | + return (mpconsts.nounit.Cp_d |
| 110 | + + specific_humidity * (mpconsts.nounit.Cp_v - mpconsts.nounit.Cp_d)) |
| 111 | + |
| 112 | + |
| 113 | +@exporter.export |
| 114 | +@preprocess_and_wrap(wrap_like='specific_humidity') |
| 115 | +@process_units( |
| 116 | + input_dimensionalities={'specific_humidity': 'dimensionless'}, |
| 117 | + output_dimensionalities='[dimensionless]' |
| 118 | +) |
| 119 | +def moist_air_poisson_exponent(specific_humidity): |
| 120 | + r"""Calculate kappa_m, the Poisson exponent for a moist air parcel. |
| 121 | +
|
| 122 | + Parameters |
| 123 | + ---------- |
| 124 | + specific_humidity : `pint.Quantity` |
| 125 | +
|
| 126 | + Returns |
| 127 | + ------- |
| 128 | + `pint.Quantity` |
| 129 | + Poisson exponent of moist air parcel |
| 130 | +
|
| 131 | + Examples |
| 132 | + -------- |
| 133 | + >>> from metpy.calc import moist_air_poisson_exponent |
| 134 | + >>> from metpy.units import units |
| 135 | + >>> moist_air_poisson_exponent(11 * units('g/kg')) |
| 136 | + <Quantity(0.284955757, 'dimensionless')> |
| 137 | +
|
| 138 | + See Also |
| 139 | + -------- |
| 140 | + moist_air_gas_constant, moist_air_specific_heat_pressure |
| 141 | +
|
| 142 | + """ |
| 143 | + return (moist_air_gas_constant._nounit(specific_humidity) |
| 144 | + / moist_air_specific_heat_pressure._nounit(specific_humidity)) |
| 145 | + |
| 146 | + |
| 147 | +@exporter.export |
| 148 | +@preprocess_and_wrap(wrap_like='temperature') |
| 149 | +@process_units(input_dimensionalities={'temperature': '[temperature]'}, |
| 150 | + output_dimensionalities='[specific_enthalpy]', |
| 151 | + output_to='J kg**-1') |
| 152 | +def water_latent_heat_vaporization(temperature): |
| 153 | + r"""Calculate the latent heat of vaporization for water. |
| 154 | +
|
| 155 | + Accounts for variations in latent heat across valid temperature range. |
| 156 | +
|
| 157 | + Parameters |
| 158 | + ---------- |
| 159 | + temperature : `pint.Quantity` |
| 160 | +
|
| 161 | + Returns |
| 162 | + ------- |
| 163 | + `pint.Quantity` |
| 164 | + Latent heat of vaporization |
| 165 | +
|
| 166 | + Examples |
| 167 | + -------- |
| 168 | + >>> from metpy.calc import water_latent_heat_vaporization |
| 169 | + >>> from metpy.units import units |
| 170 | + >>> water_latent_heat_vaporization(20 * units.degC) |
| 171 | + <Quantity(2453677.15, 'joule / kilogram')> |
| 172 | +
|
| 173 | + See Also |
| 174 | + -------- |
| 175 | + water_latent_heat_sublimation, water_latent_heat_melting |
| 176 | +
|
| 177 | + Notes |
| 178 | + ----- |
| 179 | + Assumption of constant :math:`C_{pv}` limits validity to :math:`0` -- :math:`100^{\circ} C` |
| 180 | + range. |
| 181 | +
|
| 182 | + .. math:: L = L_0 - (c_{pl} - c_{pv}) (T - T_0) |
| 183 | +
|
| 184 | + Eq 15, [Ambaum2020]_, using MetPy-defined constants in place of cited values. |
| 185 | +
|
| 186 | + """ |
| 187 | + return (mpconsts.nounit.Lv |
| 188 | + - (mpconsts.nounit.Cp_l - mpconsts.nounit.Cp_v) |
| 189 | + * (temperature - mpconsts.nounit.T0)) |
| 190 | + |
| 191 | + |
| 192 | +@exporter.export |
| 193 | +@preprocess_and_wrap(wrap_like='temperature') |
| 194 | +@process_units(input_dimensionalities={'temperature': '[temperature]'}, |
| 195 | + output_dimensionalities='[specific_enthalpy]', |
| 196 | + output_to='J kg**-1') |
| 197 | +def water_latent_heat_sublimation(temperature): |
| 198 | + r"""Calculate the latent heat of sublimation for water. |
| 199 | +
|
| 200 | + Accounts for variations in latent heat across valid temperature range. |
| 201 | +
|
| 202 | + Parameters |
| 203 | + ---------- |
| 204 | + temperature : `pint.Quantity` |
| 205 | +
|
| 206 | + Returns |
| 207 | + ------- |
| 208 | + `pint.Quantity` |
| 209 | + Latent heat of vaporization |
| 210 | +
|
| 211 | + Examples |
| 212 | + -------- |
| 213 | + >>> from metpy.calc import water_latent_heat_sublimation |
| 214 | + >>> from metpy.units import units |
| 215 | + >>> water_latent_heat_sublimation(-15 * units.degC) |
| 216 | + <Quantity(2837991.13, 'joule / kilogram')> |
| 217 | +
|
| 218 | + See Also |
| 219 | + -------- |
| 220 | + water_latent_heat_vaporization, water_latent_heat_melting |
| 221 | +
|
| 222 | + Notes |
| 223 | + ----- |
| 224 | + .. math:: L_s = L_{s0} - (c_{pl} - c_{pv}) (T - T_0) |
| 225 | +
|
| 226 | + Eq 18, [Ambaum2020]_, using MetPy-defined constants in place of cited values. |
| 227 | +
|
| 228 | + """ |
| 229 | + return (mpconsts.nounit.Ls |
| 230 | + - (mpconsts.nounit.Cp_i - mpconsts.nounit.Cp_v) |
| 231 | + * (temperature - mpconsts.nounit.T0)) |
| 232 | + |
| 233 | + |
| 234 | +@exporter.export |
| 235 | +@preprocess_and_wrap(wrap_like='temperature') |
| 236 | +@process_units(input_dimensionalities={'temperature': '[temperature]'}, |
| 237 | + output_dimensionalities='[specific_enthalpy]', |
| 238 | + output_to='J kg**-1') |
| 239 | +def water_latent_heat_melting(temperature): |
| 240 | + r"""Calculate the latent heat of melting for water. |
| 241 | +
|
| 242 | + Accounts for variations in latent heat across valid temperature range. |
| 243 | +
|
| 244 | + Parameters |
| 245 | + ---------- |
| 246 | + temperature : `pint.Quantity` |
| 247 | +
|
| 248 | + Returns |
| 249 | + ------- |
| 250 | + `pint.Quantity` |
| 251 | + Latent heat of vaporization |
| 252 | +
|
| 253 | + Examples |
| 254 | + -------- |
| 255 | + >>> from metpy.calc import water_latent_heat_melting |
| 256 | + >>> from metpy.units import units |
| 257 | + >>> water_latent_heat_melting(-15 * units.degC) |
| 258 | + <Quantity(365662.294, 'joule / kilogram')> |
| 259 | +
|
| 260 | + See Also |
| 261 | + -------- |
| 262 | + water_latent_heat_vaporization, water_latent_heat_sublimation |
| 263 | +
|
| 264 | + Notes |
| 265 | + ----- |
| 266 | + .. math:: L_m = L_{m0} + (c_{pl} - c_{pi}) (T - T_0) |
| 267 | +
|
| 268 | + Body text below Eq 20, [Ambaum2020]_, derived from Eq 15, Eq 18. |
| 269 | + Uses MetPy-defined constants in place of cited values. |
| 270 | +
|
| 271 | + """ |
| 272 | + return (mpconsts.nounit.Lf |
| 273 | + - (mpconsts.nounit.Cp_l - mpconsts.nounit.Cp_i) |
| 274 | + * (temperature - mpconsts.nounit.T0)) |
| 275 | + |
| 276 | + |
32 | 277 | @exporter.export
|
33 | 278 | @preprocess_and_wrap(wrap_like='temperature', broadcast=('temperature', 'dewpoint'))
|
34 | 279 | @check_units('[temperature]', '[temperature]')
|
|
0 commit comments