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 structuresRasCmdr- Plan execution (single, parallel, sequential)RasPlan- Plan file operationsRasFlowOptimization- Native HEC-RAS flow hydrograph optimization settings and trial resultsRasGeo- Geometry file operationsRasUnsteady- Unsteady flow file managementRasSteady- Steady flow file authoring and parsingRasUtils- Utility functionsRasExamples- Example project managementRasMap- RASMapper configuration, layer discovery, and geometry HDF associationsRasProcess- RasProcess.exe CLI automation, stored maps, and native reference validatorsRasControl- Legacy COM interface
HDF Modules¶
Classes for reading HDF result files:
HdfBase- Core HDF operationsHdfPlan- Plan informationHdfMesh- Mesh geometryHdfResultsMesh- 2D mesh resultsHdfResultsPlan- Plan-level resultsHdfResultsXsec- 1D cross-section resultsHdfStruc- Structure dataHdfResultsBreach- Dam breach resultsHdfHydraulicTables- Cross section HTAB dataHdfStorageArea- Storage area volume-elevation curvesHdfChannelCapacity- 1D channel capacity analysisHdfStruc1D- 1D inline structure dataHdfPipe- Pipe network analysisHdfPump- Pump station analysis
Geometry Modules¶
Classes for parsing and authoring geometry files:
RasGeometry- Cross sections, storage, connectionsGeomCrossSection- Cross-section builder and blocked obstructionsGeomBridge- Bridge geometry authoringGeomBcLines- 2D boundary condition line authoringGeomLateral- Lateral structure parsingGeomStorage- Storage area and 2D flow area writingGeomLevee- Levee read/writeRasGeometryUtils- Parsing utilitiesRasStruct- Inline structuresRasBreach- Breach parameters
Terrain Modules¶
Classes for terrain creation, modification writing, and terrain-modification analysis:
RasTerrain- Terrain HDF creation from rastersRasTerrainModWriter/RasTerrainModification- Line and polygon terrain modification HDF/.rasmap writingRasTerrainMod- Terrain profile and volume comparison with modifications applied
Fixit Module¶
Automated geometry repair:
RasFixit- Fix blocked obstruction overlapsFixResults- Fix operation resultslog_parser- HEC-RAS log parsing for error detection
DSS Modules¶
Classes for reading DSS files:
RasDss- DSS file operations
Remote Modules¶
Classes for distributed execution:
LocalWorker- Local parallel executionPsexecWorker- Windows remote executionDockerWorker- Container executioninit_ras_worker- Factory functioncompute_parallel_remote- Distributed execution
Usage Pattern¶
All primary classes use static methods:
# 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:
@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:
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.
Enable debug logging to see these messages: