Commit 630cc8c
get_ratings: surface RDB header as df.attrs and document the nwis dep
Two non-functional follow-ups suggested during review of #269:
(1) Document the cross-module reach into nwis._read_rdb. Rating files
use the same USGS RDB shape as NWIS responses, so the parser is
already reusable as-is — no refactor of the legacy nwis module is
needed. Added a comment at the import site explaining why the
private import is intentional and what to watch for if _read_rdb
ever moves.
(2) Surface the RDB #-prefixed header block. Each parsed rating frame
now carries provenance in df.attrs:
- df.attrs["comment"]: the list of "#"-prefixed header lines
(rating id, parameter, expansion type, last-shifted timestamp,
warnings, etc.).
- df.attrs["url"]: the asset URL it was fetched from.
R's read_waterdata_ratings exposes the comment block via
comment(df); pandas's standard `attrs` dict is the Python
equivalent. Done in ratings.py only — does not touch nwis.
A live spot-check against api.waterdata.usgs.gov on USGS-01104475
exsa shows the 31-line USGS header survives intact (gauge name,
parameter code, rating expansion, etc.). One new unit test pins the
behavior.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e304763 commit 630cc8c
2 files changed
Lines changed: 52 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
87 | 104 | | |
88 | 105 | | |
89 | 106 | | |
| |||
100 | 117 | | |
101 | 118 | | |
102 | 119 | | |
103 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
104 | 124 | | |
105 | 125 | | |
106 | 126 | | |
| |||
168 | 188 | | |
169 | 189 | | |
170 | 190 | | |
171 | | - | |
172 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
173 | 197 | | |
174 | 198 | | |
175 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
103 | 128 | | |
104 | 129 | | |
105 | 130 | | |
| |||
0 commit comments