from pyhspf import WDMUtil wdm = WDMUtil() # path to hspexp2.4 data files (make sure the path is correct) # the data from the export file (*.exp) provided with hspexp need to be # imported into a wdm file; the WDMUtil class has a method for this huntday = 'huntday/huntobs.exp' f = 'hunting.wdm' # import from exp to wdm wdm.import_exp(huntday, f) # copy the data to the hspfmodel using WDMUtil. in general climate # data would need to come from some other place (not a wdm file); # e.g., an NCDC file. the preprocessing modules can automate this # for the hspexp example, only one timeseries for precip and evap # are provided. the file also contains the observed flow at the outlet. # this is set up to find the dsns, time steps etc, though if they were # known they could be provided directly. # open the wdm for read access wdm.open(f, 'r') # find all the dsns
# this is just a check to see the file is there if not os.path.isfile(hunthour): print('error: file {} seems to be missing'.format(hunthour)) print('please update the path and re-run\n') raise # the path to the wdm file to create f = 'hunting.wdm' # import from exp to wdm wdm.import_exp(hunthour, f) # copy the data to the hspfmodel using WDMUtil # open the wdm for read access wdm.open(f, 'r') # the dsns are known from the exp file so just use those this time precip = wdm.get_data(f, 106) evap = wdm.get_data(f, 111) oflow = wdm.get_data(f, 281) start, end = wdm.get_dates(f, 106)