def get_contrasts(args_here):
    # Unwrap Args
    i, frame, directory = args_here

    if frame == 8800:
        frame = 8801  # Remove problem frame

    # Get Data
    density = fromfile("../%s/gasdens%d.dat" % (directory, frame)).reshape(
        num_rad, num_theta) / surface_density_zero
    density, shift_c = shift_density(density,
                                     fargo_par,
                                     reference_density=density)
    azimuthal_profile = az.get_mean_azimuthal_profile(density,
                                                      fargo_par,
                                                      sliver_width=1.5,
                                                      end=1.85)

    if "low_mass" in directory:
        azimuthal_profile /= (0.3)  # low-mass case

    maxima_over_time[i] = np.percentile(azimuthal_profile, 90)
    minima_over_time[i] = np.percentile(azimuthal_profile, 5)
    contrasts_over_time[i] = maxima_over_time[i] / minima_over_time[i]
    differences_over_time[i] = maxima_over_time[i] - minima_over_time[i]

    print i, frame, differences_over_time[i], maxima_over_time[
        i], minima_over_time[i], contrasts_over_time[i]
Ejemplo n.º 2
0
def get_contrasts(args_here):
    # Unwrap Args
    i, frame, directory, comparison_directory = args_here

    # Get Data
    density = fromfile("%s/gasdens%d.dat" % (directory, frame)).reshape(
        num_rad, num_theta) / surface_density_zero
    density, shift_c = shift_density(density,
                                     fargo_par,
                                     reference_density=density)
    azimuthal_profile = az.get_mean_azimuthal_profile(density,
                                                      fargo_par,
                                                      sliver_width=1.5)

    maxima_over_time[i] = np.percentile(azimuthal_profile, 90)
    minima_over_time[i] = np.percentile(azimuthal_profile, 5)
    differences_over_time[i] = maxima_over_time[i] - minima_over_time[i]
    contrasts_over_time[i] = maxima_over_time[i] / minima_over_time[i]

    print i, frame, contrasts_over_time[i], maxima_over_time[
        i], minima_over_time[i], differences_over_time[i]

    # Do Comparison
    if frame >= 2500 and frame < 3000:
        density = fromfile("%s/gasdens%d.dat" %
                           (comparison_directory, frame)).reshape(
                               num_rad, num_theta) / surface_density_zero
        density, shift_c = shift_density(density,
                                         fargo_par,
                                         reference_density=density)
        azimuthal_profile = az.get_mean_azimuthal_profile(density,
                                                          fargo_par,
                                                          sliver_width=1.5)

        maxima = np.percentile(azimuthal_profile, 90)
        minima = np.percentile(azimuthal_profile, 5)
        contrasts_over_time_comparison[i] = maxima / minima

        print i, frame, contrasts_over_time_comparison[i]
Ejemplo n.º 3
0
def get_contrasts(args_here):
    # Unwrap Args
    i, frame = args_here

    # Get Data
    density = fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta) / surface_density_zero
    density, shift_c = shift_density(density, fargo_par, reference_density = density)
    azimuthal_profile = az.get_mean_azimuthal_profile(density, fargo_par, sliver_width = 1.5, end = 1.85)

    maxima_over_time[i] = np.percentile(azimuthal_profile, 90)
    minima_over_time[i] = np.percentile(azimuthal_profile, 5)
    contrasts_over_time[i] = maxima_over_time[i] / minima_over_time[i]
    differences_over_time[i] = maxima_over_time[i] - minima_over_time[i]

    print i, frame, differences_over_time[i], maxima_over_time[i], minima_over_time[i], contrasts_over_time[i]
def make_plot(frame, show = False):
    # Set up figure
    fig = plot.figure(figsize = (7, 6), dpi = dpi)
    ax = fig.add_subplot(111)

    # Data
    density = fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta) / surface_density_zero
    if center:
        density, shift_c = shift_density(density, fargo_par, reference_density = density)

    azimuthal_profile = az.get_mean_azimuthal_profile(density, fargo_par, sliver_width = 1.5)

    ### Plot ###
    x = theta * (180.0 / np.pi)
    y = azimuthal_profile
    result = plot.plot(x, y, linewidth = linewidth, zorder = 99)

    if args.zero:
        density_zero = fromfile("gasdens0.dat").reshape(num_rad, num_theta)
        averagedDensity_zero = np.average(density_zero, axis = 1)
        normalized_density_zero = averagedDensity_zero / surface_density_zero

        x = theta
        y_zero = normalized_density_zero
        result = plot.plot(x, y_zero, linewidth = linewidth, zorder = 0)

    if args.compare is not None:
        directory = args.compare
        density_compare = (fromfile("%s/gasdens%d.dat" % (directory, frame)).reshape(num_rad, num_theta))
        averagedDensity_compare = np.average(density_compare, axis = 1)
        normalized_density_compare = averagedDensity_compare / surface_density_zero

        ### Plot ###
        x = rad
        y_compare = normalized_density_compare
        result = plot.plot(x, y_compare, linewidth = linewidth, alpha = 0.6, zorder = 99, label = "compare")

        plot.legend()

    # Axes
    if args.max_y is None:
        max_y = 1.1 * max(y)
    else:
        max_y = args.max_y

    plot.xlim(0, 360)
    plot.ylim(0, max_y)

    angles = np.linspace(0, 360, 7)
    plot.xticks(angles)

    # Annotate Axes
    orbit = (dt / (2 * np.pi)) * frame

    if orbit >= taper_time:
        current_mass = planet_mass
    else:
        current_mass = np.power(np.sin((np.pi / 2) * (1.0 * orbit / taper_time)), 2) * planet_mass

    current_mass += accreted_mass[frame]

    #title = readTitle()

    unit = "r_\mathrm{p}"
    plot.ylabel(r"$\phi$", fontsize = fontsize)
    plot.ylabel(r"$\Sigma / \Sigma_0$", 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"$T_\mathrm{growth} = %d$ $\mathrm{orbits}$" % (taper_time)
    title1 = r"$\Sigma_0 = %.3e$  $M_c = %.2f\ M_J$  $A = %.2f$" % (surface_density_zero, planet_mass, accretion)
    title2 = r"$t = %d$ $\mathrm{orbits}}$  [$m_\mathrm{p}(t)\ =\ %.2f$ $M_\mathrm{Jup}$]" % (orbit, current_mass)
    plot.title("%s" % (title2), y = 1.015, fontsize = fontsize + 1)
    #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/meanAzimuthalProfile_%04d.png" % (save_directory, frame)
    else:
        save_fn = "%s/v%04d_meanAzimuthalProfile_%04d.png" % (save_directory, version, frame)
    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(frame_range, show = False):
    # Set up figure
    fig = plot.figure(figsize = (7, 6), dpi = dpi)
    ax = fig.add_subplot(111)

    # Data
    for i, frame in enumerate(frame_range):
        density = fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta) / surface_density_zero
        if center:
            density, shift_c = shift_density(density, fargo_par, reference_density = density)

        azimuthal_profile = az.get_mean_azimuthal_profile(density, fargo_par, sliver_width = 1.5)

        ### Plot ###
        x = theta * (180.0 / np.pi)
        y = azimuthal_profile
        result = plot.plot(x, y, c = colors[i % len(colors)], linewidth = linewidth, linestyle = linestyles[i % 2], zorder = 99, label = r"$t$ $=$ $%d$ $T_\mathrm{p}$" % frame)

    plot.legend(loc = "lower center", fontsize = fontsize - 6)

    # Axes
    if args.max_y is None:
        max_y = 1.1 * max(y)
    else:
        max_y = args.max_y

    plot.xlim(0, 360)
    plot.ylim(0, max_y)

    angles = np.linspace(0, 360, 7)
    plot.xticks(angles)

    # Annotate Axes
    orbit = (dt / (2 * np.pi)) * frame

    if orbit >= taper_time:
        current_mass = planet_mass
    else:
        current_mass = np.power(np.sin((np.pi / 2) * (1.0 * orbit / taper_time)), 2) * planet_mass

    current_mass += accreted_mass[frame]

    #title = readTitle()

    unit = "r_\mathrm{p}"
    plot.xlabel(r"$\phi$", fontsize = fontsize)
    plot.ylabel(r"$\Sigma$ $/$ $\Sigma_0$", 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"$T_\mathrm{growth} = %d$ $\mathrm{orbits}$" % (taper_time)
    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 \approx %s \times 10^{%d}$    $A = %.2f$" % (scale_height, alpha_coefficent, int(np.log(viscosity) / np.log(10)) + 2, accretion)
    #title2 = r"$t = %d$ $\mathrm{orbits}}$  [$m_\mathrm{p}(t)\ =\ %.2f$ $M_\mathrm{Jup}$]" % (orbit, current_mass)
    plot.title("%s" % (title1), y = 1.015, fontsize = fontsize + 1)
    #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')

    if args.start is not None:
        text_start = r"$t_\mathrm{start}$ $=$ $%d$ $T_\mathrm{p}$" % args.start
        plot.text(10, 0.93 * max_y, text_start, fontsize = fontsize - 4, color = 'black', horizontalalignment = 'left')
    if args.end is not None:
        text_end = r"$t_\mathrm{end}$ $=$ $%d$ $T_\mathrm{p}$" % args.end
        plot.text(350, 0.93 * max_y, text_end, fontsize = fontsize - 4, color = 'black', horizontalalignment = 'right')

    # Save, Show, and Close
    directory_name = os.getcwd().split("/")[-1].split("-")[0]

    if version is None:
        save_fn = "%s/meanAzimuthalProfile_%s_%04d-%04d-%04d.png" % (save_directory, directory_name, args.frames[0], args.frames[1], args.frames[2])
    else:
        save_fn = "%s/v%04d_meanAzimuthalProfile_%s_%04d-%04d-%04d.png" % (save_directory, version, directory_name, args.frames[0], args.frames[1], args.frames[2])
    plot.savefig(save_fn, bbox_inches = 'tight', dpi = dpi)

    if show:
        plot.show()

    plot.close(fig) # Close Figure (to avoid too many figures)