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

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

debugging commandline options -- removing hidden settings

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    sc.setTierMax( 1 )
24    for l in ll:
25      x = sc.volByMip2( l, pmax=priorityMax )*1.e-12*bytesPerFloat
26      print ( '%9s  %5.1fTb'  % ( l,x ) )
27      ss += x
28    z = sc.volByMip2( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
29
30    print ( 'Combined:  %5.1fTb'  % z )
31    print ( 'Overlap:   %5.1fTb'  % (ss-z) )
32
33    z1 = sc.volByMip2( set(ll), pmax=priorityMax )*1.e-12*bytesPerFloat
34    sc.setTierMax( 2 )
35    z2 = sc.volByMip2( 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  ##sc.showOpts()
51
52if __name__ == '__main__':
53  main( scope )
Note: See TracBrowser for help on using the repository browser.