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

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

time and calendar working in netcdf output. Time subsetting by min/max or explicit values. Ready for attempt at data extractor integration.

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            data = DI.getSubsetOfDataForVar(**kwargs)
38        else:
39            data = DI.getDataForVar()
40    return data
41       
42def __calendar(file,timedim):
43    #open the file
44    DI = csmldataiface.DataInterface()
45    DI=DI.getUnknownInterfaceType(file)
46    DI.openFile(file)
47    DI.setAxis(timedim)
48    cal=DI.getAxisAttribute('calendar')
49    units=DI.getAxisAttribute('units')
50    return cal, units
51   
Note: See TracBrowser for help on using the repository browser.