# evapotranspiration time series; let's make an instance to use calculator = ETCalculator() # the ETCalculator makes use of hourly and daily time series that must be # supplied externally as: # # 1. time series type (temperature, dewpoint, humidity, wind, solar, etc) # 2. time step step ("daily", "hourly", or size in minutes, e.g., 60, 1440) # 3. start time # 4. list of data values # # note these are the same formats used by the PyHSPF HSPFModel class # so now we can add the daily timeseries from above calculator.add_timeseries('tmin', 'daily', start, tmin) calculator.add_timeseries('tmax', 'daily', start, tmax) calculator.add_timeseries('dewpoint', 'daily', start, dewt) calculator.add_timeseries('wind', 'daily', start, wind) calculator.add_timeseries('solar', 'daily', start, dsolar) # the temperature and dewpoint are assumed to be in C, wind speed in m/s, and # solar radiation in W/m2; these are the units supplied by the other classes # in PyHSPF already so no manipulation is needed # some of the parameters in the Penman-Monteith Equation depend on the # geographic location so let's use the information in the shapefile to # provide the average longitude, latitude, and elevation sf = Reader(filename)
ys = [r[fields.index('CenY') - 1] for r in sf.records()] zs = [r[fields.index('AvgElevM') - 1] for r in sf.records()] # get the areal-weighted averages lon = sum([a * x for a, x in zip(areas, xs)]) / sum(areas) lat = sum([a * y for a, y in zip(areas, ys)]) / sum(areas) elev = sum([a * z for a, z in zip(areas, zs)]) / sum(areas) # add the information to the calculator calculator.add_location(lon, lat, elev) # add the daily time series to the calculator calculator.add_timeseries('tmin', 'daily', start, tmin) calculator.add_timeseries('tmax', 'daily', start, tmax) calculator.add_timeseries('dewpoint', 'daily', start, dewt) calculator.add_timeseries('wind', 'daily', start, wind) calculator.add_timeseries('solar', 'daily', start, solar) # calculate the reference evapotranspiration (RET) time series from the daily # Penman-Monteith Equation calculator.penman_daily(start, end) # save the time series for later (i.e., to add to an HSPF Model) RET = [e for e in calculator.daily['RET'][1]] data = start, 1440, RET
ys = [r[fields.index("CenY") - 1] for r in sf.records()] zs = [r[fields.index("AvgElevM") - 1] for r in sf.records()] # get the areal-weighted averages lon = sum([a * x for a, x in zip(areas, xs)]) / sum(areas) lat = sum([a * y for a, y in zip(areas, ys)]) / sum(areas) elev = sum([a * z for a, z in zip(areas, zs)]) / sum(areas) # add the information to the calculator calculator.add_location(lon, lat, elev) # use the daily tmin and tmax time series to the calculator to get hourly temps calculator.add_timeseries("tmin", "daily", start, tmin) calculator.add_timeseries("tmax", "daily", start, tmax) # calculate the hourly temperature time series hourlytemps = calculator.interpolate_temperatures(start, end) # assume the values for wind speed and dewpoint are constant throughout the day hdewt = [v for v in dewt for i in range(24)] hwind = [v for v in wind for i in range(24)] # now add the hourly time series to the calculator calculator.add_timeseries("temperature", "hourly", start, hourlytemps) calculator.add_timeseries("dewpoint", "hourly", start, hdewt)
# evapotranspiration time series; let's make an instance to use calculator = ETCalculator() # the ETCalculator makes use of hourly and daily time series that must be # supplied externally as: # # 1. time series type (temperature, dewpoint, humidity, wind, solar, etc) # 2. time step step ("daily", "hourly", or size in minutes, e.g., 60, 1440) # 3. start time # 4. list of data values # # note these are the same formats used by the PyHSPF HSPFModel class # so now we can add the daily timeseries from above calculator.add_timeseries('tmin', 'daily', start, tmin) calculator.add_timeseries('tmax', 'daily', start, tmax) calculator.add_timeseries('dewpoint', 'daily', start, dewt) calculator.add_timeseries('wind', 'daily', start, wind) calculator.add_timeseries('solar', 'daily', start, solar) # the temperature and dewpoint are assumed to be in C, wind speed in m/s, and # solar radiation in W/m2; these are the units supplied by the other classes # in PyHSPF already so no manipulation is needed # some of the parameters in the Penman-Monteith Equation depend on the # geographic location so let's use the information in the shapefile to # provide the average longitude, latitude, and elevation sf = Reader(filename)
ys = [r[fields.index('CenY') - 1] for r in sf.records()] zs = [r[fields.index('AvgElevM') - 1] for r in sf.records()] # get the areal-weighted averages lon = sum([a * x for a, x in zip(areas, xs)]) / sum(areas) lat = sum([a * y for a, y in zip(areas, ys)]) / sum(areas) elev = sum([a * z for a, z in zip(areas, zs)]) / sum(areas) # add the information to the calculator calculator.add_location(lon, lat, elev) # add the daily time series to the calculator for plotting calculator.add_timeseries('tmin', 'daily', start, tmin) calculator.add_timeseries('tmax', 'daily', start, tmax) calculator.add_timeseries('dewpoint', 'daily', start, dewt) calculator.add_timeseries('wind', 'daily', start, wind) calculator.add_timeseries('solar', 'daily', start, dsolar) # calculate the hourly temperature time series hourlytemps = calculator.interpolate_temperatures(start, end) # assume the values for wind speed and dewpoint are constant throughout the day hdewt = [v for v in dewt for i in range(24)] hwind = [v for v in wind for i in range(24)] # now add the hourly time series to the calculator