Changeset 1557 for TI02-CSML


Ignore:
Timestamp:
06/10/06 14:14:26 (13 years ago)
Author:
domlowe
Message:

Improved csmlContainer mechanism to allow subsetting of multiple features and delivery in a single csml document with multiple CSML files

Location:
TI02-CSML/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/Examples/parsing/apicalls.py

    r1555 r1557  
    5252spatialSubsetDictionary['longitude']=(-31.265,30.258) 
    5353 
    54 #request subsetted data from feature (can set paths here) 
    55 feature.subsetToGridSeries(csmlContainer, timeSelection,  ncpath='myfile.nc',**spatialSubsetDictionary) 
     54#request subsetted data from features (can set paths here) and add to container 
     55#subset a feature 
     56csmlContainer.add(feature.subsetToGridSeries(timeSelection,  ncpath='myfile.nc',**spatialSubsetDictionary)) 
     57#subset another feature (in fact it's the same feature again, but it proves the concept) 
     58csmlContainer.add(feature.subsetToGridSeries(timeSelection,  ncpath='myfile2.nc',**spatialSubsetDictionary)) 
     59 
     60#when you have finished, get the contents of the container 
    5661csmlbundle=csmlContainer.getContents() 
    57  
    5862print 'CSML %s'%csmlbundle[0] # csml document 
    59  
    60 #parse and pretty print the result 
    61 # strCSML=parser_extra.PrettyPrint(subsetCSML) 
    62 # strCSML=parser_extra.removeInlineNS(strCSML) 
    63 # print strCSML #csml document (string) 
    64 # print subsetCSML 
    65 # print subsetNetCDF # netcdf file (file) 
    66 # print 'arraySize: %s' %arraySize 
     63paths=csmlbundle[1:] 
     64print paths #paths to netcdf files 
  • TI02-CSML/trunk/csml/API/csmlContainer.py

    r1555 r1557  
    5050    def attachNetCDFFile(self, ncfile): 
    5151        ''' Attach a NetCDF file to the container object. Multiple NetCDF files can be referenced from multiple features and returned with the CSML document''' 
    52         #append NetCDF file object to containerContents 
    53         #need to think about whether it is best to append the file object or just a path to the file 
     52        #append NetCDF file path to containerContents 
    5453        self.ncfiles.append(ncfile) 
    5554 
     55    def add(self, featureplusfile): 
     56        #featureplusfile should be a feature, and a filepath to the netcdf file  
     57        self.appendFeature(featureplusfile[0]) 
     58        self.attachNetCDFFile(featureplusfile[1]) 
    5659         
     60    
    5761    def getContents(self): 
    5862        self.ds.arrayDescriptors=self.ad 
  • TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py

    r1523 r1557  
    5353 
    5454 
    55 def subsetToGridSeries(self, container, timeSubset,  csmlpath=None, ncpath=None,**kwargs): 
     55def subsetToGridSeries(self, timeSubset,  csmlpath=None, ncpath=None,**kwargs): 
    5656    #MUST be supplied with a CSMLContainer object to store the subsetted feature in 
    5757     
    58     pathToSubsetCSML = container.csmlpath 
     58    #pathToSubsetCSML = container.csmlpath 
    5959    if ncpath is not None: 
    6060        pathToSubsetNetCDF=ncpath 
     
    178178    csmlWrap=csml.csmllibs.csmlfeaturewrap.CSMLWrapper() 
    179179    subsettedFeature=csmlWrap.createGridSeriesFeature(domain,rangeSet,datasetID="A",featureID="B",description="C") 
    180     container.appendFeature(subsettedFeature) 
     180    #container.appendFeature(subsettedFeature) 
    181181 
    182182    ### write netcdf using NCWriter class (wraps cdms) ### 
     
    204204    nc.addVariable(fulldata,self.id, axes,units='') #to do, units attribute for CF compliance 
    205205    nc.closeFinishedFile() 
    206     container.attachNetCDFFile(nc) 
     206    return subsettedFeature, pathToSubsetNetCDF 
     207    #container.attachNetCDFFile(nc) 
Note: See TracChangeset for help on using the changeset viewer.