Ticket #748 (closed task: fixed)
[DS] CSML supports XMLBASE (or equivalant)
Reported by: | domlowe | Owned by: | domlowe |
---|---|---|---|
Priority: | desirable | Milestone: | Reporting |
Component: | CSML | Version: | |
Keywords: | C-SEKT | Cc: |
Description
Fix paths so that csml file and netcdf files are bundled together with the correct relative paths.
Change History
comment:2 Changed 14 years ago by domlowe
- Status changed from assigned to closed
- Resolution set to fixed
Okay, added a fix for this now. xml:base didn't really do what was wanted so the fix is implemented at the python level (which is probably better than adding more to the CSML schema!)
It has had some impact on the API - you now need to pass a variable called 'outputdir' both to the csml container and to the subsetting methods.
Doing this will ensure that the CSML file and NetCDF files are stored in this same directory with the correct paths for the file extracts. Don't attempt to pass a different 'outputdir' to the container and the subsetting methods or things will break :-)
Here's an example:
#------------------------------------------------------------- #csml file: f='thecsmlfile.xml' #output directory outputdir='/home/user/me/temp' #define empty container: csmlContainer=csml.API.csmlContainer.Container(outputdir, csmlname='pointseries.xml',docID="mycsmldoc_1", metadata="mymetadatastring") #parse csml file: csmldoc = csml.parser.Dataset() csmldoc.parse(f) #get a feature: feature=csmldoc.getFeature(flist[0]) #define a selection: timerange=('1972-12-31T21:59:60.0' ,'1973-01-01T01:59:60.0') #perform the subset: csmlContainer.add(feature.subsetToPointSeries(outputdir, ncname='mypointseries.nc',times=timerange)) #get the finished bundle (csml + netcdf): csmlbundle=csmlContainer.getContents() #-------------------------------------------------------------
comment:3 Changed 14 years ago by spascoe
- Priority changed from critical to desirable
- Status changed from closed to reopened
- Resolution fixed deleted
I think there is a more general problem that will require something like xml:base. However, this is probably no longer a "critical" bug, just very annoying, hence downgrading the priority.
If define a relative path as my data source to csmlscan the CSML API can only use the CSML if sitting in the same directory from which csmlscan was ran. E.g. using this csmlscan config file
[features] type: GridSeries number: many [files] root: data mapping: onetoseveral output: data/test.csml printscreen:0 [spatialaxes] spatialstorage:fileextract [values] valuestorage:fileextract [SpatialReference] srs: EPSG 4326 [time] timedimension: time timestorage:inline
Unless I am sitting in the directory containing data I get the following error when looking for a feature's domain:
>>> import csml >>> d = csml.parser.Dataset() >>> d.parse('tests/data/test.csml') (60, 63, 120, 109) >>> d.getFeatureList() ['TEe1WPeQ', 'R4pBu5iY', 'NsrjEthN', 'PNBhERDn'] >>> f = d.getFeature('TEe1WPeQ') >>> f.getDomain()['time'] Traceback (most recent call last): File "<stdin>", line 1, in ? File "/research/saturn2/spascoe/svn/csml_trunk/csml/API/ops_GridSeriesFeature.py", line 67, in getDomain self.domain[name], fill, axisorder, units=gridOrd.coordAxisValues.insertedExtract.getData() File "/research/saturn2/spascoe/svn/csml_trunk/csml/API/ops_FileExtract.py", line 59, in getData DI.setAxis(self.variableName.CONTENT) File "/research/saturn2/spascoe/svn/csml_trunk/csml/csmllibs/csmldataiface.py", line 405, in setAxis self.axisobj=self.file.getAxis(axis) AttributeError: 'cdunifInterface' object has no attribute 'file'
I assume this is because the CSML API fails silently to open the underlying NetCDF. This could be fixed if the CSML file stored the directory in which csmlscan (or a subset operation) was executed in.
Always needing to fix absolute paths in the CSML document means we need to run csmlscan when ever the location of the data changes, even if the CSML doc. moves with the data!
comment:5 Changed 13 years ago by spascoe
- Status changed from reopened to closed
- Resolution set to wontfix
Possible future CSML development.