# or time series assignments simplified.build_from_existing(hspfmodel, newmodel) # find the comid of the gage and add the flow data to the new model d = { v: k for k, v in list(hspfmodel.subbasin_timeseries['flowgage'].items()) } comid = d[gageid] s, tstep, data = hspfmodel.flowgages[gageid] simplified.add_timeseries('flowgage', gageid, s, data, tstep=tstep) simplified.assign_subbasin_timeseries('flowgage', comid, gageid) # add and assign the snowfall and snowdepth from the old model s, tstep, data = hspfmodel.snowdepths[HUC8] simplified.add_timeseries('snowdepth', HUC8, s, data, tstep=tstep) simplified.assign_watershed_timeseries('snowdepth', HUC8) s, tstep, data = hspfmodel.snowfalls[HUC8] simplified.add_timeseries('snowfall', HUC8, s, data, tstep=tstep) simplified.assign_watershed_timeseries('snowfall', HUC8) # add other time series to the model and assign them to the whole watershed # note that the first year from the PyHSPF data is used for the warmup # since the BASINS station data are incomplete
evap = wdm.get_data(wdmFile, 200 + x) # Add and assign timeseries data hspfmodel.add_timeseries('precipitation', ('prcp_' + str(x)), start, prcp, tstep=tstep) hspfmodel.add_timeseries('evaporation', ('evap_' + str(x)), start, evap, tstep=tstep) # Assign to specific basin hspfmodel.assign_subbasin_timeseries('precipitation', str(basin + 1), ('prcp_' + str(x))) hspfmodel.assign_subbasin_timeseries('evaporation', str(basin + 1), ('evap_' + str(x))) x += 1 # Add flow data to the gaged basin flow = wdm.get_data(wdmFile, 301) hspfmodel.add_timeseries('flowgage', 'flow', start, flow, tstep=tstep) hspfmodel.assign_subbasin_timeseries('flowgage', '11', 'flow') wdm.close(wdmFile)
# build new model parameters from the base model; the build_from_existing # method can be used to copy the perlnds, implnds, rchreses, special # actions, and reach network from the old file but contains no time series # or time series assignments simplified.build_from_existing(hspfmodel, newmodel) # find the comid of the gage and add the flow data to the new model d = {v:k for k, v in hspfmodel.subbasin_timeseries['flowgage'].items()} comid = d[gageid] s, tstep, data = hspfmodel.flowgages[gageid] simplified.add_timeseries('flowgage', gageid, s, data, tstep = tstep) simplified.assign_subbasin_timeseries('flowgage', comid, gageid) # add and assign the snowfall and snowdepth from the old model s, tstep, data = hspfmodel.snowdepths[HUC8] simplified.add_timeseries('snowdepth', HUC8, s, data, tstep = tstep) simplified.assign_watershed_timeseries('snowdepth', HUC8) s, tstep, data = hspfmodel.snowfalls[HUC8] simplified.add_timeseries('snowfall', HUC8, s, data, tstep = tstep) simplified.assign_watershed_timeseries('snowfall', HUC8) # add other time series to the model and assign them to the whole watershed # note that the first year from the PyHSPF data is used for the warmup # since the BASINS station data are incomplete
hspfmodel.add_timeseries('precipitation', 'hunting_prec', start, precip, tstep=60) hspfmodel.add_timeseries('evaporation', 'hunting_evap', start, evap, tstep=60) hspfmodel.add_timeseries('flowgage', 'hunting_flow', start, oflow, tstep=60) # and assign the watershed time series to all the operations hspfmodel.assign_watershed_timeseries('precipitation', 'hunting_prec') hspfmodel.assign_watershed_timeseries('evaporation', 'hunting_evap') # assign the flowgage to the subbasin 30 (the outlet) hspfmodel.assign_subbasin_timeseries('flowgage', '30', 'hunting_flow') # this simulation used the hydrology modules (and no others); need to set the # operations for the watershed and default values for the hydrology parameters hspfmodel.add_hydrology() # this example will stop here by pickling the hspfmodel for later--since the # model will be run many times it just makes sense to save the work so far # before moving on. with open('example03', 'wb') as f: pickle.dump(hspfmodel, f) print('\nsuccessfully created new model "example03."\n')
hspfmodel.add_timeseries('precipitation', 'hunting_prec', start, precip, tstep = 60) hspfmodel.add_timeseries('evaporation', 'hunting_evap', start, evap, tstep = 60) hspfmodel.add_timeseries('flowgage', 'hunting_flow', start, oflow, tstep = 60) # and assign the watershed time series to all the operations hspfmodel.assign_watershed_timeseries('precipitation', 'hunting_prec') hspfmodel.assign_watershed_timeseries('evaporation', 'hunting_evap') # assign the flowgage to the subbasin 30 (the outlet) hspfmodel.assign_subbasin_timeseries('flowgage', '30', 'hunting_flow') # this simulation used the hydrology modules (and no others); need to set the # operations for the watershed and default values for the hydrology parameters hspfmodel.add_hydrology() # this example will stop here by pickling the hspfmodel for later--since the # model will be run many times it just makes sense to save the work so far # before moving on. with open('example03', 'wb') as f: pickle.dump(hspfmodel, f) print('\nsuccessfully created new model "example03."\n') # the Watershed class has a plot method to show the mass linkages for the