source: CMIP6dreq/trunk/dreqPy/examples/ex102.py @ 626

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/trunk/dreqPy/examples/ex102.py@626
Revision 626, 986 bytes checked in by mjuckes, 4 years ago (diff)

adding examples and pav.xsd

Line 
1
2import sys, os
3import xml
4import xml.dom.minidom
5
6if len( sys.argv ) > 1:
7  fn = sys.argv[1]
8  if os.path.isfile( fn ):
9    xmlf = fn
10  else:
11    print 'File %s not found' % fn
12    sys.exit(0)
13else:
14  xmlf = 'out/annotated_20150731.xml'
15
16doc = xml.dom.minidom.parse( xmlf )
17
18dcppLinks = []
19requestedGroups = set()
20
21# find request links
22sect = doc.getElementsByTagName( 'requestLink' )[0]
23s = set()
24for item in sect.getElementsByTagName( 'item' ):
25  if item.getAttribute( 'mip' ) == 'DCPP':
26    dcppLinks.append( item )
27    requestedGroups.add( item.getAttribute( 'refid' ) )
28print 'Request links found for DCPP: %s' % len( dcppLinks )
29
30print 'Request groups found for DCPP: %s' % len( requestedGroups )
31
32sect = doc.getElementsByTagName( 'requestVar' )[0]
33cmorVars = set()
34for item in sect.getElementsByTagName( 'item' ):
35  if item.getAttribute( 'vgid' ) in requestedGroups:
36    cmorVars.add(  item.getAttribute( 'vid' ) )
37
38print 'CMOR variables requested by DCPP: %s' % len(cmorVars)
Note: See TracBrowser for help on using the repository browser.