def get_star_mass_coefficients(galaxies_by_id, galaxy_num): #time orig. in Gyr; use Myr to not have to convert it in hermite code time = [time_slice[1]*1.e3 for time_slice in galaxies_by_id[galaxy_num]] stellar_mass = [time_slice[3] for time_slice in galaxies_by_id[galaxy_num]] popt = galaxies_star_mass.get_func_coeffs(time, stellar_mass) stellar_mass_fitted = [10.**(galaxies_star_mass.poly_func(t, *tuple(popt))) for t in time] galaxies_star_mass.plot_stellar_mass(time, galaxy_num, stellar_mass, stellar_mass_fitted) plt.show() return popt
def plot_all_data(t_s, masses_fitted, galaxies_masses, galaxy_num, central_bh_mass, central_bh_mass_fitted, time, stellar_mass, stellar_mass_fitted): fig = plt.figure() ax1 = fig.add_subplot(2, 2, 1) ax1.semilogy(np.array(galaxies_masses[galaxy_num][1]), np.array(galaxies_masses[galaxy_num][2]), label='Orig data') ax1.semilogy(t_s, masses_fitted, label='Fitted data') ax1.set_xlabel('Time (Gyr)') ax1.set_ylabel('Galaxy Mass (Msun)') ax1.grid(b=True, which='major', color='g', linestyle='-') ax1.grid(b=True, which='minor', color='r', linestyle='--') ax1.legend(loc='best') ax1.set_title(''.join(['Galaxy ', galaxy_num, ' Mass Evolution'])) ax2 = fig.add_subplot(2, 2, 2) label = 'Orig data' merger_tree_plots.plot_central_bh_mass(central_bh_mass[:, 0], central_bh_mass[:, 1], galaxy_num, label) label = 'Fitted data' merger_tree_plots.plot_central_bh_mass(central_bh_mass_fitted[0], central_bh_mass_fitted[1], galaxy_num, label) ax3 = fig.add_subplot(2, 2, 3) galaxies_star_mass.plot_stellar_mass(time, galaxy_num, stellar_mass, stellar_mass_fitted) plt.show()