source: TI02-CSML/trunk/csml/DDC/model/is92/cccmasubset.py @ 2128

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/DDC/model/is92/cccmasubset.py@2128
Revision 2128, 1.7 KB checked in by domlowe, 13 years ago (diff)

fixed problems with longitude subsetting

Line 
1'''apicalls.py  - test the api'''
2
3import csml,sys
4
5f='DDC/model/is92/cccma.xml'
6
7#Initialise the CSML container
8csmlContainer=csml.API.csmlContainer.Container(csmlpath='./DDC/model/is92/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
20for f in flist:
21    feature=csmldoc.getFeature(f)
22    print feature.id
23    print feature.description.CONTENT
24
25
26#select a feature by name (gml:id)
27#print '\n Selecting feature with gml:id = %s' %flist[3]
28feature=csmldoc.getFeature(flist[0])
29
30#feature 'bestname'
31print feature.id
32print feature.description
33
34#get the domain of the feature
35
36print '\n The feature has domain:' 
37#print feature.getDomain()
38
39#get list of allowed subsettings
40print '\n the following feature subsetting operations are allowed:'
41#print feature.getAllowedSubsettings()
42
43
44#define a selection (based on the domain)
45subsetDictionary={}
46subsetDictionary['time']=('2024-1-15T0:0:0.0','2024-8-15T0:0:0.0')
47subsetDictionary['latitude']=(0, 20)
48subsetDictionary['longitude']=(-10,10)
49#request subsetted data from features (can set paths here) and add to container
50#subset a feature
51csmlContainer.add(feature.subsetToGridSeries(ncpath='DDC/model/is92/subsClim10_1.nc',**subsetDictionary))
52#subsetDictionary['longitude']=(-5,6)
53#csmlContainer.add(feature.subsetToGridSeries(ncpath='DDC/model/is92/subsClim10_2.nc',**subsetDictionary))
54
55
56#when you have finished, get the contents of the container
57csmlbundle=csmlContainer.getContents()
58print 'CSML %s'%csmlbundle[0] # csml document
59paths=csmlbundle[1:]
60print paths #paths to netcdf files
Note: See TracBrowser for help on using the repository browser.