Пример #1
0
def make_plots(all_particles, disk_only, i=0):
    for j, particles in enumerate([all_particles, disk_only]):
        if HAS_PYNBODY:
            temp_particles = particles.copy()
            temp_particles.u = 1 | units.ms**2
            temp = Gadget2()
            temp.gas_particles.add_particles(temp_particles)
            temp.commit_particles()
            pynbody_column_density_plot(
                temp.gas_particles, width=300 | units.kpc, units='m_p cm^-2',
                vmin=17, vmax=23)
            temp.stop()
        else:
            native_plot.gca().set_aspect("equal")
            native_plot.xlim(-150, 150)
            native_plot.ylim(-150, 150)
            plot(particles.x.as_quantity_in(units.kpc),
                 particles.y.as_quantity_in(units.kpc), 'r.')

        native_plot.savefig(
                os.path.join(
                    "plots",
                    "plot_galaxy_merger_{0}_{1:=04}.png".format(
                        "disk" if j else "total", i)
                    )
                )
        native_plot.close()
Пример #2
0
def make_plots(all_particles, disk_only, i=0):
    for j, particles in enumerate([all_particles, disk_only]):
        if HAS_PYNBODY:
            temp_particles = particles.copy()
            temp_particles.u = 1 | units.ms**2
            temp = Gadget2()
            temp.gas_particles.add_particles(temp_particles)
            temp.commit_particles()
            pynbody_column_density_plot(temp.gas_particles,
                                        width=300 | units.kpc,
                                        units='m_p cm^-2',
                                        vmin=17,
                                        vmax=23)
            temp.stop()
        else:
            native_plot.gca().set_aspect("equal")
            native_plot.xlim(-150, 150)
            native_plot.ylim(-150, 150)
            plot(particles.x.as_quantity_in(units.kpc),
                 particles.y.as_quantity_in(units.kpc), 'r.')

        native_plot.savefig(
            os.path.join(
                "plots", "plot_galaxy_merger_{0}_{1:=04}.png".format(
                    "disk" if j else "total", i)))
        native_plot.close()
Пример #3
0
 def evolve_model(self, end_time):
     time_next_plot = self.time_last_plot + self._timestep
     while time_next_plot < end_time:
         super(PlottingHydrodynamics, self).__getattr__("evolve_model")(time_next_plot)
         self._plot_function(self.gas_particles, **self._plot_function_arguments)
         native_plot.savefig(self._next_filename())
         native_plot.close()
         self.time_last_plot = time_next_plot
         time_next_plot = self.time_last_plot + self._timestep
     super(PlottingHydrodynamics, self).__getattr__("evolve_model")(end_time)
def plot_plummer_model(N, M, R):
    sph_particles = plummer_model(N, M, R)
    x_label = "x [pc]"
    y_label = "y [pc]"
    figure, ax = figure_frame(x_label, y_label, xsize=12, ysize=12)
    sph_particles_plot(sph_particles, min_size = 500, max_size = 500, alpha=0.01, view=(-50, 50, -50, 50)|units.parsec)
    ax.set_axis_bgcolor('white')
    pyplot.xlabel(x_label)
    pyplot.ylabel(y_label)
    native_plot.savefig("plummer_projected")
Пример #5
0
def group_plot(groups, no_group, figname="group_plot.png"):
    colors = ["r", "g", "b", "y", "k", "w"]*100
    for group, color in zip(groups, colors):
        scatter(group.x, group.y, c=color)
    
    if len(no_group):
        scatter(no_group.x, no_group.y, c="m", marker="s")
    
    native_plot.gca().set_aspect("equal", adjustable = "datalim")
    native_plot.savefig(figname)
    native_plot.clf()
Пример #6
0
def group_plot(groups, no_group, figname="group_plot.png"):
    colors = ["r", "g", "b", "y", "k", "w"] * 100
    for group, color in zip(groups, colors):
        scatter(group.x, group.y, c=color)

    if len(no_group):
        scatter(no_group.x, no_group.y, c="m", marker="s")

    native_plot.gca().set_aspect("equal", adjustable="datalim")
    native_plot.savefig(figname)
    native_plot.clf()
def plot_stellar_model(N, M, t):
    sph_particles = stellar_model(N, M, t)
    x_label = "x [R$_\odot$]"
    y_label = "y [R$_\odot$]"
    figure, ax = figure_frame(x_label, y_label, xsize=12, ysize=12)
    sph_particles_plot(sph_particles, min_size = 500, max_size = 500, alpha=0.01, view=(-5, 5, -5, 5)|units.RSun)
#    sph_particles_plot(sph_particles, min_size = 500, max_size = 500, alpha=0.01, view=(-2, 2, -2, 2)|units.RSun)
    ax.set_axis_bgcolor('white')
    pyplot.xlabel(x_label)
    pyplot.ylabel(y_label)
    native_plot.savefig("stellar_2MSun_projected")
Пример #8
0
def energy_evolution_plot(time, kinetic, potential, thermal, figname="energy_evolution.png"):
    native_plot.subplot(211)
    plot(time, kinetic, label='K')
    plot(time, potential, label='U')
    plot(time, thermal, label='Q')
    plot(time, kinetic + potential + thermal, label='E')
    xlabel('Time')
    ylabel('Energy')
    native_plot.legend(prop={'size':"x-small"}, loc=4)
    native_plot.subplot(212)
    plot(time, thermal, label='Q')
    native_plot.savefig(figname)
    native_plot.clf()
Пример #9
0
def energy_evolution_plot(time, kinetic, potential, thermal, figname="energy_evolution.png"):
    native_plot.subplot(211)
    plot(time, kinetic, label='K')
    plot(time, potential, label='U')
    plot(time, thermal, label='Q')
    plot(time, kinetic + potential + thermal, label='E')
    xlabel('Time')
    ylabel('Energy')
    native_plot.legend(prop={'size':"x-small"}, loc=4)
    native_plot.subplot(212)
    plot(time, thermal, label='Q')
    native_plot.savefig(figname)
    native_plot.clf()
def plot_plummer_model(N, M, R):
    sph_particles = plummer_model(N, M, R)
    x_label = "x [pc]"
    y_label = "y [pc]"
    figure, ax = figure_frame(x_label, y_label, xsize=12, ysize=12)
    sph_particles_plot(sph_particles,
                       min_size=500,
                       max_size=500,
                       alpha=0.01,
                       view=(-50, 50, -50, 50) | units.parsec)
    ax.set_axis_bgcolor('white')
    pyplot.xlabel(x_label)
    pyplot.ylabel(y_label)
    native_plot.savefig("plummer_projected")
def plot_stellar_model(N, M, t):
    sph_particles = stellar_model(N, M, t)
    x_label = "x [R$_\odot$]"
    y_label = "y [R$_\odot$]"
    figure, ax = figure_frame(x_label, y_label, xsize=12, ysize=12)
    sph_particles_plot(sph_particles,
                       min_size=500,
                       max_size=500,
                       alpha=0.01,
                       view=(-5, 5, -5, 5) | units.RSun)
    #    sph_particles_plot(sph_particles, min_size = 500, max_size = 500, alpha=0.01, view=(-2, 2, -2, 2)|units.RSun)
    ax.set_axis_bgcolor('white')
    pyplot.xlabel(x_label)
    pyplot.ylabel(y_label)
    native_plot.savefig("stellar_2MSun_projected")