Skip to content

CAVI Scripts

Jeff Gregory edited this page Mar 16, 2022 · 24 revisions

Cumulus Grid Download

The initialization of the rtsutils package provides a template script (cumulus.py) that can be used as-is or copied. Any changes to the template script will be overwritten if the initialization script (rtsutil_init.py) is executed. rtsutil_update.py only updates any changes to the rts-utils repository; modified scripts in the CAVI watershed are safe and not overwritten. Configurations for the Cumulus script are also safe because each script, and copy of that script, creates its own configuration dependency. A HEADLESS option is provided in the code allowing the user to create the configuration (HEADLESS = False) and then executing without the GUI (HEADLESS = True). There are parameters that the user may need to change but in most cases these should be good.

params_ = {
    "Host": "cumulus-api.corps.cloud",
    "Scheme": "https",
    "Timeout": 150  # default is 300
}

Timeout can be increased to facilitate long download times or completely left out of the configuration to default to 300 seconds. Host should already be set properly. The Scheme should not be modified. The time window is determined by the CAVI and active tab. If the active tab is Modeling and no forecast open, an exception is raised and the program stops.

Watershed Extract

The initialization of the rtsutils package provides a template script (extract.py) that can be used as-is or copied. Any changes to the template script will be overwritten if the initialization script (rtsutil_init.py) is executed. rtsutil_update.py only updates any changes to the rts-utils repository; modified scripts in the CAVI watershed are safe and not overwritten. Configurations for the Extract script are also safe because each script, and copy of that script, creates its own configuration dependency. A HEADLESS option is provided in the code allowing the user to create the configuration (HEADLESS = False) and then executing without the GUI (HEADLESS = True). There are parameters that the user may need to change but in most cases these should be good.

params_ = {
    "Host": "cumulus-api.corps.cloud",
    "Scheme": "https",
    "Timeout": 150  # default is 300
}

Timeout can be increased to facilitate long download times or completely left out of the configuration to default to 300 seconds. Host should already be set properly. The Scheme should not be modified. The time window is determined by the CAVI and active tab. If the active tab is Modeling and no forecast open, an exception is raised and the program stops.

CWMS Radar 2 DSS

README

CWMS RADAR

Method Modifier and Type Description
CwmsRADAR() Class Set inputs that are used to build the sys.argv for cwms_data2dss.py
CwmsRADAR().begintime String Assign time format 'yyyy-MM-ddTHH:mm:00'
CwmsRADAR().endtime String Assign time format 'yyyy-MM-ddTHH:mm:00'
CwmsRADAR().format_datetime(HecTime dt) String Input HecTime object returning time format 'yyyy-MM-ddTHH:mm:00'
CwmsRADAR().dssfile String Assign path and dss pathname
CwmsRADAR().set_tsids(tsid[], [dssid[]]) String[] Assign list of TSIDs and/or list of DSS IDs
CwmsRADAR().set_timezone(String tz) String Assign timezone; checked against available IDs
CwmsRADAR().run() void Build arguments for cwms_data2dss.py and call its main() method

Example Scripts

TSID and DSS ID Lists

import os
import sys
from hec.heclib.util import HecTime
# Add rtsutils package to sys.path before importing
sys.path.append(os.path.join(os.environ['APPDATA'], "rsgis"))
from rtsutils import cavistatus, cwmsradar
#
tw = cavistatus.get_timewindow()
if tw != None:
    st, et = tw
else:
    raise Exception('No Forecast open to get a timewindow')
tsid_list = [
    'LRN/NAST1-CumberlandR-NashvilleTN.Stage.Inst.30Minutes.0.dcp-rev',
    'LRN/ANTT1-MillCr-AntiochTN.Precip-Inc.Total.30Minutes.30Minutes.dcp-rev',
    'LRN/Anderson.Precip-Inc.Total.15Minutes.15Minutes.CCP-Computed-Rev'
    ]
dssid_list = [
    '//NAST1-CUMBERLANDR-NASHVILLETN/STAGE//30MIN/DCP-REV/',
    '//ANNT1-MILLCR-ANTIOCHTN/PRECIP-INC//30MIN/DCP-REV/',
    '//ANDERSON/PRECIP-INC//15MIN/CCP-COMPUTED-REV'
]
cwmsdat = cwmsradar.CwmsRADAR()
cwmsdat.begintime = cwmsdat.format_datetime(HecTime(st))
cwmsdat.endtime = cwmsdat.format_datetime(HecTime(et))
cwmsdat.dssfile = os.path.join(cavistatus.get_database_directory(), 'test-data.dss')
cwmsdat.set_tsids(tsid_list)                   # Define TSID only tells the script to define DSS paths
cwmsdat.set_tsids(tsid_list, dssid_list)       # Define TSID and DSS lists defines DSS path names
cwmsdat.run()

TSIDs and DSS IDs Defined by Configuration File

import os
import sys
from hec.heclib.util import HecTime
# Add rtsutils package to sys.path before importing
sys.path.append(os.path.join(os.environ['APPDATA'], "rsgis"))
from rtsutils import cavistatus, cwmsradar
#
tw = cavistatus.get_timewindow()
if tw != None:
    st, et = tw
else:
    raise Exception('No Forecast open to get a timewindow')
cwmsdat = cwmsradar.CwmsRADAR()
cwmsdat.begintime = cwmsdat.format_datetime(HecTime(st))
cwmsdat.endtime = cwmsdat.format_datetime(HecTime(et))
cwmsdat.dssfile = os.path.join(cavistatus.get_database_directory(), 'test-data.dss')
cwmsdat.read_config(os.path.join(cavistatus.get_database_directory(), 'cwms_radar.config'))
cwmsdat.set_tsids()  # Reading the configutation file defines the lists but they still need to be set
cwmsdat.run()

Example: Configuration file for TSIDs and DSS IDs

*Do NOT leave any trailing commas (,) after the last entry!

{
    "DistrictID/Location.Parameter.ParameterType.Interval.Duration.Version": "/Apart/Bpart/Cpart/Dpart/Epart/Fpart/",
    "DistrictID/Location.Parameter.ParameterType.Interval.Duration.Version": "/Apart/Bpart/Cpart/Dpart/Epart/Fpart/"
}

{
  "LRN/NAST1-CumberlandR-NashvilleTN.Stage.Inst.30Minutes.0.dcp-rev": "//NAST1-CUMBERLANDR-NASHVILLETN/STAGE//30MIN/DCP-REV/",
  "LRN/ANTT1-MillCr-AntiochTN.Precip-Inc.Total.30Minutes.30Minutes.dcp-rev": "//ANNT1-MILLCR-ANTIOCHTN/PRECIP-INC//30MIN/DCP-REV/"
}

Get USGS

Clone this wiki locally