Postprocessing API

Post-Processing routines

enstools.post.convective_adjustment_time_scale(pr, cape, th=1.0, fraction_above_th=0.0015)

Calculate the convective adjustment time scale from precipitation and CAPE as described in [1]. A gaussian filter is applied to the input data if at least one dimension has more then 30 grid points.

Parameters:
pr: xarray.DataArray

Hourly or longer accumulated precipitation converted to [kg m-2 s-1].

cape: xarray.DataArray

The CAPE of mean surface layer parcel [J kg-1]. For example, mean of start and end value of the period of the accumulation.

th: float

threshold for the precipitation rate above which the calculation should be performed [kg m-2 h-1]. Grid points with smaller precipitation values will contain missing values. Default: 1

fraction_above_th: float

fraction of grid points that must exceed the threshold defined in th. Default: 0.0015 (e.g. 15 of 10.000 grid points).

Returns:
tau: masked_array or xarray (depending on type of pr)

the convective adjustment time scale [h]

References

[1]

Keil, C., Heinlein, F. and Craig, G. C. (2014), The convective adjustment time-scale as indicator of predictability of convective precipitation. Q.J.R. Meteorol. Soc., 140: 480-490. doi:10.1002/qj.2143

Examples

>>> if np.__version__ > "1.13.9": np.set_printoptions(legacy="1.13")            # numpy version independent printing
>>> cape = xarray.DataArray([500.0, 290.44], attrs={"units": "J kg-1"})
>>> pr   = xarray.DataArray([0.0, 2.0], attrs={"units": "kg m-2 hour-1"})
>>> np.round(convective_adjustment_time_scale(pr, cape).compute(), 4)                            
<xarray.DataArray 'tauc-...' (dim_0: 2)>
array([ nan,   1.])
Dimensions without coordinates: dim_0

with not enough values above the defined threshold:

>>> np.round(convective_adjustment_time_scale(pr, cape, fraction_above_th=0.6).compute(), 4)     
<xarray.DataArray 'tauc-...' (dim_0: 2)>
array([ nan,  nan])
Dimensions without coordinates: dim_0
enstools.post.ensemble_stat(dataset, stat=['mean', 'min', 'max', 'std'], dim=None, ddof=1)

Compute ensemble mean and standard deviation from an input array or dataset.

Parameters:
datasetxarray.DataArray or xarray.Dataset

input data with ensemble dimension

statlist

list auf standard statistics to compute. Implemented are “mean”, “min”, “max”, “std”.

dimstr

name of the ensemble dimension. If None, the name is determined automatically.

ddofint

degrees of freedom in the calculation of the standard deviation.

Returns:
tuple

(mean, min_, max_, std). Tuple with one item per item in argument stat.

enstools.post.vorticity(u, v, lon, lat, fill_value=nan)

Calculate relative vorticity and its components shear and curvature on a regular lat-lon-grid.

Parameters:
u: xarray.DataArray

u-component of the wind field

v: xarray.DataArray

v-component of the wind field

lon: xarray.DataArray or np.ndarray

longitude of the input data in degrees. 1D-Array

lat: xarray.DataArray or np.ndarray

latitude of the input data in degrees. 1D-Array

fill_value: float

fill value for points at the border. Default: NaN.

Returns:
vorticity, shear_vorticity, curve_vorticity: xarray.DataArray