rashdf 0.2.2__py3-none-any.whl → 0.4.0__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/utils.py CHANGED
@@ -10,6 +10,25 @@ from typing import Any, List, Tuple, Union, Optional
10
10
  from shapely import LineString, Polygon, polygonize_full
11
11
 
12
12
 
13
+ def parse_ras_datetime_ms(datetime_str: str) -> datetime:
14
+ """Parse a datetime string with milliseconds from a RAS file into a datetime object.
15
+
16
+ If the datetime has a time of 2400, then it is converted to midnight of the next day.
17
+
18
+ Parameters
19
+ ----------
20
+ datetime_str (str): The datetime string to be parsed. The string should be in the format "ddMMMyyyy HH:mm:ss:fff".
21
+
22
+ Returns
23
+ -------
24
+ datetime: A datetime object representing the parsed datetime.
25
+ """
26
+ milliseconds = int(datetime_str[-3:])
27
+ microseconds = milliseconds * 1000
28
+ parsed_dt = parse_ras_datetime(datetime_str[:-4]).replace(microsecond=microseconds)
29
+ return parsed_dt
30
+
31
+
13
32
  def parse_ras_datetime(datetime_str: str) -> datetime:
14
33
  """Parse a datetime string from a RAS file into a datetime object.
15
34
 
@@ -266,3 +285,26 @@ def df_datetimes_to_str(df: pd.DataFrame) -> pd.DataFrame:
266
285
  lambda x: pd.Timestamp(x).isoformat() if pd.notnull(x) else None
267
286
  )
268
287
  return df_result
288
+
289
+
290
+ def ras_timesteps_to_datetimes(
291
+ timesteps: np.ndarray, start_time: datetime, time_unit: str, round_to="0.1 s"
292
+ ) -> List[datetime]:
293
+ """
294
+ Convert an array of RAS timesteps into an array of datetime objects.
295
+
296
+ Parameters
297
+ ----------
298
+ timesteps (np.ndarray): An array of RAS timesteps.
299
+ start_time (datetime): The start time of the simulation.
300
+ time_unit (str): The time unit of the timesteps.
301
+ round_to (str): The time unit to round the datetimes to. (Default: "0.1 s")
302
+
303
+ Returns
304
+ -------
305
+ List[datetime]: A list of datetime objects corresponding to the timesteps.
306
+ """
307
+ return [
308
+ start_time + pd.Timedelta(timestep, unit=time_unit).round(round_to)
309
+ for timestep in timesteps.astype(np.float64)
310
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rashdf
3
- Version: 0.2.2
3
+ Version: 0.4.0
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,8 +14,9 @@ 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
17
+ Requires-Dist: geopandas <0.15,>=0.14
18
18
  Requires-Dist: pyarrow
19
+ Requires-Dist: xarray
19
20
  Provides-Extra: dev
20
21
  Requires-Dist: pre-commit ; extra == 'dev'
21
22
  Requires-Dist: ruff ; extra == 'dev'
@@ -0,0 +1,12 @@
1
+ cli.py,sha256=dnTMEBid99xqorBFKZnUwOTDyTmIg08D83bSCkJ6104,5389
2
+ rashdf/__init__.py,sha256=XXFtJDgLPCimqAhfsFz_pTWYECJiRT0i-Kb1uflXmVU,156
3
+ rashdf/base.py,sha256=lHYVDwFTA1qFI34QYZ55QKcp7b8CeZsmDfESdkYISbg,2432
4
+ rashdf/geom.py,sha256=z3ak4TYjYo8-jrIQNSU96S7ulX5xk67rFZ5J0Y9yKbI,22048
5
+ rashdf/plan.py,sha256=YfJdjzZmGA9X8QnUflkc-8DMzMGoW5Gda3lRgMfxeQc,39669
6
+ rashdf/utils.py,sha256=93arHtIT-iL9dIpbYr7esjrxv1uJabTRJSruyjvr8mw,10168
7
+ rashdf-0.4.0.dist-info/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
8
+ rashdf-0.4.0.dist-info/METADATA,sha256=x7h2Pvw_xTQmzOhJKWkj6-R1lzCp_gDBt1wIkBikTZQ,5671
9
+ rashdf-0.4.0.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
10
+ rashdf-0.4.0.dist-info/entry_points.txt,sha256=LHHMR1lLy4wRyscMuW1RlYDXemtPgqQhNcILz0DtStY,36
11
+ rashdf-0.4.0.dist-info/top_level.txt,sha256=SrmLb6FFTJtM_t6O1v0M0JePshiQJMHr0yYVkHL7ztk,11
12
+ rashdf-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- cli.py,sha256=QMTNosimfe95bQn2_ovLB98GeaQ0gwMTMA1rboMEknw,5119
2
- rashdf/__init__.py,sha256=XXFtJDgLPCimqAhfsFz_pTWYECJiRT0i-Kb1uflXmVU,156
3
- rashdf/base.py,sha256=lHYVDwFTA1qFI34QYZ55QKcp7b8CeZsmDfESdkYISbg,2432
4
- rashdf/geom.py,sha256=8bdATVPc_HxECA9evnwyL3nXC5YHEY78I3JpUUP4_xM,17597
5
- rashdf/plan.py,sha256=8xdDkAvk9sTrBlCcXepuNvGRbp0JjlyHdRMFN5PRiHE,2734
6
- rashdf/utils.py,sha256=yEZCm06KjpL8pebbW4MIDIcX2vHp-IzVXsKJGKznWBc,8703
7
- rashdf-0.2.2.dist-info/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
8
- rashdf-0.2.2.dist-info/METADATA,sha256=4MuaGRrWegMZ4RVGtuYl6KjWpksteMTTj36gwAvGjCo,5636
9
- rashdf-0.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10
- rashdf-0.2.2.dist-info/entry_points.txt,sha256=LHHMR1lLy4wRyscMuW1RlYDXemtPgqQhNcILz0DtStY,36
11
- rashdf-0.2.2.dist-info/top_level.txt,sha256=SrmLb6FFTJtM_t6O1v0M0JePshiQJMHr0yYVkHL7ztk,11
12
- rashdf-0.2.2.dist-info/RECORD,,