def measure_peak_offset(args): # Unpack i, frame = args intensity_polar = util.read_data(frame, 'polar_intensity', fargo_par, id_number=id_number) # Shift and get peak shift_c = az.shift_away_from_minimum(intensity_polar, fargo_par) intensity_polar = np.roll(intensity_polar, shift_c, axis=-1) peak_r_i, peak_phi_i = az.get_peak(intensity_polar, fargo_par) # Return peak relative to the center, where the edges are set by a threshold intensity_polar /= np.max(intensity_polar) # normalize intensity_polar_at_peak = intensity_polar[ peak_r_i, :] # take azimuthal profile left_index = az.my_searchsorted(intensity_polar_at_peak, threshold) right_index = len(intensity_polar_at_peak) - az.my_searchsorted( intensity_polar_at_peak[::-1], threshold) - 1 # Convert to theta left_theta = theta[left_index] * (180.0 / np.pi) right_theta = theta[right_index] * (180.0 / np.pi) center_theta = left_theta + (right_theta - left_theta) / 2.0 peak_theta = theta[peak_phi_i] * (180.0 / np.pi) peak_offset = peak_theta - center_theta print i, frame, peak_offset, center_theta, peak_theta # Store in mp_array peak_offsets[i] = peak_offset
def tick_function(masses): # For the secondary x-axis showing the planet mass over time tick_locations = np.zeros(len(masses)) tick_labels = [] for i, mass in enumerate(masses): total_mass_jupiter = total_mass / jupiter_mass # in Jupiter masses times_i = az.my_searchsorted(total_mass_jupiter, mass) print mass, times_i, len(times) tick_locations[i] = times[times_i] if delta_mass < 0.1: tick_labels.append("%.2f" % mass) else: tick_labels.append("%.1f" % mass) return tick_locations, tick_labels
def make_plot(show=False): # Set up figure fig, (ax1, ax2, ax3) = plot.subplots(3, 1, figsize=(6, 12), gridspec_kw={'height_ratios': [4, 6, 5]}) # Iterate for i, directory in enumerate(directories): # Frame Range frame_range = util.get_frame_range(frame_ranges[i]) dt = (frame_range[1] - frame_range[0]) * ( 2.0 * np.pi) # for growth rate calculation start_time = start_times[i] start_time_i = az.my_searchsorted(frame_range, start_time) # Label if args.choice > 0: scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 else: scale_height = 0.06 log_viscosity = 5.0 accretion_rate = accretion_rates[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) if args.choice > 0: if i == 4: master_label = r"$0.3$ $\Sigma_0$" else: master_label = r"$A = %.02f$" % (accretion_rate) else: labels = ["Default", "Restart"] label = labels[i] # Data #gap_depth_over_time = np.zeros(len(frame_range)) #for i, frame in enumerate(frame_range): # get_min((i, frame)) pool_args = [(j, frame, directory) for j, frame in enumerate(frame_range)] p = Pool(num_cores) p.map(get_contrasts, pool_args) p.terminate() num_frames = len(frame_range) this_maxima_over_time = np.array(maxima_over_time[:num_frames]) this_minima_over_time = np.array(minima_over_time[:num_frames]) this_contrasts_over_time = np.array(contrasts_over_time[:num_frames]) this_differences_over_time = np.array( differences_over_time[:num_frames]) this_smoothed_differences_over_time = smooth( this_differences_over_time, 5) this_growth_rates_over_time = np.diff( np.log(this_smoothed_differences_over_time)) / dt ##### Top Plot ##### # Plot x = frame_range y1 = this_contrasts_over_time p1, = ax1.plot(x[start_time_i:], y1[start_time_i:], c=colors[i], linewidth=linewidth, zorder=99 - i) # Axes ax1.set_yscale('log') ax1.yaxis.set_major_formatter(ScalarFormatter()) ax1.yaxis.set_minor_formatter(NullFormatter()) if i == 3: ax1.set_xlim(x[0], x[-1]) if scale_height == 0.08: ax1.set_ylim(1, 15) ax1.set_yticks([1, 3, 10]) else: ax1.set_ylim(1, 7) ax1.set_yticks([1, 3, 7]) # Annotate #ax1.set_xlabel("", fontsize = fontsize) ax1.set_ylabel("Contrast", fontsize=fontsize) alpha_coefficent = "3" if scale_height == 0.08: alpha_coefficent = "1.5" elif scale_height == 0.04: alpha_coefficent = "6" title1 = r"$h = %.2f$ $\alpha = %s \times 10^{%d}$" % ( scale_height, alpha_coefficent, int(round(np.log(viscosity) / np.log(10), 0)) + 2) #title1 = r"$A = %.2f$" % (accretion) ax1.set_title("%s" % (title1), y=1.035, fontsize=fontsize + 2) ##### Middle Plot ##### label1 = "" label2 = "" if i == 0: label1 = r"$\Sigma_\mathrm{max}$" label2 = r"$\Sigma_\mathrm{min}$" y2 = this_maxima_over_time p2, = ax2.plot(x[start_time_i:], y2[start_time_i:], c=colors[i], linewidth=linewidth, label=label1, zorder=99 - i) y3 = this_minima_over_time p3, = ax2.plot(x[start_time_i:], y3[start_time_i:], c=colors[i], linewidth=linewidth - 2, label=label2, zorder=90 - i) # Axes if i == 3: ax2.set_xlim(x[0], x[-1]) if scale_height == 0.08: ax2.set_ylim(0, 2.8) ax2.set_yticks([0, 0.5, 1, 1.5, 2, 2.5]) else: ax2.set_ylim(0, 1.8) ax2.set_yticks([0, 0.5, 1, 1.5]) # Annotate ax2.set_ylabel(r"$\Sigma$ $/$ $\Sigma_0$", fontsize=fontsize) ax2.legend(loc="upper right", fontsize=fontsize - 5) ##### Bottom Plot ##### # Plot y4 = this_growth_rates_over_time p4, = ax3.plot(x[start_time_i:-5], y4[start_time_i:-4], c=colors[i], linewidth=linewidth, alpha=alpha, label=master_label, zorder=90 - i) # Axes if i == 3: ax3.set_xlim(x[0], x[-1]) ax3.set_ylim(0.4 * 10**(-5), 0.4 * 10**(-2)) ax3.set_yscale('log') ax3.set_yticks([10**(-5), 10**(-4), 10**(-3)]) # Annotate ax3.set_xlabel("Time (planet orbits)", fontsize=fontsize) ax3.set_ylabel(r"Growth Rate", fontsize=fontsize) ax3.legend(loc="upper right", fontsize=fontsize - 5) # Save, Show, and Close if version is None: save_fn = "%s/growthRatesOverTime_choice%d.png" % (save_directory, args.choice) else: save_fn = "%s/v%04d_growthRatesOverTime_choice%d.png" % ( save_directory, version, arg.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def make_plot(show=False): # Set up figure fig = plot.figure(figsize=(7, 6), dpi=dpi) ax = fig.add_subplot(111) # Iterate for i, directory in enumerate(directories): # Label scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 disc_mass = disc_masses[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) #label = r"$A = %.02f$" % (accretion_rate) label = disc_mass # Data data = np.loadtxt("../%s/planet0.dat" % directory) times = data[:, 0] base_mass = data[:, 7] accreted_mass = data[:, 8] total_mass = base_mass + accreted_mass if negative: negative_mass = data[:, 13] total_mass -= negative_mass ### Plot ### # Basic x = times y = total_mass / jupiter_mass result = plot.plot(x, y, c=colors[i], linewidth=linewidth - 1, zorder=99, label=label) # Vortex Lifetime if start_time > 0: start_time_i = az.my_searchsorted(x, start_time) if end_time > 0: end_time_i = az.my_searchsorted(x, end_time) else: end_time_i = -1 result = plot.plot(x[start_time_i:end_time_i], y[start_time_i:end_time_i], c=colors[i], linewidth=linewidth + 3, zorder=99) plot.scatter(x[start_time_i], y[start_time_i], c=colors[i], s=150, marker="o", zorder=120) if end_time > 0: plot.scatter(x[end_time_i], y[end_time_i], c=colors[i], s=175, marker="H", zorder=120) plot.legend(loc="upper right", fontsize=fontsize - 4) # Axes if args.max_y is None: x_min_i = np.searchsorted(x, x_min) x_max_i = np.searchsorted(x, x_max) max_y = 1.1 * max(y[x_min_i:x_max_i]) else: max_y = args.max_y plot.xlim(x_min, x_max) plot.ylim(0, max_y) #title = readTitle() unit = "orbits" plot.xlabel(r"Time [%s]" % unit, fontsize=fontsize) plot.ylabel(r"$M_p$ [$M_J$]", fontsize=fontsize) #if title is None: # plot.title("Dust Density Map\n(t = %.1f)" % (orbit), fontsize = fontsize + 1) #else: # plot.title("Dust Density Map\n%s\n(t = %.1f)" % (title, orbit), fontsize = fontsize + 1) x_range = x_max - x_min x_mid = x_min + x_range / 2.0 y_text = 1.14 #title1 = r"$\Sigma_0 = %.3e$ $M_c = %.2f\ M_J$ $A = %.2f$" % (surface_density_zero, planet_mass, accretion) #title1 = r"$T_\mathrm{growth} = %d$ $\mathrm{orbits}$" % (taper_time) #title2 = r"$t = %d$ $\mathrm{orbits}}$ [$m_\mathrm{p}(t)\ =\ %.2f$ $M_\mathrm{Jup}$]" % (orbit, current_mass) title = r"$h = %.02f$ $\alpha_\mathrm{disk} = 3 \times 10^{-%d}$" % ( scale_height, log_viscosity) plot.title("%s" % (title), y=1.015, fontsize=fontsize + 2) #plot.text(x_mid, y_text * plot.ylim()[-1], title1, horizontalalignment = 'center', bbox = dict(facecolor = 'none', edgecolor = 'black', linewidth = 1.5, pad = 7.0), fontsize = fontsize + 2) # Text text_mass = r"$M_\mathrm{p} = %d$ $M_\mathrm{Jup}$" % (int(planet_mass)) text_visc = r"$\alpha_\mathrm{disk} = 3 \times 10^{%d}$" % ( int(np.log(viscosity) / np.log(10)) + 2) #plot.text(-0.9 * box_size, 2, text_mass, fontsize = fontsize, color = 'black', horizontalalignment = 'left', bbox=dict(facecolor = 'white', edgecolor = 'black', pad = 10.0)) #plot.text(0.9 * box_size, 2, text_visc, fontsize = fontsize, color = 'black', horizontalalignment = 'right', bbox=dict(facecolor = 'white', edgecolor = 'black', pad = 10.0)) #plot.text(-0.84 * x_range / 2.0 + x_mid, y_text * plot.ylim()[-1], text_mass, fontsize = fontsize, color = 'black', horizontalalignment = 'right') #plot.text(0.84 * x_range / 2.0 + x_mid, y_text * plot.ylim()[-1], text_visc, fontsize = fontsize, color = 'black', horizontalalignment = 'left') # Save, Show, and Close if version is None: save_fn = "%s/severalMassOverTime_choice%d.png" % (save_directory, args.choice) else: save_fn = "%s/v%04d_severalMassOverTime_choice%d.png" % ( save_directory, version, arg.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def make_plot(show=False): # Set up figure if args.choice > 0: fig = plot.figure(figsize=(7, 6), dpi=dpi) else: fig = plot.figure(figsize=(7, 2), dpi=dpi) ax = fig.add_subplot(111) # Iterate #max_gap_depth = 0 for i, directory in enumerate(directories): # Frame Range frame_range = util.get_frame_range(frame_ranges[i]) # Label if args.choice > 0: scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 else: scale_height = 0.06 log_viscosity = 5.0 accretion_rate = accretion_rates[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) if args.choice > 0: label = r"$A = %.02f$" % (accretion_rate) else: labels = ["Default", "Restart"] label = labels[i] # Data #gap_depth_over_time = np.zeros(len(frame_range)) #for i, frame in enumerate(frame_range): # get_min((i, frame)) pool_args = [(j, frame, directory) for j, frame in enumerate(frame_range)] p = Pool(num_cores) p.map(get_rossby_criteria, pool_args) p.terminate() #if np.max(gap_depth_over_time) > max_gap_depth: # max_gap_depth = np.max(gap_depth_over_time) num_frames = len(frame_range) this_inner_peak_difference_over_time = np.array( inner_peak_difference_over_time[:num_frames]) #if i == 4: # this_gap_depth_over_time = this_gap_depth_over_time * (0.3) # low-mass case ### Plot ### # Basic x = frame_range y = this_inner_peak_difference_over_time result = plot.plot(x, y, c=colors[i], linewidth=linewidth + 1, zorder=99, label=label, alpha=0.65) # Vortex Lifetime if start_time > 1e6: # Set to > 0 to use this start_time_i = az.my_searchsorted(x, start_time) end_time_i = az.my_searchsorted(x, end_time) result = plot.plot(x[start_time_i:end_time_i], y[start_time_i:end_time_i], c=colors[i], linewidth=linewidth + 3, zorder=99) plot.scatter(x[start_time_i], y[start_time_i], c=colors[i], s=150, marker="o", zorder=120) if args.choice > 0: plot.scatter(x[end_time_i], y[end_time_i], c=colors[i], s=175, marker="H", zorder=120) # Reference Line plot.plot([0, frame_ranges[3][1]], [-0.15, -0.15], c='k', linewidth=1) # Ro = -0.15 is critical value if args.choice > 0: plot.legend(loc="lower right", fontsize=fontsize - 4) else: plot.legend(loc="upper left", fontsize=fontsize - 4) # Axes if args.choice > 0: x_max = frame_ranges[3][1] plot.xlim(0, x_max) else: x_max = frame_ranges[0][1] plot.xlim(0, x_max) plot.ylim(0, 0.3) unit = "planet orbits" plot.xlabel(r"Time [%s]" % unit, fontsize=fontsize) plot.ylabel("Radii", fontsize=fontsize) x_range = x_max - x_min x_mid = x_min + x_range / 2.0 y_text = 1.14 alpha_coefficent = "3" if scale_height == 0.08: alpha_coefficent = "1.5" elif scale_height == 0.04: alpha_coefficent = "6" title = r"$h = %.02f$ $\alpha \approx %s \times 10^{%d}$" % ( scale_height, alpha_coefficent, int(np.log(viscosity) / np.log(10)) + 2) #title = r"$h = %.02f$ $\alpha_\mathrm{disk} = 3 \times 10^{-%d}$" % (scale_height, log_viscosity) if args.choice > 0: plot.title("%s" % (title), y=1.015, fontsize=fontsize + 2) #top_text = "Incompressible"; top_y = -0.02 #bottom_text = "Compressible"; bottom_y = -0.38 #plot.text(0.9 * x_max, top_y, top_text, horizontalalignment = 'right', verticalalignment = 'top', fontsize = fontsize - 3) #plot.text(0.1 * x_max, bottom_y, bottom_text, horizontalalignment = 'left', verticalalignment = 'bottom', fontsize = fontsize - 3) #title = readTitle() # Save, Show, and Close if version is None: save_fn = "%s/rossbyWaves_choice%d.png" % (save_directory, args.choice) else: save_fn = "%s/v%04d_rossbyWaves_choice%d.png" % (save_directory, version, args.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def make_plot(show=False): # Set up figure fig = plot.figure(figsize=(7, 12), dpi=dpi) plot.subplots_adjust(hspace=0.12) ######### TOP PANEL ######### ax = fig.add_subplot(211) # Iterate for i, directory in enumerate(directories): # Label scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 disc_mass = disc_masses[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) #label = r"$A = %.02f$" % (accretion_rate) label = disc_mass legend_text = r"$\Sigma_\mathrm{0}$ $/$ $\Sigma_\mathrm{base}$" # Data data = np.loadtxt("../%s/planet0.dat" % directory) times = data[:, 0] base_mass = data[:, 7] accreted_mass = data[:, 8] total_mass = base_mass + accreted_mass if negative: negative_mass = data[:, 13] total_mass -= negative_mass ### Plot ### # Basic x = times y = total_mass / jupiter_mass result = plot.plot(x, y, c=colors[i % len(colors)], linewidth=linewidth - 1, zorder=99, label=label) # Vortex Lifetime if start_time > 0: start_time_i = az.my_searchsorted(x, start_time) if end_time > 0: end_time_i = az.my_searchsorted(x, end_time) else: end_time_i = -1 result = plot.plot(x[start_time_i:end_time_i], y[start_time_i:end_time_i], c=colors[i % len(colors)], linewidth=linewidth + 3, zorder=99) plot.scatter(x[start_time_i], y[start_time_i], c=colors[i % len(colors)], s=150, marker="o", zorder=120) if end_time > 0: plot.scatter(x[end_time_i], y[end_time_i], c=colors[i % len(colors)], s=175, marker="H", zorder=120) legend = plot.legend(loc="upper right", fontsize=fontsize - 4, title=legend_text, facecolor='white', framealpha=0.9) legend.set_zorder(150) ax.get_legend().get_title().set_fontsize(fontsize - 4) # Axes if args.max_y is None: x_min_i = np.searchsorted(x, x_min) x_max_i = np.searchsorted(x, x_max) max_y = 1.1 * max(y[x_min_i:x_max_i]) else: max_y = args.max_y plot.xlim(x_min, x_max) plot.ylim(0, max_y) #title = readTitle() unit = "planet orbits" #plot.xlabel(r"Time [%s]" % unit, fontsize = fontsize) plot.ylabel(r"$M_\mathrm{p}$ [$M_\mathrm{Jup}$]", fontsize=fontsize) x_range = x_max - x_min x_mid = x_min + x_range / 2.0 y_text = 1.14 alpha_coefficent = "3" if scale_height == 0.08: alpha_coefficent = "1.5" elif scale_height == 0.04: alpha_coefficent = "6" title = r"$h = %.02f$ $\alpha \approx %s \times 10^{%d}$" % ( scale_height, alpha_coefficent, int(np.log(viscosity) / np.log(10)) + 2) #title = r"$h = %.02f$ $\alpha_\mathrm{disk} = 3 \times 10^{-%d}$" % (scale_height, log_viscosity) plot.title("%s" % (title), y=1.015, fontsize=fontsize + 2) #plot.text(x_mid, y_text * plot.ylim()[-1], title1, horizontalalignment = 'center', bbox = dict(facecolor = 'none', edgecolor = 'black', linewidth = 1.5, pad = 7.0), fontsize = fontsize + 2) ######### BOTTOM PANEL ######### ax = fig.add_subplot(212) # Iterate for i, directory in enumerate(directories): # Label scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 disc_mass = disc_masses[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) #label = r"$A = %.02f$" % (accretion_rate) label = disc_mass legend_text = r"$\Sigma_\mathrm{0}$ $/$ $\Sigma_\mathrm{base}$" # Data data = np.loadtxt("../%s/planet0.dat" % directory) times = data[:, 0] base_mass = data[:, 7] accreted_mass = data[:, 8] total_mass = base_mass + accreted_mass if negative: negative_mass = data[:, 13] total_mass -= negative_mass accretion = total_mass[1:] - total_mass[:-1] # Filter out repeats times = (times[1:])[accretion > 0] accretion = accretion[accretion > 0] ### Plot ### # Basic x = times[9:] y = accretion[9:] / jupiter_mass result = plot.plot(x, y, c=colors[i % len(colors)], linewidth=linewidth - 2, zorder=99, label=label) # Vortex Lifetime if start_time > 0: start_time_i = az.my_searchsorted(x, start_time) if end_time > 0: end_time_i = az.my_searchsorted(x, end_time) else: end_time_i = -1 result = plot.plot(x[start_time_i:end_time_i], y[start_time_i:end_time_i], c=colors[i % len(colors)], linewidth=linewidth + 1, zorder=99) plot.scatter(x[start_time_i], y[start_time_i], c=colors[i % len(colors)], s=150, marker="o", zorder=120) if end_time > 0: plot.scatter(x[end_time_i], y[end_time_i], c=colors[i % len(colors)], s=175, marker="H", zorder=120) #plot.legend(loc = "upper right", fontsize = fontsize - 4) # Axes plot.xlim(x_min, x_max) plot.ylim(10**(-6), 10**(-2)) plot.yscale("log") #title = readTitle() unit = "planet orbits" plot.xlabel(r"Time [%s]" % unit, fontsize=fontsize) plot.ylabel(r"$\dot{M}_\mathrm{p}$ [$M_\mathrm{Jup}$ $/$ $T_\mathrm{p}$]", fontsize=fontsize) # Save, Show, and Close if version is None: save_fn = "%s/severalMassAndAccretionRates_choice%d.png" % ( save_directory, args.choice) else: save_fn = "%s/v%04d_severalMassAndAccretionRates_choice%d.png" % ( save_directory, version, arg.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def make_plot(show=False): # Set up figure if args.choice > 0: fig = plot.figure(figsize=(7, 6), dpi=dpi) else: fig = plot.figure(figsize=(7, 2), dpi=dpi) ax = fig.add_subplot(111) # Iterate max_gap_depth = 0 for i, directory in enumerate(directories): # Frame Range frame_range = util.get_frame_range(frame_ranges[i]) # Label if args.choice > 0: scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 else: scale_height = 0.06 log_viscosity = 5.0 accretion_rate = accretion_rates[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) if args.choice > 0: label = r"$A = %.02f$" % (accretion_rate) else: labels = ["Default", "Restart"] label = labels[i] # Data #gap_depth_over_time = np.zeros(len(frame_range)) #for i, frame in enumerate(frame_range): # get_min((i, frame)) pool_args = [(j, frame, directory) for j, frame in enumerate(frame_range)] p = Pool(num_cores) p.map(get_min, pool_args) p.terminate() if np.max(gap_depth_over_time) > max_gap_depth: max_gap_depth = np.max(gap_depth_over_time) num_frames = len(frame_range) this_gap_depth_over_time = np.array(gap_depth_over_time[:num_frames]) if i >= 4: this_gap_depth_over_time = this_gap_depth_over_time * ( 0.3) # low-mass case ### Plot ### # Basic x = frame_range y = this_gap_depth_over_time result = plot.plot(x, y, c=colors[i], linewidth=linewidth - 1, zorder=99, label=label) # Vortex Lifetime if start_time > 0: start_time_i = az.my_searchsorted(x, start_time) end_time_i = az.my_searchsorted(x, end_time) result = plot.plot(x[start_time_i:end_time_i], y[start_time_i:end_time_i], c=colors[i], linewidth=linewidth + 3, zorder=99) plot.scatter(x[start_time_i], y[start_time_i], c=colors[i], s=150, marker="o", zorder=120) if args.choice > 0: plot.scatter(x[end_time_i], y[end_time_i], c=colors[i], s=175, marker="H", zorder=120) if args.choice > 0: plot.legend(loc="upper right", fontsize=fontsize - 4) else: plot.legend(loc="upper left", fontsize=fontsize - 4) # Axes if args.choice > 0: plot.xlim(0, frame_range[-1]) else: plot.xlim(0, frame_ranges[0][1]) if args.choice > 0: plot.ylim(1, 3.0 * 10**(1)) plot.yscale('log') else: plot.ylim(1, 5) plot.yscale('log') ax.set_major_formatter(ScalarFormatter()) plot.yticks([1, 3, 5], ["1", "3", "5"]) #title = readTitle() unit = "planet orbits" plot.xlabel(r"Time [%s]" % unit, fontsize=fontsize) if args.choice > 0: plot.ylabel( r" Gap Depth ($\delta_\mathrm{gap}$ $\equiv$ $\Sigma_{0}$ $/$ $\Sigma_\mathrm{min}$)", fontsize=fontsize) else: plot.ylabel(r"Gap Depth", fontsize=fontsize) x_range = x_max - x_min x_mid = x_min + x_range / 2.0 y_text = 1.14 alpha_coefficent = "3" if scale_height == 0.08: alpha_coefficent = "1.5" elif scale_height == 0.04: alpha_coefficent = "6" title = r"$h = %.02f$ $\alpha \approx %s \times 10^{%d}$" % ( scale_height, alpha_coefficent, int(np.log(viscosity) / np.log(10)) + 2) #title = r"$h = %.02f$ $\alpha_\mathrm{disk} = 3 \times 10^{-%d}$" % (scale_height, log_viscosity) if args.choice > 0: plot.title("%s" % (title), y=1.015, fontsize=fontsize + 2) #plot.text(x_mid, y_text * plot.ylim()[-1], title1, horizontalalignment = 'center', bbox = dict(facecolor = 'none', edgecolor = 'black', linewidth = 1.5, pad = 7.0), fontsize = fontsize + 2) #title = readTitle() # Save, Show, and Close if version is None: save_fn = "%s/rossbyGapDepth_choice%d.png" % (save_directory, args.choice) else: save_fn = "%s/v%04d_rossbyGapDepth_choice%d.png" % ( save_directory, version, arg.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def get_extents(args_here): # Unwrap Args i, frame = args_here if frame in problem_frames: frame += 3 # switch to an adjacent frame # Get Data density = fromfile("gasdens%d.dat" % frame).reshape( num_rad, num_theta) / surface_density_zero avg_density = np.average(density, axis=1) peak_rad, peak_density = az.get_radial_peak(avg_density, fargo_par) normal = True if frame > check_rossby: vrad = (fromfile("gasvy%d.dat" % frame).reshape(num_rad, num_theta) ) # add a read_vrad to util.py! vtheta = (fromfile("gasvx%d.dat" % frame).reshape(num_rad, num_theta) ) # add a read_vrad to util.py! vorticity = utilVorticity.velocity_curl(vrad, vtheta, rad, theta, rossby=True, residual=True) # Find minimum if accretion > 0.015: start_rad = min([peak_rad - 0.05, 1.5]) start_rad_i = np.searchsorted(rad, start_rad) # Is this necessary? end_rad_i = np.searchsorted(rad, 2.5) else: start_rad_i = np.searchsorted(rad, 1.0) # Is this necessary? end_rad_i = np.searchsorted(rad, 1.8) zoom_vorticity = vorticity[start_rad_i:end_rad_i] min_rossby_number = np.percentile(zoom_vorticity, 0.25) if min_rossby_number < -0.15: normal = False # Compressible regime from Surville+ 15 if normal: azimuthal_extent = az.get_extent( density, fargo_par, threshold=args.threshold ) # Use 0.9 for h = 0.08 (Add as a parameter) radial_extent, radial_peak = az.get_radial_extent( density, fargo_par, threshold=args.threshold) radial_peak_a, _ = az.get_radial_peak(avg_density, fargo_par) azimuthal_extent_over_time[i] = azimuthal_extent * (180.0 / np.pi) radial_extent_over_time[i] = radial_extent / scale_height radial_peak_over_time[i] = radial_peak_a # radial_peak #radial_peak_over_time_a[i] = radial_peak_a else: # Shift everything density, vorticity, shift_c = shift_density(density, vorticity, fargo_par, reference_density=density) # Locate minimum if accretion > 0.015: start_rad = min([peak_rad - 0.05, 1.5]) start_rad_i = np.searchsorted(rad, start_rad) # Is this necessary? end_rad_i = np.searchsorted(rad, 2.5) else: start_rad_i = np.searchsorted(rad, 1.0) # Is this necessary? end_rad_i = np.searchsorted(rad, 1.8) zoom_vorticity = vorticity[start_rad_i:end_rad_i] min_rossby_number = np.percentile(zoom_vorticity, 0.25) abs_zoom_vorticity = np.abs(zoom_vorticity - min_rossby_number) minimum_location = np.argmin(abs_zoom_vorticity) rad_min_i, theta_min_i = np.unravel_index(minimum_location, np.shape(zoom_vorticity)) # Locate radial and azimuthal center left_side = zoom_vorticity[rad_min_i, :theta_min_i] right_side = zoom_vorticity[rad_min_i, theta_min_i:] front_side = zoom_vorticity[:rad_min_i, theta_min_i] back_side = zoom_vorticity[rad_min_i:, theta_min_i] if frame < extreme_cutoff: cutoff = -0.04 else: cutoff = -0.12 # Extreme! (neglects "vortex" that develops around the minimum) left_i = theta_min_i - az.my_searchsorted( left_side[::-1], cutoff) # at location of minimum right_i = theta_min_i + az.my_searchsorted(right_side, cutoff) front_i = rad_min_i - az.my_searchsorted(front_side[::-1], cutoff) back_i = rad_min_i + az.my_searchsorted(back_side, cutoff) radial_center_i = start_rad_i + int((front_i + back_i) / 2.0) azimuthal_center_i = int((left_i + right_i) / 2.0) radial_center = (rad[start_rad_i + front_i] + rad[start_rad_i + back_i]) / 2.0 azimuthal_center = ( (theta[left_i] + theta[right_i]) / 2.0) * (180.0 / np.pi) print i, frame, rad[start_rad_i + rad_min_i], theta[theta_min_i] * ( 180.0 / np.pi), "Minimum Rossby Number" print i, frame, rad[start_rad_i + front_i], radial_center, rad[ start_rad_i + back_i], "Radial: Left, Center, Right" print i, frame, theta[left_i] * ( 180.0 / np.pi), azimuthal_center, theta[right_i] * ( 180.0 / np.pi), "Azimuthal: Left, Center, Right" # Measure radial and azimuthal extents left_side = vorticity[radial_center_i, :azimuthal_center_i] right_side = vorticity[radial_center_i, azimuthal_center_i:] front_side = vorticity[:radial_center_i, azimuthal_center_i] back_side = vorticity[radial_center_i:, azimuthal_center_i] left_i = azimuthal_center_i - az.my_searchsorted( left_side[::-1], cutoff) # relative to center right_i = azimuthal_center_i + az.my_searchsorted(right_side, cutoff) front_i = radial_center_i - az.my_searchsorted(front_side[::-1], cutoff) back_i = radial_center_i + az.my_searchsorted(back_side, cutoff) radial_peak_over_time[i] = radial_center radial_extent_over_time[i] = (rad[back_i] - rad[front_i]) / scale_height azimuthal_extent_over_time[i] = theta[right_i - left_i] * (180.0 / np.pi) print i, frame, rad[front_i], radial_center, rad[ back_i], "Final Radial: Left, Center, Right" print i, frame, theta[left_i] * ( 180.0 / np.pi), azimuthal_center, theta[right_i] * ( 180.0 / np.pi), "Final Azimuthal: Left, Center, Right" #contrasts_over_time[i] = az.get_contrast(density, fargo_par) print i, frame, azimuthal_extent_over_time[i], radial_extent_over_time[ i], radial_peak_over_time[i]
def make_plot(show=False): fig = plot.figure(figsize=(10, 6), dpi=dpi) gs = gridspec.GridSpec(nrows=1, ncols=2, width_ratios=[5, 2], figure=fig) ax = fig.add_subplot(gs[0]) # Plot x = frame_range y = np.array(peak_offsets) kernel = 5 smooth_y = util.smooth(y, kernel) plot.scatter(x, y, c="mediumspringgreen", s=size, alpha=alpha) #plot.plot(x, y, c = colors[1], linewidth = linewidth) #plot.plot(x, smooth_y, c = colors[1], linewidth = linewidth) plot.plot([last_frame, last_frame], [-120, 120], linestyle="--", c='k') # Axes plot.xlim(x[0], x[-1]) #ax.set_xticklabels([]) angles = np.linspace(-120, 120, 9) plot.yticks(angles) plot.ylim(-120, 120) # Annotate Axes plot.xlabel(r"$t \mathrm{\ (planet\ orbits)}$", fontsize=fontsize + 2) plot.ylabel(r"Peak Offsets $\mathrm{(degrees)}$", fontsize=fontsize + 2) threshold_text = r"$\frac{I_\mathrm{cut}}{I_\mathrm{max}}=%.2f$" % threshold plot.text(0.98 * (x[-1] - x[0]) + x[0], 0.9 * (plot.ylim()[-1] - plot.ylim()[0]) + plot.ylim()[0], threshold_text, horizontalalignment='right', fontsize=fontsize - 4) #plot.legend(loc = "upper right", bbox_to_anchor = (1.28, 1.0)) # outside of plot #plot.legend(loc = "upper left") # outside of plot # Title #title = r"$\mathrm{Azimuthal\ Extents}$" title = r'$h = %.2f$ $\Sigma = %.3e$ (2-D) [$%.3f^{\prime\prime}$]' % ( scale_height, fargo_par["p"].sigma0, arc_beam) plot.title("%s" % (title), y=1.20, fontsize=fontsize + 3, bbox=dict(facecolor='none', edgecolor='black', linewidth=1.5, pad=7.0)) #### Histograms #### ax2 = fig.add_subplot(gs[1]) truncate = az.my_searchsorted(frame_range, last_frame) - 1 y_truncated = y[:truncate] plot.hist(y_truncated, bins=np.linspace(-120 - 10, 120 + 10, 261), cumulative=True, color='darkgreen', align='left', orientation='horizontal', histtype='stepfilled', density=True) ref_lines = np.linspace(0, 30, 4) for i, ref_i in enumerate(ref_lines): if ref_i == 0 or ref_i == ref_lines[-1]: linestyle = "-" ref_linewidth = 2 else: linestyle = "--" ref_linewidth = 1 plot.plot([0, 1], [ref_i, ref_i], c='k', linestyle=linestyle, linewidth=ref_linewidth) plot.plot([0, 1], [-ref_i, -ref_i], c='k', linestyle=linestyle, linewidth=ref_linewidth) ax2.set_xlim(0, 1) hist_ticks = np.linspace(0, 1, 6) hist_ticks_minor = np.linspace(0, 1, 11) ax2.set_xticks(hist_ticks) ax2.set_xticks(hist_ticks_minor, minor=True) ax2.set_ylim(-120, 120) ax2.set_yticks(angles) #ax2.set_yticklabels([]) if last_frame < frame_range[-1]: plot.title(r"ONLY to $t$ = $%d$" % last_frame, fontsize=fontsize - 1) #### Add mass axis #### min_mass = args.min_mass max_mass = args.max_mass delta_mass = args.delta_mass if max_mass is None: max_mass = total_mass[frame_range[-1] - 1] mass_ticks = np.arange(min_mass, max_mass, delta_mass) def tick_function(masses): # For the secondary x-axis showing the planet mass over time tick_locations = np.zeros(len(masses)) tick_labels = [] for i, mass in enumerate(masses): #total_mass_jupiter = total_mass # in Jupiter masses times_i = az.my_searchsorted(total_mass, mass) #tick_times = times[times_i] print mass, times_i, len(times) tick_locations[i] = times[times_i] if delta_mass < 0.1: tick_labels.append("%.2f" % mass) else: tick_labels.append("%.1f" % mass) return tick_locations, tick_labels tick_locations, tick_labels = tick_function(mass_ticks) ax_twin = ax.twiny() ax_twin.set_xlim(ax.get_xlim()) ax_twin.set_xticks(tick_locations) ax_twin.set_xticklabels(tick_labels) ax_twin.set_xlabel(r"$M_\mathrm{p}$ [$M_\mathrm{J}$]", fontsize=fontsize, labelpad=10) if args.minor_delta_mass is not None: minor_mass_ticks = np.arange(0.1, max_mass, args.minor_delta_mass) minor_tick_locations, _ = tick_function(minor_mass_ticks) ax_twin.set_xticks(minor_tick_locations, minor=True) # Save, Show, and Close current_directory = os.getcwd().split("/")[-3] current_beam = os.getcwd().split("/")[-1] if version is None: save_fn = "%s/peakOffsets-%s-%s.png" % ( save_directory, current_directory, current_beam) else: save_fn = "%s/v%04d_peakOffsets-%s-%s.png" % ( save_directory, version, current_directory, current_beam) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi, pad_inches=0.2) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def make_plot(show=False): # Set up figure fig, (ax1, ax2, ax3) = plot.subplots(3, 1, figsize=(6, 12), gridspec_kw={'height_ratios': [1, 1, 1]}) # Iterate for i, directory in enumerate(directories): # Frame Range frame_range = util.get_frame_range(frame_ranges[i]) dt = (frame_range[1] - frame_range[0]) * ( 2.0 * np.pi) # for growth rate calculation start_time = start_times[i] start_time_i = az.my_searchsorted(frame_range, start_time) check_rossby = check_rossby_frames[i] # Label if args.choice > 0: scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 else: scale_height = 0.06 log_viscosity = 5.0 accretion_rate = accretion_rates[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) if args.choice > 0: if i == 4: master_label = r"$0.3$ $\Sigma_0$" else: master_label = r"$A = %.02f$" % (accretion_rate) else: labels = ["Default", "Restart"] label = labels[i] # Data #for j, frame in enumerate(frame_range): # get_extents((j, frame, directory)) pool_args = [(j, frame, directory, check_rossby) for j, frame in enumerate(frame_range)] p = Pool(num_cores) p.map(get_extents, pool_args) p.terminate() num_frames = len(frame_range) this_azimuthal_extent_over_time = np.array( azimuthal_extent_over_time[:num_frames]) this_radial_extent_over_time = np.array( radial_extent_over_time[:num_frames]) this_radial_peak_over_time = np.array( radial_peak_over_time[:num_frames]) #this_smoothed_differences_over_time = smooth(this_differences_over_time, 5) #this_growth_rates_over_time = np.diff(np.log(this_smoothed_differences_over_time)) / dt ##### Top Plot ##### # Plot x = frame_range y1 = this_azimuthal_extent_over_time p1, = ax1.plot(x, y1, c=colors[i], linewidth=linewidth, zorder=99 - i) # Axes if i == 3: ax1.set_xlim(0, x[-1]) angles = np.linspace(0, 360, 7) ax1.set_ylim(0, 360) ax1.set_yticks(angles) # Annotate #ax1.set_xlabel("", fontsize = fontsize) ax1.set_ylabel("Azimuthal Extent (degrees)", fontsize=fontsize) alpha_coefficent = "3" if scale_height == 0.08: alpha_coefficent = "1.5" elif scale_height == 0.04: alpha_coefficent = "6" title1 = r"$h = %.2f$ $\alpha = %s \times 10^{%d}$" % ( scale_height, alpha_coefficent, int(round(np.log(viscosity) / np.log(10), 0)) + 2) #title1 = r"$A = %.2f$" % (accretion) ax1.set_title("%s" % (title1), y=1.035, fontsize=fontsize + 2) ##### Middle Plot ##### y2 = this_radial_extent_over_time p2, = ax2.plot(x, y2, c=colors[i], linewidth=linewidth, zorder=99 - i) # Axes if i == 3: ax2.set_xlim(0, x[-1]) if scale_height == 0.08: ax2.set_ylim(0, 0.75) else: ax2.set_ylim(0, 0.50) # Annotate ax2.set_ylabel(r"Radial Extent (planet radii)", fontsize=fontsize) ##### Bottom Plot ##### # Plot y3 = this_radial_peak_over_time p3, = ax3.plot(x, y3, c=colors[i], linewidth=linewidth, alpha=alpha, zorder=90 - i) # Axes if i == 3: ax3.set_xlim(0, x[-1]) if scale_height == 0.08: ax3.set_ylim(1.0, 2.5) else: ax3.set_ylim(1.0, 1.6) # Annotate ax3.set_xlabel("Time (planet orbits)", fontsize=fontsize) ax3.set_ylabel(r"Radial Center (planet radii)", fontsize=fontsize) #ax3.legend(loc = "upper right", fontsize = fontsize - 5) # Save, Show, and Close if version is None: save_fn = "%s/radiiAndExtentsOverTime_choice%d.png" % (save_directory, args.choice) else: save_fn = "%s/v%04d_radiiAndExtentsOverTime_choice%d.png" % ( save_directory, version, arg.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)
def make_plot(show=False): # Set up figure if args.choice > 0: fig = plot.figure(figsize=(7, 6), dpi=dpi) else: fig = plot.figure(figsize=(7, 2), dpi=dpi) ax = fig.add_subplot(111) # Iterate max_gap_depth = 0 for i, directory in enumerate(directories): # Frame Range frame_range = util.get_frame_range(frame_ranges[i]) # Label if args.choice > 0: scale_height = float(directories[0].split("_")[0][1:]) / 100.0 log_viscosity = float(directories[0].split("_")[1][2:]) - 2.0 else: scale_height = 0.06 log_viscosity = 5.0 accretion_rate = accretion_rates[i] start_time = start_times[i] end_time = end_times[i] #label = r"$h =$ $%.02f$, $\alpha_\mathrm{visc} = 3 \times 10^{-%d}$, A = %.02f" % (scale_height, log_viscosity, accretion_rate) if args.choice > 0: label = r"$A = %.02f$" % (accretion_rate) else: labels = ["Default", "Restart"] label = labels[i] # Data #gap_depth_over_time = np.zeros(len(frame_range)) #for i, frame in enumerate(frame_range): # get_min((i, frame)) pool_args = [(j, frame, directory) for j, frame in enumerate(frame_range)] p = Pool(num_cores) p.map(get_min, pool_args) p.terminate() #if np.max(gap_depth_over_time) > max_gap_depth: # max_gap_depth = np.max(radial_peak_over_time) num_frames = len(frame_range) this_radial_peak_over_time = np.array( radial_peak_over_time[:num_frames]) ### Plot ### # Basic x = frame_range y = this_radial_peak_over_time result = plot.plot(x, y, c=colors[i], linewidth=linewidth - 1, zorder=99, label=label) # Vortex Lifetime if start_time > 0: start_time_i = az.my_searchsorted(x, start_time) end_time_i = az.my_searchsorted(x, end_time) result = plot.plot(x[start_time_i:end_time_i], y[start_time_i:end_time_i], c=colors[i], linewidth=linewidth + 3, zorder=99) #plot.scatter(x[start_time_i], y[start_time_i], c = colors[i], s = 150, marker = "o", zorder = 120) if args.choice > 0: plot.scatter(x[end_time_i], y[end_time_i], c=colors[i], s=175, marker="H", zorder=120) # Scatter critical points if scale_height == 0.04: i_h4 = plot.scatter(initial_times_h4, initial_critical_maxima_h4, s=120, c=colors[initial_accretion_numbers_h4 - 1], zorder=100, alpha=alpha) s_h4 = plot.scatter(second_times_h4, second_critical_maxima_h4, s=170, c=colors[second_accretion_numbers_h4 - 1], zorder=100, alpha=alpha, marker="*") d_h4 = plot.scatter(interior_times_h4, interior_critical_maxima_h4, s=120, c=colors[interior_accretion_numbers_h4 - 1], zorder=100, alpha=alpha, marker="D") t_h4 = plot.scatter(too_interior_times_h4, too_interior_critical_maxima_h4, s=120, c=colors[too_interior_accretion_numbers_h4 - 1], zorder=100, alpha=alpha, marker="x") elif scale_height == 0.06: i_h6 = plot.scatter(initial_times_h6, initial_critical_maxima_h6, s=120, c=colors[initial_accretion_numbers_h6 - 1], zorder=100, alpha=alpha) s_h4 = plot.scatter(second_times_h6, second_critical_maxima_h6, s=170, c=colors[second_accretion_numbers_h6 - 1], zorder=100, alpha=alpha, marker="*") d_h4 = plot.scatter(interior_times_h6, interior_critical_maxima_h6, s=120, c=colors[interior_accretion_numbers_h6 - 1], zorder=100, alpha=alpha, marker="D") t_h4 = plot.scatter(too_interior_times_h6, too_interior_critical_maxima_h6, s=120, c=colors[too_interior_accretion_numbers_h6 - 1], zorder=100, alpha=alpha, marker="x") if scale_height == 0.04: plot.legend(loc="upper left", fontsize=fontsize - 4) # Pressure Bump label x1 = 1200 x2 = 2800 x_center = (x1 + x2) / 2.0 y_base = 1.45 dy = 0.08 plot.text(x_center, y_base + dy, r"$r_\mathrm{pressure}$", horizontalalignment='center', fontsize=fontsize) top_brace_x, top_brace_y = range_brace(x1, x2, height=0.06) plot.plot(top_brace_x, y_base + top_brace_y, c="k", linewidth=2) # Critical Bump label x1 = 800 x2 = 2200 x_center = (x1 + x2) / 2.0 y_base = 1.14 dy = 0.10 plot.text(x_center, y_base - dy, r"$r_\mathrm{crit}$", horizontalalignment='center', fontsize=fontsize) bottom_brace_x, bottom_brace_y = range_brace(x1, x2, height=0.06) plot.plot(bottom_brace_x, y_base - bottom_brace_y, c="k", linewidth=2) elif scale_height == 0.06: plot.legend(loc="lower right", fontsize=fontsize - 4) # Pressure Bump label x1 = 4000 x2 = 6000 x_center = (x1 + x2) / 2.0 y_base = 1.48 dy = 0.08 plot.text(x_center, y_base + dy, r"$r_\mathrm{pressure}$", horizontalalignment='center', fontsize=fontsize) top_brace_x, top_brace_y = range_brace(x1, x2, height=0.06) plot.plot(top_brace_x, y_base + top_brace_y, c="k", linewidth=2) # Critical Bump label x1 = 1500 x2 = 4800 x_center = (x1 + x2) / 2.0 y_base = 1.18 dy = 0.10 plot.text(x_center, y_base - dy, r"$r_\mathrm{crit}$", horizontalalignment='center', fontsize=fontsize) bottom_brace_x, bottom_brace_y = range_brace(x1, x2, height=0.06) plot.plot(bottom_brace_x, y_base - bottom_brace_y, c="k", linewidth=2) # Axes if args.choice > 0: plot.xlim(0, frame_range[-1]) else: plot.xlim(0, frame_ranges[0][1]) start_y = 1.0 end_y = 1.6 plot.ylim(start_y, end_y) #title = readTitle() unit_x = "planet orbits" unit_y = "r_\mathrm{p}" plot.xlabel(r"Time [%s]" % unit_x, fontsize=fontsize) plot.ylabel(r"$r$ [$%s$]" % unit_y, fontsize=fontsize) x_range = x_max - x_min x_mid = x_min + x_range / 2.0 y_text = 1.14 alpha_coefficent = "3" if scale_height == 0.08: alpha_coefficent = "1.5" elif scale_height == 0.04: alpha_coefficent = "6" title = r"$h = %.02f$ $\alpha \approx %s \times 10^{%d}$" % ( scale_height, alpha_coefficent, int(np.log(viscosity) / np.log(10)) + 2) #title = r"$h = %.02f$ $\alpha_\mathrm{disk} = 3 \times 10^{-%d}$" % (scale_height, log_viscosity) if args.choice > 0: plot.title("%s" % (title), y=1.015, fontsize=fontsize + 2) #plot.text(x_mid, y_text * plot.ylim()[-1], title1, horizontalalignment = 'center', bbox = dict(facecolor = 'none', edgecolor = 'black', linewidth = 1.5, pad = 7.0), fontsize = fontsize + 2) #title = readTitle() # Set twin axis twin = ax.twinx() twin.set_ylim(0, (end_y - start_y) / scale_height) twin.set_ylabel(r"$(r - r_\mathrm{p})$ $/$ $H_0$", fontsize=fontsize, rotation=270, labelpad=30) # Save, Show, and Close if version is None: save_fn = "%s/pressureBumps_choice%d.png" % (save_directory, args.choice) else: save_fn = "%s/v%04d_pressureBumps_choice%d.png" % (save_directory, version, arg.choice) plot.savefig(save_fn, bbox_inches='tight', dpi=dpi) if show: plot.show() plot.close(fig) # Close Figure (to avoid too many figures)