Changes between Version 8 and Version 9 of CSMLReadMethods


Ignore:
Timestamp:
25/01/08 15:45:58 (12 years ago)
Author:
domlowe
Comment:

Added cdml subclassing example.

Legend:

Unmodified
Added
Removed
Modified
  • CSMLReadMethods

    v8 v9  
    423423 
    424424 
    425  
    426  
     425== Appendix 2: Data Interfaces for CDML == 
     426 
     427The CDML interface uses cdms. However cdms methods actually behave a bit differently when reading CDML instead of netcdf, so to write a CDML interface we can just subclass the cdunifInterface and override the methods that differ:  
     428 
     429{{{ 
     430#!python 
     431class cdmlInterface(cdunifInterface): 
     432    #this is more  or less the cdunif interface but a few methods have been overwritten 
     433    def __init__(self): 
     434        #this all needs to be revisited in csml v2. 
     435        self.extractType='cdmlExtract' 
     436        self.extractPrefix = '_cdmlextract_' 
     437         
     438    def getListOfAxes(self): 
     439        axes=self.file.axes.keys()  
     440        return axes 
     441 
     442    def getSizeOfAxis(self,axis): 
     443        axisSize=self.file.axes[axis].length 
     444        return axisSize 
     445}}} 
     446 
     447Compare this with the same methods in the cdunifinterface: 
     448{{{ 
     449#!python 
     450    def getListOfAxes(self): 
     451        axes=self.file.dimensions.keys() 
     452        return axes 
     453 
     454    def getSizeOfAxis(self,axis): 
     455        axisSize=self.file.dimensions[axis] 
     456        return axisSize 
     457}}}