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/API/ops_GridSeriesFeature.py

    r4019 r4030  
    252252     
    253253    #now add any other data we preserved earlier, e.g. projection variables: 
     254    #TODO: this should be a separate method 
     255    sliceinfo=csml.csmllibs.csmlpreservation.getDomainSlice(domainSubset, self.domain) 
    254256    for pv in preservedData.projectionVariables: 
     257        pvslice=[] 
    255258        for pvaxis in pv.axes: 
    256             nc.addAxis(pvaxis,pv.axes[pvaxis], pv.attributes) #of form: nc.addAxis(axisname, data)  
    257         print pv.data 
    258         #TODO slice the extra variables 
    259         #nc.addVariable(pv.data, pv.name, pv.axes.keys(),**pv.attributes)    
     259            nc.addAxis(pvaxis,pv.axes[pvaxis][sliceinfo[pvaxis][0]:sliceinfo[pvaxis][1]], pv.attributes) #of form: nc.addAxis(axisname, data)  
     260            pvslice.append(tuple([sliceinfo[pvaxis][0],sliceinfo[pvaxis][1]])) 
     261 
     262        #add the sliced (or not) variables. 
     263        if len(pvslice) > 0: 
     264            nc.addVariable(pv.data(*pvslice), pv.name, pv.axes.keys(),**pv.attributes) 
     265        else: 
     266            nc.addVariable(pv.data, pv.name, pv.axes.keys(),**pv.attributes) 
     267 
    260268    nc.closeFinishedFile() 
    261269    print 'NetCDF file written to %s'%pathToSubsetNetCDF 
Note: See TracChangeset for help on using the changeset viewer.