Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowpack percentage function #82

Merged
merged 8 commits into from
Feb 10, 2023
Merged

Snowpack percentage function #82

merged 8 commits into from
Feb 10, 2023

Conversation

jinducil
Copy link
Contributor

@jinducil jinducil commented Jan 27, 2023

Closes #81; also addresses MBKEngineers/safca-portal#77

  • Adds get_daily_snowpack_data function to CDEC queries.py
  • Takes in region and date_string (YYYYMMDD) as arguments; date_string is optional argument, will use today's date if none provided
  • Returns dictionary with metadata and data for % values

Code to test

from collect.dwr import cdec

data = cdec.get_daily_snowpack_data('CENTRAL')
print(data['meta'])
print(data['data'])

Copy link
Member

@narlesky narlesky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work - the layout and content of this function is really clear!

A couple of thoughts:

  1. Could you please extend this to return the No. of Stations and Avg. SWC reported as well?
  2. It would also be very powerful to be able to query a date range for these values.
  3. What do you think about allowing the date to be specified as a datetime.datetime structure? I could see an argument for providing as a string if it makes the timezone handling easier though. Let me know what you think!

@narlesky narlesky added feeds support a new data feed and removed enhancement New feature or request labels Feb 8, 2023
@jinducil
Copy link
Contributor Author

@narlesky Changes made!

  • Now returns dataframe containing # of stations and average SWC
  • Now queries a date range
  • Validates start/end times

Updated code to test

from collect.dwr import cdec
import datetime as dt

data = cdec.get_daily_snowpack_data('CENTRAL', dt.datetime(2003, 2, 15), dt.datetime(2023, 2, 9))
print(data['data'])

collect/dwr/cdec/queries.py Outdated Show resolved Hide resolved
collect/dwr/cdec/queries.py Outdated Show resolved Hide resolved
collect/dwr/cdec/queries.py Outdated Show resolved Hide resolved
collect/dwr/cdec/queries.py Outdated Show resolved Hide resolved
Copy link
Member

@narlesky narlesky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ready to merge! 🎉. Would love to share with a wider audience within MBK at some point soon :)

@jinducil jinducil merged commit 8e82d70 into main Feb 10, 2023
@jinducil jinducil deleted the snowpack_percentage_function branch February 10, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feeds support a new data feed ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate function that scrapes daily snow water equivalents
2 participants