source: CMIP6dreqbuild/trunk/src/framework/dreqPy/examples/ex203.py @ 862

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/dreqPy/examples/ex203.py@862
Revision 862, 1.5 KB checked in by mjuckes, 3 years ago (diff)

fixed ex203.py

Line 
1import sys, os
2
3if len(sys.argv) > 1 and __name__ == '__main__':
4  if os.path.isdir( sys.argv[1] ):
5    if os.path.isfile( '%s/scope.py' % sys.argv[1] ):
6      sys.path.insert(0, sys.argv[1] )
7      import scope
8    else:
9      print ( 'No scope.py in specified directory' )
10      sys.exit(0)
11  else:
12    print ( 'Specified directory does not exist: %s' % sys.argv[1] )
13    sys.exit(0)
14
15## set bytes per floating point number to be 2, assuming 50% compression
16bytesPerFloat = 2.
17
18priorityMax = 3
19def runExample( sc, priorityMax ):
20    ll = ['C4MIP','CFMIP','LUMIP']
21    ee = {}
22    ss = 0.
23    for l in ll:
24      x = sc.volByMip( l, pmax=priorityMax )*1.e-12*bytesPerFloat
25      print ( '%9s  %5.1fTb'  % ( l,x ) )
26      ss += x
27    z = sc.volByMip( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
28
29    print ( 'Combined:  %5.1fTb'  % z )
30    print ( 'Overlap:   %5.1fTb'  % (ss-z) )
31
32    sc.setTierMax( 1 )
33    z1 = sc.volByMip( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
34    sc.setTierMax( 2 )
35    z2 = sc.volByMip( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
36    print ( '' )
37    print ( 'Combined, tier 1 only:  %5.1fTb'  % z1 )
38    print ( 'Combined, tier 1+2 only:  %5.1fTb'  % z2 )
39
40def main(scope):
41
42  sc = scope.dreqQuery()
43  print ('DREQ VERSION: %s' % str(sc.dq.version) )
44  print ( '######### All variables ###########' )
45  priorityMax = 3
46  runExample( sc, priorityMax )
47  print ( '######### Top priority variables ###########' )
48  priorityMax = 1
49  runExample( sc, priorityMax )
50
51if __name__ == '__main__':
52  main( scope )
Note: See TracBrowser for help on using the repository browser.