Changeset 3096


Ignore:
Timestamp:
03/12/07 15:10:24 (12 years ago)
Author:
domlowe
Message:

subsetting of profileseries, pointseries retested and fixed

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

Legend:

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

    r3068 r3096  
    318318def subsetToProfile(self, outputdir = None, ncname='profile.nc',**kwargs): 
    319319    #Two step process - subset GridSeries to ProfileSeries, then ProfileSeries to Profile 
    320     profileSeries, pSfile=self.subsetToProfileSeries(outputdir, ncname, **kwargs)    
     320    odir=outputdir 
     321    profileSeries, pSfile, descriptor=self.subsetToProfileSeries(odir, ncname, **kwargs)    
    321322    del kwargs['latitude']    #TODO - need to remove excess kwargs based on the domain of the temporary profileSeries feature 
    322323    del kwargs['longitude'] 
    323     subsettedFeature, pathToSubsetNetCDF=profileSeries.subsetToProfile(ouputdir,ncname, **kwargs)     
    324     return subsettedFeature, pathToSubsetNetCDF 
     324    subsettedFeature, pathToSubsetNetCDF, descriptor =profileSeries.subsetToProfile(odir,ncname, **kwargs)     
     325    return subsettedFeature, pathToSubsetNetCDF, descriptor 
    325326 
    326327def subsetToPointSeries(self, outputdir =None, ncname='pointseries.nc',**kwargs): 
    327328    #Two step process - subset GridSeries to ProfileSeries, then ProfileSeries to PointSeries 
    328     profileSeries, pSfile=self.subsetToProfileSeries(outputdir, ncname, **kwargs)    
     329    profileSeries, pSfile, descriptor =self.subsetToProfileSeries(outputdir, ncname, **kwargs)    
    329330    del kwargs['latitude']    #TODO - need to remove excess kwargs based on the domain of the temporary profileSeries feature 
    330331    del kwargs['longitude'] 
    331     subsettedFeature, pathToSubsetNetCDF=profileSeries.subsetToPointSeries(outputdir, ncname, **kwargs)     
    332     return subsettedFeature, pathToSubsetNetCDF 
     332    subsettedFeature, pathToSubsetNetCDF, descriptor=profileSeries.subsetToPointSeries(outputdir, ncname, **kwargs)     
     333    return subsettedFeature, pathToSubsetNetCDF, descriptor 
  • TI02-CSML/trunk/csml/API/ops_ProfileSeriesFeature.py

    r2590 r3096  
    4848    #get the CRS from a  the  catalogue 
    4949    cat=csml.csmllibs.csmlcrs.CRSCatalogue() 
    50     crs=cat.getCRS(self.value.profileSeriesDomain.srsName, labels = self.value.profileSeriesDomain.axisLabels)   
     50    crs=cat.getCRS(self.value.profileSeriesDomain.srsName) 
    5151     
    5252    #non-feature specific setup code, mainly handles the time dimension/calendar 
     
    6363        except KeyError: 
    6464            allValues=tuple(self.domain[gridOrd.coordAxisLabel.CONTENT]) 
    65     strTimes, axisorder, units, fulldata, fillvalue =csml.API.genSubset.getTheData(self, selection, times, timeName) 
     65    strTimes, axisorder, units, fulldata, fillvalue =csml.API.genSubset.getTheData(self, selection, times, timeName, timeAxis) 
    6666    return pathToSubsetNetCDF, crs, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs 
    6767             
     
    137137    #parameter, as before subsetting. 
    138138    param = self.parameter 
     139    stdname=param.getStandardName() 
    139140         
    140141    #create 'location' attribute: 
     
    166167    otherdims['latitude']=float(loc.CONTENT.split()[0]) 
    167168    otherdims['longitude']=float(loc.CONTENT.split()[1]) 
    168     nc.genWriteVar(self.name.CONTENT,ords, times,  caltype, axislist, units, fulldata, fillvalue, **otherdims) 
     169    nc.genWriteVar(self.name.CONTENT,ords, times,  caltype, axislist, units, stdname, fulldata, fillvalue, **otherdims) 
    169170    nc.closeFinishedFile() 
    170171    print 'NetCDF file written to %s'%pathToSubsetNetCDF 
     
    178179    elif csml.API.csmlContainer.globalContainer.OUTPUTDIR is not None: 
    179180        self.outputdir=csml.API.csmlContainer.globalContainer.OUTPUTDIR 
    180      
    181     pathToSubsetNetCDF, crs, timeName, times, strTimes, calunits, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetProfileSeries(**kwargs)  
    182      
    183     (time, lat, lon)=(crs.axes[crs.timeAxis],crs.axes[crs.latAxis], crs.axes[crs.lonAxis]) 
    184     print axisorder 
     181    self.ncname=ncname 
     182     
     183    pathToSubsetNetCDF, crs, timeName, times, strTimes, caltype, axisorder,units, fulldata, fillvalue, kwargs=self._subsetProfileSeries(**kwargs)     
     184    time=crs.axes[crs.timeAxis] 
     185    lon='longitude' 
     186    lat='latitude' 
    185187    for axis in axisorder: 
    186188        if axis not in [time, lat, lon]: 
     
    196198     
    197199    rangeSet=csml.parser.RangeSet() 
    198     #rangeSet.arrayDescriptor=csml.parser.NetCDFExtract(id=self.id,fileName=csml.parser.csString(pathToSubsetNetCDF),variableName=csml.parser.csString(self.id),arraySize=csml.parser.csString(totalArraySize)) 
     200    rangeSet.arrayDescriptor=csml.parser.NetCDFExtract(id=self.id,fileName=csml.parser.csString(pathToSubsetNetCDF),variableName=csml.parser.csString(self.id),arraySize=csml.parser.csString(len(times))) 
    199201     
    200202    #gridseries coverage 
     
    205207    #parameter, as before subsetting. 
    206208    param = self.parameter 
     209    stdname=param.getStandardName() 
    207210         
    208211    #create 'location' attribute: 
     
    227230    otherdims[extraName]=extraAxis 
    228231    otherdims['latitude']=float(loc.CONTENT.split()[0]) 
    229     otherdims['longitude']=float(loc.CONTENT.split()[1]) 
    230      
    231     nc.genWriteVar(self.name.CONTENT,ords, times, calunits, caltype, axislist, units, fulldata, fillvalue, **otherdims) 
     232    otherdims['longitude']=float(loc.CONTENT.split()[1])     
     233    nc.genWriteVar(self.name.CONTENT,ords, times, caltype, axislist, units, stdname,fulldata, fillvalue, **otherdims) 
    232234    nc.closeFinishedFile() 
    233235    print 'NetCDF file written to %s'%pathToSubsetNetCDF 
    234     return subsettedFeature, pathToSubsetNetCDF 
    235  
     236    return subsettedFeature, pathToSubsetNetCDF, rangeSet.arrayDescriptor 
     237 
  • TI02-CSML/trunk/csml/API/ops_RaggedSectionFeature.py

    r3055 r3096  
    9191                break 
    9292             
     93    if not hasattr(self, 'domain'): 
     94        self.domain=self.getDomain() 
    9395    #need to get the lat and lon to correspond with the selected times: 
    9496    selectedLats=[eval(lat) for lat in self.domain['latitude'][minIndex:maxIndex+1]] 
  • TI02-CSML/trunk/csml/csmllibs/netCDFWriter.py

    r3051 r3096  
    5858    def addVariable(self,data, variableName,axesList, fillvalue, stdname=None, **kwargs):         
    5959        #creates a new variable containing data with named attributes from **kwargs        
    60               
    6160        dataarray=MV.array(data)       
    6261        dataarray.id=variableName 
  • TI02-CSML/trunk/csml/testfiles/gridseries/subset.py

    r2974 r3096  
    5757#csmlContainer.add(feature.subsetToGridSeries(outputdir,ncname='mygridseries.nc',latitude=(-90,90), longitude=(-180,180),time=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0'))) 
    5858 
    59 csmlContainer.add(feature.subsetToGridSeries(outputdir,ncname='mygridseries.nc',latitude=(60), longitude=(180),time=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0'))) 
     59#csmlContainer.add(feature.subsetToGridSeries(outputdir,ncname='mygridseries.nc',latitude=(60), longitude=(180),time=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0'))) 
    6060 
    61 #subset another feature (in fact it's the same feature again, but this time subsetting to a profileseries) 
    62 subsetDictionary={} 
    63 subsetDictionary['time']=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0') 
    64 subsetDictionary['latitude']=(75) 
    65 subsetDictionary['longitude']=(45) 
     61##subset another feature (in fact it's the same feature again, but this time subsetting to a profileseries) 
     62#subsetDictionary={} 
     63#subsetDictionary['time']=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0') 
     64#subsetDictionary['latitude']=(75) 
     65#subsetDictionary['longitude']=(45) 
    6666 
    67 ##assigning profileseries feature to variable 
    68 #print 'subset grid to profileseries' 
    69 psfeature, file, descriptor =feature.subsetToProfileSeries(outputdir, ncname='myprofileseries.nc',**subsetDictionary) 
    70 csmlContainer.add([psfeature,file, descriptor]) 
     67###assigning profileseries feature to variable 
     68##print 'subset grid to profileseries' 
     69#psfeature, file, descriptor =feature.subsetToProfileSeries(outputdir, ncname='myprofileseries.nc',**subsetDictionary) 
     70#csmlContainer.add([psfeature,file, descriptor]) 
    7171 
    7272#csmlContainer.add(feature.subsetToProfileSeries(outputdir,ncname='myprofileseries.nc',latitude=(75), longitude=(45),time=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0'))) 
    7373 
    74 #Now subset this New ProfileSeries feature into a Profile feature 
     74##Now subset this New ProfileSeries feature into a Profile feature 
    7575#print 'subset  profileseries to profile' 
    7676#subsetDictionary={} 
    77 #subsetDictionary['time']=('2794-12-1T0:0:0.0') 
    78 #csmlContainer.add(psfeature.subsetToProfile(outputdir, ncname='myprofile1.nc',**subsetDictionary)) 
     77#subsetDictionary['time']=('2804-12-01T00:00:00.0') 
     78#csmlContainer.add(psfeature.subsetToProfile(outputdir, ncname='myprofile.nc',**subsetDictionary)) 
    7979 
    8080 
    8181#Now try the subset to profile method of the grid series feature -BROKEN 
    82 #subsetDictionary={} 
    83 #subsetDictionary['time']=('2804-12-1T0:0:0.0') 
    84 #subsetDictionary['latitude']=(80) 
    85 #subsetDictionary['longitude']=(55) 
    86 #csmlContainer.add(feature.subsetToProfile(outputdir, ncname='myprofile.nc',**subsetDictionary)) 
     82print 'subsetting gridseries to profile' 
     83subsetDictionary={} 
     84subsetDictionary['time']=('2804-12-01T00:00:00.0') 
     85subsetDictionary['latitude']=(80) 
     86subsetDictionary['longitude']=(55) 
     87csmlContainer.add(feature.subsetToProfile(outputdir, ncname='myprofile.nc',**subsetDictionary)) 
    8788 
    8889#Now try the subset to PointSeries method of the grid series feature 
    89 #subsetDictionary={} 
    90 #subsetDictionary['time']=('2794-12-1T0:0:0.0','2904-12-1T0:0:0.0') 
    91 #subsetDictionary['latitude']=(80) 
    92 #subsetDictionary['longitude']=(55) 
    93 ##subsetDictionary['pressure']=(0)  #BROKEN 
    94 #csmlContainer.add(feature.subsetToPointSeries(outputdir,ncname='mypointseries.nc',**subsetDictionary)) 
     90print 'subsetting gridseries to pointseries' 
     91subsetDictionary={} 
     92subsetDictionary['time']=('2804-12-01T00:00:00.0','2904-12-01T00:00:00.0') 
     93subsetDictionary['latitude']=80 
     94subsetDictionary['longitude']=55 
     95#subsetDictionary['pressure']=(0)  #BROKEN 
     96csmlContainer.add(feature.subsetToPointSeries(outputdir,ncname='mypointseries.nc',**subsetDictionary)) 
    9597 
    9698 
Note: See TracChangeset for help on using the changeset viewer.