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

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

added EnvelopeWithTimePeriod?, also, more on subsetting

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