@@ -216,29 +216,22 @@ |
|
c = getConnBeta().cursor(cursor_factory=psycopg2.extras.DictCursor) |
|
- # Maintain simple cache to hold repeats |
- cache = {} |
- |
for i in range(len(tiles)): |
gid = tiles[i] |
cell_name = names[i] |
|
- if gid in cache: |
- cell_data = cache[gid] |
- else: |
- c.execute("SELECT * FROM narr.cells_ts WHERE gid=%s AND date>=%s AND date<=%s ORDER BY date", (gid, start_date, end_date)) |
- cell_data = [] |
- for row in c.fetchall(): |
- cell_data.append([cell_name, |
- row['date'].strftime("%Y-%m-%d"), |
- round(conv_dict['tmp'](row['tmin (C)']), 2), |
- round(conv_dict['tmp'](row['tmax (C)']), 2), |
- round(conv_dict['apcp'](row['ppt (mm)']), 3), |
- round(conv_dict['dswrf'](row['dswrf (W/m^2)']), 1), |
- round(conv_dict['rh'](row['rh (%)']), 0), |
- round(conv_dict['windgust'](row['windgust (m/s)']), 2) |
- ]) |
- cache[gid] = cell_data |
+ c.execute("SELECT * FROM narr.cells_ts WHERE gid=%s AND date>=%s AND date<=%s ORDER BY date", (gid, start_date, end_date)) |
+ cell_data = [] |
+ for row in c.fetchall(): |
+ cell_data.append([cell_name, |
+ row['date'].strftime("%Y-%m-%d"), |
+ round(conv_dict['tmp'](row['tmin (C)']), 2), |
+ round(conv_dict['tmp'](row['tmax (C)']), 2), |
+ round(conv_dict['apcp'](row['ppt (mm)']), 3), |
+ round(conv_dict['dswrf'](row['dswrf (W/m^2)']), 1), |
+ round(conv_dict['rh'](row['rh (%)']), 0), |
+ round(conv_dict['windgust'](row['windgust (m/s)']), 2) |
+ ]) |
climate_data += cell_data |
return climate_data, cell_defs, cell_extents |
|
@@ -402,27 +395,20 @@ |
conv_dict = to_english_fn |
climate_data = [['cell', 'date', 'tmpmin (F)', 'tmpmax (F)', 'apcp (in)']] |
|
- # Maintain simple cache to hold repeats |
- cache = {} |
- |
c = getConnBeta().cursor(cursor_factory=psycopg2.extras.DictCursor) |
for i in range(len(tiles)): |
gid = tiles[i] |
cell_name = names[i] |
|
- if gid in cache: |
- cell_data = cache[gid] |
- else: |
- c.execute("SELECT * FROM prism.cells_ts WHERE gid=%s AND date>=%s AND date<=%s ORDER BY date", (gid, start_date, end_date)) |
- cell_data = [] |
- for row in c.fetchall(): |
- cell_data.append([cell_name, |
- row['date'].strftime("%Y-%m-%d"), |
- round(conv_dict['temp'](row['tmin']), 2), |
- round(conv_dict['temp'](row['tmax']), 2), |
- round(conv_dict['ppt'](row['ppt']), 2), |
- ]) |
- cache[gid] = cell_data |
+ c.execute("SELECT * FROM prism.cells_ts WHERE gid=%s AND date>=%s AND date<=%s ORDER BY date", (gid, start_date, end_date)) |
+ cell_data = [] |
+ for row in c.fetchall(): |
+ cell_data.append([cell_name, |
+ row['date'].strftime("%Y-%m-%d"), |
+ round(conv_dict['temp'](row['tmin']), 2), |
+ round(conv_dict['temp'](row['tmax']), 2), |
+ round(conv_dict['ppt'](row['ppt']), 2), |
+ ]) |
climate_data += cell_data |
return climate_data, cell_defs, cell_extents |
|