rashdf 0.6.0__py3-none-any.whl → 0.7.1__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.
rashdf/plan.py CHANGED
@@ -6,6 +6,7 @@ from .utils import (
6
6
  ras_timesteps_to_datetimes,
7
7
  parse_ras_datetime_ms,
8
8
  deprecated,
9
+ convert_ras_hdf_value,
9
10
  )
10
11
 
11
12
  from geopandas import GeoDataFrame
@@ -156,6 +157,7 @@ class RasPlanHdf(RasGeomHdf):
156
157
  PLAN_INFO_PATH = "Plan Data/Plan Information"
157
158
  PLAN_PARAMS_PATH = "Plan Data/Plan Parameters"
158
159
  PRECIP_PATH = "Event Conditions/Meteorology/Precipitation"
160
+ OBS_DATA_PATH = "Event Conditions/Observed Data"
159
161
  RESULTS_UNSTEADY_PATH = "Results/Unsteady"
160
162
  RESULTS_UNSTEADY_SUMMARY_PATH = f"{RESULTS_UNSTEADY_PATH}/Summary"
161
163
  VOLUME_ACCOUNTING_PATH = f"{RESULTS_UNSTEADY_PATH}/Volume Accounting"
@@ -166,6 +168,8 @@ class RasPlanHdf(RasGeomHdf):
166
168
  UNSTEADY_TIME_SERIES_PATH = f"{BASE_OUTPUT_PATH}/Unsteady Time Series"
167
169
  REFERENCE_LINES_OUTPUT_PATH = f"{UNSTEADY_TIME_SERIES_PATH}/Reference Lines"
168
170
  REFERENCE_POINTS_OUTPUT_PATH = f"{UNSTEADY_TIME_SERIES_PATH}/Reference Points"
171
+ OBS_FLOW_OUTPUT_PATH = f"{OBS_DATA_PATH}/Flow"
172
+ OBS_STAGE_OUTPUT_PATH = f"{OBS_DATA_PATH}/Stage"
169
173
 
170
174
  RESULTS_STEADY_PATH = "Results/Steady"
171
175
  BASE_STEADY_PATH = f"{RESULTS_STEADY_PATH}/Output/Output Blocks/Base Output"
@@ -1117,6 +1121,74 @@ class RasPlanHdf(RasGeomHdf):
1117
1121
  """
1118
1122
  return self.reference_timeseries_output(reftype="lines")
1119
1123
 
1124
+ def observed_timeseries_input(self, vartype: str = "Flow") -> xr.DataArray:
1125
+ """Return observed timeseries input data for reference lines and points from a HEC-RAS HDF plan file.
1126
+
1127
+ Parameters
1128
+ ----------
1129
+ vartype : str, optional
1130
+ The type of observed data to retrieve. Must be either "Flow" or "Stage".
1131
+ (default: "Flow")
1132
+
1133
+ Returns
1134
+ -------
1135
+ xr.DataArray
1136
+ An xarray DataArray with observed timeseries input data for reference lines or reference points.
1137
+ """
1138
+ if vartype == "Flow":
1139
+ output_path = self.OBS_FLOW_OUTPUT_PATH
1140
+ elif vartype == "Stage":
1141
+ output_path = self.OBS_STAGE_OUTPUT_PATH
1142
+ else:
1143
+ raise ValueError('vartype must be either "Flow" or "Stage".')
1144
+
1145
+ observed_group = self.get(output_path)
1146
+ if observed_group is None:
1147
+ raise RasPlanHdfError(
1148
+ f"Could not find HDF group at path '{output_path}'."
1149
+ f" Does the Plan HDF file contain reference {vartype} output data?"
1150
+ )
1151
+ if "Attributes" in observed_group.keys():
1152
+ attr_path = observed_group["Attributes"]
1153
+ attrs_df = pd.DataFrame(attr_path[:]).map(convert_ras_hdf_value)
1154
+
1155
+ das = {}
1156
+ for idx, site in enumerate(observed_group.keys()):
1157
+ if site != "Attributes":
1158
+ # Site Ex: 'Ref Point: Grapevine_Lake_RP'
1159
+ site_path = observed_group[site]
1160
+ site_name = site.split(":")[1][1:] # Grapevine_Lake_RP
1161
+ ref_type = site.split(":")[0] # Ref Point
1162
+ if ref_type == "Ref Line":
1163
+ ref_type = "refln"
1164
+ else:
1165
+ ref_type = "refpt"
1166
+ df = pd.DataFrame(site_path[:]).map(convert_ras_hdf_value)
1167
+ # rename Date to time
1168
+ df = df.rename(columns={"Date": "time"})
1169
+ # Ensure the Date index is unique
1170
+ df = df.drop_duplicates(subset="time")
1171
+ # Package into an 1D xarray DataArray
1172
+ values = df["Value"].values
1173
+ times = df["time"].values
1174
+ da = xr.DataArray(
1175
+ values,
1176
+ name=vartype,
1177
+ dims=["time"],
1178
+ coords={
1179
+ "time": times,
1180
+ },
1181
+ attrs={
1182
+ "hdf_path": f"{output_path}/{site}",
1183
+ },
1184
+ )
1185
+ # Expand dimensions to add additional coordinates
1186
+ da = da.expand_dims({f"{ref_type}_id": [idx - 1]})
1187
+ da = da.expand_dims({f"{ref_type}_name": [site_name]})
1188
+ das[site_name] = da
1189
+ das = xr.concat([das[site] for site in das.keys()], dim="time")
1190
+ return das
1191
+
1120
1192
  def reference_points_timeseries_output(self) -> xr.Dataset:
1121
1193
  """Return timeseries output data for reference points from a HEC-RAS HDF plan file.
1122
1194
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rashdf
3
- Version: 0.6.0
3
+ Version: 0.7.1
4
4
  Summary: Read data from HEC-RAS HDF files.
5
5
  Project-URL: repository, https://github.com/fema-ffrd/rashdf
6
6
  Classifier: Development Status :: 4 - Beta
@@ -14,24 +14,24 @@ Classifier: Programming Language :: Python :: 3.12
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
  Requires-Dist: h5py
17
- Requires-Dist: geopandas <2.0,>=1.0
17
+ Requires-Dist: geopandas<2.0,>=1.0
18
18
  Requires-Dist: pyarrow
19
19
  Requires-Dist: xarray
20
20
  Provides-Extra: dev
21
- Requires-Dist: pre-commit ; extra == 'dev'
22
- Requires-Dist: ruff ; extra == 'dev'
23
- Requires-Dist: pytest ; extra == 'dev'
24
- Requires-Dist: pytest-cov ; extra == 'dev'
25
- Requires-Dist: fiona ; extra == 'dev'
26
- Requires-Dist: kerchunk ; extra == 'dev'
27
- Requires-Dist: zarr ; extra == 'dev'
28
- Requires-Dist: dask ; extra == 'dev'
29
- Requires-Dist: fsspec ; extra == 'dev'
30
- Requires-Dist: s3fs ; extra == 'dev'
21
+ Requires-Dist: pre-commit; extra == "dev"
22
+ Requires-Dist: ruff; extra == "dev"
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: pytest-cov; extra == "dev"
25
+ Requires-Dist: kerchunk; extra == "dev"
26
+ Requires-Dist: zarr; extra == "dev"
27
+ Requires-Dist: dask; extra == "dev"
28
+ Requires-Dist: fsspec; extra == "dev"
29
+ Requires-Dist: s3fs; extra == "dev"
30
+ Requires-Dist: fiona==1.9.6; extra == "dev"
31
31
  Provides-Extra: docs
32
- Requires-Dist: sphinx ; extra == 'docs'
33
- Requires-Dist: numpydoc ; extra == 'docs'
34
- Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
32
+ Requires-Dist: sphinx; extra == "docs"
33
+ Requires-Dist: numpydoc; extra == "docs"
34
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
35
35
 
36
36
  # rashdf
37
37
  [![CI](https://github.com/fema-ffrd/rashdf/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/fema-ffrd/rashdf/actions/workflows/continuous-integration.yml)
@@ -145,8 +145,12 @@ $ python -m venv venv-rashdf
145
145
 
146
146
  Activate the virtual environment:
147
147
  ```
148
- $ source ./venv/bin/activate
148
+ # For macOS/Linux
149
+ $ source ./venv-rashdf/bin/activate
149
150
  (venv-rashdf) $
151
+
152
+ # For Windows
153
+ > ./venv-rashdf/Scripts/activate
150
154
  ```
151
155
 
152
156
  Install dev dependencies:
@@ -0,0 +1,12 @@
1
+ cli.py,sha256=yItWmCxnYLcuOpJVRpUsfv_NLS9IxLjojZB9GrxfKAU,6571
2
+ rashdf/__init__.py,sha256=XXFtJDgLPCimqAhfsFz_pTWYECJiRT0i-Kb1uflXmVU,156
3
+ rashdf/base.py,sha256=cAQJX1aeBJKb3MJ06ltpbRTUaZX5NkuxpR1J4f7FyTU,2507
4
+ rashdf/geom.py,sha256=2aTfj6mqZGP6rysflQ5L8FeItlYJsknO00sKHo-yaTw,26090
5
+ rashdf/plan.py,sha256=FUfLhGs0a87GKaNzR9sdm1qzYVhpXhq_cHTlP4oRJo8,59530
6
+ rashdf/utils.py,sha256=Cba6sULF0m0jg6CQass4bPm2oxTd_avoe1pRQxq082c,10896
7
+ rashdf-0.7.1.dist-info/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
8
+ rashdf-0.7.1.dist-info/METADATA,sha256=T9ClhfBiqw26Ib_kWuZln-V2XpbjJ0m3_16FwFI7X24,5986
9
+ rashdf-0.7.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
10
+ rashdf-0.7.1.dist-info/entry_points.txt,sha256=LHHMR1lLy4wRyscMuW1RlYDXemtPgqQhNcILz0DtStY,36
11
+ rashdf-0.7.1.dist-info/top_level.txt,sha256=SrmLb6FFTJtM_t6O1v0M0JePshiQJMHr0yYVkHL7ztk,11
12
+ rashdf-0.7.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (71.1.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- cli.py,sha256=yItWmCxnYLcuOpJVRpUsfv_NLS9IxLjojZB9GrxfKAU,6571
2
- rashdf/__init__.py,sha256=XXFtJDgLPCimqAhfsFz_pTWYECJiRT0i-Kb1uflXmVU,156
3
- rashdf/base.py,sha256=cAQJX1aeBJKb3MJ06ltpbRTUaZX5NkuxpR1J4f7FyTU,2507
4
- rashdf/geom.py,sha256=2aTfj6mqZGP6rysflQ5L8FeItlYJsknO00sKHo-yaTw,26090
5
- rashdf/plan.py,sha256=4kftqnZedhSWPl-5Yn3vz9Z4VifTXcUokti0s5lX1lU,56479
6
- rashdf/utils.py,sha256=Cba6sULF0m0jg6CQass4bPm2oxTd_avoe1pRQxq082c,10896
7
- rashdf-0.6.0.dist-info/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
8
- rashdf-0.6.0.dist-info/METADATA,sha256=0MarTKZArGaOTTROyz4PENscSiVy7cYwvatftl89y_Q,5920
9
- rashdf-0.6.0.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
10
- rashdf-0.6.0.dist-info/entry_points.txt,sha256=LHHMR1lLy4wRyscMuW1RlYDXemtPgqQhNcILz0DtStY,36
11
- rashdf-0.6.0.dist-info/top_level.txt,sha256=SrmLb6FFTJtM_t6O1v0M0JePshiQJMHr0yYVkHL7ztk,11
12
- rashdf-0.6.0.dist-info/RECORD,,