discontinuum 1.0.1__py3-none-any.whl → 1.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- discontinuum/_version.py +2 -2
- {discontinuum-1.0.1.dist-info → discontinuum-1.0.2.dist-info}/METADATA +1 -1
- {discontinuum-1.0.1.dist-info → discontinuum-1.0.2.dist-info}/RECORD +7 -7
- rating_gp/providers/usgs.py +60 -13
- {discontinuum-1.0.1.dist-info → discontinuum-1.0.2.dist-info}/WHEEL +0 -0
- {discontinuum-1.0.1.dist-info → discontinuum-1.0.2.dist-info}/licenses/LICENSE.md +0 -0
- {discontinuum-1.0.1.dist-info → discontinuum-1.0.2.dist-info}/top_level.txt +0 -0
discontinuum/_version.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
discontinuum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
discontinuum/_version.py,sha256=
|
2
|
+
discontinuum/_version.py,sha256=98Mtoja-WpqDUnppClywkGhX6oxX6l-ZHnSYMYYbBUE,511
|
3
3
|
discontinuum/data_manager.py,sha256=LiZoPR0nnu7YAUfh5L1ZDRfaS3dgfVIELXIHkzUKyBg,4416
|
4
4
|
discontinuum/pipeline.py,sha256=1avuZnFai-b3HmihcpZ8M3WFNQ8lXAFSNTrnfl2NrY0,10074
|
5
5
|
discontinuum/plot.py,sha256=eZQS6-Ydq8FFcEukPtNuDVB-weV6lHyWMyJ1hqTkVrU,2969
|
@@ -11,7 +11,7 @@ discontinuum/engines/pymc.py,sha256=phbtE-3UCSVcP1MhbXwAHIWDZWDr56wK9U7aRt-w-2o,
|
|
11
11
|
discontinuum/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
discontinuum/providers/base.py,sha256=Yn2EHS1b4fYl09-m2MYuf2P9VRUXAP-WDpSoZrCbRvY,720
|
13
13
|
discontinuum/tests/test_pipeline.py,sha256=_FhkGxbFIxNb35lGaIdZk7Zjgs6CkxEF3gFUX3PE8EU,918
|
14
|
-
discontinuum-1.0.
|
14
|
+
discontinuum-1.0.2.dist-info/licenses/LICENSE.md,sha256=XElVHHnS2uQ15M_Z2giPH1vmeWMzdpGQ48ItkuZurVA,1650
|
15
15
|
loadest_gp/__init__.py,sha256=YISfvbc7Zy2y0BOxS1A2KzqxyoNJTz0EnLMnRW6iVT8,740
|
16
16
|
loadest_gp/plot.py,sha256=x2PK7vBCc44dX9lu5YV-rvw1u4pvXSLdcrTSvYLiHMA,2595
|
17
17
|
loadest_gp/utils.py,sha256=m5QaqR_0JiuRXPfryH8nI5lODp8PqvQla5C05WDN3LY,2772
|
@@ -28,8 +28,8 @@ rating_gp/models/base.py,sha256=e2Kq644I88YLHWPNA0qyRgitF5wimdLW4618vKX-o_s,1474
|
|
28
28
|
rating_gp/models/gpytorch.py,sha256=rSxuTMoSeGK2LwqANMDMrmxDsOCXyAWSmENm6KFjRZ0,5930
|
29
29
|
rating_gp/models/kernels.py,sha256=3xg2mhY3aEgjI3r5vyAll9MA4c3M5UKqRi3FApNhJJQ,11579
|
30
30
|
rating_gp/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
|
-
rating_gp/providers/usgs.py,sha256=
|
32
|
-
discontinuum-1.0.
|
33
|
-
discontinuum-1.0.
|
34
|
-
discontinuum-1.0.
|
35
|
-
discontinuum-1.0.
|
31
|
+
rating_gp/providers/usgs.py,sha256=KmKYN3c8Mi-ly2l6X80WT3taEhqCPXeEcRNi9HvbJmY,8134
|
32
|
+
discontinuum-1.0.2.dist-info/METADATA,sha256=0oCct8VOrQib5sCzdi2cBNI8KEcpYTYTKj1oCL3DCsc,6231
|
33
|
+
discontinuum-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
34
|
+
discontinuum-1.0.2.dist-info/top_level.txt,sha256=mwU_PSFrZYSJrBgqIuTJTo7Pp9ODDv6XdDed7kAagXM,34
|
35
|
+
discontinuum-1.0.2.dist-info/RECORD,,
|
rating_gp/providers/usgs.py
CHANGED
@@ -21,6 +21,16 @@ if TYPE_CHECKING:
|
|
21
21
|
FT_TO_M = 0.3048
|
22
22
|
FT3_TO_M3 = 0.0283168
|
23
23
|
|
24
|
+
# Quantitative values of "measured_rating_diff"
|
25
|
+
USGS_QUALITY_CODES = {
|
26
|
+
'Excellent': '0.02',
|
27
|
+
'Good': '0.05',
|
28
|
+
'Fair': '0.08',
|
29
|
+
'Poor': '0.12',
|
30
|
+
'Unspecified': '0.12',
|
31
|
+
}
|
32
|
+
|
33
|
+
|
24
34
|
@dataclass
|
25
35
|
class NWISColumn:
|
26
36
|
column_name: str
|
@@ -182,6 +192,53 @@ def get_measurements(
|
|
182
192
|
)
|
183
193
|
df = nwis._read_rdb(response.text)
|
184
194
|
|
195
|
+
return read_measurements_df(df)
|
196
|
+
|
197
|
+
|
198
|
+
def read_measurements_df(df: pd.DataFrame) -> xr.Dataset:
|
199
|
+
"""Read a DataFrame of USGS discharge measurements and convert to xarray Dataset.
|
200
|
+
|
201
|
+
Parameters
|
202
|
+
----------
|
203
|
+
df : pd.DataFrame
|
204
|
+
Dataframe from `dataretrieval.nwis.get_discharge_measurements()`
|
205
|
+
|
206
|
+
Returns
|
207
|
+
-------
|
208
|
+
xr.Dataset
|
209
|
+
|
210
|
+
Example
|
211
|
+
-------
|
212
|
+
>>> from dataretrieval import nwis
|
213
|
+
>>> from rating_gp.providers.usgs import read_measurements_df
|
214
|
+
>>> df, _ = nwis.get_discharge_measurements(
|
215
|
+
sites='03339000',
|
216
|
+
start='2020-01-01',
|
217
|
+
end='2020-12-31',
|
218
|
+
format='rdb_expanded',
|
219
|
+
)
|
220
|
+
>>> ds = read_measurements_df(df)
|
221
|
+
"""
|
222
|
+
|
223
|
+
# assert the correct columns are present
|
224
|
+
required_columns = [
|
225
|
+
"measurement_dt",
|
226
|
+
"gage_height_va",
|
227
|
+
"discharge_va",
|
228
|
+
"q_meas_used_fg",
|
229
|
+
"control_type_cd",
|
230
|
+
"measured_rating_diff",
|
231
|
+
"streamflow_method",
|
232
|
+
NWISStage.column_name,
|
233
|
+
NWISDischarge.column_name,
|
234
|
+
]
|
235
|
+
|
236
|
+
missing_columns = set(required_columns) - set(df.columns)
|
237
|
+
if missing_columns:
|
238
|
+
raise ValueError(
|
239
|
+
f"Missing required columns in the DataFrame: {missing_columns}"
|
240
|
+
)
|
241
|
+
|
185
242
|
# covert timezone to UTC? ignore for now
|
186
243
|
df.index = pd.to_datetime(
|
187
244
|
df["measurement_dt"],
|
@@ -215,26 +272,16 @@ def get_measurements(
|
|
215
272
|
UserWarning,
|
216
273
|
)
|
217
274
|
|
218
|
-
|
219
|
-
|
220
|
-
# Quantitative values of "measured_rating_diff"
|
221
|
-
quality_codes = {
|
222
|
-
'Excellent': '0.02',
|
223
|
-
'Good': '0.05',
|
224
|
-
'Fair': '0.08',
|
225
|
-
'Poor': '0.12',
|
226
|
-
'Unspecified': '0.12',
|
227
|
-
}
|
228
275
|
# Replace other values with 'Unspecified'
|
229
276
|
df['measured_rating_diff'] = df['measured_rating_diff'].where(
|
230
|
-
df['measured_rating_diff'].isin(
|
277
|
+
df['measured_rating_diff'].isin(USGS_QUALITY_CODES.keys()),
|
231
278
|
'Unspecified'
|
232
279
|
)
|
233
280
|
|
234
|
-
|
235
281
|
df['discharge_unc_frac'] = (df['measured_rating_diff']
|
236
|
-
.replace(
|
282
|
+
.replace(USGS_QUALITY_CODES)
|
237
283
|
.astype(float))
|
284
|
+
|
238
285
|
# Set indirect measurements as 20% uncertain regardless of quality code
|
239
286
|
df.loc[df['streamflow_method'] == 'QIDIR', 'discharge_unc_frac'] = 0.2
|
240
287
|
|
File without changes
|
File without changes
|
File without changes
|