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

Line 
1''' ops_AbstractFileExtract  contains operations for AbstractFileExtracts'''
2import csml.csmllibs.csmldataiface
3
4def testmethod(self):
5    print 'testmethod for AbstractFileExtract feature'
6    return 'testmethod AbstractFileExtract'
7
8
9def getData(self,  fileposition=None,**kwargs):
10    #should handle setAxis or setVariable as cdms netcdf model
11    #file position defines the position of the filename if a list of filenames exists
12    #**kwargs can hold subsetting request.
13    #print fileposition
14    #print self.fileName
15   
16    #get the right file
17    if fileposition is not None:
18        file=self.fileName.CONTENT.split()[fileposition]
19    else:
20        file=self.fileName.CONTENT
21    #open the file
22    DI = csml.csmllibs.csmldataiface.DataInterface()
23    DI=DI.getUnknownInterfaceType(file)
24    DI.openFile(file)
25   
26    try:
27        DI.setAxis(self.variableName.CONTENT)
28        data=DI.getDataForAxis()
29    except:
30        DI.setVariable(self.variableName.CONTENT)
31        if kwargs:
32            #print 'getting data for %s'%kwargs
33            data = DI.getSubsetOfDataForVar(**kwargs)
34        else:
35            data = DI.getDataForVar()
36    DI.closeFile()
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.