baseflow's People
baseflow's Issues
Multiple baseflow separation methods fails if data contains NaNs
If any NaNs are present, the returned baseflow estimates contain only NaNs for all methods apart from Fixed
and Slide
, and KGE values will be undefined for these 10 methods. MWE:
import baseflow
import numpy as np
Q, date = baseflow.load_streamflow(baseflow.example)
Q[1] = np.nan
b, KGEs = baseflow.separation(Q, date, area=276)
print(b)
[(nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan)
(nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan)
(nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan) ...
(nan, nan, 0.92596, 1.39319, nan, nan, nan, nan, nan, nan, nan, nan)
(nan, nan, 0.92596, 1.39319, nan, nan, nan, nan, nan, nan, nan, nan)
(nan, nan, 1.39319, 1.39319, nan, nan, nan, nan, nan, nan, nan, nan)]
Depending on what is considered intended behaviour, user-friendliness would be improved if either:
- A warning is implemented to detect NaNs, and possibly stop baseflow separation execution if so; or,
- Perform separation on a temporary interpolated flow vector, and replace any estimated baseflow values with NaN after:
def separation(Q, date=None, area=None, ice=None, method='all', return_kge=True):
Q = np.array(Q)
nan_mask = np.isnan(Q)
indices = np.arange(len(Q))
Q_interp = np.interp(indices, indices[~nan_mask], Q[~nan_mask])
[..]
for m in method:
if m == 'UKIH':
b[m] = UKIH(Q_interp, b_LH)
b[nan_mask] = np.nan
[..]
Nuances with approach 2 are that the edge values before and after NaNs are not necessarily accurate, and that the KGE function may need further updates to deal with NaNs in either time series.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.