Example #1
0
# get the area, centroid and elevation of each shape

areas = [r[fields.index('AreaSqKm') - 1] for r in sf.records()]
xs = [r[fields.index('CenX') - 1] for r in sf.records()]
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)

# since we don't have hourly data for temperature, wind, or dew point, some
# assumptions are needed (if anyone can suggest hourly databases for these
# parameters that would be pretty awesome BTW); the ETCalculator has a public
# method to interpolate temperatures to hourly values assuming the minimum
# temperature occurs at 6 am and the max at 4 pm and then interpolating using
# sin function for each day

hourlytemps = calculator.interpolate_temperatures(start, end)

# for wind speed and dewpoint, just assume the values 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)]
Example #2
0
# get the area, centroid and elevation of each shape

areas = [r[fields.index('AreaSqKm') - 1] for r in sf.records()]
xs    = [r[fields.index('CenX')     - 1] for r in sf.records()]
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)

# it is pretty trivial to get the corresponding reference evapotranspiration 
# (RET) time series from the Daily Penman-Monteith Equation if the necessary 
# data are available by calling the public "penman_daily" method

calculator.penman_daily(start, end)

# the RET estimates are stored in the calculator's daily timeseries dictionary
# with the start date and data (the timestep is 1440 minutes = 1 day)

start, RET = calculator.daily['RET']

# calculate the linear regression between the Penman-Monteith model and the 
# observed pan evaporation using scipy