def addData(dss,path,data):
  tsc = TimeSeriesContainer()
  tsc.fullName = path
  start = HecTime("01Jan2100", "1200")
  tsc.interval = 5
  rain = data
  times = []
  for value in rain :
   times.append(start. value())
   start.add(tsc.interval)
  tsc.times = times
  tsc.values = rain
  tsc.numberValues = len(rain)
  tsc.units = "MM"
  tsc.type = "PER-CUM"
  dss.put(tsc)
Example #2
0
def createTSrecord(dss_filename, pathname, start_time, values, comp_step,
                   data_units):

    start = HecTime()
    tsc = TimeSeriesContainer()
    tsc.fullName = pathname
    tsc.interval = comp_step
    start.set(start_time)
    times = []
    for value in values:
        times.append(start.value())
        start.add(tsc.interval)
    tsc.values = values
    tsc.times = times
    tsc.startTime = times[0]
    tsc.endTime = times[-1]
    tsc.numberValues = len(values)
    tsc.units = data_units
    tsc.type = "INST-VAL"
    dss_file = HecDss.open(dss_filename)
    dss_file.put(tsc)
    dss_file.done()
Example #3
0
    num_locations = len(csv_list[0]) - 1
    num_values = len(csv_list) - NUM_METADATA_LINES  # Ignore Metadata
    location_ids = csv_list[1][1:]

    for i in range(0, num_locations):
        precipitations = []
        for j in range(NUM_METADATA_LINES, num_values + NUM_METADATA_LINES):
            p = float(csv_list[j][i + 1])
            precipitations.append(p)

        tsc = TimeSeriesContainer()
        # tsc.fullName = "/BASIN/LOC/FLOW//1HOUR/OBS/"
        # tsc.fullName = '//' + locationIds[i].upper() + '/PRECIP-INC//1DAY/GAGE/'
        tsc.fullName = '//' + location_ids[i].upper(
        ) + '/PRECIP-INC//1HOUR/GAGE/'

        start = HecTime(csv_list[NUM_METADATA_LINES][0])
        tsc.interval = 60  # in minutes
        times = []
        for value in precipitations:
            times.append(start.value())
            start.add(tsc.interval)
        tsc.times = times
        tsc.values = precipitations
        tsc.numberValues = len(precipitations)
        tsc.units = "MM"
        tsc.type = "PER-CUM"
        converted_dss.put(tsc)
finally:
    converted_dss.done()
ver = "OBS"
startTime = "12Oct2003 0100"
values = [12.36, 12.37, 12.42, 12.55, 12.51, 12.47, 12.43, 12.39]
hecTime = HecTime()

tsc = TimeSeriesContainer()
tsc.watershed = watershed
tsc.location = loc
tsc.parameter = param
tsc.version = ver
tsc.fullName = "/%s/%s/%s//1HOUR/%s/" % (watershed, loc, param, ver)
tsc.interval = 60

hecTime.set(startTime)
times=[]

for value in values:
    times.append(hecTime.value())
    hecTime.add(tsc.interval)

tsc.values = values
tsc.times = times
tsc.startTime = times[0]
tsc.endTime = times[-1]

tsc.numberValues = len(values)
tsc.units = "FEET"
tsc.type = "INST-VAL"
dssFile = HecDss.open("myFile.dss")
dssFile.put(tsc)
dssFile.done()