ras-commander 0.59.0__tar.gz → 0.64.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.59.0/ras_commander.egg-info → ras_commander-0.64.0}/PKG-INFO +79 -45
- {ras_commander-0.59.0 → ras_commander-0.64.0}/README.md +79 -45
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/Decorators.py +13 -7
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfBndry.py +91 -7
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfInfiltration.py +7 -1
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfPlan.py +44 -5
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfResultsMesh.py +24 -14
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfResultsPlan.py +380 -364
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfStruc.py +30 -8
- ras_commander-0.64.0/ras_commander/RasMapper.py +24 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasPlan.py +218 -5
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasPrj.py +146 -41
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/__init__.py +3 -7
- {ras_commander-0.59.0 → ras_commander-0.64.0/ras_commander.egg-info}/PKG-INFO +79 -45
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander.egg-info/SOURCES.txt +0 -2
- {ras_commander-0.59.0 → ras_commander-0.64.0}/setup.py +1 -1
- ras_commander-0.59.0/ras_commander/RasGpt.py +0 -27
- ras_commander-0.59.0/ras_commander/RasMapper.py +0 -105
- ras_commander-0.59.0/ras_commander/RasToGo.py +0 -37
- {ras_commander-0.59.0 → ras_commander-0.64.0}/LICENSE +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/pyproject.toml +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfBase.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfFluvialPluvial.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfMesh.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfPipe.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfPlot.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfPump.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfResultsPlot.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfResultsXsec.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfUtils.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/HdfXsec.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/LoggingConfig.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasCmdr.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasExamples.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasGeo.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasUnsteady.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander/RasUtils.py +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander.egg-info/dependency_links.txt +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander.egg-info/requires.txt +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.0}/ras_commander.egg-info/top_level.txt +0 -0
- {ras_commander-0.59.0 → ras_commander-0.64.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.64.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.
|
@@ -35,22 +35,25 @@ Dynamic: summary
|
|
35
35
|
RAS Commander is a Python library for automating HEC-RAS operations, providing a set of tools to interact with HEC-RAS project files, execute simulations, and manage project data. This library was initially conceptualized in the Australian Water School course "AI Tools for Modelling Innovation", and subsequently expanded to cover the basic functionality of the HECRASController COM32 interface using open-source python libraries. This library uses a Test Driven Development strategy, leveraging the publicly-available HEC-RAS Example projects to create repeatable demonstration examples. The "Commmander" moniker is inspired by the "Command Line is All You Need" approach to HEC-RAS automation that was first implemented in the HEC-Commander Tools repository.
|
36
36
|
|
37
37
|
## Repository Author:
|
38
|
-
|
38
|
+
[William Katzenmeyer, P.E., C.F.M.](https://engineeringwithllms.info)
|
39
|
+
-----
|
39
40
|
|
40
|
-
## Don't Ask Me, Ask GPT!
|
41
|
+
## Don't Ask Me, Ask GPT!
|
41
42
|
|
42
43
|
This repository has several methods of interaction with Large Language Models and LLM-Assisted Coding built right in:
|
43
44
|
|
44
|
-
1. **[
|
45
|
+
1. **[Purpose-Built Knowledge Base Summaries](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/llm_knowledge_bases)**: Up-to-date compilations of the documentation and codebase for use with large language models like Claude, ChatGPT, Gemini or Grok. 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.
|
45
46
|
|
46
|
-
2. **[
|
47
|
+
2. **[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.
|
47
48
|
|
48
|
-
3. **[
|
49
|
+
3. **[RAS-Commander Library Assistant](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/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 Claude 3.7, OpenAI's o1 and o3-mini, and Deepseek V3 and R1 models using US-based Together.ai**
|
50
|
+
|
51
|
+
|
52
|
+
4. **[RAS Commander Library Assistant on ChatGPT](https://chatgpt.com/g/g-TZRPR3oAO-ras-commander-library-assistant)**: A specialized ChatGPT "GPT" 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. _NOTE: GPT's are still quite limited by OpenAI's GPT frameworks and may not be useful for long conversations. Code interpreter cannot run HEC-RAS but can open and view smaller HDF files and projects for demonstration purposes_
|
49
53
|
|
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**
|
51
54
|
|
52
55
|
## Background
|
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.
|
56
|
+
The ras-commander library emerged from the initial test-bed of AI-driven coding represented by the [HEC-Commander tools](https://github.com/gpt-cmdr/HEC-Commander) Python notebooks. These notebooks served as a proof of concept, demonstrating the value proposition of automating HEC-RAS operations. In 2024, I taught a series of progressively more complex webinars demonstrating how to use simple prompting, example projects and natural language instruction to effectively code HEC-RAS automation workflows, culminating in a 6 hour course. The library published for utilization in that course, [awsrastools](https://github.com/gpt-cmdr/awsrastools) served as a foundation of examples which were iteratively extended into the full RAS-Commander library. Unlike the original notebook by the same name, this library is not focused on parallel execution across multiple machines. Instead, it is focused on providing a general-purpose python API for interacting with HEC-RAS projects, and building an AI-friendly library that will allow new users to quickly scaffold their own workflows into a python script. Example notebooks are provided, but the intention is to empower engineers, software developers, GIS personnel and data analysts to more easily access and interact with HEC-RAS data in a python environment. Also, by publishing these examples publicly, with complete working code examples and LLM optimization, future users can readily rewrite they key functions of the library for inclusion in into their own preferred libraries, languages or return formats.
|
54
57
|
|
55
58
|
## Features
|
56
59
|
|
@@ -92,7 +95,13 @@ In your virtual environment, install ras-commander using pip:
|
|
92
95
|
pip install --upgrade ras-commander
|
93
96
|
```
|
94
97
|
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.
|
95
|
-
|
98
|
+
|
99
|
+
Dependencies can also be manually installed:
|
100
|
+
```
|
101
|
+
pip install h5py numpy pandas requests tqdm scipy xarray geopandas matplotlib shapely pathlib rasterstats rtree
|
102
|
+
```
|
103
|
+
|
104
|
+
|
96
105
|
#### Work in a Local Copy
|
97
106
|
|
98
107
|
If you want to make revisions and work actively in your local version of ras-commander, just skip the pip install rascommander step above and clone a fork of the repo to your local machine using Git (ask ChatGPT if you need help). Most of the notebooks and examples in this repo have a code segment similar to the one below, that works as long as the script is located in a first-level subfolder of the ras-commander repository:
|
@@ -119,11 +128,46 @@ It is highly suggested to fork this repository before going this route, and usin
|
|
119
128
|
from ras_commander import init_ras_project, RasCmdr, RasPlan
|
120
129
|
```
|
121
130
|
|
122
|
-
### Initialize a project
|
131
|
+
### Initialize a project (single project)
|
123
132
|
```
|
124
133
|
init_ras_project(r"/path/to/project", "6.5")
|
125
134
|
```
|
126
135
|
|
136
|
+
### Initialize a project (multiple projects)
|
137
|
+
```
|
138
|
+
your_ras_project = RasPrj()
|
139
|
+
init_ras_project(r"/path/to/project", "6.5", ras_object=your_ras_project)
|
140
|
+
```
|
141
|
+
|
142
|
+
## Accessing Plan, Unsteady and Boundary Conditions Dataframes
|
143
|
+
Using the default 'ras" object, othewise substitute your_ras_project for muli-project scripts
|
144
|
+
```
|
145
|
+
print("\nPlan Files DataFrame:")
|
146
|
+
ras.plan_df
|
147
|
+
```
|
148
|
+
```
|
149
|
+
print("\nFlow Files DataFrame:")
|
150
|
+
ras.flow_df
|
151
|
+
```
|
152
|
+
```
|
153
|
+
print("\nUnsteady Flow Files DataFrame:")
|
154
|
+
ras.unsteady_df
|
155
|
+
```
|
156
|
+
```
|
157
|
+
print("\nGeometry Files DataFrame:")
|
158
|
+
ras.geom_df
|
159
|
+
```
|
160
|
+
```
|
161
|
+
print("\nBoundary Conditions DataFrame:")
|
162
|
+
ras.boundaries_df
|
163
|
+
```
|
164
|
+
```
|
165
|
+
print("\nHDF Entries DataFrame:")
|
166
|
+
ras.get_hdf_entries()
|
167
|
+
```
|
168
|
+
|
169
|
+
|
170
|
+
|
127
171
|
### Execute a single plan
|
128
172
|
```
|
129
173
|
RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
@@ -185,8 +229,10 @@ RAS Commander allows working with multiple HEC-RAS projects simultaneously:
|
|
185
229
|
|
186
230
|
```python
|
187
231
|
# Initialize multiple projects
|
188
|
-
project1 =
|
189
|
-
|
232
|
+
project1 = RasPrj()
|
233
|
+
init_ras_project(path1, "6.6", ras_object=project1)
|
234
|
+
project2 = RasPrj()
|
235
|
+
init_ras_project(path2, "6.6", ras_object=project2)
|
190
236
|
|
191
237
|
# Perform operations on each project
|
192
238
|
RasCmdr.compute_plan("01", ras_object=project1, dest_folder=folder1)
|
@@ -202,7 +248,7 @@ print(f"Project 2: {project2.project_name}")
|
|
202
248
|
|
203
249
|
This is useful for comparing different river systems, running scenario analyses across multiple watersheds, or managing a suite of related models.
|
204
250
|
|
205
|
-
####
|
251
|
+
#### Core HEC-RAS Automation Classes
|
206
252
|
|
207
253
|
- `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
|
208
254
|
- `RasCmdr`: Handles execution of HEC-RAS simulations
|
@@ -212,7 +258,7 @@ This is useful for comparing different river systems, running scenario analyses
|
|
212
258
|
- `RasUtils`: Contains utility functions for file operations and data management
|
213
259
|
- `RasExamples`: Manages and loads HEC-RAS example projects
|
214
260
|
|
215
|
-
####
|
261
|
+
#### HDF Data Access Classes
|
216
262
|
- `HdfBase`: Core functionality for HDF file operations
|
217
263
|
- `HdfBndry`: Enhanced boundary condition handling
|
218
264
|
- `HdfMesh`: Comprehensive mesh data management
|
@@ -224,14 +270,18 @@ This is useful for comparing different river systems, running scenario analyses
|
|
224
270
|
- `HdfPipe`: Pipe network analysis tools
|
225
271
|
- `HdfPump`: Pump station analysis capabilities
|
226
272
|
- `HdfFluvialPluvial`: Fluvial-pluvial boundary analysis
|
227
|
-
- `RasMapper`: RASMapper
|
228
|
-
- `RasToGo`: Go-Consequences integration
|
273
|
+
- `RasMapper`: RASMapper Functions
|
229
274
|
- `HdfPlot` & `HdfResultsPlot`: Specialized plotting utilities
|
230
275
|
|
231
276
|
### Project Organization Diagram
|
232
277
|
|
233
278
|
```
|
234
279
|
ras_commander
|
280
|
+
├── ai_tools
|
281
|
+
│ ├── [AI Knowledge Bases](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/llm_knowledge_bases)
|
282
|
+
│ └── [Library Assistant](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/library_asssistant)
|
283
|
+
├── examples
|
284
|
+
│ └── [Examples Notebooks](https://github.com/gpt-cmdr/ras-commander/tree/main/ras_commander)
|
235
285
|
├── ras_commander
|
236
286
|
│ ├── __init__.py
|
237
287
|
│ ├── _version.py
|
@@ -244,8 +294,6 @@ ras_commander
|
|
244
294
|
│ ├── RasPrj.py
|
245
295
|
│ ├── RasUnsteady.py
|
246
296
|
│ ├── RasUtils.py
|
247
|
-
│ ├── RasToGo.py
|
248
|
-
│ ├── RasGpt.py
|
249
297
|
│ ├── HdfBase.py
|
250
298
|
│ ├── HdfBndry.py
|
251
299
|
│ ├── HdfMesh.py
|
@@ -259,28 +307,13 @@ ras_commander
|
|
259
307
|
│ ├── HdfFluvialPluvial.py
|
260
308
|
│ ├── HdfPlot.py
|
261
309
|
│ └── HdfResultsPlot.py
|
262
|
-
├── examples
|
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
|
273
|
-
├── tests
|
274
|
-
│ └── ... (test files)
|
275
310
|
├── .gitignore
|
276
311
|
├── LICENSE
|
277
312
|
├── README.md
|
278
313
|
├── STYLE_GUIDE.md
|
279
314
|
├── Comprehensive_Library_Guide.md
|
280
315
|
├── pyproject.toml
|
281
|
-
├── setup.cfg
|
282
316
|
├── setup.py
|
283
|
-
└── requirements.txt
|
284
317
|
```
|
285
318
|
|
286
319
|
### Accessing HEC Examples through RasExamples
|
@@ -302,6 +335,8 @@ projects = ras_examples.list_projects("Steady Flow")
|
|
302
335
|
extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
|
303
336
|
```
|
304
337
|
|
338
|
+
The RasExamples class is used to provide an alternative to traditional unit testing, with example notebooks doubling as tests and in-context examples for the end user. This increases interpretability by LLM's, reducing hallucinations.
|
339
|
+
|
305
340
|
### RasPrj
|
306
341
|
|
307
342
|
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.
|
@@ -426,18 +461,11 @@ The ras-commander library is an ongoing project. Future plans include:
|
|
426
461
|
- [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
|
427
462
|
- [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
|
428
463
|
|
429
|
-
## Contributing
|
430
|
-
|
431
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
432
464
|
|
433
465
|
## Style Guide
|
434
466
|
|
435
467
|
This project follows a specific style guide to maintain consistency across the codebase. Please refer to the [Style Guide](STYLE_GUIDE.md) for details on coding conventions, documentation standards, and best practices.
|
436
468
|
|
437
|
-
## License
|
438
|
-
|
439
|
-
ras-commander is released under the MIT License. See the license file for details.
|
440
|
-
|
441
469
|
## Acknowledgments
|
442
470
|
|
443
471
|
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.
|
@@ -455,7 +483,7 @@ Additionally, we would like to acknowledge the following notable contributions a
|
|
455
483
|
Xiaofeng Liu, Ph.D., P.E., Associate Professor, Department of Civil and Environmental Engineering
|
456
484
|
Institute of Computational and Data Sciences, Penn State University
|
457
485
|
|
458
|
-
3. Attribution: The[ffrd\rashdf'](https://github.com/fema-ffrd/rashdf) project by FEMA-FFRD (FEMA Future of Flood Risk Data) was incorporated, revised, adapted and extended in rascommander's RasHDF libaries (where noted).
|
486
|
+
3. Attribution: The [ffrd\rashdf'](https://github.com/fema-ffrd/rashdf) project by FEMA-FFRD (FEMA Future of Flood Risk Data) was incorporated, revised, adapted and extended in rascommander's RasHDF libaries (where noted).
|
459
487
|
|
460
488
|
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.
|
461
489
|
|
@@ -466,19 +494,25 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
466
494
|
## Official RAS Commander AI-Generated Songs:
|
467
495
|
|
468
496
|
[No More Wait and See (Bluegrass)](https://suno.com/song/16889f3e-50f1-4afe-b779-a41738d7617a)
|
469
|
-
|
497
|
+
|
498
|
+
|
470
499
|
[No More Wait and See (Cajun Zydeco)](https://suno.com/song/4441c45d-f6cd-47b9-8fbc-1f7b277ee8ed)
|
471
|
-
|
500
|
+
|
472
501
|
## Other Resources
|
473
502
|
|
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)
|
503
|
+
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)
|
504
|
+
|
475
505
|
Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
|
476
506
|
|
507
|
+
## Contributing
|
508
|
+
|
509
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
510
|
+
|
477
511
|
## LICENSE
|
478
512
|
|
479
513
|
This software is released under the MIT license.
|
480
514
|
|
481
515
|
## Contact
|
482
516
|
|
483
|
-
For questions, suggestions, or support, please contact:
|
517
|
+
For questions, suggestions, or support, please contact:
|
484
518
|
William Katzenmeyer, P.E., C.F.M. - heccommander@gmail.com
|
@@ -3,22 +3,25 @@
|
|
3
3
|
RAS Commander is a Python library for automating HEC-RAS operations, providing a set of tools to interact with HEC-RAS project files, execute simulations, and manage project data. This library was initially conceptualized in the Australian Water School course "AI Tools for Modelling Innovation", and subsequently expanded to cover the basic functionality of the HECRASController COM32 interface using open-source python libraries. This library uses a Test Driven Development strategy, leveraging the publicly-available HEC-RAS Example projects to create repeatable demonstration examples. The "Commmander" moniker is inspired by the "Command Line is All You Need" approach to HEC-RAS automation that was first implemented in the HEC-Commander Tools repository.
|
4
4
|
|
5
5
|
## Repository Author:
|
6
|
-
|
6
|
+
[William Katzenmeyer, P.E., C.F.M.](https://engineeringwithllms.info)
|
7
|
+
-----
|
7
8
|
|
8
|
-
## Don't Ask Me, Ask GPT!
|
9
|
+
## Don't Ask Me, Ask GPT!
|
9
10
|
|
10
11
|
This repository has several methods of interaction with Large Language Models and LLM-Assisted Coding built right in:
|
11
12
|
|
12
|
-
1. **[
|
13
|
+
1. **[Purpose-Built Knowledge Base Summaries](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/llm_knowledge_bases)**: Up-to-date compilations of the documentation and codebase for use with large language models like Claude, ChatGPT, Gemini or Grok. 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.
|
13
14
|
|
14
|
-
2. **[
|
15
|
+
2. **[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.
|
15
16
|
|
16
|
-
3. **[
|
17
|
+
3. **[RAS-Commander Library Assistant](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/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 Claude 3.7, OpenAI's o1 and o3-mini, and Deepseek V3 and R1 models using US-based Together.ai**
|
18
|
+
|
19
|
+
|
20
|
+
4. **[RAS Commander Library Assistant on ChatGPT](https://chatgpt.com/g/g-TZRPR3oAO-ras-commander-library-assistant)**: A specialized ChatGPT "GPT" 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. _NOTE: GPT's are still quite limited by OpenAI's GPT frameworks and may not be useful for long conversations. Code interpreter cannot run HEC-RAS but can open and view smaller HDF files and projects for demonstration purposes_
|
17
21
|
|
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**
|
19
22
|
|
20
23
|
## Background
|
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.
|
24
|
+
The ras-commander library emerged from the initial test-bed of AI-driven coding represented by the [HEC-Commander tools](https://github.com/gpt-cmdr/HEC-Commander) Python notebooks. These notebooks served as a proof of concept, demonstrating the value proposition of automating HEC-RAS operations. In 2024, I taught a series of progressively more complex webinars demonstrating how to use simple prompting, example projects and natural language instruction to effectively code HEC-RAS automation workflows, culminating in a 6 hour course. The library published for utilization in that course, [awsrastools](https://github.com/gpt-cmdr/awsrastools) served as a foundation of examples which were iteratively extended into the full RAS-Commander library. Unlike the original notebook by the same name, this library is not focused on parallel execution across multiple machines. Instead, it is focused on providing a general-purpose python API for interacting with HEC-RAS projects, and building an AI-friendly library that will allow new users to quickly scaffold their own workflows into a python script. Example notebooks are provided, but the intention is to empower engineers, software developers, GIS personnel and data analysts to more easily access and interact with HEC-RAS data in a python environment. Also, by publishing these examples publicly, with complete working code examples and LLM optimization, future users can readily rewrite they key functions of the library for inclusion in into their own preferred libraries, languages or return formats.
|
22
25
|
|
23
26
|
## Features
|
24
27
|
|
@@ -60,7 +63,13 @@ In your virtual environment, install ras-commander using pip:
|
|
60
63
|
pip install --upgrade ras-commander
|
61
64
|
```
|
62
65
|
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.
|
63
|
-
|
66
|
+
|
67
|
+
Dependencies can also be manually installed:
|
68
|
+
```
|
69
|
+
pip install h5py numpy pandas requests tqdm scipy xarray geopandas matplotlib shapely pathlib rasterstats rtree
|
70
|
+
```
|
71
|
+
|
72
|
+
|
64
73
|
#### Work in a Local Copy
|
65
74
|
|
66
75
|
If you want to make revisions and work actively in your local version of ras-commander, just skip the pip install rascommander step above and clone a fork of the repo to your local machine using Git (ask ChatGPT if you need help). Most of the notebooks and examples in this repo have a code segment similar to the one below, that works as long as the script is located in a first-level subfolder of the ras-commander repository:
|
@@ -87,11 +96,46 @@ It is highly suggested to fork this repository before going this route, and usin
|
|
87
96
|
from ras_commander import init_ras_project, RasCmdr, RasPlan
|
88
97
|
```
|
89
98
|
|
90
|
-
### Initialize a project
|
99
|
+
### Initialize a project (single project)
|
91
100
|
```
|
92
101
|
init_ras_project(r"/path/to/project", "6.5")
|
93
102
|
```
|
94
103
|
|
104
|
+
### Initialize a project (multiple projects)
|
105
|
+
```
|
106
|
+
your_ras_project = RasPrj()
|
107
|
+
init_ras_project(r"/path/to/project", "6.5", ras_object=your_ras_project)
|
108
|
+
```
|
109
|
+
|
110
|
+
## Accessing Plan, Unsteady and Boundary Conditions Dataframes
|
111
|
+
Using the default 'ras" object, othewise substitute your_ras_project for muli-project scripts
|
112
|
+
```
|
113
|
+
print("\nPlan Files DataFrame:")
|
114
|
+
ras.plan_df
|
115
|
+
```
|
116
|
+
```
|
117
|
+
print("\nFlow Files DataFrame:")
|
118
|
+
ras.flow_df
|
119
|
+
```
|
120
|
+
```
|
121
|
+
print("\nUnsteady Flow Files DataFrame:")
|
122
|
+
ras.unsteady_df
|
123
|
+
```
|
124
|
+
```
|
125
|
+
print("\nGeometry Files DataFrame:")
|
126
|
+
ras.geom_df
|
127
|
+
```
|
128
|
+
```
|
129
|
+
print("\nBoundary Conditions DataFrame:")
|
130
|
+
ras.boundaries_df
|
131
|
+
```
|
132
|
+
```
|
133
|
+
print("\nHDF Entries DataFrame:")
|
134
|
+
ras.get_hdf_entries()
|
135
|
+
```
|
136
|
+
|
137
|
+
|
138
|
+
|
95
139
|
### Execute a single plan
|
96
140
|
```
|
97
141
|
RasCmdr.compute_plan("01", dest_folder=r"/path/to/results", overwrite_dest=True)
|
@@ -153,8 +197,10 @@ RAS Commander allows working with multiple HEC-RAS projects simultaneously:
|
|
153
197
|
|
154
198
|
```python
|
155
199
|
# Initialize multiple projects
|
156
|
-
project1 =
|
157
|
-
|
200
|
+
project1 = RasPrj()
|
201
|
+
init_ras_project(path1, "6.6", ras_object=project1)
|
202
|
+
project2 = RasPrj()
|
203
|
+
init_ras_project(path2, "6.6", ras_object=project2)
|
158
204
|
|
159
205
|
# Perform operations on each project
|
160
206
|
RasCmdr.compute_plan("01", ras_object=project1, dest_folder=folder1)
|
@@ -170,7 +216,7 @@ print(f"Project 2: {project2.project_name}")
|
|
170
216
|
|
171
217
|
This is useful for comparing different river systems, running scenario analyses across multiple watersheds, or managing a suite of related models.
|
172
218
|
|
173
|
-
####
|
219
|
+
#### Core HEC-RAS Automation Classes
|
174
220
|
|
175
221
|
- `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
|
176
222
|
- `RasCmdr`: Handles execution of HEC-RAS simulations
|
@@ -180,7 +226,7 @@ This is useful for comparing different river systems, running scenario analyses
|
|
180
226
|
- `RasUtils`: Contains utility functions for file operations and data management
|
181
227
|
- `RasExamples`: Manages and loads HEC-RAS example projects
|
182
228
|
|
183
|
-
####
|
229
|
+
#### HDF Data Access Classes
|
184
230
|
- `HdfBase`: Core functionality for HDF file operations
|
185
231
|
- `HdfBndry`: Enhanced boundary condition handling
|
186
232
|
- `HdfMesh`: Comprehensive mesh data management
|
@@ -192,14 +238,18 @@ This is useful for comparing different river systems, running scenario analyses
|
|
192
238
|
- `HdfPipe`: Pipe network analysis tools
|
193
239
|
- `HdfPump`: Pump station analysis capabilities
|
194
240
|
- `HdfFluvialPluvial`: Fluvial-pluvial boundary analysis
|
195
|
-
- `RasMapper`: RASMapper
|
196
|
-
- `RasToGo`: Go-Consequences integration
|
241
|
+
- `RasMapper`: RASMapper Functions
|
197
242
|
- `HdfPlot` & `HdfResultsPlot`: Specialized plotting utilities
|
198
243
|
|
199
244
|
### Project Organization Diagram
|
200
245
|
|
201
246
|
```
|
202
247
|
ras_commander
|
248
|
+
├── ai_tools
|
249
|
+
│ ├── [AI Knowledge Bases](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/llm_knowledge_bases)
|
250
|
+
│ └── [Library Assistant](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/library_asssistant)
|
251
|
+
├── examples
|
252
|
+
│ └── [Examples Notebooks](https://github.com/gpt-cmdr/ras-commander/tree/main/ras_commander)
|
203
253
|
├── ras_commander
|
204
254
|
│ ├── __init__.py
|
205
255
|
│ ├── _version.py
|
@@ -212,8 +262,6 @@ ras_commander
|
|
212
262
|
│ ├── RasPrj.py
|
213
263
|
│ ├── RasUnsteady.py
|
214
264
|
│ ├── RasUtils.py
|
215
|
-
│ ├── RasToGo.py
|
216
|
-
│ ├── RasGpt.py
|
217
265
|
│ ├── HdfBase.py
|
218
266
|
│ ├── HdfBndry.py
|
219
267
|
│ ├── HdfMesh.py
|
@@ -227,28 +275,13 @@ ras_commander
|
|
227
275
|
│ ├── HdfFluvialPluvial.py
|
228
276
|
│ ├── HdfPlot.py
|
229
277
|
│ └── HdfResultsPlot.py
|
230
|
-
├── examples
|
231
|
-
│ ├── 00_Using_RasExamples.ipynb
|
232
|
-
│ ├── 01_project_initialization.ipynb
|
233
|
-
│ ├── 02_plan_and_geometry_operations.ipynb
|
234
|
-
│ ├── 03_unsteady_flow_operations.ipynb
|
235
|
-
│ ├── 04_multiple_project_operations.ipynb
|
236
|
-
│ ├── 05_single_plan_execution.ipynb
|
237
|
-
│ ├── 06_executing_plan_sets.ipynb
|
238
|
-
│ ├── 07_sequential_plan_execution.ipynb
|
239
|
-
│ ├── 08_parallel_execution.ipynb
|
240
|
-
│ └── 09_plan_parameter_operations.ipynb
|
241
|
-
├── tests
|
242
|
-
│ └── ... (test files)
|
243
278
|
├── .gitignore
|
244
279
|
├── LICENSE
|
245
280
|
├── README.md
|
246
281
|
├── STYLE_GUIDE.md
|
247
282
|
├── Comprehensive_Library_Guide.md
|
248
283
|
├── pyproject.toml
|
249
|
-
├── setup.cfg
|
250
284
|
├── setup.py
|
251
|
-
└── requirements.txt
|
252
285
|
```
|
253
286
|
|
254
287
|
### Accessing HEC Examples through RasExamples
|
@@ -270,6 +303,8 @@ projects = ras_examples.list_projects("Steady Flow")
|
|
270
303
|
extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
|
271
304
|
```
|
272
305
|
|
306
|
+
The RasExamples class is used to provide an alternative to traditional unit testing, with example notebooks doubling as tests and in-context examples for the end user. This increases interpretability by LLM's, reducing hallucinations.
|
307
|
+
|
273
308
|
### RasPrj
|
274
309
|
|
275
310
|
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.
|
@@ -394,18 +429,11 @@ The ras-commander library is an ongoing project. Future plans include:
|
|
394
429
|
- [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
|
395
430
|
- [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
|
396
431
|
|
397
|
-
## Contributing
|
398
|
-
|
399
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
400
432
|
|
401
433
|
## Style Guide
|
402
434
|
|
403
435
|
This project follows a specific style guide to maintain consistency across the codebase. Please refer to the [Style Guide](STYLE_GUIDE.md) for details on coding conventions, documentation standards, and best practices.
|
404
436
|
|
405
|
-
## License
|
406
|
-
|
407
|
-
ras-commander is released under the MIT License. See the license file for details.
|
408
|
-
|
409
437
|
## Acknowledgments
|
410
438
|
|
411
439
|
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.
|
@@ -423,7 +451,7 @@ Additionally, we would like to acknowledge the following notable contributions a
|
|
423
451
|
Xiaofeng Liu, Ph.D., P.E., Associate Professor, Department of Civil and Environmental Engineering
|
424
452
|
Institute of Computational and Data Sciences, Penn State University
|
425
453
|
|
426
|
-
3. Attribution: The[ffrd\rashdf'](https://github.com/fema-ffrd/rashdf) project by FEMA-FFRD (FEMA Future of Flood Risk Data) was incorporated, revised, adapted and extended in rascommander's RasHDF libaries (where noted).
|
454
|
+
3. Attribution: The [ffrd\rashdf'](https://github.com/fema-ffrd/rashdf) project by FEMA-FFRD (FEMA Future of Flood Risk Data) was incorporated, revised, adapted and extended in rascommander's RasHDF libaries (where noted).
|
427
455
|
|
428
456
|
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.
|
429
457
|
|
@@ -434,19 +462,25 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
434
462
|
## Official RAS Commander AI-Generated Songs:
|
435
463
|
|
436
464
|
[No More Wait and See (Bluegrass)](https://suno.com/song/16889f3e-50f1-4afe-b779-a41738d7617a)
|
437
|
-
|
465
|
+
|
466
|
+
|
438
467
|
[No More Wait and See (Cajun Zydeco)](https://suno.com/song/4441c45d-f6cd-47b9-8fbc-1f7b277ee8ed)
|
439
|
-
|
468
|
+
|
440
469
|
## Other Resources
|
441
470
|
|
442
|
-
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)
|
471
|
+
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)
|
472
|
+
|
443
473
|
Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
|
444
474
|
|
475
|
+
## Contributing
|
476
|
+
|
477
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
478
|
+
|
445
479
|
## LICENSE
|
446
480
|
|
447
481
|
This software is released under the MIT license.
|
448
482
|
|
449
483
|
## Contact
|
450
484
|
|
451
|
-
For questions, suggestions, or support, please contact:
|
452
|
-
William Katzenmeyer, P.E., C.F.M. - heccommander@gmail.com
|
485
|
+
For questions, suggestions, or support, please contact:
|
486
|
+
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:
|