Giter VIP home page Giter VIP logo

baseflow's People

Contributors

xiejx5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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:

  1. A warning is implemented to detect NaNs, and possibly stop baseflow separation execution if so; or,
  2. 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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.