Skip to content

API Reference

This section provides documentation for the RAS Commander Python API.

Core Classes

Primary classes for project management and execution:

  • RasPrj - Project management and data structures
  • RasCmdr - Plan execution (single, parallel, sequential)
  • RasPlan - Plan file operations
  • RasFlowOptimization - Native HEC-RAS flow hydrograph optimization settings and trial results
  • RasGeo - Geometry file operations
  • RasUnsteady - Unsteady flow file management
  • RasSteady - Steady flow file authoring and parsing
  • RasUtils - Utility functions
  • RasExamples - Example project management
  • RasMap - RASMapper configuration, layer discovery, and geometry HDF associations
  • RasProcess - RasProcess.exe CLI automation, stored maps, and native reference validators
  • RasControl - Legacy COM interface

HDF Modules

Classes for reading HDF result files:

Geometry Modules

Classes for parsing and authoring geometry files:

Terrain Modules

Classes for terrain creation, modification writing, and terrain-modification analysis:

  • RasTerrain - Terrain HDF creation from rasters
  • RasTerrainModWriter / RasTerrainModification - Line and polygon terrain modification HDF/.rasmap writing
  • RasTerrainMod - Terrain profile and volume comparison with modifications applied

Fixit Module

Automated geometry repair:

DSS Modules

Classes for reading DSS files:

  • RasDss - DSS file operations

Remote Modules

Classes for distributed execution:

Usage Pattern

All primary classes use static methods:

Python
# No instantiation needed
from ras_commander import RasCmdr, RasPlan

# Direct static method calls
RasCmdr.compute_plan("01")
RasPlan.set_num_cores("01", 4)

Decorators

RAS Commander uses two key decorators that affect method behavior:

@standardize_input

Automatically converts various input types to the correct HDF file path. This decorator is applied to all HDF methods.

Accepted Input Types:

Input Type Example Behavior
Plan number (str) "01", "p01" Looks up HDF path in ras.plan_df
Plan number (int) 1, 2 Converted to string, then lookup
Path object Path("x.hdf") Used directly if file exists
String path "/path/to.hdf" Converted to Path, used directly
h5py.File hdf_file Extracts filename from object

file_type Parameter:

Python
@standardize_input(file_type='plan_hdf')  # Default - looks for .p##.hdf
@standardize_input(file_type='geom_hdf')  # Looks for .g##.hdf
@standardize_input(file_type='plan')      # Looks for .p## (plain text)

Usage Examples:

Python
from ras_commander import HdfResultsMesh, init_ras_project

init_ras_project("/path/to/project", "6.5")

# All of these are equivalent:
HdfResultsMesh.get_mesh_max_ws("01")           # Plan number string
HdfResultsMesh.get_mesh_max_ws(1)              # Integer
HdfResultsMesh.get_mesh_max_ws("p01")          # With 'p' prefix
HdfResultsMesh.get_mesh_max_ws(Path("x.hdf"))  # Path object
HdfResultsMesh.get_mesh_max_ws("/path/to.hdf") # String path

Project Initialization Required

When using plan/geometry numbers (not direct paths), you must first call init_ras_project() to populate the ras.plan_df lookup table.

@log_call

Automatic logging decorator applied to most methods. Logs function entry/exit at DEBUG level.

Python
@log_call
def my_function():
    ...

# Logs: "Calling my_function"
# Logs: "Finished my_function"

Enable debug logging to see these messages:

Python
import logging
logging.getLogger('ras_commander').setLevel(logging.DEBUG)
CLB Engineering Corporation  ·  LLM Forward Engineering
RAS Commander is a free and open-source project maintained by CLB Engineering Corporation. For agencies and firms seeking to modernize H&H workflows with LLM Forward approaches, contact CLB to partner with the engineers who wrote the automation.