Ignore:
Timestamp:
08/06/07 14:47:23 (13 years ago)
Author:
domlowe
Message:

Fixed problem with relative paths in CSML documents

File:
1 edited

Legend:

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

    r2527 r2567  
    8787    return uom 
    8888 
    89 def _subsetGrid(self, csmlpath=None, ncpath=None,**kwargs): 
     89def _subsetGrid(self, **kwargs): 
    9090    '''this takes a selection from a gridseries object (be it a profile, a grid, whatever, it is still just a selection''' 
    9191            
     
    101101    #non-feature specific setup code, mainly handles the time dimension/calendar 
    102102     
    103     pathToSubsetNetCDF, kwargs, timeAxis, timeName, caltype, times=csml.API.genSubset.genericSubset(self, csmlpath, ncpath, self.domain, kwargs) 
     103    pathToSubsetNetCDF, kwargs, timeAxis, timeName, caltype, times=csml.API.genSubset.genericSubset(self, self.outputdir, self.ncname, self.domain, kwargs) 
    104104       
    105105    ##Get names of variables in file and relate them to the subset selection  
     
    127127    return pathToSubsetNetCDF, crs, frame, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs 
    128128     
    129 def subsetToGridSeries(self, csmlpath=None, ncpath=None,**kwargs): 
     129def subsetToGridSeries(self, outputdir, ncname='gridseries.nc',**kwargs): 
    130130    #perform the subset (note this included nearest neighbour searching, so may return a different set of kwargs 
    131     pathToSubsetNetCDF, crs, frame, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetGrid(csmlpath, ncpath,**kwargs)  
     131    self.outputdir=outputdir 
     132    csml.csmllibs.csmlextra.checkDirExists(self.outputdir) 
     133    self.ncname=ncname 
     134    pathToSubsetNetCDF, crs, frame, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetGrid(**kwargs)  
    132135    #Okay, got the data now. Need to write CSML feature and NetCDF files. 
    133136    #Writing out the CSML feature 
     
    150153    rs=csml.parser.RangeSet() 
    151154    sdid=csml.csmllibs.csmlextra.getRandomID() 
    152     descriptor=csml.parser.NetCDFExtract(id=sdid,fileName=csml.parser.csString(pathToSubsetNetCDF),variableName=self.name,arraySize=csml.parser.csString(totalArraySize)) 
     155    descriptor=csml.parser.NetCDFExtract(id=sdid,fileName=csml.parser.csString(self.ncname),variableName=self.name,arraySize=csml.parser.csString(totalArraySize)) 
    153156    rs=csml.parser.RangeSet() 
    154157    va=csml.parser.ValueArray() 
     
    190193     
    191194 
    192 def subsetToProfileSeries(self, csmlpath=None, ncpath=None,**kwargs): 
     195def subsetToProfileSeries(self, outputdir, ncname='profileseries.nc',**kwargs): 
    193196    #TODO   !!!!!!!!! Need to perform some sort of testing on the kwargs to check it is a profileseries request. 
    194      
     197    self.outputdir=outputdir 
     198    csml.csmllibs.csmlextra.checkDirExists(self.outputdir) 
     199    self.ncname=ncname    
    195200     
    196201    #perform the subset (note this included nearest neighbour searching, so may return a different set of kwargs 
    197     pathToSubsetNetCDF, crs,frame, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetGrid(csmlpath, ncpath,**kwargs)  
     202    pathToSubsetNetCDF, crs,frame, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetGrid(**kwargs)  
    198203    latName=crs.axes[crs.latAxis] 
    199204    lonName=crs.axes[crs.lonAxis] 
     
    236241    rangeSet=csml.parser.RangeSet() 
    237242    descid=csml.csmllibs.csmlextra.getRandomID() 
    238     descriptor=csml.parser.NetCDFExtract(id=descid,fileName=csml.parser.csString(pathToSubsetNetCDF),variableName=csml.parser.csString(self.id),arraySize=csml.parser.csString(totalArraySize)) 
     243    descriptor=csml.parser.NetCDFExtract(id=descid,fileName=csml.parser.csString(ncname),variableName=csml.parser.csString(self.id),arraySize=csml.parser.csString(totalArraySize)) 
    239244    rs=csml.parser.RangeSet() 
    240245    va=csml.parser.ValueArray() 
     
    287292    return subsettedFeature, pathToSubsetNetCDF, descriptor 
    288293 
    289 def subsetToProfile(self, csmlpath=None, ncpath=None,**kwargs): 
     294def subsetToProfile(self, outputdir, ncname='profile.nc',**kwargs): 
    290295    #Two step process - subset GridSeries to ProfileSeries, then ProfileSeries to Profile 
    291     profileSeries, pSfile=self.subsetToProfileSeries(csmlpath=csmlpath, ncpath=ncpath, **kwargs)    
     296    profileSeries, pSfile=self.subsetToProfileSeries(outputdir, ncname, **kwargs)    
    292297    del kwargs['latitude']    #TODO - need to remove excess kwargs based on the domain of the temporary profileSeries feature 
    293298    del kwargs['longitude'] 
    294     subsettedFeature, pathToSubsetNetCDF=profileSeries.subsetToProfile(csmlpath=csmlpath, ncpath=ncpath, **kwargs)     
     299    subsettedFeature, pathToSubsetNetCDF=profileSeries.subsetToProfile(ouputdir,ncname, **kwargs)     
    295300    return subsettedFeature, pathToSubsetNetCDF 
    296301 
    297 def subsetToPointSeries(self, csmlpath=None, ncpath=None,**kwargs): 
     302def subsetToPointSeries(self, outputdir, ncname='pointseries.nc',**kwargs): 
    298303    #Two step process - subset GridSeries to ProfileSeries, then ProfileSeries to PointSeries 
    299     profileSeries, pSfile=self.subsetToProfileSeries(csmlpath=csmlpath, ncpath=ncpath, **kwargs)    
     304    profileSeries, pSfile=self.subsetToProfileSeries(outputdir, ncname, **kwargs)    
    300305    del kwargs['latitude']    #TODO - need to remove excess kwargs based on the domain of the temporary profileSeries feature 
    301306    del kwargs['longitude'] 
    302     subsettedFeature, pathToSubsetNetCDF=profileSeries.subsetToPointSeries(csmlpath=csmlpath, ncpath=ncpath, **kwargs)     
     307    subsettedFeature, pathToSubsetNetCDF=profileSeries.subsetToPointSeries(outputdir, ncname, **kwargs)     
    303308    return subsettedFeature, pathToSubsetNetCDF 
Note: See TracChangeset for help on using the changeset viewer.