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

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

basic getData method working for NetCDF/PP/NasaAmes

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()
23print featureList
24
25#get type of feature (supply feature name)
26
27
28#get types of all features
29for i in range(0, len(featureList)):
30    featureType = csml.getFeatureType(featureList[i])
31    print featureType
32
33#get type of single feature
34#eg featureType=csml.getFeatureType('feat04')
35
36
37#get gml description (long name) of feature
38#fdesc= csml.getFeatureDescription('feat04')
39#print fdesc
40
41#get list of file extracts by gml:id
42fileExtractList=csml.getFileExtractList()
43print fileExtractList
44
45
46
47#get data from file extract (supply name):
48#currently returns a list, but may need to consider masked arrays
49#dataArray = csml.getData(fileExtractID)
50#dataArray = csml.getData('feat04times')
51dataArray = csml.getData('2__ncextract_latitude')
52print dataArray
53
54
55#Alternatively you can call getDatasetObj and then directly
56#interrogate the Parser.Dataset object returned thus bypassing the csmlio wrapper functions
57dataset = csml.getDatasetObj()
58print dir(dataset)
59
Note: See TracBrowser for help on using the repository browser.