meteodatalab.operators.time_operators

Various time operators.

Functions

delta(field, dtime)

Compute difference for a given delta in time.

get_nsteps(valid_time, dtime)

Compute number of steps required for a given time delta.

resample(field, interval)

Resample field.

resample_average(field, dtime)

Compute weighted difference for a given delta in time.

time_rate(var, dtime)

Compute a time rate for a given delta in time.

meteodatalab.operators.time_operators.delta(field: DataArray, dtime: timedelta64) DataArray[source]

Compute difference for a given delta in time.

Parameters:
  • field (xr.DataArray) – Field that contains the input data.

  • dtime (np.timedelta64) – Time delta for which to evaluate the difference.

Raises:

ValueError – if dtime is not multiple of the field time step or if the time step is not regular.

Returns:

The field difference for the given time delta.

Return type:

xr.DataArray

meteodatalab.operators.time_operators.get_nsteps(valid_time: DataArray, dtime: timedelta64) int[source]

Compute number of steps required for a given time delta.

Parameters:
  • valid_time (xr.DataArray) – Array of time values.

  • dtime (np.timedelta64) – Time difference for which to search the corresponding number of steps.

Raises:

ValueError – if the time difference is not a multiple of the given time index step or if the array of time values is not uniform.

Returns:

Number of time steps.

Return type:

int

meteodatalab.operators.time_operators.resample(field: DataArray, interval: timedelta64) DataArray[source]

Resample field.

The interval must be a multiple of the current time step. No interpolation is performed.

Parameters:
  • field (xr.DataArray) – Field that contains the input data.

  • interval (np.timedelta64) – Output sample interval.

Raises:

ValueError – if dtime is not multiple of the field time step or if the time step is not regular.

Returns:

The resampled field.

Return type:

xr.DataArray

meteodatalab.operators.time_operators.resample_average(field: DataArray, dtime: timedelta64) DataArray[source]

Compute weighted difference for a given delta in time.

This operator is useful for recomputing time averaged values that are aggregated from the reference time to the lead time. The output field is averaged with respect to the given time interval for every lead time present in the input field. The output for lead times that are smaller than the reference time shifted by the interval are undefined.

Note that this operator is named tdelta in fieldextra.

Parameters:
  • field (xr.DataArray) – Field that contains the input data.

  • dtime (np.timedelta64) – Time delta for which to evaluate the difference.

Raises:

ValueError – if dtime is not multiple of the field time step or if the time step is not regular.

Returns:

The field weighted difference for the given time delta.

Return type:

xr.DataArray

meteodatalab.operators.time_operators.time_rate(var: DataArray, dtime: timedelta64)[source]

Compute a time rate for a given delta in time.

It assumes the input data is an accumulated value between two time steps of the time coordinate

Parameters:
  • var – variable that contains the input data

  • dtime – delta time of the desired output time rate