ras-commander 0.58.0__py3-none-any.whl → 0.59.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/RasPrj.py CHANGED
@@ -828,7 +828,6 @@ def init_ras_project(ras_project_folder, ras_version=None, ras_object=None):
828
828
  Initialize a RAS project.
829
829
 
830
830
  USE THIS FUNCTION TO INITIALIZE A RAS PROJECT, NOT THE INITIALIZE METHOD OF THE RasPrj CLASS.
831
- The initialize method of the RasPrj class only modifies the global 'ras' object.
832
831
 
833
832
  Parameters:
834
833
  -----------
@@ -838,8 +837,10 @@ def init_ras_project(ras_project_folder, ras_version=None, ras_object=None):
838
837
  The version of RAS to use (e.g., "6.6").
839
838
  The version can also be a full path to the Ras.exe file.
840
839
  If None, the function will attempt to use the version from the global 'ras' object or a default path.
841
- ras_object : RasPrj, optional
842
- An instance of RasPrj to initialize. If None, the global 'ras' object is used.
840
+ ras_object : RasPrj or str, optional
841
+ If None, the global 'ras' object is updated.
842
+ If a RasPrj instance, that instance is updated.
843
+ If any other value is provided, a new RasPrj instance is created and returned.
843
844
 
844
845
  Returns:
845
846
  --------
@@ -852,16 +853,24 @@ def init_ras_project(ras_project_folder, ras_version=None, ras_object=None):
852
853
 
853
854
  ras_exe_path = get_ras_exe(ras_version)
854
855
 
856
+ # Determine which RasPrj instance to use
855
857
  if ras_object is None:
858
+ # Use the global 'ras' object
856
859
  logger.info("Initializing global 'ras' object via init_ras_project function.")
857
860
  ras_object = ras
858
861
  elif not isinstance(ras_object, RasPrj):
859
- logger.error("Provided ras_object is not an instance of RasPrj.")
860
- raise TypeError("ras_object must be an instance of RasPrj or None.")
862
+ # Create a new RasPrj instance
863
+ logger.info("Creating a new RasPrj instance.")
864
+ ras_object = RasPrj()
861
865
 
862
866
  # Initialize the RasPrj instance
863
867
  ras_object.initialize(ras_project_folder, ras_exe_path)
864
868
 
869
+ # Always update the global ras object as well
870
+ if ras_object is not ras:
871
+ ras.initialize(ras_project_folder, ras_exe_path)
872
+ logger.info("Global 'ras' object also updated to match the new project.")
873
+
865
874
  logger.info(f"Project initialized. ras_object project folder: {ras_object.project_folder}")
866
875
  return ras_object
867
876
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ras-commander
3
- Version: 0.58.0
3
+ Version: 0.59.0
4
4
  Summary: A Python library for automating HEC-RAS 6.x operations
5
5
  Home-page: https://github.com/gpt-cmdr/ras-commander
6
6
  Author: William M. Katzenmeyer, P.E., C.F.M.
@@ -43,12 +43,11 @@ This repository has several methods of interaction with Large Language Models an
43
43
 
44
44
  1. **[RAS Commander Library Assistant GPT](https://chatgpt.com/g/g-TZRPR3oAO-ras-commander-library-assistant)**: A specialized GPT model with access to the ras-commander codebase and library, available for answering queries and providing code suggestions. You can even upload your own plan, unsteady and HDF files to inspect and help determine how to automate your workflows or visualize your results, although this ability is still limited by OpenAI's GPT frameworks and may not be useful for long conversations.
45
45
 
46
- 2. **[Purpose-Built Knowledge Base Summaries](https://github.com/billk-FM/ras-commander/tree/main/ai_tools/assistant_knowledge_bases)**: Up-to-date compilations of the documentation and codebase for use with large language models like Claude or GPT-4. Look in 'ai_tools/assistant_knowledge_bases/' in the repo. The repo's codebase (without documentation and examples) has been curated to stay within the current ~200k context window limitations of frontier models, and for tasks that do not need an understanding of the underlying code, the Comprehensive Library Guide and any relevant examples from the example folder should be adequate context for leveraging the ras-commander API to complete tasks.
46
+ 2. **[Purpose-Built Knowledge Base Summaries](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/assistant_knowledge_bases)**: Up-to-date compilations of the documentation and codebase for use with large language models like Claude or GPT-4. Look in 'ai_tools/assistant_knowledge_bases/' in the repo. The repo's codebase (without documentation and examples) has been curated to stay within the current ~200k context window limitations of frontier models, and for tasks that do not need an understanding of the underlying code, the Comprehensive Library Guide and any relevant examples from the example folder should be adequate context for leveraging the ras-commander API to complete tasks.
47
47
 
48
- 3. **[Cursor IDE Integration](https://github.com/billk-FM/ras-commander/blob/main/.cursorrules)**: Custom rules(.cursorrules) for the Cursor IDE to provide context-aware suggestions and documentation. Just open the repository folder in Cursor to recognize these instructions. You can create your own folders "/workspace/, "/projects/", or "my_projects/" as these are already in the .gitignore, and place your custom scripts there for your projects. This will allow easy referencing of the ras-commander documents and individual repo files, the automatic loading of the .cursorrules file. Alternatvely, download the github repo into your projects folder to easily load documents and use cursor rules files.
49
-
50
- 5. **[RAS-Commander Library Assistant](https://github.com/billk-FM/ras-commander/blob/main/library_assistant)**: A full-featured interface for multi-turn conversations, using your own API keys and the ras-commander library for context. The library assistant allows you to load your own scripts and chat with specific examples and/or function classes in the RAS-Commander library to effectively utilize the library's functions in your workflow. To reduce hallucinations, a file browser is included which adds full files to the conversation to ensure grounded responses. A dashboard shows you the total context and estimated cost of each request. **Now with support for OpenAI's o1 and o3-mini, and Deepseek V3 and R1 models using US-based Together.ai**
48
+ 3. **[Cursor IDE Integration](https://github.com/gpt-cmdr/ras-commander/blob/main/.cursorrules)**: Custom rules(.cursorrules) for the Cursor IDE to provide context-aware suggestions and documentation. Just open the repository folder in Cursor to recognize these instructions. You can create your own folders "/workspace/, "/projects/", or "my_projects/" as these are already in the .gitignore, and place your custom scripts there for your projects. This will allow easy referencing of the ras-commander documents and individual repo files, the automatic loading of the .cursorrules file. Alternatvely, download the github repo into your projects folder to easily load documents and use cursor rules files.
51
49
 
50
+ 5. **[RAS-Commander Library Assistant](https://github.com/gpt-cmdr/ras-commander/blob/main/library_assistant)**: A full-featured interface for multi-turn conversations, using your own API keys and the ras-commander library for context. The library assistant allows you to load your own scripts and chat with specific examples and/or function classes in the RAS-Commander library to effectively utilize the library's functions in your workflow. To reduce hallucinations, a file browser is included which adds full files to the conversation to ensure grounded responses. A dashboard shows you the total context and estimated cost of each request. **Now with support for OpenAI's o1 and o3-mini, and Deepseek V3 and R1 models using US-based Together.ai**
52
51
 
53
52
  ## Background
54
53
  The ras-commander library emerged from the initial test-bed of AI-driven coding represented by the HEC-Commander tools Python notebooks. These notebooks served as a proof of concept, demonstrating the value proposition of automating HEC-RAS operations. The transition from notebooks to a structured library aims to provide a more robust, maintainable, and extensible solution for water resources engineers.
@@ -65,8 +64,6 @@ HEC-RAS Project Management & Execution
65
64
  - Progress tracking and logging
66
65
  - Execution error handling and recovery
67
66
 
68
-
69
-
70
67
  HDF Data Access & Analysis
71
68
  - 2D mesh results processing (depths, velocities, WSE)
72
69
  - Cross-section data extraction
@@ -76,7 +73,6 @@ HDF Data Access & Analysis
76
73
  - Fluvial-pluvial boundary calculations
77
74
  - Infiltration and precipitation data handling
78
75
 
79
-
80
76
  RAS ASCII File Operations
81
77
  - Plan file creation and modification
82
78
  - Geometry file parsing examples
@@ -93,7 +89,6 @@ First, create a virtual environment with conda or venv (ask ChatGPT if you need
93
89
 
94
90
  In your virtual environment, install ras-commander using pip:
95
91
  ```
96
- pip install h5py numpy pandas requests tqdm scipy xarray geopandas matplotlib ipython tqdm psutil shapely fiona pathlib rtree rasterstats
97
92
  pip install --upgrade ras-commander
98
93
  ```
99
94
  If you have dependency issues with pip (especially if you have errors with numpy), try clearing your local pip packages 'C:\Users\your_username\AppData\Roaming\Python\' and then creating a new virtual environment.
@@ -118,10 +113,6 @@ except ImportError:
118
113
  ```
119
114
  It is highly suggested to fork this repository before going this route, and using Git to manage your changes! This allows any revisions to the ras-commander classes and functions to be actively edited and developed by end users. The folders "/workspace/, "/projects/", or "my_projects/" are included in the .gitignore, so users can place you custom scripts there for any project data they don't want to be tracked by git.
120
115
 
121
-
122
-
123
-
124
-
125
116
  ## Quick Start Guide
126
117
 
127
118
  ```
@@ -141,9 +132,9 @@ RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
141
132
  ### Execute plans in parallel
142
133
  ```
143
134
  results = RasCmdr.compute_parallel(
144
- plan_numbers=["01", "02"],
135
+ plan_number=["01", "02"],
145
136
  max_workers=2,
146
- cores_per_run=2,
137
+ num_cores=2,
147
138
  dest_folder=r"/path/to/results",
148
139
  overwrite_dest=True
149
140
  )
@@ -154,6 +145,63 @@ results = RasCmdr.compute_parallel(
154
145
  RasPlan.set_geom("01", "02")
155
146
  ```
156
147
 
148
+ ### Execution Modes
149
+
150
+ RAS Commander provides three methods for executing HEC-RAS plans:
151
+
152
+ #### Single Plan Execution
153
+ ```python
154
+ # Execute a single plan
155
+ success = RasCmdr.compute_plan("01", dest_folder=r"/path/to/results")
156
+ print(f"Plan execution {'successful' if success else 'failed'}")
157
+ ```
158
+
159
+ #### Sequential Execution of Multiple Plans
160
+ ```python
161
+ # Execute multiple plans in sequence in a test folder
162
+ results = RasCmdr.compute_test_mode(
163
+ plan_number=["01", "02", "03"],
164
+ dest_folder_suffix="[Test]"
165
+ )
166
+ for plan, success in results.items():
167
+ print(f"Plan {plan}: {'Successful' if success else 'Failed'}")
168
+ ```
169
+
170
+ #### Parallel Execution of Multiple Plans
171
+ ```python
172
+ # Execute multiple plans concurrently
173
+ results = RasCmdr.compute_parallel(
174
+ plan_number=["01", "02", "03"],
175
+ max_workers=3,
176
+ num_cores=2
177
+ )
178
+ for plan, success in results.items():
179
+ print(f"Plan {plan}: {'Successful' if success else 'Failed'}")
180
+ ```
181
+
182
+ ### Working with Multiple Projects
183
+
184
+ RAS Commander allows working with multiple HEC-RAS projects simultaneously:
185
+
186
+ ```python
187
+ # Initialize multiple projects
188
+ project1 = init_ras_project(path1, "6.6")
189
+ project2 = init_ras_project(path2, "6.6")
190
+
191
+ # Perform operations on each project
192
+ RasCmdr.compute_plan("01", ras_object=project1, dest_folder=folder1)
193
+ RasCmdr.compute_plan("01", ras_object=project2, dest_folder=folder2)
194
+
195
+ # Compare results between projects
196
+ print(f"Project 1: {project1.project_name}")
197
+ print(f"Project 2: {project2.project_name}")
198
+
199
+ # Always specify the ras_object parameter when working with multiple projects
200
+ # to avoid confusion with the global 'ras' object
201
+ ```
202
+
203
+ This is useful for comparing different river systems, running scenario analyses across multiple watersheds, or managing a suite of related models.
204
+
157
205
  #### Key Components
158
206
 
159
207
  - `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
@@ -182,8 +230,6 @@ RasPlan.set_geom("01", "02")
182
230
 
183
231
  ### Project Organization Diagram
184
232
 
185
- ### Project Organization Diagram
186
-
187
233
  ```
188
234
  ras_commander
189
235
  ├── ras_commander
@@ -214,24 +260,16 @@ ras_commander
214
260
  │ ├── HdfPlot.py
215
261
  │ └── HdfResultsPlot.py
216
262
  ├── examples
217
- │ ├── 01_project_initialization.py
218
- │ ├── 02_plan_operations.py
219
- │ ├── 03_geometry_operations.py
220
- │ ├── 04_unsteady_flow_operations.py
221
- │ ├── 05_utility_functions.py
222
- │ ├── 06_single_plan_execution.py
223
- │ ├── 07_sequential_plan_execution.py
224
- │ ├── 08_parallel_execution.py
225
- │ ├── 09_specifying_plans.py
226
- │ ├── 10_arguments_for_compute.py
227
- │ ├── 11_Using_RasExamples.ipynb
228
- │ ├── 12_plan_set_execution.py
229
- │ ├── 13_multiple_project_operations.py
230
- │ ├── 14_Core_Sensitivity.ipynb
231
- │ ├── 15_plan_key_operations.py
232
- │ ├── 16_scanning_ras_project_info.py
233
- │ ├── 17_parallel_execution_ble.py
234
- │ └── HEC_RAS_2D_HDF_Analysis.ipynb
263
+ │ ├── 00_Using_RasExamples.ipynb
264
+ │ ├── 01_project_initialization.ipynb
265
+ │ ├── 02_plan_and_geometry_operations.ipynb
266
+ │ ├── 03_unsteady_flow_operations.ipynb
267
+ │ ├── 04_multiple_project_operations.ipynb
268
+ │ ├── 05_single_plan_execution.ipynb
269
+ │ ├── 06_executing_plan_sets.ipynb
270
+ │ ├── 07_sequential_plan_execution.ipynb
271
+ │ ├── 08_parallel_execution.ipynb
272
+ │ └── 09_plan_parameter_operations.ipynb
235
273
  ├── tests
236
274
  │ └── ... (test files)
237
275
  ├── .gitignore
@@ -311,7 +349,6 @@ print(runtime_data)
311
349
  ```
312
350
  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.
313
351
 
314
-
315
352
  #### Infrastructure Analysis
316
353
  ```python
317
354
  from ras_commander import HdfPipe, HdfPump
@@ -348,13 +385,33 @@ boundary = HdfFluvialPluvial.calculate_fluvial_pluvial_boundary(
348
385
  )
349
386
  ```
350
387
 
351
- ## Documentation
388
+ ## Examples
352
389
 
353
- For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
390
+ Check out the examples in the repository to learn how to use RAS Commander:
354
391
 
355
- ## Examples
392
+ ### Project Setup
393
+ - `00_Using_RasExamples.ipynb`: Download and extract HEC-RAS example projects
394
+ - `01_project_initialization.ipynb`: Initialize HEC-RAS projects and explore their components
395
+
396
+ ### File Operations
397
+ - `02_plan_and_geometry_operations.ipynb`: Clone and modify plan and geometry files
398
+ - `03_unsteady_flow_operations.ipynb`: Extract and modify boundary conditions
399
+ - `09_plan_parameter_operations.ipynb`: Retrieve and update plan parameters
400
+
401
+ ### Execution Modes
402
+ - `05_single_plan_execution.ipynb`: Execute a single plan with specific options
403
+ - `06_executing_plan_sets.ipynb`: Different ways to specify and execute plan sets
404
+ - `07_sequential_plan_execution.ipynb`: Run multiple plans in sequence
405
+ - `08_parallel_execution.ipynb`: Run multiple plans in parallel
356
406
 
357
- Check out the `examples/` directory for sample scripts demonstrating various features of ras-commander.
407
+ ### Advanced Operations
408
+ - `04_multiple_project_operations.ipynb`: Work with multiple HEC-RAS projects simultaneously
409
+
410
+ These examples demonstrate practical applications of RAS Commander for automating HEC-RAS workflows, from basic operations to advanced scenarios.
411
+
412
+ ## Documentation
413
+
414
+ For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
358
415
 
359
416
  ## Future Development
360
417
 
@@ -365,10 +422,9 @@ The ras-commander library is an ongoing project. Future plans include:
365
422
 
366
423
  ## Related Resources
367
424
 
368
- - [HEC-Commander Blog](https://github.com/billk-FM/HEC-Commander/tree/main/Blog)
425
+ - [HEC-Commander Blog](https://github.com/gpt-cmdr/HEC-Commander/tree/main/Blog)
369
426
  - [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
370
- - [ChatGPT Examples for Water Resources Engineers](https://github.com/billk-FM/HEC-Commander/tree/main/ChatGPT%20Examples)
371
-
427
+ - [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
372
428
 
373
429
  ## Contributing
374
430
 
@@ -405,8 +461,7 @@ These acknowledgments recognize the contributions and inspirations that have hel
405
461
 
406
462
  4. 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.
407
463
 
408
- 5. [HEC-Commander Tools](https://github.com/billk-FM/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
409
-
464
+ 5. [HEC-Commander Tools](https://github.com/gpt-cmdr/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
410
465
 
411
466
  ## Official RAS Commander AI-Generated Songs:
412
467
 
@@ -416,14 +471,13 @@ These acknowledgments recognize the contributions and inspirations that have hel
416
471
 
417
472
  ## Other Resources
418
473
 
419
- Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/billk-FM/HEC-Commander/tree/main/RAS-Commander)
474
+ Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/gpt-cmdr/HEC-Commander/tree/main/RAS-Commander)
420
475
  Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
421
476
 
422
477
  ## LICENSE
423
478
 
424
479
  This software is released under the MIT license.
425
480
 
426
-
427
481
  ## Contact
428
482
 
429
483
  For questions, suggestions, or support, please contact:
@@ -22,13 +22,13 @@ ras_commander/RasGeo.py,sha256=M0sVNKlWmmbve8iMXLWq25WgbxqLWBo7_1oDg_rALzU,5607
22
22
  ras_commander/RasGpt.py,sha256=N_7p2nucWrBBXdB2k2ZKvOeOdXNmFD9dIY3W7_5i5nw,1206
23
23
  ras_commander/RasMapper.py,sha256=A7xupixCmgXFiSfQs3oWBMBstrO8XcxieMeZWKTcbPQ,3271
24
24
  ras_commander/RasPlan.py,sha256=1HAn31oyz0hGv2r7GVNCLWcAZFcRjYTBNdL19mabvmw,53651
25
- ras_commander/RasPrj.py,sha256=9F0UVQZ2RfjhDf5717aJcEChL6z5BD8agGWAlUvqe0E,37472
25
+ ras_commander/RasPrj.py,sha256=epORKnwdzAovAO-whadvkOhJ8ruXPqmPjGCouHdqzuo,37783
26
26
  ras_commander/RasToGo.py,sha256=TKujfaV1xQhFaOddF4g2ogGy6ky-CLlfelSMPD2J3Nk,1223
27
27
  ras_commander/RasUnsteady.py,sha256=KfCXAag-_bPwwS3JbPZH-s4hbaoHACO0mlRnGrzbFgA,32092
28
28
  ras_commander/RasUtils.py,sha256=P2-aBL61kdRINsjnBpstZVD6VVc7hI_D3RUXqr6ldmc,34863
29
29
  ras_commander/__init__.py,sha256=mceEWRQJkDBi1o3zVg7DpG2qMrMnKHwwuK3GwyxoVr4,2132
30
- ras_commander-0.58.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
31
- ras_commander-0.58.0.dist-info/METADATA,sha256=aKq0yFZkuylnSHsK_BRqyie9X30WA9rThWeZQN7X2Ek,22149
32
- ras_commander-0.58.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
33
- ras_commander-0.58.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
34
- ras_commander-0.58.0.dist-info/RECORD,,
30
+ ras_commander-0.59.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
31
+ ras_commander-0.59.0.dist-info/METADATA,sha256=Ai5tJpr_j9k8uO1SDIIz0WFLJu2QhAKesqh5ZB1mPWY,24307
32
+ ras_commander-0.59.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
33
+ ras_commander-0.59.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
34
+ ras_commander-0.59.0.dist-info/RECORD,,