Changeset 4228 for cows/trunk/cows/service/imps/wms_csmllayer.py
- Timestamp:
- 24/09/08 15:19:12 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cows/trunk/cows/service/imps/wms_csmllayer.py
r3954 r4228 110 110 @raise ValueError: If no layers are available for these keywords. 111 111 """ 112 #print kwargs113 112 fileoruri=kwargs['fileoruri'] 114 113 if fileoruri in self.layermapcache.keys(): 115 114 #we've accessed this layer map before, get it from the cache dictionary 116 #print 'found layer map in cache'117 115 return self.layermapcache[fileoruri] 118 116 … … 153 151 self._feature=feature 154 152 self.legendSize=(30,100) 155 153 bb= self._feature.getCSMLBoundingBox().getBox() 156 154 #convert 0 - 360 to -180, 180 as per common WMS convention 157 155 if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 158 156 bb[0], bb[2]=-180, 180 159 160 157 self.wgs84BBox = bb 158 self.featureInfoFormats = ['text/html'] 161 159 try: 162 160 self.wgs84BBox = self.getBBox('EPSG:4326') … … 175 173 #if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 176 174 # bb[0], bb[2]=-180, 180 177 175 #self.wgs84BBox = bb 178 176 return self.wgs84BBox 179 177 #raise NotImplementedError … … 207 205 result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) 208 206 #for now have to read netcdf back from 209 207 #disk (limitiation of CSML api) 210 208 netcdf=cdms.open(result[1]) 211 209 #and then delete the temporary file … … 252 250 dictindex=str((self._feature.id, dimValues)) 253 251 if dictindex in self.featureinfofilecache: 254 print 'calling cache'252 log.debug('calling cache') 255 253 f=self.featureinfofilecache[dictindex] 256 254 else: #else, use the csml api to subset the feature afresh 257 print 'not calling cache'255 log.debug('not calling cache') 258 256 randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 259 257 result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) … … 264 262 #and then delete the temporary file 265 263 os.system('rm %s'%result[1]) 266 264 267 265 netcdf = f(self.title) #netcdf here is a cdms transient variable 268 266 269 267 270 268 #Now grab the netCDF object for the point specified. 271 272 273 274 275 276 277 278 print value279 print t_point.fill_value()280 281 282 283 284 285 286 287 288 289 print [value, fill_value] 290 291 292 293 269 #The reason for the 'cob' option is so that if the grid the data 270 #is defined on does not have a grid point at the point specified, 271 #we should still get the nearest location 272 273 t_point = netcdf(latitude=(point[1], point[1], 'cob'), longitude=(point[0], point[0], 'cob')) 274 #now get the value recorded at this location 275 value = t_point.getValue().tolist() 276 log.debug(value) 277 log.debug(t_point.fill_value()) 278 #and the fill_value too 279 fill_value = t_point.fill_value() 280 #value is actually embedded in a multi dimensional list, 281 #so we need to extract the actual value from the list 282 while type(value) is list: 283 value = value[0] 284 285 #now check if the value is actually the fill_value rather than 286 #a value recorded at the point specified 287 log.debug('%s %s' % (value, fill_value)) 288 if (2*fill_value) == value: 289 value = "No value found at position: "+str(point[1])+", "+str(point[0]) 290 else: 291 value = "Value found at position: "+str(point[1])+", "+str(point[0])+" is: "+str(value) 294 292 # finally return the value 295 293 return value … … 407 405 def __init__(self, layer, netcdf, bbox, width, height): 408 406 #we know the axes are called latitude and longitude as the CSML code has written it: 409 #print netcdf410 407 v=netcdf(layer.title) 411 #print v412 408 tvar=v(latitude=(bbox[1], bbox[3]), longitude=(bbox[0],bbox[2]),squeeze=1) 413 409 order=tvar.getOrder() 414 410 #array of data 415 411 self.value=tvar.getValue() 416 #print self.value417 #order of axes418 412 if order == 'xy': 419 413 self.ix=0 … … 428 422 self.dx=abs(lon[0]-lon[1]) 429 423 self.dy=abs(lat[0]-lat[1]) 430 #print [lon, len(lon)] 431 #print len(self.value) 432 print len(lon) 433 print len(lat) 434 435 436 437 424 425 426 427 438 428 439 429 self.nx=len(lon)
Note: See TracChangeset
for help on using the changeset viewer.