radarx.retrieve.lagrangian.trajectories#

radarx.retrieve.lagrangian.trajectories(winds, time=None, *, direction='backward', start=None, levels=None, dt=20.0, iterations=3, max_steps=None, storm_motion=None, extend=0.0, extend_before=None, extend_after=None, surface_downdraft=True, termination=True, boundary='environment', parameters=None, u='u', v='v', w='w', dbz='auto', valid=None, environment_mask=None, n_threads=None, engine='auto')[source]#

Backward or forward air trajectories through a time series of 3-D winds.

Parameters:
  • winds (xarray.Dataset) – Winds on (time, z, y, x) (any order; time may be absent for a single analysis used with storm_motion and extend), with coordinates x, y (m, increasing) and z (m, increasing; the lowest level is the ground), e.g. a time series of radarx.retrieve.multi_doppler() analyses joined with xr.concat(..., "time"). Ground-relative winds in m s-1.

  • time (datetime-like, optional) – Analysis time at which the trajectories start. Default: the last wind time for backward and the first for forward trajectories. It need not be one of the wind times.

  • direction ({"backward", "forward"}, optional) – Integration direction. Default "backward".

  • start (xarray.Dataset or dict, optional) – Start points as x, y, z arrays (m) of the same shape. Default: every grid point (those of levels), with points of the lowest level started at the offset height above it.

  • levels (sequence of int, optional) – Grid level indices to start from when start is not given. Default: all levels.

  • dt (float, optional) – Time step in s. Default 20 (Z13a [1], sect. 2b, p. 2250).

  • iterations (int, optional) – Corrector iterations per step. Default 3 (Z13a [1], sect. 2b; Z07 [3], p. 2422).

  • max_steps (int, optional) – Maximum number of steps. Default: enough to reach the end of the wind time series (plus extend).

  • storm_motion ((float, float), xarray.Dataset or "estimate", optional) – Constant storm motion \((c_x, c_y)\) in m s-1 with which every analysis is moved between its time and the parcel time: a pair, the domain-wide output of radarx.retrieve.estimate_motion() (u, v), or "estimate" to estimate it with radarx.retrieve.estimate_motion() from the reflectivity of the first and last wind times. Default: no motion (fixed analyses).

  • extend (float or (float, float), optional) – Seconds by which the series is extended before the first and after the last analysis by moving those analyses with storm_motion (time morphing, Z13b [2], sect. 2c, p. 2268). Default 0.

  • extend_before, extend_after (float, optional) – Seconds of time morphing before the first and after the last analysis; override the corresponding part of extend. For backward trajectories extend_before lets parcels of an air mass older than the wind series (e.g. a squall-line cold pool) reach the environment.

  • surface_downdraft (bool, optional) – Replace the vertical velocity at the ground with the parameterised surface downdraft (Z13a [1], eqs. 2-3, p. 2251). Default True.

  • termination ({True, "ziegler2013", "precipitation", False}, optional) – Environment test of backward trajectories. True or "ziegler2013" (default): the tests of Z13a [1] (sect. 2a, p. 2250). "precipitation": the parcel is outside precipitation (\(Z_H\) below env_dbz for env_dbz_steps steps) and either above cold_pool_depth or where environment_mask is true (e.g. ahead of the gust front); see the module documentation. False: no test (trajectories run to max_steps or the data).

  • boundary (str or sequence of str, optional) – Which exits through a lateral boundary count as reaching the environment (backward trajectories with a termination test). "environment" (default, Z13a [1], sect. 2a, test iii): every exit. "environment_mask": only where environment_mask is true at the last point inside the domain. "no_echo": only where the reflectivity there is below env_dbz or the mask is true. A sequence of sides ("west", "east", "south", "north"; the domain edges at the smallest and largest x and y): only exits through those sides. Other exits stop the trajectory with flag 128 and are not environmental.

  • parameters (dict, optional) – Overrides of TRAJECTORY_DEFAULTS (sources of every default are listed there): offset_height (m), wmix0, wmix1 (m s-1), z0_dbz, zddc_dbz (dBZ), min_steps, env_dbz (dBZ), env_w (m s-1), env_w_steps, env_dbz_steps, cold_pool_depth (m above the ground) and dbz_floor (dBZ given to missing reflectivity).

  • u, v, w (str, optional) – Names of the wind components. Default "u", "v", "w".

  • dbz (str or None, optional) – Reflectivity (dBZ) variable, "auto" (default: the first of DBZ, DBZH, reflectivity, corrected_reflectivity, dbz) or None (not used; the reflectivity test of the environment is then never met).

  • valid (str or xarray.DataArray, optional) – True (non-zero) where the winds are analysed, e.g. "dd_valid" of radarx.retrieve.multi_doppler() output, and false where they are a background or filled. Interpolated to the parcels; the fraction of trajectory points with a value of at least 0.5 is returned as valid_fraction. Default: all valid.

  • environment_mask (str or xarray.DataArray, optional) – True where a parcel may count as environmental for termination="precipitation" below cold_pool_depth (e.g. the air ahead of the gust front). Default: nowhere.

  • n_threads (int, optional) – Threads of the compiled kernel. Default: all cores.

  • engine ({"auto", "compiled", "numpy"}, optional) – Implementation. "auto" (default) prefers the compiled kernel.

Returns:

xarray.Dataset – On (trajectory, step): x, y, z (m), time (datetime64), u, v, w (m s-1, w with the surface downdraft), reflectivity (dBZ) and valid (0-1) at every point (NaN after the end); on trajectory: n_points, valid_fraction, flags (bit mask, see the module documentation), environment (True where the trajectory reached the storm environment or a lateral boundary) and the start point start_x, start_y, start_z (plus the grid indices k, j, i for gridpoint trajectories).

Notes

Dask. This function computes the dask array: it follows trajectories through the winds of all times. The input is loaded into memory and the result is held in memory.

References

[1] Ziegler, C. L., 2013a: A diabatic Lagrangian technique for the analysis of convective storms. Part I: Description and validation via an observing system simulation experiment. J. Atmos. Oceanic Technol., 30 (10), 2248-2265, https://doi.org/10.1175/JTECH-D-12-00194.1

[2] Ziegler, C. L., 2013b: A diabatic Lagrangian technique for the analysis of convective storms. Part II: Application to a radar-observed storm. J. Atmos. Oceanic Technol., 30 (10), 2266-2280, https://doi.org/10.1175/JTECH-D-13-00036.1

[3] Ziegler, C. L., M. S. Buban, and E. N. Rasmussen, 2007: A Lagrangian objective analysis technique for assimilating in situ observations with multiple-radar-derived airflow. Mon. Wea. Rev., 135 (7), 2417-2442, https://doi.org/10.1175/MWR3396.1

Examples

>>> import numpy as np, xarray as xr
>>> from radarx.retrieve import trajectories
>>> c = np.arange(0.0, 10001.0, 1000.0)
>>> t = np.array(["2022-03-30T23:00", "2022-03-30T23:10"], "datetime64[ns]")
>>> ds = xr.Dataset(
...     {k: (("time", "z", "y", "x"), np.full((2, 11, 11, 11), val))
...      for k, val in (("u", 5.0), ("v", 0.0), ("w", 0.0))},
...     coords={"time": t, "z": c, "y": c, "x": c})
>>> tr = trajectories(ds, start={"x": [8000.0], "y": [5000.0], "z": [3000.0]},
...                   dbz=None)
>>> float(tr.x.isel(step=int(tr.n_points[0]) - 1)[0])
5000.0