Example #1
0
hspfmodel.add_timeseries('evaporation', 'hunting_evap', start, evap, 
                         tstep = tstep)

# and assign the time series to all the operations in the watershed

hspfmodel.assign_watershed_timeseries('precipitation', 'hunting_prec')
hspfmodel.assign_watershed_timeseries('evaporation',   'hunting_evap')

# this simulation used the hydrology modules (and no others); need to create the
# operations for the model and the default values for the hydrology parameters

hspfmodel.add_hydrology()

# build the input wdm file

hspfmodel.build_wdminfile()

# tell HSPF to keep track of the outflow volume from the reach, which
# has a Fortran name "ROVOL" and a PyHSPF name "reach_outvolume"

targets = ['reach_outvolume']

# create the UCI for the simulation period to provide the targets

hspfmodel.build_uci(targets, start, end, hydrology = True)

# run it

hspfmodel.run(verbose = True)

# pull up the results; this output wdmfile is created automatically
        simplified = pickle.load(f)

    d = {
        v: k
        for k, v in list(simplified.subbasin_timeseries['flowgage'].items())
    }
    comid = d[gageid]

# change the filename

its = directory, HUC8, gageid
simplified.filename = '{}/{}/simplified/preliminary/{}'.format(*its)

# build the input WDM file

simplified.build_wdminfile()

# output variables

targets = [
    'water_state',
    'reach_outvolume',
    'evaporation',
    'runoff',
    'groundwater',
    'snow_state',
    'snowpack',
    'snowfall',
]

# build the UCI and output WDM files
Example #3
0
tstype = 'precipitation'
identifier = 'example_prec'

hspfmodel.add_timeseries(tstype, identifier, start, rainfall, tstep=tstep)

# connect the time series to the whole watershed

hspfmodel.assign_watershed_timeseries(tstype, identifier)

# tell HSPF to run hydrology and assign default parameters

hspfmodel.add_hydrology()

# build the wdm input file using the timeseries

hspfmodel.build_wdminfile()

# external targets

targets = ['reach_outvolume', 'evaporation', 'reach_volume', 'runoff']

# build the input files and run

hspfmodel.build_uci(targets, start, end, hydrology=True, verbose=False)
hspfmodel.run(verbose=True)

# retrieve results using WDMUtil

wdm = WDMUtil()

# open the file for read access
Example #4
0
else:

    with open(newmodel, 'rb') as f: simplified = pickle.load(f)

    d = {v:k for k, v in simplified.subbasin_timeseries['flowgage'].items()}
    comid = d[gageid]

# change the filename

its = directory, HUC8, gageid
simplified.filename = '{}/{}/simplified/preliminary/{}'.format(*its)

# build the input WDM file

simplified.build_wdminfile()

# output variables

targets = ['water_state', 
           'reach_outvolume', 
           'evaporation', 
           'runoff', 
           'groundwater',
           'snow_state', 
           'snowpack', 
           'snowfall',
           ]

# build the UCI and output WDM files