A library for automating HEC-RAS operations using python functions.
Project description
RAS-Commander (ras_commander)
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.
Features
- Automate HEC-RAS project management and simulations
- Support for both single and multiple project instances
- Parallel execution of HEC-RAS plans
- Utilities for managing geometry, plan, and unsteady flow files
- Example project management for testing and development
- Two primary operation modes: "Run Missing" and "Build from DSS"
Installation
Install ras_commander using pip:
pip install ras-commander
Requirements
- Python 3.9+
- HEC-RAS 6.2 or later (other versions may work, all testing was done with version 6.2 and above)
For a full list of dependencies, see the requirements.txt file.
Quick Start
from ras_commander import init_ras_project, RasCommander, RasPlan
# Initialize a project
init_ras_project("/path/to/project", "6.5")
# Execute a single plan
RasCommander.compute_plan("01")
# Execute plans in parallel
results = RasCommander.compute_parallel(
plan_numbers=["01", "02"],
max_workers=2,
cores_per_run=2
)
# Modify a plan
RasPlan.set_geom("01", "02")
Key Components
RasPrj: Manages HEC-RAS projectsRasCommander: Handles execution of HEC-RAS simulationsRasPlan: Provides functions for modifying and updating plan filesRasGeo: Handles operations related to geometry filesRasUnsteady: Manages unsteady flow file operationsRasUtils: Contains utility functions for file operations and data managementRasExamples: Manages and loads HEC-RAS example projects
Documentation
For detailed usage instructions and API documentation, please refer to the Comprehensive Library Guide.
Examples
Check out the examples/ directory for sample scripts demonstrating various features of ras_commander.
Development
Setting up the development environment
- Clone the repository:
git clone https://github.com/yourusername/ras_commander.git - Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` - Install the development dependencies:
pip install -r requirements.txt
Certainly! I'll provide an updated Project Organization Diagram based on the current structure of the ras_commander library. Here's the updated diagram:
Project Organization Diagram
ras_commander
├── .github
│ └── workflows
│ └── python-package.yml
├── ras_commander
│ ├── __init__.py
│ ├── RasCommander.py
│ ├── RasExamples.py
│ ├── RasGeo.py
│ ├── RasPlan.py
│ ├── RasPrj.py
│ ├── RasUnsteady.py
│ └── RasUtils.py
├── examples
│ ├── 01_project_initialization.py
│ ├── 02_plan_operations.py
│ ├── 03_geometry_operations.py
│ ├── 04_unsteady_flow_operations.py
│ ├── 05_utility_functions.py
│ ├── 06_single_plan_execution.py
│ ├── 07_sequential_plan_execution.py
│ ├── 08_parallel_execution.py
│ ├── 09_specifying_plans.py
│ ├── 10_arguments_for_compute.py
│ ├── 11_Using_RasExamples.ipynb
│ ├── 12_plan_set_execution.py
│ └── 13_multiple_project_operations.py
├── tests
│ └── ... (test files)
├── .gitignore
├── LICENSE
├── README.md
├── STYLE_GUIDE.md
├── Comprehensive_Library_Guide.md
├── pyproject.toml
├── setup.cfg
├── setup.py
└── requirements.txt
Inclusion of .cursorrules and ai_tools for AI-driven Coding Experience
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:
- ChatGPT: ras_commander GPT Assistant (LINK HERE)
- Latest LLM summaries of the code base:
- Entire code base: LINK HERE (TOKEN COUNT) (for Claude or Gemini)
- Examples and Function Docstrings Only: LINK HERE (TOKEN COUNT) (for GPT-4o, o1 or Llama 3.1 405b)
- Cursor IDE through .cursorrules file
- 'rascommander_code_assistant.ipynb' notebook in the ras_commander folder, which allows for dynamic summarization of the code base and API chatting directly through the notebook.
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.
RAS-Commander GPT Assistant
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.
Contributing
We welcome contributions! Please see our Contributing Guide for details on how to submit pull requests, report issues, and suggest improvements.
Style Guide
This project follows a specific style guide to maintain consistency across the codebase. Please refer to the Style Guide for details on coding conventions, documentation standards, and best practices.
License
ras_commander is released under the MIT License. See the license file for details.
Acknowledgments
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.
Contact
For questions, suggestions, or support, please contact: William Katzenmeyer, P.E., C.F.M. - billk@fenstermaker.com
NOTES: INCORPORATE INTO THE README.MD FILE ABOVE UNDER A NEW SECTION FOR CURRENT USES AND ROADMAP ITEMS, THEN DELETE THIS NOTE
Potential Uses of HEC-RAS Automation Functions This set of functions provides a powerful foundation for automating various aspects of HEC-RAS modeling workflows. Here are some potential applications:
- Calibration and Sensitivity Analysis: 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. 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.
- Real-time Forecasting: 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. 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.
- Scenario Analysis: 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. 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.
- Batch Processing and High-Performance Computing: 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. Automated Report Generation: Integrate with Python libraries like matplotlib and bokeh to automatically generate customized reports summarizing simulation results, including tables, figures, and maps.
- Model Development and Testing: Rapid Prototyping: Quickly set up and run new model configurations using template files and automated workflows, facilitating rapid model development and testing. 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.
- User-Friendly Interfaces: 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ras_commander-0.23.0.dev0.tar.gz.
File metadata
- Download URL: ras_commander-0.23.0.dev0.tar.gz
- Upload date:
- Size: 207.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
360458d9adb5cb70ad8da0847565dde1e9357249f7b448176cfd315d35d0a9d7
|
|
| MD5 |
9a349ad1494f1f7016b74aec38d6db42
|
|
| BLAKE2b-256 |
c214ae14ea281f3cd0ad95ac477510242323547002d7ede7cd97f816d63af042
|
File details
Details for the file ras_commander-0.23.0.dev0-py2.py3-none-any.whl.
File metadata
- Download URL: ras_commander-0.23.0.dev0-py2.py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e321293e42d04640b502cd13135ddd5f757924373759dedfaa844da6a10c793c
|
|
| MD5 |
dc69e67fb8999cc33235bcbcaa9be9e7
|
|
| BLAKE2b-256 |
1fc6a31f9dd60e80ef8002f5216db77e003df3535f80d03f46e0e155328ff55f
|