summaryrefslogtreecommitdiffstats
path: root/reduce.py
blob: 10caef794a46d126bf446a32f553e2ab49a46b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import matplotlib as mpl; mpl.use('agg')
import DiskXYZ
import DiskRTZ
import argparse
import sys

# Parse Arguments
parser = argparse.ArgumentParser()
parser.add_argument("imin", type=int, help='First Output')
parser.add_argument("imax", type=int, help='Last Output')
parser.add_argument("--nsamples", type=int, \
                    help='Number of Sampling Points per Axis')
args = parser.parse_args()

# Sanity Checks
if args.imin > args.imax:
    print("Cannot Work With Imin > Imax. Use -h for help.")
    sys.exit(-1)

# Sampling:
print ""
if args.nsamples:
    print "*** Using %i Sampling Points per Axis." % args.nsamples
else:
    print "*** Using %i Sampling Points per Axis." % 128

# Loop Over Outputs
iouts = range(args.imin, args.imax+1)
for iout in iouts:
    print ""
    print "******************************"
    print "Processing Output %05i (XYZ)." % iout
    print "******************************"
    print ""
    disk = DiskXYZ.Disk(iout)
    if args.nsamples:
        disk.nx = args.nsamples
        disk.ny = args.nsamples
        disk.nz = args.nsamples
    print ""; print "***"; print "*** Loading Raw Data."; print "***"; print ""
    disk.load_ramses()
    print ""; print "***"; print "*** Reducing Raw Data."; print "***"; print ""
    disk.reduce_all()
    print ""; print "***"; print "*** Saving Reduced Data."; print "***"; print ""
    disk.save_npz()
    print ""; print "***"; print "*** Done."; print "***"
    print ""
    print "******************************"
    print "Processing Output %05i (RTZ)." % iout
    print "******************************"
    print ""
    disk = DiskRTZ.Disk(iout)
    if args.nsamples:
        disk.nr     = args.nsamples
        disk.ntheta = args.nsamples
        disk.nz     = args.nsamples
    print ""; print "***"; print "*** Loading Raw Data."; print "***"; print ""
    disk.load_ramses()
    print ""; print "***"; print "*** Reducing Raw Data."; print "***"; print ""
    disk.reduce_all()
    print ""; print "***"; print "*** Saving Reduced Data."; print "***"; print ""
    disk.save_npz()
    print ""; print "***"; print "*** Done."; print "***"; print ""