Repository navigation
fix(codes): reconcile time-zone table with USGS and WQX code lists - #456
Merged
thodson-usgs merged 2 commits intoOct 16, 2026
Merged
Conversation
…lists Samples writes American Samoa as ZP-11, which the table lacked, so every timed American Samoa row from get_samples() had a NaT datetime. Follow the USGS NWIS list (Samples) and the WQX TimeZone domain (WQP); where they disagree (SST, BST), WQX wins. Snapshots of both lists back an offline test, and live tests watch the published lists and responses for Pacific monitoring locations.
thodson-usgs
force-pushed
the
fix/timezone-code-lists
branch
from
October 16, 2026 15:50
cdf4480 to
6d3824a
Compare
A live sweep of every state and territory found ZP-11 in WQP responses for USGS American Samoa records, so the USGS list governs part of WQP too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows up #455 (merged); rebased onto main as a single commit.
Summary
codes.timezonesturns the abbreviation beside a local time into the UTC offset used for the*DateTimecolumns thatwaterdata.get_samples()andwqp.get_results()append. The table now follows the code lists those services use: the USGS NWIS time-zone list (Samples) and the WQX TimeZone domain (WQP).ZP-11, which the table lacked, so every timed American Samoa row came back with aNaTdatetime. It is now UTC-11.NaT: 39 more codes from the two lists now resolve: the otherZP*offsets,IDLW/IDLE,NZT,SWT, the retired WQX codesAHSTandYST, and others.CAST+9:30,CCT+8,EASST+11,EAST+10,NFT-3:30,NZDT+13,WAST+7,WAT-1.FJSTmoves to +13 too.SST(Samoa in WQX, Swedish Summer Time in USGS) stays UTC-11, the meaning WQP returns.BSTbecomes UTC-11. Samples doesn't use either code for Samoa; it writesZP-11.tests/data/, and the module docstring points to them.Tests
tests/timezones_test.py, offline: checks that every code in each list maps to that list's offset, and thatWQX_WINS == {"SST", "BST"}covers every conflict between the lists, so any new conflict has to be decided explicitly.tests/timezones_test.py, live: checks that the published lists still match the snapshots, and that Samples/WQP responses for Pacific monitoring locations have noNaTamong timed rows.utils_test.py: an end-to-endZP-11case through_attach_datetime_columns.ruff,mypy,lint-imports,xenon,complexipy; 1757 tests pass; coverage 99.08%.Live verification (2026-10-16)
NaTZP-11NaTbefore)GSTstatecode=US:60, since 2023SSTstatecode=US:66, since 2023GSTSSTGSTExample: Samples
2011-09-09 09:40 ZP-11→2011-09-09 20:40Z.Not done
NaT: an unrecognized code still becomesNaTwithout any warning.SSTorBSTwith its USGS meaning.Stress test (2026-10-16)
wqp.what_activitiesplus_attach_datetime_columnsandwaterdata.get_samples(service="activities")for all 50 states, DC, and five territories, over four windows (Jan–Mar 1995, Jul 2010, Jun 2024, Jan 2025): about 520,000 timed rows and 25 distinct codes.NaT.AST/ADT, and one Idaho well (USGS-433812111574701) whose ten activities are all stampedWAST. That code is wrong in the source record whatever the table does; the old table put it at +2, the USGS list at +7.ZP-11appears in WQP results for USGS American Samoa records, so this fix reacheswqp.get_results()too. A live case now covers it, and the docstring and NEWS say so.