cwms-python 0.7.0__tar.gz → 0.7.1__tar.gz
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.
- {cwms_python-0.7.0 → cwms_python-0.7.1}/PKG-INFO +1 -1
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/cwms_types.py +2 -2
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries.py +39 -34
- {cwms_python-0.7.0 → cwms_python-0.7.1}/pyproject.toml +1 -1
- {cwms_python-0.7.0 → cwms_python-0.7.1}/LICENSE +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/README.md +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/__init__.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/api.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/catalog/blobs.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/catalog/catalog.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/catalog/clobs.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/forecast/forecast_instance.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/forecast/forecast_spec.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/levels/location_levels.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/levels/specified_levels.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/locations/gate_changes.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/locations/location_groups.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/locations/physical_locations.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/measurements/measurements.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/outlets/outlets.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/outlets/virtual_outlets.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/projects/project_lock_rights.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/projects/project_locks.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/projects/projects.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/ratings/ratings.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/ratings/ratings_spec.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/ratings/ratings_template.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/standard_text/standard_text.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_bin.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_group.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_identifier.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_profile.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_profile_instance.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_profile_parser.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_txt.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/turbines/turbines.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/utils/__init__.py +0 -0
- {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/utils/checks.py +0 -0
|
@@ -62,8 +62,8 @@ class Data:
|
|
|
62
62
|
def rating_type(data: JSON) -> DataFrame:
|
|
63
63
|
# grab the correct point values for a rating table
|
|
64
64
|
df = DataFrame(data["point"]) if data["point"] else DataFrame()
|
|
65
|
-
|
|
66
|
-
return
|
|
65
|
+
df_numeric = df.apply(to_numeric, axis=0, result_type="expand")
|
|
66
|
+
return DataFrame(df_numeric)
|
|
67
67
|
|
|
68
68
|
def timeseries_type(orig_json: JSON, value_json: JSON) -> DataFrame:
|
|
69
69
|
# if timeseries values are present then grab the values and put into
|
|
@@ -247,64 +247,69 @@ def timeseries_df_to_json(
|
|
|
247
247
|
df = df.reindex(columns=["date-time", "value", "quality-code"])
|
|
248
248
|
if df.isnull().values.any():
|
|
249
249
|
raise ValueError("Null/NaN data must be removed from the dataframe")
|
|
250
|
-
|
|
250
|
+
if version_date:
|
|
251
|
+
version_date_iso = version_date.isoformat()
|
|
252
|
+
else:
|
|
253
|
+
version_date_iso = None
|
|
251
254
|
ts_dict = {
|
|
252
255
|
"name": ts_id,
|
|
253
256
|
"office-id": office_id,
|
|
254
257
|
"units": units,
|
|
255
258
|
"values": df.values.tolist(),
|
|
256
|
-
"version-date":
|
|
259
|
+
"version-date": version_date_iso,
|
|
257
260
|
}
|
|
258
261
|
|
|
259
262
|
return ts_dict
|
|
260
263
|
|
|
261
264
|
|
|
262
265
|
def store_multi_timeseries_df(
|
|
263
|
-
|
|
266
|
+
data: pd.DataFrame, office_id: str, max_workers: Optional[int] = 30
|
|
264
267
|
) -> None:
|
|
265
|
-
|
|
266
268
|
def store_ts_ids(
|
|
267
269
|
data: pd.DataFrame,
|
|
268
270
|
ts_id: str,
|
|
269
271
|
office_id: str,
|
|
270
272
|
version_date: Optional[datetime] = None,
|
|
271
273
|
) -> None:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
try:
|
|
275
|
+
units = data["units"].iloc[0]
|
|
276
|
+
data_json = timeseries_df_to_json(
|
|
277
|
+
data=data,
|
|
278
|
+
ts_id=ts_id,
|
|
279
|
+
units=units,
|
|
280
|
+
office_id=office_id,
|
|
281
|
+
version_date=version_date,
|
|
282
|
+
)
|
|
283
|
+
store_timeseries(data=data_json)
|
|
284
|
+
except Exception as e:
|
|
285
|
+
print(f"Error processing {ts_id}: {e}")
|
|
281
286
|
return None
|
|
282
287
|
|
|
288
|
+
ts_data_all = data.copy()
|
|
289
|
+
if "version_date" not in ts_data_all.columns:
|
|
290
|
+
ts_data_all = ts_data_all.assign(version_date=pd.to_datetime(pd.Series([])))
|
|
283
291
|
unique_tsids = (
|
|
284
|
-
|
|
292
|
+
ts_data_all["ts_id"].astype(str) + ":" + ts_data_all["version_date"].astype(str)
|
|
285
293
|
).unique()
|
|
286
294
|
|
|
287
295
|
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
288
|
-
for
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
)
|
|
306
|
-
except Exception as e:
|
|
307
|
-
print(f"Error processing {ts_id}: {e}")
|
|
296
|
+
for unique_tsid in unique_tsids:
|
|
297
|
+
ts_id, version_date = unique_tsid.split(":", 1)
|
|
298
|
+
if version_date != "NaT":
|
|
299
|
+
version_date_dt = pd.to_datetime(version_date)
|
|
300
|
+
ts_data = ts_data_all[
|
|
301
|
+
(ts_data_all["ts_id"] == ts_id)
|
|
302
|
+
& (ts_data_all["version_date"] == version_date_dt)
|
|
303
|
+
]
|
|
304
|
+
else:
|
|
305
|
+
version_date_dt = None
|
|
306
|
+
ts_data = ts_data_all[
|
|
307
|
+
(ts_data_all["ts_id"] == ts_id) & ts_data_all["version_date"].isna()
|
|
308
|
+
]
|
|
309
|
+
if not data.empty:
|
|
310
|
+
executor.submit(
|
|
311
|
+
store_ts_ids, ts_data, ts_id, office_id, version_date_dt
|
|
312
|
+
)
|
|
308
313
|
|
|
309
314
|
|
|
310
315
|
def store_timeseries(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|