source: TI02-CSML/trunk/csml/API/ops_AbstractFileExtract.py @ 1485

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

more module moves

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, times=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.split()[fileposition]
19        print file
20    else:
21        file=self.fileName
22    #open the file
23    DI = csml.csmllibs.csmldataiface.DataInterface()
24    DI=DI.getUnknownInterfaceType(file)
25    DI.openFile(file)
26   
27    #get the data
28    print self.variableName
29   
30    try:
31        DI.setAxis(self.variableName)
32        data=DI.getDataForAxis()
33    except:
34        DI.setVariable(self.variableName)
35        if kwargs:
36            print 'getting data for %s'%kwargs
37            data = DI.getSubsetOfDataForVar(**kwargs)
38        else:
39            data = DI.getDataForVar()
40    DI.closeFile()
41    return data
42       
43def __calendar(file,timedim):
44    #open the file
45    DI = csmldataiface.DataInterface()
46    DI=DI.getUnknownInterfaceType(file)
47    DI.openFile(file)
48    DI.setAxis(timedim)
49    cal=DI.getAxisAttribute('calendar')
50    units=DI.getAxisAttribute('units')
51    return cal, units
52   
Note: See TracBrowser for help on using the repository browser.