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

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

spid fix

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