source: TI02-CSML/trunk/csml/DDC/obs/clim10subset.py @ 2167

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/DDC/obs/clim10subset.py@2167
Revision 2167, 1.6 KB checked in by domlowe, 14 years ago (diff)

added EnvelopeAggregator? class and code to create an EnvelopeWithTimePeriod? for the feature collection

Line 
1'''apicalls.py  - test the api'''
2
3import csml,sys
4
5f='DDC/obs/clim_10.xml'
6
7#Initialise the CSML container
8csmlContainer=csml.API.csmlContainer.Container(csmlpath='./DDC/obs/subsClim10.xml',docID="subsdoc_clim10", metadata='DDC Subsetted Data')
9
10#Initialise and parse the dataset
11csmldoc = csml.parser.Dataset()
12csmldoc.parse(f)
13
14
15#get list of features in the dataset
16flist= csmldoc.getFeatureList() 
17#print '\n Here are all the features in %s:' %f
18#print flist
19
20#select a feature by name (gml:id)
21#print '\n Selecting feature with gml:id = %s' %flist[3]
22feature=csmldoc.getFeature(flist[0])
23
24#feature 'bestname'
25#print feature.id
26#print feature.description
27
28#get the domain of the feature
29
30print '\n The feature has domain:' 
31#print feature.getDomain()
32
33print '\n The units of measure are'
34print feature.getUom()
35
36#get list of allowed subsettings
37print '\n the following feature subsetting operations are allowed:'
38#print feature.getAllowedSubsettings()
39
40
41#define a selection (based on the domain)
42subsetDictionary={}
43#subsetDictionary['time']=('1985-1-15T0:0:0.0')
44subsetDictionary['latitude']=(12,88.85)
45subsetDictionary['longitude']=(53.66, 55)
46#request subsetted data from features (can set paths here) and add to container
47#subset a feature
48csmlContainer.add(feature.subsetToGridSeries(ncpath='DDC/obs/subsClim10_1.nc',**subsetDictionary))
49#subsetDictionary['longitude']=(-1,4)
50#csmlContainer.add(feature.subsetToGridSeries(ncpath='DDC/obs/subsClim10_2.nc',**subsetDictionary))
51
52#when you have finished, get the contents of the container
53csmlbundle=csmlContainer.getContents()
54print 'CSML %s'%csmlbundle[0] # csml document
55paths=csmlbundle[1:]
56print paths #paths to netcdf files
Note: See TracBrowser for help on using the repository browser.