Lapse Integration
const_lapse_fitting(temp_env_lev, p_lev, temp_env_lower, p_lower, temp_env_upper, p_upper, n_lev_above_upper_integral=0, sanity_check=False)
Find the bulk lapse rate such that \(\int_{p_1}^{p_2} \Gamma_{env}(p) d\ln p = \Gamma_{bulk} \ln (p_2/p_1)\). Then computes the error in this approximation: \(\int_{p_1}^{p_2} |\Gamma_{env}(p) - \Gamma_{bulk}| d\ln p\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_env_lev
|
Union[DataArray, ndarray]
|
|
required |
p_lev
|
Union[DataArray, ndarray]
|
|
required |
temp_env_lower
|
float
|
Environmental temperature at lower pressure level (nearer surface) |
required |
p_lower
|
float
|
Pressure level to start profile (near surface). |
required |
temp_env_upper
|
float
|
Environmental temperature at upper pressure level (further from surface) |
required |
p_upper
|
float
|
Pressure level to end profile (further from surface). |
required |
n_lev_above_upper_integral
|
int
|
Will return |
0
|
sanity_check
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
lapse_bulk |
float
|
Bulk lapse rate. Units are K/km. |
integral |
float
|
Result of integral \(\int_{p_1}^{p_2} \Gamma_{env}(p) d\ln p\). Units are K/km. |
integral_error |
float
|
Result of integral \(\int_{p_1}^{p_2} |\Gamma_{env}(p) - \Gamma_{bulk}| d\ln p\). Units are K/km. |
Source code in isca_tools/thesis/lapse_integral.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
fitting_2_layer(temp_env_lev, p_lev, temp_env_lower, p_lower, temp_env_upper, p_upper, temp_env_upper2, p_upper2, method_layer1='const', method_layer2='const', n_lev_above_upper2_integral=0, sanity_check=False)
Applies const_lapse_fitting or mod_parcel_lapse_fitting to each layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_env_lev
|
Union[DataArray, ndarray]
|
|
required |
p_lev
|
Union[DataArray, ndarray]
|
|
required |
temp_env_lower
|
float
|
Environmental temperature at lower pressure level (nearer surface) |
required |
p_lower
|
float
|
Pressure level to start profile (near surface). |
required |
temp_env_upper
|
float
|
Environmental temperature at the upper pressure level of the first layer (layer closest to surface) |
required |
p_upper
|
float
|
Pressure level to end profile of first layer (layer closest to surface). |
required |
temp_env_upper2
|
float
|
Environmental temperature at the upper pressure level of the second layer (layer furthest from surface) |
required |
p_upper2
|
float
|
Pressure level to end profile of second layer (layer furthest from surface). |
required |
temp_parcel_lev
|
|
required | |
temp_parcel_lower
|
Parcel temperature at lower pressure level (nearer surface) |
required | |
temp_parcel_upper
|
Parcel temperature at the upper pressure level of the first layer (layer closest to surface) |
required | |
temp_parcel_upper2
|
Parcel temperature at the upper pressure level of the second layer (layer furthest from surface) |
required | |
method_layer1
|
Literal['const', 'mod_parcel']
|
Which fitting method to use for layer 1. |
'const'
|
method_layer2
|
Literal['const', 'mod_parcel']
|
Which fitting method to use for layer 2. |
'const'
|
n_lev_above_upper2_integral
|
int
|
Will return |
0
|
sanity_check
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
lapse |
ndarray
|
Lapse rate info for each layer. Bulk lapse rate if |
integral |
ndarray
|
Result of integral \(\int_{p_1}^{p_2} \Gamma_{env}(p) d\ln p\) of each layer. Units are K/km. |
integral_error |
ndarray
|
Result of integral \(\int_{p_1}^{p_2} |\Gamma_{env}(p) - \Gamma_{approx}| d\ln p\) of each layer. Units are K/km. |
Source code in isca_tools/thesis/lapse_integral.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
get_temp_const_lapse(p_lev, temp_low, p_low, lapse)
Get the temperature at p_lev assuming constant lapse rate up from temp_low at p_low.
This assumes hydrostatic balance: \(\Gamma(p) = −\frac{dT}{dz} = \frac{g}{R} \frac{d \ln T}{d\ln p}\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p_lev
|
Union[DataArray, ndarray, float]
|
|
required |
temp_low
|
Union[DataArray, ndarray, float]
|
Temperature at low pressure |
required |
p_low
|
Union[DataArray, ndarray, float]
|
Pressure level where to start ascent from along constant lapse rate profile. Units: Pa. |
required |
lapse
|
Union[DataArray, ndarray, float]
|
Constant lapse rate, \(\Gamma\), to use to find temperature at |
required |
Returns:
| Name | Type | Description |
|---|---|---|
temp_lev |
Union[DataArray, ndarray, float]
|
|
Source code in isca_tools/thesis/lapse_integral.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get_temp_mod_parcel_lapse(p_lev, p_low, lapse_diff_const, temp_parcel_low=None, temp_parcel_lev=None)
This finds the temperature at pressure levels p_lev following a lapse rate \(\Gamma(p) = \Gamma_p(p, T_p(p)) + \eta\)
where \(\Gamma_p(p, T)\) is the parcel (moist adiabatic) lapse rate and \(\eta\) is a constant. \(T_p(p)\) refers
to parcel temperature at pressure \(p\).
This assumes hydrostatic balance: \(\Gamma(p) = −\frac{dT}{dz} = \frac{g}{R} \frac{d \ln T}{d\ln p}\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p_lev
|
Union[DataArray, ndarray, float]
|
|
required |
p_low
|
Union[DataArray, ndarray, float]
|
Pressure level where to start the ascent from along the modified parcel profile. Units: Pa. |
required |
lapse_diff_const
|
Union[DataArray, ndarray, float]
|
Constant, \(\eta\), which is added to the parcel lapse rate at each pressure level. Units: K/m. |
required |
temp_parcel_low
|
Optional[Union[DataArray, ndarray, float]]
|
Temperature of the parcel at |
None
|
temp_parcel_lev
|
Optional[Union[DataArray, ndarray, float]]
|
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
temp_lev |
Union[DataArray, ndarray, float]
|
|
Source code in isca_tools/thesis/lapse_integral.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
integral_lapse_dlnp_hydrostatic(temp_lev, p_lev, p1, p2, T_p1, T_p2, temp_ref_lev=None, temp_ref_p1=None, temp_ref_p2=None, take_abs=False)
Compute \(\int_{p_1}^{p_2} \Gamma d\ln p\) using the hydrostatic relation (converted to pressure integral) only (no Z required), where \(\Gamma = -dT/dz\) is the lapse rate. Can also compute \(\int_{p_1}^{p_2} \Gamma - \Gamma_{ref} d\ln p\)
Uses hydrostatic balance, \(d\ln p = -\frac{g}{RT(p)} dz\), to convert integral into sum over levels.
If temp_ref_lev is None, there is an analytic solution: \(\frac{g}{R} \ln \left(\frac{T_2}{T_1}\right)\),
but this function will return a numerical estimate still.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_lev
|
Union[DataArray, ndarray]
|
xr.DataArray Temperature [K], dims include 'lev' (vertical pressure coordinate) |
required |
p_lev
|
Union[DataArray, ndarray]
|
xr.DataArray Pressure [Pa], same 'lev' coordinate as temp_lev |
required |
p1
|
float
|
float Lower integration limit [Pa] |
required |
p2
|
float
|
float Upper integration limit [Pa] |
required |
T_p1
|
float
|
float | None, optional Temperature at p1 [K]; if None, will be log-interpolated from temp_lev |
required |
T_p2
|
float
|
float | None, optional Temperature at p2 [K]; if None, will be log-interpolated from temp_lev |
required |
temp_ref_lev
|
Optional[Union[DataArray, ndarray]]
|
Temperature of reference profile at pressure |
None
|
temp_ref_p1
|
Optional[float]
|
Temperature of reference profile at pressure |
None
|
temp_ref_p2
|
Optional[float]
|
Temperature of reference profile at pressure |
None
|
take_abs
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
integral |
float
|
Value of the integral |
Source code in isca_tools/thesis/lapse_integral.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
mod_parcel_lapse_fitting(temp_env_lev, p_lev, temp_env_lower, p_lower, temp_env_upper, p_upper, temp_parcel_lev=None, temp_parcel_lower=None, temp_parcel_upper=None, n_lev_above_upper_integral=0, sanity_check=False)
Find the constant, \(\eta\) that needs adding to parcel lapse rate such that \(\int_{p_1}^{p_2} \Gamma_{env}(p) d\ln p = \int_{p_1}^{p_2} \Gamma_p(p, T_p(p)) + \eta d\ln p\). Then computes the error in this approximation: \(\int_{p_1}^{p_2} |\Gamma_{env}(p) - \Gamma_p(p, T_p(p)) - \eta| d\ln p\).
where \(\Gamma_p(p, T)\) is the parcel (moist adiabatic) lapse rate and \(T_p(p)\) is the parcel temperature at pressure \(p\) starting at \(p_1\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_env_lev
|
ndarray
|
|
required |
p_lev
|
ndarray
|
|
required |
temp_env_lower
|
float
|
Environmental temperature at lower pressure level (nearer surface) |
required |
p_lower
|
float
|
Pressure level to start profile (near surface). |
required |
temp_env_upper
|
float
|
Environmental temperature at upper pressure level (further from surface) |
required |
p_upper
|
float
|
Pressure level to end profile (further from surface). |
required |
temp_parcel_lev
|
Optional[ndarray]
|
|
None
|
temp_parcel_lower
|
Optional[float]
|
Parcel temperature at lower pressure level (nearer surface) |
None
|
temp_parcel_upper
|
Optional[float]
|
Parcel temperature at upper pressure level (further from surface) |
None
|
n_lev_above_upper_integral
|
int
|
Will return |
0
|
sanity_check
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
lapse_diff_const |
float
|
Lapse rate adjustment, \(\eta\) which needs to be added to \(\Gamma_{p}(p, T_p(p))\) so integral matches that of environmental lapse rate. Units are K/km. |
integral |
float
|
Result of integral \(\int_{p_1}^{p_2} \Gamma_{env}(p) d\ln p\). Units are K/km. |
integral_error |
float
|
Result of integral \(\int_{p_1}^{p_2} |\Gamma_{env}(p) - \Gamma_p(p) - \eta| d\ln p\). Units are K/km. |
Source code in isca_tools/thesis/lapse_integral.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |