-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Add code to get_usgs_CDA to allow converting smaller interval data to store as 15 minute data. #228
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
base: main
Are you sure you want to change the base?
fix: Add code to get_usgs_CDA to allow converting smaller interval data to store as 15 minute data. #228
Changes from all commits
463b1d4
a168ba4
85a3db1
20cc807
ead1155
a07ec81
77794e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,26 +3,30 @@ repos: | |
| hooks: | ||
| - id: black | ||
| name: black | ||
| entry: poetry run black | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want a separate PR if the yaml needs to be changed?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say so, I had started one to fix the issue with the formatting library versions being different based on version of python running. I.e. your local vs CI versions But this was also blocking the local tests from running. Should we pick this out into its own PR? @msweier
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to me!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to change the yaml in order to pass the commit checks, otherwise it could not find poetry. I don't know if this is an everybody problem or just a me problem. |
||
| language: system | ||
| entry: black | ||
| language: python | ||
| additional_dependencies: [black] | ||
| types: [file, python] | ||
| exclude: ^cwmscli/_generated/ownership_data\.py$ | ||
|
|
||
| - id: isort | ||
| name: isort | ||
| entry: poetry run isort | ||
| language: system | ||
| entry: isort | ||
| language: python | ||
| additional_dependencies: [isort] | ||
| types: [file, python] | ||
| exclude: ^cwmscli/_generated/ownership_data\.py$ | ||
|
|
||
| - id: yamlfix | ||
| name: yamlfix | ||
| entry: poetry run yamlfix | ||
| language: system | ||
| entry: yamlfix | ||
| language: python | ||
| additional_dependencies: [yamlfix] | ||
| types: [file, yaml] | ||
|
|
||
| - id: ownership-sync | ||
| name: generated ownership files | ||
| entry: poetry run python scripts/sync_ownership.py --check | ||
| language: system | ||
| entry: python scripts/sync_ownership.py --check | ||
| language: python | ||
| additional_dependencies: [poetry] | ||
| pass_filenames: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| repos: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This .pre-cmmit-file.cong.yaml.org is a copy of the original and probably was included by accident. |
||
| - repo: local | ||
| hooks: | ||
| - id: black | ||
| name: black | ||
| entry: poetry run black | ||
| language: system | ||
| types: [file, python] | ||
| exclude: ^cwmscli/_generated/ownership_data\.py$ | ||
|
|
||
| - id: isort | ||
| name: isort | ||
| entry: poetry run isort | ||
| language: system | ||
| types: [file, python] | ||
| exclude: ^cwmscli/_generated/ownership_data\.py$ | ||
|
|
||
| - id: yamlfix | ||
| name: yamlfix | ||
| entry: poetry run yamlfix | ||
| language: system | ||
| types: [file, yaml] | ||
|
|
||
| - id: ownership-sync | ||
| name: generated ownership files | ||
| entry: poetry run python scripts/sync_ownership.py --check | ||
| language: system | ||
| pass_filenames: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -370,6 +370,16 @@ def CWMS_writeData(USGS_ts, USGS_data, USGS_data_method, days_back): | |
| office = row["office-id"] | ||
| values["quality-code"] = 0 | ||
|
|
||
| # 15 minute conversion to allow storing smaller interval data (eg. 5 minute) as 15 minute data | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this site start as 15 minute and went to 5 minute? Another thought is to use an irregular timeseries ~15Minute which would let you keep them in the same timeseries and preserving all the data. But if you want to subsample to 15 minutes, this works too!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some sites that went from 15 to 5 and some that have always been 5. For my purposes, 5 minutes is overkill and no need to fill up the database unnecessarily. So, I have always only stored 15 minute data for these sites. Previous versions of getusgs (non-cda and cda) allowed for this, but it was somehow missed in the cwms-cli version of getusgs. I just want to maintain my existing processing. |
||
| if ts_id.split(".")[3] == "15Minutes": | ||
| values_dt = values.copy() | ||
| values_dt["date-time"] = pd.to_datetime( | ||
| values_dt["date-time"] | ||
| ) | ||
| values_dt.set_index("date-time", inplace=True) | ||
| values15 = values_dt.resample("15min").first() | ||
| values = values15.reset_index() | ||
|
|
||
| # write values to CWMS database | ||
| try: | ||
| data = cwms.timeseries_df_to_json( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to resolve the issue you had with poetry trying to run locally. Good!