Ignore:
Timestamp:
03/07/07 13:46:24 (13 years ago)
Author:
domlowe
Message:

try except added to sliceing code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py

    r2665 r2692  
    2222def getSliceIndices(self, selection): 
    2323    ''' Calculates indices to use in slicing (eg for RawFileExtracts) and adds them to the selection dictionary 
     24    #Doesn't work fully due to lack of proper CRS cataloguing so returns empty lists if error is encountered 
    2425    ''' 
    2526    selLower=[] 
    2627    selUpper=[] 
    27       
    28     #create artificial range for single selections so that (60) becomes (60,60) 
    29     for sel in selection: 
    30         if type(selection[sel]) in [int,float]:  #ie. single value as opposed to a list containing a range 
    31             tmp=selection[sel] 
    32             selection[sel]=[tmp,tmp]  
     28     
     29    try: 
     30        #create artificial range for single selections so that (60) becomes (60,60) 
     31        for sel in selection: 
     32            if type(selection[sel]) in [int,float]:  #ie. single value as opposed to a list containing a range 
     33                tmp=selection[sel] 
     34                selection[sel]=[tmp,tmp]  
     35             
     36        for sel in selection: 
     37            for item in enumerate(self.domain[sel]): 
     38                index=item[0] 
     39                value=item[1]    
     40                if value==selection[sel][0]: 
     41                    #selLower.append(self.domain[sel].index(item)) 
     42                    limit1=index 
     43                    #selLower.append(item[0]) 
     44                if value==selection[sel][1]: 
     45                    #selUpper.append(self.domain[sel].index(item)) 
     46                    limit2=index 
     47                     
     48            #make sure the lower limit is the smaller of the two selection criteria         
     49            if limit1 <= limit2: 
     50                selLower.append(limit1) 
     51                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] 
     52            else: 
     53                selLower.append(limit2) 
     54                selUpper.append(limit1 +1) 
    3355         
    34     for sel in selection: 
    35         for item in enumerate(self.domain[sel]): 
    36             index=item[0] 
    37             value=item[1]    
    38             if value==selection[sel][0]: 
    39                 #selLower.append(self.domain[sel].index(item)) 
    40                 limit1=index 
    41                 #selLower.append(item[0]) 
    42             if value==selection[sel][1]: 
    43                 #selUpper.append(self.domain[sel].index(item)) 
    44                 limit2=index 
    45                  
    46         #make sure the lower limit is the smaller of the two selection criteria         
    47         if limit1 <= limit2: 
    48             selLower.append(limit1) 
    49             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] 
    50         else: 
    51             selLower.append(limit2) 
    52             selUpper.append(limit1 +1) 
    53      
    54     selection['lower']=tuple(selLower) 
    55     selection['upper']=tuple(selUpper)   
     56        selection['lower']=tuple(selLower) 
     57        selection['upper']=tuple(selUpper)   
     58    except: 
     59        pass 
    5660    return selection 
    5761 
     
    99103    srsname=self.value.gridSeriesDomain.srsName 
    100104    cat=csml.csmllibs.csmlcrs.CRSCatalogue() 
    101     crs=cat.getCRS(srsname)       
     105    crs=cat.getCRS(srsname,self.value.gridSeriesDomain.axisLabels)       
    102106    axID=None 
    103107    if name == 'lon': 
     
    121125    return self.__getAxis('time') 
    122126 
     127def getAxisLabels(self): 
     128    labels=[] 
     129    for label in self.value.gridSeriesDomain.axisLabels.split(): 
     130        labels.append(label) 
     131    return labels 
    123132 
    124133def _subsetGrid(self, **kwargs): 
Note: See TracChangeset for help on using the changeset viewer.