From 52a7b083db65b36aa4b68e4cfca44ccde5c58ba4 Mon Sep 17 00:00:00 2001 From: folkert Date: Wed, 1 Mar 2023 14:57:49 +0000 Subject: [PATCH 01/34] Update the observational data to the most recent one --- observational_data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/observational_data b/observational_data index a3fdc9fe..aec5c536 160000 --- a/observational_data +++ b/observational_data @@ -1 +1 @@ -Subproject commit a3fdc9feadf6f7ad9c024a4e51da197afde21230 +Subproject commit aec5c536f1ead5cb13257610246e5ce8d449ea4d From d171d929d249e0027ff4f1fb2cb9f3e70832fa32 Mon Sep 17 00:00:00 2001 From: folkert Date: Wed, 1 Mar 2023 15:02:27 +0000 Subject: [PATCH 02/34] Update the config file and add the cosmic CC SN rate plot --- colibre/config.yml | 7 +- colibre/scripts/cosmic_CC_SN_rate.py | 161 +++++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 colibre/scripts/cosmic_CC_SN_rate.py diff --git a/colibre/config.yml b/colibre/config.yml index d11c30e6..f2a0f987 100644 --- a/colibre/config.yml +++ b/colibre/config.yml @@ -506,5 +506,10 @@ scripts: - filename: scripts/cosmic_SNIa_rate.py title: 'Cosmic SNIa rate' caption: SNIa rate history plotted directly from the SNIa.txt file produced by SWIFT. - section: SNIa Rate + section: SN Rate (cosmic) output_file: SNIa_rate_history.png + - filename: scripts/cosmic_CC_SN_rate.py + title: 'Cosmic CC SN rate' + caption: CC SN rate history plotted directly from the SNII.txt file produced by SWIFT. + section: SN Rate (cosmic) + output_file: CC_SN_rate_history.png diff --git a/colibre/scripts/cosmic_CC_SN_rate.py b/colibre/scripts/cosmic_CC_SN_rate.py new file mode 100644 index 00000000..c0858828 --- /dev/null +++ b/colibre/scripts/cosmic_CC_SN_rate.py @@ -0,0 +1,161 @@ +""" +Plots the cosmic CCSN rate history. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +from swiftpipeline.argumentparser import ScriptArgumentParser + +arguments = ScriptArgumentParser( + description="Creates a CC SN rate history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +CCSN_filenames = [f"{directory}/SNII.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.semilogx() + +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +CCSN_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) + +for idx, (snapshot_filename, CCSN_filename, name) in enumerate( + zip(snapshot_filenames, CCSN_filenames, names) +): + data = np.loadtxt( + CCSN_filename, + usecols=(4, 6, 11), + dtype=[("a", np.float32), ("z", np.float32), ("CC SN rate", np.float32)], + ) + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + CCSN_rate_units = 1.0 / (units.time * units.length ** 3) + + # a, Redshift, SFR + scale_factor = data["a"] + CC_SN_rate = (data["CC SN rate"] * CC_SN_rate_units).to(CC_SN_rate_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factor, CCSN_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicCCSNRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + ) + ) + observation_labels.append(f"{obs_data.citation}") + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc="center right" +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(0.0, 1.6) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel( + f"CC SN rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]" +) +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/CC_SN_rate_history.png") From aed82c1772e514586bc3cb5a6b1abd38e911c5e9 Mon Sep 17 00:00:00 2001 From: folkert Date: Mon, 6 Mar 2023 08:54:35 +0000 Subject: [PATCH 03/34] Include more cosmic SN rate plots into the pipeline --- colibre/auto_plotter/snia_rates.yml | 81 +++++++-- colibre/scripts/cosmic_CC_SN_rate.py | 11 +- colibre/scripts/cosmic_SNIa_rate.py | 8 +- colibre/scripts/cosmic_log_CC_SN_rate.py | 163 +++++++++++++++++++ colibre/scripts/cosmic_log_CEJSN_rate.py | 135 +++++++++++++++ colibre/scripts/cosmic_log_NSM_rate.py | 135 +++++++++++++++ colibre/scripts/cosmic_log_SNIa_rate.py | 163 +++++++++++++++++++ colibre/scripts/cosmic_log_collapsar_rate.py | 135 +++++++++++++++ 8 files changed, 807 insertions(+), 24 deletions(-) create mode 100644 colibre/scripts/cosmic_log_CC_SN_rate.py create mode 100644 colibre/scripts/cosmic_log_CEJSN_rate.py create mode 100644 colibre/scripts/cosmic_log_NSM_rate.py create mode 100644 colibre/scripts/cosmic_log_SNIa_rate.py create mode 100644 colibre/scripts/cosmic_log_collapsar_rate.py diff --git a/colibre/auto_plotter/snia_rates.yml b/colibre/auto_plotter/snia_rates.yml index 9d968293..fdc8a519 100644 --- a/colibre/auto_plotter/snia_rates.yml +++ b/colibre/auto_plotter/snia_rates.yml @@ -25,7 +25,7 @@ stellar_mass_snia_rates_50: metadata: title: Stellar Mass-SNIa rate relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) observational_data_bracket_width: 10.0 observational_data: - filename: GalaxyStellarMassSNIaRate/Kistler2014.hdf5 @@ -63,7 +63,7 @@ stellar_mass_snia_rates_active_only_50: metadata: title: Stellar Mass-SNIa rate relation (active only, 50 kpc aperture) caption: Uses a 50 kpc 3D aperture and only active galaxies. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) observational_data: - filename: GalaxyStellarMassSNIaRate/Smith2012_active.hdf5 - filename: GalaxyStellarMassSNIaRate/Graur2015_active.hdf5 @@ -99,7 +99,7 @@ stellar_mass_snia_rates_passive_only_50: metadata: title: Stellar Mass-SNIa rate relation (passive only, 50 kpc aperture) caption: Uses a 50 kpc 3D aperture and only passive galaxies. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) observational_data: - filename: GalaxyStellarMassSNIaRate/Smith2012_passive.hdf5 - filename: GalaxyStellarMassSNIaRate/Graur2015_passive.hdf5 @@ -132,7 +132,7 @@ stellar_mass_snia_rates_per_stellar_mass_50: metadata: title: Stellar Mass-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) observational_data_bracket_width: 10.0 observational_data: - filename: GalaxyStellarMassSNIaRatePerStellarMass/Kistler2014.hdf5 @@ -170,7 +170,7 @@ stellar_mass_snia_rates_per_stellar_mass_active_only_50: metadata: title: Stellar Mass-SNIa rate per stellar mass relation (active only, 50 kpc aperture) caption: Uses a 50 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) observational_data: - filename: GalaxyStellarMassSNIaRatePerStellarMass/Smith2012_active.hdf5 - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015_active.hdf5 @@ -206,7 +206,7 @@ stellar_mass_snia_rates_per_stellar_mass_passive_only_50: metadata: title: Stellar Mass-SNIa rate per stellar mass relation (passive only, 50 kpc aperture) caption: Uses a 50 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) observational_data: - filename: GalaxyStellarMassSNIaRatePerStellarMass/Smith2012_passive.hdf5 - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015_passive.hdf5 @@ -243,7 +243,7 @@ gas_metallicity_snia_rates_per_stellar_mass_active_only_50: metadata: title: Gas metallicity-SNIa rate per stellar mass relation (active only, 50 kpc aperture) caption: Uses a 50 kpc 3D aperture, active galaxies only with a stellar mass above 1e10 Msun. - section: SNIa Rate + section: SNIa Rate (Gas Metallicity) observational_data: - filename: GalaxyGasMetallicitySNIaRatePerStellarMass/Graur2017.hdf5 @@ -278,7 +278,7 @@ gas_metallicity_snia_rates_per_stellar_mass_active_only_50_Mstar5e10: metadata: title: Gas metallicity-SNIa rate per stellar mass relation (active only, 50 kpc aperture) caption: Uses a 50 kpc 3D aperture, active galaxies only with a stellar mass above 5e10 Msun. - section: SNIa Rate + section: SNIa Rate (Gas Metallicity) observational_data: - filename: GalaxyGasMetallicitySNIaRatePerStellarMass/Graur2017.hdf5 @@ -312,7 +312,7 @@ star_formation_rates_snia_rates_per_stellar_mass_50: metadata: title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. - section: SNIa Rate + section: SNIa Rate (SFR and sSFR) observational_data: - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - filename: StarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 @@ -347,14 +347,17 @@ star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: metadata: title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 5e10 Msun. - section: SNIa Rate + section: SNIa Rate (SFR and sSFR) observational_data: - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - filename: StarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 star_formation_rates_snia_rates_50: + comment: "$M_\\star > 10^{10}$ $M_\\odot$" + comment_loc: "lower left" type: "scatter" legend_loc: "upper left" + selection_mask: "derived_quantities.stellar_mass_is_bigger_than_1e10_msun_50_kpc" x: quantity: "apertures.sfr_gas_50_kpc" units: "Solar_Mass/year" @@ -378,9 +381,45 @@ star_formation_rates_snia_rates_50: units: "Solar_Mass/year" metadata: title: SFR-SNIa rate relation (50 kpc aperture) - caption: Uses a 50 kpc 3D aperture. - section: SNIa Rate + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. + section: SNIa Rate (SFR and sSFR) + observational_data: + - filename: StarFormationRateSNIaRate/Sullivan2006.hdf5 + - filename: StarFormationRateSNIaRate/Smith2012.hdf5 + +star_formation_rates_snia_rates_50_Mstar5e10: + comment: "$M_\\star > 5 \\times 10^{10}$ $M_\\odot$" + comment_loc: "lower left" + type: "scatter" + legend_loc: "upper left" + selection_mask: "derived_quantities.stellar_mass_is_bigger_than_5e10_msun_50_kpc" + x: + quantity: "apertures.sfr_gas_50_kpc" + units: "Solar_Mass/year" + start: 1e-3 + end: 1e2 + y: + quantity: "snia_rates.snia_rates_50_kpc" + units: "1/year" + start: 1e-6 + end: 1e-1 + mean: + plot: true + log: true + adaptive: true + number_of_bins: 30 + start: + value: 1e-3 + units: "Solar_Mass/year" + end: + value: 1e2 + units: "Solar_Mass/year" + metadata: + title: SFR-SNIa rate relation (50 kpc aperture) + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. + section: SNIa Rate (SFR and sSFR) observational_data: + - filename: StarFormationRateSNIaRate/Sullivan2006.hdf5 - filename: StarFormationRateSNIaRate/Smith2012.hdf5 specific_star_formation_rates_snia_rates_per_stellar_mass_50: @@ -413,8 +452,11 @@ specific_star_formation_rates_snia_rates_per_stellar_mass_50: metadata: title: sSFR-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. - section: SNIa Rate + section: SNIa Rate (SFR and sSFR) observational_data: + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Mannucci2005.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Sullivan2006.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Smith2012.hdf5 - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 @@ -448,8 +490,11 @@ specific_star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: metadata: title: sSFR-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 5e10 Msun. - section: SNIa Rate + section: SNIa Rate (SFR and sSFR) observational_data: + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Mannucci2005.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Sullivan2006.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Smith2012.hdf5 - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 @@ -480,7 +525,7 @@ stellar_mass_snia_rates_30: metadata: title: Stellar Mass-SNIa rate relation (50 kpc aperture) caption: Uses a 30 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) show_on_webpage: false observational_data: - filename: GalaxyStellarMassSNIaRate/Wiseman2021.hdf5 @@ -512,7 +557,7 @@ stellar_mass_snia_rates_per_stellar_mass_30: metadata: title: Stellar Mass-SNIa rate per stellar mass relation (30 kpc aperture) caption: Uses a 30 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) show_on_webpage: false observational_data: - filename: GalaxyStellarMassSNIaRatePerStellarMass/Wiseman2021.hdf5 @@ -546,7 +591,7 @@ stellar_mass_snia_rates_100: metadata: title: Stellar Mass-SNIa rate relation (100 kpc aperture) caption: Uses a 30 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) show_on_webpage: false observational_data: - filename: GalaxyStellarMassSNIaRate/Wiseman2021.hdf5 @@ -578,7 +623,7 @@ stellar_mass_snia_rates_per_stellar_mass_100: metadata: title: Stellar Mass-SNIa rate per stellar mass relation (100 kpc aperture) caption: Uses a 30 kpc 3D aperture. - section: SNIa Rate + section: SNIa Rate (Stellar Mass) show_on_webpage: false observational_data: - filename: GalaxyStellarMassSNIaRatePerStellarMass/Wiseman2021.hdf5 diff --git a/colibre/scripts/cosmic_CC_SN_rate.py b/colibre/scripts/cosmic_CC_SN_rate.py index c0858828..047878f4 100644 --- a/colibre/scripts/cosmic_CC_SN_rate.py +++ b/colibre/scripts/cosmic_CC_SN_rate.py @@ -41,7 +41,7 @@ log_multiplicative_factor = 4 multiplicative_factor = 10 ** log_multiplicative_factor -CCSN_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) +CC_SN_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) for idx, (snapshot_filename, CCSN_filename, name) in enumerate( zip(snapshot_filenames, CCSN_filenames, names) @@ -59,7 +59,7 @@ cosmology = snapshot.metadata.cosmology units = snapshot.units - CCSN_rate_units = 1.0 / (units.time * units.length ** 3) + CC_SN_rate_units = 1.0 / (units.time * units.length ** 3) # a, Redshift, SFR scale_factor = data["a"] @@ -67,7 +67,7 @@ # High z-order as we always want these to be on top of the observations simulation_lines.append( - ax.plot(scale_factor, CCSN_rate.value * multiplicative_factor, zorder=10000)[0] + ax.plot(scale_factor, CC_SN_rate.value * multiplicative_factor, zorder=10000)[0] ) simulation_labels.append(name) @@ -117,7 +117,7 @@ ax.set_xticklabels(redshift_labels) observation_legend = ax.legend( - observation_lines, observation_labels, markerfirst=True, loc="center right" + observation_lines, observation_labels, markerfirst=True, loc="center right", fontsize="xx-small" ) simulation_legend = ax.legend( @@ -148,7 +148,7 @@ ax.tick_params(axis="x", which="minor", bottom=False) ax2.tick_params(axis="x", which="minor", top=False) -ax.set_ylim(0.0, 1.6) +ax.set_ylim(0.0, 26.0) ax.set_xlim(1.02, 0.07) ax2.set_xlim(1.02, 0.07) @@ -159,3 +159,4 @@ ax2.set_xlabel("Cosmic time [Gyr]") fig.savefig(f"{output_path}/CC_SN_rate_history.png") + diff --git a/colibre/scripts/cosmic_SNIa_rate.py b/colibre/scripts/cosmic_SNIa_rate.py index b440b3d1..1d76f696 100644 --- a/colibre/scripts/cosmic_SNIa_rate.py +++ b/colibre/scripts/cosmic_SNIa_rate.py @@ -93,6 +93,7 @@ markeredgecolor="none", markersize=2, zorder=-10, + capsize=1.0, ) ) observation_labels.append(f"{obs_data.citation}") @@ -117,7 +118,7 @@ ax.set_xticklabels(redshift_labels) observation_legend = ax.legend( - observation_lines, observation_labels, markerfirst=True, loc="center right" + observation_lines, observation_labels, markerfirst=True, loc="lower right", fontsize="xx-small", ncol=2 ) simulation_legend = ax.legend( @@ -159,3 +160,8 @@ ax2.set_xlabel("Cosmic time [Gyr]") fig.savefig(f"{output_path}/SNIa_rate_history.png") + +ax.set_xlim(1.02, 0.33) +ax2.set_xlim(1.02, 0.33) + +fig.savefig(f"{output_path}/SNIa_rate_history_zoom.png") diff --git a/colibre/scripts/cosmic_log_CC_SN_rate.py b/colibre/scripts/cosmic_log_CC_SN_rate.py new file mode 100644 index 00000000..9ce833a1 --- /dev/null +++ b/colibre/scripts/cosmic_log_CC_SN_rate.py @@ -0,0 +1,163 @@ +""" +Plots the cosmic CCSN rate history. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +from swiftpipeline.argumentparser import ScriptArgumentParser + +arguments = ScriptArgumentParser( + description="Creates a CC SN rate history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +CCSN_filenames = [f"{directory}/SNII.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.semilogx() + +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +CC_SN_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) + +for idx, (snapshot_filename, CCSN_filename, name) in enumerate( + zip(snapshot_filenames, CCSN_filenames, names) +): + data = np.loadtxt( + CCSN_filename, + usecols=(4, 6, 11), + dtype=[("a", np.float32), ("z", np.float32), ("CC SN rate", np.float32)], + ) + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + CC_SN_rate_units = 1.0 / (units.time * units.length ** 3) + + # a, Redshift, SFR + scale_factor = data["a"] + CC_SN_rate = (data["CC SN rate"] * CC_SN_rate_units).to(CC_SN_rate_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factor, CC_SN_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicCCSNRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + ) + ) + observation_labels.append(f"{obs_data.citation}") + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc="center right", fontsize="xx-small" +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") +ax.set_yscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(1e-1, 3e1) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel( + f"CC SN rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]" +) +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_CC_SN_rate_history.png") + diff --git a/colibre/scripts/cosmic_log_CEJSN_rate.py b/colibre/scripts/cosmic_log_CEJSN_rate.py new file mode 100644 index 00000000..a81c5985 --- /dev/null +++ b/colibre/scripts/cosmic_log_CEJSN_rate.py @@ -0,0 +1,135 @@ +""" +Plots the cosmic r_process rate history. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +from swiftpipeline.argumentparser import ScriptArgumentParser + +arguments = ScriptArgumentParser( + description="Creates a r-process rate history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +r_process_filenames = [f"{directory}/r_processes.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.semilogx() + +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +r_process_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) + +for idx, (snapshot_filename, r_process_filename, name) in enumerate( + zip(snapshot_filenames, r_process_filenames, names) +): + data = np.loadtxt( + r_process_filename, + usecols=(2,3, 4, 6, 14, 15, 16), + dtype=[("t2", np.float32), ("t1", np.float32), ("a", np.float32), ("z", np.float32), ("NSM", np.float32), ("CEJSN", np.float32), ("collapsar", np.float32)], + ) + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + r_process_rate_units = 1.0 / (units.time * units.length ** 3) + + dt = (data["t2"] - data["t1"]) * 1e5 + + # a, Redshift, SFR + scale_factor = data["a"] + NSM_rate = (data["NSM"] /dt * r_process_rate_units).to(r_process_rate_output_units) + CEJSN_rate = (data["CEJSN"]/dt * r_process_rate_units).to(r_process_rate_output_units) + collapsar_rate = (data["collapsar"]/dt * r_process_rate_units).to(r_process_rate_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factor, CEJSN_rate.value * multiplicative_factor, zorder=10000, linestyle="--")[0] + ) + simulation_labels.append(name) + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") +ax.set_yscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(1e-5, 1e-1) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel( + f"Common-envelop jets SN rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]" +) +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_CEJSN_rate_history.png") diff --git a/colibre/scripts/cosmic_log_NSM_rate.py b/colibre/scripts/cosmic_log_NSM_rate.py new file mode 100644 index 00000000..7abcd1c5 --- /dev/null +++ b/colibre/scripts/cosmic_log_NSM_rate.py @@ -0,0 +1,135 @@ +""" +Plots the cosmic r_process rate history. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +from swiftpipeline.argumentparser import ScriptArgumentParser + +arguments = ScriptArgumentParser( + description="Creates a r-process rate history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +r_process_filenames = [f"{directory}/r_processes.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.semilogx() + +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +r_process_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) + +for idx, (snapshot_filename, r_process_filename, name) in enumerate( + zip(snapshot_filenames, r_process_filenames, names) +): + data = np.loadtxt( + r_process_filename, + usecols=(2,3, 4, 6, 14, 15, 16), + dtype=[("t2", np.float32), ("t1", np.float32), ("a", np.float32), ("z", np.float32), ("NSM", np.float32), ("CEJSN", np.float32), ("collapsar", np.float32)], + ) + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + r_process_rate_units = 1.0 / (units.time * units.length ** 3) + + dt = (data["t2"] - data["t1"]) * 1e5 + + # a, Redshift, SFR + scale_factor = data["a"] + NSM_rate = (data["NSM"] /dt * r_process_rate_units).to(r_process_rate_output_units) + CEJSN_rate = (data["CEJSN"]/dt * r_process_rate_units).to(r_process_rate_output_units) + collapsar_rate = (data["collapsar"]/dt * r_process_rate_units).to(r_process_rate_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factor, NSM_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") +ax.set_yscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(1e-5, 1e-1) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel( + f"NS-NS merger rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]" +) +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_NSM_rate_history.png") diff --git a/colibre/scripts/cosmic_log_SNIa_rate.py b/colibre/scripts/cosmic_log_SNIa_rate.py new file mode 100644 index 00000000..8047737a --- /dev/null +++ b/colibre/scripts/cosmic_log_SNIa_rate.py @@ -0,0 +1,163 @@ +""" +Plots the cosmic SNIa rate history. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +from swiftpipeline.argumentparser import ScriptArgumentParser + +arguments = ScriptArgumentParser( + description="Creates a SNIa rate history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +SNIa_filenames = [f"{directory}/SNIa.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.semilogx() + +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +SNIa_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) + +for idx, (snapshot_filename, SNIa_filename, name) in enumerate( + zip(snapshot_filenames, SNIa_filenames, names) +): + data = np.loadtxt( + SNIa_filename, + usecols=(4, 6, 11), + dtype=[("a", np.float32), ("z", np.float32), ("SNIa rate", np.float32)], + ) + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + SNIa_rate_units = 1.0 / (units.time * units.length ** 3) + + # a, Redshift, SFR + scale_factor = data["a"] + SNIa_rate = (data["SNIa rate"] * SNIa_rate_units).to(SNIa_rate_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factor, SNIa_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicSNIaRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + capsize=1.0, + ) + ) + observation_labels.append(f"{obs_data.citation}") + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc="lower right", fontsize="xx-small", ncol=2 +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") +ax.set_yscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(3e-2, 2.0) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel( + f"SNIa rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]" +) +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_SNIa_rate_history.png") diff --git a/colibre/scripts/cosmic_log_collapsar_rate.py b/colibre/scripts/cosmic_log_collapsar_rate.py new file mode 100644 index 00000000..353373ec --- /dev/null +++ b/colibre/scripts/cosmic_log_collapsar_rate.py @@ -0,0 +1,135 @@ +""" +Plots the cosmic r_process rate history. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +from swiftpipeline.argumentparser import ScriptArgumentParser + +arguments = ScriptArgumentParser( + description="Creates a r-process rate history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +r_process_filenames = [f"{directory}/r_processes.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.semilogx() + +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +r_process_rate_output_units = 1.0 / (unyt.yr * unyt.Mpc ** 3) + +for idx, (snapshot_filename, r_process_filename, name) in enumerate( + zip(snapshot_filenames, r_process_filenames, names) +): + data = np.loadtxt( + r_process_filename, + usecols=(2,3, 4, 6, 14, 15, 16), + dtype=[("t2", np.float32), ("t1", np.float32), ("a", np.float32), ("z", np.float32), ("NSM", np.float32), ("CEJSN", np.float32), ("collapsar", np.float32)], + ) + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + r_process_rate_units = 1.0 / (units.time * units.length ** 3) + + dt = (data["t2"] - data["t1"]) * 1e5 + + # a, Redshift, SFR + scale_factor = data["a"] + NSM_rate = (data["NSM"] /dt * r_process_rate_units).to(r_process_rate_output_units) + CEJSN_rate = (data["CEJSN"]/dt * r_process_rate_units).to(r_process_rate_output_units) + collapsar_rate = (data["collapsar"]/dt * r_process_rate_units).to(r_process_rate_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factor, collapsar_rate.value * multiplicative_factor, zorder=10000, linestyle="-.")[0] + ) + simulation_labels.append(name) + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") +ax.set_yscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(1e-5, 2.0) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel( + f"Collapsar rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]" +) +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_collapsar_rate_history.png") From cc035b975e83e768cdc1ae6cebcdea59792ad1a2 Mon Sep 17 00:00:00 2001 From: folkert Date: Wed, 8 Mar 2023 10:36:03 +0000 Subject: [PATCH 04/34] Add description for the SNIa DTD models --- colibre/description.html | 93 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/colibre/description.html b/colibre/description.html index eb1ce987..d14ee3be 100644 --- a/colibre/description.html +++ b/colibre/description.html @@ -379,6 +379,99 @@

Chemistry

+

SNIa DTD

+{% if data.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", False) %} + + + + + + {% if data.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False) %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% else %} + + + + + + + + + + + + + + + + + + + {% if data.metadata.parameters.get("SNIaDTD:power_law_slope", False) %} + + {% else %} + + {% endif %} + + {% endif %} +
ParameterValue
ModelGaussian
SNIa efficiency per Msun (Gaussian part){{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_efficiency_gauss_p_Msun") }}
SNIa efficiency per Msun (constant part){{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_efficiency_const_p_Msun") }}
SNIa delay time{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_delay_time_Gyr") }} Gyr
Normalisation time scale (constant part){{ data.metadata.parameters | get_if_present_float("SNIaDTD:normalization_timescale_Gyr") }} Gyr
Characteristic time of the Guassian{{ data.metadata.parameters | get_if_present_float("SNIaDTD:characteristic_time_Gyr") }} Gyr
Standard deviation time of the Guassian{{ data.metadata.parameters | get_if_present_float("SNIaDTD:STD_characteristic_time_Gyr") }} Gyr
ModelPower law
SNIa efficiency per Msun{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_efficiency_p_Msun") }}
SNIa delay time{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_delay_time_Gyr") }} Gyr
Normalisation time scale{{ data.metadata.parameters | get_if_present_float("SNIaDTD:normalization_timescale_Gyr") }} Gyr
power law slope{{ data.metadata.parameters | get_if_present_float("SNIaDTD:power_law_slope") }}1.0
+ +{% else %} +{% if data.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", False) %} + + + + + + + + + + + + + + + + + + + + + +
ParameterValue
Modelexponential
SNIa efficiency per Msun{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_efficiency_p_Msun") }}
SNIa delay time{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_delay_time_Gyr") }} Gyr
exponential delay time{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_timescale_Gyr") }} Gyr
+{% else %} +

DTD not found

+{% endif %} +{% endif %} +

AGN feedback

{% if data.metadata.parameters.get("COLIBREAGN:AGN_delta_T_K", False) %} From f5a1eda94b059b811ec31a68aec098173ce33e21 Mon Sep 17 00:00:00 2001 From: folkert Date: Wed, 8 Mar 2023 10:36:27 +0000 Subject: [PATCH 05/34] Update the CEJSN, NSM and collapsar rate plots --- colibre/scripts/cosmic_log_CEJSN_rate.py | 11 +++++++---- colibre/scripts/cosmic_log_NSM_rate.py | 11 +++++++---- colibre/scripts/cosmic_log_collapsar_rate.py | 11 +++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/colibre/scripts/cosmic_log_CEJSN_rate.py b/colibre/scripts/cosmic_log_CEJSN_rate.py index a81c5985..1b6dc4ef 100644 --- a/colibre/scripts/cosmic_log_CEJSN_rate.py +++ b/colibre/scripts/cosmic_log_CEJSN_rate.py @@ -61,13 +61,16 @@ units = snapshot.units r_process_rate_units = 1.0 / (units.time * units.length ** 3) - dt = (data["t2"] - data["t1"]) * 1e5 + volume = snapshot.metadata.boxsize[0] * snapshot.metadata.boxsize[1]* snapshot.metadata.boxsize[2] + volume.convert_to_units("Mpc**3") + + dt = (data["t2"] - data["t1"]) # a, Redshift, SFR scale_factor = data["a"] - NSM_rate = (data["NSM"] /dt * r_process_rate_units).to(r_process_rate_output_units) - CEJSN_rate = (data["CEJSN"]/dt * r_process_rate_units).to(r_process_rate_output_units) - collapsar_rate = (data["collapsar"]/dt * r_process_rate_units).to(r_process_rate_output_units) + NSM_rate = (data["NSM"]/volume.value /dt * r_process_rate_units).to(r_process_rate_output_units) + CEJSN_rate = (data["CEJSN"]/volume.value/dt * r_process_rate_units).to(r_process_rate_output_units) + collapsar_rate = (data["collapsar"]/volume.value/dt * r_process_rate_units).to(r_process_rate_output_units) # High z-order as we always want these to be on top of the observations simulation_lines.append( diff --git a/colibre/scripts/cosmic_log_NSM_rate.py b/colibre/scripts/cosmic_log_NSM_rate.py index 7abcd1c5..b18fb303 100644 --- a/colibre/scripts/cosmic_log_NSM_rate.py +++ b/colibre/scripts/cosmic_log_NSM_rate.py @@ -60,14 +60,17 @@ units = snapshot.units r_process_rate_units = 1.0 / (units.time * units.length ** 3) + + volume = snapshot.metadata.boxsize[0] * snapshot.metadata.boxsize[1]* snapshot.metadata.boxsize[2] + volume.convert_to_units("Mpc**3") - dt = (data["t2"] - data["t1"]) * 1e5 + dt = (data["t2"] - data["t1"]) # a, Redshift, SFR scale_factor = data["a"] - NSM_rate = (data["NSM"] /dt * r_process_rate_units).to(r_process_rate_output_units) - CEJSN_rate = (data["CEJSN"]/dt * r_process_rate_units).to(r_process_rate_output_units) - collapsar_rate = (data["collapsar"]/dt * r_process_rate_units).to(r_process_rate_output_units) + NSM_rate = (data["NSM"]/volume.value /dt * r_process_rate_units).to(r_process_rate_output_units) + CEJSN_rate = (data["CEJSN"]/volume.value/dt * r_process_rate_units).to(r_process_rate_output_units) + collapsar_rate = (data["collapsar"]/volume.value/dt * r_process_rate_units).to(r_process_rate_output_units) # High z-order as we always want these to be on top of the observations simulation_lines.append( diff --git a/colibre/scripts/cosmic_log_collapsar_rate.py b/colibre/scripts/cosmic_log_collapsar_rate.py index 353373ec..1c945a50 100644 --- a/colibre/scripts/cosmic_log_collapsar_rate.py +++ b/colibre/scripts/cosmic_log_collapsar_rate.py @@ -61,13 +61,16 @@ units = snapshot.units r_process_rate_units = 1.0 / (units.time * units.length ** 3) - dt = (data["t2"] - data["t1"]) * 1e5 + volume = snapshot.metadata.boxsize[0] * snapshot.metadata.boxsize[1]* snapshot.metadata.boxsize[2] + volume.convert_to_units("Mpc**3") + + dt = (data["t2"] - data["t1"]) # a, Redshift, SFR scale_factor = data["a"] - NSM_rate = (data["NSM"] /dt * r_process_rate_units).to(r_process_rate_output_units) - CEJSN_rate = (data["CEJSN"]/dt * r_process_rate_units).to(r_process_rate_output_units) - collapsar_rate = (data["collapsar"]/dt * r_process_rate_units).to(r_process_rate_output_units) + NSM_rate = (data["NSM"]/volume.value /dt * r_process_rate_units).to(r_process_rate_output_units) + CEJSN_rate = (data["CEJSN"]/volume.value/dt * r_process_rate_units).to(r_process_rate_output_units) + collapsar_rate = (data["collapsar"]/volume.value/dt * r_process_rate_units).to(r_process_rate_output_units) # High z-order as we always want these to be on top of the observations simulation_lines.append( From 599ed8e014dbc11e16561ab305b6aa30554f5c06 Mon Sep 17 00:00:00 2001 From: folkert Date: Tue, 14 Mar 2023 09:31:06 +0000 Subject: [PATCH 06/34] Incorparate new ordered plots and improve the ordering of the plots --- colibre/auto_plotter/snia_rates.yml | 208 ++++++++++++++-------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/colibre/auto_plotter/snia_rates.yml b/colibre/auto_plotter/snia_rates.yml index fdc8a519..03564ba2 100644 --- a/colibre/auto_plotter/snia_rates.yml +++ b/colibre/auto_plotter/snia_rates.yml @@ -1,4 +1,4 @@ -stellar_mass_snia_rates_50: +stellar_mass_snia_rates_per_stellar_mass_50: type: "scatter" legend_loc: "upper left" x: @@ -7,10 +7,10 @@ stellar_mass_snia_rates_50: start: 1e6 end: 1e12 y: - quantity: "snia_rates.snia_rates_50_kpc" - units: "1/year" - start: 3e-8 - end: 1e-1 + quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" + units: "1/year/Solar_Mass" + start: 3e-15 + end: 3e-12 mean: plot: true log: true @@ -23,17 +23,17 @@ stellar_mass_snia_rates_50: value: 1e12 units: Solar_Mass metadata: - title: Stellar Mass-SNIa rate relation (50 kpc aperture) + title: Stellar Mass-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture. section: SNIa Rate (Stellar Mass) observational_data_bracket_width: 10.0 observational_data: - - filename: GalaxyStellarMassSNIaRate/Kistler2014.hdf5 - - filename: GalaxyStellarMassSNIaRate/Graur2015.hdf5 - - filename: GalaxyStellarMassSNIaRate/Graur2017.hdf5 - - filename: GalaxyStellarMassSNIaRate/Wiseman2021.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Kistler2014.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Wiseman2021.hdf5 -stellar_mass_snia_rates_active_only_50: +stellar_mass_snia_rates_per_stellar_mass_active_only_50: type: "scatter" comment: "Active only" comment_loc: "lower left" @@ -45,10 +45,10 @@ stellar_mass_snia_rates_active_only_50: start: 1e6 end: 1e12 y: - quantity: "snia_rates.snia_rates_50_kpc" - units: "1/year" - start: 3e-8 - end: 1e-1 + quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" + units: "1/year/Solar_Mass" + start: 3e-15 + end: 3e-12 mean: plot: true log: true @@ -61,15 +61,15 @@ stellar_mass_snia_rates_active_only_50: value: 1e12 units: Solar_Mass metadata: - title: Stellar Mass-SNIa rate relation (active only, 50 kpc aperture) - caption: Uses a 50 kpc 3D aperture and only active galaxies. + title: Stellar Mass-SNIa rate per stellar mass relation (active only, 50 kpc aperture) + caption: Uses a 50 kpc 3D aperture. section: SNIa Rate (Stellar Mass) observational_data: - - filename: GalaxyStellarMassSNIaRate/Smith2012_active.hdf5 - - filename: GalaxyStellarMassSNIaRate/Graur2015_active.hdf5 - - filename: GalaxyStellarMassSNIaRate/Graur2017_active.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Smith2012_active.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015_active.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017_active.hdf5 -stellar_mass_snia_rates_passive_only_50: +stellar_mass_snia_rates_per_stellar_mass_passive_only_50: type: "scatter" comment: "Passive only" comment_loc: "lower left" @@ -81,10 +81,10 @@ stellar_mass_snia_rates_passive_only_50: start: 1e6 end: 1e12 y: - quantity: "snia_rates.snia_rates_50_kpc" - units: "1/year" - start: 3e-8 - end: 1e-1 + quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" + units: "1/year/Solar_Mass" + start: 3e-15 + end: 3e-12 mean: plot: true log: true @@ -97,15 +97,15 @@ stellar_mass_snia_rates_passive_only_50: value: 1e12 units: Solar_Mass metadata: - title: Stellar Mass-SNIa rate relation (passive only, 50 kpc aperture) - caption: Uses a 50 kpc 3D aperture and only passive galaxies. + title: Stellar Mass-SNIa rate per stellar mass relation (passive only, 50 kpc aperture) + caption: Uses a 50 kpc 3D aperture. section: SNIa Rate (Stellar Mass) observational_data: - - filename: GalaxyStellarMassSNIaRate/Smith2012_passive.hdf5 - - filename: GalaxyStellarMassSNIaRate/Graur2015_passive.hdf5 - - filename: GalaxyStellarMassSNIaRate/Graur2017_passive.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Smith2012_passive.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015_passive.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017_passive.hdf5 -stellar_mass_snia_rates_per_stellar_mass_50: +stellar_mass_snia_rates_50: type: "scatter" legend_loc: "upper left" x: @@ -114,10 +114,10 @@ stellar_mass_snia_rates_per_stellar_mass_50: start: 1e6 end: 1e12 y: - quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" - units: "1/year/Solar_Mass" - start: 3e-15 - end: 3e-12 + quantity: "snia_rates.snia_rates_50_kpc" + units: "1/year" + start: 3e-8 + end: 1e-1 mean: plot: true log: true @@ -130,17 +130,17 @@ stellar_mass_snia_rates_per_stellar_mass_50: value: 1e12 units: Solar_Mass metadata: - title: Stellar Mass-SNIa rate per stellar mass relation (50 kpc aperture) + title: Stellar Mass-SNIa rate relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture. section: SNIa Rate (Stellar Mass) observational_data_bracket_width: 10.0 observational_data: - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Kistler2014.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Wiseman2021.hdf5 + - filename: GalaxyStellarMassSNIaRate/Kistler2014.hdf5 + - filename: GalaxyStellarMassSNIaRate/Graur2015.hdf5 + - filename: GalaxyStellarMassSNIaRate/Graur2017.hdf5 + - filename: GalaxyStellarMassSNIaRate/Wiseman2021.hdf5 -stellar_mass_snia_rates_per_stellar_mass_active_only_50: +stellar_mass_snia_rates_active_only_50: type: "scatter" comment: "Active only" comment_loc: "lower left" @@ -152,10 +152,10 @@ stellar_mass_snia_rates_per_stellar_mass_active_only_50: start: 1e6 end: 1e12 y: - quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" - units: "1/year/Solar_Mass" - start: 3e-15 - end: 3e-12 + quantity: "snia_rates.snia_rates_50_kpc" + units: "1/year" + start: 3e-8 + end: 1e-1 mean: plot: true log: true @@ -168,15 +168,15 @@ stellar_mass_snia_rates_per_stellar_mass_active_only_50: value: 1e12 units: Solar_Mass metadata: - title: Stellar Mass-SNIa rate per stellar mass relation (active only, 50 kpc aperture) - caption: Uses a 50 kpc 3D aperture. + title: Stellar Mass-SNIa rate relation (active only, 50 kpc aperture) + caption: Uses a 50 kpc 3D aperture and only active galaxies. section: SNIa Rate (Stellar Mass) observational_data: - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Smith2012_active.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015_active.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017_active.hdf5 + - filename: GalaxyStellarMassSNIaRate/Smith2012_active.hdf5 + - filename: GalaxyStellarMassSNIaRate/Graur2015_active.hdf5 + - filename: GalaxyStellarMassSNIaRate/Graur2017_active.hdf5 -stellar_mass_snia_rates_per_stellar_mass_passive_only_50: +stellar_mass_snia_rates_passive_only_50: type: "scatter" comment: "Passive only" comment_loc: "lower left" @@ -188,10 +188,10 @@ stellar_mass_snia_rates_per_stellar_mass_passive_only_50: start: 1e6 end: 1e12 y: - quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" - units: "1/year/Solar_Mass" - start: 3e-15 - end: 3e-12 + quantity: "snia_rates.snia_rates_50_kpc" + units: "1/year" + start: 3e-8 + end: 1e-1 mean: plot: true log: true @@ -204,13 +204,13 @@ stellar_mass_snia_rates_per_stellar_mass_passive_only_50: value: 1e12 units: Solar_Mass metadata: - title: Stellar Mass-SNIa rate per stellar mass relation (passive only, 50 kpc aperture) - caption: Uses a 50 kpc 3D aperture. + title: Stellar Mass-SNIa rate relation (passive only, 50 kpc aperture) + caption: Uses a 50 kpc 3D aperture and only passive galaxies. section: SNIa Rate (Stellar Mass) observational_data: - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Smith2012_passive.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015_passive.hdf5 - - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017_passive.hdf5 + - filename: GalaxyStellarMassSNIaRate/Smith2012_passive.hdf5 + - filename: GalaxyStellarMassSNIaRate/Graur2015_passive.hdf5 + - filename: GalaxyStellarMassSNIaRate/Graur2017_passive.hdf5 gas_metallicity_snia_rates_per_stellar_mass_active_only_50: comment: "$M_\\star > 10^{10}$ $M_\\odot$ and active only" @@ -282,7 +282,7 @@ gas_metallicity_snia_rates_per_stellar_mass_active_only_50_Mstar5e10: observational_data: - filename: GalaxyGasMetallicitySNIaRatePerStellarMass/Graur2017.hdf5 -star_formation_rates_snia_rates_per_stellar_mass_50: +star_formation_rates_snia_rates_50: comment: "$M_\\star > 10^{10}$ $M_\\odot$" comment_loc: "lower left" type: "scatter" @@ -294,10 +294,10 @@ star_formation_rates_snia_rates_per_stellar_mass_50: start: 1e-3 end: 1e2 y: - quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" - units: "1/year/Solar_Mass" - start: 1e-14 - end: 3e-12 + quantity: "snia_rates.snia_rates_50_kpc" + units: "1/year" + start: 1e-6 + end: 1e-1 mean: plot: true log: true @@ -310,19 +310,19 @@ star_formation_rates_snia_rates_per_stellar_mass_50: value: 1e2 units: "Solar_Mass/year" metadata: - title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) + title: SFR-SNIa rate relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. section: SNIa Rate (SFR and sSFR) observational_data: - - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - - filename: StarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 + - filename: StarFormationRateSNIaRate/Sullivan2006.hdf5 + - filename: StarFormationRateSNIaRate/Smith2012.hdf5 -star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: - comment: "$M_\\star > 5 \\times 10^{10}$ $M_\\odot$" +star_formation_rates_snia_rates_per_stellar_mass_50: + comment: "$M_\\star > 10^{10}$ $M_\\odot$" comment_loc: "lower left" type: "scatter" legend_loc: "upper left" - selection_mask: "derived_quantities.stellar_mass_is_bigger_than_5e10_msun_50_kpc" + selection_mask: "derived_quantities.stellar_mass_is_bigger_than_1e10_msun_50_kpc" x: quantity: "apertures.sfr_gas_50_kpc" units: "Solar_Mass/year" @@ -346,46 +346,49 @@ star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: units: "Solar_Mass/year" metadata: title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) - caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 5e10 Msun. + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. section: SNIa Rate (SFR and sSFR) observational_data: - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - filename: StarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 -star_formation_rates_snia_rates_50: +specific_star_formation_rates_snia_rates_per_stellar_mass_50: comment: "$M_\\star > 10^{10}$ $M_\\odot$" comment_loc: "lower left" type: "scatter" legend_loc: "upper left" selection_mask: "derived_quantities.stellar_mass_is_bigger_than_1e10_msun_50_kpc" x: - quantity: "apertures.sfr_gas_50_kpc" - units: "Solar_Mass/year" + quantity: "derived_quantities.specific_sfr_gas_50_kpc" + units: "1/gigayear" start: 1e-3 - end: 1e2 + end: 1e1 y: - quantity: "snia_rates.snia_rates_50_kpc" - units: "1/year" - start: 1e-6 - end: 1e-1 + quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" + units: "1/year/Solar_Mass" + start: 1e-14 + end: 3e-12 mean: plot: true log: true adaptive: true number_of_bins: 30 start: - value: 1e-3 - units: "Solar_Mass/year" + value: 1e-4 + units: "1/gigayear" end: - value: 1e2 - units: "Solar_Mass/year" + value: 1e1 + units: "1/gigayear" metadata: - title: SFR-SNIa rate relation (50 kpc aperture) + title: sSFR-SNIa rate per stellar mass relation (50 kpc aperture) caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. section: SNIa Rate (SFR and sSFR) observational_data: - - filename: StarFormationRateSNIaRate/Sullivan2006.hdf5 - - filename: StarFormationRateSNIaRate/Smith2012.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Mannucci2005.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Sullivan2006.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Smith2012.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 + - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 star_formation_rates_snia_rates_50_Mstar5e10: comment: "$M_\\star > 5 \\times 10^{10}$ $M_\\odot$" @@ -422,17 +425,17 @@ star_formation_rates_snia_rates_50_Mstar5e10: - filename: StarFormationRateSNIaRate/Sullivan2006.hdf5 - filename: StarFormationRateSNIaRate/Smith2012.hdf5 -specific_star_formation_rates_snia_rates_per_stellar_mass_50: - comment: "$M_\\star > 10^{10}$ $M_\\odot$" +star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: + comment: "$M_\\star > 5 \\times 10^{10}$ $M_\\odot$" comment_loc: "lower left" type: "scatter" legend_loc: "upper left" - selection_mask: "derived_quantities.stellar_mass_is_bigger_than_1e10_msun_50_kpc" + selection_mask: "derived_quantities.stellar_mass_is_bigger_than_5e10_msun_50_kpc" x: - quantity: "derived_quantities.specific_sfr_gas_50_kpc" - units: "1/gigayear" + quantity: "apertures.sfr_gas_50_kpc" + units: "Solar_Mass/year" start: 1e-3 - end: 1e1 + end: 1e2 y: quantity: "derived_quantities.snia_rate_per_stellar_mass_50_kpc" units: "1/year/Solar_Mass" @@ -445,20 +448,17 @@ specific_star_formation_rates_snia_rates_per_stellar_mass_50: number_of_bins: 30 start: value: 1e-3 - units: "1/gigayear" + units: "Solar_Mass/year" end: - value: 1e1 - units: "1/gigayear" + value: 1e2 + units: "Solar_Mass/year" metadata: - title: sSFR-SNIa rate per stellar mass relation (50 kpc aperture) - caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. + title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 5e10 Msun. section: SNIa Rate (SFR and sSFR) observational_data: - - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Mannucci2005.hdf5 - - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Sullivan2006.hdf5 - - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Smith2012.hdf5 - - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 - - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 + - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 + - filename: StarFormationRateSNIaRatePerStellarMass/Graur2017.hdf5 specific_star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: comment: "$M_\\star > 5 \\times 10^{10}$ $M_\\odot$" @@ -482,7 +482,7 @@ specific_star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: adaptive: true number_of_bins: 30 start: - value: 1e-3 + value: 1e-4 units: "1/gigayear" end: value: 1e1 From db6805aaa1e2f30d1dd4d82b1be549c9f4c364e3 Mon Sep 17 00:00:00 2001 From: folkert Date: Thu, 16 Mar 2023 09:38:09 +0000 Subject: [PATCH 07/34] Add scripts to use the CSFH to calculate the CC SN and SNIa rate --- colibre/config.yml | 70 +++- .../scripts/cosmic_CC_SN_rate_CSFH_based.py | 191 +++++++++++ .../cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 257 +++++++++++++++ .../scripts/cosmic_SNIa_rate_CSFH_based.py | 276 ++++++++++++++++ .../cosmic_log_CC_SN_rate_CSFH_based.py | 193 +++++++++++ .../cosmic_log_SNIa_rate_CSFH_based.py | 307 ++++++++++++++++++ 6 files changed, 1284 insertions(+), 10 deletions(-) create mode 100644 colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py create mode 100644 colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py create mode 100644 colibre/scripts/cosmic_SNIa_rate_CSFH_based.py create mode 100644 colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py create mode 100644 colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py diff --git a/colibre/config.yml b/colibre/config.yml index f2a0f987..958ea354 100644 --- a/colibre/config.yml +++ b/colibre/config.yml @@ -20,6 +20,66 @@ description_template: description.html # Location and description of additional figures scripts: + - filename: scripts/cosmic_log_SNIa_rate_CSFH_based.py + title: 'Cosmic SNIa rate' + caption: SNIa rate history calculated from the SFR.txt file produced by SWIFT. + section: SN Rate (cosmic - CSFH based) + output_file: log_SNIa_rate_history_based_on_CSFH.png + - filename: scripts/cosmic_SNIa_rate_CSFH_based.py + title: 'Cosmic SNIa rate' + caption: SNIa rate history calculated from the SFR.txt file produced by SWIFT. + section: SN Rate (cosmic - CSFH based) + output_file: SNIa_rate_history_based_on_CSFH.png + - filename: scripts/cosmic_log_CC_SN_rate_CSFH_based.py + title: 'Cosmic CC SN rate' + caption: CC SN rate history calculated from the SFR.txt file produced by SWIFT. + section: SN Rate (cosmic - CSFH based) + output_file: log_CC_SN_rate_history_based_on_CSFH.png + - filename: scripts/cosmic_CC_SN_rate_CSFH_based.py + title: 'Cosmic CC SN rate' + caption: CC SN rate history calculated from the SFR.txt file produced by SWIFT. + section: SN Rate (cosmic - CSFH based) + output_file: CC_SN_rate_history_based_on_CSFH.png + - filename: scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py + title: 'Cosmic SNIa rate / CC SN rate' + caption: SNIa rate over CC SN rate history calculated from the SFR.txt file produced by SWIFT. + section: SN Rate (cosmic - CSFH based) + output_file: SNIa_over_CC_rate_history_based_on_CSFH.png + - filename: scripts/cosmic_SNIa_rate.py + title: 'Cosmic SNIa rate' + caption: SNIa rate history plotted directly from the SNIa.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: SNIa_rate_history.png + - filename: scripts/cosmic_log_SNIa_rate.py + title: 'Cosmic SNIa rate' + caption: SNIa rate history plotted directly from the SNIa.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: log_SNIa_rate_history.png + - filename: scripts/cosmic_CC_SN_rate.py + title: 'Cosmic CC SN rate' + caption: CC SN rate history plotted directly from the SNII.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: CC_SN_rate_history.png + - filename: scripts/cosmic_log_CC_SN_rate.py + title: 'Cosmic CC SN rate' + caption: CC SN rate history plotted directly from the SNII.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: log_CC_SN_rate_history.png + - filename: scripts/cosmic_log_NSM_rate.py + title: 'Cosmic NS-NS merger rate' + caption: NS-NS merger rate or short GRB rate plotted directly from the r_processes.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: log_NSM_rate_history.png + - filename: scripts/cosmic_log_CEJSN_rate.py + title: 'Cosmic common-envelop jets SN rate' + caption: Common-envelop (CE) jets SN rate plotted directly from the r_processes.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: log_CEJSN_rate_history.png + - filename: scripts/cosmic_log_collapsar_rate.py + title: 'Cosmic collapsar rate' + caption: Collapsar rate plotted directly from the r_processes.txt file produced by SWIFT. + section: SN Rate (cosmic - stochastic) + output_file: log_collapsar_rate_history.png - filename: scripts/density_temperature.py caption: Density-temperature diagram. If present, dashed line represents the entropy floor (equation of state). output_file: density_temperature.png @@ -503,13 +563,3 @@ scripts: section: Column Densities additional_arguments: parallel: True - - filename: scripts/cosmic_SNIa_rate.py - title: 'Cosmic SNIa rate' - caption: SNIa rate history plotted directly from the SNIa.txt file produced by SWIFT. - section: SN Rate (cosmic) - output_file: SNIa_rate_history.png - - filename: scripts/cosmic_CC_SN_rate.py - title: 'Cosmic CC SN rate' - caption: CC SN rate history plotted directly from the SNII.txt file produced by SWIFT. - section: SN Rate (cosmic) - output_file: CC_SN_rate_history.png diff --git a/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py new file mode 100644 index 00000000..16c8dc99 --- /dev/null +++ b/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py @@ -0,0 +1,191 @@ +""" +Plots the star formation history. Modified version of the script in the +github.com/swiftsim/swiftsimio-examples repository. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from load_sfh_data import read_obs_data + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +sfr_output_units = unyt.msun / (unyt.year * unyt.Mpc ** 3) +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +SNIa_output_units = 1. / (unyt.year * unyt.Mpc ** 3) + +from swiftpipeline.argumentparser import ScriptArgumentParser + +def CC_SN_DTD(t, t_min, t_max): + mask = (t > t_min) & (t < t_max) + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1./(t_max - t_min) * (np.ones(len(t[mask]))) + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +arguments = ScriptArgumentParser( + description="Creates a star formation history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +sfr_filenames = [f"{directory}/SFR.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.set_xscale("log") + +for idx, (snapshot_filename, sfr_filename, name) in enumerate( + zip(snapshot_filenames, sfr_filenames, names) +): + data = np.genfromtxt(sfr_filename).T + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + boxsize = snapshot.metadata.boxsize + box_volume = boxsize[0] * boxsize[1] * boxsize[2] + + sfr_units = snapshot.gas.star_formation_rates.units + + # a, Redshift, SFR + scale_factor = data[2] + redshift = data[3] + star_formation_rate = (data[7] * sfr_units / box_volume).to(sfr_output_units) + times = data[1] * units.time + dM = data[4] * units.mass + + # Calculate the times we plot + times_desired = np.linspace(0.05,13.8,500) * unyt.Gyr + scale_factors_use = np.interp(times_desired, times, scale_factor) + + SNIa_rate = np.zeros(len(times_desired)) + + for i in range(1,len(times_desired)): + time_consider = times[times < times_desired[i]] + time_since_formation = times_desired[i] - time_consider + dM_consider = dM[times < times_desired[i]] + SNIa_rate_individual = 1.180e-2 * CC_SN_DTD(time_since_formation, 3*unyt.Myr, 0.04*unyt.Gyr) * dM_consider / unyt.Msun + + SNIa_rate_sum = np.sum(SNIa_rate_individual) + SNIa_rate[i] = SNIa_rate_sum + + SNIa_rate = (SNIa_rate / box_volume / unyt.Gyr).to(SNIa_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factors_use, SNIa_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicCCSNRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + capsize=1.0, + ) + ) + observation_labels.append(f"{obs_data.citation}") + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc=4, fontsize=4, ncol=2 +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(0, 26.0) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel(f"CC SN rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]") +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/CC_SN_rate_history_based_on_CSFH.png") diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py new file mode 100644 index 00000000..fad83eea --- /dev/null +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -0,0 +1,257 @@ +""" +Plots the star formation history. Modified version of the script in the +github.com/swiftsim/swiftsimio-examples repository. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from load_sfh_data import read_obs_data + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +sfr_output_units = unyt.msun / (unyt.year * unyt.Mpc ** 3) +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +SNIa_output_units = 1. / (unyt.year * unyt.Mpc ** 3) + +from swiftpipeline.argumentparser import ScriptArgumentParser + +def power_law_beta_one_DTD(t, t_delay, tH): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1./(np.log(tH) - np.log(t_delay)) / t[mask] + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def power_law_DTD(t, t_delay, tH, beta): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = (1.-beta)/(tH**(1-beta) - (t_delay)**(1-beta)) / t[mask]**beta + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + + +def exponential_law_DTD(t, t_decay, t_delay): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = np.exp(-(t[mask]-t_delay)/t_decay)/t_decay + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def Gaussian_law_DTD(t, t_delay, tmean, tsigma): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1/np.sqrt(2*tsigma**2) * np.exp(-0.5*(t[mask]-tmean)**2 / (2*tsigma)**2) + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def CC_SN_DTD(t, t_min, t_max): + mask = (t > t_min) & (t < t_max) + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1./(t_max - t_min) * (np.ones(len(t[mask]))) + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +arguments = ScriptArgumentParser( + description="Creates a star formation history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +sfr_filenames = [f"{directory}/SFR.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.set_xscale("log") + + +for idx, (snapshot_filename, sfr_filename, name) in enumerate( + zip(snapshot_filenames, sfr_filenames, names) +): + data = np.genfromtxt(sfr_filename).T + + snapshot = load(snapshot_filename) + + # find out which DTD model we are currently using in the code + normalization_timescale = snapshot.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", None) + if normalization_timescale == None: + have_normalization_timescale = False + else: + normalization_timescale = float(normalization_timescale) * unyt.Gyr + have_normalization_timescale = True + + exponential_decay = snapshot.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", None) + if exponential_decay == None: + have_exponential_decay = False + else: + have_exponential_decay = True + exponential_decay = float(exponential_decay) * unyt.Gyr + + Gaussian_SNIa_efficiency = snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", None) + if Gaussian_SNIa_efficiency == None: + have_Gaussian = False + else: + have_Gaussian = True + Gaussian_SNIa_efficiency = float(Gaussian_SNIa_efficiency) / unyt.Msun + + power_law_slope = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope", None) + if power_law_slope == None: + have_slope = False + else: + have_slope = True + power_law_slope = float(power_law_slope) + + if have_Gaussian: + used_DTD = "Gaussian" + elif have_slope and have_normalization_timescale: + used_DTD = "power-law" + elif have_normalization_timescale: + used_DTD = "power-law-beta-one" + else: + used_DTD = "exponential" + + delay_time = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_delay_time_Gyr", False) ) * unyt.Gyr + + if used_DTD == "power-law" or used_DTD == "exponential" or used_DTD == "power-law-beta-one": + SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun + elif used_DTD == "Gaussian": + Gaussian_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False)) / unyt.Msun + Gaussian_const_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_const_p_Msun", False)) / unyt.Msun + Gaussian_characteristic_time = float(snapshot.metadata.parameters.get("SNIaDTD:characteristic_time_Gyr", False)) * unyt.Gyr + Gaussian_std_time = float(snapshot.metadata.parameters.get("SNIaDTD:STD_characteristic_time_Gyr", False)) * unyt.Gyr + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + boxsize = snapshot.metadata.boxsize + box_volume = boxsize[0] * boxsize[1] * boxsize[2] + + sfr_units = snapshot.gas.star_formation_rates.units + + # a, Redshift, SFR + scale_factor = data[2] + redshift = data[3] + star_formation_rate = (data[7] * sfr_units / box_volume).to(sfr_output_units) + times = data[1] * units.time + dM = data[4] * units.mass + + # Calculate the times we plot + times_desired = np.linspace(0.05,13.8,500) * unyt.Gyr + scale_factors_use = np.interp(times_desired, times, scale_factor) + + SNIa_rate = np.zeros(len(times_desired)) + CC_SN_rate = np.zeros(len(times_desired)) + + for i in range(1,len(times_desired)): + time_consider = times[times < times_desired[i]] + time_since_formation = times_desired[i] - time_consider + dM_consider = dM[times < times_desired[i]] + #SNIa_rate_individual = 1.6e-3 * exponential_law_DTD(time_since_formation, 2.0, 0.04) * dM_consider + #SNIa_rate_individual = 1.6e-3 * power_law_beta_one_DTD(time_since_formation, 0.04, 13.6) * dM_consider + if used_DTD == "power-law": + SNIa_rate_individual = SNIa_efficiency * power_law_DTD(time_since_formation, delay_time, normalization_timescale,power_law_slope) * dM_consider + elif used_DTD == "power-law-beta-one": + SNIa_rate_individual = SNIa_efficiency * power_law_beta_one_DTD(time_since_formation, delay_time, normalization_timescale) * dM_consider + elif used_DTD == "exponential": + SNIa_rate_individual = SNIa_efficiency * exponential_law_DTD(time_since_formation, exponential_decay, delay_time) * dM_consider + elif used_DTD == "Gaussian": + SNIa_rate_individual = Gaussian_SNIa_efficiency * Gaussian_law_DTD(time_since_formation, delay_time, Gaussian_characteristic_time, Gaussian_std_time) * dM_consider + + SNIa_rate_sum = np.sum(SNIa_rate_individual) + SNIa_rate[i] = SNIa_rate_sum + + CC_SN_rate_individual = 1.180e-2 * CC_SN_DTD(time_since_formation, 3*unyt.Myr, 0.04*unyt.Gyr) * dM_consider / unyt.Msun + + CC_SN_rate_sum = np.sum(CC_SN_rate_individual) + CC_SN_rate[i] = CC_SN_rate_sum + + + SNIa_rate = (SNIa_rate / box_volume / unyt.Gyr).to(SNIa_output_units) + CC_SN_rate = (CC_SN_rate / box_volume / unyt.Gyr).to(SNIa_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factors_use, SNIa_rate.value / CC_SN_rate.value, zorder=10000)[0] + ) + simulation_labels.append(name) + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(0, 0.6) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel(f"SNIa rate / CC SN rate") +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/SNIa_over_CC_rate_history_based_on_CSFH.png") diff --git a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py new file mode 100644 index 00000000..baa5643a --- /dev/null +++ b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py @@ -0,0 +1,276 @@ +""" +Plots the star formation history. Modified version of the script in the +github.com/swiftsim/swiftsimio-examples repository. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from load_sfh_data import read_obs_data + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +sfr_output_units = unyt.msun / (unyt.year * unyt.Mpc ** 3) +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +SNIa_output_units = 1. / (unyt.year * unyt.Mpc ** 3) + +from swiftpipeline.argumentparser import ScriptArgumentParser + +def power_law_beta_one_DTD(t, t_delay, tH): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1./(np.log(tH) - np.log(t_delay)) / t[mask] + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def power_law_DTD(t, t_delay, tH, beta): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = (1.-beta)/(tH**(1-beta) - (t_delay)**(1-beta)) / t[mask]**beta + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + + +def exponential_law_DTD(t, t_decay, t_delay): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = np.exp(-(t[mask]-t_delay)/t_decay)/t_decay + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def Gaussian_law_DTD(t, t_delay, tmean, tsigma): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + norm = 1./(tsigma* np.sqrt(2*np.pi)) + delta_t = t[mask] - tmean + value_new = norm * np.exp(-0.5 * delta_t**2 / tsigma**2) + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +arguments = ScriptArgumentParser( + description="Creates a star formation history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +sfr_filenames = [f"{directory}/SFR.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.set_xscale("log") + + +for idx, (snapshot_filename, sfr_filename, name) in enumerate( + zip(snapshot_filenames, sfr_filenames, names) +): + data = np.genfromtxt(sfr_filename).T + + snapshot = load(snapshot_filename) + + # find out which DTD model we are currently using in the code + normalization_timescale = snapshot.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", None) + if normalization_timescale == None: + have_normalization_timescale = False + else: + normalization_timescale = float(normalization_timescale) * unyt.Gyr + have_normalization_timescale = True + + exponential_decay = snapshot.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", None) + if exponential_decay == None: + have_exponential_decay = False + else: + have_exponential_decay = True + exponential_decay = float(exponential_decay) * unyt.Gyr + + Gaussian_SNIa_efficiency = snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", None) + if Gaussian_SNIa_efficiency == None: + have_Gaussian = False + else: + have_Gaussian = True + Gaussian_SNIa_efficiency = float(Gaussian_SNIa_efficiency) / unyt.Msun + + power_law_slope = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope", None) + if power_law_slope == None: + have_slope = False + else: + have_slope = True + power_law_slope = float(power_law_slope) + + if have_Gaussian: + used_DTD = "Gaussian" + elif have_slope and have_normalization_timescale: + used_DTD = "power-law" + elif have_normalization_timescale: + used_DTD = "power-law-beta-one" + else: + used_DTD = "exponential" + + delay_time = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_delay_time_Gyr", False) ) * unyt.Gyr + + if used_DTD == "power-law" or used_DTD == "exponential" or used_DTD == "power-law-beta-one": + SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun + elif used_DTD == "Gaussian": + Gaussian_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False)) / unyt.Msun + Gaussian_const_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_const_p_Msun", False)) / unyt.Msun + Gaussian_characteristic_time = float(snapshot.metadata.parameters.get("SNIaDTD:characteristic_time_Gyr", False)) * unyt.Gyr + Gaussian_std_time = float(snapshot.metadata.parameters.get("SNIaDTD:STD_characteristic_time_Gyr", False)) * unyt.Gyr + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + boxsize = snapshot.metadata.boxsize + box_volume = boxsize[0] * boxsize[1] * boxsize[2] + + sfr_units = snapshot.gas.star_formation_rates.units + + # a, Redshift, SFR + scale_factor = data[2] + redshift = data[3] + star_formation_rate = (data[7] * sfr_units / box_volume).to(sfr_output_units) + times = data[1] * units.time + dM = data[4] * units.mass + + # Calculate the times we plot + times_desired = np.linspace(0.05,13.8,500) * unyt.Gyr + scale_factors_use = np.interp(times_desired, times, scale_factor) + + SNIa_rate = np.zeros(len(times_desired)) + + for i in range(1,len(times_desired)): + time_consider = times[times < times_desired[i]] + time_since_formation = times_desired[i] - time_consider + dM_consider = dM[times < times_desired[i]] + #SNIa_rate_individual = 1.6e-3 * exponential_law_DTD(time_since_formation, 2.0, 0.04) * dM_consider + #SNIa_rate_individual = 1.6e-3 * power_law_beta_one_DTD(time_since_formation, 0.04, 13.6) * dM_consider + if used_DTD == "power-law": + SNIa_rate_individual = SNIa_efficiency * power_law_DTD(time_since_formation, delay_time, normalization_timescale,power_law_slope) * dM_consider + elif used_DTD == "power-law-beta-one": + SNIa_rate_individual = SNIa_efficiency * power_law_beta_one_DTD(time_since_formation, delay_time, normalization_timescale) * dM_consider + elif used_DTD == "exponential": + SNIa_rate_individual = SNIa_efficiency * exponential_law_DTD(time_since_formation, exponential_decay, delay_time) * dM_consider + elif used_DTD == "Gaussian": + SNIa_rate_individual = Gaussian_SNIa_efficiency * Gaussian_law_DTD(time_since_formation, delay_time, Gaussian_characteristic_time, Gaussian_std_time) * dM_consider + + SNIa_rate_sum = np.sum(SNIa_rate_individual) + SNIa_rate[i] = SNIa_rate_sum + + SNIa_rate = (SNIa_rate / box_volume / unyt.Gyr).to(SNIa_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factors_use, SNIa_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicSNIaRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + capsize=1.0, + ) + ) + observation_labels.append(f"{obs_data.citation}") + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc=4, fontsize=4, ncol=2 +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(0, 1.6) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel(f"SNIa rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]") +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/SNIa_rate_history_based_on_CSFH.png") diff --git a/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py new file mode 100644 index 00000000..b9531fd3 --- /dev/null +++ b/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py @@ -0,0 +1,193 @@ +""" +Plots the star formation history. Modified version of the script in the +github.com/swiftsim/swiftsimio-examples repository. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from load_sfh_data import read_obs_data + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +sfr_output_units = unyt.msun / (unyt.year * unyt.Mpc ** 3) +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +SNIa_output_units = 1. / (unyt.year * unyt.Mpc ** 3) + +from swiftpipeline.argumentparser import ScriptArgumentParser + +def CC_SN_DTD(t, t_min, t_max): + mask = (t > t_min) & (t < t_max) + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1./(t_max - t_min) * (np.ones(len(t[mask]))) + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +arguments = ScriptArgumentParser( + description="Creates a star formation history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +sfr_filenames = [f"{directory}/SFR.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.set_xscale("log") +ax.set_yscale("log") + + +for idx, (snapshot_filename, sfr_filename, name) in enumerate( + zip(snapshot_filenames, sfr_filenames, names) +): + data = np.genfromtxt(sfr_filename).T + + snapshot = load(snapshot_filename) + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + boxsize = snapshot.metadata.boxsize + box_volume = boxsize[0] * boxsize[1] * boxsize[2] + + sfr_units = snapshot.gas.star_formation_rates.units + + # a, Redshift, SFR + scale_factor = data[2] + redshift = data[3] + star_formation_rate = (data[7] * sfr_units / box_volume).to(sfr_output_units) + times = data[1] * units.time + dM = data[4] * units.mass + + # Calculate the times we plot + times_desired = np.linspace(0.05,13.8,500) * unyt.Gyr + scale_factors_use = np.interp(times_desired, times, scale_factor) + + SNIa_rate = np.zeros(len(times_desired)) + + for i in range(1,len(times_desired)): + time_consider = times[times < times_desired[i]] + time_since_formation = times_desired[i] - time_consider + dM_consider = dM[times < times_desired[i]] + SNIa_rate_individual = 1.180e-2 * CC_SN_DTD(time_since_formation, 3*unyt.Myr, 0.04*unyt.Gyr) * dM_consider / unyt.Msun + + SNIa_rate_sum = np.sum(SNIa_rate_individual) + SNIa_rate[i] = SNIa_rate_sum + + SNIa_rate = (SNIa_rate / box_volume / unyt.Gyr).to(SNIa_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factors_use, SNIa_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicCCSNRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + capsize=1.0, + ) + ) + observation_labels.append(f"{obs_data.citation}") + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc=4, fontsize=4, ncol=2 +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(1e-1, 3e1) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel(f"CC SN rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]") +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_CC_SN_rate_history_based_on_CSFH.png") diff --git a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py new file mode 100644 index 00000000..8b1af21b --- /dev/null +++ b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py @@ -0,0 +1,307 @@ +""" +Plots the star formation history. Modified version of the script in the +github.com/swiftsim/swiftsimio-examples repository. +""" +import unyt + +import matplotlib.pyplot as plt +import numpy as np +import glob + +from swiftsimio import load + +from load_sfh_data import read_obs_data + +from velociraptor.observations import load_observations + +from astropy.cosmology import z_at_value +from astropy.units import Gyr + +sfr_output_units = unyt.msun / (unyt.year * unyt.Mpc ** 3) +log_multiplicative_factor = 4 +multiplicative_factor = 10 ** log_multiplicative_factor +SNIa_output_units = 1. / (unyt.year * unyt.Mpc ** 3) + +from swiftpipeline.argumentparser import ScriptArgumentParser + +def power_law_beta_one_DTD(t, t_delay, tH): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = 1./(np.log(tH) - np.log(t_delay)) / t[mask] + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def power_law_DTD(t, t_delay, tH, beta): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = (1.-beta)/(tH**(1-beta) - (t_delay)**(1-beta)) / t[mask]**beta + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + + +def exponential_law_DTD(t, t_decay, t_delay): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + value_new = np.exp(-(t[mask]-t_delay)/t_decay)/t_decay + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def Gaussian_law_DTD(t, t_delay, tmean, tsigma): + mask = t > 0.04 + value = np.zeros(len(t)) / unyt.Gyr + norm = 1./(tsigma* np.sqrt(2*np.pi)) + delta_t = t[mask] - tmean + value_new = norm * np.exp(-0.5 * delta_t**2 / tsigma**2) + value_new.convert_to_units("Gyr**-1") + value[mask] = value_new + return value + +def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, delay_time, normalization_timescale): + mask1 = (t > 0.04) & (t < break_time_Gyr) + mask2 = (t>= break_time_Gyr) + value = np.zeros(len(t)) / unyt.Gyr + norm1 = (1- slope_short_time) * (1 - slope_long_time) + norm2a = (slope_short_time - slope_long_time) * break_time_Gyr + norm2b = (1 - slope_short_time) * normalization_timescale**(1-slope_long_time) * break_time_Gyr**slope_long_time + norm2c = (1 - slope_long_time) * normalization_timescale**(1-slope_short_time) * break_time_Gyr**slope_short_time + norm2 = norm2a + norm2b + norm2c + norm = norm1 / norm2 + value[mask1] = norm * (t[mask1]/break_time_Gyr)**(-slope_short_time) + value[mask2] = norm * (t[mask2]/break_time_Gyr)**(-slope_long_time) + return value + + +arguments = ScriptArgumentParser( + description="Creates a star formation history plot, with added observational data." +) + +snapshot_filenames = [ + f"{directory}/{snapshot}" + for directory, snapshot in zip(arguments.directory_list, arguments.snapshot_list) +] + +sfr_filenames = [f"{directory}/SFR.txt" for directory in arguments.directory_list] + +names = arguments.name_list +output_path = arguments.output_directory + +plt.style.use(arguments.stylesheet_location) + +simulation_lines = [] +simulation_labels = [] + +fig, ax = plt.subplots() + +ax.set_xscale("log") +ax.set_yscale("log") + + +for idx, (snapshot_filename, sfr_filename, name) in enumerate( + zip(snapshot_filenames, sfr_filenames, names) +): + data = np.genfromtxt(sfr_filename).T + + snapshot = load(snapshot_filename) + + # find out which DTD model we are currently using in the code + normalization_timescale = snapshot.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", None) + if normalization_timescale == None: + have_normalization_timescale = False + else: + normalization_timescale = float(normalization_timescale) * unyt.Gyr + have_normalization_timescale = True + + exponential_decay = snapshot.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", None) + if exponential_decay == None: + have_exponential_decay = False + else: + have_exponential_decay = True + exponential_decay = float(exponential_decay) * unyt.Gyr + + Gaussian_SNIa_efficiency = snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", None) + if Gaussian_SNIa_efficiency == None: + have_Gaussian = False + else: + have_Gaussian = True + Gaussian_SNIa_efficiency = float(Gaussian_SNIa_efficiency) / unyt.Msun + + power_law_slope = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope", None) + if power_law_slope == None: + have_slope = False + else: + have_slope = True + power_law_slope = float(power_law_slope) + + power_law_slope_short_time = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope_short_time", None) + if power_law_slope_short_time == None: + have_broken_slope = False + else: + have_broken_slope = True + power_law_slope_short_time = float(power_law_slope_short_time) + + if have_Gaussian: + used_DTD = "Gaussian" + elif have_broken_slope: + used_DTD = "broken-power-law" + elif have_slope and have_normalization_timescale: + used_DTD = "power-law" + elif have_normalization_timescale: + used_DTD = "power-law-beta-one" + else: + used_DTD = "exponential" + + delay_time = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_delay_time_Gyr", False) ) * unyt.Gyr + + if used_DTD == "power-law" or used_DTD == "exponential" or used_DTD == "power-law-beta-one": + SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun + elif used_DTD == "Gaussian": + Gaussian_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False)) / unyt.Msun + Gaussian_const_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_const_p_Msun", False)) / unyt.Msun + Gaussian_characteristic_time = float(snapshot.metadata.parameters.get("SNIaDTD:characteristic_time_Gyr", False)) * unyt.Gyr + Gaussian_std_time = float(snapshot.metadata.parameters.get("SNIaDTD:STD_characteristic_time_Gyr", False)) * unyt.Gyr + elif used_DTD == "broken-power-law": + SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun + power_law_slope_long_time = float(snapshot.metadata.parameters.get("SNIaDTD:power_law_slope_long_time", False)) + break_time_Gyr = float(snapshot.metadata.parameters.get("SNIaDTD:break_time_Gyr", False) ) * unyt.Gyr + + # Read cosmology from the first run in the list + if idx == 0: + cosmology = snapshot.metadata.cosmology + + units = snapshot.units + boxsize = snapshot.metadata.boxsize + box_volume = boxsize[0] * boxsize[1] * boxsize[2] + + sfr_units = snapshot.gas.star_formation_rates.units + + # a, Redshift, SFR + scale_factor = data[2] + redshift = data[3] + star_formation_rate = (data[7] * sfr_units / box_volume).to(sfr_output_units) + times = data[1] * units.time + dM = data[4] * units.mass + + # Calculate the times we plot + times_desired = np.linspace(0.05,13.8,500) * unyt.Gyr + scale_factors_use = np.interp(times_desired, times, scale_factor) + + SNIa_rate = np.zeros(len(times_desired)) + + for i in range(1,len(times_desired)): + time_consider = times[times < times_desired[i]] + time_since_formation = times_desired[i] - time_consider + dM_consider = dM[times < times_desired[i]] + #SNIa_rate_individual = 1.6e-3 * exponential_law_DTD(time_since_formation, 2.0, 0.04) * dM_consider + #SNIa_rate_individual = 1.6e-3 * power_law_beta_one_DTD(time_since_formation, 0.04, 13.6) * dM_consider + if used_DTD == "power-law": + SNIa_rate_individual = SNIa_efficiency * power_law_DTD(time_since_formation, delay_time, normalization_timescale,power_law_slope) * dM_consider + elif used_DTD == "power-law-beta-one": + SNIa_rate_individual = SNIa_efficiency * power_law_beta_one_DTD(time_since_formation, delay_time, normalization_timescale) * dM_consider + elif used_DTD == "exponential": + SNIa_rate_individual = SNIa_efficiency * exponential_law_DTD(time_since_formation, exponential_decay, delay_time) * dM_consider + elif used_DTD == "Gaussian": + SNIa_rate_individual = Gaussian_SNIa_efficiency * Gaussian_law_DTD(time_since_formation, delay_time, Gaussian_characteristic_time, Gaussian_std_time) * dM_consider + elif used_DTD == "broken-power-law": + SNIa_rate_individual = SNIa_efficiency * broken_power_law_DTD(time_since_formation, power_law_slope_short_time, power_law_slope_long_time, break_time_Gyr, delay_time, normalization_timescale) * dM_consider + + SNIa_rate_sum = np.sum(SNIa_rate_individual) + SNIa_rate[i] = SNIa_rate_sum + + SNIa_rate = (SNIa_rate / box_volume / unyt.Gyr).to(SNIa_output_units) + + # High z-order as we always want these to be on top of the observations + simulation_lines.append( + ax.plot(scale_factors_use, SNIa_rate.value * multiplicative_factor, zorder=10000)[0] + ) + simulation_labels.append(name) + +observation_lines = [] +observation_labels = [] + +path_to_obs_data = f"{arguments.config.config_directory}/{arguments.config.observational_data_directory}" +observational_data = load_observations( + sorted(glob.glob(f"{path_to_obs_data}/data/CosmicSNIaRate/*.hdf5")) +) + +for obs_data in observational_data: + observation_lines.append( + ax.errorbar( + obs_data.x.value, + obs_data.y.value * multiplicative_factor, + yerr=obs_data.y_scatter.value * multiplicative_factor, + label=obs_data.citation, + linestyle="none", + marker="o", + elinewidth=0.5, + markeredgecolor="none", + markersize=2, + zorder=-10, + capsize=1.0, + ) + ) + observation_labels.append(f"{obs_data.citation}") + + +redshift_ticks = np.array([0.0, 0.2, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +redshift_labels = [ + "$0$", + "$0.2$", + "$0.5$", + "$1$", + "$2$", + "$3$", + "$5$", + "$10$", + "$20$", + "$50$", + "$100$", +] +a_ticks = 1.0 / (redshift_ticks + 1.0) + +ax.set_xticks(a_ticks) +ax.set_xticklabels(redshift_labels) + +observation_legend = ax.legend( + observation_lines, observation_labels, markerfirst=True, loc=4, fontsize=4, ncol=2 +) + +simulation_legend = ax.legend( + simulation_lines, simulation_labels, markerfirst=False, loc="upper right" +) + +ax.add_artist(observation_legend) + +# Create second X-axis (to plot cosmic time alongside redshift) +ax2 = ax.twiny() +ax2.set_xscale("log") + +# Cosmic-time ticks (in Gyr) along the second X-axis +t_ticks = np.array([0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, cosmology.age(1.0e-5).value]) + +# To place the new ticks onto the X-axis we need to know the corresponding scale factors +a_ticks_2axis = [ + 1.0 / (1.0 + z_at_value(cosmology.age, t_tick * Gyr)) for t_tick in t_ticks +] + +# Attach the ticks to the second X-axis +ax2.set_xticks(a_ticks_2axis) + +# Format the ticks' labels +ax2.set_xticklabels(["$%2.1f$" % t_tick for t_tick in t_ticks]) + +# Final adjustments +ax.tick_params(axis="x", which="minor", bottom=False) +ax2.tick_params(axis="x", which="minor", top=False) + +ax.set_ylim(3e-2, 2.0) +ax.set_xlim(1.02, 0.07) +ax2.set_xlim(1.02, 0.07) + +ax.set_xlabel("Redshift $z$") +ax.set_ylabel(f"SNIa rate [$10^{{-{log_multiplicative_factor}}}$ yr$^{{-1}}$ cMpc$^{{-3}}$]") +ax2.set_xlabel("Cosmic time [Gyr]") + +fig.savefig(f"{output_path}/log_SNIa_rate_history_based_on_CSFH.png") From 07e56a936cc974efb68e99c49b746aa92213a294 Mon Sep 17 00:00:00 2001 From: folkert Date: Thu, 16 Mar 2023 09:38:41 +0000 Subject: [PATCH 08/34] Improve the CEJSN and collapsar plot script --- colibre/scripts/cosmic_log_CEJSN_rate.py | 2 +- colibre/scripts/cosmic_log_collapsar_rate.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/colibre/scripts/cosmic_log_CEJSN_rate.py b/colibre/scripts/cosmic_log_CEJSN_rate.py index 1b6dc4ef..2a1b6cc6 100644 --- a/colibre/scripts/cosmic_log_CEJSN_rate.py +++ b/colibre/scripts/cosmic_log_CEJSN_rate.py @@ -74,7 +74,7 @@ # High z-order as we always want these to be on top of the observations simulation_lines.append( - ax.plot(scale_factor, CEJSN_rate.value * multiplicative_factor, zorder=10000, linestyle="--")[0] + ax.plot(scale_factor, CEJSN_rate.value * multiplicative_factor, zorder=10000)[0] ) simulation_labels.append(name) diff --git a/colibre/scripts/cosmic_log_collapsar_rate.py b/colibre/scripts/cosmic_log_collapsar_rate.py index 1c945a50..986cc6e4 100644 --- a/colibre/scripts/cosmic_log_collapsar_rate.py +++ b/colibre/scripts/cosmic_log_collapsar_rate.py @@ -74,7 +74,7 @@ # High z-order as we always want these to be on top of the observations simulation_lines.append( - ax.plot(scale_factor, collapsar_rate.value * multiplicative_factor, zorder=10000, linestyle="-.")[0] + ax.plot(scale_factor, collapsar_rate.value * multiplicative_factor, zorder=10000)[0] ) simulation_labels.append(name) From 3ce2cb45564f62d28fea5b24488872f401f2834f Mon Sep 17 00:00:00 2001 From: folkert Date: Tue, 21 Mar 2023 12:58:15 +0000 Subject: [PATCH 09/34] Add the Brown+2019 data to the specific SNIa rate versus stellar mass plot --- colibre/auto_plotter/snia_rates.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/colibre/auto_plotter/snia_rates.yml b/colibre/auto_plotter/snia_rates.yml index 03564ba2..162b2242 100644 --- a/colibre/auto_plotter/snia_rates.yml +++ b/colibre/auto_plotter/snia_rates.yml @@ -31,6 +31,8 @@ stellar_mass_snia_rates_per_stellar_mass_50: - filename: GalaxyStellarMassSNIaRatePerStellarMass/Kistler2014.hdf5 - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2015.hdf5 - filename: GalaxyStellarMassSNIaRatePerStellarMass/Graur2017.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Brown2019_vol_limited.hdf5 + - filename: GalaxyStellarMassSNIaRatePerStellarMass/Brown2019_full.hdf5 - filename: GalaxyStellarMassSNIaRatePerStellarMass/Wiseman2021.hdf5 stellar_mass_snia_rates_per_stellar_mass_active_only_50: From ce9a2ac1022ba5423da17a73a56c12ba64a6195a Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Fri, 28 Apr 2023 09:04:08 +0200 Subject: [PATCH 10/34] Update colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py remove f-string Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index fad83eea..172e6f2b 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -251,7 +251,7 @@ def CC_SN_DTD(t, t_min, t_max): ax2.set_xlim(1.02, 0.07) ax.set_xlabel("Redshift $z$") -ax.set_ylabel(f"SNIa rate / CC SN rate") +ax.set_ylabel("SNIa rate / CC SN rate") ax2.set_xlabel("Cosmic time [Gyr]") fig.savefig(f"{output_path}/SNIa_over_CC_rate_history_based_on_CSFH.png") From 535dd2465c231a5fe90359175663b9da1800aa60 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Fri, 28 Apr 2023 09:04:31 +0200 Subject: [PATCH 11/34] Update colibre/description.html Co-authored-by: Evgenii Chaikin --- colibre/description.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/description.html b/colibre/description.html index d14ee3be..e533205d 100644 --- a/colibre/description.html +++ b/colibre/description.html @@ -433,7 +433,7 @@

SNIa DTD

- + {% if data.metadata.parameters.get("SNIaDTD:power_law_slope", False) %} {% else %} From 7f7e784cf698391c59441f4999ba031509addc61 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Fri, 28 Apr 2023 09:04:41 +0200 Subject: [PATCH 12/34] Update colibre/description.html Co-authored-by: Evgenii Chaikin --- colibre/description.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/description.html b/colibre/description.html index e533205d..a139ed3a 100644 --- a/colibre/description.html +++ b/colibre/description.html @@ -463,7 +463,7 @@

SNIa DTD

- +
{{ data.metadata.parameters | get_if_present_float("SNIaDTD:normalization_timescale_Gyr") }} Gyr
power law slopePower law slope{{ data.metadata.parameters | get_if_present_float("SNIaDTD:power_law_slope") }}{{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_delay_time_Gyr") }} Gyr
exponential delay timeExponential delay time {{ data.metadata.parameters | get_if_present_float("SNIaDTD:SNIa_timescale_Gyr") }} Gyr
From f476f938fa6c398ed4244448ed807692c1254d0c Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Fri, 28 Apr 2023 09:04:53 +0200 Subject: [PATCH 13/34] Update colibre/description.html Co-authored-by: Evgenii Chaikin --- colibre/description.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/description.html b/colibre/description.html index a139ed3a..c7124f03 100644 --- a/colibre/description.html +++ b/colibre/description.html @@ -468,7 +468,7 @@

SNIa DTD

{% else %} -

DTD not found

+

DTD model is not found

{% endif %} {% endif %} From faf16f92b4e1f32dd5f66880536cba40e2507161 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:50:19 +0200 Subject: [PATCH 14/34] Update colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py Change == to is Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index 172e6f2b..46551136 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -98,7 +98,7 @@ def CC_SN_DTD(t, t_min, t_max): # find out which DTD model we are currently using in the code normalization_timescale = snapshot.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", None) - if normalization_timescale == None: + if normalization_timescale is None: have_normalization_timescale = False else: normalization_timescale = float(normalization_timescale) * unyt.Gyr From ab26d85aa5402dd039df4ba031f24d4d9731760d Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:50:48 +0200 Subject: [PATCH 15/34] Update colibre/auto_plotter/snia_rates.yml Change to LaTeX formattting Co-authored-by: Evgenii Chaikin --- colibre/auto_plotter/snia_rates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/auto_plotter/snia_rates.yml b/colibre/auto_plotter/snia_rates.yml index 162b2242..15e1e96f 100644 --- a/colibre/auto_plotter/snia_rates.yml +++ b/colibre/auto_plotter/snia_rates.yml @@ -348,7 +348,7 @@ star_formation_rates_snia_rates_per_stellar_mass_50: units: "Solar_Mass/year" metadata: title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) - caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above $10^{10} \mathrm{M_\odot}$. section: SNIa Rate (SFR and sSFR) observational_data: - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 From dfb2aedaaed992f947d8282326970f7407d83691 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:51:08 +0200 Subject: [PATCH 16/34] Update colibre/auto_plotter/snia_rates.yml Change to LaTeX formatting Co-authored-by: Evgenii Chaikin --- colibre/auto_plotter/snia_rates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/auto_plotter/snia_rates.yml b/colibre/auto_plotter/snia_rates.yml index 15e1e96f..6647b7a8 100644 --- a/colibre/auto_plotter/snia_rates.yml +++ b/colibre/auto_plotter/snia_rates.yml @@ -383,7 +383,7 @@ specific_star_formation_rates_snia_rates_per_stellar_mass_50: units: "1/gigayear" metadata: title: sSFR-SNIa rate per stellar mass relation (50 kpc aperture) - caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 1e10 Msun. + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above $10^{10} \mathrm{M_\odot}$. section: SNIa Rate (SFR and sSFR) observational_data: - filename: SpecificStarFormationRateSNIaRatePerStellarMass/Mannucci2005.hdf5 From 3d753383d3defff0b1e36e238adbb4a1feb3f62d Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:51:23 +0200 Subject: [PATCH 17/34] Update colibre/auto_plotter/snia_rates.yml Change to LaTeX formatting Co-authored-by: Evgenii Chaikin --- colibre/auto_plotter/snia_rates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/auto_plotter/snia_rates.yml b/colibre/auto_plotter/snia_rates.yml index 6647b7a8..4d05a617 100644 --- a/colibre/auto_plotter/snia_rates.yml +++ b/colibre/auto_plotter/snia_rates.yml @@ -456,7 +456,7 @@ star_formation_rates_snia_rates_per_stellar_mass_50_Mstar5e10: units: "Solar_Mass/year" metadata: title: SFR-SNIa rate per stellar mass relation (50 kpc aperture) - caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above 5e10 Msun. + caption: Uses a 50 kpc 3D aperture, only select galaxies with a stellar mass above $5 \times 10^{10} \mathrm{M_\odot}$. section: SNIa Rate (SFR and sSFR) observational_data: - filename: StarFormationRateSNIaRatePerStellarMass/Graur2015.hdf5 From 0e167e1c58606bc49b1cda6827eca2ecda2bbb61 Mon Sep 17 00:00:00 2001 From: fonotec Date: Mon, 22 May 2023 09:55:47 +0200 Subject: [PATCH 18/34] Update the description string --- colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py | 2 +- colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py index 16c8dc99..6199251c 100644 --- a/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_CC_SN_rate_CSFH_based.py @@ -33,7 +33,7 @@ def CC_SN_DTD(t, t_min, t_max): return value arguments = ScriptArgumentParser( - description="Creates a star formation history plot, with added observational data." + description="Creates a CC SN history plot, with added observational data." ) snapshot_filenames = [ diff --git a/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py index b9531fd3..352580bd 100644 --- a/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py @@ -33,7 +33,7 @@ def CC_SN_DTD(t, t_min, t_max): return value arguments = ScriptArgumentParser( - description="Creates a star formation history plot, with added observational data." + description="Creates a CC SN history plot, with added observational data." ) snapshot_filenames = [ From fc42d50620c2ca44ee925461dc70ba98a0af2e07 Mon Sep 17 00:00:00 2001 From: fonotec Date: Mon, 22 May 2023 09:57:42 +0200 Subject: [PATCH 19/34] Remove out commented code --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index 46551136..d0452d91 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -172,8 +172,6 @@ def CC_SN_DTD(t, t_min, t_max): time_consider = times[times < times_desired[i]] time_since_formation = times_desired[i] - time_consider dM_consider = dM[times < times_desired[i]] - #SNIa_rate_individual = 1.6e-3 * exponential_law_DTD(time_since_formation, 2.0, 0.04) * dM_consider - #SNIa_rate_individual = 1.6e-3 * power_law_beta_one_DTD(time_since_formation, 0.04, 13.6) * dM_consider if used_DTD == "power-law": SNIa_rate_individual = SNIa_efficiency * power_law_DTD(time_since_formation, delay_time, normalization_timescale,power_law_slope) * dM_consider elif used_DTD == "power-law-beta-one": From 31fdbe7b81ca12e040287c7a3d3edf12f9b20d8b Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:58:32 +0200 Subject: [PATCH 20/34] Update colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index d0452d91..f2eed18d 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -105,7 +105,7 @@ def CC_SN_DTD(t, t_min, t_max): have_normalization_timescale = True exponential_decay = snapshot.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", None) - if exponential_decay == None: + if exponential_decay is None: have_exponential_decay = False else: have_exponential_decay = True From 7c1b1180b22869a9f226ed1352a0ee849c339c89 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:59:09 +0200 Subject: [PATCH 21/34] Update colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index f2eed18d..6e3732aa 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -112,7 +112,7 @@ def CC_SN_DTD(t, t_min, t_max): exponential_decay = float(exponential_decay) * unyt.Gyr Gaussian_SNIa_efficiency = snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", None) - if Gaussian_SNIa_efficiency == None: + if Gaussian_SNIa_efficiency is None: have_Gaussian = False else: have_Gaussian = True From 3a1e38073d00cbda936ceb4fd294720f81f4f63b Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 09:59:33 +0200 Subject: [PATCH 22/34] Update colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index 6e3732aa..7136ed1b 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -119,7 +119,7 @@ def CC_SN_DTD(t, t_min, t_max): Gaussian_SNIa_efficiency = float(Gaussian_SNIa_efficiency) / unyt.Msun power_law_slope = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope", None) - if power_law_slope == None: + if power_law_slope is None: have_slope = False else: have_slope = True From 2f488c43c56fcd070eeaefc45638f462ddbe9683 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:00:03 +0200 Subject: [PATCH 23/34] Update colibre/scripts/cosmic_log_CC_SN_rate.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_log_CC_SN_rate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_log_CC_SN_rate.py b/colibre/scripts/cosmic_log_CC_SN_rate.py index 9ce833a1..d1837315 100644 --- a/colibre/scripts/cosmic_log_CC_SN_rate.py +++ b/colibre/scripts/cosmic_log_CC_SN_rate.py @@ -1,5 +1,5 @@ """ -Plots the cosmic CCSN rate history. +Plots the cosmic log CCSN rate history. """ import unyt From cb47568fa19fe3547c40bdb3afc1790f17761714 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:00:28 +0200 Subject: [PATCH 24/34] Update colibre/scripts/cosmic_log_CC_SN_rate.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_log_CC_SN_rate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_log_CC_SN_rate.py b/colibre/scripts/cosmic_log_CC_SN_rate.py index d1837315..cd232a58 100644 --- a/colibre/scripts/cosmic_log_CC_SN_rate.py +++ b/colibre/scripts/cosmic_log_CC_SN_rate.py @@ -17,7 +17,7 @@ from swiftpipeline.argumentparser import ScriptArgumentParser arguments = ScriptArgumentParser( - description="Creates a CC SN rate history plot, with added observational data." + description="Creates a log CC SN rate history plot, with added observational data." ) snapshot_filenames = [ From a0dda865df10888da621f6fad37702233f56ff4c Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:01:29 +0200 Subject: [PATCH 25/34] Update colibre/scripts/cosmic_log_SNIa_rate.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_log_SNIa_rate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_log_SNIa_rate.py b/colibre/scripts/cosmic_log_SNIa_rate.py index 8047737a..20bb6d43 100644 --- a/colibre/scripts/cosmic_log_SNIa_rate.py +++ b/colibre/scripts/cosmic_log_SNIa_rate.py @@ -1,5 +1,5 @@ """ -Plots the cosmic SNIa rate history. +Plots the cosmic log SNIa rate history. """ import unyt From bd80b528cf05a90a343da215a77d64b5b31d79f8 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:02:14 +0200 Subject: [PATCH 26/34] Update colibre/scripts/cosmic_log_SNIa_rate.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_log_SNIa_rate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_log_SNIa_rate.py b/colibre/scripts/cosmic_log_SNIa_rate.py index 20bb6d43..05317b48 100644 --- a/colibre/scripts/cosmic_log_SNIa_rate.py +++ b/colibre/scripts/cosmic_log_SNIa_rate.py @@ -17,7 +17,7 @@ from swiftpipeline.argumentparser import ScriptArgumentParser arguments = ScriptArgumentParser( - description="Creates a SNIa rate history plot, with added observational data." + description="Creates a log SNIa rate history plot, with added observational data." ) snapshot_filenames = [ From 196a69501729dc84f8f8533af090b38be5a9985c Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:03:07 +0200 Subject: [PATCH 27/34] Update colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py index 8b1af21b..40426cf0 100644 --- a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py @@ -108,7 +108,7 @@ def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, d # find out which DTD model we are currently using in the code normalization_timescale = snapshot.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", None) - if normalization_timescale == None: + if normalization_timescale is None: have_normalization_timescale = False else: normalization_timescale = float(normalization_timescale) * unyt.Gyr From 3b42698bd2a1dd2bf0150790e91f8d6145e833ea Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:03:47 +0200 Subject: [PATCH 28/34] Update colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py index 40426cf0..a6ac0594 100644 --- a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py @@ -122,7 +122,7 @@ def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, d exponential_decay = float(exponential_decay) * unyt.Gyr Gaussian_SNIa_efficiency = snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", None) - if Gaussian_SNIa_efficiency == None: + if Gaussian_SNIa_efficiency is None: have_Gaussian = False else: have_Gaussian = True From 6927f194731735aa0c8d57011b58924d1e3e4de6 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:04:25 +0200 Subject: [PATCH 29/34] Update colibre/scripts/cosmic_SNIa_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py index baa5643a..51ddd9a7 100644 --- a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py @@ -99,7 +99,7 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): have_normalization_timescale = True exponential_decay = snapshot.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", None) - if exponential_decay == None: + if exponential_decay is None: have_exponential_decay = False else: have_exponential_decay = True From df13395f088cf62978d6881153deeae9164fa9d8 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:04:56 +0200 Subject: [PATCH 30/34] Update colibre/scripts/cosmic_SNIa_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py index 51ddd9a7..84d25eb7 100644 --- a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py @@ -92,7 +92,7 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): # find out which DTD model we are currently using in the code normalization_timescale = snapshot.metadata.parameters.get("SNIaDTD:normalization_timescale_Gyr", None) - if normalization_timescale == None: + if normalization_timescale is None: have_normalization_timescale = False else: normalization_timescale = float(normalization_timescale) * unyt.Gyr From 9f55395a23dc0cbddd6bb090c2d2beb2a8beb395 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:06:33 +0200 Subject: [PATCH 31/34] Update colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index 7136ed1b..1316b6bc 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -136,7 +136,7 @@ def CC_SN_DTD(t, t_min, t_max): delay_time = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_delay_time_Gyr", False) ) * unyt.Gyr - if used_DTD == "power-law" or used_DTD == "exponential" or used_DTD == "power-law-beta-one": + if used_DTD in ["power-law", "exponential", "power-law-beta-one"]: SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun elif used_DTD == "Gaussian": Gaussian_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False)) / unyt.Msun From e454ddf128a5d7745bb983ba5b4f851a7d6b4a03 Mon Sep 17 00:00:00 2001 From: Folkert Nobels Date: Mon, 22 May 2023 10:09:02 +0200 Subject: [PATCH 32/34] Apply suggestions from code review Co-authored-by: Evgenii Chaikin --- colibre/scripts/cosmic_SNIa_rate_CSFH_based.py | 4 ++-- colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py index 84d25eb7..e3d0e2a8 100644 --- a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py @@ -113,7 +113,7 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): Gaussian_SNIa_efficiency = float(Gaussian_SNIa_efficiency) / unyt.Msun power_law_slope = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope", None) - if power_law_slope == None: + if power_law_slope is None: have_slope = False else: have_slope = True @@ -130,7 +130,7 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): delay_time = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_delay_time_Gyr", False) ) * unyt.Gyr - if used_DTD == "power-law" or used_DTD == "exponential" or used_DTD == "power-law-beta-one": + if used_DTD in ["power-law", "exponential", "power-law-beta-one"]: SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun elif used_DTD == "Gaussian": Gaussian_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False)) / unyt.Msun diff --git a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py index a6ac0594..cff3390a 100644 --- a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py @@ -115,7 +115,7 @@ def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, d have_normalization_timescale = True exponential_decay = snapshot.metadata.parameters.get("SNIaDTD:SNIa_timescale_Gyr", None) - if exponential_decay == None: + if exponential_decay is None: have_exponential_decay = False else: have_exponential_decay = True @@ -129,14 +129,14 @@ def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, d Gaussian_SNIa_efficiency = float(Gaussian_SNIa_efficiency) / unyt.Msun power_law_slope = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope", None) - if power_law_slope == None: + if power_law_slope is None: have_slope = False else: have_slope = True power_law_slope = float(power_law_slope) power_law_slope_short_time = snapshot.metadata.parameters.get("SNIaDTD:power_law_slope_short_time", None) - if power_law_slope_short_time == None: + if power_law_slope_short_time is None: have_broken_slope = False else: have_broken_slope = True @@ -155,7 +155,7 @@ def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, d delay_time = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_delay_time_Gyr", False) ) * unyt.Gyr - if used_DTD == "power-law" or used_DTD == "exponential" or used_DTD == "power-law-beta-one": + if used_DTD in ["power-law", "exponential", "power-law-beta-one"]: SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_p_Msun", False) ) / unyt.Msun elif used_DTD == "Gaussian": Gaussian_SNIa_efficiency = float(snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", False)) / unyt.Msun From 15a108d68bed452918d44e1f7609068da86f96b1 Mon Sep 17 00:00:00 2001 From: fonotec Date: Tue, 23 May 2023 15:50:59 +0200 Subject: [PATCH 33/34] Improve Evgeniis comments on the description --- colibre/scripts/cosmic_SNIa_rate.py | 5 ----- colibre/scripts/cosmic_SNIa_rate_CSFH_based.py | 5 +---- colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py | 3 +-- colibre/scripts/cosmic_log_CEJSN_rate.py | 4 ++-- colibre/scripts/cosmic_log_NSM_rate.py | 4 ++-- colibre/scripts/cosmic_log_collapsar_rate.py | 4 ++-- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/colibre/scripts/cosmic_SNIa_rate.py b/colibre/scripts/cosmic_SNIa_rate.py index 1d76f696..0f5c77fa 100644 --- a/colibre/scripts/cosmic_SNIa_rate.py +++ b/colibre/scripts/cosmic_SNIa_rate.py @@ -160,8 +160,3 @@ ax2.set_xlabel("Cosmic time [Gyr]") fig.savefig(f"{output_path}/SNIa_rate_history.png") - -ax.set_xlim(1.02, 0.33) -ax2.set_xlim(1.02, 0.33) - -fig.savefig(f"{output_path}/SNIa_rate_history_zoom.png") diff --git a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py index e3d0e2a8..1c8af888 100644 --- a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py @@ -1,6 +1,5 @@ """ -Plots the star formation history. Modified version of the script in the -github.com/swiftsim/swiftsimio-examples repository. +Plots the cosmic SNIa rate based on the star formation history. """ import unyt @@ -165,8 +164,6 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): time_consider = times[times < times_desired[i]] time_since_formation = times_desired[i] - time_consider dM_consider = dM[times < times_desired[i]] - #SNIa_rate_individual = 1.6e-3 * exponential_law_DTD(time_since_formation, 2.0, 0.04) * dM_consider - #SNIa_rate_individual = 1.6e-3 * power_law_beta_one_DTD(time_since_formation, 0.04, 13.6) * dM_consider if used_DTD == "power-law": SNIa_rate_individual = SNIa_efficiency * power_law_DTD(time_since_formation, delay_time, normalization_timescale,power_law_slope) * dM_consider elif used_DTD == "power-law-beta-one": diff --git a/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py index 352580bd..e8b38fc9 100644 --- a/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_log_CC_SN_rate_CSFH_based.py @@ -1,6 +1,5 @@ """ -Plots the star formation history. Modified version of the script in the -github.com/swiftsim/swiftsimio-examples repository. +Plots the cosmic core-collapse SNe rate based on the star formation history and use a logged y-axis. """ import unyt diff --git a/colibre/scripts/cosmic_log_CEJSN_rate.py b/colibre/scripts/cosmic_log_CEJSN_rate.py index 2a1b6cc6..4263dbcf 100644 --- a/colibre/scripts/cosmic_log_CEJSN_rate.py +++ b/colibre/scripts/cosmic_log_CEJSN_rate.py @@ -1,5 +1,5 @@ """ -Plots the cosmic r_process rate history. +Plots the cosmic CEJSN rate history based on the chemical enrichment logger. """ import unyt @@ -17,7 +17,7 @@ from swiftpipeline.argumentparser import ScriptArgumentParser arguments = ScriptArgumentParser( - description="Creates a r-process rate history plot, with added observational data." + description="Creates a CEJSN rate history plot, with added observational data." ) snapshot_filenames = [ diff --git a/colibre/scripts/cosmic_log_NSM_rate.py b/colibre/scripts/cosmic_log_NSM_rate.py index b18fb303..b33bcb3f 100644 --- a/colibre/scripts/cosmic_log_NSM_rate.py +++ b/colibre/scripts/cosmic_log_NSM_rate.py @@ -1,5 +1,5 @@ """ -Plots the cosmic r_process rate history. +Plots the cosmic neutron star merger rate history based on the chemical enrichment logger. """ import unyt @@ -17,7 +17,7 @@ from swiftpipeline.argumentparser import ScriptArgumentParser arguments = ScriptArgumentParser( - description="Creates a r-process rate history plot, with added observational data." + description="Creates a neutral star merger rate history plot, with added observational data." ) snapshot_filenames = [ diff --git a/colibre/scripts/cosmic_log_collapsar_rate.py b/colibre/scripts/cosmic_log_collapsar_rate.py index 986cc6e4..7ffdfc2b 100644 --- a/colibre/scripts/cosmic_log_collapsar_rate.py +++ b/colibre/scripts/cosmic_log_collapsar_rate.py @@ -1,5 +1,5 @@ """ -Plots the cosmic r_process rate history. +Plots the cosmic collapser rate history based on the chemical enrichment logger. """ import unyt @@ -17,7 +17,7 @@ from swiftpipeline.argumentparser import ScriptArgumentParser arguments = ScriptArgumentParser( - description="Creates a r-process rate history plot, with added observational data." + description="Creates a collapser rate history plot, with added observational data." ) snapshot_filenames = [ From 257dc7ea7bb5198d6e014b3b43c4eeb74a3b6b25 Mon Sep 17 00:00:00 2001 From: fonotec Date: Tue, 23 May 2023 16:03:43 +0200 Subject: [PATCH 34/34] Include further suggestions from Evgenii to the code --- colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py | 3 +-- colibre/scripts/cosmic_SNIa_rate_CSFH_based.py | 4 ++-- colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py | 5 +---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py index 1316b6bc..ca15dce7 100644 --- a/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_over_CC_SN_rate_CSFH_based.py @@ -1,6 +1,5 @@ """ -Plots the star formation history. Modified version of the script in the -github.com/swiftsim/swiftsimio-examples repository. +Plots the cosmic SNIa rate over the core-collapse SNe rate based on the star formation history. """ import unyt diff --git a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py index 1c8af888..84570cf3 100644 --- a/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_SNIa_rate_CSFH_based.py @@ -59,7 +59,7 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): return value arguments = ScriptArgumentParser( - description="Creates a star formation history plot, with added observational data." + description="Creates a cosmic SNIa rate history plot based on the star formation history, with added observational data." ) snapshot_filenames = [ @@ -105,7 +105,7 @@ def Gaussian_law_DTD(t, t_delay, tmean, tsigma): exponential_decay = float(exponential_decay) * unyt.Gyr Gaussian_SNIa_efficiency = snapshot.metadata.parameters.get("SNIaDTD:SNIa_efficiency_gauss_p_Msun", None) - if Gaussian_SNIa_efficiency == None: + if Gaussian_SNIa_efficiency is None: have_Gaussian = False else: have_Gaussian = True diff --git a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py index cff3390a..737e4f11 100644 --- a/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py +++ b/colibre/scripts/cosmic_log_SNIa_rate_CSFH_based.py @@ -1,6 +1,5 @@ """ -Plots the star formation history. Modified version of the script in the -github.com/swiftsim/swiftsimio-examples repository. +Plots the cosmic SNIa rate history based on the star formation history and use a logged y-axis. """ import unyt @@ -194,8 +193,6 @@ def broken_power_law_DTD(t, slope_short_time, slope_long_time, break_time_Gyr, d time_consider = times[times < times_desired[i]] time_since_formation = times_desired[i] - time_consider dM_consider = dM[times < times_desired[i]] - #SNIa_rate_individual = 1.6e-3 * exponential_law_DTD(time_since_formation, 2.0, 0.04) * dM_consider - #SNIa_rate_individual = 1.6e-3 * power_law_beta_one_DTD(time_since_formation, 0.04, 13.6) * dM_consider if used_DTD == "power-law": SNIa_rate_individual = SNIa_efficiency * power_law_DTD(time_since_formation, delay_time, normalization_timescale,power_law_slope) * dM_consider elif used_DTD == "power-law-beta-one":