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

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

adding bounding box class which represents spatial, temporal bbox + crs

Line 
1''' ops_AbstractFeature  contains operations for AbstractFeatures'''
2import string
3import cdtime
4import csml
5import csmlutils
6import MA
7
8def testmethod(self):
9    print 'testmethod for abstract feature'
10    return 'testmethod abstract feature'
11
12def getAllowedSubsettings(self):
13    return ['none']
14
15def getDomainUnits(self):
16    return None
17   
18def getLongitudeAxis(self):
19    return None
20
21def getLatitudeAxis(self):
22    return None
23
24def getTimeAxis(self):
25    return None
26
27def getAxisLabels(self):
28    return None
29
30def getBoundingBox(self):
31    return None
32
33def getSliceIndices(self, selection):
34    ''' Calculates indices to use in slicing (eg for RawFileExtracts) and adds them to the selection dictionary
35    #Doesn't work fully due to lack of proper CRS cataloguing so returns empty lists if error is encountered
36    '''
37    selLower=[]
38    selUpper=[]
39   
40    try:
41        #create artificial range for single selections so that (60) becomes (60,60)
42        for sel in selection:
43            if type(selection[sel]) in [int,float,str]:  #ie. single value as opposed to a list containing a range
44                tmp=selection[sel]
45                selection[sel]=[tmp,tmp] 
46           
47        for sel in selection:
48            for item in enumerate(self.domain[sel]):
49                index=item[0]
50                value=item[1]   
51                if value==selection[sel][0]:
52                    #selLower.append(self.domain[sel].index(item))
53                    limit1=index
54                    #selLower.append(item[0])
55                if value==selection[sel][1]:
56                    #selUpper.append(self.domain[sel].index(item))
57                    limit2=index
58                   
59            #make sure the lower limit is the smaller of the two selection criteria       
60            if limit1 <= limit2:
61                selLower.append(limit1)
62                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]
63            else:
64                selLower.append(limit2)
65                selUpper.append(limit1 +1)
66       
67       
68        selection['lower']=tuple(selLower)
69        selection['upper']=tuple(selUpper) 
70       
71    except:
72        pass
73    return selection
Note: See TracBrowser for help on using the repository browser.