Changeset 2692 for TI02-CSML


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

try except added to sliceing code

Location:
TI02-CSML/trunk/csml
Files:
4 edited

Legend:

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

    r2584 r2692  
    2525def getTimeAxis(self): 
    2626    return None 
     27 
     28def getAxisLabels(self): 
     29    return None 
  • TI02-CSML/trunk/csml/API/ops_Dataset.py

    r2683 r2692  
    4949def parseElemTree(self, elemtree): 
    5050    ''''alternative parsing method, supply with elementtree instance instead of file/uri''' 
    51     import time 
    52     t1=time.time() 
     51    #import time 
     52    #t1=time.time() 
    5353     
    5454    self.fromXML(elemtree) 
    55     print 'time 1: ',time.time()-t1       
     55    #print 'time 1: ',time.time()-t1       
    5656    self =csml.parser_extra.ParserPostProcessor(self).resolveReferences() 
     57     
    5758def getSecurity(self): 
    5859    """ returns a dictonary containing attributeAuthority: role""" 
  • 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): 
  • TI02-CSML/trunk/csml/csmllibs/csmlcrs.py

    r2665 r2692  
    132132            #need to find the right pseudosystem. 
    133133            #at the moment a simple test on number of dimensions works, but need to make this more generic. 
    134             for psystem in self.pseudosystems: 
     134            for psystem in self.pseudosystems:                 
    135135                try: 
    136136                    if len(self.pseudosystems[psystem].axes) == len (labellist): 
    137137                        return self.pseudosystems[psystem] 
    138138                except: 
     139                    print 'rejecting %s'%psystem 
    139140                    pass 
    140141            else: 
Note: See TracChangeset for help on using the changeset viewer.