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()
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()
def monitor_density_profile(system, i_step, time, n_steps, memory=Memory()): if i_step == 0: memory.xlimits = (None, None) memory.ylimits = (None, None) position = system.gas_particles.position - system.gas_particles.center_of_mass() loglog(position.lengths_squared(), system.gas_particles.density, 'gs') native_plot.title("{0}: t={1}".format(i_step, time.as_quantity_in(units.yr))) native_plot.xlim(memory.xlimits) native_plot.ylim(memory.ylimits) native_plot.pause(0.0001) memory.xlimits = native_plot.gca().get_xlim() memory.ylimits = native_plot.gca().get_ylim() if i_step == n_steps-1: native_plot.show(block=True) native_plot.cla()
def monitor_density_profile(system, i_step, time, n_steps, memory=Memory()): if i_step == 0: memory.xlimits = (None, None) memory.ylimits = (None, None) position = system.gas_particles.position - system.gas_particles.center_of_mass( ) loglog(position.lengths_squared(), system.gas_particles.density, 'gs') native_plot.title("{0}: t={1}".format(i_step, time.as_quantity_in(units.yr))) native_plot.xlim(memory.xlimits) native_plot.ylim(memory.ylimits) native_plot.pause(0.0001) memory.xlimits = native_plot.gca().get_xlim() memory.ylimits = native_plot.gca().get_ylim() if i_step == n_steps - 1: native_plot.show(block=True) native_plot.cla()
# the imports needed to read and write a set from amuse.io import write_set_to_file from amuse.io import read_set_from_file import os.path if __name__ == "__main__": if os.path.exists('plummer128.hdf'): os.remove('plummer128.hdf') # generate a particle set plummer=new_plummer_model(128) # write the set to file 'testfile' # the third argument is the file format, 'amuse' is an hdf5 based format # that saves all information. Other formats # available are e.g. csv, txt, gadget, starlab write_set_to_file(plummer,'plummer128.hdf','amuse') # reading back the file # we close the file, causing all data to be copied to memory # instead of being read from an open file particles=read_set_from_file('plummer128.hdf','amuse', close_file = True) # plotting plot(particles.x, particles.y,'r.') native_plot.xlim(-5,5) native_plot.ylim(-5,5) native_plot.show()
# the imports needed to read and write a set from amuse.io import write_set_to_file from amuse.io import read_set_from_file import os.path if __name__ == "__main__": if os.path.exists('plummer128.hdf'): os.remove('plummer128.hdf') # generate a particle set plummer = new_plummer_model(128) # write the set to file 'testfile' # the third argument is the file format, 'amuse' is an hdf5 based format # that saves all information. Other formats # available are e.g. csv, txt, gadget, starlab write_set_to_file(plummer, 'plummer128.hdf', 'amuse') # reading back the file # we close the file, causing all data to be copied to memory # instead of being read from an open file particles = read_set_from_file('plummer128.hdf', 'amuse', close_file=True) # plotting plot(particles.x, particles.y, 'r.') native_plot.xlim(-5, 5) native_plot.ylim(-5, 5) native_plot.show()