Changeset 2584


Ignore:
Timestamp:
13/06/07 13:24:28 (12 years ago)
Author:
domlowe
Message:

exposing getUnits methods etc

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

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/API/__init__.py

    r2562 r2584  
    1818import ops_TrajectoryFeature 
    1919import csmlContainer 
     20import types 
    2021 
    21 def addMethods(obj, meths): 
    22     for meth in meths: 
    23         setattr(obj, meth.__name__, meth) 
     22def getFuncsInModule(mod):   
     23    fs = [] 
     24    for key, item in mod.__dict__.items(): 
     25        if type(item) is types.FunctionType: 
     26            fs.append(item) 
     27    return fs 
    2428 
    25 #Assign methods to parser classes 
    26 #Dataset methods: 
    27 addMethods(csml.parser.Dataset, [ops_Dataset.parse, ops_Dataset.getSecurity, ops_Dataset.getFeatureList, ops_Dataset.getFeature, ops_Dataset.getFileExtract]) 
    2829 
    29 #AbstractFileExtract methods: 
    30 addMethods(csml.parser.FileExtract, [ops_FileExtract.getData,ops_FileExtract.getDataFromChunks]) 
     30def appendMethods(obj, mod): 
     31    for func in getFuncsInModule(mod): 
     32        setattr(obj, func.__name__, func) 
    3133 
    32 #RawFileExtract methods: 
    33 addMethods(csml.parser.RawFileExtract, [ops_RawFileExtract.getData]) 
    3434 
    35 #ArrayGenerator methods: 
    36 #addMethods(csml.parser.ArrayGenerator, [ops_ArrayGenerator.getGeneratedValues]) 
     35operationsMap={csml.parser.Dataset:ops_Dataset, csml.parser.FileExtract:ops_FileExtract, csml.parser.RawFileExtract: ops_RawFileExtract, csml.parser.AbstractFeature:ops_AbstractFeature, csml.parser.GridSeriesFeature:ops_GridSeriesFeature, csml.parser.GridFeature:ops_GridFeature, csml.parser.PointSeriesFeature:ops_PointSeriesFeature, csml.parser.PointSeriesFeature:ops_PointSeriesFeature} 
    3736 
    38 ##AbstractFeature methods: 
    39 addMethods(csml.parser.AbstractFeature, [ops_AbstractFeature.testmethod, ops_AbstractFeature.getAllowedSubsettings]) 
    4037 
    41 ##PointFeature methods: 
    42 #addMethods(csml.parser.PointFeature,[ops_PointFeature.testmethod]) 
     38for parserItem in operationsMap: 
     39    appendMethods(parserItem, operationsMap[parserItem]) 
    4340 
    44 ##PointSeriesFeature methods: 
    45 addMethods(csml.parser.PointSeriesFeature, [ops_PointSeriesFeature.testmethod,ops_PointSeriesFeature.getDomain, ops_PointSeriesFeature.subsetToPointSeries,ops_PointSeriesFeature.subsetToPoint,  ops_PointSeriesFeature.getAllowedSubsettings]) 
    46  
    47 ##ProfileFeature methods: 
    48 #addMethods(csml.parser.ProfileFeature,[ops_ProfileFeature.testmethod]) 
    49  
    50 ##ProfileSeriesFeature methods: 
    51 addMethods(csml.parser.ProfileSeriesFeature,[ops_ProfileSeriesFeature.testmethod, ops_ProfileSeriesFeature.getDomain, ops_ProfileSeriesFeature.subsetToProfile,ops_ProfileSeriesFeature.subsetToPointSeries,ops_ProfileSeriesFeature._subsetProfileSeries]) 
    52  
    53 ##GridFeature methods: 
    54 #addMethods(csml.parser.GridFeature,[ops_GridFeature.testmethod]) 
    55  
    56 ##GridSeriesFeature methods: 
    57 addMethods(csml.parser.GridSeriesFeature,[ops_GridSeriesFeature.getAllowedSubsettings,ops_GridSeriesFeature.getDomain,ops_GridSeriesFeature.subsetToGridSeries, ops_GridSeriesFeature.getUom,ops_GridSeriesFeature.getSliceIndices, ops_GridSeriesFeature._subsetGrid,ops_GridSeriesFeature.subsetToProfileSeries, ops_GridSeriesFeature.subsetToProfile,ops_GridSeriesFeature.subsetToPointSeries]) 
    58  
    59 ##TrajectoryFeature methods: 
    60 #addMethods(csml.parser.TrajectoryFeature, [ops_TrajectoryFeature.testmethod]) 
  • TI02-CSML/trunk/csml/API/ops_AbstractFeature.py

    r2548 r2584  
    1414 
    1515 
     16def getDomainUnits(self): 
     17    return None 
     18     
     19def getLongitudeAxis(self): 
     20    return None 
    1621 
    17      
     22def getLatitudeAxis(self): 
     23    return None 
    1824 
    19  
    20  
     25def getTimeAxis(self): 
     26    return None 
  • TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py

    r2569 r2584  
    77import csml.API.genSubset 
    88import csml.csmllibs.netCDFWriter 
     9import csml.csmllibs.csmlcrs 
    910import csmlutils 
    1011 
     
    8687        uom =None 
    8788    return uom 
     89     
     90def getDomainUnits(self): 
     91    srsname=self.value.gridSeriesDomain.srsName 
     92    cat=csml.csmllibs.csmlcrs.CRSCatalogue() 
     93    crs=cat.getCRS(srsname) 
     94    return crs.units 
     95     
     96def __getAxis(self, name): 
     97    '''called by getLongitudeAxis, getTimeAxis and getLatitudeAxis'''     
     98    srsname=self.value.gridSeriesDomain.srsName 
     99    cat=csml.csmllibs.csmlcrs.CRSCatalogue() 
     100    crs=cat.getCRS(srsname)       
     101    axID=None 
     102    if name == 'lon': 
     103        axID = crs.lonAxis 
     104    elif name == 'lat': 
     105        axID = crs.latAxis 
     106    elif name == 'time': 
     107        axID = crs.timeAxis      
     108    if axID is not None: 
     109        return crs.getAxisLabels()[axID] 
     110    else: 
     111        return None 
     112     
     113def getLongitudeAxis(self): 
     114    return self.__getAxis('lon') 
     115 
     116def getLatitudeAxis(self): 
     117    return self.__getAxis('lat') 
     118 
     119def getTimeAxis(self): 
     120    return self.__getAxis('time') 
     121 
    88122 
    89123def _subsetGrid(self, **kwargs): 
  • TI02-CSML/trunk/csml/csmllibs/csmlcrs.py

    r2527 r2584  
    1414        self.lonAxis=None 
    1515        self.latAxis=None 
     16        self.units=None 
     17     
     18    def getAxisLabels(self): 
     19        labelList=[] 
     20        for item in self.axisLabels.split(): 
     21            labelList.append(item) 
     22        return labelList 
    1623 
    1724class CRSCatalogue(object): 
     
    3239        crs=CRSystem(srsName='ndg:crs:t', axes =['time']) 
    3340        crs.timeAxis=0 
     41        crs.lonAxis=None 
     42        crs.latAxis=None 
    3443        self.systems['ndg:crs:t']=crs 
    3544         
     
    7483        self.pseudosystems['ndg:crs:undefined2d']=crs 
    7584        crs.timeAxis=1 
     85        crs.lonAxis=None 
     86        crs.latAxis=None 
    7687         
    7788        #define unknown 3D CRS: 
     
    8091        crs.lonAxis=0 
    8192        crs.latAxis=1 
     93        crs.timeAxis=None 
    8294         
    8395        #define unknown 4D CRS: 
Note: See TracChangeset for help on using the changeset viewer.