Exemple #1
0
# 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])]
wdm.add_data(str_wdm_new, 12, pet_add, date_start)

# close wdm file
wdm.close(str_wdm_new)