source: TI02-CSML/trunk/csml/API/ops_AbstractFeature.py @ 3267

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

Documenting CSML code - not complete

Line 
1''' ops_AbstractFeature  contains operations for AbstractFeatures
2These methods are attached to AbstractFeature instances at runtime.
3Therefore they are inherited by all feature instances (unless they are overwritten'''
4import string
5import cdtime
6import csml
7import csmlutils
8import MA
9
10def testmethod(self):
11    '''test method'''
12    print 'testmethod for abstract feature'
13    return 'testmethod abstract feature'
14
15def getAllowedSubsettings(self):
16    '''get the allowed operations
17    @return:    list of operations'''
18    return ['none']
19
20def getDomainUnits(self):
21    '''  get the units used in the domain'''
22    return None
23   
24def getLongitudeAxis(self):
25    ''' get the index of the longitude axis, if one exists'''
26    return None
27
28def getLatitudeAxis(self):
29    ''' get the index of the latitude axis, if one exists'''
30    return None
31
32def getTimeAxis(self):
33    ''' get the index of the time axis, if one exists'''
34    return None
35
36def getAxisLabels(self):
37    ''' get the names of all the axes'''
38    return None
39
40def getBoundingBox(self):
41    ''' get the simple boundingBox '''
42    return None
43
44def getCSMLBoundingBox(self):
45    ''' returns a complete boundingBox object including temporal domain and crs'''
46    if hasattr(self, 'boundedBy'):
47        return csml.API.csmlbbox.CSMLBoundingBox(self.boundedBy)
48    else:
49        return None
50   
51def getNativeCRS(self):
52    ''' returns the crs of the feature '''
53    return None
54
55def getSliceIndices(self, selection):
56    ''' Calculates indices to use in slicing (eg for RawFileExtracts) and adds them to the selection dictionary. Doesn't work fully due to lack of proper CRS cataloguing so returns empty lists if error is encountered
57    '''
58    selLower=[]
59    selUpper=[]
60   
61    try:
62        #create artificial range for single selections so that (60) becomes (60,60)
63        for sel in selection:
64            if type(selection[sel]) in [int,float,str]:  #ie. single value as opposed to a list containing a range
65                tmp=selection[sel]
66                selection[sel]=[tmp,tmp] 
67           
68        for sel in selection:
69            for item in enumerate(self.domain[sel]):
70                index=item[0]
71                value=item[1]   
72                if value==selection[sel][0]:
73                    #selLower.append(self.domain[sel].index(item))
74                    limit1=index
75                    #selLower.append(item[0])
76                if value==selection[sel][1]:
77                    #selUpper.append(self.domain[sel].index(item))
78                    limit2=index
79                   
80            #make sure the lower limit is the smaller of the two selection criteria       
81            if limit1 <= limit2:
82                selLower.append(limit1)
83                selUpper.append(limit2+1)#plus 1 to take account of the fact that Numeric (and python) slicing returns only 6 values for [0:6] so, to get the first 7 values say you need to pass [0:7]
84            else:
85                selLower.append(limit2)
86                selUpper.append(limit1 +1)
87       
88       
89        selection['lower']=tuple(selLower)
90        selection['upper']=tuple(selUpper) 
91       
92    except:
93        pass
94    return selection
Note: See TracBrowser for help on using the repository browser.