Comments (5)
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.
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:
- raise ValueErrors for 'discharge', 'q', & 'stage' at lines 238, 240, & 242 (con: it is repetitive, not DRY)
- 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)
- 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.
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.
from hydrofunctions.
@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)
- Make pyarrow an optional dependency
- Some NWIS sites have non-standard parameter codes
- SSL Certification error HOT 3
- mysterious hydrofunctions_testing.log HOT 3
- extract_nwis_df() function returns a tuple with dataframe and dictionary HOT 4
- annual statistics creates invalid URL HOT 1
- The hydrofunctions docstring example no longer works HOT 2
- Request site data from NWIS for stations HOT 2
- requesting rdb data from nonexistent site returns uncaught error
- Update dependencies HOT 7
- Add functionality for multiple sensor / parameter code combinations HOT 6
- What is the relationship between hydrofunctions, Ulmo, dataretrieval, HyRiver, and others? HOT 13
- hf.peaks ParserError month HOT 6
- NWIS & get_nwis should print url before making request HOT 1
- Pandas error: TypeError: Cannot compare type 'Timedelta' with type 'Minute' HOT 5
- Add additional USGS webservices HOT 1
- Update CI system HOT 1
- extract_nwis_df wrong variable name HOT 5
- Create a 'verbose' mode that can be turned off. HOT 1
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.
from hydrofunctions.