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

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

corrections to unitTest option

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)
14else:
15  from dreqPy import scope
16
17sc = scope.dreqQuery()
18
19## set bytes per floating point number to be 2, assuming 50% compression
20bytesPerFloat = 2.
21
22priorityMax = 3
23def runExample( priorityMax ):
24    ll = ['C4MIP','CFMIP','LUMIP']
25    ee = {}
26    ss = 0.
27    for l in ll:
28      x = sc.volByMip( l, pmax=priorityMax )*1.e-12*bytesPerFloat
29      print ( '%9s  %5.1fTb'  % ( l,x ) )
30      ss += x
31    z = sc.volByMip( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
32
33    print ( 'Combined:  %5.1fTb'  % z )
34    print ( 'Overlap:   %5.1fTb'  % (ss-z) )
35
36    sc.setTierMax( 1 )
37    z1 = sc.volByMip( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
38    sc.setTierMax( 2 )
39    z2 = sc.volByMip( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
40    print ( '' )
41    print ( 'Combined, tier 1 only:  %5.1fTb'  % z1 )
42    print ( 'Combined, tier 1+2 only:  %5.1fTb'  % z2 )
43
44print ( '######### All variables ###########' )
45priorityMax = 3
46runExample( priorityMax )
47print ( '######### Top priority variables ###########' )
48priorityMax = 1
49runExample( priorityMax )
Note: See TracBrowser for help on using the repository browser.