source: TI02-CSML/trunk/parser/apicalls.py @ 1115

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/parser/apicalls.py@1178
Revision 1115, 1.6 KB checked in by domlowe, 14 years ago (diff)

testing oxygen subversion client

Line 
1'''apicalls.py  - test the api'''
2
3#from parser api import *
4import API
5
6f='coapec.xml'
7
8#Initialise and parse the dataset
9csml = API.Parser.Dataset()
10csml.parse(f)
11
12#get list of features in the dataset
13flist= csml.getFeatureList() 
14print '\n Here are all the features in %s:' %f
15print flist
16
17#select a feature by name (gml:id)
18print '\n Selecting feature with gml:id = %s' %flist[5]
19feature=csml.getFeature(flist[5])
20
21#feature 'bestname'
22print feature.id
23print feature.description
24
25#get the domain of the feature
26print '\n The feature has domain reference:' 
27#print feature.getDomainReference()
28
29#get the domain complement of the feature
30print '\n The feature has domain complement :' 
31print feature.getDomainComplement()
32
33#get combined domain
34print '\n The feature has domain:' 
35#print feature.getDomain()
36
37#get list of allowed subsettings
38print '\n the following feature subsetting operations are allowed:'
39print feature.getAllowedSubsettings()
40
41
42#define a selection (based on the domain ref/complement)
43#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']
44timeSelection=['2881-3-16T0:0:0.0', '2881-9-16T0:0:0.0']
45spatialSubsetDictionary= {}
46spatialSubsetDictionary['latitude']=(0.,30.0)
47spatialSubsetDictionary['longitude']=(90, 120.0)
48
49#request subsetted data from feature (can set paths here)
50subsetCSML, subsetNetCDF, arraySize=feature.subsetToGridSeries(timeSelection,  csmlpath='myfile.xml', ncpath='myfile.nc',**spatialSubsetDictionary)
51
52print subsetCSML #csml document (string)
53print subsetNetCDF # netcdf file (file)
54print 'arraySize: %s' %arraySize
Note: See TracBrowser for help on using the repository browser.