Ignore:
Timestamp:
27/06/08 10:19:12 (12 years ago)
Author:
domlowe
Message:

added code to preserve CF projection variables and subset them accordingly

File:
1 edited

Legend:

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

    r4019 r4030  
    8080         
    8181         
     82def getDomainSlice(subsettedDomain, originalDomain): 
     83    ''' Utility function to convert the subsettedDomain to a set of slice tuples based on its position within the original domain. This information is needed to retrospectively subset the additional projection variables''' 
     84    sliceinfo={}    
     85    try: 
     86        for key in subsettedDomain: 
     87            firstvalue=eval(subsettedDomain[key].split(',')[0]) 
     88            lastvalue=eval(subsettedDomain[key].split(',')[-1:][0]) 
     89            vals= originalDomain[key].tolist() 
     90            sliceinfo[key]=(vals.index(firstvalue), vals.index(lastvalue)) 
     91    except: 
     92            pass # skip key 
     93    return sliceinfo 
    8294         
    8395         
    8496         
    85          
Note: See TracChangeset for help on using the changeset viewer.