Changeset 1972 for TI02-CSML


Ignore:
Timestamp:
09/01/07 09:10:46 (13 years ago)
Author:
domlowe
Message:

changed getCRS to determineCRS, now getCRS gets a known CRSystem object by name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/csmllibs/csmlcrs.py

    r1969 r1972  
    4040        crs=CRSystem(srsName='ndg:crs:unknown', axes=['unknown']) 
    4141        self.systems['ndg:crs:unknown']=crs 
    42          
    43     def getCRS(self, axes, units): 
    44         #given any list of axis names and a list of units for these axes attempt to determine the CRS 
     42     
     43    def getCRS(self, srsName): 
     44        #given the name of a CRS e.g. 'ndg:crs:xypt' return the CRSystem object  
     45        try: 
     46            return self.systems[srsName] 
     47        except: 
     48            return self.systems['ndg:crs:unknown'] 
     49     
     50    def determineCRS(self, axes, units): 
     51        #given any list of axis names and a list of units for these axes attempt to determine the CRS and return the CRSystem object 
    4552        crs=self.systems['ndg:crs:unknown'] 
    4653        if len(axes)==3: 
     
    5966    cat=CRSCatalogue() 
    6067     
    61     #test getting various crs 
     68    #test determining various crs 
    6269    print 'TEST 1:' 
    6370    print '*************************************' 
     
    6673    print 'AXES: %s'%axs 
    6774    print 'UNITS: %s'%uns 
    68     crs= cat.getCRS(axes=axs, units=uns) 
     75    crs= cat.determineCRS(axes=axs, units=uns) 
    6976    print 'srsName = %s' %crs.srsName 
    7077    print 'srsDimension = %s' %crs.srsDimension 
     
    7885    print 'AXES: %s'%axs 
    7986    print 'UNITS: %s'%uns 
    80     crs=cat.getCRS(axes=axs, units=uns) 
     87    crs=cat.determineCRS(axes=axs, units=uns) 
    8188    print 'srsName = %s' %crs.srsName 
    8289    print 'srsDimension = %s' %crs.srsDimension 
     
    97104#    print units 
    98105        crsdictionary[str(axes)]=units 
    99     print crsdictionary 
     106    #print crsdictionary 
    100107    n=2 
    101108    #test each definition in dictionary 
     
    108115        print 'AXES: %s'%axs 
    109116        print 'UNITS: %s'%uns 
    110         crs= cat.getCRS(axes=axs, units=uns) 
     117        crs= cat.determineCRS(axes=axs, units=uns) 
    111118        print 'srsName = %s' %crs.srsName 
    112119        print 'srsDimension = %s' %crs.srsDimension 
    113120        print 'axisLabels =%s' %crs.axisLabels 
    114121        print '**************************************' 
    115     
    116     
    117     
    118      
    119      
    120  
     122   #test getting CRS by name: 
     123    print 'getting ndg:crs:xypt by name' 
     124    crs=cat.getCRS('ndg:crs:xypt') 
     125    print 'srsName = %s' %crs.srsName 
     126    print 'srsDimension = %s' %crs.srsDimension 
     127    print 'axisLabels =%s' %crs.axisLabels 
     128    print 'time axis =%s' %crs.timeAxis 
     129    print 'longitude axis =%s' %crs.lonAxis 
     130    print 'latitude axis =%s' %crs.latAxis 
    121131if __name__=="__main__": 
    122132    main() 
Note: See TracChangeset for help on using the changeset viewer.