ras-commander 0.61.0__tar.gz → 0.65.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.
Files changed (41) hide show
  1. {ras_commander-0.61.0/ras_commander.egg-info → ras_commander-0.65.0}/PKG-INFO +48 -47
  2. {ras_commander-0.61.0 → ras_commander-0.65.0}/README.md +48 -47
  3. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfBndry.py +91 -7
  4. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfInfiltration.py +7 -1
  5. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfPlan.py +44 -5
  6. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfResultsMesh.py +24 -14
  7. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfResultsPlan.py +380 -364
  8. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfStruc.py +30 -8
  9. ras_commander-0.65.0/ras_commander/RasMapper.py +24 -0
  10. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasPlan.py +262 -52
  11. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasPrj.py +186 -41
  12. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/__init__.py +3 -7
  13. {ras_commander-0.61.0 → ras_commander-0.65.0/ras_commander.egg-info}/PKG-INFO +48 -47
  14. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander.egg-info/SOURCES.txt +0 -2
  15. {ras_commander-0.61.0 → ras_commander-0.65.0}/setup.py +1 -1
  16. ras_commander-0.61.0/ras_commander/RasGpt.py +0 -27
  17. ras_commander-0.61.0/ras_commander/RasMapper.py +0 -105
  18. ras_commander-0.61.0/ras_commander/RasToGo.py +0 -37
  19. {ras_commander-0.61.0 → ras_commander-0.65.0}/LICENSE +0 -0
  20. {ras_commander-0.61.0 → ras_commander-0.65.0}/pyproject.toml +0 -0
  21. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/Decorators.py +0 -0
  22. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfBase.py +0 -0
  23. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfFluvialPluvial.py +0 -0
  24. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfMesh.py +0 -0
  25. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfPipe.py +0 -0
  26. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfPlot.py +0 -0
  27. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfPump.py +0 -0
  28. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfResultsPlot.py +0 -0
  29. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfResultsXsec.py +0 -0
  30. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfUtils.py +0 -0
  31. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/HdfXsec.py +0 -0
  32. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/LoggingConfig.py +0 -0
  33. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasCmdr.py +0 -0
  34. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasExamples.py +0 -0
  35. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasGeo.py +0 -0
  36. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasUnsteady.py +0 -0
  37. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander/RasUtils.py +0 -0
  38. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander.egg-info/dependency_links.txt +0 -0
  39. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander.egg-info/requires.txt +0 -0
  40. {ras_commander-0.61.0 → ras_commander-0.65.0}/ras_commander.egg-info/top_level.txt +0 -0
  41. {ras_commander-0.61.0 → ras_commander-0.65.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ras-commander
3
- Version: 0.61.0
3
+ Version: 0.65.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
- (William Katzenmeyer, P.E., C.F.M.)[https://engineeringwithllms.info]
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. **[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
+ 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. **[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
+ 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. **[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.
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. The transition from notebooks to a structured library aims to provide a more robust, maintainable, and extensible solution for water resources engineers.
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:
@@ -135,24 +144,27 @@ Using the default 'ras" object, othewise substitute your_ras_project for muli-pr
135
144
  ```
136
145
  print("\nPlan Files DataFrame:")
137
146
  ras.plan_df
138
-
147
+ ```
148
+ ```
139
149
  print("\nFlow Files DataFrame:")
140
150
  ras.flow_df
141
-
151
+ ```
152
+ ```
142
153
  print("\nUnsteady Flow Files DataFrame:")
143
154
  ras.unsteady_df
144
-
155
+ ```
156
+ ```
145
157
  print("\nGeometry Files DataFrame:")
146
158
  ras.geom_df
147
-
148
- print("\nHDF Entries DataFrame:")
149
- ras.get_hdf_entries()
150
-
159
+ ```
160
+ ```
151
161
  print("\nBoundary Conditions DataFrame:")
152
162
  ras.boundaries_df
153
-
154
163
  ```
155
-
164
+ ```
165
+ print("\nHDF Entries DataFrame:")
166
+ ras.get_hdf_entries()
167
+ ```
156
168
 
157
169
 
158
170
 
@@ -265,6 +277,11 @@ This is useful for comparing different river systems, running scenario analyses
265
277
 
266
278
  ```
267
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)
268
285
  ├── ras_commander
269
286
  │ ├── __init__.py
270
287
  │ ├── _version.py
@@ -277,8 +294,6 @@ ras_commander
277
294
  │ ├── RasPrj.py
278
295
  │ ├── RasUnsteady.py
279
296
  │ ├── RasUtils.py
280
- │ ├── RasToGo.py
281
- │ ├── RasGpt.py
282
297
  │ ├── HdfBase.py
283
298
  │ ├── HdfBndry.py
284
299
  │ ├── HdfMesh.py
@@ -292,28 +307,13 @@ ras_commander
292
307
  │ ├── HdfFluvialPluvial.py
293
308
  │ ├── HdfPlot.py
294
309
  │ └── HdfResultsPlot.py
295
- ├── examples
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
306
- ├── tests
307
- │ └── ... (test files)
308
310
  ├── .gitignore
309
311
  ├── LICENSE
310
312
  ├── README.md
311
313
  ├── STYLE_GUIDE.md
312
314
  ├── Comprehensive_Library_Guide.md
313
315
  ├── pyproject.toml
314
- ├── setup.cfg
315
316
  ├── setup.py
316
- └── requirements.txt
317
317
  ```
318
318
 
319
319
  ### Accessing HEC Examples through RasExamples
@@ -335,6 +335,8 @@ projects = ras_examples.list_projects("Steady Flow")
335
335
  extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
336
336
  ```
337
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
+
338
340
  ### RasPrj
339
341
 
340
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.
@@ -459,18 +461,11 @@ The ras-commander library is an ongoing project. Future plans include:
459
461
  - [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
460
462
  - [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
461
463
 
462
- ## Contributing
463
-
464
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
465
464
 
466
465
  ## Style Guide
467
466
 
468
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.
469
468
 
470
- ## License
471
-
472
- ras-commander is released under the MIT License. See the license file for details.
473
-
474
469
  ## Acknowledgments
475
470
 
476
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.
@@ -488,7 +483,7 @@ Additionally, we would like to acknowledge the following notable contributions a
488
483
  Xiaofeng Liu, Ph.D., P.E., Associate Professor, Department of Civil and Environmental Engineering
489
484
  Institute of Computational and Data Sciences, Penn State University
490
485
 
491
- 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).
492
487
 
493
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.
494
489
 
@@ -499,19 +494,25 @@ These acknowledgments recognize the contributions and inspirations that have hel
499
494
  ## Official RAS Commander AI-Generated Songs:
500
495
 
501
496
  [No More Wait and See (Bluegrass)](https://suno.com/song/16889f3e-50f1-4afe-b779-a41738d7617a)
502
-
497
+
498
+
503
499
  [No More Wait and See (Cajun Zydeco)](https://suno.com/song/4441c45d-f6cd-47b9-8fbc-1f7b277ee8ed)
504
-
500
+
505
501
  ## Other Resources
506
502
 
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)
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
+
508
505
  Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
509
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
+
510
511
  ## LICENSE
511
512
 
512
513
  This software is released under the MIT license.
513
514
 
514
515
  ## Contact
515
516
 
516
- For questions, suggestions, or support, please contact:
517
+ For questions, suggestions, or support, please contact:
517
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
- (William Katzenmeyer, P.E., C.F.M.)[https://engineeringwithllms.info]
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. **[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
+ 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. **[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
+ 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. **[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.
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. The transition from notebooks to a structured library aims to provide a more robust, maintainable, and extensible solution for water resources engineers.
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:
@@ -103,24 +112,27 @@ Using the default 'ras" object, othewise substitute your_ras_project for muli-pr
103
112
  ```
104
113
  print("\nPlan Files DataFrame:")
105
114
  ras.plan_df
106
-
115
+ ```
116
+ ```
107
117
  print("\nFlow Files DataFrame:")
108
118
  ras.flow_df
109
-
119
+ ```
120
+ ```
110
121
  print("\nUnsteady Flow Files DataFrame:")
111
122
  ras.unsteady_df
112
-
123
+ ```
124
+ ```
113
125
  print("\nGeometry Files DataFrame:")
114
126
  ras.geom_df
115
-
116
- print("\nHDF Entries DataFrame:")
117
- ras.get_hdf_entries()
118
-
127
+ ```
128
+ ```
119
129
  print("\nBoundary Conditions DataFrame:")
120
130
  ras.boundaries_df
121
-
122
131
  ```
123
-
132
+ ```
133
+ print("\nHDF Entries DataFrame:")
134
+ ras.get_hdf_entries()
135
+ ```
124
136
 
125
137
 
126
138
 
@@ -233,6 +245,11 @@ This is useful for comparing different river systems, running scenario analyses
233
245
 
234
246
  ```
235
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)
236
253
  ├── ras_commander
237
254
  │ ├── __init__.py
238
255
  │ ├── _version.py
@@ -245,8 +262,6 @@ ras_commander
245
262
  │ ├── RasPrj.py
246
263
  │ ├── RasUnsteady.py
247
264
  │ ├── RasUtils.py
248
- │ ├── RasToGo.py
249
- │ ├── RasGpt.py
250
265
  │ ├── HdfBase.py
251
266
  │ ├── HdfBndry.py
252
267
  │ ├── HdfMesh.py
@@ -260,28 +275,13 @@ ras_commander
260
275
  │ ├── HdfFluvialPluvial.py
261
276
  │ ├── HdfPlot.py
262
277
  │ └── HdfResultsPlot.py
263
- ├── examples
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
274
- ├── tests
275
- │ └── ... (test files)
276
278
  ├── .gitignore
277
279
  ├── LICENSE
278
280
  ├── README.md
279
281
  ├── STYLE_GUIDE.md
280
282
  ├── Comprehensive_Library_Guide.md
281
283
  ├── pyproject.toml
282
- ├── setup.cfg
283
284
  ├── setup.py
284
- └── requirements.txt
285
285
  ```
286
286
 
287
287
  ### Accessing HEC Examples through RasExamples
@@ -303,6 +303,8 @@ projects = ras_examples.list_projects("Steady Flow")
303
303
  extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
304
304
  ```
305
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
+
306
308
  ### RasPrj
307
309
 
308
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.
@@ -427,18 +429,11 @@ The ras-commander library is an ongoing project. Future plans include:
427
429
  - [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
428
430
  - [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
429
431
 
430
- ## Contributing
431
-
432
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
433
432
 
434
433
  ## Style Guide
435
434
 
436
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.
437
436
 
438
- ## License
439
-
440
- ras-commander is released under the MIT License. See the license file for details.
441
-
442
437
  ## Acknowledgments
443
438
 
444
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.
@@ -456,7 +451,7 @@ Additionally, we would like to acknowledge the following notable contributions a
456
451
  Xiaofeng Liu, Ph.D., P.E., Associate Professor, Department of Civil and Environmental Engineering
457
452
  Institute of Computational and Data Sciences, Penn State University
458
453
 
459
- 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).
460
455
 
461
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.
462
457
 
@@ -467,19 +462,25 @@ These acknowledgments recognize the contributions and inspirations that have hel
467
462
  ## Official RAS Commander AI-Generated Songs:
468
463
 
469
464
  [No More Wait and See (Bluegrass)](https://suno.com/song/16889f3e-50f1-4afe-b779-a41738d7617a)
470
-
465
+
466
+
471
467
  [No More Wait and See (Cajun Zydeco)](https://suno.com/song/4441c45d-f6cd-47b9-8fbc-1f7b277ee8ed)
472
-
468
+
473
469
  ## Other Resources
474
470
 
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)
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
+
476
473
  Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
477
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
+
478
479
  ## LICENSE
479
480
 
480
481
  This software is released under the MIT license.
481
482
 
482
483
  ## Contact
483
484
 
484
- For questions, suggestions, or support, please contact:
485
- 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
@@ -122,6 +122,12 @@ class HdfBndry:
122
122
  -------
123
123
  gpd.GeoDataFrame
124
124
  A GeoDataFrame containing the breaklines.
125
+
126
+ Notes
127
+ -----
128
+ - Zero-length breaklines are logged and skipped.
129
+ - Single-point breaklines are logged and skipped.
130
+ - These invalid breaklines should be removed in RASMapper to prevent potential issues.
125
131
  """
126
132
  try:
127
133
  with h5py.File(hdf_path, 'r') as hdf_file:
@@ -129,17 +135,95 @@ class HdfBndry:
129
135
  if breaklines_path not in hdf_file:
130
136
  logger.warning(f"Breaklines path '{breaklines_path}' not found in HDF file.")
131
137
  return gpd.GeoDataFrame()
138
+
132
139
  bl_line_data = hdf_file[breaklines_path]
133
- bl_line_ids = range(bl_line_data["Attributes"][()].shape[0])
134
- names = np.vectorize(HdfUtils.convert_ras_string)(
135
- bl_line_data["Attributes"][()]["Name"]
136
- )
137
- geoms = HdfBase.get_polylines_from_parts(hdf_path, breaklines_path)
140
+ attributes = bl_line_data["Attributes"][()]
141
+
142
+ # Initialize lists to store valid breakline data
143
+ valid_ids = []
144
+ valid_names = []
145
+ valid_geoms = []
146
+
147
+ # Track invalid breaklines for summary
148
+ zero_length_count = 0
149
+ single_point_count = 0
150
+ other_error_count = 0
151
+
152
+ # Process each breakline
153
+ for idx, (pnt_start, pnt_cnt, part_start, part_cnt) in enumerate(bl_line_data["Polyline Info"][()]):
154
+ name = HdfUtils.convert_ras_string(attributes["Name"][idx])
155
+
156
+ # Check for zero-length breaklines
157
+ if pnt_cnt == 0:
158
+ zero_length_count += 1
159
+ logger.debug(f"Zero-length breakline found (FID: {idx}, Name: {name})")
160
+ continue
161
+
162
+ # Check for single-point breaklines
163
+ if pnt_cnt == 1:
164
+ single_point_count += 1
165
+ logger.debug(f"Single-point breakline found (FID: {idx}, Name: {name})")
166
+ continue
167
+
168
+ try:
169
+ points = bl_line_data["Polyline Points"][()][pnt_start:pnt_start + pnt_cnt]
170
+
171
+ # Additional validation of points array
172
+ if len(points) < 2:
173
+ single_point_count += 1
174
+ logger.debug(f"Invalid point count in breakline (FID: {idx}, Name: {name})")
175
+ continue
176
+
177
+ if part_cnt == 1:
178
+ geom = LineString(points)
179
+ else:
180
+ parts = bl_line_data["Polyline Parts"][()][part_start:part_start + part_cnt]
181
+ geom = MultiLineString([
182
+ points[part_pnt_start:part_pnt_start + part_pnt_cnt]
183
+ for part_pnt_start, part_pnt_cnt in parts
184
+ if part_pnt_cnt > 1 # Skip single-point parts
185
+ ])
186
+ # Skip if no valid parts remain
187
+ if len(geom.geoms) == 0:
188
+ other_error_count += 1
189
+ logger.debug(f"No valid parts in multipart breakline (FID: {idx}, Name: {name})")
190
+ continue
191
+
192
+ valid_ids.append(idx)
193
+ valid_names.append(name)
194
+ valid_geoms.append(geom)
195
+
196
+ except Exception as e:
197
+ other_error_count += 1
198
+ logger.debug(f"Error processing breakline {idx}: {str(e)}")
199
+ continue
200
+
201
+ # Log summary of invalid breaklines
202
+ total_invalid = zero_length_count + single_point_count + other_error_count
203
+ if total_invalid > 0:
204
+ logger.info(
205
+ f"Breakline processing summary:\n"
206
+ f"- Zero-length breaklines: {zero_length_count}\n"
207
+ f"- Single-point breaklines: {single_point_count}\n"
208
+ f"- Other invalid breaklines: {other_error_count}\n"
209
+ f"Consider removing these invalid breaklines using RASMapper."
210
+ )
211
+
212
+ # Create GeoDataFrame with valid breaklines
213
+ if not valid_ids:
214
+ logger.warning("No valid breaklines found in the HDF file.")
215
+ return gpd.GeoDataFrame()
216
+
138
217
  return gpd.GeoDataFrame(
139
- {"bl_id": bl_line_ids, "Name": names, "geometry": geoms},
218
+ {
219
+ "bl_id": valid_ids,
220
+ "Name": valid_names,
221
+ "geometry": valid_geoms
222
+ },
140
223
  geometry="geometry",
141
- crs=HdfBase.get_projection(hdf_file),
224
+ crs=HdfBase.get_projection(hdf_file)
142
225
  )
226
+
143
227
  except Exception as e:
144
228
  logger.error(f"Error reading breaklines: {str(e)}")
145
229
  return gpd.GeoDataFrame()
@@ -47,7 +47,7 @@ from pathlib import Path
47
47
  import pandas as pd
48
48
  import geopandas as gpd
49
49
  import h5py
50
- from rasterstats import zonal_stats
50
+
51
51
  from .Decorators import log_call, standardize_input
52
52
 
53
53
  class HdfInfiltration:
@@ -232,6 +232,12 @@ class HdfInfiltration:
232
232
  Returns:
233
233
  DataFrame with soil statistics including percentages and areas
234
234
  """
235
+
236
+ try:
237
+ from rasterstats import zonal_stats
238
+ except ImportError as e:
239
+ logger.error("Failed to import rasterstats. Please run 'pip install rasterstats' and try again.")
240
+ raise e
235
241
  # Initialize areas dictionary
236
242
  mukey_areas = {mukey: 0 for mukey in raster_map.values()}
237
243