summaryrefslogtreecommitdiffstats
path: root/plot_rho_rz.py
blob: 046c544c63efe3e1c82e1df653822987788e66af (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
import matplotlib as mpl; mpl.use('agg')
import matplotlib.pyplot as plt
from DiskRTZ import Disk
import numpy as np
import argparse
import sys
from math import pi

# Parse Arguments
parser = argparse.ArgumentParser()
parser.add_argument("imin", type=int, help='First Output')
parser.add_argument("imax", type=int, help='Last Output')
args = parser.parse_args()

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

# Build Output Range
iouts = range(args.imin, args.imax+1)

# Determine Density Limits
first = True;
for iout in iouts:
    print "Scanning MinMax %i/%i." % (iout, iouts[-1])
    disk = Disk(iout)
    disk.load_npz_minmax()
    if first:
        rho_rz_lo = disk.rho_rz_min; rho_rz_hi = disk.rho_rz_max
        first = False
    else:
        if disk.rho_rz_min < rho_rz_lo: rho_rz_lo = disk.rho_rz_min
        if disk.rho_rz_max > rho_rz_hi: rho_rz_hi = disk.rho_rz_max

rho_rz_lim = [np.log10(rho_rz_lo), np.log10(rho_rz_hi)]

# Make Plots
for iout in iouts:
    print "Rendering Figure %i/%i." % (iout, iouts[-1])
    disk = Disk(iout)
    disk.load_npz()
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    disk.plot_rho_rz(ax, clim=rho_rz_lim)
    plt.suptitle("t=%0.2f [code] / t=%0.2f [yr] / %05d [iout]" % \
        (disk.info["time"], disk.info["time"]/2./pi, iout))
    plt.savefig('rho_rz_%05d.png' % iout)
    plt.clf()
    plt.close()
    del disk