Changeset 3065


Ignore:
Timestamp:
27/11/07 15:18:27 (12 years ago)
Author:
domlowe
Message:

added ability to filter out low dimension variables in scanner. Added some test crs definitions for testing rotated grids. Added axis identification by standard name

Location:
TI02-CSML/trunk/csml
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/csmllibs/csmlbuilder.py

    r2907 r3065  
    66    #this class contains all the method calls to create and populate a csmldoc 
    77    #it needs to be provided with several bits of information to be able to do this. 
    8     def __init__(self,datasetid, directory,csmlft, mapping, timedimension ,outputfile,printscreen,timestorage,spatialstorage,valuestorage): 
     8    def __init__(self,datasetid, directory,csmlft, mapping, timedimension ,outputfile,printscreen,timestorage,spatialstorage,valuestorage, minaxes): 
    99        if datasetid is not None: 
    1010            self.datasetid = datasetid 
     
    2020        self.spatialstorage=spatialstorage 
    2121        self.valuestorage=valuestorage 
     22        self.minaxes=minaxes 
    2223        self.csml = None  # csml object holds the csml document in memory. 
    2324        self.ds_element = None #<Dataset> tag, root node. 
     
    108109        if not hasattr(self, 'extractDictionary'): 
    109110            self.extractDictionary=None 
    110         thefeatures = csml.csmllibs.csmlfeaturetypes.featureBuilder(self.ds,self.featureCollection, self.ffmap, self.extractDictionary,self.timedimension, self.timestorage, self.spatialstorage,self.valuestorage) 
     111        thefeatures = csml.csmllibs.csmlfeaturetypes.featureBuilder(self.ds,self.featureCollection, self.ffmap, self.extractDictionary,self.timedimension, self.timestorage, self.spatialstorage,self.valuestorage, self.minaxes) 
    111112                
    112113        #self.csml = thefeatures.csml 
  • TI02-CSML/trunk/csml/csmllibs/csmlcrs.py

    r3058 r3065  
    9696         
    9797        #define rotated_latitude_longitude CRS (test) 
    98         crs=CRSystem(srsName='ndg:crs:rlonrlatsurft', axes =['rotated_longitude', 'rotated_latitude','surface', 'time']) 
     98        crs=CRSystem(srsName='ndg:crs:rlonrlatsurft', axes =['grid_longitude', 'grid_latitude','surface', 'time']) 
    9999        self.systems['ndg:crs:rlonrlatsurft']=crs 
     100        crs.lonAxis=0 
     101        crs.latAxis=1 
     102        crs.timeAxis=3 
     103         
     104         
     105        #define rotated_latitude_longitude_undefined surface CRS (test) 
     106        crs=CRSystem(srsName='ndg:crs:undefined_rlonrlatt', axes =['grid_longitude', 'grid_latitude','tba', 'time']) 
     107        self.pseudosystems['ndg:crs:undefined_rlonrlatt']=crs 
    100108        crs.lonAxis=0 
    101109        crs.latAxis=1 
     
    219227        return crs, axisorder 
    220228 
    221     def determineCRS(self, axes=None, units=None): 
     229    def determineCRS(self, axes=None, units=None, stdNames=None): 
    222230        '''given any list of axis names and a list of units for these axes attempt to determine the CRS and return the CRSystem object and an axis order list. 
    223231        e.g passing in: (axes=['t', 'ht', 'latitude', 'longitude'],units=['days since 1991-09-01 00:00:00', 'm', 'degrees_north', 'degrees_east']) 
     
    225233        Assumes the units are ordered to correspond with the axes 
    226234        '''      
    227        
    228235        axisorder=[] 
    229236        crs =None 
    230237         
    231         #build a map of axes and units 
     238        #build a map of axes and units - use std names to help! 
    232239        crsMap=[] 
    233240        for axis in axes: 
    234             unit=units[axes.index(axis)] 
    235             unittype=self.getUnitType(unit)             
     241            if stdNames[axes.index(axis)]: 
     242                unittype=stdNames[axes.index(axis)] 
     243            else: 
     244                unit=units[axes.index(axis)] 
     245                unittype=self.getUnitType(unit)             
    236246            crsMap.append(unittype) 
    237    
     247               
    238248        match=0 
    239249        #now try and match up crsMap with known crsystems.         
     
    268278                    crs.units=csml.csmllibs.csmlextra.stringify(orderedunits) 
    269279        return crs, axisorder 
     280     
     281    def _identifyAxisByStdName(self,  stdName): 
     282        '''given a CF standard name return the axis name''' 
     283        understoodNames={'grid_longitude': 'grid_longitude', 'grid_latitude':'grid_latitude'} 
     284        if stdName in understoodNames.keys(): 
     285            axisname= understoodNames[stdName] 
     286        else: 
     287            axisname =None 
     288        return axisname 
    270289         
    271290def main(): 
  • TI02-CSML/trunk/csml/csmllibs/csmlfeaturetypes.py

    r3055 r3065  
    1414 
    1515class featureBuilder(object): 
    16     def __init__(self, dataset_element, featureCollection_element, ffmap,fileExtractDictionary, timedim, timestorage,spatialstorage,valuestorage): 
     16    def __init__(self, dataset_element, featureCollection_element, ffmap,fileExtractDictionary, timedim, timestorage,spatialstorage,valuestorage,minaxes): 
    1717        self.ds_element=dataset_element 
    1818        self.featureCollection = featureCollection_element 
     
    2323        self.spatialstorage=spatialstorage 
    2424        self.valuestorage=valuestorage 
     25        self.minaxes=minaxes 
    2526                 
    2627        #empty list to hold featureMembers 
     
    104105        self.DI.openFile(self.repfilename) 
    105106        allVarNames=self.DI.getListofVariables() 
    106         numFeatures=len(allVarNames) 
    107         return allVarNames, numFeatures 
     107        checkedVars=[] 
     108        for var in allVarNames: 
     109            self.DI.setVariable(var) 
     110            numaxes=len(self.DI.getVariableAxes()) 
     111            #ignore any variables below the specified dimension threshold 
     112            if numaxes > self.minaxes: 
     113                checkedVars.append(var)               
     114        numFeatures=len(checkedVars) 
     115        return checkedVars, numFeatures 
    108116     
    109117    def __getGridCoordinatesTable(self,dimNames, crs,axisorder): 
     
    209217            return None, None, None 
    210218        unitlist=[] 
     219        stdNames=[] 
    211220        for dim in dimNames: 
    212221            self.DI.setAxis(dim) 
    213222            units=self.DI.getAxisAttribute('units')  #need to make special case of units in DI layer 
     223            stdname =None 
     224            try: 
     225                stdname=self.DI.getAxisAttribute('standard_name')                
     226            except: 
     227                pass 
     228            stdNames.append(stdname) 
    214229            unitlist.append(units)     
    215         crs, axisorder=catalogue.determineCRS(dimNames,unitlist) 
     230        crs, axisorder=catalogue.determineCRS(dimNames,unitlist, stdNames) 
    216231        return crs, axisorder, dimNames 
    217232     
  • TI02-CSML/trunk/csml/csmlscan.py

    r2901 r3065  
    119119        DATASETID = config.getConfigNoError('dataset', 'dsID') 
    120120        FEATURETYPE = config.getConfigNoError('features', 'type') 
    121         FEATURENUMBER = config.getConfigNoError('features', 'number') 
     121        FEATURENUMBER = config.getConfigNoError('features', 'number')         
     122        try: 
     123            MINAXES=eval(config.getConfigNoError('features','minaxes')) 
     124        except ConfigParser.NoOptionError: 
     125            MINAXES=0 
    122126        ROOTDIRECTORY = config.getConfigNoError('files', 'root') 
    123127        MAPPING = config.getConfigNoError('files', 'mapping') 
     
    130134        SPATIALSTORAGE=config.getConfigNoError('spatialaxes','spatialstorage') 
    131135         
     136         
    132137        if configTest==True: 
    133138            print 'Testing config file:' 
     
    138143            print '\n features:type =%s'%FEATURETYPE 
    139144            print '\n features:number =%s'%FEATURENUMBER 
     145            print '\n features:minaxes =%s'%MINAXES 
    140146            print '\n files:root =%s'%ROOTDIRECTORY 
    141147            print '\n files:mapping =%s'%MAPPING 
     
    186192    #build CSML document 
    187193    print ROOTDIRECTORY 
    188     csmldataset=csmllibs.csmlbuilder.csmlBuilder(DATASETID,ROOTDIRECTORY,FEATURETYPE,MAPPING,TIMEDIMENSION, OUTPUTFILE, PRINTSCREEN,TIMESTORAGE,SPATIALSTORAGE,VALUESTORAGE) 
     194    csmldataset=csmllibs.csmlbuilder.csmlBuilder(DATASETID,ROOTDIRECTORY,FEATURETYPE,MAPPING,TIMEDIMENSION, OUTPUTFILE, PRINTSCREEN,TIMESTORAGE,SPATIALSTORAGE,VALUESTORAGE, MINAXES) 
    189195    csmldataset.build() 
    190196 
Note: See TracChangeset for help on using the changeset viewer.