radarx.retrieve.lightning.flash_rate#

radarx.retrieve.lightning.flash_rate(obj, *, interval='1min', time_edges=None, coverage=None)[source]#

Number of flashes and the flash rate per time interval.

Parameters:
  • obj (xarray.Dataset, xarray.DataArray or array-like) – The flashes: a dataset with flash_time_start (as returned by cluster_flashes(), or the flash table of a GLM file), or the flash start times themselves.

  • interval (str or timedelta, optional) – Length of the time bins, e.g. "1min" (default), when time_edges is not given. The bins are aligned to multiples of the interval and cover all flashes.

  • time_edges (array-like of datetime64, optional) – Explicit bin edges (at least two, increasing); flashes outside are not counted. The last bin may be shorter than the others; its rate uses its own length.

  • coverage (sequence of (start, end), optional) – The times the instrument data cover (for example the granules of the GLM files read, or the span of the LMA files). A bin that is not covered completely by one of these intervals has no count and no rate (NaN), because a bin without data is not a bin without lightning. Default: every bin is covered.

Returns:

xarray.Dataset – flash_count (1) and flash_rate (flashes min-1) on time (bin centres, with time_bounds).

Notes

A flash that starts exactly at the last edge is counted in the last bin. The rate is the count divided by the length of the bin in minutes. Feed the rate to lightning_jump() after averaging it over its period.

Dask. This function computes the dask array: the flash counts are reduced over all flashes. The input is loaded into memory and the result is held in memory.

Examples

>>> t = np.array(["2022-03-30T00:00:10", "2022-03-30T00:01:20"], "datetime64[ns]")
>>> radarx.retrieve.flash_rate(t, interval="1min").flash_count.values
array([1., 1.])