Skip to content

a Python toolbox for the RAPID (Routing Application for Parallel computatIon of Discharge) model.

License

Notifications You must be signed in to change notification settings

erdc/python-toolbox-for-rapid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAPID Tools

This repository houses a Python toolbox of tools for preprocessing inputs and postprocessing outputs of the RAPID (Routing Application for Parallel computation of Discharge) model. To find out more about RAPID, please visit http://rapid-hub.org/.

Getting Started

alt tag

  • In order to use the Preprocessing tools, you will need to have the following inputs available:

    • Drainage Line and Catchment feature classes for the watersheds of interests. To learn about how to create them, please refer to the workflow of Basic Dendritic Terrain Processing with ArcHydro tools.
    • For WRF-Hydro, you will need both its geogrid file and runoff file; for ECMWF, you will need only the runoff file.

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

Tools

The tools are organized into four toolsets. One for preprocessing and preparing the input datasets for RAPID. The second is for generating calibrated values for the Muksingum Paremeters. The third is for doing some postprocessing especially for visualizing the RAPID output of stream flow. The fourth toolset has some utilities to assist you with the workflow and sharing the visualization as web map service.

Calibration Tools

  • Create Muksingum Kfac File

    This tool is used to generate values of Kfac based on the flow wave celerity (Co) for the basin as well as length and slope of each stream reach.

    There are three options:

    1. River Length/Co
    2. Eta*River Length/Sqrt(River Slope)
    3. Eta*River Length/Sqrt(River Slope) [0.05, 0.95] - this option filters out slopes outside the 5th and 95th percentiles.

    Note: Eta = Average(River Length/Co of all rivers) / Average(River Length/Sqrt(River Slope) of all rivers)

  • Create Muksingum K File

    Using lambda, this tool modifies each of the Kfac values by multiplying by lambda and generates the calibrated Muskgingum K file (e.g. k.csv). The value for lambda is obtained by running the calibration routine in RAPID for your simulation.

  • Create Muksingum X Field

    This tool adds or updates the Musk_x field to the drainage line and sets the value to the input provided by the user (Default is 0.3). If a shapefile with reservoirs is given, then it will set the value to "0" where it intersects the drainage line.

  • Create Muksingum X File

    This tool generates the Muskingum X file based on the Musk_x field in the drainage lines.

Preprocessing Tools

  • Create Connectivity File

    This tool creates the stream network connectivity file based on two fields in the input Drainage Line feature class: HydroID, and NextDownID. It does the following:

    1. Finds the HydroID of each stream.
    2. Counts the total number of its upstreams.
    3. Writes the stream HydroID, the total number of its upstreams, and the HydroID(s) of all upstream(s) into the output file. The records are sorted in the ascending order based on the stream HydroID.
  • Create Connectivity File NHDPlus

    This tool creates the stream network connectivity file based on four fields in the input Drainage Line feature class: COMID, FROMNODE, TONODE, DIVERGENCE. It does the following:

    1. Disconnects streams with divergence greater than 1.
    2. Creates NextDownID based on COMID, FROMNODE, and TONODE fields.
    3. Runs the Create Connectivity File tool with updated fields.
  • Create Subset File

    This tool writes the HydroID of a subset of the stream features. The subset is created by selecting stream features in the input layer.

  • Create Muskingum Parameters File

    This tool writes the values of the Muskingum parameter fields (Musk_kfac, Musk_k, and Musk_x) into individual parameter files. The three fields can be calculated using the Calculate Muskingum Parameters tool in the ArcHydro toolbox. The records in all files are sorted in the ascending order based on the stream HydroID.

  • Create Weight Table From ECMWF/WRF-Hydro Runoff

    This tool creates a table that represents the runoff contribution of the ECMWF/WRF-Hydro computational grid to the catchment. It requires that the input Catchment feature class has a drainage line ID field that corresponds to the HydroID of the Drainage Line feature class. If your input Catchment feature class does not have that field, you can use the Add DrainLnID to Catchment tool in the ArcHydro toolbox. This tool does the following:

    For ECMWF,

    1. Creates computational grid point feature class based on the latitude and longitude in the ECMWF runoff file.
    2. Creates Thiessen polygons from the computational grid points. The Thiessen polygons represent computational grids.

    For WRF-Hydro,

    1. Creates a raster based on the spatial resolution, extent, and projection information in the WRF geogrid file.
    2. Creates fishnet polygons and points based on the raster. The polygons and points represent the computational grids and points.

    Then for both,

    1. Intersects the computational polygons with the input catchments.
    2. Calculates the geodesic area for each intersected polygon.
    3. Calculates the area ratio of each intersected polygon to its corresponding catchment, which is defined as the weight representing the contribution of the computational grid to the catchment (drainage line segment).
    4. Writes the stream ID, the coordinates of the contributing computational grid, the contributing area, and the weight, etcetera, into the weight table.

The records in the weight table are sorted in the ascending order based on the stream ID.

  • Update Weight Table

    This tool updates the weight table specifically for the scenario in which the Drainage Line and the Catchment features are not one-to-one relationship. It does the following to the weight table:

    1. Removes the rows with stream IDs that don’t have a match in the Drainage Line feature class.
    2. Adds rows with stream IDs that are in the Drainage Line but not in the Catchment feature class. In these newly added rows, the contributing area and the weight are given values of 0. And the "npoints" (number of points) column that represents the total number of computational grids contributing to the same catchment is given the value of 1.
  • Create Inflow File From ECMWF/WRF-Hydro Runoff

    This tool creates the RAPID inflow file from ECMWF / WRF-Hydro runoff data. It does the following:

    1. Obtains a list of stream IDs based on the input drainage line feature class.
    2. For each stream feature, obtains the information of all contributing computational grids from the weight table.
    3. Calculates the runoff to each stream feature based on the computational-grid-specific runoff rates from the ECMWF / WRF-Hydro runoff data file and the contributing areas from the weight table.
    4. If a stream ID does not have a corresponding record in the weight table, specifies its runoff as 0.
    5. Writes the runoff data into the inflow file in netCDF format.

Postprocessing Tools

  • Create Discharge Table

    This tool creates a discharge table converted from the RAPID discharge file. In the discharge table, each row contains the information of COMID (an ID field of the NHDPlus dataset), time, and the discharge of the stream at the time step. Time in date/time format is calculated based on the start date and time input by the user and the time dimension of the stream flow variable in the RAPID discharge file. Attribute indexes are added respectively for COMID, and the time fields in the table. The discharge table is saved in a SQL Server geodatabase or a file geodatabase.

  • Create Discharge Map

    This tool creates a map document with time-enabled stream flow layer(s) showing stream- and time-specific discharge amounts. Stream flow can be animated in the discharge map. The tool does the following:

    1. If the layer information is not specified, all stream features that have records in the discharge table will be copied into the same geodatabase where the discharge table is. If the layer information is specified, based on the information of minimum stream order for each layer, stream features are selected using the query definition of stream order >= the minimum, then the selected stream features are copied into the same geodatabase where the discharge table is.
    2. Creates a map document and add all the copied stream feature classes into the map.
    3. For each layer, adds a join to the discharge table based on COMID as the join field.
    4. For each layer, defines the minScale and maxScale based on the user-specified information.
    5. Applies symbology to each layer based on the same template layer file. Note that the layers of data in SQL Server geodatabase and file geodatabase have different templates.
    6. Updates the time properties for each layer based on the time-enabled template.
  • Update Discharge Map

    This tool updates the existing map document by applying symbology from a template layer file to the layer(s) in the map document. The tool is run only if the discharge table has been updated.

Utilities Tools

  • Add Streamflow Prediction Tool Fields

    This tool adds the fields required to be used in the Streamflow Prediction Tool web application (https://github.com/erdc/tethysapp-streamflow_prediction_tool).

  • Create rivid gage file

    This tool writes the file with rivid and gage ids used in the Streamflow Prediction Tool forecast framework for data assimilation (https://github.com/erdc/spt_ecmwf_autorapid_process).

  • Copy Data To Server

    This tool copies the discharge table, the drainage line features, or both to the ArcGIS server machine from the author/publisher machine.

  • Flowline to Point

    This tool writes the centroid coordinates of flowlines into a CSV file.

  • Publish Discharge Map

    This tool publishes a discharge map service of stream flow visualization to an ArcGIS server.

Workflow Tools

  • DEM to Stream Network

    This tool creates the stream network reqired for RAPID input from the DEM(s) provided using ArcHydro Tools.

  • Stream Network to RAPID

    This tool creates the required RAPID input files automatically using the defaults provided by the tools. These files include:

    1. The connectivity file.
    2. The subset file.
    3. The Muskingum K & Kfac files.
    4. The Muskingum X file.
    5. The comid_lat_lon_z file.

    There is an option to add the catchments for the stream network. If added, it will also generate:

    1. The High-Resolution ECMWF forecast weight table.
    2. The Low-Resolution ECMWF forecast weight table.
    3. The ERA Interim weight table.
  • Stream Network to SPT

    This tool will run the "Add Streamflow Prediction Tool Fields" tool and generate the shapefiles needed for the Streamflow Prediction Tool web application (https://github.com/erdc/tethysapp-streamflow_prediction_tool).

  • Automatic RAPID File Generator

    This tool requires the HydroSHEDS 3 arc-second hydrologically conditioned .bil DEM data (www.hydrosheds.org). It also requires the HydroBASINS (www.hydrosheds.org) level 3 boundaries with the associated "RegionName" field added manually with a descriptive region name for each region. With all of the .bil DEM files in one folder, it will determine the DEM(s) required for the watershed and run automatically:

    1. DEM to Stream Network
    2. Stream Network to RAPID
    3. Stream Network to SPT

Licensing

Copyright 2016 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's License.txt file.

[](Esri Tags: ArcGIS Python Toolbox of Preprocessing and Postprocessing for a River Routing Model RAPID) [](Esri Language: Python)​

About

a Python toolbox for the RAPID (Routing Application for Parallel computatIon of Discharge) model.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%