wrf.cape_3d¶
- wrf.cape_3d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, missing=<MagicMock name='mock().item()' id='140499233145616'>, meta=True)¶
Return the three-dimensional CAPE and CIN.
This function calculates the maximum convective available potential energy (CAPE) and maximum convective inhibition (CIN). This function uses the RIP [Read/Interpolate/plot] code to calculate potential energy (CAPE) and convective inhibition (CIN) [J kg-1] for every grid point in the entire 3D domain (treating each grid point as a parcel).
The leftmost dimension of the returned array represents two different quantities:
return_val[0,…] will contain CAPE [J kg-1]
return_val[1,…] will contain CIN [J kg-1]
This function also supports computing CAPE along a single vertical column. In this mode, the pres_hpa, tkel, qv and height arguments must be one-dimensional vertical columns, and the terrain and psfc_hpa arguments must be scalar values (
float
,numpy.float32
ornumpy.float64
).This is the raw computational algorithm and does not extract any variables from WRF output files. Use
wrf.getvar()
to both extract and compute diagnostic variables.- Parameters:
pres_hpa (
xarray.DataArray
ornumpy.ndarray
) –Full pressure (perturbation + base state pressure) in [hPa] with at least three dimensions when operating on a grid of values. The rightmost dimensions can be top_bottom x south_north x west_east or bottom_top x south_north x west_east. When operating on only a single column of values, the vertical column can be bottom_top or top_bottom. In this case, terrain and psfc_hpa must be scalars.
Note
The units for pres_hpa are [hPa].
Note
This variable must be supplied as a
xarray.DataArray
in order to copy the dimension names to the output. Otherwise, default names will be used.tkel (
xarray.DataArray
ornumpy.ndarray
) – Temperature in [K] with same dimensionality as pres_hpa.qv (
xarray.DataArray
ornumpy.ndarray
) – Water vapor mixing ratio in [kg/kg] with the same dimensionality as pres_hpa.height (
xarray.DataArray
ornumpy.ndarray
) – Geopotential height in [m] with the same dimensionality as pres_hpa.terrain (
xarray.DataArray
,numpy.ndarray
, or a scalar) – Terrain height in [m]. When operating on a grid of values, this argument is at least a two-dimensional array with the same dimensionality as pres_hpa, excluding the vertical (bottom_top/top_bottom) dimension. When operating on a single vertical column, this argument must be a scalar (float
,numpy.float32
, ornumpy.float64
).psfc_hpa (
xarray.DataArray
,numpy.ndarray
, or a scalar) –Surface pressure in [hPa]. When operating on a grid of values, this argument is at least a two-dimensional array with the same dimensionality as pres_hpa, excluding the vertical (bottom_top/top_bottom) dimension. When operating on a single vertical column, this argument must be a scalar (
float
,numpy.float32
, ornumpy.float64
).Note
The units for psfc_hpa are [hPa].
ter_follow (
bool
) – A boolean that should be set to True if the data uses terrain following coordinates (WRF data). Set to False for pressure level data.missing (
float
, optional) – The fill value to use for the output. Default iswrf.default_fill(numpy.float64)
.meta (
bool
) – Set to False to disable metadata and returnnumpy.ndarray
instead ofxarray.DataArray
. Default is True.
Warning
The input arrays must not contain any missing/fill values or
numpy.nan
values.- Returns:
The CAPE and CIN as an array whose leftmost dimension is 2 (0=CAPE, 1=CIN). If xarray is enabled and the meta parameter is True, then the result will be an
xarray.DataArray
object. Otherwise, the result will be anumpy.ndarray
object with no metadata.- Return type:
See also