swirlspy.utils.conversion package

Data conversion methods

swirlspy.utils.conversion.to_rainfall_depth(frames: xarray.core.dataarray.DataArray, **kwargs)

Convert data frames’ value to accumulated rainfall. If Z-R relationship is used, default a & b are Marshall-Plalmer. You may wish to refer to the Z-R relationship page for more information on the choice of a & b.

Parameters:

frames (xarray.DataArray) – data frames to be convert

Other Parameters:
 
  • a (float) – a in Z = aR^b relationship
  • b (float) – b in Z = aR^b relationship
Returns:

r – xarray containing the accumulated rainfall depth relationship return frames no need to do any conversion

Return type:

xarray.DataArray

swirlspy.utils.conversion.to_rainfall_rate(frames: xarray.core.dataarray.DataArray, logarithmic: bool, **kwargs)

Convert data frames’ value to rainfall rate. If Z-R relationship is used, default a & b are Marshall-Plalmer. You may wish to refer to the Z-R relationship page for more information on the choice of a & b.

Parameters:

frames (xarray.DataArray) – data frames to be convert

Other Parameters:
 
  • a (float) – a in Z = aR^b relationship
  • b (float) – b in Z = aR^b relationship
Returns:

r – xarray containing the rainfall rate relationship return frames no need to do any conversion

Return type:

xarray.DataArray

swirlspy.utils.conversion.to_reflectivity(frames: xarray.core.dataarray.DataArray, logarithmic: bool, **kwargs)

Convert data frames’ value to radar reflectivity factor. If Z-R relationship is used, default a & b are Marshall-Plalmer. You may wish to refer to the Z-R relationship page for more information on the choice of a & b.

Parameters:

frames (xarray.DataArray) – data frames to be convert

Other Parameters:
 
  • a (float) – a in Z = aR^b relationship
  • b (float) – b in Z = aR^b relationship
Returns:

r – xarray containing the radar reflectivity factor relationship return frames no need to do any conversion

Return type:

xarray.DataArray

swirlspy.utils.conversion.acc_rainfall_depth(frames, start_time, end_time, result_step_size=Timedelta('0 days 00:30:00'), acc_interval=Timedelta('0 days 01:00:00'))

Obtain accumulated rainfall over a time period from a start_time to an end_time at certain times. For example, to generate past 60 minute rainfall every 30 minutes from start_time = x to end_time = y (inclusive).

acc_rainfall_depth(
frames, start_time, end_time, result_step_size=pd.Timedelta(minutes=30), acc_interval=pd.Timedelta(minutes=60)

)

Parameters:
  • frames (xarray.DataArray) – Contains observed and/or forecasted rainfall every n minutes, n being the interval (in minutes) between two timestamps.
  • start_time (pandas.Timestamp) – The first base time of accumulation.
  • end_time (pandas.Timestamp) – The last base time of accumulation.
  • result_step_size (pandas.Timedelta) – Times at which accumulated rainfall are to be calculated. Defaults to every 30 minutes.
  • acc_interval (pandas.Timedelta) – Rainfall accumulation period. Defaults to 1 hour.
Returns:

macc_rf – Contains accumulated rainfall over acc_interval every times.

Return type:

xarray,DataArray

swirlspy.utils.conversion.temporal_interpolate(frames, start_time, end_time, result_step_size=Timedelta('0 days 00:06:00'), interp_type='linear')

Interpolate xarray data values such as rainrates along the time dimension.

Parameters:
  • frames (xarray.DataArray) – Contains data values to be temporally interpolated.
  • start_time (pandas.Timestamp) – User defined start-time.
  • end_time (pandas.Timestamp) – The user-defined end time.
  • result_step_size (pandas.Timedelta) – The time interval between interpolated data. Defaults to 6 minutes.
  • interp_type (str) – The interpolation type for interpolating data in the time axis. Options include: ‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘previous’, ‘next’. Interpolation based on scipy.interpolate.interp1d. Default is linear.
Returns:

interp_da – Contains data interpolated along the time axis.

Return type:

xarray.DataArray

swirlspy.utils.conversion.tz2naive(timestamp)

Convert timezone-aware pandas.Timestamp to timezone-naive pandas.Timestamp in local time