GithubHelp home page GithubHelp logo

Comments (5)

mroberge avatar mroberge commented on June 14, 2024

This is a great idea! I love your solution. Would you be interested in submitting it in a pull request?

If you are interested, I could walk you through how to do it.

from hydrofunctions.

mroberge avatar mroberge commented on June 14, 2024

I figured out what triggered this behavior. The default behavior is to return all of the data if no parameters are requested. So if you request my_nwis_object.df() you will get every parameter in the dataset. Because I set up separate pathways for 'discharge', 'q', and 'stage' (which I use all the time) the code is slightly different for these than for any other parameter. For these, if you request them and there is nothing there, no new columns get selected and df() goes to the next item (station.py line 238). For any other parameter, if the parameter isn't in one of the column names, it raises a ValueError (station.py line 251).

Some solutions are:

  1. raise ValueErrors for 'discharge', 'q', & 'stage' at lines 238, 240, & 242 (con: it is repetitive, not DRY)
  2. check list of args for 'discharge', 'q', & 'stage', then replace them with the parameter codes ( 00060 & 00065) (pro: it would be easier to add more shortcuts. con: adds another loop)
  3. raise ValueError after the loop (line 272) instead of selecting all columns if no parameters are selected. (pro: if someone asks for two parameters and only one is there, it might be better to NOT raise an error? con: we'd have to find another way to return the whole dataframe if nothing is selected.)

from hydrofunctions.

mroberge avatar mroberge commented on June 14, 2024

I think I like option # 2, which would just change the 'discharge' case from an elif to an if:

line 238:

    if item == 'discharge':
        item = '00060'
    elif item == 'stage':
        item = '00065'

... and so on. The other elif lines would stay the same, except for the first at line 248. This would substitute the shortcut for the actual parameter code, and then treat it like any other parameter code.

What are your thoughts?

BTW, would you like to add a 'res_level' shortcut or something?

from hydrofunctions.

dgketchum avatar dgketchum commented on June 14, 2024

from hydrofunctions.

mroberge avatar mroberge commented on June 14, 2024

@dgketchum I just took one of your commits from your pull request and added a test. I'm closing this issue with commit 86f83ec
Thank you for reporting this! I definitely have a blind spot- I mostly use discharge data, so I don't always notice problems involving other parameters. To help fix this, I added a new test fixture from your site in Lake Sherburne, Montana!

from hydrofunctions.

Related Issues (20)

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.