def plot_oscillatory_infall_model(axes, inset): """ Plots the models in which the infall rate oscillates with time Parameters ========== axes :: list The 1-D list of matplotlib axis objects to plot on inset :: subplot The matplotlib axis to plot the tracks inset on """ visuals.plot_output_3axes(axes, "../../simulations/SFRoscil_amp0p3_per4", "crimson", "O") visuals.plot_output_3axes(axes, "../../simulations/SFRoscil_amp0p6_per2", "deepskyblue", "O") visuals.plot_output_3axes(axes, "../../simulations/SFRoscil_amp0p3_per2", "black", "O") visuals.plot_track_points_intervals( axes[1], vice.history("../../simulations/SFRoscil_amp0p3_per2")) # visuals.plot_output_3axes(axes, "../../simulations/slow", "lime", "O") visuals.plot_inset(inset, "../../simulations/SFRoscil_amp0p3_per4", "crimson") visuals.plot_inset(inset, "../../simulations/SFRoscil_amp0p6_per2", "deepskyblue") visuals.plot_inset(inset, "../../simulations/SFRoscil_amp0p3_per2", "black") visuals.plot_inset(inset, "../../simulations/default", "black", linestyle=":") visuals.plot_track_points_intervals( inset, vice.history("../../simulations/SFRoscil_amp0p3_per2")) # visuals.plot_inset(inset, "../../simulations/slow", "lime") visuals.plot_reference(axes) visuals.sfr_ifr_legend(axes[0], ncol=2)
def main(): """ Produces the figure and saves it as a PDF. """ plt.clf() axes = setup_axes() plot_track(axes[0], "../../simulations/default", "black") plot_track(axes[0], "../../simulations/yccsr_linear", "crimson") plot_track(axes[0], "../../simulations/yccsr_1-exp", "deepskyblue") plot_track(axes[1], "../../simulations/sudden_5Gyr_5e9Msun", "black") plot_track(axes[1], "../../simulations/yccsr_linear_sudden_5Gyr_5e9Msun", "crimson") plot_track(axes[1], "../../simulations/yccsr_1-exp_sudden_5Gyr_5e9Msun", "deepskyblue") plot_track(axes[2], "../../simulations/SFEdriven_5Gyr", "black") plot_track(axes[2], "../../simulations/yccsr_linear_SFEdriven_5Gyr", "crimson") plot_track(axes[2], "../../simulations/yccsr_1-exp_SFEdriven_5Gyr", "deepskyblue") visuals.plot_track_points_intervals(axes[0], vice.history("../../simulations/default"), element = "Sr", reference = "O") visuals.plot_track_points_intervals(axes[1], vice.history("../../simulations/sudden_5Gyr_5e9Msun"), element = "Sr", reference = "O") visuals.plot_track_points_intervals(axes[2], vice.history("../../simulations/SFEdriven_5Gyr"), element = "Sr", reference = "O") legend(axes[0]) label(axes[1], "Gas-Driven") label(axes[2], "Efficiency-Driven") plt.savefig(sys.argv[1]) plt.clf()
def main(): """ Produces the figure and saves it as a PDF. """ plt.clf() axes = setup_axes() visuals.plot_output_4axes(axes, "../../simulations/sudden_5Gyr_5e9Msun_schmidt", "crimson", "O") visuals.plot_output_4axes( axes, "../../simulations/sudden_5Gyr_5e9Msun_ts1p0_schmidt", "deepskyblue", "O") visuals.plot_output_4axes(axes, "../../simulations/sudden_5Gyr_5e9Msun", "black", "O", second_linestyle=':') visuals.plot_track_points_intervals( axes[2], vice.history("../../simulations/sudden_5Gyr_5e9Msun")) visuals.sfr_ifr_legend(axes[0]) visuals.legend(axes[2], ["black", "crimson", "deepskyblue"], [ r"$\tau_*\propto M_\text{g}^0$ \qquad$\tau_\text{s}$ = 0", r"$\tau_*\propto M_\text{g}^{-1/2}$\quad$\tau_\text{s}$ = 0", r"$\tau_*\propto M_\text{g}^{-1/2}$\quad$\tau_\text{s}$ = 1 Gyr" ]) plot_ifr(axes[0], "../../simulations/sudden_5Gyr_5e9Msun_schmidt", "crimson") plot_ifr(axes[0], "../../simulations/sudden_5Gyr_5e9Msun_ts1p0_schmidt", "deepskyblue") plot_ifr(axes[0], "../../simulations/sudden_5Gyr_5e9Msun", "black") plt.tight_layout() visuals.yticklabel_formatter(axes[3]) plt.savefig(sys.argv[1]) plt.clf()
def plot_history(axes, name, color, linestyle = '-'): """ Plots the relevant information for a given history on the 2x2 axis grid Parameters ========== axes :: list The 2x2 list of matplotlib axis objects to plot on name :: str The name of the model to plot color :: str The name of the color to use in plotting the model """ hist = vice.history(name) # axes[0][0].plot(hist["time"], hist["ifr"], linestyle = '--', # c = visuals.colors()[color]) axes[0][0].plot(hist["time"], hist["sfr"], c = visuals.colors()[color], linestyle = linestyle) if linestyle == '-': axes[0][1].plot(hist["[Fe/H]"], hist["[O/Fe]"], c = visuals.colors()[color], linestyle = linestyle) axes[1][0].plot(hist["time"], hist["[O/H]"], linestyle = '--', c = visuals.colors()[color]) axes[1][0].plot(hist["time"], hist["[Fe/H]"], linestyle = '-', c = visuals.colors()[color]) else: axes[1][0].plot(hist["time"], hist["[O/H]"], linestyle = linestyle, c = visuals.colors()[color]) axes[1][0].plot(hist["time"], hist["[Fe/H]"], linestyle = linestyle, c = visuals.colors()[color]) axes[1][1].plot(hist["time"], hist["[O/Fe]"], c = visuals.colors()[color], linestyle = linestyle)
def plot_oscillatory_eff_model(axes, inset): """ Plots the models in which the SFE timescale oscillates with time Parameters ========== axes :: list The 1-D list of matplotlib axis objects to plot on inset :: subplot The matplotlib axis to plot the tracks inset on """ visuals.plot_output_4axes(axes, "../../simulations/SFEoscil_amp0p2_per4", "crimson", "O") visuals.plot_output_4axes(axes, "../../simulations/SFEoscil_amp0p4_per2", "deepskyblue", "O") visuals.plot_output_4axes(axes, "../../simulations/SFEoscil_amp0p2_per2", "black", "O") visuals.plot_track_points_intervals( axes[2], vice.history("../../simulations/SFEoscil_amp0p2_per2")) # visuals.plot_output_4axes(axes, # "../../simulations/slow", "lime", "O") visuals.plot_inset(inset, "../../simulations/SFEoscil_amp0p2_per4", "crimson") visuals.plot_inset(inset, "../../simulations/SFEoscil_amp0p4_per2", "deepskyblue") visuals.plot_inset(inset, "../../simulations/SFEoscil_amp0p2_per2", "black") visuals.plot_inset(inset, "../../simulations/default", "black", linestyle=':') visuals.plot_track_points_intervals( inset, vice.history("../../simulations/SFEoscil_amp0p2_per2")) # visuals.plot_inset(inset, # "../../simulations/slow", "lime") visuals.plot_reference(axes)
def plot_eff_driven_models(axes): """ Plots the efficiency-driven starburst models in the bottom row of panels. Parameters ========== axes :: list The 1-D list of matplotlib axes """ visuals.plot_output_4axes(axes, "../../simulations/SFEdriven_2Gyr", "crimson", "Sr") visuals.plot_output_4axes(axes, "../../simulations/SFEdriven_5Gyr", "deepskyblue", "Sr") visuals.plot_output_4axes(axes, "../../simulations/default", "black", "Sr", second_linestyle = ':') visuals.plot_track_points_intervals(axes[2], vice.history("../../simulations/default"), element = "Sr")
def plot_gas_driven_models(axes): """ Plots the gas-driven starburst models in the top row of panels. Parameters ========== axes :: list The 1-D list of matplotlib axes """ visuals.plot_output_3axes(axes, "../../simulations/sudden_2Gyr_5e9Msun", "crimson", "Sr") visuals.plot_output_3axes(axes, "../../simulations/sudden_5Gyr_5e9Msun", "deepskyblue", "Sr") visuals.plot_output_3axes(axes, "../../simulations/default", "black", "Sr", second_linestyle = ':') visuals.plot_track_points_intervals(axes[1], vice.history("../../simulations/default"), element = "Sr")
def plot_gas_driven_prolonged_models(axes): """ Plots the 5-Gyr gas driven models with varying accretion timescales. Parameters ========== axes :: list The 1-D list of matplotlib axes to plot on """ visuals.plot_output_3axes(axes, "../../simulations/prolonged_5Gyr_5e9Msun_0p5Gyr", "crimson", "O") visuals.plot_output_3axes(axes, "../../simulations/prolonged_5Gyr_5e9Msun_1p0Gyr", "deepskyblue", "O") visuals.plot_output_3axes(axes, "../../simulations/sudden_5Gyr_5e9Msun", "black", "O", second_linestyle = ':') visuals.plot_track_points_intervals(axes[1], vice.history("../../simulations/sudden_5Gyr_5e9Msun"))
def plot_eff_driven_models(axes): """ Plots the efficiency-driven starburst models on a set of axes Parameters ========== axes :: list The 1-D list of matplotlib axis objects to plot on """ visuals.plot_output_4axes(axes, "../../simulations/SFEdriven_5Gyr_ts0p5", "crimson", "O") visuals.plot_output_4axes(axes, "../../simulations/SFEdriven_5Gyr_ts1p0", "deepskyblue", "O") visuals.plot_output_4axes(axes, "../../simulations/SFEdriven_5Gyr", "black", "O", second_linestyle=':') visuals.plot_track_points_intervals( axes[2], vice.history("../../simulations/SFEdriven_5Gyr"))
def main(): """ Produces the figure and saves it as a PDF. """ plt.clf() axes = setup_axes() plot_output(axes, "../../simulations/default", "black") plot_output(axes, "../../simulations/yccsr_zero", "crimson") plot_output(axes, "../../simulations/yccsr_linear", "lime") plot_output(axes, "../../simulations/yccsr_1-exp", "deepskyblue") visuals.plot_track_points_intervals( axes[0], vice.history("../../simulations/default"), element="Sr", reference="Fe") plot_legend(axes[1]) plt.tight_layout() visuals.yticklabel_formatter(axes[1]) plt.savefig(sys.argv[1]) plt.clf()
def main(): """ Runs the tests on the singlezone object, the output object, and the mirror function. """ warnings.filterwarnings("ignore") print("=================================================================") print("TESTING: vice.singlezone") print(" vice.output") print(" vice.mirror") out = open("test_sz_output_mirror.out", 'w') _MODES_ = ["ifr", "sfr", "gas"] _IMF_ = ["kroupa", "salpeter"] _ETA_ = [2.5, lambda t: 2.5 * math.exp(-t / 4.0)] _ZIN_ = [ 0, 1.0e-8, lambda t: 1.0e-8 * (t / 10.0), { "o": lambda t: 0.0057 * (t / 10.0), "fe": 0.0013 } ] _RECYCLING_ = ["continuous", 0.4] _RIA_ = ["plaw", "exp", lambda t: t**-1.5] _TAU_STAR_ = [2.0, lambda t: 2.0 + t / 10.0] _SCHMIDT_ = [False, True] _AGB_MODEL_ = ["cristallo11", "karakas10"] a = 0 b = 2304 keys = ["success", "failure"] singlezone_tracker = dict(zip(keys, [0, 0])) mirror_tracker = dict(zip(keys, [0, 0])) output_tracker = dict(zip(keys, [0, 0])) history_tracker = dict(zip(keys, [0, 0])) mdf_tracker = dict(zip(keys, [0, 0])) for i in _MODES_: for j in _IMF_: for k in _ETA_: for l in _ZIN_: for m in _RECYCLING_: for n in _RIA_: for o in _TAU_STAR_: for p in _SCHMIDT_: for q in _AGB_MODEL_: metadata = dict( elements=["fe", "o", "c"], mode=i, IMF=j, eta=k, Zin=l, recycling=m, RIa=n, tau_star=o, schmidt=p, agb_model=q, dt=0.05) try: vice.singlezone(**metadata).run( _OUTTIMES_, overwrite=True) singlezone_tracker["success"] += 1 except: singlezone_tracker["failure"] += 1 try: foo = vice.history("onezonemodel") assert isinstance( foo, vice.dataframe) history_tracker["success"] += 1 except: history_tracker["failure"] += 1 try: foo = vice.mdf("onezonemodel") assert isinstance( foo, vice.dataframe) mdf_tracker["success"] += 1 except: mdf_tracker["failure"] += 1 success = True try: foo = vice.output("onezonemodel") assert isinstance(foo, vice.output) assert isinstance( foo.history, vice.dataframe) assert isinstance( foo.mdf, vice.dataframe) assert isinstance( foo.ccsne_yields, vice.dataframe) assert isinstance( foo.sneia_yields, vice.dataframe) assert isinstance( foo.elements, tuple) output_tracker["success"] += 1 try: mir = vice.mirror(foo) assert isinstance( mir, vice.singlezone) mirror_tracker["success"] += 1 except: mirror_tracker["failure"] += 1 except: output_tracker["failure"] += 1 a += 1 sys.stdout.write("Progress: %.1f%%\r" % (a / b * 100)) sys.stdout.flush() ####### message = """\ vice.singlezone :: %d successes :: %d failures vice.history :: %d successes :: %d failures vice.mdf :: %d successes :: %d failures vice.output :: %d successes :: %d failures vice.mirror :: %d successes :: %d failures \ """ % (singlezone_tracker["success"], singlezone_tracker["failure"], history_tracker["success"], history_tracker["failure"], mdf_tracker["success"], mdf_tracker["failure"], output_tracker["success"], output_tracker["failure"], mirror_tracker["success"], mirror_tracker["failure"]) print(message) out.write(message) out.close()
def draw(axes, name, color): hist = vice.history(name) axes[0].plot(hist["time"], map(lambda x, y: 1.e-9 * x / y, hist["mgas"], hist["sfr"]), c=colors()[color]) axes[1].plot(hist["[Fe/H]"], hist["[O/Fe]"], c=colors()[color])