コード例 #1
0
def get_data(frame):
    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis = 1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = ref_frame)
    vortensity = vorticity / normalized_density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)

    peak_rad, peak_density = find_peak(averagedDensity)
    min_rad, min_density = find_min(averagedDensity, peak_rad)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 2.0 * scale_height # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread, num_profiles)
    azimuthal_indices = [np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii]
    azimuthal_profiles = [vortensity[azimuthal_index, :] for azimuthal_index in azimuthal_indices]

    return azimuthal_radii, azimuthal_profiles
コード例 #2
0
def get_data(frame):
    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(
        num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis=1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=ref_frame)
    vortensity = vorticity / normalized_density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)

    peak_rad, peak_density = find_peak(averagedDensity)
    min_rad, min_density = find_min(averagedDensity, peak_rad)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 2.0 * scale_height  # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread,
                                  num_profiles)
    azimuthal_indices = [
        np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii
    ]
    azimuthal_profiles = [
        vortensity[azimuthal_index, :] for azimuthal_index in azimuthal_indices
    ]

    return azimuthal_radii, azimuthal_profiles
コード例 #3
0
def get_data(frame_i, frame, modes = default_modes):
    """ frame_i is ith frame, frame is frame number """

    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis = 1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = ref_frame)
    vortensity = vorticity / normalized_density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)
    peak_rad, peak_density = find_peak(averagedDensity)
    min_rad, min_density = find_min(averagedDensity, peak_rad)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 1.0 * scale_height # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread, num_profiles)
    azimuthal_indices = [np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii]
    azimuthal_profiles = np.array([np.fft.fft(vortensity[azimuthal_index, :]) for azimuthal_index in azimuthal_indices])

    # Normalize by m = 0 mode (integral of density), Take Absolute Value
    azimuthal_profiles = np.array([np.abs(azimuthal_profile / azimuthal_profile[0]) for azimuthal_profile in azimuthal_profiles])

    for m, mode in enumerate(modes):
        modes_over_time[m, frame_i] = np.max(azimuthal_profiles[:, mode])

    print "%d: %.4f, %.4f, %.4f, %.4f, %.4f" % (frame, np.max(azimuthal_profiles[:, 1]), np.max(azimuthal_profiles[:, 2]), np.max(azimuthal_profiles[:, 3]), np.max(azimuthal_profiles[:, 4]), np.max(azimuthal_profiles[:, 5]))
コード例 #4
0
def sum_vorticity(args):
    i, frame = args

    # Get Data
    density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density_zero
    vrad = np.array(fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = np.array(fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    # Get Background Data
    vtheta_keplerian = np.array(fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

    # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
    vtheta -= (vtheta_keplerian)
    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = 0)

    #vorticity = np.abs(vorticity) # should be all negative

    # Add up vorticity
    dr = rad[1] - rad[0] # assumes arithmetic grid
    d_phi = theta[1] - theta[0]

    radial_vorticity = np.average(vorticity, axis = 1)
    total_vorticity = np.sum((dr * d_phi) * rad[:-1, None] * radial_vorticity)
    
    # Print Update
    print "%d: %.4f" % (frame, total_vorticity)

    # Store Data
    vorticity_over_time[i] = total_vorticity
コード例 #5
0
def find_extrema(args):
    # Unwrap Args
    i, frame = args

    # Data
    density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density
    averagedDensity = np.average(density, axis = 1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = ref_frame)
    vortensity = vorticity / density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)
    peak_rad, peak_rad_index, peak_density = find_radial_peak(averagedDensity)

    # Find Peaks in Azimuthal Profiles (and center around that peak)
    density_peak_theta, density_theta_index, max_density = find_azimuthal_extrema(density[peak_rad_index], maximum = True) # Max
    vortensity_peak_theta, vortensity_peak_theta_index, min_vortensity = find_azimuthal_extrema(vortensity[peak_rad_index], maximum = False) # Min

    print "%d, %.2f, %.3f" % (frame, max_density, min_vortensity)

    #return max_density, min_vortensity
    maximum_densities[i] = max_density
    minimum_vortensities[i] = min_vortensity
コード例 #6
0
def sum_vorticity(args):
    i, frame = args

    # Get Data
    density = (fromfile("gasdens%d.dat" % frame).reshape(
        num_rad, num_theta)) / surface_density_zero
    vrad = np.array(
        fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = np.array(
        fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    # Get Background Data
    vtheta_keplerian = np.array(
        fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

    # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
    vtheta -= (vtheta_keplerian)
    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=0)

    #vorticity = np.abs(vorticity) # should be all negative

    # Add up vorticity
    dr = rad[1] - rad[0]  # assumes arithmetic grid
    d_phi = theta[1] - theta[0]

    radial_vorticity = np.average(vorticity, axis=1)
    total_vorticity = np.sum((dr * d_phi) * rad[:-1, None] * radial_vorticity)

    # Print Update
    print "%d: %.4f" % (frame, total_vorticity)

    # Store Data
    vorticity_over_time[i] = total_vorticity
コード例 #7
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize=(700 / my_dpi, 600 / my_dpi), dpi=my_dpi)
        ax = fig.add_subplot(111)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)

        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40)  # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta))
        normalized_density = density / surface_density_zero

        vrad = (fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = (fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vortensity = util.velocity_curl(
            vrad, vtheta, rad, theta, frame=ref_frame) / normalized_density[1:,
                                                                            1:]

        ### Plot ###
        result = ax.pcolormesh(x, theta, np.transpose(vortensity), cmap=cmap)

        fig.colorbar(result)
        result.set_clim(clim[0], clim[1])

        # Annotate
        plot.xlabel(xlabel, fontsize=fontsize)
        plot.ylabel(r"$\phi$", fontsize=fontsize)
        plot.title("Vortensity Map at Orbit %d" % orbit, fontsize=fontsize + 1)

        # Save and Close
        plot.savefig("%s/%svortensityMap_%03d.png" %
                     (save_directory, prefix, i),
                     bbox_inches='tight',
                     dpi=my_dpi)
        if show:
            plot.show()
        plot.close(fig)  # Close Figure (to avoid too many figures)
コード例 #8
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize = (700 / my_dpi, 600 / my_dpi), dpi = my_dpi)
        ax = fig.add_subplot(111)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)

        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40) # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        vrad = np.array(fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = np.array(fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vtheta_keplerian = np.array(fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

        # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
        vtheta -= (vtheta_keplerian)

        vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = 0)

        # Divide out Angular Frequency (for Rossby Number)
        vorticity = vorticity / (np.array([r**(-1.5) for r in rad[:-1]]))[:, None]

        ### Plot ###
        result = ax.pcolormesh(x, theta, np.transpose(vorticity), cmap = cmap)
    
        fig.colorbar(result)
        result.set_clim(clim[0], clim[1])

        # Annotate
        plot.xlabel(xlabel, fontsize = fontsize)
        plot.ylabel(r"$\phi$", fontsize = fontsize)
        plot.title("Vorticity (v - vK) Map at Orbit %d" % orbit, fontsize = fontsize + 1)

        # Save and Close
        plot.savefig("%s/%sexcessVorticityMap_%03d.png" % (save_directory, prefix, i), bbox_inches = 'tight', dpi = my_dpi)
        if show:
            plot.show()
        plot.close(fig) # Close Figure (to avoid too many figures)
コード例 #9
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize = (700 / my_dpi, 600 / my_dpi), dpi = my_dpi)
        ax = fig.add_subplot(111)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)

        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40) # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta))
        normalized_density = density / surface_density_zero

        vrad = (fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = (fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vortensity = util.velocity_curl(vrad, vtheta, rad, theta, frame = ref_frame) / normalized_density[1:, 1:]
        avg_vortensity = np.average(vortensity, axis = 1)

        excess_vortensity = avg_vortensity[:, None] - vortensity #### Vortex is Positive ####

        ### Plot ###
        result = ax.pcolormesh(x, theta, np.transpose(excess_vortensity), cmap = cmap)
    
        fig.colorbar(result)
        result.set_clim(clim[0], clim[1])

        # Annotate
        plot.xlabel(xlabel, fontsize = fontsize)
        plot.ylabel(r"$\phi$", fontsize = fontsize)
        plot.title("Excess Vortensity Map at Orbit %d" % orbit, fontsize = fontsize + 1)

        # Save and Close
        plot.savefig("%s/%sexcessVortensityMap_%03d.png" % (save_directory, prefix, i), bbox_inches = 'tight', dpi = my_dpi)
        if show:
            plot.show()
        plot.close(fig) # Close Figure (to avoid too many figures)
コード例 #10
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize=(700 / my_dpi, 600 / my_dpi), dpi=my_dpi)

        # Axis
        plot.ylim(0, 1.3)
        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40)  # to match the ApJL paper
            #plot.ylim(0, 1.3)
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta))
        normalized_density = density / surface_density_zero

        vrad = (fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = (fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vorticity = util.velocity_curl(vrad,
                                       vtheta,
                                       rad,
                                       theta,
                                       average=True,
                                       frame=ref_frame)
        vortensity = vorticity / normalized_density[1:, 1:]
        averaged_w = np.average(vortensity, axis=1)

        ### Plot ###
        plot.plot(x[1:], averaged_w, linewidth=linewidth)

        # Annotate
        this_title = readTitle()
        plot.xlabel(xlabel, fontsize=fontsize)
        plot.ylabel("Azimuthally Averaged Vortensity", fontsize=fontsize)
        plot.title("Orbit %d: %s" % (orbit, this_title), fontsize=fontsize + 1)

        # Save and Close
        plot.savefig("%s/%saveragedVortensity_%03d.png" %
                     (save_directory, prefix, i),
                     bbox_inches='tight',
                     dpi=my_dpi)
        if show:
            plot.show()
        plot.close(fig)  # Close Figure (to avoid too many figures)
コード例 #11
0
def get_data(frame):
    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(
        num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis=1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=ref_frame)
    vortensity = vorticity / normalized_density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)

    peak_rad, peak_density = find_peak(averagedDensity)
    min_rad, min_density = find_min(averagedDensity, peak_rad)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 1.0 * scale_height  # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread,
                                  num_profiles)
    azimuthal_indices = [
        np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii
    ]
    azimuthal_profiles = [
        np.fft.fft(vortensity[azimuthal_index, :])
        for azimuthal_index in azimuthal_indices
    ]

    # Normalize by m = 0 mode (integral of vortensity), Take Absolute Value
    azimuthal_profiles = [
        np.abs(azimuthal_profile / azimuthal_profile[0])
        for azimuthal_profile in azimuthal_profiles
    ]

    ### Gather Averaged Profiles ###
    start_half = azimuthal_indices[1]
    end_half = azimuthal_indices[-2]
    avg_half_profile = np.average(vortensity[start_half:end_half, :], axis=0)
    avg_half = np.fft.fft(avg_half_profile)

    start_full = azimuthal_indices[0]
    end_full = azimuthal_indices[-1]
    avg_full_profile = np.average(vortensity[start_full:end_full, :], axis=0)
    avg_full = np.fft.fft(avg_full_profile)

    # Normalize
    avg_half = np.abs(avg_half / avg_half[0])
    avg_full = np.abs(avg_full / avg_full[0])

    return azimuthal_radii, azimuthal_profiles, avg_half, avg_full
コード例 #12
0
def sum_vorticity(args):
    i, frame = args

    # Get Data
    density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density_zero
    vrad = np.array(fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = np.array(fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    # Get Background Data
    vtheta_keplerian = np.array(fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

    # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
    vtheta -= (vtheta_keplerian)
    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = 0)

    # Mask Non-Vortex Regions
    min_vorticity = -0.65

    vorticity[density[:-1, :-1] < 0.45] = 0 # if density is too low, it's not in the vortex
    vorticity[vorticity > 0] = 0 # if vorticity is positive, it's not in the vortex
    vorticity[vorticity < min_vorticity] = min_vorticity # if vorticity is too low, it's not in the vortex

    vorticity = np.abs(vorticity) # everything that remains should be negative. switch to positive.

    # Extract Near Vortex
    averagedDensity = np.average(density, axis = 1)
    peak_rad, peak_density = find_peak(averagedDensity)

    vortex_start = np.max([1.0, peak_rad - 5.0 * scale_height])
    vortex_end = peak_rad + 5.0 * scale_height

    vortex_start_i = np.searchsorted(rad, vortex_start)
    vortex_end_i = np.searchsorted(rad, vortex_end)

    vortex_rad = rad[vortex_start_i : vortex_end_i]
    vortex_vorticity_grid = vorticity[vortex_start_i : vortex_end_i]

    vortex_vorticity = np.average(vortex_vorticity_grid, axis = 1)

    # Add up vorticity
    dr = rad[1] - rad[0] # assumes arithmetic grid
    d_phi = theta[1] - theta[0]

    total_vorticity = np.sum((dr * d_phi) * vortex_rad[:, None] * vortex_vorticity)

    ##### Instead: take max vorticity (90th percentile???) #####
    
    # Print Update
    print "%d: %.4f" % (frame, total_vorticity)

    # Store Data
    vorticity_over_time[i] = total_vorticity
コード例 #13
0
def get_data(frame_i, frame, modes=default_modes):
    """ frame_i is ith frame, frame is frame number """

    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(
        num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis=1)

    vrad = np.array(
        fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = np.array(
        fromfile("gasvtheta%d.dat" % frame).reshape(
            num_rad, num_theta)) - vtheta_keplerian

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=ref_frame)
    combo = normalized_density[:-1, :-1] * vorticity

    # Find Peak in Radial Profile (in Outer Disk)
    peak_rad, peak_density = find_peak(averagedDensity)
    min_rad, min_density = find_min(averagedDensity, peak_rad)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 1.0 * scale_height  # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread,
                                  num_profiles)
    azimuthal_indices = [
        np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii
    ]
    azimuthal_profiles = np.array([
        np.fft.fft(combo[azimuthal_index, :])
        for azimuthal_index in azimuthal_indices
    ])

    # Normalize by m = 0 mode (integral of density), Take Absolute Value
    azimuthal_profiles = np.array([
        np.abs(azimuthal_profile / azimuthal_profile[0])
        for azimuthal_profile in azimuthal_profiles
    ])

    for m, mode in enumerate(modes):
        modes_over_time[m, frame_i] = np.max(azimuthal_profiles[:, mode])

    single_mode_strength[frame_i] = modes_over_time[0, frame_i] / np.max(
        modes_over_time[1:, frame_i])  # m = 1 / Max of Higher Number Modes

    print "%d: %.4f, %.4f, %.4f, %.4f, %.4f - [%.4f]" % (
        frame, np.max(azimuthal_profiles[:, 1]),
        np.max(azimuthal_profiles[:, 2]), np.max(azimuthal_profiles[:, 3]),
        np.max(azimuthal_profiles[:, 4]), np.max(
            azimuthal_profiles[:, 5]), single_mode_strength[frame_i])
コード例 #14
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize = (700 / my_dpi, 600 / my_dpi), dpi = my_dpi)

        # Axis
        plot.ylim(0, 1.3)
        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40) # to match the ApJL paper
            #plot.ylim(0, 1.3)
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta))
        normalized_density = density / surface_density_zero

        vrad = (fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = (fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vorticity = util.velocity_curl(vrad, vtheta, rad, theta, average = True, frame = ref_frame)
        vortensity = vorticity / normalized_density[1:, 1:]
        averaged_w = np.average(vortensity, axis = 1)

        ### Plot ###
        plot.plot(x[1:], averaged_w, linewidth = linewidth)

        # Annotate
        this_title = readTitle()
        plot.xlabel(xlabel, fontsize = fontsize)
        plot.ylabel("Azimuthally Averaged Vortensity", fontsize = fontsize)
        plot.title("Orbit %d: %s" % (orbit, this_title), fontsize = fontsize + 1)

        # Save and Close
        plot.savefig("%s/%saveragedVortensity_%03d.png" % (save_directory, prefix, i), bbox_inches = 'tight', dpi = my_dpi)
        if show:
            plot.show()
        plot.close(fig) # Close Figure (to avoid too many figures)
コード例 #15
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize = (700 / my_dpi, 600 / my_dpi), dpi = my_dpi)
        ax = fig.add_subplot(111, polar = True)

        # Axis
        if axis == "zoom":
            prefix = "zoom_"
            rmax = 2.4 # to match ApJL paper
        else:
            prefix = ""
            rmax = float(fargo_par["Rmax"])

        plot.xticks([], []) # Angles
        plot.yticks([rmax], ["%.1f" % rmax]) # Max Radius
        plot.ylim(0, rmax)

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta))
        normalized_density = density / surface_density_zero

        vrad = (fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = (fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vorticity = util.velocity_curl(vrad, vtheta, rad, theta) / normalized_density[1:, 1:]

        ### Plot ###
        result = ax.pcolormesh(theta, rad, vorticity, cmap = cmap)
    
        fig.colorbar(result)
        result.set_clim(clim[0], clim[1])

        # Annotate
        this_title = readTitle()
        plot.title("Vortensity Map at Orbit %d\n%s" % (orbit, this_title), fontsize = fontsize + 1)

        # Save and Close
        plot.savefig("%s/%svortensityMap_%03d.png" % (save_directory, prefix, i), bbox_inches = 'tight', dpi = my_dpi)
        if show:
            plot.show()
        plot.close(fig) # Close Figure (to avoid too many figures)
コード例 #16
0
def get_data(frame):
    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis = 1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = ref_frame)
    vortensity = vorticity / normalized_density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)

    peak_rad, peak_density = find_peak(averagedDensity)
    min_rad, min_density = find_min(averagedDensity, peak_rad)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 1.0 * scale_height # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread, num_profiles)
    azimuthal_indices = [np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii]
    azimuthal_profiles = [np.fft.fft(vortensity[azimuthal_index, :]) for azimuthal_index in azimuthal_indices]

    # Normalize by m = 0 mode (integral of vortensity), Take Absolute Value
    azimuthal_profiles = [np.abs(azimuthal_profile / azimuthal_profile[0]) for azimuthal_profile in azimuthal_profiles]

    ### Gather Averaged Profiles ###
    start_half = azimuthal_indices[1]
    end_half = azimuthal_indices[-2]
    avg_half_profile = np.average(vortensity[start_half : end_half, :], axis = 0)
    avg_half = np.fft.fft(avg_half_profile)

    start_full = azimuthal_indices[0]
    end_full = azimuthal_indices[-1]
    avg_full_profile = np.average(vortensity[start_full : end_full, :], axis = 0)
    avg_full = np.fft.fft(avg_full_profile)

    # Normalize
    avg_half = np.abs(avg_half / avg_half[0])
    avg_full = np.abs(avg_full / avg_full[0])

    return azimuthal_radii, azimuthal_profiles, avg_half, avg_full
コード例 #17
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Axis
        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40) # to match the ApJL paper
            #plot.ylim(0, 1.2)
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]) - 0.05, float(fargo_par["Rmax"]) + 0.05)
            #plot.ylim(0, 5.0)
            xlabel = "Radius"
            
        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta))
        normalized_density = density / surface_density_zero

        vrad = (fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = (fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vorticity = util.velocity_curl(vrad, vtheta, rad, theta, average = True, frame = ref_frame)
        vortensity = vorticity / normalized_density[1:, 1:]
        averaged_w = np.average(vortensity, axis = 1)

        ### Plot ###
        plot.plot(x, averaged_w, linewidth = linewidth, label = "%d" % frame)

        # Annotate
        this_title = readTitle()
        plot.xlabel(xlabel, fontsize = fontsize)
        plot.ylabel(r"Azimuthally Averaged Vortensity", fontsize = fontsize)
        plot.title("%s" % this_title, fontsize = fontsize + 1)
コード例 #18
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize=(1400 / my_dpi, 600 / my_dpi), dpi=my_dpi)
        #gs = gridspec.GridSpec(1, 2)
        #ax1 = fig.add_subplot(gs[0])
        #ax2 = fig.add_subplot(gs[1])

        ###### Density ######
        # Select Plot
        plot.subplot(1, 2, 1)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)
        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40)  # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(
            num_rad, num_theta)) / surface_density_zero
        background_density = (fromfile("gasdens%d.dat" % (i - 1)).reshape(
            num_rad, num_theta)) / surface_density_zero

        diff_density = density - background_density

        ### Plot ###
        result = plot.pcolormesh(x,
                                 theta,
                                 np.transpose(diff_density),
                                 cmap=d_cmap)
        fig.colorbar(result)
        result.set_clim(d_clim[0], d_clim[1])

        # Annotate
        this_title = readTitle()
        plot.xlabel(xlabel, fontsize=fontsize)
        plot.ylabel(r"$\phi$", fontsize=fontsize)
        plot.title("Gas Density Difference Map at Orbit %d\n%s" %
                   (orbit, this_title),
                   fontsize=fontsize + 1)

        ###### Excess Vortensity ######
        # Select Plot
        plot.subplot(1, 2, 2)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)

        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40)  # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        vtheta_keplerian = np.array(
            fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

        ### FRAME 1 ###

        vrad = np.array(
            fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = np.array(
            fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
        vtheta -= (vtheta_keplerian)
        vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=0)

        # Divide out Angular Frequency (for Rossby Number)
        vorticity = vorticity / (np.array([r**(-1.5)
                                           for r in rad[:-1]]))[:, None]

        ### FRAME 2 ###

        background_vrad = np.array(
            fromfile("gasvrad%d.dat" % (i - 1)).reshape(num_rad, num_theta))
        background_vtheta = np.array(
            fromfile("gasvtheta%d.dat" % (i - 1)).reshape(num_rad, num_theta))

        # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
        background_vtheta -= (vtheta_keplerian)
        background_vorticity = util.velocity_curl(background_vrad,
                                                  background_vtheta,
                                                  rad,
                                                  theta,
                                                  frame=0)

        # Divide out Angular Frequency (for Rossby Number)
        background_vorticity = background_vorticity / (np.array(
            [r**(-1.5) for r in rad[:-1]]))[:, None]

        # Remove (vorticity > 0) from background
        background_vorticity[background_vorticity > 0] = 0

        ### TAKE DIFFERENCE
        diff_vorticity = vorticity - background_vorticity

        ### Plot ###
        result = plot.pcolormesh(x,
                                 theta,
                                 np.transpose(diff_vorticity),
                                 cmap=v_cmap)

        fig.colorbar(result)
        result.set_clim(v_clim[0], v_clim[1])

        # Annotate
        plot.xlabel(xlabel, fontsize=fontsize)
        plot.ylabel(r"$\phi$", fontsize=fontsize)
        plot.title("Vorticity (v - vK) Map at Orbit %d\n%s" %
                   (orbit, this_title),
                   fontsize=fontsize + 1)

        # Save and Close
        plot.savefig("%s/%sdiffComboMap_%03d.png" %
                     (save_directory, prefix, i),
                     bbox_inches='tight',
                     dpi=my_dpi)
        if show:
            plot.show()
        plot.close(fig)  # Close Figure (to avoid too many figures)
コード例 #19
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize=(700 / my_dpi, 600 / my_dpi), dpi=my_dpi)
        ax = fig.add_subplot(111)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)

        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40)  # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        vrad = np.array(
            fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = np.array(
            fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        vtheta_keplerian = np.array(
            fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

        # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
        vtheta -= (vtheta_keplerian)

        vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=0)

        # Divide out Angular Frequency (for Rossby Number)
        vorticity = vorticity / (np.array([r**(-1.5)
                                           for r in rad[:-1]]))[:, None]

        ### Plot ###
        result = ax.pcolormesh(x, theta, np.transpose(vorticity), cmap=cmap)

        fig.colorbar(result)
        result.set_clim(clim[0], clim[1])

        # Annotate
        plot.xlabel(xlabel, fontsize=fontsize)
        plot.ylabel(r"$\phi$", fontsize=fontsize)
        plot.title("Vorticity (v - vK) Map at Orbit %d" % orbit,
                   fontsize=fontsize + 1)

        # Save and Close
        plot.savefig("%s/%sexcessVorticityMap_%03d.png" %
                     (save_directory, prefix, i),
                     bbox_inches='tight',
                     dpi=my_dpi)
        if show:
            plot.show()
        plot.close(fig)  # Close Figure (to avoid too many figures)
コード例 #20
0
    def choose_axis(i, axis):
        # Orbit Number
        time = float(fargo_par["Ninterm"]) * float(fargo_par["DT"])
        orbit = int(round(time / (2 * np.pi), 0)) * i

        # Set up figure
        fig = plot.figure(figsize = (1400 / my_dpi, 600 / my_dpi), dpi = my_dpi)
        #gs = gridspec.GridSpec(1, 2)
        #ax1 = fig.add_subplot(gs[0])
        #ax2 = fig.add_subplot(gs[1])

        ###### Density ######
        # Select Plot
        plot.subplot(1, 2, 1)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)
        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40) # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        density = (fromfile("gasdens%d.dat" % i).reshape(num_rad, num_theta)) / surface_density_zero
        background_density = (fromfile("gasdens%d.dat" % (i - 1)).reshape(num_rad, num_theta)) / surface_density_zero

        diff_density = density - background_density

        ### Plot ###
        result = plot.pcolormesh(x, theta, np.transpose(diff_density), cmap = d_cmap)
        fig.colorbar(result)
        result.set_clim(d_clim[0], d_clim[1])

        # Annotate
        this_title = readTitle()
        plot.xlabel(xlabel, fontsize = fontsize)
        plot.ylabel(r"$\phi$", fontsize = fontsize)
        plot.title("Gas Density Difference Map at Orbit %d\n%s" % (orbit, this_title), fontsize = fontsize + 1)

        ###### Excess Vortensity ######
        # Select Plot
        plot.subplot(1, 2, 2)

        # Axis
        angles = np.linspace(0, 2 * np.pi, 7)
        degree_angles = ["%d" % d_a for d_a in np.linspace(0, 360, 7)]

        plot.ylim(0, 2 * np.pi)
        plot.yticks(angles, degree_angles)

        if axis == "zoom":
            x = (rad - 1) / scale_height
            prefix = "zoom_"
            plot.xlim(0, 40) # to match the ApJL paper
            xlabel = r"($r - r_p$) $/$ $h$"
        else:
            x = rad
            prefix = ""
            plot.xlim(float(fargo_par["Rmin"]), float(fargo_par["Rmax"]))
            xlabel = "Radius"

        # Data
        vtheta_keplerian = np.array(fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

        ### FRAME 1 ###
        
        vrad = np.array(fromfile("gasvrad%d.dat" % i).reshape(num_rad, num_theta))
        vtheta = np.array(fromfile("gasvtheta%d.dat" % i).reshape(num_rad, num_theta))

        # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
        vtheta -= (vtheta_keplerian)
        vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = 0)

        # Divide out Angular Frequency (for Rossby Number)
        vorticity = vorticity / (np.array([r**(-1.5) for r in rad[:-1]]))[:, None]

        ### FRAME 2 ###

        background_vrad = np.array(fromfile("gasvrad%d.dat" % (i - 1)).reshape(num_rad, num_theta))
        background_vtheta = np.array(fromfile("gasvtheta%d.dat" % (i - 1)).reshape(num_rad, num_theta))

        # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
        background_vtheta -= (vtheta_keplerian)
        background_vorticity = util.velocity_curl(background_vrad, background_vtheta, rad, theta, frame = 0)

        # Divide out Angular Frequency (for Rossby Number)
        background_vorticity = background_vorticity / (np.array([r**(-1.5) for r in rad[:-1]]))[:, None]

        # Remove (vorticity > 0) from background
        background_vorticity[background_vorticity > 0] = 0

        ### TAKE DIFFERENCE
        diff_vorticity = vorticity - background_vorticity

        ### Plot ###
        result = plot.pcolormesh(x, theta, np.transpose(diff_vorticity), cmap = v_cmap)
    
        fig.colorbar(result)
        result.set_clim(v_clim[0], v_clim[1])

        # Annotate
        plot.xlabel(xlabel, fontsize = fontsize)
        plot.ylabel(r"$\phi$", fontsize = fontsize)
        plot.title("Vorticity (v - vK) Map at Orbit %d\n%s" % (orbit, this_title), fontsize = fontsize + 1)

        # Save and Close
        plot.savefig("%s/%sdiffComboMap_%03d.png" % (save_directory, prefix, i), bbox_inches = 'tight', dpi = my_dpi)
        if show:
            plot.show()
        plot.close(fig) # Close Figure (to avoid too many figures)
コード例 #21
0
def measure_asymmetry(frame):
    print frame

    # Load Data Files
    normalized_density = (fromfile("gasdens%d.dat" % frame).reshape(num_rad, num_theta)) / surface_density
    averagedDensity = np.average(normalized_density, axis = 1)

    vrad = (fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = (fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame = ref_frame)
    vortensity = vorticity / normalized_density[1:, 1:]

    # Find Peak in Radial Profile (in Outer Disk)

    peak_rad, peak_density = find_peak(averagedDensity)

    # Gather Azimuthal Profiles
    num_profiles = 5
    spread = 1.0 * scale_height # half-width

    azimuthal_radii = np.linspace(peak_rad - spread, peak_rad + spread, num_profiles)
    azimuthal_indices = [np.searchsorted(rad, this_radius) for this_radius in azimuthal_radii]
    azimuthal_profiles = [vortensity[azimuthal_index, :] for azimuthal_index in azimuthal_indices]

    # For each profile, measure the azimuthal extent of the vortex (vortensity < threshold = 0.25)
    vortex_value = 360.0 / float(fargo_par["Nsec"])
    background_value = 0.0

    asymmetry_values = []
    avg_densities = []
    for azimuthal_profile in azimuthal_profiles:
        # Get Asymmetry
        copy = np.zeros(np.shape(azimuthal_profile))

        copy[azimuthal_profile > threshold] = background_value
        copy[azimuthal_profile <= threshold] = vortex_value

        azithumal_extent = np.sum(copy) # should be the angle spanned by the vortex (in degrees)
        asymmetry_values.append(azithumal_extent)

        # Get Vortensity
        copy = azimuthal_profile[azimuthal_profile <= threshold]

        avg_vortensity = np.mean(copy)
        avg_densities.append(avg_vortensity)

    # Take Median of Profiles between -H and +H about peak in radial density profile
    asymmetry = np.median(asymmetry_values)

    # Get Mean Density of Vortex within One Scale Height (+ 25% and 75% values)
    start = azimuthal_indices[0]
    end = azimuthal_indices[-1]
    vortex_zone = vortensity[start : end, :]

    vortex_vortensities = vortex_zone[vortex_zone < threshold]
    avg_vortensity = np.mean(vortex_vortensities)

    # Detect Nan
    if avg_vortensity != avg_vortensity:
        avg_vortensity = threshold
        lower_quartile = threshold
        upper_quartile = threshold
    else:
        # If no nan, compute quartiles
        lower_quartile = np.percentile(vortex_vortensities, 25) # 25%
        upper_quartile = np.percentile(vortex_vortensities, 75) # 75%

    return asymmetry, avg_vortensity, lower_quartile, upper_quartile
コード例 #22
0
def sum_vorticity(args):
    i, frame = args

    # Get Data
    density = (fromfile("gasdens%d.dat" % frame).reshape(
        num_rad, num_theta)) / surface_density_zero
    vrad = np.array(
        fromfile("gasvrad%d.dat" % frame).reshape(num_rad, num_theta))
    vtheta = np.array(
        fromfile("gasvtheta%d.dat" % frame).reshape(num_rad, num_theta))

    # Get Background Data
    vtheta_keplerian = np.array(
        fromfile("gasvtheta0.dat").reshape(num_rad, num_theta))

    # Subtract off Keplerian velocity (and rotate back into non-rotating frame???)
    vtheta -= (vtheta_keplerian)
    vorticity = util.velocity_curl(vrad, vtheta, rad, theta, frame=0)

    # Mask Non-Vortex Regions
    min_vorticity = -0.65

    vorticity[density[:-1, :-1] <
              0.45] = 0  # if density is too low, it's not in the vortex
    vorticity[
        vorticity > 0] = 0  # if vorticity is positive, it's not in the vortex
    vorticity[
        vorticity <
        min_vorticity] = min_vorticity  # if vorticity is too low, it's not in the vortex

    vorticity = np.abs(
        vorticity
    )  # everything that remains should be negative. switch to positive.

    # Extract Near Vortex
    averagedDensity = np.average(density, axis=1)
    peak_rad, peak_density = find_peak(averagedDensity)

    vortex_start = np.max([1.0, peak_rad - 5.0 * scale_height])
    vortex_end = peak_rad + 5.0 * scale_height

    vortex_start_i = np.searchsorted(rad, vortex_start)
    vortex_end_i = np.searchsorted(rad, vortex_end)

    vortex_rad = rad[vortex_start_i:vortex_end_i]
    vortex_vorticity_grid = vorticity[vortex_start_i:vortex_end_i]

    vortex_vorticity = np.average(vortex_vorticity_grid, axis=1)

    # Add up vorticity
    dr = rad[1] - rad[0]  # assumes arithmetic grid
    d_phi = theta[1] - theta[0]

    total_vorticity = np.sum(
        (dr * d_phi) * vortex_rad[:, None] * vortex_vorticity)

    ##### Instead: take max vorticity (90th percentile???) #####

    # Print Update
    print "%d: %.4f" % (frame, total_vorticity)

    # Store Data
    vorticity_over_time[i] = total_vorticity