ras-commander 0.58.0__tar.gz → 0.61.0__tar.gz
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-0.58.0/ras_commander.egg-info → ras_commander-0.61.0}/PKG-INFO +139 -52
- {ras_commander-0.58.0 → ras_commander-0.61.0}/README.md +139 -52
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/Decorators.py +13 -7
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasPrj.py +14 -5
- {ras_commander-0.58.0 → ras_commander-0.61.0/ras_commander.egg-info}/PKG-INFO +139 -52
- {ras_commander-0.58.0 → ras_commander-0.61.0}/setup.py +1 -1
- {ras_commander-0.58.0 → ras_commander-0.61.0}/LICENSE +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/pyproject.toml +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfBase.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfBndry.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfFluvialPluvial.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfInfiltration.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfMesh.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfPipe.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfPlan.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfPlot.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfPump.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfResultsMesh.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfResultsPlan.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfResultsPlot.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfResultsXsec.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfStruc.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfUtils.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/HdfXsec.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/LoggingConfig.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasCmdr.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasExamples.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasGeo.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasGpt.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasMapper.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasPlan.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasToGo.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasUnsteady.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/RasUtils.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander/__init__.py +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander.egg-info/SOURCES.txt +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander.egg-info/dependency_links.txt +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander.egg-info/requires.txt +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/ras_commander.egg-info/top_level.txt +0 -0
- {ras_commander-0.58.0 → ras_commander-0.61.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ras-commander
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.61.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/
|
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/
|
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,21 +113,49 @@ 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
|
```
|
128
119
|
from ras_commander import init_ras_project, RasCmdr, RasPlan
|
129
120
|
```
|
130
121
|
|
131
|
-
### Initialize a project
|
122
|
+
### Initialize a project (single project)
|
132
123
|
```
|
133
124
|
init_ras_project(r"/path/to/project", "6.5")
|
134
125
|
```
|
135
126
|
|
127
|
+
### Initialize a project (multiple projects)
|
128
|
+
```
|
129
|
+
your_ras_project = RasPrj()
|
130
|
+
init_ras_project(r"/path/to/project", "6.5", ras_object=your_ras_project)
|
131
|
+
```
|
132
|
+
|
133
|
+
## Accessing Plan, Unsteady and Boundary Conditions Dataframes
|
134
|
+
Using the default 'ras" object, othewise substitute your_ras_project for muli-project scripts
|
135
|
+
```
|
136
|
+
print("\nPlan Files DataFrame:")
|
137
|
+
ras.plan_df
|
138
|
+
|
139
|
+
print("\nFlow Files DataFrame:")
|
140
|
+
ras.flow_df
|
141
|
+
|
142
|
+
print("\nUnsteady Flow Files DataFrame:")
|
143
|
+
ras.unsteady_df
|
144
|
+
|
145
|
+
print("\nGeometry Files DataFrame:")
|
146
|
+
ras.geom_df
|
147
|
+
|
148
|
+
print("\nHDF Entries DataFrame:")
|
149
|
+
ras.get_hdf_entries()
|
150
|
+
|
151
|
+
print("\nBoundary Conditions DataFrame:")
|
152
|
+
ras.boundaries_df
|
153
|
+
|
154
|
+
```
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
136
159
|
### Execute a single plan
|
137
160
|
```
|
138
161
|
RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
@@ -141,9 +164,9 @@ RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
|
141
164
|
### Execute plans in parallel
|
142
165
|
```
|
143
166
|
results = RasCmdr.compute_parallel(
|
144
|
-
|
167
|
+
plan_number=["01", "02"],
|
145
168
|
max_workers=2,
|
146
|
-
|
169
|
+
num_cores=2,
|
147
170
|
dest_folder=r"/path/to/results",
|
148
171
|
overwrite_dest=True
|
149
172
|
)
|
@@ -154,7 +177,66 @@ results = RasCmdr.compute_parallel(
|
|
154
177
|
RasPlan.set_geom("01", "02")
|
155
178
|
```
|
156
179
|
|
157
|
-
|
180
|
+
### Execution Modes
|
181
|
+
|
182
|
+
RAS Commander provides three methods for executing HEC-RAS plans:
|
183
|
+
|
184
|
+
#### Single Plan Execution
|
185
|
+
```python
|
186
|
+
# Execute a single plan
|
187
|
+
success = RasCmdr.compute_plan("01", dest_folder=r"/path/to/results")
|
188
|
+
print(f"Plan execution {'successful' if success else 'failed'}")
|
189
|
+
```
|
190
|
+
|
191
|
+
#### Sequential Execution of Multiple Plans
|
192
|
+
```python
|
193
|
+
# Execute multiple plans in sequence in a test folder
|
194
|
+
results = RasCmdr.compute_test_mode(
|
195
|
+
plan_number=["01", "02", "03"],
|
196
|
+
dest_folder_suffix="[Test]"
|
197
|
+
)
|
198
|
+
for plan, success in results.items():
|
199
|
+
print(f"Plan {plan}: {'Successful' if success else 'Failed'}")
|
200
|
+
```
|
201
|
+
|
202
|
+
#### Parallel Execution of Multiple Plans
|
203
|
+
```python
|
204
|
+
# Execute multiple plans concurrently
|
205
|
+
results = RasCmdr.compute_parallel(
|
206
|
+
plan_number=["01", "02", "03"],
|
207
|
+
max_workers=3,
|
208
|
+
num_cores=2
|
209
|
+
)
|
210
|
+
for plan, success in results.items():
|
211
|
+
print(f"Plan {plan}: {'Successful' if success else 'Failed'}")
|
212
|
+
```
|
213
|
+
|
214
|
+
### Working with Multiple Projects
|
215
|
+
|
216
|
+
RAS Commander allows working with multiple HEC-RAS projects simultaneously:
|
217
|
+
|
218
|
+
```python
|
219
|
+
# Initialize multiple projects
|
220
|
+
project1 = RasPrj()
|
221
|
+
init_ras_project(path1, "6.6", ras_object=project1)
|
222
|
+
project2 = RasPrj()
|
223
|
+
init_ras_project(path2, "6.6", ras_object=project2)
|
224
|
+
|
225
|
+
# Perform operations on each project
|
226
|
+
RasCmdr.compute_plan("01", ras_object=project1, dest_folder=folder1)
|
227
|
+
RasCmdr.compute_plan("01", ras_object=project2, dest_folder=folder2)
|
228
|
+
|
229
|
+
# Compare results between projects
|
230
|
+
print(f"Project 1: {project1.project_name}")
|
231
|
+
print(f"Project 2: {project2.project_name}")
|
232
|
+
|
233
|
+
# Always specify the ras_object parameter when working with multiple projects
|
234
|
+
# to avoid confusion with the global 'ras' object
|
235
|
+
```
|
236
|
+
|
237
|
+
This is useful for comparing different river systems, running scenario analyses across multiple watersheds, or managing a suite of related models.
|
238
|
+
|
239
|
+
#### Core HEC-RAS Automation Classes
|
158
240
|
|
159
241
|
- `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
|
160
242
|
- `RasCmdr`: Handles execution of HEC-RAS simulations
|
@@ -164,7 +246,7 @@ RasPlan.set_geom("01", "02")
|
|
164
246
|
- `RasUtils`: Contains utility functions for file operations and data management
|
165
247
|
- `RasExamples`: Manages and loads HEC-RAS example projects
|
166
248
|
|
167
|
-
####
|
249
|
+
#### HDF Data Access Classes
|
168
250
|
- `HdfBase`: Core functionality for HDF file operations
|
169
251
|
- `HdfBndry`: Enhanced boundary condition handling
|
170
252
|
- `HdfMesh`: Comprehensive mesh data management
|
@@ -176,14 +258,11 @@ RasPlan.set_geom("01", "02")
|
|
176
258
|
- `HdfPipe`: Pipe network analysis tools
|
177
259
|
- `HdfPump`: Pump station analysis capabilities
|
178
260
|
- `HdfFluvialPluvial`: Fluvial-pluvial boundary analysis
|
179
|
-
- `RasMapper`: RASMapper
|
180
|
-
- `RasToGo`: Go-Consequences integration
|
261
|
+
- `RasMapper`: RASMapper Functions
|
181
262
|
- `HdfPlot` & `HdfResultsPlot`: Specialized plotting utilities
|
182
263
|
|
183
264
|
### Project Organization Diagram
|
184
265
|
|
185
|
-
### Project Organization Diagram
|
186
|
-
|
187
266
|
```
|
188
267
|
ras_commander
|
189
268
|
├── ras_commander
|
@@ -214,24 +293,16 @@ ras_commander
|
|
214
293
|
│ ├── HdfPlot.py
|
215
294
|
│ └── HdfResultsPlot.py
|
216
295
|
├── examples
|
217
|
-
│ ├──
|
218
|
-
│ ├──
|
219
|
-
│ ├──
|
220
|
-
│ ├──
|
221
|
-
│ ├──
|
222
|
-
│ ├──
|
223
|
-
│ ├──
|
224
|
-
│ ├──
|
225
|
-
│ ├──
|
226
|
-
│
|
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
|
296
|
+
│ ├── 00_Using_RasExamples.ipynb
|
297
|
+
│ ├── 01_project_initialization.ipynb
|
298
|
+
│ ├── 02_plan_and_geometry_operations.ipynb
|
299
|
+
│ ├── 03_unsteady_flow_operations.ipynb
|
300
|
+
│ ├── 04_multiple_project_operations.ipynb
|
301
|
+
│ ├── 05_single_plan_execution.ipynb
|
302
|
+
│ ├── 06_executing_plan_sets.ipynb
|
303
|
+
│ ├── 07_sequential_plan_execution.ipynb
|
304
|
+
│ ├── 08_parallel_execution.ipynb
|
305
|
+
│ └── 09_plan_parameter_operations.ipynb
|
235
306
|
├── tests
|
236
307
|
│ └── ... (test files)
|
237
308
|
├── .gitignore
|
@@ -311,7 +382,6 @@ print(runtime_data)
|
|
311
382
|
```
|
312
383
|
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
384
|
|
314
|
-
|
315
385
|
#### Infrastructure Analysis
|
316
386
|
```python
|
317
387
|
from ras_commander import HdfPipe, HdfPump
|
@@ -348,13 +418,33 @@ boundary = HdfFluvialPluvial.calculate_fluvial_pluvial_boundary(
|
|
348
418
|
)
|
349
419
|
```
|
350
420
|
|
351
|
-
##
|
421
|
+
## Examples
|
352
422
|
|
353
|
-
|
423
|
+
Check out the examples in the repository to learn how to use RAS Commander:
|
354
424
|
|
355
|
-
|
425
|
+
### Project Setup
|
426
|
+
- `00_Using_RasExamples.ipynb`: Download and extract HEC-RAS example projects
|
427
|
+
- `01_project_initialization.ipynb`: Initialize HEC-RAS projects and explore their components
|
428
|
+
|
429
|
+
### File Operations
|
430
|
+
- `02_plan_and_geometry_operations.ipynb`: Clone and modify plan and geometry files
|
431
|
+
- `03_unsteady_flow_operations.ipynb`: Extract and modify boundary conditions
|
432
|
+
- `09_plan_parameter_operations.ipynb`: Retrieve and update plan parameters
|
433
|
+
|
434
|
+
### Execution Modes
|
435
|
+
- `05_single_plan_execution.ipynb`: Execute a single plan with specific options
|
436
|
+
- `06_executing_plan_sets.ipynb`: Different ways to specify and execute plan sets
|
437
|
+
- `07_sequential_plan_execution.ipynb`: Run multiple plans in sequence
|
438
|
+
- `08_parallel_execution.ipynb`: Run multiple plans in parallel
|
439
|
+
|
440
|
+
### Advanced Operations
|
441
|
+
- `04_multiple_project_operations.ipynb`: Work with multiple HEC-RAS projects simultaneously
|
356
442
|
|
357
|
-
|
443
|
+
These examples demonstrate practical applications of RAS Commander for automating HEC-RAS workflows, from basic operations to advanced scenarios.
|
444
|
+
|
445
|
+
## Documentation
|
446
|
+
|
447
|
+
For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
|
358
448
|
|
359
449
|
## Future Development
|
360
450
|
|
@@ -365,10 +455,9 @@ The ras-commander library is an ongoing project. Future plans include:
|
|
365
455
|
|
366
456
|
## Related Resources
|
367
457
|
|
368
|
-
- [HEC-Commander Blog](https://github.com/
|
458
|
+
- [HEC-Commander Blog](https://github.com/gpt-cmdr/HEC-Commander/tree/main/Blog)
|
369
459
|
- [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
|
370
|
-
- [ChatGPT Examples for Water Resources Engineers](https://github.com/
|
371
|
-
|
460
|
+
- [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
|
372
461
|
|
373
462
|
## Contributing
|
374
463
|
|
@@ -405,8 +494,7 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
405
494
|
|
406
495
|
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
496
|
|
408
|
-
5. [HEC-Commander Tools](https://github.com/
|
409
|
-
|
497
|
+
5. [HEC-Commander Tools](https://github.com/gpt-cmdr/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
|
410
498
|
|
411
499
|
## Official RAS Commander AI-Generated Songs:
|
412
500
|
|
@@ -416,14 +504,13 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
416
504
|
|
417
505
|
## Other Resources
|
418
506
|
|
419
|
-
Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/
|
507
|
+
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
508
|
Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
|
421
509
|
|
422
510
|
## LICENSE
|
423
511
|
|
424
512
|
This software is released under the MIT license.
|
425
513
|
|
426
|
-
|
427
514
|
## Contact
|
428
515
|
|
429
516
|
For questions, suggestions, or support, please contact:
|
@@ -11,12 +11,11 @@ This repository has several methods of interaction with Large Language Models an
|
|
11
11
|
|
12
12
|
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.
|
13
13
|
|
14
|
-
2. **[Purpose-Built Knowledge Base Summaries](https://github.com/
|
14
|
+
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.
|
15
15
|
|
16
|
-
3. **[Cursor IDE Integration](https://github.com/
|
17
|
-
|
18
|
-
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**
|
16
|
+
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.
|
19
17
|
|
18
|
+
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**
|
20
19
|
|
21
20
|
## Background
|
22
21
|
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.
|
@@ -33,8 +32,6 @@ HEC-RAS Project Management & Execution
|
|
33
32
|
- Progress tracking and logging
|
34
33
|
- Execution error handling and recovery
|
35
34
|
|
36
|
-
|
37
|
-
|
38
35
|
HDF Data Access & Analysis
|
39
36
|
- 2D mesh results processing (depths, velocities, WSE)
|
40
37
|
- Cross-section data extraction
|
@@ -44,7 +41,6 @@ HDF Data Access & Analysis
|
|
44
41
|
- Fluvial-pluvial boundary calculations
|
45
42
|
- Infiltration and precipitation data handling
|
46
43
|
|
47
|
-
|
48
44
|
RAS ASCII File Operations
|
49
45
|
- Plan file creation and modification
|
50
46
|
- Geometry file parsing examples
|
@@ -61,7 +57,6 @@ First, create a virtual environment with conda or venv (ask ChatGPT if you need
|
|
61
57
|
|
62
58
|
In your virtual environment, install ras-commander using pip:
|
63
59
|
```
|
64
|
-
pip install h5py numpy pandas requests tqdm scipy xarray geopandas matplotlib ipython tqdm psutil shapely fiona pathlib rtree rasterstats
|
65
60
|
pip install --upgrade ras-commander
|
66
61
|
```
|
67
62
|
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.
|
@@ -86,21 +81,49 @@ except ImportError:
|
|
86
81
|
```
|
87
82
|
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.
|
88
83
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
84
|
## Quick Start Guide
|
94
85
|
|
95
86
|
```
|
96
87
|
from ras_commander import init_ras_project, RasCmdr, RasPlan
|
97
88
|
```
|
98
89
|
|
99
|
-
### Initialize a project
|
90
|
+
### Initialize a project (single project)
|
100
91
|
```
|
101
92
|
init_ras_project(r"/path/to/project", "6.5")
|
102
93
|
```
|
103
94
|
|
95
|
+
### Initialize a project (multiple projects)
|
96
|
+
```
|
97
|
+
your_ras_project = RasPrj()
|
98
|
+
init_ras_project(r"/path/to/project", "6.5", ras_object=your_ras_project)
|
99
|
+
```
|
100
|
+
|
101
|
+
## Accessing Plan, Unsteady and Boundary Conditions Dataframes
|
102
|
+
Using the default 'ras" object, othewise substitute your_ras_project for muli-project scripts
|
103
|
+
```
|
104
|
+
print("\nPlan Files DataFrame:")
|
105
|
+
ras.plan_df
|
106
|
+
|
107
|
+
print("\nFlow Files DataFrame:")
|
108
|
+
ras.flow_df
|
109
|
+
|
110
|
+
print("\nUnsteady Flow Files DataFrame:")
|
111
|
+
ras.unsteady_df
|
112
|
+
|
113
|
+
print("\nGeometry Files DataFrame:")
|
114
|
+
ras.geom_df
|
115
|
+
|
116
|
+
print("\nHDF Entries DataFrame:")
|
117
|
+
ras.get_hdf_entries()
|
118
|
+
|
119
|
+
print("\nBoundary Conditions DataFrame:")
|
120
|
+
ras.boundaries_df
|
121
|
+
|
122
|
+
```
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
104
127
|
### Execute a single plan
|
105
128
|
```
|
106
129
|
RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
@@ -109,9 +132,9 @@ RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
|
109
132
|
### Execute plans in parallel
|
110
133
|
```
|
111
134
|
results = RasCmdr.compute_parallel(
|
112
|
-
|
135
|
+
plan_number=["01", "02"],
|
113
136
|
max_workers=2,
|
114
|
-
|
137
|
+
num_cores=2,
|
115
138
|
dest_folder=r"/path/to/results",
|
116
139
|
overwrite_dest=True
|
117
140
|
)
|
@@ -122,7 +145,66 @@ results = RasCmdr.compute_parallel(
|
|
122
145
|
RasPlan.set_geom("01", "02")
|
123
146
|
```
|
124
147
|
|
125
|
-
|
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 = RasPrj()
|
189
|
+
init_ras_project(path1, "6.6", ras_object=project1)
|
190
|
+
project2 = RasPrj()
|
191
|
+
init_ras_project(path2, "6.6", ras_object=project2)
|
192
|
+
|
193
|
+
# Perform operations on each project
|
194
|
+
RasCmdr.compute_plan("01", ras_object=project1, dest_folder=folder1)
|
195
|
+
RasCmdr.compute_plan("01", ras_object=project2, dest_folder=folder2)
|
196
|
+
|
197
|
+
# Compare results between projects
|
198
|
+
print(f"Project 1: {project1.project_name}")
|
199
|
+
print(f"Project 2: {project2.project_name}")
|
200
|
+
|
201
|
+
# Always specify the ras_object parameter when working with multiple projects
|
202
|
+
# to avoid confusion with the global 'ras' object
|
203
|
+
```
|
204
|
+
|
205
|
+
This is useful for comparing different river systems, running scenario analyses across multiple watersheds, or managing a suite of related models.
|
206
|
+
|
207
|
+
#### Core HEC-RAS Automation Classes
|
126
208
|
|
127
209
|
- `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
|
128
210
|
- `RasCmdr`: Handles execution of HEC-RAS simulations
|
@@ -132,7 +214,7 @@ RasPlan.set_geom("01", "02")
|
|
132
214
|
- `RasUtils`: Contains utility functions for file operations and data management
|
133
215
|
- `RasExamples`: Manages and loads HEC-RAS example projects
|
134
216
|
|
135
|
-
####
|
217
|
+
#### HDF Data Access Classes
|
136
218
|
- `HdfBase`: Core functionality for HDF file operations
|
137
219
|
- `HdfBndry`: Enhanced boundary condition handling
|
138
220
|
- `HdfMesh`: Comprehensive mesh data management
|
@@ -144,14 +226,11 @@ RasPlan.set_geom("01", "02")
|
|
144
226
|
- `HdfPipe`: Pipe network analysis tools
|
145
227
|
- `HdfPump`: Pump station analysis capabilities
|
146
228
|
- `HdfFluvialPluvial`: Fluvial-pluvial boundary analysis
|
147
|
-
- `RasMapper`: RASMapper
|
148
|
-
- `RasToGo`: Go-Consequences integration
|
229
|
+
- `RasMapper`: RASMapper Functions
|
149
230
|
- `HdfPlot` & `HdfResultsPlot`: Specialized plotting utilities
|
150
231
|
|
151
232
|
### Project Organization Diagram
|
152
233
|
|
153
|
-
### Project Organization Diagram
|
154
|
-
|
155
234
|
```
|
156
235
|
ras_commander
|
157
236
|
├── ras_commander
|
@@ -182,24 +261,16 @@ ras_commander
|
|
182
261
|
│ ├── HdfPlot.py
|
183
262
|
│ └── HdfResultsPlot.py
|
184
263
|
├── examples
|
185
|
-
│ ├──
|
186
|
-
│ ├──
|
187
|
-
│ ├──
|
188
|
-
│ ├──
|
189
|
-
│ ├──
|
190
|
-
│ ├──
|
191
|
-
│ ├──
|
192
|
-
│ ├──
|
193
|
-
│ ├──
|
194
|
-
│
|
195
|
-
│ ├── 11_Using_RasExamples.ipynb
|
196
|
-
│ ├── 12_plan_set_execution.py
|
197
|
-
│ ├── 13_multiple_project_operations.py
|
198
|
-
│ ├── 14_Core_Sensitivity.ipynb
|
199
|
-
│ ├── 15_plan_key_operations.py
|
200
|
-
│ ├── 16_scanning_ras_project_info.py
|
201
|
-
│ ├── 17_parallel_execution_ble.py
|
202
|
-
│ └── HEC_RAS_2D_HDF_Analysis.ipynb
|
264
|
+
│ ├── 00_Using_RasExamples.ipynb
|
265
|
+
│ ├── 01_project_initialization.ipynb
|
266
|
+
│ ├── 02_plan_and_geometry_operations.ipynb
|
267
|
+
│ ├── 03_unsteady_flow_operations.ipynb
|
268
|
+
│ ├── 04_multiple_project_operations.ipynb
|
269
|
+
│ ├── 05_single_plan_execution.ipynb
|
270
|
+
│ ├── 06_executing_plan_sets.ipynb
|
271
|
+
│ ├── 07_sequential_plan_execution.ipynb
|
272
|
+
│ ├── 08_parallel_execution.ipynb
|
273
|
+
│ └── 09_plan_parameter_operations.ipynb
|
203
274
|
├── tests
|
204
275
|
│ └── ... (test files)
|
205
276
|
├── .gitignore
|
@@ -279,7 +350,6 @@ print(runtime_data)
|
|
279
350
|
```
|
280
351
|
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.
|
281
352
|
|
282
|
-
|
283
353
|
#### Infrastructure Analysis
|
284
354
|
```python
|
285
355
|
from ras_commander import HdfPipe, HdfPump
|
@@ -316,13 +386,33 @@ boundary = HdfFluvialPluvial.calculate_fluvial_pluvial_boundary(
|
|
316
386
|
)
|
317
387
|
```
|
318
388
|
|
319
|
-
##
|
389
|
+
## Examples
|
320
390
|
|
321
|
-
|
391
|
+
Check out the examples in the repository to learn how to use RAS Commander:
|
322
392
|
|
323
|
-
|
393
|
+
### Project Setup
|
394
|
+
- `00_Using_RasExamples.ipynb`: Download and extract HEC-RAS example projects
|
395
|
+
- `01_project_initialization.ipynb`: Initialize HEC-RAS projects and explore their components
|
396
|
+
|
397
|
+
### File Operations
|
398
|
+
- `02_plan_and_geometry_operations.ipynb`: Clone and modify plan and geometry files
|
399
|
+
- `03_unsteady_flow_operations.ipynb`: Extract and modify boundary conditions
|
400
|
+
- `09_plan_parameter_operations.ipynb`: Retrieve and update plan parameters
|
401
|
+
|
402
|
+
### Execution Modes
|
403
|
+
- `05_single_plan_execution.ipynb`: Execute a single plan with specific options
|
404
|
+
- `06_executing_plan_sets.ipynb`: Different ways to specify and execute plan sets
|
405
|
+
- `07_sequential_plan_execution.ipynb`: Run multiple plans in sequence
|
406
|
+
- `08_parallel_execution.ipynb`: Run multiple plans in parallel
|
407
|
+
|
408
|
+
### Advanced Operations
|
409
|
+
- `04_multiple_project_operations.ipynb`: Work with multiple HEC-RAS projects simultaneously
|
324
410
|
|
325
|
-
|
411
|
+
These examples demonstrate practical applications of RAS Commander for automating HEC-RAS workflows, from basic operations to advanced scenarios.
|
412
|
+
|
413
|
+
## Documentation
|
414
|
+
|
415
|
+
For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
|
326
416
|
|
327
417
|
## Future Development
|
328
418
|
|
@@ -333,10 +423,9 @@ The ras-commander library is an ongoing project. Future plans include:
|
|
333
423
|
|
334
424
|
## Related Resources
|
335
425
|
|
336
|
-
- [HEC-Commander Blog](https://github.com/
|
426
|
+
- [HEC-Commander Blog](https://github.com/gpt-cmdr/HEC-Commander/tree/main/Blog)
|
337
427
|
- [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
|
338
|
-
- [ChatGPT Examples for Water Resources Engineers](https://github.com/
|
339
|
-
|
428
|
+
- [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
|
340
429
|
|
341
430
|
## Contributing
|
342
431
|
|
@@ -373,8 +462,7 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
373
462
|
|
374
463
|
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.
|
375
464
|
|
376
|
-
5. [HEC-Commander Tools](https://github.com/
|
377
|
-
|
465
|
+
5. [HEC-Commander Tools](https://github.com/gpt-cmdr/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
|
378
466
|
|
379
467
|
## Official RAS Commander AI-Generated Songs:
|
380
468
|
|
@@ -384,15 +472,14 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
384
472
|
|
385
473
|
## Other Resources
|
386
474
|
|
387
|
-
Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/
|
475
|
+
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)
|
388
476
|
Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
|
389
477
|
|
390
478
|
## LICENSE
|
391
479
|
|
392
480
|
This software is released under the MIT license.
|
393
481
|
|
394
|
-
|
395
482
|
## Contact
|
396
483
|
|
397
484
|
For questions, suggestions, or support, please contact:
|
398
|
-
William Katzenmeyer, P.E., C.F.M. - heccommander@gmail.com
|
485
|
+
William Katzenmeyer, P.E., C.F.M. - heccommander@gmail.com
|
@@ -85,20 +85,24 @@ def standardize_input(file_type: str = 'plan_hdf'):
|
|
85
85
|
if Path(hdf_input).is_file():
|
86
86
|
hdf_path = Path(hdf_input)
|
87
87
|
# Check if it's a number (with or without 'p' prefix)
|
88
|
-
elif hdf_input.isdigit() or (len(hdf_input)
|
88
|
+
elif hdf_input.isdigit() or (len(hdf_input) > 1 and hdf_input[0] == 'p' and hdf_input[1:].isdigit()):
|
89
89
|
try:
|
90
90
|
ras_obj.check_initialized()
|
91
91
|
except Exception as e:
|
92
92
|
raise ValueError(f"RAS object is not initialized: {str(e)}")
|
93
93
|
|
94
|
-
|
94
|
+
# Extract the numeric part and convert to integer for comparison
|
95
|
+
number_str = hdf_input if hdf_input.isdigit() else hdf_input[1:]
|
96
|
+
number_int = int(number_str)
|
95
97
|
|
96
98
|
if file_type == 'plan_hdf':
|
97
|
-
|
99
|
+
# Convert plan_number column to integers for comparison
|
100
|
+
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].astype(int) == number_int]
|
98
101
|
if not plan_info.empty:
|
99
102
|
hdf_path = Path(plan_info.iloc[0]['HDF_Results_Path'])
|
100
103
|
elif file_type == 'geom_hdf':
|
101
|
-
|
104
|
+
# Convert geom_number column to integers for comparison
|
105
|
+
geom_info = ras_obj.geom_df[ras_obj.geom_df['geom_number'].astype(int) == number_int]
|
102
106
|
if not geom_info.empty:
|
103
107
|
hdf_path = Path(geom_info.iloc[0]['HDF_Path'])
|
104
108
|
else:
|
@@ -110,14 +114,16 @@ def standardize_input(file_type: str = 'plan_hdf'):
|
|
110
114
|
except Exception as e:
|
111
115
|
raise ValueError(f"RAS object is not initialized: {str(e)}")
|
112
116
|
|
113
|
-
|
117
|
+
number_int = hdf_input
|
114
118
|
|
115
119
|
if file_type == 'plan_hdf':
|
116
|
-
|
120
|
+
# Convert plan_number column to integers for comparison
|
121
|
+
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].astype(int) == number_int]
|
117
122
|
if not plan_info.empty:
|
118
123
|
hdf_path = Path(plan_info.iloc[0]['HDF_Results_Path'])
|
119
124
|
elif file_type == 'geom_hdf':
|
120
|
-
|
125
|
+
# Convert geom_number column to integers for comparison
|
126
|
+
geom_info = ras_obj.geom_df[ras_obj.geom_df['geom_number'].astype(int) == number_int]
|
121
127
|
if not geom_info.empty:
|
122
128
|
hdf_path = Path(geom_info.iloc[0]['HDF_Path'])
|
123
129
|
else:
|
@@ -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
|
-
|
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
|
-
|
860
|
-
|
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.
|
3
|
+
Version: 0.61.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/
|
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/
|
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,21 +113,49 @@ 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
|
```
|
128
119
|
from ras_commander import init_ras_project, RasCmdr, RasPlan
|
129
120
|
```
|
130
121
|
|
131
|
-
### Initialize a project
|
122
|
+
### Initialize a project (single project)
|
132
123
|
```
|
133
124
|
init_ras_project(r"/path/to/project", "6.5")
|
134
125
|
```
|
135
126
|
|
127
|
+
### Initialize a project (multiple projects)
|
128
|
+
```
|
129
|
+
your_ras_project = RasPrj()
|
130
|
+
init_ras_project(r"/path/to/project", "6.5", ras_object=your_ras_project)
|
131
|
+
```
|
132
|
+
|
133
|
+
## Accessing Plan, Unsteady and Boundary Conditions Dataframes
|
134
|
+
Using the default 'ras" object, othewise substitute your_ras_project for muli-project scripts
|
135
|
+
```
|
136
|
+
print("\nPlan Files DataFrame:")
|
137
|
+
ras.plan_df
|
138
|
+
|
139
|
+
print("\nFlow Files DataFrame:")
|
140
|
+
ras.flow_df
|
141
|
+
|
142
|
+
print("\nUnsteady Flow Files DataFrame:")
|
143
|
+
ras.unsteady_df
|
144
|
+
|
145
|
+
print("\nGeometry Files DataFrame:")
|
146
|
+
ras.geom_df
|
147
|
+
|
148
|
+
print("\nHDF Entries DataFrame:")
|
149
|
+
ras.get_hdf_entries()
|
150
|
+
|
151
|
+
print("\nBoundary Conditions DataFrame:")
|
152
|
+
ras.boundaries_df
|
153
|
+
|
154
|
+
```
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
136
159
|
### Execute a single plan
|
137
160
|
```
|
138
161
|
RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
@@ -141,9 +164,9 @@ RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
|
141
164
|
### Execute plans in parallel
|
142
165
|
```
|
143
166
|
results = RasCmdr.compute_parallel(
|
144
|
-
|
167
|
+
plan_number=["01", "02"],
|
145
168
|
max_workers=2,
|
146
|
-
|
169
|
+
num_cores=2,
|
147
170
|
dest_folder=r"/path/to/results",
|
148
171
|
overwrite_dest=True
|
149
172
|
)
|
@@ -154,7 +177,66 @@ results = RasCmdr.compute_parallel(
|
|
154
177
|
RasPlan.set_geom("01", "02")
|
155
178
|
```
|
156
179
|
|
157
|
-
|
180
|
+
### Execution Modes
|
181
|
+
|
182
|
+
RAS Commander provides three methods for executing HEC-RAS plans:
|
183
|
+
|
184
|
+
#### Single Plan Execution
|
185
|
+
```python
|
186
|
+
# Execute a single plan
|
187
|
+
success = RasCmdr.compute_plan("01", dest_folder=r"/path/to/results")
|
188
|
+
print(f"Plan execution {'successful' if success else 'failed'}")
|
189
|
+
```
|
190
|
+
|
191
|
+
#### Sequential Execution of Multiple Plans
|
192
|
+
```python
|
193
|
+
# Execute multiple plans in sequence in a test folder
|
194
|
+
results = RasCmdr.compute_test_mode(
|
195
|
+
plan_number=["01", "02", "03"],
|
196
|
+
dest_folder_suffix="[Test]"
|
197
|
+
)
|
198
|
+
for plan, success in results.items():
|
199
|
+
print(f"Plan {plan}: {'Successful' if success else 'Failed'}")
|
200
|
+
```
|
201
|
+
|
202
|
+
#### Parallel Execution of Multiple Plans
|
203
|
+
```python
|
204
|
+
# Execute multiple plans concurrently
|
205
|
+
results = RasCmdr.compute_parallel(
|
206
|
+
plan_number=["01", "02", "03"],
|
207
|
+
max_workers=3,
|
208
|
+
num_cores=2
|
209
|
+
)
|
210
|
+
for plan, success in results.items():
|
211
|
+
print(f"Plan {plan}: {'Successful' if success else 'Failed'}")
|
212
|
+
```
|
213
|
+
|
214
|
+
### Working with Multiple Projects
|
215
|
+
|
216
|
+
RAS Commander allows working with multiple HEC-RAS projects simultaneously:
|
217
|
+
|
218
|
+
```python
|
219
|
+
# Initialize multiple projects
|
220
|
+
project1 = RasPrj()
|
221
|
+
init_ras_project(path1, "6.6", ras_object=project1)
|
222
|
+
project2 = RasPrj()
|
223
|
+
init_ras_project(path2, "6.6", ras_object=project2)
|
224
|
+
|
225
|
+
# Perform operations on each project
|
226
|
+
RasCmdr.compute_plan("01", ras_object=project1, dest_folder=folder1)
|
227
|
+
RasCmdr.compute_plan("01", ras_object=project2, dest_folder=folder2)
|
228
|
+
|
229
|
+
# Compare results between projects
|
230
|
+
print(f"Project 1: {project1.project_name}")
|
231
|
+
print(f"Project 2: {project2.project_name}")
|
232
|
+
|
233
|
+
# Always specify the ras_object parameter when working with multiple projects
|
234
|
+
# to avoid confusion with the global 'ras' object
|
235
|
+
```
|
236
|
+
|
237
|
+
This is useful for comparing different river systems, running scenario analyses across multiple watersheds, or managing a suite of related models.
|
238
|
+
|
239
|
+
#### Core HEC-RAS Automation Classes
|
158
240
|
|
159
241
|
- `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
|
160
242
|
- `RasCmdr`: Handles execution of HEC-RAS simulations
|
@@ -164,7 +246,7 @@ RasPlan.set_geom("01", "02")
|
|
164
246
|
- `RasUtils`: Contains utility functions for file operations and data management
|
165
247
|
- `RasExamples`: Manages and loads HEC-RAS example projects
|
166
248
|
|
167
|
-
####
|
249
|
+
#### HDF Data Access Classes
|
168
250
|
- `HdfBase`: Core functionality for HDF file operations
|
169
251
|
- `HdfBndry`: Enhanced boundary condition handling
|
170
252
|
- `HdfMesh`: Comprehensive mesh data management
|
@@ -176,14 +258,11 @@ RasPlan.set_geom("01", "02")
|
|
176
258
|
- `HdfPipe`: Pipe network analysis tools
|
177
259
|
- `HdfPump`: Pump station analysis capabilities
|
178
260
|
- `HdfFluvialPluvial`: Fluvial-pluvial boundary analysis
|
179
|
-
- `RasMapper`: RASMapper
|
180
|
-
- `RasToGo`: Go-Consequences integration
|
261
|
+
- `RasMapper`: RASMapper Functions
|
181
262
|
- `HdfPlot` & `HdfResultsPlot`: Specialized plotting utilities
|
182
263
|
|
183
264
|
### Project Organization Diagram
|
184
265
|
|
185
|
-
### Project Organization Diagram
|
186
|
-
|
187
266
|
```
|
188
267
|
ras_commander
|
189
268
|
├── ras_commander
|
@@ -214,24 +293,16 @@ ras_commander
|
|
214
293
|
│ ├── HdfPlot.py
|
215
294
|
│ └── HdfResultsPlot.py
|
216
295
|
├── examples
|
217
|
-
│ ├──
|
218
|
-
│ ├──
|
219
|
-
│ ├──
|
220
|
-
│ ├──
|
221
|
-
│ ├──
|
222
|
-
│ ├──
|
223
|
-
│ ├──
|
224
|
-
│ ├──
|
225
|
-
│ ├──
|
226
|
-
│
|
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
|
296
|
+
│ ├── 00_Using_RasExamples.ipynb
|
297
|
+
│ ├── 01_project_initialization.ipynb
|
298
|
+
│ ├── 02_plan_and_geometry_operations.ipynb
|
299
|
+
│ ├── 03_unsteady_flow_operations.ipynb
|
300
|
+
│ ├── 04_multiple_project_operations.ipynb
|
301
|
+
│ ├── 05_single_plan_execution.ipynb
|
302
|
+
│ ├── 06_executing_plan_sets.ipynb
|
303
|
+
│ ├── 07_sequential_plan_execution.ipynb
|
304
|
+
│ ├── 08_parallel_execution.ipynb
|
305
|
+
│ └── 09_plan_parameter_operations.ipynb
|
235
306
|
├── tests
|
236
307
|
│ └── ... (test files)
|
237
308
|
├── .gitignore
|
@@ -311,7 +382,6 @@ print(runtime_data)
|
|
311
382
|
```
|
312
383
|
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
384
|
|
314
|
-
|
315
385
|
#### Infrastructure Analysis
|
316
386
|
```python
|
317
387
|
from ras_commander import HdfPipe, HdfPump
|
@@ -348,13 +418,33 @@ boundary = HdfFluvialPluvial.calculate_fluvial_pluvial_boundary(
|
|
348
418
|
)
|
349
419
|
```
|
350
420
|
|
351
|
-
##
|
421
|
+
## Examples
|
352
422
|
|
353
|
-
|
423
|
+
Check out the examples in the repository to learn how to use RAS Commander:
|
354
424
|
|
355
|
-
|
425
|
+
### Project Setup
|
426
|
+
- `00_Using_RasExamples.ipynb`: Download and extract HEC-RAS example projects
|
427
|
+
- `01_project_initialization.ipynb`: Initialize HEC-RAS projects and explore their components
|
428
|
+
|
429
|
+
### File Operations
|
430
|
+
- `02_plan_and_geometry_operations.ipynb`: Clone and modify plan and geometry files
|
431
|
+
- `03_unsteady_flow_operations.ipynb`: Extract and modify boundary conditions
|
432
|
+
- `09_plan_parameter_operations.ipynb`: Retrieve and update plan parameters
|
433
|
+
|
434
|
+
### Execution Modes
|
435
|
+
- `05_single_plan_execution.ipynb`: Execute a single plan with specific options
|
436
|
+
- `06_executing_plan_sets.ipynb`: Different ways to specify and execute plan sets
|
437
|
+
- `07_sequential_plan_execution.ipynb`: Run multiple plans in sequence
|
438
|
+
- `08_parallel_execution.ipynb`: Run multiple plans in parallel
|
439
|
+
|
440
|
+
### Advanced Operations
|
441
|
+
- `04_multiple_project_operations.ipynb`: Work with multiple HEC-RAS projects simultaneously
|
356
442
|
|
357
|
-
|
443
|
+
These examples demonstrate practical applications of RAS Commander for automating HEC-RAS workflows, from basic operations to advanced scenarios.
|
444
|
+
|
445
|
+
## Documentation
|
446
|
+
|
447
|
+
For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
|
358
448
|
|
359
449
|
## Future Development
|
360
450
|
|
@@ -365,10 +455,9 @@ The ras-commander library is an ongoing project. Future plans include:
|
|
365
455
|
|
366
456
|
## Related Resources
|
367
457
|
|
368
|
-
- [HEC-Commander Blog](https://github.com/
|
458
|
+
- [HEC-Commander Blog](https://github.com/gpt-cmdr/HEC-Commander/tree/main/Blog)
|
369
459
|
- [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
|
370
|
-
- [ChatGPT Examples for Water Resources Engineers](https://github.com/
|
371
|
-
|
460
|
+
- [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
|
372
461
|
|
373
462
|
## Contributing
|
374
463
|
|
@@ -405,8 +494,7 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
405
494
|
|
406
495
|
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
496
|
|
408
|
-
5. [HEC-Commander Tools](https://github.com/
|
409
|
-
|
497
|
+
5. [HEC-Commander Tools](https://github.com/gpt-cmdr/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
|
410
498
|
|
411
499
|
## Official RAS Commander AI-Generated Songs:
|
412
500
|
|
@@ -416,14 +504,13 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
416
504
|
|
417
505
|
## Other Resources
|
418
506
|
|
419
|
-
Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/
|
507
|
+
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
508
|
Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
|
421
509
|
|
422
510
|
## LICENSE
|
423
511
|
|
424
512
|
This software is released under the MIT license.
|
425
513
|
|
426
|
-
|
427
514
|
## Contact
|
428
515
|
|
429
516
|
For questions, suggestions, or support, please contact:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|