source: TI02-CSML/trunk/csml/API/ops_FileExtract.py @ 1956

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/API/ops_FileExtract.py@1956
Revision 1956, 1.4 KB checked in by domlowe, 13 years ago (diff)

added stub methods to AbstractDI class

RevLine 
[1026]1''' ops_AbstractFileExtract  contains operations for AbstractFileExtracts'''
[1485]2import csml.csmllibs.csmldataiface
[1026]3
4def testmethod(self):
5    print 'testmethod for AbstractFileExtract feature'
6    return 'testmethod AbstractFileExtract'
[1027]7
[1032]8
[1956]9def getData(self,  fileposition=None,**kwargs):
[1032]10    #should handle setAxis or setVariable as cdms netcdf model
[1042]11    #file position defines the position of the filename if a list of filenames exists
12    #**kwargs can hold subsetting request.
[1086]13    #print fileposition
14    #print self.fileName
[1042]15   
16    #get the right file
[1086]17    if fileposition is not None:
[1939]18        file=self.fileName.CONTENT.split()[fileposition]
[1042]19    else:
[1939]20        file=self.fileName.CONTENT
[1042]21    #open the file
[1485]22    DI = csml.csmllibs.csmldataiface.DataInterface()
[1042]23    DI=DI.getUnknownInterfaceType(file)
24    DI.openFile(file)
25   
[1086]26    try:
[1939]27        DI.setAxis(self.variableName.CONTENT)
[1086]28        data=DI.getDataForAxis()
29    except:
[1939]30        DI.setVariable(self.variableName.CONTENT)
[1086]31        if kwargs:
[1594]32            #print 'getting data for %s'%kwargs
[1086]33            data = DI.getSubsetOfDataForVar(**kwargs)
34        else:
35            data = DI.getDataForVar()
[1186]36    DI.closeFile()
[1086]37    return data
38       
39def __calendar(file,timedim):
40    #open the file
41    DI = csmldataiface.DataInterface()
42    DI=DI.getUnknownInterfaceType(file)
43    DI.openFile(file)
44    DI.setAxis(timedim)
45    cal=DI.getAxisAttribute('calendar')
46    units=DI.getAxisAttribute('units')
47    return cal, units
48   
Note: See TracBrowser for help on using the repository browser.