Changeset 5684 for cows


Ignore:
Timestamp:
03/09/09 15:31:19 (10 years ago)
Author:
pnorton
Message:

Fixed a problem in the masking of the landtype_common variable from the modis_file_reader. The index 0 data was bing masked along with the cases where all the indicies are 0.0.

Also made some small improvements to the geoplot layers.

Location:
cows/trunk/cows/service/imps/data_reader_geoplot_backend
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/service/imps/data_reader_geoplot_backend/data_reader_geoplot_layer_mapper.py

    r5682 r5684  
    5858         
    5959    def _getReader(self, fileoruri): 
     60        """ 
     61        Searches the reader classes to find one that contains the data for  
     62        the fileoruri given, when found the class is returned. If no 
     63        reader class is found and Exception is raised. 
     64        """ 
    6065         
    6166        log.debug("CSMLDataReader.isDataPresent(fileoruri) = %s" % (CSMLDataReader.isDataPresent(fileoruri),)) 
  • cows/trunk/cows/service/imps/data_reader_geoplot_backend/data_reader_geoplot_wms_layer.py

    r5682 r5684  
    1717log = logging.getLogger(__name__) 
    1818 
    19 from cows.service.imps.data_reader_geoplot_backend.data_reader_geoplot_wms_layer_slab_base import DRGeoplotWmsLayerSlab, STYLES 
     19from cows.service.imps.data_reader_geoplot_backend.data_reader_geoplot_wms_layer_slab import DRGeoplotWmsLayerSlab, STYLES 
    2020from cows.service.imps.data_reader_geoplot_backend.data_reader_geoplot_render_options_parser import DRGeoplotRenderOptionsParser  
    2121 
  • cows/trunk/cows/service/imps/data_reader_geoplot_backend/data_readers/modis_file_reader.py

    r5682 r5684  
    55 
    66from cows.service.imps.data_reader_geoplot_backend.data_readers.mosid_config import config 
    7  
    8 modis_file_path = '/data/pnorton/qesdi_data/modis/modis_data/MCD12Q1_10min/MODIS_classification_IGBP.nc' 
    97 
    108log = logging.getLogger(__name__) 
     
    4240            yield (name, title, abstract, dimensions, units, crss, bb) 
    4341             
    44  
    45      
    4642    def _getBBox(self): 
    4743        try:  
     
    5652            bb=[-180,-90,180,90] 
    5753        return bb         
    58  
    5954 
    6055    def getNetcdfVar(self, name,  dimValues): 
     
    9691        return var 
    9792     
    98          
    9993    def _convertDimValues(self, dimValues): 
    10094        """ 
     
    116110     
    117111    def _getLandtypeCommon(self, convertedDimValues): 
     112        # the problem is we need to know when all the land types are 0  
     113        # and put that as a mask, otherwise we need to use the index of the  
     114        # maxiumum 
    118115         
     116        (nx, ny, nz) = self.var.shape 
     117        log.debug("nx = %s, ny=%s, nz=%s" % (nx, ny, nz)) 
     118         
     119        #assuming the axis are lat, lon index, sum over the index axis 
     120        sumArr = self.var[:].sum(axis=2) 
     121         
     122        #create a mask where this sum is 0.0 
     123        mask = sumArr == 0.0 
     124         
     125        #get the index of the maximum for the actual data ( should be 0-15) 
    119126        arr = self.var[:].argmax(2) 
    120         common_var = cdms.createVariable(arr, axes=self.var.getAxisList()[0:2], fill_value=0.0) 
     127         
     128        common_var = cdms.createVariable(arr, axes=self.var.getAxisList()[0:2], 
     129                                         mask=mask) 
     130         
     131         
    121132        return common_var 
    122133         
     
    126137        return var_n 
    127138         
    128      
    129139    @staticmethod 
    130140    def isDataPresent(fileoruri): 
     
    134144        else: 
    135145            return fileoruri == config['modis_variable'] 
     146 
     147 
     148if __name__ == '__main__': 
     149     
     150    import logging 
     151    logging.basicConfig(level=logging.DEBUG, format='%(name)-10s %(asctime)s ln:%(lineno)-3s %(levelname)-8s\n %(message)s\n') 
     152     
     153    config['modis_variable'] = 'landtype' 
     154    config['modis_file'] = '/data/pnorton/qesdi_data/modis/modis_data/MCD12Q1_10min/MODIS_classification_IGBP.nc' 
     155     
     156     
     157    reader = ModisFileReader('landtype') 
     158     
     159    var = reader._getLandtypeCommon({}) 
     160     
     161    print var.id 
Note: See TracChangeset for help on using the changeset viewer.