Skip to content

Explanation of the Base Scripts ras2fim

HeidiSafa-NOAA edited this page Apr 4, 2024 · 90 revisions

Base Scripts Explanation ras2fim agency

ras2fim logo Script name: ras2fim.py

RAS2FIM is computed from a base orchestration python script named ras2fim.py. This script kicks off eight (8) steps in a serial process to create the desired RAS2FIM depth grids and rating curves. An explanation of these scripts is detailed below. Please note that each of these scripts was written such that it could run in a stand-alone mode. An overview of the use of each script is provided below.

workflow


#1 - Create Shapes From HEC-RAS

Script name: create_shapes_from_hecras.py

The user provides a path to a directory containing HEC-RAS model files. This routine walks the directory and finds all the HEC-RAS projects (.prj). It determines the geometry that is set in the active HEC-RAS plan of each project. If a corresponding HEC-RAS Hierarchical Data Format (g01.hdf) of the geometry does not exist, the script will compute the active HEC-RAS plan so that one is generated. After running all the models, stream centerlines and cross-section vector geometries, and attribute data are read from the HDF files. These data are merged into two shapefiles, named stream_LN_from_ras.shp and cross_section_LN_from_ras.shp.

Step1

Note: Considerations create_shapes_from_hecras.py :

  • All models must be on the same coordinate reference system (CRS)
  • If a HEC-RAS model has multiple reaches and rivers - only the first (main) reach/river is extracted

#2 - Conflate HEC-RAS Rivers to National Water Model Streams

Script name: conflate_hecras_to_nwm.py

The National Water Model defines rivers and streams within the contiguous United States (CONUS) through the assignment of a unique numeric code known as a feature-id. Within CONUS there are currently approximately 2.7 million stream-reaches defined. The National Water Model configurations calculate stream flows for each of these reaches.

This script determines what portion of the user-provided HEC-RAS models best represents each of the National Water Model streams within the subject HUC-8 watershed. This is determined by:

  1. Clipping the National Water Model (NWM) streams to the subject HUC-8 watershed boundary
  2. Setting and attributing points on clipped NWM streams at a regular interval (default = 150 feet)
  3. Read the stream centerline shapefile for all the HEC-RAS models.
  4. Buffer the HEC-RAS stream centerline (default = 600 ft) and delete NWM stream points that are not within this buffer
  5. Snap the remaining points to the HEC-RAS streamlines and retain NWM feature-id attributes.
  6. Rank and determine the HEC-RAS model with the most snapped feature-id points
  7. Determine the starting and ending HEC-RAS cross-section for the most popular HEC-RAS model for each feature-id
  8. Create a CSV lookup XXXXXXXX_stream_qc.csv where XXXXXXXX is the HUC-8. The CSV file Contains feature-id, conflated HEC-RAS models path, cross-section station limits, and peak flow rate from the HEC-RAS model.
  9. Creates a CSV lookup conflated_ras_models.csv containing conflated HEC-RAS models path, corresponding model_IDs and key_model_names from OWP_ras_models_catalog.

Step2

Note: Considerations conflate_hecras_to_nwm.py :

  • Conflation may return the wrong HEC-RAS model. Check the XXXXXXXX_interim_list_of_streams.csv for matches with low counts of snapped points
  • Two HEC-RAS models may 'split' a feature-id. The most popular wins, however a portion of each HEC-RAS model may be more correct. RAS2FIM simply picks the most popular and ignores the other.
  • Confluences are the most likely area for a false snap.

#3 - Clip Terrain Data for conflated HEC-RAS Models

Script name: clip_dem_from_shape.py

This script creates a GeoTIFF for each conflated HEC-RAS model. For flood inundation mapping, a raster digital elevation model (DEM) is required for the floodplain. For RAS2FIM, the terrain is compiled on a HUC-12 watershed basis. The script reads the cross-section shapefile for each conflated HEC-RAS model, and identifies all HUC-12s that intersect with the cross-sections. It then merges the intersected HUC-12s and assigns a name based on the model ID.

The user should supply a path to a terrain surface which will be used for the creation of the flood depth grids. Note that this surface is not used to alter or modify the supplied HEC-RAS models. It is only used for flood depth delineation. These surface data need to be in the same coordinate reference system (CRS) as the provided HEC-RAS models. The user-supplied terrain can be either a GeoTIFF or a Virtual Raster (VRT). Vertical data is converted to feet if the user specifies that HEC-RAS models are in English (SI) units.

Step3


#4 - Convert Terrain GeoTIFF to HEC-RAS Terrains (HDF5)

Script name: convert_tif_to_ras_hdf5

For the terrain to be used automatically with HEC-RAS, each generated GeoTIFF will need to be converted to a HEC-RAS compliant HDF5 file. This script creates the files using a command line interface with the RasProcess.exe that is packaged and installed with HEC-RAS.


#5 - Create Depth Grids

Script names: worker_fim_rasters and create_fim_rasters

This is where the bulk of the RAS2FIM workflow is performed. The conflated 1D HEC-RAS models are executed using their original boundary conditions (BCs) of Water Surface Elevation (WSE) or Normal Depth (ND).

A first pass steady flow file is created for each HEC-RAS model. The script is hard coded to multiply the provided peak discharge at each flow change location by 1.2 and split that resulting value into 76 flow values. For example, a flow of 5100 cfs at the inlet of Buckners Creek, TX, is broken into flow values at an interval of 68 cfs. Then, a depth is simulated for each cross-section across the HEC-RAS model streamline for 75 flow values, starting with 1 cfs [1 cfs, 69 cfs, 137 cfs … 4964 cfs, 5032 cfs, 5100 cfs]** and a 'first-pass rating curve' is determined for each cross-section.

From the first-pass depth values, a cross-section that has the highest depth is selected and the highest depth is divided into 0.5-foot intervals. For instance, a highest depth of 65 feet in Buckners Creek is broken into [0.5, 1, 1.5, … 64, 64.5, 65 feet] depth values. From the first-pass rating curve for the highest-depth cross-section, flows are interpolated at points where it is assumed that the HEC-RAS model will compute flood depths at the desired depth intervals (here at 0.5 foot). The interpolated flows are called second-pass flow.

Step5_Flows

From these interpolated flow values, a revised flow file and a RAS Mapper file are created and finally, HEC-RAS is recomputed for all second-pass flow values. RAS Mapper file requests a flood inundation grid be generated for each depth interval at approximately every 0.5 feet. Note that for all HEC-RAS simulations, all flow is assumed to be sub-critical.

Step5_DepthGrids

Step5_DepthGrids

Note: Considerations worker_fim_rasters.py :

  • This script currently only processes HEC-RAS models that utilize Water Surface Elevation (WSE) or Normal Depth (ND) as boundary conditions (BCs). Support for two less common boundary conditions, "Critical Depth" and "Rating Curve," will be included in future versions of RAS2FIM.

#6 - Create Rating Curves

Script names: create_rating_curves

This step creates synthetic rating curves for each NWM feature-ids (reaches) using one of the outputs of step 5, all_x_sections_info_2nd_XXXXX_YYY.csv which XXXXX is the model-id and YYY is the model name. This file is created for each conflated RAS model and has flow, depth(stage), and water surface elevation, for each cross-section across the model. In the conflation output XXXXXXXX_stream_qc_fid_xs.csv in step #2, on the other hand, each National Water Model (NWM) feature-id that conflates to an HEC-RAS model is associated with the (1) path to the corresponding HEC-RAS model [ras_path], (2) the cross-section limits including upstream [us-xs] and downstream [ds-xs] XSs and (3) the peak flow rate for the profiles within these cross sections [peak_flow]. us-xs and ds-xs cross sections are the spatial limits that approximate the conflated limits of the NWM feature-id (reach). Using these two outputs of the conflation step (step 2) and the fim raster step (step 5), reach averaged values for second-pass flows and depths are calculated for each NWM feature-id (reach). Then, rating curves are created for each NWM feature-id (reach)

For example, feature-id #5791020 conflates to the Buckners Creek model between cross sections 82646 and 65980 with a peak discharge of 173,000 cfs.

Step5

Step 5 output of the Buckners Creek HEC-RAS model between cross sections 82646 and 65980 is reach-averaged for the 5791020 feature-id and the rating curve is created.

Step5_Clip_RAS


#7 - Calculate Terrain Statistics

Script names: calculate_all_terrain_stats (optional)

RAS Mapper will delineate any terrain that is provided. It does not determine that the terrain on which the delineation is performed matches the cross-section vertical point data. It is possible that the terrain that is harvested in step #3 from the USGS 3DEP does not match or have the same accuracy as the terrain used to create the provided HEC-RAS models. This script calculates each 'clipped' (step #5) HEC-RAS model and determines the vertical difference between the terrain and the model.

After the completion of the RAS2FIM workflow, it is advised that a maximum threshold for the median, mean and standard deviation of the vertical error be evaluated on each run. If the error is too great, then it is further advised that the flood inundation rasters be disregarded. If this is the case, it would be a good idea to locate a better alternative terrain source that more closely matches the provided HEC-RAS geometry.

This script creates a point at every station-elevation pair along every cross-section in a HEC-RAS model. At each point, the elevation in the model is compared to the elevation of the terrain digital elevation model (DEM). The difference in these points is aggregated on a 'per model' basis and statistics are reported for each model.

Step5_DepthGrids


#8 - Create Geo Rating Curves

Script names: create_geocurves (optional)

Step5_DepthGrids