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.
Files changed (38) hide show
  1. {cwms_python-0.7.0 → cwms_python-0.7.1}/PKG-INFO +1 -1
  2. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/cwms_types.py +2 -2
  3. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries.py +39 -34
  4. {cwms_python-0.7.0 → cwms_python-0.7.1}/pyproject.toml +1 -1
  5. {cwms_python-0.7.0 → cwms_python-0.7.1}/LICENSE +0 -0
  6. {cwms_python-0.7.0 → cwms_python-0.7.1}/README.md +0 -0
  7. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/__init__.py +0 -0
  8. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/api.py +0 -0
  9. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/catalog/blobs.py +0 -0
  10. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/catalog/catalog.py +0 -0
  11. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/catalog/clobs.py +0 -0
  12. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/forecast/forecast_instance.py +0 -0
  13. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/forecast/forecast_spec.py +0 -0
  14. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/levels/location_levels.py +0 -0
  15. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/levels/specified_levels.py +0 -0
  16. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/locations/gate_changes.py +0 -0
  17. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/locations/location_groups.py +0 -0
  18. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/locations/physical_locations.py +0 -0
  19. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/measurements/measurements.py +0 -0
  20. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/outlets/outlets.py +0 -0
  21. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/outlets/virtual_outlets.py +0 -0
  22. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/projects/project_lock_rights.py +0 -0
  23. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/projects/project_locks.py +0 -0
  24. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/projects/projects.py +0 -0
  25. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/ratings/ratings.py +0 -0
  26. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/ratings/ratings_spec.py +0 -0
  27. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/ratings/ratings_template.py +0 -0
  28. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/standard_text/standard_text.py +0 -0
  29. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_bin.py +0 -0
  30. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_group.py +0 -0
  31. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_identifier.py +0 -0
  32. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_profile.py +0 -0
  33. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_profile_instance.py +0 -0
  34. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_profile_parser.py +0 -0
  35. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/timeseries/timeseries_txt.py +0 -0
  36. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/turbines/turbines.py +0 -0
  37. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/utils/__init__.py +0 -0
  38. {cwms_python-0.7.0 → cwms_python-0.7.1}/cwms/utils/checks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cwms-python
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Corps water management systems (CWMS) REST API for Data Retrieval of USACE water data
5
5
  License: LICENSE
6
6
  Keywords: USACE,water data,CWMS
@@ -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
- df = df.apply(to_numeric)
66
- return df
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": 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
- ts_data: pd.DataFrame, office_id: str, max_workers: Optional[int] = 30
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
- units = data["units"].iloc[0]
273
- data_json = timeseries_df_to_json(
274
- data=data,
275
- ts_id=ts_id,
276
- units=units,
277
- office_id=office_id,
278
- version_date=version_date,
279
- )
280
- store_timeseries(data=data_json)
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
- ts_data["ts_id"].astype(str) + ":" + ts_data["version_date"].astype(str)
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 ts_id_all in unique_tsids:
289
- try:
290
- ts_id, version_date = ts_id_all.split(":", 1)
291
- if version_date != "NaT":
292
- version_date_dt = pd.to_datetime(version_date)
293
- data = ts_data[
294
- (ts_data["ts_id"] == ts_id)
295
- & (ts_data["version_date"] == version_date_dt)
296
- ]
297
- else:
298
- version_date_dt = None
299
- data = ts_data[
300
- (ts_data["ts_id"] == ts_id) & ts_data["version_date"].isna()
301
- ]
302
- if not data.empty:
303
- executor.submit(
304
- store_ts_ids, data, ts_id, office_id, version_date_dt
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(
@@ -2,7 +2,7 @@
2
2
  name = "cwms-python"
3
3
  repository = "https://github.com/HydrologicEngineeringCenter/cwms-python"
4
4
 
5
- version = "0.7.0"
5
+ version = "0.7.1"
6
6
 
7
7
 
8
8
  packages = [
File without changes
File without changes
File without changes