Changeset 1966 for TI02-CSML/trunk/csml
- Timestamp:
- 08/01/07 13:55:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/csmllibs/csmlcrs.py
r1965 r1966 1 import string 1 2 2 3 class CRSystem(object): … … 7 8 self.lonAxis=None 8 9 self.latAxis=None 9 self.srsDimension=len[axes] 10 10 self.srsDimension=len(self.axes) 11 self.axisLabels='' 12 for axis in self.axes: 13 self.axisLabels=self.axisLabels + axis + ' ' 11 14 12 15 class CRSCatalogue(object): … … 16 19 17 20 # define lon lat pressure time CRS: 18 crs=CRSystem(srsName='ndg:crs:xypt', srsDimension='4', axes =['Long', 'Lat','Pressure','Time'])21 crs=CRSystem(srsName='ndg:crs:xypt', axes =['Lon', 'Lat','Pressure','Time']) 19 22 crs.lonAxis=0 20 23 crs.latAxis=1 … … 23 26 24 27 # define lon lat height time CRS: 25 crs=CRSystem(srsName='ndg:crs:xyht', srsDimension='4', axes =['Long', 'Lat','Height','Time'])28 crs=CRSystem(srsName='ndg:crs:xyht', axes =['Lon', 'Lat','Height','Time']) 26 29 crs.lonAxis=0 27 30 crs.latAxis=1 … … 29 32 self.systems['ndg:crs:xyht']=crs 30 33 31 # define test CRS:32 crs=CRSystem(srsName='ndg:crs: abcde', srsDimension='5', axes =['Apple', 'Banana','Cat','Dog','Elephant'])33 self.systems .['ndg:crs:abcde']=crs34 # define lon lat time CRS: 35 crs=CRSystem(srsName='ndg:crs:xyt', axes =['Lon', 'Lat','Time']) 36 self.systems['ndg:crs:xyt']=crs 34 37 38 #define unknown CRS: 39 crs=CRSystem(srsName='ndg:crs:unknown', axes=['unknown']) 40 self.systems['ndg:crs:unknown']=crs 35 41 36 42 def getCRS(self, axes, units): 37 #given any list of axis names and a list of units for these axes return the name of the CRS 38 pass 43 #given any list of axis names and a list of units for these axes attempt to determine the CRS 44 crs=self.systems['ndg:crs:unknown'] 45 if len(axes)==3: 46 #it's a 3d crs 47 for axis in axes: 48 for unit in units: 49 if string.lower(unit) in ['second', 'seconds', 's', 'mins','minute','minutes','hour','hours','h','hr','hrs','day','days']: 50 #unit is time 51 return self.systems['ndg:crs:xyt'] 52 elif len(axes)==4: 53 #it's a 4d crs 54 pass 55 return crs 39 56 40 57 def main(): 41 58 cat=CRSCatalogue() 42 #test getCRS 43 print getCRS(axes=['longitude', 'latitude', 'pressure', 't'], units=['','','Pa','s']) 59 60 #test getting various crs 61 print 'TEST 1:' 62 print '*************************************' 63 axs=['longitude', 'latitude', 'pressure', 't'] 64 uns=['','','Pa','s'] 65 print 'AXES: %s'%axs 66 print 'UNITS: %s'%uns 67 crs= cat.getCRS(axes=axs, units=uns) 68 print 'srsName = %s' %crs.srsName 69 print 'srsDimension = %s' %crs.srsDimension 70 print 'axisLabels =%s' %crs.axisLabels 71 print '**************************************' 72 73 print 'TEST 2:' 74 print '*************************************' 75 axs=['longitude', 'latitude', 't'] 76 uns=['','','s'] 77 print 'AXES: %s'%axs 78 print 'UNITS: %s'%uns 79 crs=cat.getCRS(axes=axs, units=uns) 80 print 'srsName = %s' %crs.srsName 81 print 'srsDimension = %s' %crs.srsDimension 82 print 'axisLabels = %s' %crs.axisLabels 44 83 45 84 if __name__=="__main__":
Note: See TracChangeset
for help on using the changeset viewer.