source: TI02-CSML/trunk/newparser/ioDemo.py @ 864

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

csmlio - getDomainComplement,getDomainReference linked up with file extracts

Line 
1#!/usr/bin/env python
2
3#ioDemo.py
4#This document contains example calls to Parser csml io interface
5#Dominic Lowe 25th April 2006
6
7#import csml io module:
8from csmlio import *
9
10#instantiate CSMLinterface object:
11csml =CSMLinterface()
12
13#parse in CSML document:
14#csml.parse('example.xml')
15csml.parse('gridseriestest.xml')
16
17#return CSML document as string:
18strCSML=csml.getCSMLasString()
19#print strCSML
20
21#get list of features by name (gml:id):
22featureList = csml.getFeatureList()
23#print featureList
24
25#get type of feature (supply feature name)
26#get types of all features
27for i in range(0, len(featureList)):
28    featureType = csml.getFeatureType(featureList[i])
29    #print featureType
30   
31   
32#get type of single feature
33#eg featureType=csml.getFeatureType('feat04')
34
35domainref=csml.getDomainReference('solar_3')
36print 'domainref: ' + str(domainref)
37domaincomp=csml.getDomainComplement('solar_3')
38print 'domaincomp: ' + str(domaincomp)
39domain=csml.getDomain('solar_3')
40print 'domain: ' + str(domain)
41
42sys.exit()
43
44#get gml description (long name) of feature
45#fdesc= csml.getFeatureDescription('feat04')
46#print fdesc
47
48#get list of file extracts by gml:id
49fileExtractList=csml.getFileExtractList()
50#print fileExtractList
51
52
53
54#get data from file extract (supply name):
55#currently returns a list, but may need to consider masked arrays
56#dataArray = csml.getData(fileExtractID)
57#dataArray = csml.getData('feat04times')
58for extract in fileExtractList:
59    dataArray=csml.getData(extract)
60    #print extract
61    #print dataArray
62
63#dataArray = csml.getData('2__ncextract_latitude')
64#print dataArray
65
66
67#Alternatively you can call getDatasetObj and then directly
68#interrogate the Parser.Dataset object returned thus bypassing the csmlio wrapper functions
69dataset = csml.getDatasetObj()
70#print dir(dataset)
71
Note: See TracBrowser for help on using the repository browser.