Example #1
0
# that does not depend on time step)
#
# the time step form is perhaps most difficult to understand. different 
# variables have different forms when they are discretized into time steps.
# the flow for a time step could represent the average value across the
# step, the value at the beginning or end, the average value, or the total
# value (this is perhaps most important)--thus for example if I say "the flow
# between 2 and 3 pm was 10 m3 is different than saying the flow at 3 pm was
# 10 m3 per hour. Given that context, HSPF groups all variables into one of
# three categories (the examples reference heat transfer concepts):

# TSFORM = 1 -- The mean value of a state variable (such as temperature)
# TSFORM = 2 -- The total flux across a time step (such as heat flux energy)
# TSFORM = 3 -- The value at the end of the time step (such as temperature)

wdm.create_dataset('test.wdm', 134, attributes)

# change the time series type appropriately

attributes['TSTYPE'] = 'EVAP'

# change the time series form to 2 (evaporation is a "flux" variable so the
# quantity depends on the time step length)

attributes['TSFORM'] = 2

wdm.create_dataset('test.wdm',  41, attributes)

# change the time series form to 1 (wind speed and all the rest of the 
# variables are the average across the day)
Example #2
0
# that does not depend on time step)
#
# the time step form is perhaps most difficult to understand. different
# variables have different forms when they are discretized into time steps.
# the flow for a time step could represent the average value across the
# step, the value at the beginning or end, the average value, or the total
# value (this is perhaps most important)--thus for example if I say "the flow
# between 2 and 3 pm was 10 m3 is different than saying the flow at 3 pm was
# 10 m3 per hour. Given that context, HSPF groups all variables into one of
# three categories (the examples reference heat transfer concepts):

# TSFORM = 1 -- The mean value of a state variable (such as temperature)
# TSFORM = 2 -- The total flux across a time step (such as heat flux energy)
# TSFORM = 3 -- The value at the end of the time step (such as temperature)

wdm.create_dataset('test.wdm', 134, attributes)

# change the time series type appropriately

attributes['TSTYPE'] = 'EVAP'

# change the time series form to 2 (evaporation is a "flux" variable so the
# quantity depends on the time step length)

attributes['TSFORM'] = 2

wdm.create_dataset('test.wdm', 41, attributes)

# change the time series form to 1 (wind speed and all the rest of the
# variables are the average across the day)
Example #3
0
pyhspfdirectory = os.path.dirname(hspf.__file__)
messagepath = '{}/pyhspf/core/hspfmsg.wdm'.format(pyhspfdirectory)

# the 3rd simulation adds more data to "test.wdm," so we need to create the
# datasets as before.

wdm = WDMUtil(verbose=True)

wdm.open('test.wdm', 'rw')

attributes = {
    'TCODE ': 4,  # hourly units 
    'TSSTEP': 1,  # one unit (hourly) time step
    'TSFORM': 1  # cloud cover is an average across the step
}

attributes['TSTYPE'] = 'CLND'

wdm.create_dataset('test.wdm', 140, attributes)

attributes['TSTYPE'] = 'CLDC'

wdm.create_dataset('test.wdm', 135, attributes)

wdm.close('test.wdm')

# run it

hspf.hsppy('test03.uci', messagepath)
Example #4
0
# the 2nd simulation adds more data to "test.wdm," so we need to create the
# datasets as before.

wdm = WDMUtil(verbose=True)

wdm.open('test.wdm', 'rw')

attributes = {
    'TCODE ': 3,  # hourly units 
    'TSSTEP': 1,  # one unit (hourly) time step
    'TSTYPE': 'PREC',  # precipitation type
    'TSFORM': 2  # precip is a total amount across the step
}

wdm.create_dataset('test.wdm', 39, attributes)
wdm.create_dataset('test.wdm', 131, attributes)
wdm.create_dataset('test.wdm', 132, attributes)

# solar radiation -- the file aggregates the hourly to bi-hourly so TSSTEP = 2

attributes['TSTYPE'] = 'SOLR'
attributes['TSSTEP'] = 2

wdm.create_dataset('test.wdm', 46, attributes)

# air temperature -- the file aggregates the hourly to bi-hourly so TSSTEP = 2
# also the from is point-values so TSFORM = 1

attributes['TSTYPE'] = 'ATMP'
attributes['TSFORM'] = 1
Example #5
0
pyhspfdirectory = os.path.dirname(hspf.__file__)
messagepath = '{}/pyhspf/core/hspfmsg.wdm'.format(pyhspfdirectory)

# the 3rd simulation adds more data to "test.wdm," so we need to create the
# datasets as before.

wdm = WDMUtil(verbose = True)

wdm.open('test.wdm', 'rw')

attributes = {'TCODE ': 4,      # hourly units 
              'TSSTEP': 1,      # one unit (hourly) time step
              'TSFORM': 1       # cloud cover is an average across the step
              }

attributes['TSTYPE'] = 'CLND'

wdm.create_dataset('test.wdm', 140, attributes)

attributes['TSTYPE'] = 'CLDC'

wdm.create_dataset('test.wdm', 135, attributes)

wdm.close('test.wdm')

# run it

hspf.hsppy('test03.uci', messagepath)


Example #6
0
messagepath = '{}/pyhspf/core/hspfmsg.wdm'.format(pyhspfdirectory)

# the 2nd simulation adds more data to "test.wdm," so we need to create the
# datasets as before.

wdm = WDMUtil(verbose = True)

wdm.open('test.wdm', 'rw')

attributes = {'TCODE ': 3,      # hourly units 
              'TSSTEP': 1,      # one unit (hourly) time step
              'TSTYPE': 'PREC', # precipitation type
              'TSFORM': 2       # precip is a total amount across the step
              }

wdm.create_dataset('test.wdm',  39, attributes)
wdm.create_dataset('test.wdm', 131, attributes)
wdm.create_dataset('test.wdm', 132, attributes)

# solar radiation -- the file aggregates the hourly to bi-hourly so TSSTEP = 2

attributes['TSTYPE'] = 'SOLR'
attributes['TSSTEP'] = 2

wdm.create_dataset('test.wdm', 46, attributes)

# air temperature -- the file aggregates the hourly to bi-hourly so TSSTEP = 2
# also the from is point-values so TSFORM = 1

attributes['TSTYPE'] = 'ATMP'
attributes['TSFORM'] = 1      
Example #7
0
# variables have different forms when they are discretized into time steps.
# the flow for a time step could represent the average value across the
# step, the value at the beginning or end, the average value, or the total
# value (this is perhaps most important)--thus for example if I say "the flow
# between 2 and 3 pm was 10 m3 is different than saying the flow at 3 pm was
# 10 m3 per hour. Given that context, HSPF groups all variables into one of
# three categories (the examples reference heat transfer concepts):

# TSFORM = 1 -- The mean value of a state variable (such as temperature)
# TSFORM = 2 -- The total flux across a time step (such as heat flux energy)
# TSFORM = 3 -- The value at the end of the time step (such as temperature)

# for precip and pet, the TSFORM  value would be 2 becuase it would be the total precip that occured over the time-step
attributes['TSFORM'] = 3
attributes['TSTYPE'] = 'PREC'
wdm.create_dataset(str_wdm_new, 11, attributes)
attributes['TSTYPE'] = 'PET'
wdm.create_dataset(str_wdm_new, 12, attributes)

# add precip data for sub-basin 1
start_date = df_prec['DATE'][0]
date_start = datetime.datetime(int(start_date[5:9]), int(start_date[0:2]),
                               int(start_date[3:4]))
prec_add = [float(x) for x in list(df_prec.iloc[:, 1])]
wdm.add_data(str_wdm_new, 11, prec_add, date_start)

# add pet data for sub-basin 1
start_date = df_prec['DATE'][0]
date_start = datetime.datetime(int(start_date[5:9]), int(start_date[0:2]),
                               int(start_date[3:4]))
pet_add = [float(x) for x in list(df_pet.iloc[:, 1])]