Rainfall
- To do:
To read, compute, and show rainfall data
- class IO.Rainfall.Rainfall(rain_mask, rain_source, source_sep=',', dem_ras=None)
a class to set rainfall data for the model
- time_s
1-col array, time in seconds
- mask_header
dictionary showing mask georeference
- mask_dict
dict with two keys:’value’ and ‘index’, providing int array showing rain source number and their index respectively
- rain_rate
numpy array m/s
- attrs
summary of the object
- subs_in
tuple of row and col number, provide subs of the mask array values inside the model domain. Only available when dem_ras is given
- start_date
start date and time of time zero in time_s
- time_dt
datetime format of time_s
- __init__(rain_mask, rain_source, source_sep=',', dem_ras=None)
initialize rainfall object with source file and mask file
- Parameters:
rain_mask – str [filename of a Raster endswith .gz/asc/tif] numpy int array with the same shape with DEM array a Raster object. If rain_mask is a scalar or array, dem_ras must be provided.
rain_source – numpy array the 1st column is time in seconds, 2nd to the end columns are rainfall rates in m/s. str [filename of a csv file for rainfall source data]
dem_ras – a Raster object for DEM
source_sep – delimeter of the rain source file
- get_attrs()
define rain_attr
- get_mask_array()
Return a mask array
- get_source_array()
Return a source array, first column is time_s, then continue with rain_rate in m/s
- get_spatial_map(method='sum')
Get spatial rainfall map over time series
- Parameters:
rain_mask_obj – asc file name or Raster object for rain mask
cellsize – resample the rain_mask to a new grid (with larger cellsize)
method – sum|mean caculate method for each cell, sum by time or mean by time
- get_time_series(method='mean', rain_rate_valid=None)
Plot time series of average rainfall rate inside the model domain
- Parameters:
method – ‘mean’|’max’,’min’,’mean’method to calculate gridded rainfall over the model domain
- get_valid_rain_rate(unique=True)
Get a rain rate array over valid cells
row is time axis, col is source id axis
- plot_rainfall_map(method='sum', cmap='YlGnBu', **kw)
plot rainfall map within model domain method: the way to calculate time series rainfall rate
- plot_time_series(method='mean', dt_interval=24, dt_format='%m-%d', title_str=None, **kwargs)
Plot time series of average rainfall rate inside the model domain method: ‘mean’|’max’,’min’,’mean’method to calculate gridded rainfall over the model domain
- set_mask(rain_mask, dem_ras=None)
Set rainfall mask from a scalar or a grid (object/file)
if rain_mask is a scalar or array, dem_ras must be provided
- set_source(rain_source, delimiter=',')
Set rainfall mask from a numpy array or a csv file
- set_start_date(datetime_str, fmt)
Set start date for the time series