wrf.cape_3d

wrf.cape_3d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, missingval=9.969209968386869e+36, 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 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 or numpy.ndarray) –

    Full pressure (perturbation + base state pressure) in [hPa] with at least three dimensions. The rightmost dimensions can be top_bottom x south_north x west_east or bottom_top x south_north x west_east.

    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 or numpy.ndarray) – Temperature in [K] with same dimensionality as pres_hpa.
  • qv (xarray.DataArray or numpy.ndarray) – Water vapor mixing ratio in [kg/kg] with the same dimensionality as pres_hpa.
  • height (xarray.DataArray or numpy.ndarray) – Geopotential height in [m] with the same dimensionality as pres_hpa.
  • terrain (xarray.DataArray or numpy.ndarray) – Terrain height in [m]. This is at least a two-dimensional array with the same dimensionality as pres_hpa, excluding the vertical (bottom_top/top_bottom) dimension.
  • psfc_hpa (xarray.DataArray or numpy.ndarray) –

    The surface pressure in [hPa]. This is at least a two-dimensional array with the same dimensionality as pres_hpa, excluding the vertical (bottom_top/top_bottom) dimension.

    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.
  • missingval (float, optional) – The fill value to use for the output. Default is wrf.Constants.DEFAULT_FILL.
  • meta (bool) – Set to False to disable metadata and return numpy.ndarray instead of xarray.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 a numpy.ndarray object with no metadata.
Return type:xarray.DataArray or numpy.ndarray