Changeset 3296 for TI02-CSML/trunk/csml/Examples/Parsing/apicalls.py
- Timestamp:
- 04/02/08 12:19:28 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/Examples/Parsing/apicalls.py
r2049 r3296 3 3 import csml 4 4 5 f='Examples/parsing/test.xml' 5 f='example.xml' 6 outputdir = 'out' 6 7 7 8 #Initialise the CSML container 8 csmlContainer=csml.API.csmlContainer.Container( csmlpath='myfile.xml',docID="mycsmldoc_1", metadata="mymetadatastring")9 csmlContainer=csml.API.csmlContainer.Container(outputdir,csmlname='myfile.xml',docID="mycsmldoc_1", metadata="mymetadatastring") 9 10 10 11 #Initialise and parse the dataset 11 csmldoc = csml.parser.Dataset() 12 csmldoc.parse(f) 12 csmldoc = csml.parser.Dataset(file=f) 13 13 14 14 … … 19 19 20 20 #select a feature by name (gml:id) 21 print '\n Selecting feature with gml:id = %s' %flist[ 4]22 feature=csmldoc.getFeature(flist[ 4])21 print '\n Selecting feature with gml:id = %s' %flist[0] 22 feature=csmldoc.getFeature(flist[0]) 23 23 24 24 f#eature 'bestname' … … 27 27 28 28 #get the domain of the feature 29 print '\n The feature has domain reference:' 30 print feature.getDomainReference() 31 32 #get the domain complement of the feature 33 print '\n The feature has domain complement :' 34 print feature.getDomainComplement() 35 36 #get combined domain 37 print '\n The feature has domain:' 38 #print feature.getDomain() 29 print '\n The feature has domain: ' 30 print feature.getDomain() 39 31 40 32 #get list of allowed subsettings … … 43 35 44 36 45 #define a selection (based on the domain ref/complement) 46 #timeSelection=['2881-3-16T0:0:0.0', '2881-4-16T0:0:0.0', '2881-5-16T0:0:0.0', '2881-6-16T0:0:0.0', '2881-7-16T0:0:0.0', '2881-8-16T0:0:0.0', '2881-9-16T0:0:0.0'] 47 timeSelection=['2794-12-1T0:0:0.0', '2844-12-1T0:0:0.0'] 48 49 spatialSubsetDictionary= {} 50 spatialSubsetDictionary['latitude']=(-90,90) 51 #spatialSubsetDictionary['longitude']=(330,359) 52 spatialSubsetDictionary['longitude']=(-31.265,30.258) 37 #define a selection (based on the domain) 38 timeSelection=['2007-08-12T10:45:00', '2007-08-12T11:45:00'] 53 39 54 40 #request subsetted data from features (can set paths here) and add to container 55 41 #subset a feature 56 csmlContainer.add(feature.subsetToGridSeries(timeSelection, ncpath='myfile.nc',**spatialSubsetDictionary)) 57 #subset another feature (in fact it's the same feature again, but it proves the concept) 58 csmlContainer.add(feature.subsetToGridSeries(timeSelection, ncpath='myfile2.nc',**spatialSubsetDictionary)) 42 csmlContainer.add(feature.subsetToPointSeries(times=timeSelection, ncname='myfile.nc')) 59 43 60 44 #when you have finished, get the contents of the container
Note: See TracChangeset
for help on using the changeset viewer.