ras-commander 0.34.0__py3-none-any.whl → 0.35.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.
ras_commander/RasPlan.py CHANGED
@@ -1060,7 +1060,7 @@ class RasPlan:
1060
1060
  Any: The value associated with the specified key
1061
1061
 
1062
1062
  Raises:
1063
- ValueError: If an invalid key is provided or if the plan file is not found
1063
+ ValueError: If the plan file is not found
1064
1064
  IOError: If there's an error reading the plan file
1065
1065
 
1066
1066
  Available keys and their expected types:
@@ -1086,6 +1086,7 @@ class RasPlan:
1086
1086
  - 'unet_1d_methodology' (str): 1D calculation methodology
1087
1087
  - 'unet_d2_solver_type' (str): 2D solver type
1088
1088
  - 'unet_d2_name' (str): Name of the 2D area
1089
+ - 'run_rasmapper' (int): Flag to run RASMapper for floodplain mapping (-1 for off, 0 for on)
1089
1090
 
1090
1091
  Example:
1091
1092
  >>> computation_interval = RasPlan.get_plan_value("01", "computation_interval")
@@ -1099,11 +1100,11 @@ class RasPlan:
1099
1100
  'geom_file', 'mapping_interval', 'plan_file', 'plan_title', 'program_version',
1100
1101
  'run_htab', 'run_post_process', 'run_sediment', 'run_unet', 'run_wqnet',
1101
1102
  'short_identifier', 'simulation_date', 'unet_d1_cores', 'unet_use_existing_ib_tables',
1102
- 'unet_1d_methodology', 'unet_d2_solver_type', 'unet_d2_name'
1103
+ 'unet_1d_methodology', 'unet_d2_solver_type', 'unet_d2_name', 'run_rasmapper'
1103
1104
  }
1104
1105
 
1105
1106
  if key not in valid_keys:
1106
- raise ValueError(f"Invalid key: {key}. Valid keys are: {', '.join(valid_keys)}")
1107
+ logging.warning(f"Unknown key: {key}. Valid keys are: {', '.join(valid_keys)}\n Add more keys and explanations in get_plan_value() as needed.")
1107
1108
 
1108
1109
  plan_file_path = Path(plan_number_or_path)
1109
1110
  if not plan_file_path.is_file():
@@ -1124,7 +1125,11 @@ class RasPlan:
1124
1125
  else:
1125
1126
  pattern = f"{key.replace('_', ' ').title()}=(.*)"
1126
1127
  match = re.search(pattern, content)
1127
- return match.group(1).strip() if match else None
1128
+ if match:
1129
+ return match.group(1).strip()
1130
+ else:
1131
+ logging.error(f"Key '{key}' not found in the plan file.")
1132
+ return None
1128
1133
 
1129
1134
  @staticmethod
1130
1135
  def update_plan_value(
@@ -1143,7 +1148,7 @@ class RasPlan:
1143
1148
  ras_object (RasPrj, optional): Specific RAS object to use. If None, uses the global ras instance.
1144
1149
 
1145
1150
  Raises:
1146
- ValueError: If an invalid key is provided or if the plan file is not found
1151
+ ValueError: If the plan file is not found
1147
1152
  IOError: If there's an error reading or writing the plan file
1148
1153
 
1149
1154
  Note: See the docstring of get_plan_value for a full list of available keys and their types.
@@ -1151,6 +1156,7 @@ class RasPlan:
1151
1156
  Example:
1152
1157
  >>> RasPlan.update_plan_value("01", "computation_interval", "10SEC")
1153
1158
  >>> RasPlan.update_plan_value("/path/to/plan.p01", "run_htab", 1)
1159
+ >>> RasPlan.update_plan_value("01", "run_rasmapper", 0) # Turn on Floodplain Mapping
1154
1160
  """
1155
1161
  ras_obj = ras_object or ras
1156
1162
  ras_obj.check_initialized()
@@ -1160,11 +1166,11 @@ class RasPlan:
1160
1166
  'geom_file', 'mapping_interval', 'plan_file', 'plan_title', 'program_version',
1161
1167
  'run_htab', 'run_post_process', 'run_sediment', 'run_unet', 'run_wqnet',
1162
1168
  'short_identifier', 'simulation_date', 'unet_d1_cores', 'unet_use_existing_ib_tables',
1163
- 'unet_1d_methodology', 'unet_d2_solver_type', 'unet_d2_name'
1169
+ 'unet_1d_methodology', 'unet_d2_solver_type', 'unet_d2_name', 'run_rasmapper'
1164
1170
  }
1165
1171
 
1166
1172
  if key not in valid_keys:
1167
- raise ValueError(f"Invalid key: {key}. Valid keys are: {', '.join(valid_keys)}")
1173
+ logging.warning(f"Unknown key: {key}. Valid keys are: {', '.join(valid_keys)}")
1168
1174
 
1169
1175
  plan_file_path = Path(plan_number_or_path)
1170
1176
  if not plan_file_path.is_file():
@@ -1203,7 +1209,8 @@ class RasPlan:
1203
1209
  updated = True
1204
1210
  break
1205
1211
  if not updated:
1206
- lines.append(f"{pattern}{value}\n")
1212
+ logging.error(f"Key '{key}' not found in the plan file.")
1213
+ return
1207
1214
 
1208
1215
  try:
1209
1216
  with open(plan_file_path, 'w') as file:
ras_commander/RasPrj.py CHANGED
@@ -650,6 +650,10 @@ def init_ras_project(ras_project_folder, ras_version, ras_instance=None):
650
650
  Avoid mixing use of the global 'ras' object and custom instances to prevent
651
651
  confusion and potential bugs.
652
652
  """
653
+ logging.info(f"Initializing project in folder: {ras_project_folder}")
654
+ logging.info(f"Using ras_instance with id: {id(ras_instance)}")
655
+
656
+
653
657
 
654
658
  if not Path(ras_project_folder).exists():
655
659
  logging.error(f"The specified RAS project folder does not exist: {ras_project_folder}. Please check the path and try again.")
@@ -666,7 +670,8 @@ def init_ras_project(ras_project_folder, ras_version, ras_instance=None):
666
670
 
667
671
  # Initialize the RasPrj instance
668
672
  ras_instance.initialize(ras_project_folder, ras_exe_path)
669
-
673
+
674
+ logging.info(f"Project initialized. ras_instance project folder: {ras_instance.project_folder}")
670
675
  return ras_instance
671
676
 
672
677
 
@@ -729,4 +734,5 @@ def get_ras_exe(ras_version):
729
734
  f"Invalid HEC-RAS version or path: {ras_version}. "
730
735
  f"Please provide a valid version number from {ras_version_numbers} "
731
736
  "or a full path to the HEC-RAS executable."
732
- )
737
+ )
738
+
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ras-commander
3
- Version: 0.34.0
3
+ Version: 0.35.0
4
4
  Summary: A Python library for automating HEC-RAS operations
5
5
  Home-page: https://github.com/billk-FM/ras-commander
6
6
  Author: William M. Katzenmeyer
7
7
  Author-email: billk@fenstermaker.com
8
- Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
9
10
  Classifier: License :: OSI Approved :: MIT License
10
11
  Classifier: Operating System :: OS Independent
11
12
  Requires-Python: >=3.9
@@ -15,9 +16,10 @@ Requires-Dist: pandas>=1.0.0
15
16
  Requires-Dist: numpy>=1.18.0
16
17
  Requires-Dist: h5py>=3.1.0
17
18
  Requires-Dist: requests>=2.25.0
18
- Requires-Dist: pathlib>=1.0.1
19
19
  Requires-Dist: scipy>=1.5.0
20
20
  Requires-Dist: matplotlib>=3.3.0
21
+ Requires-Dist: tqdm>=4.50.0
22
+ Requires-Dist: psutil>=5.7.0
21
23
  Provides-Extra: dev
22
24
  Requires-Dist: pytest>=6.2.0; extra == "dev"
23
25
  Requires-Dist: flake8>=3.9.0; extra == "dev"
@@ -116,18 +118,21 @@ results = RasCmdr.compute_parallel(
116
118
  RasPlan.set_geom("01", "02")
117
119
  ```
118
120
 
121
+ Certainly! I'll provide you with an updated Key Components section and Project Organization diagram based on the current structure of the ras-commander library.
122
+
119
123
  ## Key Components
120
124
 
121
- - `RasPrj`: Manages HEC-RAS projects
125
+ - `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
122
126
  - `RasCmdr`: Handles execution of HEC-RAS simulations
123
127
  - `RasPlan`: Provides functions for modifying and updating plan files
124
128
  - `RasGeo`: Handles operations related to geometry files
125
129
  - `RasUnsteady`: Manages unsteady flow file operations
126
130
  - `RasUtils`: Contains utility functions for file operations and data management
127
131
  - `RasExamples`: Manages and loads HEC-RAS example projects
128
-
132
+ - `RasHdf`: Provides utilities for working with HDF files in HEC-RAS projects
129
133
 
130
134
  ## Project Organization Diagram
135
+
131
136
  ```
132
137
  ras_commander
133
138
  ├── .github
@@ -135,9 +140,11 @@ ras_commander
135
140
  │ └── python-package.yml
136
141
  ├── ras_commander
137
142
  │ ├── __init__.py
143
+ │ ├── _version.py
138
144
  │ ├── RasCmdr.py
139
145
  │ ├── RasExamples.py
140
146
  │ ├── RasGeo.py
147
+ │ ├── RasHdf.py
141
148
  │ ├── RasPlan.py
142
149
  │ ├── RasPrj.py
143
150
  │ ├── RasUnsteady.py
@@ -155,7 +162,12 @@ ras_commander
155
162
  │ ├── 10_arguments_for_compute.py
156
163
  │ ├── 11_Using_RasExamples.ipynb
157
164
  │ ├── 12_plan_set_execution.py
158
- │ └── 13_multiple_project_operations.py
165
+ │ ├── 13_multiple_project_operations.py
166
+ │ ├── 14_Core_Sensitivity.ipynb
167
+ │ ├── 15_plan_key_operations.py
168
+ │ ├── 16_scanning_ras_project_info.py
169
+ │ ├── 17_parallel_execution_ble.py
170
+ │ └── HEC_RAS_2D_HDF_Analysis.ipynb
159
171
  ├── tests
160
172
  │ └── ... (test files)
161
173
  ├── .gitignore
@@ -190,7 +202,6 @@ projects = ras_examples.list_projects("Steady Flow")
190
202
  extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
191
203
  ```
192
204
 
193
-
194
205
  ## RasPrj
195
206
 
196
207
  The `RasPrj` class is central to managing HEC-RAS projects within the ras-commander library. It handles project initialization, data loading, and provides access to project components.
@@ -218,6 +229,28 @@ custom_project = RasPrj()
218
229
  init_ras_project("/path/to/another_project", "6.5", ras_instance=custom_project)
219
230
  ```
220
231
 
232
+ ## RasHdf
233
+
234
+ The `RasHdf` class provides utilities for working with HDF files in HEC-RAS projects, enabling easy access to simulation results and model data.
235
+
236
+ Example usage:
237
+
238
+ ```python
239
+ from ras_commander import RasHdf, init_ras_project, RasPrj
240
+
241
+ # Initialize project with a custom ras object
242
+ custom_ras = RasPrj()
243
+ init_ras_project("/path/to/project", "6.5", ras_instance=custom_ras)
244
+
245
+ # Get runtime data for a specific plan
246
+ plan_number = "01"
247
+ runtime_data = RasHdf.get_runtime_data(plan_number, ras_object=custom_ras)
248
+ print(runtime_data)
249
+ ```
250
+
251
+ This class simplifies the process of extracting and analyzing data from HEC-RAS HDF output files, supporting tasks such as post-processing and result visualization.
252
+
253
+
221
254
  ## Documentation
222
255
 
223
256
  For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
@@ -255,7 +288,30 @@ ras-commander is released under the MIT License. See the license file for detail
255
288
 
256
289
  ## Acknowledgments
257
290
 
258
- RAS Commander is based on the HEC-Commander project's "Command Line is All You Need" approach, leveraging the HEC-RAS command-line interface for automation. The initial development of this library was presented in the HEC-Commander Tools repository. In a 2024 Australian Water School webinar, Bill demonstrated the derivation of basic HEC-RAS automation functions from plain language instructions. Leveraging the previously developed code and AI tools, the library was created. The primary tools used for this initial development were Anthropic's Claude, GPT-4o, Google's Gemini Experimental models, and the Cursor AI Coding IDE.
291
+ RAS Commander is based on the HEC-Commander project's "Command Line is All You Need" approach, leveraging the HEC-RAS command-line interface for automation. The initial development of this library was presented in the HEC-Commander Tools repository. In a 2024 Australian Water School webinar, Bill demonstrated the derivation of basic HEC-RAS automation functions from plain language instructions. Leveraging the previously developed code and AI tools, the library was created. The primary tools used for this initial development were Anthropic's Claude, GPT-4, Google's Gemini Experimental models, and the Cursor AI Coding IDE.
292
+
293
+ Additionally, we would like to acknowledge the following notable contributions and attributions for open source projects which significantly influenced the development of RAS Commander:
294
+
295
+ 1. Contributions: Sean Micek's [`funkshuns`](https://github.com/openSourcerer9000/funkshuns), [`TXTure`](https://github.com/openSourcerer9000/TXTure), and [`RASmatazz`](https://github.com/openSourcerer9000/RASmatazz) libraries provided inspiration, code examples and utility functions which were adapted with AI for use in RAS Commander. Sean has also contributed heavily to
296
+
297
+ - Development of additional HDF functions for detailed analysis and mapping of HEC-RAS results within the RasHdf class.
298
+ - Development of the prototype `RasCmdr` class for executing HEC-RAS simulations.
299
+ - Optimization examples and methods from (INSERT REFERENCE) for use in the Ras-Commander library examples
300
+
301
+ 2. Attribution: The [`pyHMT2D`](https://github.com/psu-efd/pyHMT2D/) project by Xiaofeng Liu, which provided insights into HDF file handling methods for HEC-RAS outputs. Many of the functions in the [Ras_2D_Data.py](https://github.com/psu-efd/pyHMT2D/blob/main/pyHMT2D/Hydraulic_Models_Data/RAS_2D/RAS_2D_Data.py) file were adapted with AI for use in RAS Commander.
302
+
303
+ Xiaofeng Liu, Ph.D., P.E.
304
+ Associate Professor
305
+ Department of Civil and Environmental Engineering
306
+ Institute of Computational and Data Sciences
307
+ Penn State University
308
+
309
+ These acknowledgments recognize the contributions and inspirations that have helped shape RAS Commander, ensuring proper attribution for the ideas and code that have influenced its development.
310
+
311
+ 3. Chris Goodell, "Breaking the HEC-RAS Code" - Studied and used as a reference for understanding the inner workings of HEC-RAS, providing valuable insights into the software's functionality and structure.
312
+
313
+ 4. [HEC-Commander Tools](https://github.com/billk-FM/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
314
+
259
315
 
260
316
  ## Contact
261
317
 
@@ -0,0 +1,15 @@
1
+ ras_commander/RasCmdr.py,sha256=fX_rh_IcBuJYEbGXfUc7Fge6cdJAAGKN_V5sGZgIJT4,24447
2
+ ras_commander/RasExamples.py,sha256=VgjBcB56u5gzzzYzz0YXj5rKWk3u7oRoja97_3ArJHc,24127
3
+ ras_commander/RasGeo.py,sha256=6DO5utVBjkIhqJ_WYQSeU4i74Bv_pZO3pmWdVf-jj3U,5137
4
+ ras_commander/RasHdf.py,sha256=z5PZDZ44jS6dYNc1AdDyVqt2YqaMGulR72yBLQYoIeI,83927
5
+ ras_commander/RasPlan.py,sha256=Aa3qhPA8EvEEfSSibeQq2UYawU5kMRCJOgonjBwn8uU,53718
6
+ ras_commander/RasPrj.py,sha256=246bvWbjRCEt-4L1sMovCyNmPWQ6t2uGHkecs9Nro4E,30594
7
+ ras_commander/RasUnsteady.py,sha256=jgV3gqGFsIMV0c9eFaXjVM5pqAb82Du_7ObiIPnemJs,4077
8
+ ras_commander/RasUtils.py,sha256=ESsjQNjPsojZ8SINnMbMZDDWeyBqF6owaPV8brtS3S8,24435
9
+ ras_commander/__init__.py,sha256=7H3JDR5VmTo6P0fJFJe9mTozMWp-owrrHjy7lADVA6Q,1167
10
+ ras_commander/_version.py,sha256=BReLomJ164W3bJhfQJi0gbNKc3DXCzwusmCheUzClB8,478
11
+ ras_commander-0.35.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
12
+ ras_commander-0.35.0.dist-info/METADATA,sha256=k4I3IpZXFOHaMK0Y9CUPuaZ8IlGjBLF5ot4dElRytOQ,15325
13
+ ras_commander-0.35.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
14
+ ras_commander-0.35.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
15
+ ras_commander-0.35.0.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- ras_commander/RasCmdr.py,sha256=vaB1_33nJMISwCbayYawaVZKjrXy_Jne8KEnfvKxot8,24285
2
- ras_commander/RasExamples.py,sha256=7A3dt3DnWSdFsZYn9Jqvr93bWNoFSwJYLMiy21hzvgo,16412
3
- ras_commander/RasGeo.py,sha256=6DO5utVBjkIhqJ_WYQSeU4i74Bv_pZO3pmWdVf-jj3U,5137
4
- ras_commander/RasHdf.py,sha256=rxe9tlQdeh_wOIUa1lplxbj8JM8HCWZigEHSkySNri4,11222
5
- ras_commander/RasPlan.py,sha256=5M1ra2oOxGUa2YTRhuKInKq64sXSuVc8bZjvd9N3rOo,53314
6
- ras_commander/RasPrj.py,sha256=Clso7BccVDd51zCrN3eoAzJ8EXfK6Aai88_spGymOuM,30330
7
- ras_commander/RasUnsteady.py,sha256=jgV3gqGFsIMV0c9eFaXjVM5pqAb82Du_7ObiIPnemJs,4077
8
- ras_commander/RasUtils.py,sha256=ESsjQNjPsojZ8SINnMbMZDDWeyBqF6owaPV8brtS3S8,24435
9
- ras_commander/__init__.py,sha256=7H3JDR5VmTo6P0fJFJe9mTozMWp-owrrHjy7lADVA6Q,1167
10
- ras_commander/_version.py,sha256=BReLomJ164W3bJhfQJi0gbNKc3DXCzwusmCheUzClB8,478
11
- ras_commander-0.34.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
12
- ras_commander-0.34.0.dist-info/METADATA,sha256=qAoJZW8ITX0vGKiqdanV3UUOGph_MeH_SbDOMSFoeaI,11826
13
- ras_commander-0.34.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
14
- ras_commander-0.34.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
15
- ras_commander-0.34.0.dist-info/RECORD,,