Пример #1
0
def re_eu_ratios(n):
    """
    Plot various isotope and element ratios of Re and Eu.
    Make three subplots:
    - Re/Eu
    - Re-isos/Eu-151
    - Re-isos/Eu-153
    """
    Eu_isos = ["Eu-151", "Eu-153"]
    Re_isos = ["Re-187", "Re-185"]
    fractions = ["Re/Eu"] \
                + [re+'/'+Eu_isos[0] for re in Re_isos] \
                + [re+'/'+Eu_isos[1] for re in Re_isos]
    spectro_notation = ['[' + frac + ']' for frac in fractions]

    #make instance of 'Omega'
    inst = om.omega(galaxy="milky_way",
                    special_timesteps=n,
                    ns_merger_on=True,
                    bhns_merger_on=True)
    plotter = vs.visualize(inst,
                           "test_omega",
                           num_yaxes=3,
                           age=0,
                           loa_spectro_abu=spectro_notation)

    for frac, index in zip(fractions, [0, 1, 1, 2, 2]):
        plotter.add_time_relabu_singleomega(frac, index_yaxis=index)
    limit = [-3, 0]
    plotter.zoom([False, limit, limit])
    plotter.finalize(save="test_rnscp_fraction_n%d" % n,
                     title="Re/Eu - fractions",
                     show=True)
    return None
Пример #2
0
def test_simple(n):
    """
    Just plot a simple standard MW-galaxy to make sure the 
    plotting syntax is up-to-date
    """
    inst = om.omega(galaxy="milky_way",
                    special_timesteps=n,
                    ns_merger_on=True,
                    bhns_merger_on=True)
    plotter = vs.visualize(inst, "test_omega", num_yaxes=3, age=0)

    Eu_isos = ["Eu-151", "Eu-153"]
    Re_isos = ["Re-187", "Re-185"]
    Os_isos = [
        "Os-184", "Os-186", "Os-187", "Os-188", "Os-189", "Os-190", "Os-192"
    ]

    for i, iso_list in enumerate([Eu_isos, Re_isos, Os_isos]):
        for iso in iso_list:
            plotter.add_time_relabu_singleomega(iso,
                                                index_yaxis=i,
                                                ylabel="log abundance")

    plotter.finalize(save="test_rncp_isos_n%d.png" % n,
                     show=True,
                     title="R-process isotopes of 'Omega'")
    return None
Пример #3
0
    def __initialisation(self):

        '''
        Read the merger tree and declare and fill arrays.

        '''

        # Run an OMEGA simulation in order to copy basic arrays
        #print ('Should add the r-process tables, extra_yields_table, etc...')
        self.o_ini = omega.omega(table=self.table, pop3_table=self.pop3_table,\
                                 special_timesteps=2, cte_sfr=0.0, mgal=1e10,\
                                 print_off=self.print_off)

        # Calculate the number of redshifts
        self.nb_redshifts = len(self.redshifts)

        # Declare the galaxy instance array
        self.galaxy_inst = [0]*self.nb_redshifts
        for i_i in range(0,self.nb_redshifts):
           self.galaxy_inst[i_i] = [0]*len(self.br_m_halo[i_i])

        # Declare the extra initial baryonic mass added to galaxies
        self.dm_bar_added_iso = [0.0]*self.nb_redshifts
        for i_i in range(0,self.nb_redshifts):
           self.dm_bar_added_iso[i_i] = np.zeros(\
               (len(self.br_m_halo[i_i]), self.o_ini.nb_isotopes))

        # Get the final redshift
        self.redshift_f = min(self.redshifts)

        # Get the primordial composition (mass fraction)
        iniabu_table = 'yield_tables/iniabu/iniab_bb_walker91.txt'
        ytables_bb = ry.read_yield_sn1a_tables( \
            os.path.join(nupy_path, iniabu_table), self.o_ini.history.isotopes)
        self.prim_x_frac = np.array(ytables_bb.get(quantity='Yields'))
        del ytables_bb

        # Define the information of whether branches are sub-halo or not
        if len(self.br_is_sub) > 0:
            self.is_sub_info = True
        else:
            self.is_sub_info = False
Пример #4
0
 def run_omega(self):
     from NuPyCEE import omega as o
     o1 = o.omega()
Пример #5
0
###################################
### Inflow must match Matteucci ###
###################################
inflow_matteucci = (0.3,1.5) #[M_sol/(Gyr pc^2)]
inflow = 10.0 #[M_sol/yr]

################################
### compile sets of 'Omega's ###
""" Vary parameters and find the best fit """
################################
if False: #test current parameters to make sure plotting works
    inst = om.omega(special_timesteps=n,
                    #dt=1.0e+3,
                    imf_type=imf_type,
                    sfh_file=sfh_file_relpath,
                    mgal=mgal,
                    m_DM_0=m_DM_0, stellar_mass_0=stellar_mass_0,
                    sn1a_on=False,
                    in_out_control=True,
                    inflow_rate=10.0, mass_loading=mass_loading,
                    ns_merger_on=True, f_merger=f_merger)
    #use visualize to compare 'Omega' and 'Eris'
    #compare spectroscopic data
    Harry_Plotter = vs.visualize(inst, "simple_test",
                                 num_yaxes=3) 
    Harry_Plotter.add_time_relabu('[O/H]', index_yaxis=0)
    Harry_Plotter.add_time_relabu('[Fe/H]', index_yaxis=1)
    Harry_Plotter.add_time_relabu('[Eu/H]', index_yaxis=2)
    Harry_Plotter.zoom([[-4,1],[-4,1],[-4,1]])
    Harry_Plotter.finalize(title="Spectroscopic plotting test in bestfitfile", save="test_spectro")
    #compare SN/KN-rates
    Harry_Plotter = vs.visualize(inst, "simple_test",
Пример #6
0
while len(test_array_bool) < num_tests:
    test_array_bool.append(False)
num_steps = 350

###########################################
### Tests various ways of inserting SFR ###
###########################################

#relative path to sfh-file from 'NuPyCEE'-directory
sfh_file_dir = "../reproduce_shen/"
sfh_file_relpath1 = sfh_file_dir+"time_sfr_Shen_2015.txt"
sfh_file_relpath2 = sfh_file_dir+"timegal5e8_sfr_Shen_2015.txt"

if test_all or test_array_bool[0]:
    print "First test, vanilla 'Omega'"
    om.omega(special_timesteps=num_steps)

if test_all or test_array_bool[1]:
    print "Second test, sfh-file"
    sfh_file_omega = om.omega(special_timesteps=num_steps,
                              sfh_file=sfh_file_relpath1)
    #plot sfr
    plotting_object = vs.visualize(sfh_file_omega,
                                   "Omega(sfh-file)",
                                   age=0)
    plotting_object.add_time_sfr()
    #plotting_object.add_tbirth()
    plotting_object.finalize(show=True)

    
if test_all or test_array_bool[2]:
Пример #7
0
def precompute_ssps(main_table="K10K06",
                    sn1a_table="I99",
                    pop3_table="HW10",
                    **kwargs):
    """
    Pre-calculate the ejecta of simple stellar populations.
    You can ignore the warning.

    Returns SSPs_in, kwargs (kwargs has to be passed to GAMMA run: see caga.generate_kwargs)
    
    agb/massive stars (main_table):
      K10K06 (default): Karakas10/Kobayashi06, no hypernovae
      nuK06: nugrid/Kobayashi06
      nuN13: nugrid/Nomoto13
      K10nu: Karakas10/nugrid
      nugrid (OMEGA default): nugrid_MESAonly_fryer12delay
    
    sn1a (sn1a_table):
      I99 (default): Iwamoto et al. 1999, W7

    pop3 (pop3_table):
      HW10 (default): Heger+Woosley 2010
      N13: Nomoto+2013
    
    All other kwargs are passed to omega (e.g. ns_merger_on)
    """
    ## Get file names of yield tables based on shortened keys, making things more consistent
    main_dict = {
        "K10K06": "agb_and_massive_stars_K10_K06_0.0HNe.txt",
        "nuK06": "agb_and_massive_stars_nugrid_K06.txt",
        "nuN13": "agb_and_massive_stars_nugrid_N13.txt",
        "K10nu": "agb_and_massive_stars_nugrid_K10.txt",
        "nugrid": "agb_and_massive_stars_nugrid_MESAonly_fryer12delay.txt",
        "C15K06": "agb_and_massive_stars_FRUITY_K06.txt",
    }
    main_table = "yield_tables/" + main_dict[main_table]
    sn1a_dict = {
        "I99": "sn1a_i99_W7.txt",
    }
    sn1a_table = "yield_tables/" + sn1a_dict[sn1a_table]
    pop3_dict = {
        "HW10": "popIII_heger10.txt",
        "N13": "popIII_N13.txt",
    }
    pop3_table = "yield_tables/" + pop3_dict[pop3_table]

    table_kwargs = {
        "table": main_table,
        "sn1a_table": sn1a_table,
        "pop3_table": pop3_table
    }
    kwargs.update(table_kwargs)

    o_for_SSPs = omega.omega(special_timesteps=2,
                             pre_calculate_SSPs=True,
                             **kwargs)
    # Copy the SSPs array
    SSPs_in = [
        o_for_SSPs.ej_SSP, o_for_SSPs.ej_SSP_coef, o_for_SSPs.dt_ssp,
        o_for_SSPs.t_ssp
    ]
    # Return both the SSPs array and the kwargs used to compute this, for passing into GAMMA
    return SSPs_in, kwargs
Пример #8
0
import NuPyCEE.omega as om
import visualize as vs

########################################################
### Run 'Omega' calculation with best-fit parameters ###
""" Best-fit parameters still in progress """
########################################################
num_steps = 140

#get SFR from Shen(2015)/'Eris'
sfh_file_dir = "../reproduce_shen/"
sfh_file_relpath = sfh_file_dir + "time_sfr_Shen_2015.txt"
### make instances of 'Omega' and 'visualize' ###
rncp_omega_obj = om.omega(special_timesteps=num_steps,
                          sfh_file=sfh_file_relpath,
                          imf_type="kroupa93",
                          ns_merger_on=True,
                          f_merger=0.01,
                          nb_nsm_per_m=0.5)
rncp_plot_obj = vs.visualize(rncp_omega_obj, r"$\Omega$", num_yaxes=3, age=0)
#subplot [Eu/H] for all data
rncp_plot_obj.add_time_relabu("[Eu/H]", 0)
#subplot [Eu/H], [Re/H], [Os/H] for 'Omega' data
rncp_plot_obj.add_time_relabu_singleomega("[Eu/H]", 1)
rncp_plot_obj.add_time_relabu_singleomega("[Os/H]", 1)
rncp_plot_obj.add_time_relabu_singleomega("[Re/H]", 1)
#subplot [Eu/H], [Re-187/H], [Os-187/H] for 'Omega' data
rncp_plot_obj.add_time_relabu_singleomega("[Eu/H]", 2)
rncp_plot_obj.add_time_relabu_singleomega("[Os-187/H]", 2)
rncp_plot_obj.add_time_relabu_singleomega("[Re-187/H]", 2)
#show
rncp_plot_obj.finalize(save="rncp_1.png",
Пример #9
0
    def __initialisation(self):
        '''
        Read the merger tree and declare and fill arrays.

        '''

        # Run an OMEGA simulation in order to copy basic arrays
        self.o_ini = omega.omega(table=self.kwargs["table"], \
                                 pop3_table=self.kwargs["pop3_table"],\
                                 special_timesteps=2, cte_sfr=0.0, \
                                 mgal=1e10, print_off=True)

        # Add NuPyCEE kwargs arguments to speed-up the initialization of branches
        self.kwargs["input_yields"] = True
        self.kwargs["ytables_in"] = self.o_ini.ytables
        self.kwargs["isotopes_in"] = self.o_ini.history.isotopes
        self.kwargs["ytables_1a_in"] = self.o_ini.ytables_1a
        self.kwargs["inter_Z_points"] = self.o_ini.inter_Z_points
        self.kwargs["nb_inter_Z_points"] = self.o_ini.nb_inter_Z_points
        self.kwargs["y_coef_M"] = self.o_ini.y_coef_M
        self.kwargs["y_coef_M_ej"] = self.o_ini.y_coef_M_ej
        self.kwargs["y_coef_Z_aM"] = self.o_ini.y_coef_Z_aM
        self.kwargs["y_coef_Z_bM"] = self.o_ini.y_coef_Z_bM
        self.kwargs["y_coef_Z_bM_ej"] = self.o_ini.y_coef_Z_bM_ej
        self.kwargs["tau_coef_M"] = self.o_ini.tau_coef_M
        self.kwargs["tau_coef_M_inv"] = self.o_ini.tau_coef_M_inv
        self.kwargs["tau_coef_Z_aM"] = self.o_ini.tau_coef_Z_aM
        self.kwargs["tau_coef_Z_bM"] = self.o_ini.tau_coef_Z_bM
        self.kwargs["tau_coef_Z_aM_inv"] = self.o_ini.tau_coef_Z_aM_inv
        self.kwargs["tau_coef_Z_bM_inv"] = self.o_ini.tau_coef_Z_bM_inv
        self.kwargs["y_coef_M_pop3"] = self.o_ini.y_coef_M_pop3
        self.kwargs["y_coef_M_ej_pop3"] = self.o_ini.y_coef_M_ej_pop3
        self.kwargs["tau_coef_M_pop3"] = self.o_ini.tau_coef_M_pop3
        self.kwargs["tau_coef_M_pop3_inv"] = self.o_ini.tau_coef_M_pop3_inv
        self.kwargs[
            "inter_lifetime_points_pop3"] = self.o_ini.inter_lifetime_points_pop3
        self.kwargs[
            "inter_lifetime_points_pop3_tree"] = self.o_ini.inter_lifetime_points_pop3_tree
        self.kwargs[
            "nb_inter_lifetime_points_pop3"] = self.o_ini.nb_inter_lifetime_points_pop3
        self.kwargs["inter_lifetime_points"] = self.o_ini.inter_lifetime_points
        self.kwargs[
            "inter_lifetime_points_tree"] = self.o_ini.inter_lifetime_points_tree
        self.kwargs[
            "nb_inter_lifetime_points"] = self.o_ini.nb_inter_lifetime_points
        self.kwargs[
            "nb_inter_M_points_pop3"] = self.o_ini.nb_inter_M_points_pop3
        self.kwargs[
            "inter_M_points_pop3_tree"] = self.o_ini.inter_M_points_pop3_tree
        self.kwargs["nb_inter_M_points"] = self.o_ini.nb_inter_M_points
        self.kwargs["inter_M_points"] = self.o_ini.inter_M_points
        self.kwargs["y_coef_Z_aM_ej"] = self.o_ini.y_coef_Z_aM_ej

        # Calculate the number of redshifts
        self.nb_redshifts = len(self.redshifts)

        # Declare the galaxy instance array
        self.galaxy_inst = [0] * self.nb_redshifts
        for i_i in range(0, self.nb_redshifts):
            self.galaxy_inst[i_i] = [0] * len(self.br_m_halo[i_i])

        # Declare the extra initial baryonic mass added to galaxies
        self.dm_bar_added_iso = [0.0] * self.nb_redshifts
        for i_i in range(0, self.nb_redshifts):
            self.dm_bar_added_iso[i_i] = np.zeros(\
                (len(self.br_m_halo[i_i]), self.o_ini.nb_isotopes))

        # Set the final redshift
        self.kwargs["redshift_f"] = min(self.redshifts)

        # Get the primordial composition (mass fraction)
        iniabu_table = 'yield_tables/iniabu/iniab_bb_walker91.txt'
        ytables_bb = ry.read_yields_Z( \
            os.path.join(nupy_path, iniabu_table), self.o_ini.history.isotopes)
        self.prim_x_frac = np.array(ytables_bb.get(Z=0.0, quantity='Yields'))
        del ytables_bb

        # Define the information of whether branches are sub-halo or not
        if len(self.br_is_sub) > 0:
            self.is_sub_info = True
        else:
            self.is_sub_info = False