source: TI02-CSML/trunk/parser/API/ops_AbstractFileExtract.py @ 1178

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

fixed problem with axis ordering in csml api

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