Changeset 1523
- Timestamp:
- 15/09/06 11:55:59 (14 years ago)
- Location:
- TI02-CSML/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/Examples/parsing/apicalls.py
r1521 r1523 6 6 7 7 #Initialise the CSML container 8 csmlContainer=csml.API.csmlContainer.Container( "mycsmldoc","mymetadatastring")8 csmlContainer=csml.API.csmlContainer.Container(csmlpath='myfile.xml',docID="mycsmldoc_1", metadata="mymetadatastring") 9 9 10 10 #Initialise and parse the dataset … … 53 53 54 54 #request subsetted data from feature (can set paths here) 55 feature.subsetToGridSeries(csmlContainer, timeSelection, csmlpath='myfile.xml',ncpath='myfile.nc',**spatialSubsetDictionary)55 feature.subsetToGridSeries(csmlContainer, timeSelection, ncpath='myfile.nc',**spatialSubsetDictionary) 56 56 csmlbundle=csmlContainer.getContents() 57 57 58 print csmlbundle58 print 'CSML %s'%csmlbundle[0] # csml document 59 59 60 60 #parse and pretty print the result -
TI02-CSML/trunk/csml/API/csmlContainer.py
r1521 r1523 5 5 '''CSMLContainer object is used to hold features before generating a CSML document. This is useful because it allows you to subset several features sequentially then build a single CSML document containing all the subsetted features ''' 6 6 7 def __init__(self,docID, docMetaDataProperty): 7 def __init__(self,csmlpath='myfile.xml',docID='none',metadata='unspecified'): 8 self.csmlpath=csmlpath 8 9 ''' Initialise CSML Dataset and FeatureCollection and populate with basic Metadata''' 9 10 ''' … … 16 17 self.fc=csml.parser.FeatureCollection() 17 18 #Set attributes of dataset 18 #if docMetaDataPropertyis a URI, set it as href attribute if MetaDataProperty instance,19 #if 'metadata' is a URI, set it as href attribute if MetaDataProperty instance, 19 20 #else set it as a text attribute of a MetaDataProperty instance. 20 21 mdp=csml.parser.MetaDataProperty() 21 if csml.parser_extra.isURI( docMetaDataProperty):22 mdp.href= docMetaDataProperty22 if csml.parser_extra.isURI(metadata): 23 mdp.href=metadata 23 24 else: 24 mdp.text = [ docMetaDataProperty]25 mdp.text = [metadata] 25 26 self.ds.metaDataProperty= [mdp] 26 27 #set the id … … 35 36 '''containerContents contains the CSML Document (first item) and then any NetCDF files that are to be delivered with the document ''' 36 37 self.containerContents=[] 37 38 self.ncfiles=[] 38 39 39 40 def appendFileExtract(self, fileextract): … … 51 52 #append NetCDF file object to containerContents 52 53 #need to think about whether it is best to append the file object or just a path to the file 53 self. containerContents.append(ncfile)54 self.ncfiles.append(ncfile) 54 55 55 56 def getContents(self): … … 62 63 strCSML=csml.parser_extra.removeInlineNS(strCSML) 63 64 self.containerContents.append(strCSML) 65 for ncfile in self.ncfiles: 66 self.containerContents.append(ncfile) 64 67 return self.containerContents -
TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py
r1521 r1523 56 56 #MUST be supplied with a CSMLContainer object to store the subsetted feature in 57 57 58 if csmlpath is not None: 59 pathToSubsetCSML = csmlpath 60 else: 61 pathToSubsetCSML='temp.xml' 58 pathToSubsetCSML = container.csmlpath 62 59 if ncpath is not None: 63 60 pathToSubsetNetCDF=ncpath … … 208 205 nc.closeFinishedFile() 209 206 container.attachNetCDFFile(nc) 210 return pathToSubsetCSML,pathToSubsetNetCDF, totalArraySize
Note: See TracChangeset
for help on using the changeset viewer.