ras-commander 0.0.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.0.0/LICENSE +5 -0
- ras_commander-0.0.0/PKG-INFO +342 -0
- ras_commander-0.0.0/README.md +329 -0
- ras_commander-0.0.0/pyproject.toml +26 -0
- ras_commander-0.0.0/ras_commander/RasCommander.py +456 -0
- ras_commander-0.0.0/ras_commander/RasExamples.py +304 -0
- ras_commander-0.0.0/ras_commander/RasGeo.py +83 -0
- ras_commander-0.0.0/ras_commander/RasPlan.py +1216 -0
- ras_commander-0.0.0/ras_commander/RasPrj.py +400 -0
- ras_commander-0.0.0/ras_commander/RasUnsteady.py +53 -0
- ras_commander-0.0.0/ras_commander/RasUtils.py +283 -0
- ras_commander-0.0.0/ras_commander/__init__.py +40 -0
- ras_commander-0.0.0/ras_commander.egg-info/PKG-INFO +342 -0
- ras_commander-0.0.0/ras_commander.egg-info/SOURCES.txt +17 -0
- ras_commander-0.0.0/ras_commander.egg-info/dependency_links.txt +1 -0
- ras_commander-0.0.0/ras_commander.egg-info/top_level.txt +1 -0
- ras_commander-0.0.0/setup.cfg +7 -0
- ras_commander-0.0.0/setup.py +3 -0
@@ -0,0 +1,5 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 William M. Katzenmeyer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
|
@@ -0,0 +1,342 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: ras_commander
|
3
|
+
Version: 0.0.0
|
4
|
+
Summary: A library for automating HEC-RAS operations using python functions.
|
5
|
+
Author-email: "William Katzenmeyer, P.E., C.F.M." <heccommander@gmail.com>
|
6
|
+
Project-URL: Homepage, https://github.com/yourusername/ras_commander
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.9
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENSE
|
13
|
+
|
14
|
+
## RAS-Commander Library Organization
|
15
|
+
|
16
|
+
| Directory/File | Purpose |
|
17
|
+
|---|---|
|
18
|
+
| ras_commander/__init__.py | Initializes the library and defines the public API. |
|
19
|
+
| ras_commander/RasCommander.py | Handles execution of HEC-RAS simulations. |
|
20
|
+
| ras_commander/RasFileOps.py | Provides functions for reading and parsing HEC-RAS project files. |
|
21
|
+
| ras_commander/RasGeo.py | Provides functions for manipulating geometry files. |
|
22
|
+
| ras_commander/RasPlan.py | Provides functions for modifying and updating plan files. |
|
23
|
+
| ras_commander/RasPrj.py | Defines the RasPrj class for managing project-level information. |
|
24
|
+
| ras_commander/rasinit.py | Provides the `init_ras_project` function to initialize a project. |
|
25
|
+
| ras_commander/RasPrj.py | Provides functions for managing HEC-RAS projects (e.g., copying files, updating project file). |
|
26
|
+
| ras_commander/RasUnsteady.py | Provides functions for manipulating unsteady flow files. |
|
27
|
+
| ras_commander/RasUtils.py | Provides general utility functions (e.g., file backup, directory creation). |
|
28
|
+
|
29
|
+
## Project Organization Diagram
|
30
|
+
|
31
|
+
```
|
32
|
+
ras_commander
|
33
|
+
├── .github
|
34
|
+
│ └── workflows
|
35
|
+
│ └── python-package.yml
|
36
|
+
├── ras_commander
|
37
|
+
│ ├── __init__.py
|
38
|
+
│ ├── RasCommander.py
|
39
|
+
│ ├── RasFileOps.py
|
40
|
+
│ ├── RasGeo.py
|
41
|
+
│ ├── RasPlan.py
|
42
|
+
│ ├── RasPrj.py
|
43
|
+
│ ├── rasinit.py
|
44
|
+
│ ├── RasPrj.py
|
45
|
+
│ ├── RasUnsteady.py
|
46
|
+
│ └── RasUtils.py
|
47
|
+
├── tests
|
48
|
+
│ └── ... (test files)
|
49
|
+
├── .gitignore
|
50
|
+
├── LICENSE
|
51
|
+
├── README.md
|
52
|
+
├── pyproject.toml
|
53
|
+
├── setup.cfg
|
54
|
+
└── setup.py
|
55
|
+
```
|
56
|
+
|
57
|
+
## Functions Overview
|
58
|
+
|
59
|
+
| Function | Arguments | Purpose |
|
60
|
+
|---|---|---|
|
61
|
+
| `init_ras_project` | `ras_project_folder`, `ras_exe_path` | Initializes a HEC-RAS project by setting up the `RasPrj` with project details. |
|
62
|
+
| `compute_plan` | `plan_file` | Executes a HEC-RAS plan file. |
|
63
|
+
| `compute_plan_from_folder` | `test_plan_file`, `test_folder_path` | Execute a single HEC-RAS plan from a folder other than the project path. |
|
64
|
+
| `compute_test_mode` | `project_folder` | Recreates the -test function from the HEC-RAS interface, primarily by copying the project directory, forcing recomputation, and running each plan. |
|
65
|
+
| `compute_parallel` | `config`, `max_workers`, `cores_per_run` | Run HEC-RAS plans in parallel. |
|
66
|
+
| `compute_parallel_all` | `project_folder`, `ras_exe_path` | Run all HEC-RAS plans in parallel from a project folder path. |
|
67
|
+
|
68
|
+
[The rest of the function list remains the same, just ensure the class names are updated to their new lowercase versions]
|
69
|
+
|
70
|
+
## Potential Uses of RAS-Commander Functions
|
71
|
+
|
72
|
+
[This section remains unchanged]
|
73
|
+
|
74
|
+
## GitHub Actions
|
75
|
+
|
76
|
+
[This section remains unchanged]
|
77
|
+
|
78
|
+
## Basic Usage Instructions
|
79
|
+
|
80
|
+
To get started with RAS-Commander, follow these steps:
|
81
|
+
|
82
|
+
1. Install the library:
|
83
|
+
```
|
84
|
+
pip install ras-commander
|
85
|
+
```
|
86
|
+
|
87
|
+
2. Import the necessary modules:
|
88
|
+
```python
|
89
|
+
from ras_commander import rasinit, RasFileOps, RasPrj, RasPlan, RasGeo, RasUnsteady, RasCommander, RasUtils
|
90
|
+
```
|
91
|
+
|
92
|
+
3. Initialize a HEC-RAS project:
|
93
|
+
```python
|
94
|
+
project_folder = r"C:\path\to\your\project"
|
95
|
+
ras_exe_path = r"C:\Program Files (x86)\HEC\HEC-RAS\6.5\Ras.exe"
|
96
|
+
config = rasinit(project_folder, ras_exe_path)
|
97
|
+
```
|
98
|
+
|
99
|
+
4. Perform operations on your HEC-RAS project. For example:
|
100
|
+
|
101
|
+
- Execute a single plan:
|
102
|
+
```python
|
103
|
+
plan_file = RasPlan.get_plan_path("01")
|
104
|
+
RasCommander.compute_plan(plan_file)
|
105
|
+
```
|
106
|
+
|
107
|
+
- Run multiple plans in parallel:
|
108
|
+
```python
|
109
|
+
max_workers = 2
|
110
|
+
cores_per_run = 1
|
111
|
+
results = RasCommander.compute_parallel(config, max_workers, cores_per_run)
|
112
|
+
```
|
113
|
+
|
114
|
+
- Copy and modify geometry files:
|
115
|
+
```python
|
116
|
+
RasGeo.clone_geom(config.project_folder, "01")
|
117
|
+
plan_file = RasPlan.get_plan_path("01")
|
118
|
+
RasGeo.set_geom(plan_file, "02")
|
119
|
+
```
|
120
|
+
|
121
|
+
- Work with unsteady flow files:
|
122
|
+
```python
|
123
|
+
new_unsteady_number = RasUnsteady.clone_unsteady(config.project_folder, "01")
|
124
|
+
plan_file = RasPlan.get_plan_path("01")
|
125
|
+
RasUnsteady.set_unsteady(plan_file, new_unsteady_number)
|
126
|
+
```
|
127
|
+
|
128
|
+
5. Access project information:
|
129
|
+
```python
|
130
|
+
print(f"Project name: {config.project_name}")
|
131
|
+
print(f"Project file: {config.prj_file}")
|
132
|
+
print(f"Project folder: {config.project_folder}")
|
133
|
+
```
|
134
|
+
|
135
|
+
For more detailed examples and advanced usage, refer to the function documentation and the examples provided in the repository.
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
NOTES: INCORPORATE INTO THE README.MD FILE ABOVE UNDER A NEW SECTION FOR CURRENT USES AND ROADMAP ITEMS, THEN DELETE THIS NOTE
|
141
|
+
|
142
|
+
|
143
|
+
Potential Uses of HEC-RAS Automation Functions
|
144
|
+
This set of functions provides a powerful foundation for automating various aspects of HEC-RAS modeling workflows. Here are some potential applications:
|
145
|
+
1. Calibration and Sensitivity Analysis:
|
146
|
+
Automated Parameter Variation: Users can create multiple simulation scenarios with varying parameters (e.g., Manning's n values, boundary conditions, initial conditions) to calibrate their model against observed data.
|
147
|
+
Sensitivity Testing: Evaluate the impact of different input parameters on model outputs by generating a range of scenarios and analyzing the results. This helps identify critical parameters that require more attention during calibration.
|
148
|
+
2. Real-time Forecasting:
|
149
|
+
Dynamic Model Updates: Integrate with external data sources (e.g., weather forecasts, streamflow observations) to automatically update boundary conditions and initial conditions in unsteady flow files before running the simulation.
|
150
|
+
Ensemble Forecasting: Generate multiple forecasts by incorporating uncertainty in input data and model parameters. This provides a more comprehensive understanding of potential future flow conditions.
|
151
|
+
3. Scenario Analysis:
|
152
|
+
Land Use Change Impacts: Evaluate the effects of land use changes on flood risk by modifying Manning's n values using extract_2d_mannings_tables, modify_2d_mannings_table, and write_2d_mannings_tables and running simulations with updated geometry files.
|
153
|
+
Climate Change Impacts: Analyze the potential impacts of projected climate changes on flood risk by adjusting precipitation patterns and other relevant parameters in unsteady flow files.
|
154
|
+
4. Batch Processing and High-Performance Computing:
|
155
|
+
Large-scale Model Runs: Utilize run_plans_parallel to execute multiple simulations concurrently on a multi-core system, significantly reducing processing time for large-scale models or complex scenarios.
|
156
|
+
Automated Report Generation: Integrate with Python libraries like matplotlib and bokeh to automatically generate customized reports summarizing simulation results, including tables, figures, and maps.
|
157
|
+
5. Model Development and Testing:
|
158
|
+
Rapid Prototyping: Quickly set up and run new model configurations using template files and automated workflows, facilitating rapid model development and testing.
|
159
|
+
Regression Testing: Ensure model integrity and consistency after code changes or updates by automatically running a predefined set of simulations and comparing results with expected outputs.
|
160
|
+
6. User-Friendly Interfaces:
|
161
|
+
GUI Development: Integrate with Python GUI libraries like Tkinter or PyQt to create user-friendly interfaces for automating HEC-RAS workflows, allowing non-programmers to access the power of automation.
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
Certainly! I'll create an updated README.md for the ras_commander library, incorporating the information you've provided and the context from the previous HEC-Commander tools. Here's the updated README.md:
|
169
|
+
|
170
|
+
```markdown
|
171
|
+
# ras_commander
|
172
|
+
|
173
|
+
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 is an evolution of the RAS-Commander 1.0 Python Notebook Application previously released under the HEC-Commander tools.
|
174
|
+
|
175
|
+
## Features
|
176
|
+
|
177
|
+
- Automate HEC-RAS project management and simulations
|
178
|
+
- Support for both single and multiple project instances
|
179
|
+
- Parallel execution of HEC-RAS plans
|
180
|
+
- Utilities for managing geometry, plan, and unsteady flow files
|
181
|
+
- Example project management for testing and development
|
182
|
+
- Two primary operation modes: "Run Missing" and "Build from DSS"
|
183
|
+
|
184
|
+
## Installation
|
185
|
+
|
186
|
+
Install ras_commander using pip:
|
187
|
+
|
188
|
+
```bash
|
189
|
+
pip install ras_commander
|
190
|
+
```
|
191
|
+
|
192
|
+
## Requirements
|
193
|
+
|
194
|
+
- Python 3.9+
|
195
|
+
- HEC-RAS 6.5 (other versions may work but are not officially supported)
|
196
|
+
|
197
|
+
For a full list of dependencies, see the `requirements.txt` file.
|
198
|
+
|
199
|
+
## Quick Start
|
200
|
+
|
201
|
+
```python
|
202
|
+
from ras_commander import init_ras_project, RasCommander, RasPlan
|
203
|
+
|
204
|
+
# Initialize a project
|
205
|
+
init_ras_project("/path/to/project", "6.5")
|
206
|
+
|
207
|
+
# Execute a single plan
|
208
|
+
RasCommander.compute_plan("01")
|
209
|
+
|
210
|
+
# Execute plans in parallel
|
211
|
+
results = RasCommander.compute_parallel(
|
212
|
+
plan_numbers=["01", "02"],
|
213
|
+
max_workers=2,
|
214
|
+
cores_per_run=2
|
215
|
+
)
|
216
|
+
|
217
|
+
# Modify a plan
|
218
|
+
RasPlan.set_geom("01", "02")
|
219
|
+
```
|
220
|
+
|
221
|
+
## Key Components
|
222
|
+
|
223
|
+
- `RasPrj`: Manages HEC-RAS projects
|
224
|
+
- `RasCommander`: Handles execution of HEC-RAS simulations
|
225
|
+
- `RasPlan`: Provides functions for modifying and updating plan files
|
226
|
+
- `RasGeo`: Handles operations related to geometry files
|
227
|
+
- `RasUnsteady`: Manages unsteady flow file operations
|
228
|
+
- `RasUtils`: Contains utility functions for file operations and data management
|
229
|
+
- `RasExamples`: Manages and loads HEC-RAS example projects
|
230
|
+
|
231
|
+
## Documentation
|
232
|
+
|
233
|
+
For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
|
234
|
+
|
235
|
+
## Examples
|
236
|
+
|
237
|
+
Check out the `examples/` directory for sample scripts demonstrating various features of ras_commander.
|
238
|
+
|
239
|
+
## Development
|
240
|
+
|
241
|
+
### Setting up the development environment
|
242
|
+
|
243
|
+
1. Clone the repository:
|
244
|
+
```
|
245
|
+
git clone https://github.com/yourusername/ras_commander.git
|
246
|
+
```
|
247
|
+
2. Create a virtual environment and activate it:
|
248
|
+
```
|
249
|
+
python -m venv venv
|
250
|
+
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
|
251
|
+
```
|
252
|
+
3. Install the development dependencies:
|
253
|
+
```
|
254
|
+
pip install -r requirements.txt
|
255
|
+
```
|
256
|
+
Certainly! I'll provide an updated Project Organization Diagram based on the current structure of the ras_commander library. Here's the updated diagram:
|
257
|
+
|
258
|
+
|
259
|
+
## Project Organization Diagram
|
260
|
+
|
261
|
+
```
|
262
|
+
ras_commander
|
263
|
+
├── .github
|
264
|
+
│ └── workflows
|
265
|
+
│ └── python-package.yml
|
266
|
+
├── ras_commander
|
267
|
+
│ ├── __init__.py
|
268
|
+
│ ├── RasCommander.py
|
269
|
+
│ ├── RasExamples.py
|
270
|
+
│ ├── RasGeo.py
|
271
|
+
│ ├── RasPlan.py
|
272
|
+
│ ├── RasPrj.py
|
273
|
+
│ ├── RasUnsteady.py
|
274
|
+
│ └── RasUtils.py
|
275
|
+
├── examples
|
276
|
+
│ ├── 01_project_initialization.py
|
277
|
+
│ ├── 02_plan_operations.py
|
278
|
+
│ ├── 03_geometry_operations.py
|
279
|
+
│ ├── 04_unsteady_flow_operations.py
|
280
|
+
│ ├── 05_utility_functions.py
|
281
|
+
│ ├── 06_single_plan_execution.py
|
282
|
+
│ ├── 07_sequential_plan_execution.py
|
283
|
+
│ ├── 08_parallel_execution.py
|
284
|
+
│ ├── 09_specifying_plans.py
|
285
|
+
│ ├── 10_arguments_for_compute.py
|
286
|
+
│ ├── 11_Using_RasExamples.ipynb
|
287
|
+
│ ├── 12_plan_set_execution.py
|
288
|
+
│ └── 13_multiple_project_operations.py
|
289
|
+
├── tests
|
290
|
+
│ └── ... (test files)
|
291
|
+
├── .gitignore
|
292
|
+
├── LICENSE
|
293
|
+
├── README.md
|
294
|
+
├── STYLE_GUIDE.md
|
295
|
+
├── Comprehensive_Library_Guide.md
|
296
|
+
├── pyproject.toml
|
297
|
+
├── setup.cfg
|
298
|
+
├── setup.py
|
299
|
+
└── requirements.txt
|
300
|
+
|
301
|
+
|
302
|
+
## Inclusion of .cursorrules for AI-driven Coding Experience
|
303
|
+
|
304
|
+
Open the ras_commander folder in the Cursor IDE, and it will automatically include the .cursorrules file in your instructions. Additionally, two other provided methods for interacting with the library though your current AI subscriptions:
|
305
|
+
|
306
|
+
- ChatGPT: ras_commander GPT Assistant (LINK HERE)
|
307
|
+
- Latest LLM summaries of the code base:
|
308
|
+
- Entire code base: LINK HERE (TOKEN COUNT) (for Claude or Gemini)
|
309
|
+
- Examples and Function Docstrings Only: LINK HERE (TOKEN COUNT) (for GPT-4o, o1 or Llama 3.1 405b)
|
310
|
+
- Cursor IDE through .cursorrules file
|
311
|
+
|
312
|
+
There are a series of scripts provided in the "llm_summaries" folder that provide summaries of the code base, and the docstrings of the functions. They can be run in your local environment, or provided to ChatGPT's code interpreter for execution.
|
313
|
+
|
314
|
+
## RAS-Commander GPT Assistant
|
315
|
+
|
316
|
+
The ras_commander GPT assistant has access the entire code base, and can be a helpful tool for understanding the library and its capabilities. However, it is subject to the same context window limitations and file retrieval limtations as I have covered in ADD BLOG LINK HERE. For best results, use the llm summaries above to provide robust context to the model before asking to generate complex workflows.
|
317
|
+
|
318
|
+
## Contributing
|
319
|
+
|
320
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
321
|
+
|
322
|
+
## Style Guide
|
323
|
+
|
324
|
+
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.
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
## License
|
330
|
+
|
331
|
+
ras_commander is released under the MIT License. See the license file for details.
|
332
|
+
|
333
|
+
## Acknowledgments
|
334
|
+
|
335
|
+
ras_commander is based on the HEC-Commander project's "Command Line is All You Need" approach, leveraging the HEC-RAS command-line interface for automation. The initial development of this library was presented in the HEC-Commander Tools repository. In a 2024 Australian Water School webinar, Bill demonstrated the derivation of basic HEC-RAS automation functions from plain language instructions. Leveraging the previously developed code and AI tools, the library was created. The primary tools used for this initial development were Anthropic's Claude, GPT-4o, Google's Gemini Experimental models,and the Cursor AI Coding IDE.
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
## Contact
|
340
|
+
|
341
|
+
For questions, suggestions, or support, please contact:
|
342
|
+
William Katzenmeyer, P.E., C.F.M. - billk@fenstermaker.com
|
@@ -0,0 +1,329 @@
|
|
1
|
+
## RAS-Commander Library Organization
|
2
|
+
|
3
|
+
| Directory/File | Purpose |
|
4
|
+
|---|---|
|
5
|
+
| ras_commander/__init__.py | Initializes the library and defines the public API. |
|
6
|
+
| ras_commander/RasCommander.py | Handles execution of HEC-RAS simulations. |
|
7
|
+
| ras_commander/RasFileOps.py | Provides functions for reading and parsing HEC-RAS project files. |
|
8
|
+
| ras_commander/RasGeo.py | Provides functions for manipulating geometry files. |
|
9
|
+
| ras_commander/RasPlan.py | Provides functions for modifying and updating plan files. |
|
10
|
+
| ras_commander/RasPrj.py | Defines the RasPrj class for managing project-level information. |
|
11
|
+
| ras_commander/rasinit.py | Provides the `init_ras_project` function to initialize a project. |
|
12
|
+
| ras_commander/RasPrj.py | Provides functions for managing HEC-RAS projects (e.g., copying files, updating project file). |
|
13
|
+
| ras_commander/RasUnsteady.py | Provides functions for manipulating unsteady flow files. |
|
14
|
+
| ras_commander/RasUtils.py | Provides general utility functions (e.g., file backup, directory creation). |
|
15
|
+
|
16
|
+
## Project Organization Diagram
|
17
|
+
|
18
|
+
```
|
19
|
+
ras_commander
|
20
|
+
├── .github
|
21
|
+
│ └── workflows
|
22
|
+
│ └── python-package.yml
|
23
|
+
├── ras_commander
|
24
|
+
│ ├── __init__.py
|
25
|
+
│ ├── RasCommander.py
|
26
|
+
│ ├── RasFileOps.py
|
27
|
+
│ ├── RasGeo.py
|
28
|
+
│ ├── RasPlan.py
|
29
|
+
│ ├── RasPrj.py
|
30
|
+
│ ├── rasinit.py
|
31
|
+
│ ├── RasPrj.py
|
32
|
+
│ ├── RasUnsteady.py
|
33
|
+
│ └── RasUtils.py
|
34
|
+
├── tests
|
35
|
+
│ └── ... (test files)
|
36
|
+
├── .gitignore
|
37
|
+
├── LICENSE
|
38
|
+
├── README.md
|
39
|
+
├── pyproject.toml
|
40
|
+
├── setup.cfg
|
41
|
+
└── setup.py
|
42
|
+
```
|
43
|
+
|
44
|
+
## Functions Overview
|
45
|
+
|
46
|
+
| Function | Arguments | Purpose |
|
47
|
+
|---|---|---|
|
48
|
+
| `init_ras_project` | `ras_project_folder`, `ras_exe_path` | Initializes a HEC-RAS project by setting up the `RasPrj` with project details. |
|
49
|
+
| `compute_plan` | `plan_file` | Executes a HEC-RAS plan file. |
|
50
|
+
| `compute_plan_from_folder` | `test_plan_file`, `test_folder_path` | Execute a single HEC-RAS plan from a folder other than the project path. |
|
51
|
+
| `compute_test_mode` | `project_folder` | Recreates the -test function from the HEC-RAS interface, primarily by copying the project directory, forcing recomputation, and running each plan. |
|
52
|
+
| `compute_parallel` | `config`, `max_workers`, `cores_per_run` | Run HEC-RAS plans in parallel. |
|
53
|
+
| `compute_parallel_all` | `project_folder`, `ras_exe_path` | Run all HEC-RAS plans in parallel from a project folder path. |
|
54
|
+
|
55
|
+
[The rest of the function list remains the same, just ensure the class names are updated to their new lowercase versions]
|
56
|
+
|
57
|
+
## Potential Uses of RAS-Commander Functions
|
58
|
+
|
59
|
+
[This section remains unchanged]
|
60
|
+
|
61
|
+
## GitHub Actions
|
62
|
+
|
63
|
+
[This section remains unchanged]
|
64
|
+
|
65
|
+
## Basic Usage Instructions
|
66
|
+
|
67
|
+
To get started with RAS-Commander, follow these steps:
|
68
|
+
|
69
|
+
1. Install the library:
|
70
|
+
```
|
71
|
+
pip install ras-commander
|
72
|
+
```
|
73
|
+
|
74
|
+
2. Import the necessary modules:
|
75
|
+
```python
|
76
|
+
from ras_commander import rasinit, RasFileOps, RasPrj, RasPlan, RasGeo, RasUnsteady, RasCommander, RasUtils
|
77
|
+
```
|
78
|
+
|
79
|
+
3. Initialize a HEC-RAS project:
|
80
|
+
```python
|
81
|
+
project_folder = r"C:\path\to\your\project"
|
82
|
+
ras_exe_path = r"C:\Program Files (x86)\HEC\HEC-RAS\6.5\Ras.exe"
|
83
|
+
config = rasinit(project_folder, ras_exe_path)
|
84
|
+
```
|
85
|
+
|
86
|
+
4. Perform operations on your HEC-RAS project. For example:
|
87
|
+
|
88
|
+
- Execute a single plan:
|
89
|
+
```python
|
90
|
+
plan_file = RasPlan.get_plan_path("01")
|
91
|
+
RasCommander.compute_plan(plan_file)
|
92
|
+
```
|
93
|
+
|
94
|
+
- Run multiple plans in parallel:
|
95
|
+
```python
|
96
|
+
max_workers = 2
|
97
|
+
cores_per_run = 1
|
98
|
+
results = RasCommander.compute_parallel(config, max_workers, cores_per_run)
|
99
|
+
```
|
100
|
+
|
101
|
+
- Copy and modify geometry files:
|
102
|
+
```python
|
103
|
+
RasGeo.clone_geom(config.project_folder, "01")
|
104
|
+
plan_file = RasPlan.get_plan_path("01")
|
105
|
+
RasGeo.set_geom(plan_file, "02")
|
106
|
+
```
|
107
|
+
|
108
|
+
- Work with unsteady flow files:
|
109
|
+
```python
|
110
|
+
new_unsteady_number = RasUnsteady.clone_unsteady(config.project_folder, "01")
|
111
|
+
plan_file = RasPlan.get_plan_path("01")
|
112
|
+
RasUnsteady.set_unsteady(plan_file, new_unsteady_number)
|
113
|
+
```
|
114
|
+
|
115
|
+
5. Access project information:
|
116
|
+
```python
|
117
|
+
print(f"Project name: {config.project_name}")
|
118
|
+
print(f"Project file: {config.prj_file}")
|
119
|
+
print(f"Project folder: {config.project_folder}")
|
120
|
+
```
|
121
|
+
|
122
|
+
For more detailed examples and advanced usage, refer to the function documentation and the examples provided in the repository.
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
NOTES: INCORPORATE INTO THE README.MD FILE ABOVE UNDER A NEW SECTION FOR CURRENT USES AND ROADMAP ITEMS, THEN DELETE THIS NOTE
|
128
|
+
|
129
|
+
|
130
|
+
Potential Uses of HEC-RAS Automation Functions
|
131
|
+
This set of functions provides a powerful foundation for automating various aspects of HEC-RAS modeling workflows. Here are some potential applications:
|
132
|
+
1. Calibration and Sensitivity Analysis:
|
133
|
+
Automated Parameter Variation: Users can create multiple simulation scenarios with varying parameters (e.g., Manning's n values, boundary conditions, initial conditions) to calibrate their model against observed data.
|
134
|
+
Sensitivity Testing: Evaluate the impact of different input parameters on model outputs by generating a range of scenarios and analyzing the results. This helps identify critical parameters that require more attention during calibration.
|
135
|
+
2. Real-time Forecasting:
|
136
|
+
Dynamic Model Updates: Integrate with external data sources (e.g., weather forecasts, streamflow observations) to automatically update boundary conditions and initial conditions in unsteady flow files before running the simulation.
|
137
|
+
Ensemble Forecasting: Generate multiple forecasts by incorporating uncertainty in input data and model parameters. This provides a more comprehensive understanding of potential future flow conditions.
|
138
|
+
3. Scenario Analysis:
|
139
|
+
Land Use Change Impacts: Evaluate the effects of land use changes on flood risk by modifying Manning's n values using extract_2d_mannings_tables, modify_2d_mannings_table, and write_2d_mannings_tables and running simulations with updated geometry files.
|
140
|
+
Climate Change Impacts: Analyze the potential impacts of projected climate changes on flood risk by adjusting precipitation patterns and other relevant parameters in unsteady flow files.
|
141
|
+
4. Batch Processing and High-Performance Computing:
|
142
|
+
Large-scale Model Runs: Utilize run_plans_parallel to execute multiple simulations concurrently on a multi-core system, significantly reducing processing time for large-scale models or complex scenarios.
|
143
|
+
Automated Report Generation: Integrate with Python libraries like matplotlib and bokeh to automatically generate customized reports summarizing simulation results, including tables, figures, and maps.
|
144
|
+
5. Model Development and Testing:
|
145
|
+
Rapid Prototyping: Quickly set up and run new model configurations using template files and automated workflows, facilitating rapid model development and testing.
|
146
|
+
Regression Testing: Ensure model integrity and consistency after code changes or updates by automatically running a predefined set of simulations and comparing results with expected outputs.
|
147
|
+
6. User-Friendly Interfaces:
|
148
|
+
GUI Development: Integrate with Python GUI libraries like Tkinter or PyQt to create user-friendly interfaces for automating HEC-RAS workflows, allowing non-programmers to access the power of automation.
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
Certainly! I'll create an updated README.md for the ras_commander library, incorporating the information you've provided and the context from the previous HEC-Commander tools. Here's the updated README.md:
|
156
|
+
|
157
|
+
```markdown
|
158
|
+
# ras_commander
|
159
|
+
|
160
|
+
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 is an evolution of the RAS-Commander 1.0 Python Notebook Application previously released under the HEC-Commander tools.
|
161
|
+
|
162
|
+
## Features
|
163
|
+
|
164
|
+
- Automate HEC-RAS project management and simulations
|
165
|
+
- Support for both single and multiple project instances
|
166
|
+
- Parallel execution of HEC-RAS plans
|
167
|
+
- Utilities for managing geometry, plan, and unsteady flow files
|
168
|
+
- Example project management for testing and development
|
169
|
+
- Two primary operation modes: "Run Missing" and "Build from DSS"
|
170
|
+
|
171
|
+
## Installation
|
172
|
+
|
173
|
+
Install ras_commander using pip:
|
174
|
+
|
175
|
+
```bash
|
176
|
+
pip install ras_commander
|
177
|
+
```
|
178
|
+
|
179
|
+
## Requirements
|
180
|
+
|
181
|
+
- Python 3.9+
|
182
|
+
- HEC-RAS 6.5 (other versions may work but are not officially supported)
|
183
|
+
|
184
|
+
For a full list of dependencies, see the `requirements.txt` file.
|
185
|
+
|
186
|
+
## Quick Start
|
187
|
+
|
188
|
+
```python
|
189
|
+
from ras_commander import init_ras_project, RasCommander, RasPlan
|
190
|
+
|
191
|
+
# Initialize a project
|
192
|
+
init_ras_project("/path/to/project", "6.5")
|
193
|
+
|
194
|
+
# Execute a single plan
|
195
|
+
RasCommander.compute_plan("01")
|
196
|
+
|
197
|
+
# Execute plans in parallel
|
198
|
+
results = RasCommander.compute_parallel(
|
199
|
+
plan_numbers=["01", "02"],
|
200
|
+
max_workers=2,
|
201
|
+
cores_per_run=2
|
202
|
+
)
|
203
|
+
|
204
|
+
# Modify a plan
|
205
|
+
RasPlan.set_geom("01", "02")
|
206
|
+
```
|
207
|
+
|
208
|
+
## Key Components
|
209
|
+
|
210
|
+
- `RasPrj`: Manages HEC-RAS projects
|
211
|
+
- `RasCommander`: Handles execution of HEC-RAS simulations
|
212
|
+
- `RasPlan`: Provides functions for modifying and updating plan files
|
213
|
+
- `RasGeo`: Handles operations related to geometry files
|
214
|
+
- `RasUnsteady`: Manages unsteady flow file operations
|
215
|
+
- `RasUtils`: Contains utility functions for file operations and data management
|
216
|
+
- `RasExamples`: Manages and loads HEC-RAS example projects
|
217
|
+
|
218
|
+
## Documentation
|
219
|
+
|
220
|
+
For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
|
221
|
+
|
222
|
+
## Examples
|
223
|
+
|
224
|
+
Check out the `examples/` directory for sample scripts demonstrating various features of ras_commander.
|
225
|
+
|
226
|
+
## Development
|
227
|
+
|
228
|
+
### Setting up the development environment
|
229
|
+
|
230
|
+
1. Clone the repository:
|
231
|
+
```
|
232
|
+
git clone https://github.com/yourusername/ras_commander.git
|
233
|
+
```
|
234
|
+
2. Create a virtual environment and activate it:
|
235
|
+
```
|
236
|
+
python -m venv venv
|
237
|
+
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
|
238
|
+
```
|
239
|
+
3. Install the development dependencies:
|
240
|
+
```
|
241
|
+
pip install -r requirements.txt
|
242
|
+
```
|
243
|
+
Certainly! I'll provide an updated Project Organization Diagram based on the current structure of the ras_commander library. Here's the updated diagram:
|
244
|
+
|
245
|
+
|
246
|
+
## Project Organization Diagram
|
247
|
+
|
248
|
+
```
|
249
|
+
ras_commander
|
250
|
+
├── .github
|
251
|
+
│ └── workflows
|
252
|
+
│ └── python-package.yml
|
253
|
+
├── ras_commander
|
254
|
+
│ ├── __init__.py
|
255
|
+
│ ├── RasCommander.py
|
256
|
+
│ ├── RasExamples.py
|
257
|
+
│ ├── RasGeo.py
|
258
|
+
│ ├── RasPlan.py
|
259
|
+
│ ├── RasPrj.py
|
260
|
+
│ ├── RasUnsteady.py
|
261
|
+
│ └── RasUtils.py
|
262
|
+
├── examples
|
263
|
+
│ ├── 01_project_initialization.py
|
264
|
+
│ ├── 02_plan_operations.py
|
265
|
+
│ ├── 03_geometry_operations.py
|
266
|
+
│ ├── 04_unsteady_flow_operations.py
|
267
|
+
│ ├── 05_utility_functions.py
|
268
|
+
│ ├── 06_single_plan_execution.py
|
269
|
+
│ ├── 07_sequential_plan_execution.py
|
270
|
+
│ ├── 08_parallel_execution.py
|
271
|
+
│ ├── 09_specifying_plans.py
|
272
|
+
│ ├── 10_arguments_for_compute.py
|
273
|
+
│ ├── 11_Using_RasExamples.ipynb
|
274
|
+
│ ├── 12_plan_set_execution.py
|
275
|
+
│ └── 13_multiple_project_operations.py
|
276
|
+
├── tests
|
277
|
+
│ └── ... (test files)
|
278
|
+
├── .gitignore
|
279
|
+
├── LICENSE
|
280
|
+
├── README.md
|
281
|
+
├── STYLE_GUIDE.md
|
282
|
+
├── Comprehensive_Library_Guide.md
|
283
|
+
├── pyproject.toml
|
284
|
+
├── setup.cfg
|
285
|
+
├── setup.py
|
286
|
+
└── requirements.txt
|
287
|
+
|
288
|
+
|
289
|
+
## Inclusion of .cursorrules for AI-driven Coding Experience
|
290
|
+
|
291
|
+
Open the ras_commander folder in the Cursor IDE, and it will automatically include the .cursorrules file in your instructions. Additionally, two other provided methods for interacting with the library though your current AI subscriptions:
|
292
|
+
|
293
|
+
- ChatGPT: ras_commander GPT Assistant (LINK HERE)
|
294
|
+
- Latest LLM summaries of the code base:
|
295
|
+
- Entire code base: LINK HERE (TOKEN COUNT) (for Claude or Gemini)
|
296
|
+
- Examples and Function Docstrings Only: LINK HERE (TOKEN COUNT) (for GPT-4o, o1 or Llama 3.1 405b)
|
297
|
+
- Cursor IDE through .cursorrules file
|
298
|
+
|
299
|
+
There are a series of scripts provided in the "llm_summaries" folder that provide summaries of the code base, and the docstrings of the functions. They can be run in your local environment, or provided to ChatGPT's code interpreter for execution.
|
300
|
+
|
301
|
+
## RAS-Commander GPT Assistant
|
302
|
+
|
303
|
+
The ras_commander GPT assistant has access the entire code base, and can be a helpful tool for understanding the library and its capabilities. However, it is subject to the same context window limitations and file retrieval limtations as I have covered in ADD BLOG LINK HERE. For best results, use the llm summaries above to provide robust context to the model before asking to generate complex workflows.
|
304
|
+
|
305
|
+
## Contributing
|
306
|
+
|
307
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
308
|
+
|
309
|
+
## Style Guide
|
310
|
+
|
311
|
+
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.
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
## License
|
317
|
+
|
318
|
+
ras_commander is released under the MIT License. See the license file for details.
|
319
|
+
|
320
|
+
## Acknowledgments
|
321
|
+
|
322
|
+
ras_commander is based on the HEC-Commander project's "Command Line is All You Need" approach, leveraging the HEC-RAS command-line interface for automation. The initial development of this library was presented in the HEC-Commander Tools repository. In a 2024 Australian Water School webinar, Bill demonstrated the derivation of basic HEC-RAS automation functions from plain language instructions. Leveraging the previously developed code and AI tools, the library was created. The primary tools used for this initial development were Anthropic's Claude, GPT-4o, Google's Gemini Experimental models,and the Cursor AI Coding IDE.
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
## Contact
|
327
|
+
|
328
|
+
For questions, suggestions, or support, please contact:
|
329
|
+
William Katzenmeyer, P.E., C.F.M. - billk@fenstermaker.com
|