Changeset 2498


Ignore:
Timestamp:
21/05/07 10:37:32 (12 years ago)
Author:
domlowe
Message:

subsetting by index initially working for rawfileextracts (more testing needed)

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

Legend:

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

    r2473 r2498  
    5555 
    5656##GridSeriesFeature methods: 
    57 addMethods(csml.parser.GridSeriesFeature,[ops_GridFeature.testmethod,ops_GridSeriesFeature.getDomain,ops_GridSeriesFeature.subsetToGridSeries, ops_GridSeriesFeature.getUom, ops_GridSeriesFeature._subsetGrid,ops_GridSeriesFeature.subsetToProfileSeries, ops_GridSeriesFeature.subsetToProfile,ops_GridSeriesFeature.subsetToPointSeries]) 
     57addMethods(csml.parser.GridSeriesFeature,[ops_GridSeriesFeature.getAllowedSubsettings,ops_GridSeriesFeature.getDomain,ops_GridSeriesFeature.subsetToGridSeries, ops_GridSeriesFeature.getUom,ops_GridSeriesFeature.getSliceIndices, ops_GridSeriesFeature._subsetGrid,ops_GridSeriesFeature.subsetToProfileSeries, ops_GridSeriesFeature.subsetToProfile,ops_GridSeriesFeature.subsetToPointSeries]) 
    5858 
    5959##TrajectoryFeature methods: 
  • TI02-CSML/trunk/csml/API/genSubset.py

    r2495 r2498  
    4141    totalArraySize=1 
    4242    for key in domain.keys(): 
    43         print key 
    4443        straxisValues='' 
    4544        if key in kwargs: 
  • TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py

    r2495 r2498  
    1717 
    1818def getAllowedSubsettings(self): 
    19     return ['subsetToGridSeries']  #other operations 
     19    return ['subsetToGridSeries', 'subsetToProfileSeries']  #other operations 
     20 
     21def getSliceIndices(self, selection): 
     22    ''' Calculates indices to use in slicing (eg for RawFileExtracts) and adds them to the selection dictionary 
     23    ''' 
     24    selLower=[] 
     25    selUpper=[] 
     26    for sel in selection: 
     27        for item in enumerate(self.domain[sel]): 
     28            index=item[0] 
     29            value=item[1]    
     30            if value==selection[sel][0]: 
     31                #selLower.append(self.domain[sel].index(item)) 
     32                limit1=index 
     33                #selLower.append(item[0]) 
     34            elif value==selection[sel][1]: 
     35                #selUpper.append(self.domain[sel].index(item)) 
     36                limit2=index 
     37                 
     38        #make sure the lower limit is the smaller of the two selection criteria         
     39        if limit1 <= limit2: 
     40            selLower.append(limit1) 
     41            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] 
     42        else: 
     43            selLower.append(limit2) 
     44            selUpper.append(limit1 +1) 
     45     
     46    selection['lower']=tuple(selLower) 
     47    selection['upper']=tuple(selUpper)   
     48    return selection 
     49 
    2050 
    2151def getDomain(self): 
     
    82112    except KeyError: 
    83113        pass 
    84     #TEST selection by index: 
    85     selection['lower']=(0,10,) 
    86     selection['upper']=(124,262) 
     114     
     115    #get slice indices  
     116    selection=self.getSliceIndices(selection) 
     117 
    87118            
    88119    strTimes, axisorder, units, fulldata, fillvalue =csml.API.genSubset.getTheData(self, selection, times, timeName) 
  • TI02-CSML/trunk/csml/csmllibs/csmldataiface.py

    r2495 r2498  
    653653         for i in range(len(self.data.shape)): 
    654654            lower = int(kwargs['lower'][i]) 
    655             upper = int(kwargs['upper'][i]) 
     655            upper = int(kwargs['upper'][i])  
    656656            slices.append(str(lower)+':'+str(upper)) 
    657657         subset = eval("self.data["+','.join(slices)+"]") 
Note: See TracChangeset for help on using the changeset viewer.