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

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

moved getCSMLBoundingBox to AbstractFeature, and added getNativeCRS method to trajectory feature

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 getCSMLBoundingBox(self):
34    #returns a complete boundingBox object including temporal domain and crs
35    if hasattr(self, 'boundedBy'):
36        return csml.API.csmlbbox.CSMLBoundingBox(self.boundedBy)
37    else:
38        return None
39   
40def getNativeCRS(self):
41    #returns the crs of the feature
42    return None
43
44def getSliceIndices(self, selection):
45    ''' Calculates indices to use in slicing (eg for RawFileExtracts) and adds them to the selection dictionary
46    #Doesn't work fully due to lack of proper CRS cataloguing so returns empty lists if error is encountered
47    '''
48    selLower=[]
49    selUpper=[]
50   
51    try:
52        #create artificial range for single selections so that (60) becomes (60,60)
53        for sel in selection:
54            if type(selection[sel]) in [int,float,str]:  #ie. single value as opposed to a list containing a range
55                tmp=selection[sel]
56                selection[sel]=[tmp,tmp] 
57           
58        for sel in selection:
59            for item in enumerate(self.domain[sel]):
60                index=item[0]
61                value=item[1]   
62                if value==selection[sel][0]:
63                    #selLower.append(self.domain[sel].index(item))
64                    limit1=index
65                    #selLower.append(item[0])
66                if value==selection[sel][1]:
67                    #selUpper.append(self.domain[sel].index(item))
68                    limit2=index
69                   
70            #make sure the lower limit is the smaller of the two selection criteria       
71            if limit1 <= limit2:
72                selLower.append(limit1)
73                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]
74            else:
75                selLower.append(limit2)
76                selUpper.append(limit1 +1)
77       
78       
79        selection['lower']=tuple(selLower)
80        selection['upper']=tuple(selUpper) 
81       
82    except:
83        pass
84    return selection
Note: See TracBrowser for help on using the repository browser.