summaryrefslogtreecommitdiffstats
path: root/plot_quad_mag_r.py
blob: ab69fde2b1cb6f92d57ed0b92c9ee180d949a7e2 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import matplotlib as mpl; mpl.use('agg')
import matplotlib.pyplot as plt
import DiskXYZ
import DiskRTZ
import numpy as np
import argparse
import sys
from math import pi
from copy import deepcopy

# 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 Data Ranges
first = True
for iout in iouts:
    print "Scanning MinMax %i/%i." % (iout, iouts[-1])
    disk = DiskXYZ.Disk(iout)
    disk.load_npz_minmax()

    if first:
        T_mid_r_max = disk.T_mid_r_max
        T_mid_r_min = disk.T_mid_r_min
        n_mid_r_max = disk.n_mid_r_max
        n_mid_r_min = disk.n_mid_r_min
        xe_mid_r_max = disk.xe_mid_r_max
        xe_mid_r_min = disk.xe_mid_r_min
        ReM_mid_r_max = disk.ReM_mid_r_max
        ReM_mid_r_min = disk.ReM_mid_r_min
        first = False

    if T_mid_r_min < disk.T_mid_r_min: T_mid_r_min = disk.T_mid_r_min
    if T_mid_r_max > disk.T_mid_r_max: T_mid_r_max = disk.T_mid_r_max
    if n_mid_r_min < disk.n_mid_r_min: n_mid_r_min = disk.n_mid_r_min
    if n_mid_r_max > disk.n_mid_r_max: n_mid_r_max = disk.n_mid_r_max
    if xe_mid_r_min < disk.xe_mid_r_min: xe_mid_r_min = disk.xe_mid_r_min
    if xe_mid_r_max > disk.xe_mid_r_max: xe_mid_r_max = disk.xe_mid_r_max
    if ReM_mid_r_min < disk.ReM_mid_r_min: ReM_mid_r_min = disk.ReM_mid_r_min
    if ReM_mid_r_max > disk.ReM_mid_r_max: ReM_mid_r_max = disk.ReM_mid_r_max

    # T_mid_r_lim = [ 0.9 * T_mid_r_min, 1.1 * T_mid_r_max ]
    T_mid_r_lim = [ 0.0, 1.1 * T_mid_r_max ]
    n_mid_r_lim = [ 10.0**(np.log10(n_mid_r_min) - 1), \
                    10.0**(np.log10(n_mid_r_max) + 1) ]
    xe_mid_r_lim = [ 10.0**(np.log10(xe_mid_r_min) - 1), \
                     10.0**(np.log10(xe_mid_r_max) + 1) ]
    ReM_mid_r_lim = [ 10.0**(np.log10(ReM_mid_r_min) - 1), \
                      10.0**(np.log10(ReM_mid_r_max) + 1) ]

# Make Plots
for iout in iouts:
    print "Rendering Figure %i/%i." % (iout, iouts[-1])
    disk = DiskXYZ.Disk(iout)
    disk.load_npz()

    fig = plt.figure(figsize=(16.0, 12.0))
    ax1 = fig.add_subplot(2,2,1)
    ax2 = fig.add_subplot(2,2,2)
    ax3 = fig.add_subplot(2,2,3)
    ax4 = fig.add_subplot(2,2,4)
    disk.plot_T_mid_r(ax1, ylim=T_mid_r_lim)
    disk.plot_n_mid_r(ax2, ylim=n_mid_r_lim)
    disk.plot_xe_mid_r(ax3, ylim=xe_mid_r_lim)
    disk.plot_ReM_mid_r(ax4, ylim=ReM_mid_r_lim)
    
    plt.suptitle("t=%0.2f [code] / t=%0.2f [yr] / %05d [iout] / M_infall=%1.2e [Mstar/yr]" % \
        (disk.info["time"], disk.info["time"]/2./pi, iout, disk.infall_rate))
    fig.savefig('Quad_Mag_R_%05d.png' % iout)

    del disk