rashdf 0.1.0__py3-none-any.whl → 0.1.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/utils.py CHANGED
@@ -73,14 +73,18 @@ def parse_duration(duration_str: str) -> timedelta:
73
73
  return duration
74
74
 
75
75
 
76
- def convert_ras_hdf_string(value: str) -> Union[bool, str, List[str]]:
76
+ def convert_ras_hdf_string(
77
+ value: str,
78
+ ) -> Union[bool, datetime, List[datetime], timedelta, str]:
77
79
  """Convert a string value from an HEC-RAS HDF file into a Python object.
78
80
 
79
81
  This function handles several specific string formats:
80
- - "True" and "False" are converted to boolean values.
81
- - Strings matching the format "ddMMMyyyy HH:mm:ss" or "ddMMMyyyy HHmm" are parsed into datetime objects.
82
- - Strings matching the format "ddMMMyyyy HH:mm:ss to ddMMMyyyy HH:mm:ss" or "ddMMMyyyy HHmm to ddMMMyyyy HHmm"
83
- are parsed into a list of two datetime objects.
82
+ - The strings "True" and "False" are converted to boolean values.
83
+ - Strings matching the format "ddMMMyyyy HH:mm:ss" or "ddMMMyyyy HHmm"
84
+ are parsed into datetime objects.
85
+ - Strings matching the format "ddMMMyyyy HH:mm:ss to ddMMMyyyy HH:mm:ss" or
86
+ "ddMMMyyyy HHmm to ddMMMyyyy HHmm" are parsed into a list of two datetime objects.
87
+ - Strings matching the format "HH:mm:ss" are parsed into timedelta objects.
84
88
 
85
89
  Parameters
86
90
  ----------
@@ -88,11 +92,13 @@ def convert_ras_hdf_string(value: str) -> Union[bool, str, List[str]]:
88
92
 
89
93
  Returns
90
94
  -------
91
- The converted value, which could be a boolean, a datetime string, a list of datetime strings, or the original
92
- string if no other conditions are met.
95
+ The converted value, which could be a boolean, a datetime string,
96
+ a list of datetime strings, a timedelta objects, or the original string
97
+ if no other conditions are met.
93
98
  """
94
99
  ras_datetime_format1_re = r"\d{2}\w{3}\d{4} \d{2}:\d{2}:\d{2}"
95
100
  ras_datetime_format2_re = r"\d{2}\w{3}\d{4} \d{2}\d{2}"
101
+ ras_duration_format_re = r"\d{2}:\d{2}:\d{2}"
96
102
  s = value.decode("utf-8")
97
103
  if s == "True":
98
104
  return True
@@ -114,6 +120,8 @@ def convert_ras_hdf_string(value: str) -> Union[bool, str, List[str]]:
114
120
  parse_ras_simulation_window_datetime(split[1]),
115
121
  ]
116
122
  return parse_ras_simulation_window_datetime(s)
123
+ elif re.match(rf"^{ras_duration_format_re}$", s):
124
+ return parse_duration(s)
117
125
  return s
118
126
 
119
127
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rashdf
3
- Version: 0.1.0
3
+ Version: 0.1.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
@@ -64,9 +64,17 @@ Also, methods to extract certain HDF group attributes as dictionaries:
64
64
  ```python
65
65
  >>> from rashdf import RasPlanHdf
66
66
  >>> with RasPlanHdf("path/to/rasmodel/Muncie.p04.hdf") as plan_hdf:
67
- >>> results_unsteady_summary = plan_hdf.get_results_unsteady_summary()
67
+ >>> results_unsteady_summary = plan_hdf.get_results_unsteady_summary()
68
68
  >>> results_unsteady_summary
69
- {'Computation Time DSS': '00:00:00', 'Computation Time Total': '00:00:23', 'Maximum WSEL Error': 0.0099277812987566, 'Maximum number of cores': 6, 'Run Time Window': [datetime.datetime(2024, 3, 27, 9, 31, 52), datetime.datetime(2024, 3, 27, 9, 32, 15)], 'Solution': 'Unsteady Finished Successfully', 'Time Solution Went Unstable': None, 'Time Stamp Solution Went Unstable': 'Not Applicable'}
69
+ {'Computation Time DSS': datetime.timedelta(0),
70
+ 'Computation Time Total': datetime.timedelta(seconds=23),
71
+ 'Maximum WSEL Error': 0.0099277812987566,
72
+ 'Maximum number of cores': 6,
73
+ 'Run Time Window': [datetime.datetime(2024, 3, 27, 9, 31, 52),
74
+ datetime.datetime(2024, 3, 27, 9, 32, 15)],
75
+ 'Solution': 'Unsteady Finished Successfully',
76
+ 'Time Solution Went Unstable': None,
77
+ 'Time Stamp Solution Went Unstable': 'Not Applicable'}
70
78
  ```
71
79
 
72
80
  ## Documentation
@@ -0,0 +1,10 @@
1
+ rashdf/__init__.py,sha256=r_UaNbJve1yWg-2r7qFiZVMdYiq4m5LNoRLJKL4HYYk,133
2
+ rashdf/base.py,sha256=yTihpXoSm-S6kb1BGdru4UPIR3_-mDFrcEaQfXd8ujY,2384
3
+ rashdf/geom.py,sha256=74VKwlgElFc167hTk2BbyFmKbbzi3o9SyW9tkH23XDM,14846
4
+ rashdf/plan.py,sha256=GU8BlRBN27R-letDhF_fOK1xAaJsL4CSYEyBCiDBaPs,2472
5
+ rashdf/utils.py,sha256=VEMopHMEzI4Os2tcR6jh6LAxz7kjYYXCp8EL6P8ojUc,7337
6
+ rashdf-0.1.1.dist-info/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
7
+ rashdf-0.1.1.dist-info/METADATA,sha256=TSZEt9uzChSN__Q5ErtM5-yG4NFLhMm0ds-5587h2o0,4183
8
+ rashdf-0.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
9
+ rashdf-0.1.1.dist-info/top_level.txt,sha256=1iE403K85UTilumVhhghg2JdH3ABHE-2DmvFpKvi9fA,7
10
+ rashdf-0.1.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- rashdf/__init__.py,sha256=r_UaNbJve1yWg-2r7qFiZVMdYiq4m5LNoRLJKL4HYYk,133
2
- rashdf/base.py,sha256=yTihpXoSm-S6kb1BGdru4UPIR3_-mDFrcEaQfXd8ujY,2384
3
- rashdf/geom.py,sha256=74VKwlgElFc167hTk2BbyFmKbbzi3o9SyW9tkH23XDM,14846
4
- rashdf/plan.py,sha256=GU8BlRBN27R-letDhF_fOK1xAaJsL4CSYEyBCiDBaPs,2472
5
- rashdf/utils.py,sha256=5jWSjCkPdnwGXwN7ELv9rpiUWtn3cprlZkfxmJYAWf8,7038
6
- rashdf-0.1.0.dist-info/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
7
- rashdf-0.1.0.dist-info/METADATA,sha256=dFe6XNXj3PaygLZoSZ8DVM-M10vsrfP2drZZ0PaFBXw,4156
8
- rashdf-0.1.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
9
- rashdf-0.1.0.dist-info/top_level.txt,sha256=1iE403K85UTilumVhhghg2JdH3ABHE-2DmvFpKvi9fA,7
10
- rashdf-0.1.0.dist-info/RECORD,,
File without changes