def integrated_u_merger_graphs2(): #step, mass = 20, [1e9, 1e10, 1e11] step, mass = 20, [1e4, 1e6, 1e8, 1e10, 1e11] mass_ratio = [10**(i / step) for i in range(-4 * step, 0)] legend = ['M = 10^{}'.format(str(int(math.log10(i)))) for i in mass] for z in [0.1, 1, 2]: mergers = [] for m in mass: mergers.append([]) for u in mass_ratio: mergers[-1].append( hmc.integrated_u_merger_correction(m, u, 1, z)) graph.line(mergers, x=mass_ratio, info={ 'xlog': True, 'ylog': True, 'ylim': [6e-4, 2e1], 'xlim': [1e-4, 1], 'xlabel': 'Min Mass Ratio', 'ylabel': 'Mergers / Gyr', 'comment': 'Z = {}'.format(z), 'legend': legend, 'legend_loc': 'upper right' }) plt.show()
def integrated_u_merger_graphs(): step, us = 10, [4, 10, 100, 1000] min_u = [1 / i for i in us] legend = ['u >= 1 / {}'.format(str(i)) for i in us] starts = [8, 8.2, 9.3, 10.3] mass = [[10**(i / step) for i in range(int(j * step), int(12 * step))] for j in starts] for z in [0.1, 1, 2]: mergers = [] for k, u in enumerate(min_u): mergers.append([]) for i in mass[k]: mergers[-1].append( hmc.integrated_u_merger_correction(i, u, 1, z)) graph.line(mergers, x=mass, info={ 'xlog': True, 'ylog': True, 'ylim': [3e-3, 2e1], 'xlim': [6e7, 2e12], 'xlabel': 'Mass', 'ylabel': 'Mergers / Gyr', 'comment': 'Z = {}'.format(z), 'legend': legend, 'legend_loc': 'upper left' }) plt.show()
def plot_by_loc(sfh, loc, info={}): to_plot = [] for i in range(len(sfh.names)): if sfh.get_loc()[i] == loc or loc == 'all': to_plot.append(sfh.mass[i]) #af1 = graph.line(to_plot, [10**i/1e9 for i in sfh.legend], dict({'title': loc}, **info)) af1 = graph.line(to_plot, [10**i/1e9 for i in sfh.legend], info) graph.line([add_median(to_plot)], [10**i/1e9 for i in sfh.legend], params={'linewidth': 4}, af1=af1)
def plot_by_type(sfh, typ, info={}): to_plot = [] for i in range(len(sfh.names)): if sfh.g_type[i] == typ or typ == 'all': to_plot.append(sfh.mass[i]) #af1 = graph.line(to_plot, [10**i/1e9 for i in sfh.legend], dict({'title': typ}, **info)) af1 = graph.line(to_plot, [10**i/1e9 for i in sfh.legend], info) graph.line([add_median(to_plot)], [10**i/1e9 for i in sfh.legend], params={'linewidth': 4}, af1=af1)
def percent_dead(z0): z1 = z_from_t(t_from_z(2) - 0.1) print(z0, z1) corr, x, uncorr = hmc.correct_smf(z0, z1) print(corr, x, uncorr) data = [1 - uncorr[i]/corr[i] for i in range(len(corr))] graph.line([data], x, info={'ylog':True}) graph.line([corr, uncorr], x, info={'ylog':True}) plt.show()
def percent_dead(z0): z1 = z_from_t(t_from_z(2) - 0.1) print(z0, z1) corr, x, uncorr = hmc.correct_smf(z0, z1) print(corr, x, uncorr) data = [1 - uncorr[i] / corr[i] for i in range(len(corr))] graph.line([data], x, info={'ylog': True}) graph.line([corr, uncorr], x, info={'ylog': True}) plt.show()
def z_graphs(): step = 10 x = [i / step for i in range(30)] y = [z_to_t.t_from_z(i) for i in x] graph.line( [y], x=x, info={ 'ylabel': 'Time (Gyr)', 'xlabel': 'Z', 'title': 'Lookback Time vs Redshift' }) plt.show()
def integrated_u_merger_graphs2(): #step, mass = 20, [1e9, 1e10, 1e11] step, mass = 20, [1e4, 1e6, 1e8, 1e10, 1e11] mass_ratio = [10**(i/step) for i in range(-4*step, 0)] legend = ['M = 10^{}'.format(str(int(math.log10(i)))) for i in mass] for z in [0.1, 1, 2]: mergers = [] for m in mass: mergers.append([]) for u in mass_ratio: mergers[-1].append(hmc.integrated_u_merger_correction(m, u, 1, z)) graph.line(mergers, x=mass_ratio, info={'xlog': True, 'ylog': True, 'ylim': [6e-4, 2e1], 'xlim': [1e-4, 1], 'xlabel': 'Min Mass Ratio', 'ylabel': 'Mergers / Gyr', 'comment': 'Z = {}'.format(z), 'legend': legend, 'legend_loc': 'upper right'}) plt.show()
def merger_graphs(): step, us= 10, [4, 10, 100, 1000] min_u = [1/i for i in us] legend = ['u = 1 / {}'.format(str(i)) for i in us] starts = [8, 8.6, 9.6, 10.6] mass = [[10**(i/step) for i in range(int(j*step), int(12.3*step))] for j in starts] for z in [0.1, 1, 2]: mergers = [] for k, u in enumerate(min_u): mergers.append([]) for i in mass[k]: mergers[-1].append(hmc.merger_correction(i, u, z)) graph.line(mergers, x=mass, info={'xlog': True, 'ylog': True, 'ylim': [1e-2, 1e4], 'xlim': [6e7, 2e12], 'xlabel': 'Mass', 'ylabel': 'Mergers / Gyr', 'comment': 'Z = {}'.format(z), 'legend': legend, 'legend_loc': 'upper left'}) plt.show()
def z_graphs(): step = 10 x = [i/step for i in range(30)] y = [z_to_t.t_from_z(i) for i in x] graph.line([y], x=x, info={'ylabel': 'Time (Gyr)', 'xlabel': 'Z', 'title': 'Lookback Time vs Redshift'}) plt.show()
import sys if __name__ == "__main__": d, step = data.schechter(), 1 start, masses = [8 + i / step for i in range(3 * step)], [] # For a variety of start masses # Find the number density at that mass at the highest Z (target) # Find the masses that have the same number density at all other Z # (binary search through all number densities until we find one that = the target. return the mass) for start_mass in start: masses.append([start_mass]) target = hs.param_double_schechter(start_mass, d.double[0][-1]) # Just Z for i in range(1, len(d.double)): masses[-1].append(hs.binary_search(target, d.double[i][-1])) print(masses) print(d.z_avg) info = { 'xlabel': r'$\mathregular{Z}$', 'ylabel': r'$\mathregular{log(M/M_\odot)}$', 'title': "Mass at constant number density over time", 'xlim': [0.35, 2.75], 'invert_xaxis': True } graph.line(masses, d.z_avg, info) graph.cut_line([2.75, 9.5], [0.35, 8]) plt.show()
""" import helpers.schechter as hs import helpers.data as data import helpers.graph as graph import matplotlib.pyplot as plt import sys if __name__ == "__main__": d, step = data.schechter(), 1 start, masses = [8 + i/step for i in range(3*step)], [] # For a variety of start masses # Find the number density at that mass at the highest Z (target) # Find the masses that have the same number density at all other Z # (binary search through all number densities until we find one that = the target. return the mass) for start_mass in start: masses.append([start_mass]) target = hs.param_double_schechter(start_mass, d.double[0][-1]) # Just Z for i in range(1, len(d.double)): masses[-1].append(hs.binary_search(target, d.double[i][-1])) print(masses) print(d.z_avg) info = {'xlabel': r'$\mathregular{Z}$', 'ylabel': r'$\mathregular{log(M/M_\odot)}$', 'title': "Mass at constant number density over time", 'xlim': [0.35, 2.75], 'invert_xaxis': True} graph.line(masses, d.z_avg, info) graph.cut_line([2.75, 9.5],[0.35, 8]) plt.show()
#!/usr/bin/env python3 ''' Finds the best approximation to the slow z_to_t formula ''' from os import path import sys sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) import math import helpers.z_to_t as z_to_t import matplotlib.pyplot as plt import helpers.graph as graph if __name__ == '__main__': zs = [i/10 for i in range(31)] res = [[],[]] for z in zs: res[0].append(z_to_t.old_t_from_z(z)) res[1].append(z_to_t.t_from_z(z)) graph.line(res, x=zs) ts = res[0] res = [[], []] for t in ts: res[0].append(z_to_t.old_z_from_t(t)) res[1].append(z_to_t.z_from_t(t)) graph.line(res, x=ts) plt.show()
info = {'xlabel': r'$\mathregular{log(M/M_\odot)}$', 'ylabel': r'$\mathregular{log(\phi / Mpc^3/dex)}$', 'legend': smf.z_range[-i:], 'xlim': [7.75, 12.25], 'ylim': [-5.75, -0.75]} params = {'marker': 'x'} graph.line(smf.smf[-i:], smf.mass, dict({'title': 'SMF'}, **info), params) ''' # Plot raw data: total, quiescent, star forming smf = data.smf() info = { 'xlabel': r'$\mathregular{log(M/M_\odot)}$', 'ylabel': r'$\mathregular{log(\phi / Mpc^3/dex)}$', 'legend': smf.z_range, 'xlim': [7.75, 12.25], 'ylim': [-5.75, -0.75] } params = {'marker': 'x'} graph.line(smf.smf, smf.mass, dict({'title': ''}, **info), params) graph.line(smf.sf_smf, smf.mass, dict({'title': "Star Forming SMF"}, **info), params) graph.line(smf.q_smf, smf.mass, dict({'title': "Quiescent SMF"}, **info), params) # Plot raw data: all 8 z bins on same graph info = { 'legend': ['SMF', 'SF_SMF', 'Q_SMF'], 'xlim': [7.75, 12.25], 'ylim': [-5.75, -0.75], 'xlabel8': r'$\mathregular{log(M/M_\odot)}$', 'ylabel8': r'$\mathregular{log(\phi / Mpc^3/dex)}$' } params = {'marker': 'x'} gs = graph.setup8(info)