Closed steinadio closed 3 years ago
Finding more work is needed to be done on this ... but almost there.
Have added in making certain any up/downstream variable splitting for segs without hrus are left as nan rather than assigned values.
Current issue fixing: up/down_seg selected can still be a seg without hru because up_seg looks through all the segs to find the best match while down_seg is based on network topology .... and these hruless segs may not be headwaters and may be downstream of another seg. And this actually happens, at least for the Yakima. This issue was found from running the resulting dataset with bmorph and there were issues when doing SCBC_C but not SCBC_U ... specifically a "RuntimeWarning: invalid value encountered in true_divide" in line 48 of bmorph.py ... which is the cqm method, meaning that nan values were reaching them despite hruless segs not being ran (which makes sense seeing above).
Found that what I thought was the error was not the error. While hruless segs can be assigned as up/down_seg, it is the up/down_ref_segs that are used to pick out data for bias correction, which were not these. The error was instead having a CDF of nans due to timeseries being filled with zeros ... so those were filled with 1e-15 instead and now it runs.
Addressing the issue https://github.com/UW-Hydro/bmorph/issues/85
has_hru
has been added as a binary identifier to determine whether or a segment should be bias corrected or not based on if it is assigned an hru or not. Also, if a segment is not assigned an hru, then conditioning data mapped to it is replaced with nans rather than any fallback and a warning is printed.