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

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

calendar information is now stored in csml using the frame attribute of the TimePositionList.

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