Profile Fitting
get_lnb_lev_ind(temp_env, z_env, p_env, p_max=400 * 100, lapse_thresh=5, lapse_change_thresh=2, n_iter=5, lev_dim='lev')
Finds the index of level of neutral buoyancy in dimension lev_dim
that satisfies the following conditions
(basically so no stratospheric influence between LNB and surface):
- LNB must be a pressure lower than
p_max
. - LNB is level above which is the first layer with negative lapse rate.
- If lapse rate in level immediately below this deviates from the lapse rate in the level below that
or two below that by more than
lapse_change_thresh
, then LNB is moved to a lower level by 1. This process is repeatedn_iter
times. - Lapse rate in level immediately below LNB must be less than
lapse_thresh
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temp_env
|
DataArray
|
Environmental temperature profile in Kelvin. |
required |
z_env
|
DataArray
|
Environment geopotential height profile in m. |
required |
p_env
|
DataArray
|
Environment pressure profile in Pa
(assumed different for each location i.e. same dimensions as |
required |
p_max
|
float
|
Pressure of LNB cannot exceed this value (i.e. further from surface than this). |
400 * 100
|
lapse_thresh
|
float
|
Lapse rate in level immediately below LNB must be less than |
5
|
lapse_change_thresh
|
float
|
If lapse rate in level immediately below LNB deviates from the lapse rate in the level below that or two below that by more than this, then LNB is moved to a lower level by 1. |
2
|
n_iter
|
int
|
Number of iterations to run |
5
|
lev_dim
|
str
|
Name of dimension for vertical model level. |
'lev'
|
Returns:
Name | Type | Description |
---|---|---|
lnb_ind |
DataArray
|
Index of level of neutral buoyancy in dimension |
Source code in isca_tools/thesis/profile_fitting.py
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_mse_env(temp_env, p_env, z_env, p_lcl, prof_type='full', temp_at_lcl=None, sphum_below_lcl=None)
Returns environmental MSE profile as a function of pressure \(p\), which satisfies the following if
prof_type = full
:
- Above LCL: \(MSE_{env}(p) = MSE^*(p)\)
- Below LCL: \(MSE_{env}(p) = DSE(p) + L_v q^*_{LCL}\)
Where \(q^*_{LCL}\) is the saturation-specific humidity evaluated at \(T_{env}(p_{lcl})\). The two profiles are the same at the LCL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temp_env
|
DataArray
|
|
required |
p_env
|
DataArray
|
|
required |
z_env
|
DataArray
|
|
required |
p_lcl
|
DataArray
|
Pressure of LCL in Pa. |
required |
prof_type
|
Literal['full', 'above_lcl', 'below_lcl']
|
If |
'full'
|
temp_at_lcl
|
Optional[DataArray]
|
Environment temperature at |
None
|
sphum_below_lcl
|
Optional[DataArray]
|
Specific humidity to use for profile below the LCL. If not given, will set to \(q^*(T(p_{LCL}), p_{LCL})\). |
None
|
Returns:
Name | Type | Description |
---|---|---|
mse_env |
DataArray
|
|
Source code in isca_tools/thesis/profile_fitting.py
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 |
|
get_mse_prof_rms(temp_env, p_env, z_env, p_thickness, temp_at_split=None, p_split=None, z_at_split=None, lev_dim='lev', split_dim='lev')
For each possible split level, will compute the RMS error of \(MSE_{env} - MSE^*_{split}\) where:
- Above Split: \(MSE_{env}(p) = MSE^*(p)\)
- Below Split: \(MSE_{env}(p) = DSE(p) + L_v q^*_{split}\)
Idea being that LCL is split level with minimum RMS error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temp_env
|
DataArray
|
Environmental temperature [K], dims (..., lev_dim) |
required |
p_env
|
DataArray
|
Environmental pressure [Pa], dims (..., lev_dim) |
required |
z_env
|
DataArray
|
Geopotential height [m], dims (..., lev_dim) |
required |
p_thickness
|
DataArray
|
Pressure thickness between levels [Pa], dims (..., lev_dim) |
required |
temp_at_split
|
Optional[DataArray]
|
Temperature to use as |
None
|
p_split
|
Optional[DataArray]
|
Pressure to use as |
None
|
z_at_split
|
Optional[ndarray]
|
Geopotential height corresponding to |
None
|
lev_dim
|
str
|
Model level dimension in |
'lev'
|
split_dim
|
str
|
Dimension corresponding to different split levels in |
'lev'
|
Returns:
Name | Type | Description |
---|---|---|
mse_prof_error |
DataArray
|
Mass weighted RMS difference for each possible split level, dims (..., split_dim) |
Source code in isca_tools/thesis/profile_fitting.py
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 |
|
get_p_from_pnorm(pnorm, p_low, p_high)
Given the normalized pressure coordinate pnorm
, this inverts get_pnorm
to give the physical pressure in Pa.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pnorm
|
Union[DataArray, ndarray, float]
|
Normalized pressure coordinate (dimensionless). |
required |
p_low
|
Union[DataArray, ndarray, float]
|
Low level pressure used to compute |
required |
p_high
|
Union[DataArray, ndarray, float]
|
High level pressure used to compute |
required |
Returns:
Name | Type | Description |
---|---|---|
p |
Union[DataArray, ndarray, float]
|
Pressure corresponding to |
Source code in isca_tools/thesis/profile_fitting.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
get_pnorm(p, p_low, p_high)
Given the pressure, \(p\), this returns a normalized pressure coordinate going from 0 at \(p_{low}\) to 1 at \(p_{high}\):
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p
|
Union[DataArray, ndarray, float]
|
Pressure in Pa. |
required |
p_low
|
Union[DataArray, ndarray, float]
|
Low level pressure (closer to surface) in Pa. |
required |
p_high
|
Union[DataArray, ndarray, float]
|
High level pressure (further from surface so \(p_{high} < p_{low}\)) in Pa. |
required |
Returns:
Name | Type | Description |
---|---|---|
pnorm |
Union[DataArray, ndarray, float]
|
Value of pressure \(p\) in normalized pressure coordinates between 0 and 1. |
Source code in isca_tools/thesis/profile_fitting.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
interp_var_to_pnorm(var, p, var_at_low, p_low, var_at_high, p_high, lnb_ind, d_pnorm=0.1, pnorm_custom_grid=None, extrapolate=True, insert_low=True, insert_high=True, lev_dim='lev', pnorm_dim_name='pnorm', subtract_var_at_low=True)
Interpolate var
as a function of pressure, \(p\), into \(p_{norm}\) that goes from 0 at
\(p_{low}\) to 1 at \(p_{high}\) according to:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var
|
DataArray
|
|
required |
p
|
DataArray
|
|
required |
var_at_low
|
DataArray
|
Value of |
required |
p_low
|
Union[DataArray, float]
|
Pressure level that will correspond to \(p_{norm}=0\). |
required |
var_at_high
|
DataArray
|
Value of |
required |
p_high
|
Union[DataArray, float]
|
Pressure level that will correspond to \(p_{norm}=1\). |
required |
lnb_ind
|
DataArray
|
The value of |
required |
d_pnorm
|
float
|
Desired spacing in \(p_{norm}\) coordinates. |
0.1
|
pnorm_custom_grid
|
Optional[ndarray]
|
Option to provide the \(p_{norm}\) coordinates. Will override the |
None
|
extrapolate
|
bool
|
Whether to extrapolate above LNB. |
True
|
insert_low
|
bool
|
Whether to add |
True
|
insert_high
|
bool
|
Whether to add |
True
|
lev_dim
|
str
|
Name of dimension for vertical model level. |
'lev'
|
pnorm_dim_name
|
str
|
Name of the output |
'pnorm'
|
subtract_var_at_low
|
bool
|
If |
True
|
Returns:
Name | Type | Description |
---|---|---|
var |
DataArray
|
|
n_extrapolate |
DataArray
|
Number of model levels used above LNB that were extrapolated.
Only non-zero if |
Source code in isca_tools/thesis/profile_fitting.py
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 181 182 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 218 219 220 221 |
|