Scripts allow you to automate a defined series of actions with a single click. This makes your work more efficient by simplifying operations, ensuring consistent and repeatable results, saving time, and allowing you to schedule tasks for future execution.

HEC-RTS uses the Jython scripting language, a version of Python designed to work with Java-based applications.

Here are some ways you can use scripting in HEC-RTS:

  • Run an existing forecast with one or more alternatives at the click of a button.
  • Create and run a new forecast based on the current time with selected alternatives.
  • Schedule tasks, such as generating a forecast at a specific time or on a recurring basis.
  • Work with data across HEC-DSS files and the database.

Script Editor

You can create and edit scripts in HEC-RTS using the Script Editor dialog. To access it, go to the Scripts menu in the Menu Bar and select Editor

The Script Editor dialog consists of the following main components:

  • Menu Bar
  • Main Toolbar
  • Script Context Pane
  • Editor Pane

Each of these components is described in the sections below.

Menu Bar

The Menu Bar provides access to commands for creating, editing, running, and managing scripts. It includes three main menus: 

  • File menu
    • New - Creates a new script.
    • Open - Opens an existing script (only available when a script is selected in the Script Context Pane).
    • Run - Executed the selected script (only available when a script is selected in the Script Context Pane).
    • Delete - Deletes the selected script. This opens the Delete Object dialog for confirmation.
    • Save - Saves the currently active script in the Editor Pane.
    • Save As - Saves the active script under a new name.
    • Print - Prints the script currently open in the Editor Pane.
    • Close - Closes the Script Editor Dialog.
  • Edit menu
    • Cut - Removes selected text from the active script and places it on the clipboard.
    • Copy - Copies selected text from the active script to the clipboard.
    • Paste - Inserts clipboard context into the active script at the cursor position.
    • Select All - Selects all text in the active script.
    • Find - Opens the Find dialog to search for text within the active script.
  • Source menu
    • Convert Tabs to Spaces - Replaces tab characters with equivalent spaces.
    • Show Whitespace - Displays whitespace characters (e.g., spaces and tabs) as visible dots for easier editing (visual aid only).

Main Toolbar

The main toolbar offers quick access to commonly used tools and actions, including New, Print, Cut, Copy, and Paste.

Script Context Pane

The Script Context Pane lets you navigate through folders in the HEC-RTS directory and access the scripts stored within them. To edit a script, simply double-click its name, and it will open in the Editor Pane.

Editor Pane

The Editor Pane is where you write and edit scripts. The tab displays the script's name, which matches the name in the Script Context Pane. The file's pathname is shown in the File box. Right-clicking will display a shortcut menu, as shown below.

Shortcut Menu in the Editor Pane

Adding Scripts to Modules

Adding scripts to HEC-RTS modules allows for quick access and execution. Depending on the script’s function, it’s best to add it to the most relevant module tab:

  • Acquisition or Visualization modules: Ideal for scripts that access or manipulate data.
  • Modeling module: Best for scripts used during forecast runs, for processing model data, or for processing model outputs.

Scripts Window

Scripts are added through the Scripts window, which is located differently depending on the module:

  • Acquisition and Visualization modules: The Scripts window appears below the Time Window Details section.
  • Modeling module: The Scripts window is located on the Scripts tab. 

To add a script button, right-click in the empty area of the Scripts window and select Edit. Use the Select Scripts dialog to choose the scripts you want to add.

Once added, the Scripts window will display your selected scripts, as shown in the example below.

Running Scripts

There are several ways to manually execute a script in HEC-RTS: 

  1. From the Script Editor - Select the script, then go to the File menu and click Run to execute the script.
  2. Using a Time Series Icon - Assign the script to a Time Series Icon, then run it from the icon's shortcut menu.
  3. In the Scripts window - Add the script to the Scripts window in the Acquisition, Visualization, or Modeling module, then click the button to run the script.

Adding a Script to the Program Order

HEC-RTS allows you to include a script in the program order if one needs toe executed during a forecast run. See this guide for step-by-step instructions.

Additional Resources

You can find information on Java scripting for HEC-DSS here.