Displaying differences for changeset
 
display as  

nbproject/private/private.xml

@@ -23,9 +23,6 @@
             <file>file:/od/projects/csip-all/csip-example/test/service_tests/service.properties</file>
             <file>file:/od/projects/csip-all/csip-example/test/service_tests/externalexe/STest.java</file>
         </group>
-        <group>
-            <file>file:/home/pattersd/work/csip-weather/test/service_tests/GHCND_V1_0/ghcnd-res.json</file>
-            <file>file:/home/pattersd/work/csip-weather/test/service_tests/GHCND_V1_0/ghcnd-req.json</file>
-        </group>
+        <group/>
     </open-files>
 </project-private>

src/java/python/ghcndDownloader.py

@@ -52,7 +52,8 @@
                         if qflag.strip():
                             # Any non-empty value is an error
                             val = None
-                        val = self.convert(element, val)
+                        else:
+                            val = self.convert(element, val)
                         ret[dt][element] = val
         else:
             ret['error'] = "downloader: No data for {0}".format(station_id)

src/java/python/weatherExtraction.py

@@ -215,21 +215,31 @@
             climate_data = [['cell', 'date', 'tmpmin (F)', 'tmpmax (F)', 'apcp (in)', 'dswrf (langley/day)', 'rh (%)', 'windspeed (mph)'],]
 
         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]
-            
-            c.execute("SELECT * FROM narr.cells_ts WHERE gid=%s AND date>=%s AND date<=%s ORDER BY date", (gid, start_date, end_date))
-            for row in c.fetchall():
-                climate_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)
-                                 ])
+
+            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
+            climate_data += cell_data
         return climate_data, cell_defs, cell_extents
         
     def WEgetDataMACA(self, input_zone_file, model, forecast_option, units, start_date, end_date):
@@ -392,19 +402,28 @@
             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]
             
-            c.execute("SELECT * FROM prism.cells_ts WHERE gid=%s AND date>=%s AND date<=%s ORDER BY date", (gid, start_date, end_date))
-            for row in c.fetchall():
-                climate_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),
-                                 ])
+            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
+            climate_data += cell_data
         return climate_data, cell_defs, cell_extents
 
     def WEgetDataGHCND(self, input_zone_file_or_station_list, units, start_date, end_date, generate_average=False, IDW_center=False):

test/service_tests/NARR_V1_0/narr-req.json

@@ -20,7 +20,22 @@
               39.9167
                   ]
                 }
+              },
+              {
+                "type": "Feature",
+                "properties": {
+                  "name": "pt two",
+                  "gid": 2
+                },
+                "geometry": {
+                  "type": "Point",
+                  "coordinates": [
+              -105.75,
+              39.9167
+                  ]
+                }
               }
+
             ]
        }
     }, {

test/service_tests/PRISM_V1_0/prism-req.json

@@ -19,6 +19,20 @@
                 40.53148031584938
               ]
             }
+          },
+          {
+            "type": "Feature",
+            "properties": {
+              "name": "pt two",
+              "gid": 2
+            },
+            "geometry": {
+              "type": "Point",
+              "coordinates": [
+                -104.9220085144043,
+                40.53148031584938
+              ]
+            }
           }
         ]
       }