Changeset 2207 for TI02-CSML


Ignore:
Timestamp:
26/02/07 14:19:17 (13 years ago)
Author:
domlowe
Message:

subsetToProfileSeries working, but not fully complete

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

Legend:

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

    r2206 r2207  
    5151 
    5252##GridSeriesFeature methods: 
    53 addMethods(csml.parser.GridSeriesFeature,[ops_GridFeature.testmethod,ops_GridSeriesFeature.getDomain,ops_GridSeriesFeature.subsetToGridSeries, ops_GridSeriesFeature.getUom, ops_GridSeriesFeature._subsetGrid]) 
     53addMethods(csml.parser.GridSeriesFeature,[ops_GridFeature.testmethod,ops_GridSeriesFeature.getDomain,ops_GridSeriesFeature.subsetToGridSeries, ops_GridSeriesFeature.getUom, ops_GridSeriesFeature._subsetGrid,ops_GridSeriesFeature.subsetToProfileSeries]) 
    5454 
    5555##TrajectoryFeature methods: 
  • TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py

    r2206 r2207  
    106106    return subsettedFeature, pathToSubsetNetCDF 
    107107     
     108 
     109def subsetToProfileSeries(self, csmlpath=None, ncpath=None,**kwargs): 
     110    #TODO   !!!!!!!!! Need to perform some sort of testing on the kwargs to check it is a profileseries request. 
     111     
     112     
     113    #perform the subset (note this included nearest neighbour searching, so may return a different set of kwargs 
     114    pathToSubsetNetCDF, crs, timeName, times, strTimes, calunits, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetGrid(csmlpath, ncpath,**kwargs)  
     115     
     116    #Okay, got the data now. Need to write CSML feature and NetCDF files. 
     117    #Writing out the CSML feature 
     118     
     119    # define domain/coverage  to use in 'value' attribute    
     120    newdomain=csml.parser.ProfileSeriesDomain() 
     121    domainSubset, totalArraySize=csml.API.genSubset.subsetDomain(timeName,strTimes,self.domain, **kwargs) 
     122    cTT=csml.API.genSubset.getCoordTransformTable(domainSubset, crs) 
     123    newdomain.coordTransformTable=cTT 
     124    rangeSet=csml.parser.RangeSet() 
     125    rangeSet.arrayDescriptor=csml.parser.NetCDFExtract(id=self.id,fileName=csml.parser.csString(pathToSubsetNetCDF),variableName=csml.parser.csString(self.id),arraySize=csml.parser.csString(totalArraySize)) 
     126     
     127    #gridseries coverage 
     128    cvg=csml.parser.ProfileSeriesCoverage() 
     129    cvg.rangeSet=rangeSet 
     130    cvg.profileSeriesDomain=newdomain     
     131    csmlWrap=csml.csmllibs.csmlfeaturewrap.CSMLWrapper() 
     132     
     133    #create a stand alone gridseries feature containing this coverage 
     134    subsettedFeature=csmlWrap.createProfileSeriesFeature(value=cvg,featureID=self.id,description=self.description) 
     135  
     136     
     137    ### write netcdf using NCWriter class (wraps cdms) ### 
     138    nc=csml.csmllibs.netCDFWriter.NCwriter(pathToSubsetNetCDF) 
     139    ords=cTT.gridOrdinates 
     140    axislist=[] 
     141    for a in axisorder: 
     142        axislist.append(self.gridnames[a]) 
     143    nc.genWriteVar(self.id,ords, times, calunits, caltype, axislist, units, fulldata, fillvalue) 
     144    nc.closeFinishedFile() 
     145     
     146    return subsettedFeature, pathToSubsetNetCDF 
     147     
     148     
  • TI02-CSML/trunk/csml/csmllibs/csmlfeaturewrap.py

    r2105 r2207  
    4848        pass 
    4949             
    50     def addProfileSeriesFeature(self): 
    51         pass 
     50    def createProfileSeriesFeature(self,value, parameter=None,featureID=None,description=None): 
     51        feat=csml.parser.ProfileSeriesFeature() 
     52        if featureID: 
     53            feat.id= featureID 
     54        else: 
     55            feat.id='No ID' 
     56        if description: 
     57            feat.description=description 
     58        else: 
     59            feat.description='No Description' 
     60        feat.value=value 
     61        #feat.parameter=parameter 
     62        return feat 
    5263 
    5364    def createGridSeriesFeature(self,value, parameter=None,featureID=None,description=None): 
  • TI02-CSML/trunk/csml/testfiles/apicalls.py

    r2206 r2207  
    4242subsetDictionary['latitude']=(-90,60) 
    4343subsetDictionary['longitude']=(-31.265,30.258) 
     44 
    4445#request subsetted data from features (can set paths here) and add to container 
    4546#subset a feature 
    4647csmlContainer.add(feature.subsetToGridSeries(ncpath='myfile.nc',**subsetDictionary)) 
    4748#subset another feature (in fact it's the same feature again, but it proves the concept) 
    48 #csmlContainer.add(feature.subsetToGridSeries(timeSelection,  ncpath='myfile2.nc',**spatialSubsetDictionary)) 
     49subsetDictionary['t']=('2794-12-1T0:0:0.0','2795-12-1T0:0:0.0') 
     50subsetDictionary['latitude']=(75) 
     51subsetDictionary['longitude']=(41.25,45) 
     52csmlContainer.add(feature.subsetToProfileSeries(ncpath='myfile2.nc',**subsetDictionary)) 
    4953 
    5054#when you have finished, get the contents of the container 
Note: See TracChangeset for help on using the changeset viewer.