Ignore:
Timestamp:
24/09/08 15:19:12 (11 years ago)
Author:
spascoe
Message:

Changed print statements to loggging calls where appropriate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/service/imps/wms_csmllayer.py

    r3954 r4228  
    110110        @raise ValueError: If no layers are available for these keywords.  
    111111        """ 
    112         #print kwargs 
    113112        fileoruri=kwargs['fileoruri'] 
    114113        if fileoruri in self.layermapcache.keys(): 
    115114            #we've accessed this layer map before, get it from the cache dictionary 
    116             #print 'found layer map in cache' 
    117115            return self.layermapcache[fileoruri] 
    118116          
     
    153151        self._feature=feature 
    154152        self.legendSize=(30,100) 
    155         bb= self._feature.getCSMLBoundingBox().getBox() 
     153        bb= self._feature.getCSMLBoundingBox().getBox() 
    156154        #convert 0 - 360 to -180, 180 as per common WMS convention 
    157155        if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    158156            bb[0], bb[2]=-180, 180 
    159         self.wgs84BBox = bb 
    160         self.featureInfoFormats = ['text/html'] 
     157        self.wgs84BBox = bb 
     158        self.featureInfoFormats = ['text/html'] 
    161159        try: 
    162160            self.wgs84BBox = self.getBBox('EPSG:4326') 
     
    175173        #if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    176174        #    bb[0], bb[2]=-180, 180 
    177         #self.wgs84BBox = bb 
     175        #self.wgs84BBox = bb 
    178176        return self.wgs84BBox 
    179177        #raise NotImplementedError 
     
    207205            result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) 
    208206            #for now have to read netcdf back from  
    209             #disk (limitiation of CSML api) 
     207            #disk (limitiation of CSML api) 
    210208            netcdf=cdms.open(result[1]) 
    211209            #and then delete the temporary file 
     
    252250        dictindex=str((self._feature.id, dimValues)) 
    253251        if dictindex in self.featureinfofilecache: 
    254             print 'calling cache' 
     252            log.debug('calling cache') 
    255253            f=self.featureinfofilecache[dictindex] 
    256254        else: #else, use the csml api to subset the feature afresh 
    257             print 'not calling cache' 
     255            log.debug('not calling cache') 
    258256            randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 
    259257            result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) 
     
    264262            #and then delete the temporary file 
    265263            os.system('rm %s'%result[1]) 
    266          
     264         
    267265        netcdf = f(self.title)  #netcdf here is a cdms transient variable 
    268266         
    269267        
    270268        #Now grab the netCDF object for the point specified. 
    271         #The reason for the 'cob' option is so that if the grid the data  
    272         #is defined on does not have a grid point at the point specified,  
    273         #we should  still get the nearest location 
    274          
    275         t_point = netcdf(latitude=(point[1], point[1], 'cob'), longitude=(point[0], point[0], 'cob')) 
    276         #now get the value recorded at this location 
    277         value = t_point.getValue().tolist() 
    278         print value 
    279         print t_point.fill_value() 
    280         #and the fill_value too 
    281         fill_value = t_point.fill_value() 
    282         #value is actually embedded in a multi dimensional list,  
    283         #so we need to extract the actual value from the list 
    284         while type(value) is list: 
    285                 value = value[0] 
    286  
    287         #now check if the value is actually the fill_value rather than  
    288         #a value recorded at the point specified 
    289         print [value, fill_value] 
    290         if (2*fill_value) == value: 
    291                 value = "No value found at position: "+str(point[1])+", "+str(point[0]) 
    292         else: 
    293                 value = "Value found at position: "+str(point[1])+", "+str(point[0])+" is: "+str(value) 
     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) 
    294292        # finally return the value 
    295293        return value 
     
    407405    def __init__(self, layer, netcdf, bbox, width, height): 
    408406        #we know the axes are called latitude and longitude as the CSML code has written it: 
    409         #print netcdf 
    410407        v=netcdf(layer.title) 
    411         #print v 
    412408        tvar=v(latitude=(bbox[1], bbox[3]), longitude=(bbox[0],bbox[2]),squeeze=1) 
    413409        order=tvar.getOrder() 
    414410        #array of data 
    415411        self.value=tvar.getValue() 
    416         #print self.value 
    417         #order of axes 
    418412        if order == 'xy': 
    419413            self.ix=0 
     
    428422        self.dx=abs(lon[0]-lon[1]) 
    429423        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         
    438428 
    439429        self.nx=len(lon) 
Note: See TracChangeset for help on using the changeset viewer.