Changeset 6394


Ignore:
Timestamp:
25/01/10 13:00:00 (9 years ago)
Author:
pnorton
Message:

Major refactoring of the wms code. the csml wms code is now based on the geoplot wms code. I've also increased the use of inheritance in the geoplot wms code to reduce duplication.

Location:
cows/trunk/cows/service/imps
Files:
4 added
1 deleted
2 edited
3 copied
9 moved

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/service/imps/csmlbackend/__init__.py

    r4912 r6394  
    66# the full license text. 
    77 
     8 
     9from cows.service.imps.csmlbackend.csmlcommon import CSMLConnector 
     10 
     11_globalCSMLConnector = None 
     12 
     13def getGlobalCSMLConnector(): 
     14    global _globalCSMLConnector 
     15     
     16    if _globalCSMLConnector is None: 
     17        _globalCSMLConnector = CSMLConnector() 
     18     
     19    return _globalCSMLConnector 
  • cows/trunk/cows/service/imps/csmlbackend/csmlcommon.py

    r6393 r6394  
    193193        return os.path.isdir(os.path.join(self.csml_dir, fc)) 
    194194 
    195 # 
    196 # Global CSML connector instance 
    197 # 
    198 globalCSMLConnector = CSMLConnector() 
  • cows/trunk/cows/service/imps/csmlbackend/wms/csml_data_reader.py

    r6393 r6394  
    66 
    77from cows.service.imps.csmlbackend.config import config 
    8 from cows.service.imps.data_reader_geoplot_backend import getGlobalCSMLConnector 
     8from cows.service.imps.csmlbackend import getGlobalCSMLConnector 
    99 
    1010import numpy 
  • cows/trunk/cows/service/imps/csmlbackend/wms/csml_layer_builder.py

    r6393 r6394  
    1010import os 
    1111 
    12 from cows.service.imps.csmlbackend.wms_csmllayer import CSMLwmsDimension 
    13  
    14 from cows.service.imps.data_reader_geoplot_backend.data_reader_geoplot_wms_layer import DRGeoplotWmsLayer 
    15 from cows.service.imps.data_reader_geoplot_backend.csml_data_reader import CSMLDataReader 
    16 from cows.service.imps.data_reader_geoplot_backend import getGlobalCSMLConnector 
     12from cows.service.imps.csmlbackend import getGlobalCSMLConnector 
     13from cows.service.imps.csmlbackend.wms.wms_csmllayer import CSMLwmsLayer, CSMLwmsDimension 
     14from cows.service.imps.csmlbackend.wms.csml_data_reader import CSMLDataReader 
    1715 
    1816import logging 
     
    8684        for fc in self.connector.list(folder=fileoruri): 
    8785             
    88             l = DRGeoplotWmsLayer(self.getTitle(fc), 
    89                                   abstract=self.getAbstract(fc)) 
     86            l = self._buildGroupingLayer(self.getTitle(fc), self.getAbstract(fc)) 
    9087             
    9188            # remove the default feature info formats so this layer is not 
     
    121118        return dataLayers 
    122119 
     120    def _buildGroupingLayer(self, title, abstract): 
     121        """ 
     122        creates a layer object with only a title and abstract, used for containing other 
     123        layers 
     124        """ 
     125        return CSMLwmsLayer(title, abstract) 
     126 
    123127    def _buildDataLayer(self, feature, fileoruri, dataReader): 
    124128        """ 
     
    132136        name = fileoruri.replace('/','_') + '_' +feature.id 
    133137         
    134         layer = DRGeoplotWmsLayer(name=name, title=title, abstract=abstract,  
    135                                  dimensions=dimensions, units=units, crss=crss,  
    136                                  boundingBox=bb, dataReader=dataReader) 
     138        layer = CSMLwmsLayer(name=name, title=title, abstract=abstract,  
     139                             dimensions=dimensions, units=units, crss=crss,  
     140                             boundingBox=bb, dataReader=dataReader) 
    137141         
    138142        return layer 
     
    193197             
    194198        return title, abstract, dimensions, units, crss 
    195  
    196     @staticmethod 
    197     def isDataPresent(fileoruri): 
    198         connector = getGlobalCSMLConnector() 
    199          
    200         for file in connector.list(): 
    201              
    202             if file == fileoruri: 
    203                 return True 
    204              
    205         return False 
  • cows/trunk/cows/service/imps/csmlbackend/wms/wms_csmllayer.py

    r6393 r6394  
    3838from cows import bbox_util 
    3939 
    40 class CSMLwmsLayerMapper(CSMLLayerMapper): 
     40DEFAULT_STYLE='' 
     41 
     42class Old_CSMLwmsLayerMapper(CSMLLayerMapper): 
    4143    """ 
    4244    Map keyword arguments to a collection of layers. 
     
    4749    """ 
    4850    def __init__(self): 
    49         super(CSMLwmsLayerMapper, self).__init__() 
     51        super(Old_CSMLwmsLayerMapper, self).__init__() 
    5052     
    5153    #!TODO: (spascoe) Could be _getInfo() to make it clear it's internal 
     
    5456        @return:   title, abstract, dimensions, units, crss ''' 
    5557 
    56         title, abstract = super(CSMLwmsLayerMapper, self).getInfo(feature) 
     58        title, abstract = super(Old_CSMLwmsLayerMapper, self).getInfo(feature) 
    5759        units=feature.getDomainUnits()   
    5860        dimensions={} 
     
    124126    """ 
    125127     
    126     def __init__(self, title, abstract, dimensions, units, crss, feature, 
    127                  name=None): 
     128    def __init__(self, title, abstract, dimensions=None, units=None, crss=None, 
     129                 name=None, dataReader=None, childLayers=None, boundingBox=None): 
    128130        self.featureInfoFormats=None #NotImplemented 
    129131        self.title=title 
     
    133135        self.units=units 
    134136        self.crss=crss 
    135         self._feature=feature 
     137         
     138        self.dataReader = dataReader 
     139         
     140        if childLayers is None: 
     141            self.childLayers = [] 
     142        else: 
     143            self.childLayers = childLayers 
     144                 
    136145        self.legendSize=(630,80) 
    137146        self._minval=0 
    138         self._maxval=10.0 #dummy values  
    139         try:  
    140             bb = self._feature.getCSMLBoundingBox().getBox() 
    141         except: 
    142             #default to global 
    143             bb=[-180,-90,180,90] 
    144         #convert 0 - 360 to -180, 180 as per common WMS convention 
    145         if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    146             bb[0], bb[2]=-180, 180 
    147         self.wgs84BBox = bb 
     147        self._maxval=10.0 #dummy values 
     148         
     149        if boundingBox is not None: 
     150            bb=boundingBox 
     151 
     152            #convert 0 - 360 to -180, 180 as per common WMS convention 
     153            if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
     154                bb[0], bb[2]=-180, 180 
     155                 
     156            self.wgs84BBox = bb 
     157 
     158            try: 
     159                self.wgs84BBox = self.getBBox('EPSG:4326') 
     160            except: 
     161                raise ValueError("Layer must provide a bounding box in EPSG:4326 " 
     162                                 "coordinates for compatibility with WMS-1.3.0") 
     163                 
    148164        self.featureInfoFormats = ['text/html'] 
    149         try: 
    150             self.wgs84BBox = self.getBBox('EPSG:4326') 
    151         except: 
    152             raise ValueError("Layer must provide a bounding box in EPSG:4326 " 
    153                              "coordinates for compatibility with WMS-1.3.0") 
    154165        self.featureinfofilecache={} #used for caching netcdf file in getFeatureInfo 
    155166         
     
    167178        #raise NotImplementedError 
    168179         
    169     def getSlab(self, crs, style, dimValues, transparent, bgcolor, renderOpts={}): 
     180    def getSlab(self, crs, style, dimValues, transparent, bgcolor, additionalParams={}): 
    170181        """ 
    171182        Creates a slab of the layer in a particular CRS and set of 
     
    181192        """ 
    182193 
    183         log.debug('getSlab(%s, %s)' % (crs, dimValues)) 
    184          
    185         #unicode conversion 
    186         for dimval in dimValues: 
    187             if dimval != 'time': 
    188                 dimValues[dimval]=float(dimValues[dimval]) 
    189             else: 
    190                 #remove any trailing Zs from time string 
    191                 if dimValues[dimval] [-1:] in ['Z', 'z']: 
    192                     dimValues[dimval]=dimValues[dimval][:-1] 
    193         if type(self._feature) == csml.parser.GridSeriesFeature: 
    194             randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 
    195             result= self._feature.subsetToGridSeries(config['tmpdir'], ncname=randomname, **dimValues) 
    196             #for now have to read netcdf back from  
    197             #disk (limitiation of CSML api) 
    198             netcdf=cdms.open(result[1]) 
    199             #and then delete the temporary file 
    200             os.system('rm %s'%result[1]) 
    201             bbox=self.getBBox(crs) 
    202             slab = CSMLwmsLayerSlab(netcdf, self, crs, dimValues, renderOpts, bbox) 
    203             self._minval=slab.minval #needed for legend rendering. 
    204             self._maxval=slab.maxval 
    205             return slab 
    206         else: 
    207             raise NotImplementedError 
    208          
    209     def getCacheKey(self, crs, style, dimValues, transparent, bgcolor, renderOpts={}): 
     194        var = self.dataReader.getNetcdfVar(self.title, dimValues) 
     195         
     196        bbox=self.getBBox(crs) 
     197        slab = CSMLwmsLayerSlab(var, self, crs, dimValues, additionalParams, bbox) 
     198        self._minval=slab.minval #needed for legend rendering. 
     199        self._maxval=slab.maxval 
     200        return slab 
     201         
     202    def getCacheKey(self, crs, style, dimValues, transparent, bgcolor,  
     203                    additionalParams={}):  
    210204        """ 
    211205        Create a unique key for use in caching a slab. 
     
    218212 
    219213        """ 
     214 
    220215        dimList = list(dimValues.items()) 
    221216        dimList.sort() 
    222         return '%s:%s:%s' % (self._feature.id, crs, dimList) 
     217 
     218        #set the default style if none provided 
     219        s = self._getActualStyle(style) 
     220             
     221        return '%s:%s:%s:%s:%s:%s:%s' % (self.name, crs, s, dimList, 
     222                                      transparent, bgcolor, additionalParams) 
     223 
     224    def _getActualStyle(self, style=None): 
     225        actualStyle = None 
     226         
     227        if style == 'default' or style == '' or style is None: 
     228            actualStyle = DEFAULT_STYLE 
     229        else: 
     230            actualStyle = style 
     231                      
     232        return actualStyle 
     233     
    223234 
    224235    def getFeatureInfo(self, format, crs, point, dimValues): 
     
    239250        """ 
    240251         
    241         #cached netcdf is indexed by a tuple of feature id and dimvalues - i.e. typically a particular time and Z value for that feature. 
    242         #look in dictionary for cached copy, and if so use that as the file object. 
    243         dictindex=str((self._feature.id, dimValues)) 
    244         if dictindex in self.featureinfofilecache: 
    245             log.debug('calling cache') 
    246             f=self.featureinfofilecache[dictindex] 
    247         else: #else, use the csml api to subset the feature afresh 
    248             log.debug('not calling cache') 
    249             randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 
    250             result= self._feature.subsetToGridSeries(config['tmpdir'], ncname=randomname, **dimValues) 
    251             #for now have to read netcdf back from disk (limitation of CSML api) 
    252             f=cdms.open(result[1]) 
    253             #append to cache: 
    254             self.featureinfofilecache[dictindex]=f 
    255             #and then delete the temporary file 
    256             os.system('rm %s'%result[1]) 
    257          
    258         netcdf = f(self.title)  #netcdf here is a cdms transient variable 
    259          
     252        netcdf = self.dataReader.getNetcdfVar(self.title, dimValues) 
    260253        
    261254        #Now grab the netCDF object for the point specified. 
     
    283276        else: 
    284277                value = "Value found at position: "+str(point[1])+", "+str(point[0])+" is: "+str(value) 
     278                 
    285279        # finally return the value 
    286280        return value 
     
    302296        if 'height' in renderOpts: 
    303297                height = renderOpts['height'] 
     298                 
    304299        cmap = cm.get_cmap(config['colourmap']) 
    305300        renderer=RGBARenderer(self._minval, self._maxval) 
     
    384379    """ 
    385380 
    386     def __init__(self, netcdf, layer, crs, dimValues, renderOpts, bbox): 
    387         self._netcdf=netcdf 
     381    def __init__(self, var, layer, crs, dimValues, renderOpts, bbox): 
     382        self._var=var 
    388383        self.layer = layer 
    389384        self.crs = crs 
     
    393388         
    394389        #set colour map for ALL images from this slab 
    395         v=self._netcdf(layer.title) 
    396         tvar=v(squeeze=1) 
     390        tvar=var(squeeze=1) 
     391         
    397392        #get the min and max values to use for the colourmapping. 
    398393        #change the fill values to ensure they aren't picked up as false max/mins. 
     
    453448        cmap = cm.get_cmap(config['colourmap']) 
    454449 
    455         grid=Grid(self.layer, self._netcdf, bbox, width, height) 
     450        grid=Grid(self.layer, self._var, bbox, width, height) 
    456451        #If there is no data for the requested area, return a blank image: 
    457452        #TODO this should be included in the overhauled rendering code 
     
    493488    @ivar units: The units of the field. 
    494489    """ 
    495     def __init__(self, layer, netcdf, bbox, width, height): 
     490    def __init__(self, layer, var, bbox, width, height): 
    496491        #we know the axes are called latitude and longitude as the CSML code has written it: 
    497         v=netcdf(layer.title)         
     492        v=var   
    498493         
    499494        #sometimes these dimensions get squeezed out so need to get hold of the dx, dy spacing before the variable is subsetted. 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/__init__.py

    r6393 r6394  
    1  
    2 from cows.service.imps.csmlbackend.csmlcommon import CSMLConnector 
    3  
    4 _globalCSMLConnector = None 
    5  
    6 def getGlobalCSMLConnector(): 
    7     global _globalCSMLConnector 
    8      
    9     if _globalCSMLConnector is None: 
    10         _globalCSMLConnector = CSMLConnector() 
    11      
    12     return _globalCSMLConnector 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/geoplot_layer_mapper.py

    r6102 r6394  
    88from copy import copy 
    99 
    10 from cows.service.wxs_iface import ILayerMapper 
     10from cows.service.imps.csmlbackend.wms.csml_wms_layer_mapper import CSMLWmsLayerMapper 
    1111 
    12 from cows.service.imps.data_reader_geoplot_backend.data_reader_geoplot_wms_layer import DRGeoplotWmsLayer 
    13  
    14 from cows.service.imps.data_reader_geoplot_backend.data_readers.csml_data_reader import CSMLDataReader 
     12from cows.service.imps.geoplot_wms_backend.geoplot_layer_builder import GeoplotLayerBuilder 
    1513 
    1614log = logging.getLogger(__name__) 
    1715 
    18 class DRGeoplotLayerMapper(ILayerMapper): 
     16class GeoplotLayerMapper(CSMLWmsLayerMapper): 
    1917     
    20     def __init__(self): 
    21         self.layermapcache={} 
    22         self.readerClasses = [CSMLDataReader] 
    23     
    24     def map(self, **kwargs): 
     18    def _getBuilder(self, fileoruri): 
    2519        """ 
    26         Given csml.parser.Dataset object list the names of 
    27         all layers available. 
    28          
    29         @return: A mapping of layer names to ILayer implementations. 
    30         @raise ValueError: If no layers are available for these keywords.  
    31         """ 
    32         fileoruri=kwargs['fileoruri'] 
    33          
    34         if fileoruri in self.layermapcache.keys(): 
    35              
    36             log.debug("cached layermap used for fileoruri = %s" % (fileoruri,)) 
    37              
    38             self.datasetName = self.layermapcache[fileoruri]['dsName']  
    39             #we've accessed this layer map before, get it from the cache dictionary 
    40             return self.layermapcache[fileoruri]['layermap'] 
    41          
    42  
    43         layermap={} 
    44          
    45         reader = self._getReader(fileoruri) 
    46          
    47         try: 
    48             self.datasetName = reader.ds.name.CONTENT 
    49         except AttributeError: 
    50             self.datasetName = 'CSML/Geoplot WMS Service' 
    51              
    52         log.debug("fileoruri = %s, self.datasetName = %s" % (fileoruri, self.datasetName)); 
    53          
    54         for name, title, abstract, dimensions, units, crss, bb in \ 
    55                                      reader.getWMSLayerInfo(): 
    56              
    57             layermap[name] = DRGeoplotWmsLayer(name, title, abstract, dimensions, units, crss, bb, reader) 
    58              
    59              
    60         if len(layermap) > 0: 
    61             self.layermapcache[fileoruri]={'layermap':layermap, 
    62                                            'dsName':self.datasetName} 
    63             return layermap 
    64         else: 
    65             raise ValueError 
    66          
    67     def _getReader(self, fileoruri): 
    68         """ 
    69         Searches the reader classes to find one that contains the data for  
    70         the fileoruri given, when found the class is returned. If no 
    71         reader class is found and Exception is raised. 
     20        Creates a layer builder object to be used to generate the layers 
    7221        """ 
    7322         
    74         log.debug("CSMLDataReader.isDataPresent(fileoruri) = %s" % (CSMLDataReader.isDataPresent(fileoruri),)) 
    75         reader = None 
     23        builder = GeoplotLayerBuilder() 
    7624         
    77         for klass in self.readerClasses: 
    78             if klass.isDataPresent(fileoruri): 
    79                 reader = klass(fileoruri) 
    80                 break 
    81          
    82         if reader == None: 
    83             raise Exception("No reader found for fileoruri = %s" % (fileoruri,)) 
    84          
    85         return reader 
     25        return builder 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/geoplot_wms_layer.py

    r6123 r6394  
    1818 
    1919import geoplot.colour_bar 
    20 from geoplot.grid_builder_lat_lon import GridBuilderLatLon 
    2120 
    2221from cows.model.wms import Style, LegendURL, FormattedURL, MetadataURL 
     
    2524from routes import url_for 
    2625 
    27 from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_contour import GeoplotSlabContour 
    28 from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_grid import GeoplotSlabGrid 
    29 from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_interval import GeoplotSlabInterval 
    30 from cows.service.imps.data_reader_geoplot_backend.slab_options_parser import SlabOptionsParser 
    31  
    32  
    33 class DRGeoplotWmsLayer(IwmsLayer): 
    34  
    35     slab_classes = [GeoplotSlabGrid, GeoplotSlabContour, GeoplotSlabInterval] 
    36     default_slab_class = GeoplotSlabGrid 
     26from cows.service.imps.csmlbackend.wms.wms_csmllayer import CSMLwmsLayer 
     27 
     28from cows.service.imps.geoplot_wms_backend.slabs.slab_contour import SlabContour 
     29from cows.service.imps.geoplot_wms_backend.slabs.slab_grid import SlabGrid 
     30from cows.service.imps.geoplot_wms_backend.slabs.slab_interval import SlabInterval 
     31from cows.service.imps.geoplot_wms_backend.slab_options_parser import SlabOptionsParser 
     32 
     33 
     34class GeoplotWmsLayer(CSMLwmsLayer): 
     35 
     36    slab_classes = [SlabGrid, SlabContour, SlabInterval] 
     37    default_slab_class = SlabGrid 
    3738     
    3839    EnableDisplayOptions = False 
    3940    EnableXMLAxisConfig = False 
    4041     
    41     def __init__(self, name, title, abstract, dimensions, units, crss,  
    42                  boundingBox, dataReader): 
    43         self.featureInfoFormats=None #NotImplemented 
    44         self.title=title 
    45         self.abstract=abstract 
    46         self.dimensions=dimensions 
    47         self.units=units 
    48         self.crss=crss 
    49         self.legendSize=(630,120) 
    50          
    51         # dummy values, will need to be set when the data is opened 
    52         self._minval = None 
    53         self._maxval = None  
    54          
    55         self.name = name 
    56         self.dataReader = dataReader 
    57          
    58         self.styles = self._buildStyles() 
    59         self.metadataURLs = self._buildMetadataURL() 
    60          
    61         bb = boundingBox 
    62              
    63         #convert 0 - 360 to -180, 180 as per common WMS convention 
    64         if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    65             bb[0], bb[2]=-180, 180 
    66              
    67         self.wgs84BBox = bb 
    68         self.featureInfoFormats = ['text/html'] 
    69          
    70         try: 
    71             self.wgs84BBox = self.getBBox('EPSG:4326') 
    72         except: 
    73             raise ValueError("Layer must provide a bounding box in EPSG:4326 " 
    74                              "coordinates for compatibility with WMS-1.3.0") 
    75              
    76         self.featureinfofilecache={} #used for caching netcdf file in getFeatureInfo 
    77      
    78     def getBBox(self, crs): 
    79         """ 
    80         @return: A 4-typle of the bounding box in the given coordinate 
    81             reference system. 
    82         """ 
    83         #bb= self._feature.getCSMLBoundingBox().getBox() 
    84         #convert 0 - 360 to -180, 180 as per common WMS convention 
    85         #if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    86         #    bb[0], bb[2]=-180, 180 
    87         #self.wgs84BBox = bb 
    88         return self.wgs84BBox 
    89         #raise NotImplementedError 
     42    def __init__(self, title, abstract, name=None, dimensions=None,  
     43                       units=None, crss=None, boundingBox=None,  
     44                       dataReader=None, childLayers=None): 
     45         
     46        CSMLwmsLayer.__init__(self, title, abstract, name=name, dimensions=dimensions, 
     47                     units=units, crss=crss, boundingBox=boundingBox, 
     48                     dataReader=dataReader, childLayers=childLayers) 
     49         
     50        if name is not None: 
     51            self.styles = self._buildStyles() 
     52            self.metadataURLs = self._buildMetadataURL() 
    9053         
    9154    def getSlab(self, crs, style, dimValues, transparent, bgcolor,  
     
    10366        #create netcdf for whole lat/lon for given dimValues, use to init slab 
    10467        """ 
    105         log.debug("additionalParams = %s" % (additionalParams,)) 
    106         log.debug("bgcolor = %s" % (bgcolor,)) 
    107         log.debug("transparent = %s" % (transparent,)) 
    108         log.debug("dimValues = %s" % (dimValues,)) 
    10968         
    11069        #make the colour compatable with matplotlib 
     
    11271            bgcolor = '#' + bgcolor[2:] 
    11372         
    114         st = time.time() 
    115         netcdfVar = self.dataReader.getNetcdfVar(self.name, dimValues) 
    116         log.debug("got netcdf in %ss" % (time.time() - st,)) 
     73        netcdfVar = self.dataReader.getNetcdfVar(self.title, dimValues) 
    11774         
    11875        slabClass = self._getSlabClass(style) 
     
    12380                
    12481        return slab 
    125    
    126     def getCacheKey(self, crs, style, dimValues, transparent, bgcolor,  
    127                     additionalParams={}):  
    128         """ 
    129         Create a unique key for use in caching a slab. 
    130  
    131         The intention here is that most of the work should be done when 
    132         instantiating an ILayerSlab object.  These can be cached by the 
    133         server for future use.  The server will first call getCacheKey() 
    134         for the slab creation arguments and if the key is in it's cache 
    135         it will use a pre-generated ILayerSlab object. 
    136  
    137         """ 
    138  
    139         dimList = list(dimValues.items()) 
    140         dimList.sort() 
    141  
    142         #set the default style if none provided 
    143         s = self._getActualStyle(style) 
    144              
    145         return '%s:%s:%s:%s:%s:%s:%s' % (self.name, crs, s, dimList, 
    146                                       transparent, bgcolor, additionalParams) 
    14782 
    14883    def _getActualStyle(self, style=None): 
     
    15085         
    15186        if style == 'default' or style == '' or style is None: 
    152             actualStyle = DRGeoplotWmsLayer.default_slab_class.style 
     87            actualStyle = GeoplotWmsLayer.default_slab_class.style 
    15388        else: 
    15489            actualStyle = style 
    15590         
    156         if actualStyle not in [x.style for x in DRGeoplotWmsLayer.slab_classes]: 
     91        if actualStyle not in [x.style for x in GeoplotWmsLayer.slab_classes]: 
    15792            Exception("No slab class found for style = %s"  % (style,)) 
    15893              
     
    16499        s = self._getActualStyle(style) 
    165100         
    166         for klass in DRGeoplotWmsLayer.slab_classes: 
     101        for klass in GeoplotWmsLayer.slab_classes: 
    167102            if klass.style == s: 
    168103                slabClass = klass 
     
    190125 
    191126        """ 
    192          
    193 #        #cached netcdf is indexed by a tuple of feature id and dimvalues - i.e. typically a particular time and Z value for that feature. 
    194 #        #look in dictionary for cached copy, and if so use that as the file object. 
    195 #        dictindex=str((self._feature.id, dimValues)) 
    196 #         
    197 #        if dictindex in self.featureinfofilecache: 
    198 #            log.debug('calling cache') 
    199 #            f=self.featureinfofilecache[dictindex] 
    200 #        else: #else, use the csml api to subset the feature afresh 
    201 #            log.debug('not calling cache') 
    202 #            randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 
    203 #            result= self._feature.subsetToGridSeries(config['tmpdir'], ncname=randomname, **dimValues) 
    204 #            #for now have to read netcdf back from disk (limitation of CSML api) 
    205 #            f=cdms.open(result[1]) 
    206 #            #append to cache: 
    207 #            self.featureinfofilecache[dictindex]=f 
    208 #            #and then delete the temporary file 
    209 #            os.system('rm %s'%result[1]) 
    210 #         
    211 #        netcdf = f(self.title)  #netcdf here is a cdms transient variable 
    212          
    213         netcdf = self.dataReader.getNetcdfVar(self.name, dimValues) 
     127        netcdf = self.dataReader.getNetcdfVar(self.title, dimValues) 
    214128        
    215129        #Now grab the netCDF object for the point specified. 
     
    258172            height = self.legendSize[1] 
    259173                 
    260         variable = self.dataReader.getNetcdfVar(self.name, dimValues) 
     174        variable = self.dataReader.getNetcdfVar(self.title, dimValues) 
    261175         
    262176        klass = self._getSlabClass(style) 
     
    306220         
    307221        styles = [] 
    308         for klass in DRGeoplotWmsLayer.slab_classes: 
     222        for klass in GeoplotWmsLayer.slab_classes: 
    309223             
    310224            styleName = klass.style 
     
    334248        metadataURLs = [] 
    335249         
    336         if DRGeoplotWmsLayer.EnableDisplayOptions == True: 
     250        if GeoplotWmsLayer.EnableDisplayOptions == True: 
    337251            onlineRes = OnlineResource(self._getIndexActionURL() +\ 
    338252                       "?request=GetDisplayOptions&layers=%s" % self.name) 
     
    342256                                          onlineResource=onlineRes) ) 
    343257             
    344         if DRGeoplotWmsLayer.EnableXMLAxisConfig: 
     258        if GeoplotWmsLayer.EnableXMLAxisConfig: 
    345259             
    346260            xmlFile =  self.getAxisConfigFile() 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/slabs/slab_base.py

    r6123 r6394  
    88from cows.service.wms_iface import IwmsLayerSlab 
    99from cows.service.imps.image_import import Image 
    10 from cows.service.imps.data_reader_geoplot_backend.slab_options_parser import SlabOptionsParser 
    11 from cows.service.imps.data_reader_geoplot_backend.rendering_option import RenderingOption 
     10from cows.service.imps.geoplot_wms_backend.slab_options_parser import SlabOptionsParser 
     11from cows.service.imps.geoplot_wms_backend.rendering_option import RenderingOption 
    1212     
    1313log = logging.getLogger(__name__) 
    1414 
    15 class GeoplotSlabBase(IwmsLayerSlab): 
     15class SlabBase(IwmsLayerSlab): 
    1616    """ 
    1717    A layer slab that implements the IwmsLayerSlab interface and uses geoplot 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/slabs/slab_contour.py

    r6300 r6394  
    66from geoplot.layer_drawer_contour import LayerDrawerContour 
    77 
    8 from cows.service.imps.data_reader_geoplot_backend.rendering_option import RenderingOption 
    9 from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_base import GeoplotSlabBase 
    10 from cows.service.imps.data_reader_geoplot_backend.slab_options_parser import SlabOptionsParser 
     8from cows.service.imps.geoplot_wms_backend.slabs.slab_base import SlabBase 
     9from cows.service.imps.geoplot_wms_backend.slab_options_parser import SlabOptionsParser 
     10from cows.service.imps.geoplot_wms_backend.rendering_option import RenderingOption 
    1111 
    1212log = logging.getLogger(__name__) 
    1313 
    14  
    15  
    16 class GeoplotSlabContour(GeoplotSlabBase): 
     14class SlabContour(SlabBase): 
    1715 
    1816    style = 'contour' 
    1917    title = 'Contour Lines' 
    2018                       
    21     renderingOptions = GeoplotSlabBase.renderingOptions + [        
     19    renderingOptions = SlabBase.renderingOptions + [        
    2220        RenderingOption('num_contour_lines', "Number of Contour Lines" ,int,10), 
    2321        RenderingOption('contour_font_size', "Contour Label Size" ,str,'medium',["small","medium", "large",]), 
     
    4543    def makeColourBar(width , height, orientation, units, renderOpts, variable): 
    4644         
    47         parser = SlabOptionsParser(GeoplotSlabContour.renderingOptions, renderOpts) 
     45        parser = SlabOptionsParser(SlabContour.renderingOptions, renderOpts) 
    4846                 
    4947        minval = parser.getOption('cmap_min') 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/slabs/slab_grid.py

    r6300 r6394  
    77from geoplot.layer_drawer_grid_fast import LayerDrawerGridFast 
    88 
    9 from cows.service.imps.data_reader_geoplot_backend.rendering_option import RenderingOption 
    10 from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_base import GeoplotSlabBase 
    11 from cows.service.imps.data_reader_geoplot_backend.slab_options_parser import SlabOptionsParser 
     9from cows.service.imps.geoplot_wms_backend.slabs.slab_base import SlabBase 
     10from cows.service.imps.geoplot_wms_backend.slab_options_parser import SlabOptionsParser 
     11from cows.service.imps.geoplot_wms_backend.rendering_option import RenderingOption 
    1212 
    1313log = logging.getLogger(__name__) 
    1414 
    15 class GeoplotSlabGrid(GeoplotSlabBase): 
     15class SlabGrid(SlabBase): 
    1616 
    1717    style = 'grid' 
    1818    title = 'Grid Boxes' 
    1919                         
    20     renderingOptions = GeoplotSlabBase.renderingOptions +[      
     20    renderingOptions = SlabBase.renderingOptions +[      
    2121        RenderingOption('disable_subset', "Disable Subsetting" ,bool,False), 
    2222        RenderingOption('show_grid_lines', "Draw Grid Boxes" ,bool,False), 
     
    4747    def makeColourBar(width , height, orientation, units, renderOpts, variable): 
    4848         
    49         parser = SlabOptionsParser(GeoplotSlabGrid.renderingOptions, renderOpts) 
     49        parser = SlabOptionsParser(SlabGrid.renderingOptions, renderOpts) 
    5050                 
    5151        minval = parser.getOption('cmap_min') 
  • cows/trunk/cows/service/imps/geoplot_wms_backend/slabs/slab_interval.py

    r6300 r6394  
    77from geoplot.layer_drawer_grid_fast import LayerDrawerGridFast 
    88 
    9 from cows.service.imps.data_reader_geoplot_backend.rendering_option import RenderingOption 
    10 from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_base import GeoplotSlabBase 
    11 from cows.service.imps.data_reader_geoplot_backend.slab_options_parser import SlabOptionsParser 
     9from cows.service.imps.geoplot_wms_backend.slabs.slab_base import SlabBase 
     10from cows.service.imps.geoplot_wms_backend.slab_options_parser import SlabOptionsParser 
     11from cows.service.imps.geoplot_wms_backend.rendering_option import RenderingOption 
    1212 
    1313log = logging.getLogger(__name__) 
    1414 
    15 class GeoplotSlabInterval(GeoplotSlabBase): 
     15class SlabInterval(SlabBase): 
    1616 
    1717    style = 'interval' 
    1818    title = 'Intervals' 
    1919                         
    20     renderingOptions = GeoplotSlabBase.renderingOptions +[      
     20    renderingOptions = SlabBase.renderingOptions +[      
    2121        RenderingOption('disable_subset', "Disable Subsetting" ,bool,False), 
    2222        RenderingOption('show_grid_lines', "Draw Grid Boxes" ,bool,False), 
     
    5353    def makeColourBar(width , height, orientation, units, renderOpts, variable): 
    5454         
    55         parser = SlabOptionsParser(GeoplotSlabInterval.renderingOptions, renderOpts) 
     55        parser = SlabOptionsParser(SlabInterval.renderingOptions, renderOpts) 
    5656                 
    5757        minval = parser.getOption('cmap_min') 
Note: See TracChangeset for help on using the changeset viewer.