source: TI02-CSML/trunk/csml/tests/test_trajectory.txt @ 3131

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/tests/test_trajectory.txt@3131
Revision 3131, 2.1 KB checked in by domlowe, 12 years ago (diff)

individual bounding boxes extended to edge of grid cells - not done yet for dataset bounding box

Line 
1Trajectory feature test:
2        >>> import csml
3        >>> f='./featuretypes/Trajectory/TrajectoryFeature.xml'
4        >>> outputdir='output'
5        >>> csmlContainer=csml.API.csmlContainer.Container(outputdir,  csmlname='trajout.xml',docID="mycsmldoc_1", metadata="href://www.bodc.co.uk", datasetName='my trajectory dataset')
6        >>> csmldoc = csml.parser.Dataset()
7        >>> csmldoc.parse(f)
8        >>> flist= csmldoc.getFeatureList()
9        >>> flist
10        ['MMDA43433', 'MMDA43433_VelNorth', 'MMDA43433_ATTNMR01', 'MMDA43433_CAPHZZ01', 'MMDA43433_CDTASS01', 'MMDA43433_CPHLUW01', 'MMDA43433_CRELSS01', 'MMDA43433_CSLRZZ01', 'MMDA43433_CWETSS01', 'MMDA43433_DWIRRXSD', 'MMDA43433_DWIRSXSD', 'MMDA43433_ESZKSA01', 'MMDA43433_EWDASS01', 'MMDA43433_EWSKSS01', 'MMDA43433_FVLTAQ01', 'MMDA43433_HEADCM01', 'MMDA43433_MBANCT01', 'MMDA43433_PSALSG01', 'MMDA43433_TEMPSG01']
11        >>> feature=csmldoc.getFeature(flist[0])
12        >>> feature.id
13        'MMDA43433'
14        >>> feature.description.CONTENT
15        'Eastward velocity (over ground) of measurement platform by unspecified GPS system'
16        >>> d=feature.getDomain()   
17        >>> d.keys()
18        ['latitude', 'longitude', 'time']
19        >>> feature.getAllowedSubsettings()
20        ['subsetToTrajectory']
21        >>> csmlContainer.add(feature.subsetToTrajectory(outputdir,ncname='mytrajectory.nc',time=['1996-06-06T15:30:00.0','1996-07-04T08:40:00.1'], longitude=[-12,-10],latitude=[51,53]))
22        NetCDF file written to output/mytrajectory.nc
23        >>> csmlbundle=csmlContainer.getContents()
24        >>> csmlbundle[0] # csml document
25        'trajout.xml'
26        >>> csmlbundle[1:] #paths
27        ['output/mytrajectory.nc']
28
29Now check the output netcdf:
30        >>> import cdms
31        >>> f=cdms.open('output/mytrajectory.nc')
32        >>> f.getVariables()
33        [<Variable: ASLVZZ01, file: output/mypointseries.nc, shape: (4,)>]
34        >>> f.listdimension()
35        ['time']
36        >>> f.listvariables()
37        ['ASLVZZ01']
38        >>> v=f['ASLVZZ01']
39        >>> v.getValue()
40        array([ 5.05974293  5.66935062  6.0960741   6.18751621])
Note: See TracBrowser for help on using the repository browser.