saber.saber
fdc_mapping(sim_df, obs_df)
Bias corrects a dataframe of simulated values using a dataframe of observed values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sim_df |
pd.DataFrame
|
A dataframe with a datetime index and a single column of streamflow values |
required |
obs_df |
pd.DataFrame
|
A dataframe with a datetime index and a single column of streamflow values |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
pandas DataFrame with a datetime index and a single column of streamflow values |
Source code in saber/saber.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
map_saber(mid, asgn_mid, asgn_gid, hz, gauge_data)
Corrects all streams in the assignment table using the SABER method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mid |
str
|
the model id of the stream to be corrected |
required |
asgn_mid |
str
|
the model id of the stream assigned to mid for bias correction |
required |
asgn_gid |
str
|
the gauge id of the stream assigned to mid for bias correction |
required |
hz |
str
|
xarray dataset of hindcast streamflow data |
required |
gauge_data |
str
|
path to the directory of observed data |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame | tuple | None
|
None |
Source code in saber/saber.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
mp_saber(assign_df, hindcast_zarr, gauge_data, save_dir=None, n_processes=None)
Corrects all streams in the assignment table using the SABER method with a multiprocessing Pool
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assign_df |
pd.DataFrame
|
the assignment table |
required |
hindcast_zarr |
str
|
string path to the hindcast streamflow dataset in zarr format |
required |
gauge_data |
str
|
path to the directory of observed data |
required |
save_dir |
str
|
path to the directory to save the corrected data |
None
|
n_processes |
number of processes to use for multiprocessing, passed to Pool |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in saber/saber.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
sfdc_mapping(sim_flow_a, obs_flow_a, sim_flow_b=None, use_log=False, fix_seasonally=True, empty_months='skip', drop_outliers=False, outlier_threshold=2.5, filter_scalar_fdc=False, filter_range=(0, 80), extrapolate='nearest', fill_value=None, fit_gumbel=False, fit_range=(10, 90), metadata=False)
Removes the bias from simulated discharge using the SABER method.
Given simulated and observed discharge at location A, removes bias from simulated data at point A. Given simulated and observed discharge at location A, removes bias from simulated data at point B, if given B.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sim_flow_a |
pd.DataFrame
|
simulated hydrograph at point A. should contain a datetime index with daily values and a single column of discharge values. |
required |
obs_flow_a |
pd.DataFrame
|
observed hydrograph at point A. should contain a datetime index with daily values and a single column of discharge values. |
required |
sim_flow_b |
pd.DataFrame
|
(optional) simulated hydrograph at point B to correct using scalar flow duration curve mapping and the bias relationship at point A. should contain a datetime index with daily values and a single column of discharge values. |
None
|
use_log |
bool
|
(optional) if True, log10 transform the discharge values before correcting. default is False. |
False
|
fix_seasonally |
bool
|
fix on a monthly (True) or annual (False) basis |
True
|
empty_months |
str
|
how to handle months in the simulated data where no observed data are available. Options: "skip": ignore simulated data for months without |
'skip'
|
drop_outliers |
bool
|
flag to exclude outliers |
False
|
outlier_threshold |
int or float
|
number of std deviations from mean to exclude from flow duration curve |
2.5
|
filter_scalar_fdc |
bool
|
flag to filter the scalar flow duration curve |
False
|
filter_range |
tuple
|
lower and upper bounds of the filter range |
(0, 80)
|
extrapolate |
str
|
method to use for extrapolation. Options: nearest, const, linear, average, max, min |
'nearest'
|
fill_value |
int or float
|
value to use for extrapolation when extrapolate_method='const' |
None
|
fit_gumbel |
bool
|
flag to replace extremely low/high corrected flows with values from Gumbel type 1 |
False
|
fit_range |
tuple
|
lower and upper bounds of exceedance probabilities to replace with Gumbel values |
(10, 90)
|
metadata |
bool
|
flag to return the scalars and metadata about the correction process |
False
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
pd.DataFrame with a DateTime index and columns with corrected flow, uncorrected flow, the scalar adjustment |
pd.DataFrame
|
factor applied to correct the discharge, and the percentile of the uncorrected flow (in the seasonal grouping, |
pd.DataFrame
|
if applicable). |
Source code in saber/saber.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|