From 30c34e3d672bf1ecabea93ac27ad2fc623bdf71e Mon Sep 17 00:00:00 2001 From: Rohith Varma Buddaraju Date: Mon, 8 Aug 2022 20:28:43 +0530 Subject: [PATCH] Add the 2020 python scripts to obtain Sphinx Gallery output --- tardis-setups/2020/README.rst | 4 ++ tardis-setups/2020/plot_16d.py | 71 +++++++++++++++++++++++++++ tardis-setups/2020/plot_22d.py | 66 +++++++++++++++++++++++++ tardis-setups/2020/plot_22d_he_01.py | 65 ++++++++++++++++++++++++ tardis-setups/2020/plot_22d_he_05.py | 65 ++++++++++++++++++++++++ tardis-setups/2020/plot_22d_he_10.py | 65 ++++++++++++++++++++++++ tardis-setups/2020/plot_30d.py | 66 +++++++++++++++++++++++++ tardis-setups/2020/plot_40d.py | 67 +++++++++++++++++++++++++ tardis-setups/setup_utils/__init__.py | 2 + tardis-setups/setup_utils/config.py | 25 ++++++++++ tardis-setups/setup_utils/download.py | 13 +++++ 11 files changed, 509 insertions(+) create mode 100644 tardis-setups/2020/README.rst create mode 100644 tardis-setups/2020/plot_16d.py create mode 100644 tardis-setups/2020/plot_22d.py create mode 100644 tardis-setups/2020/plot_22d_he_01.py create mode 100644 tardis-setups/2020/plot_22d_he_05.py create mode 100644 tardis-setups/2020/plot_22d_he_10.py create mode 100644 tardis-setups/2020/plot_30d.py create mode 100644 tardis-setups/2020/plot_40d.py create mode 100644 tardis-setups/setup_utils/__init__.py create mode 100644 tardis-setups/setup_utils/config.py create mode 100644 tardis-setups/setup_utils/download.py diff --git a/tardis-setups/2020/README.rst b/tardis-setups/2020/README.rst new file mode 100644 index 0000000..3b84292 --- /dev/null +++ b/tardis-setups/2020/README.rst @@ -0,0 +1,4 @@ +Year 2020 Results +================== + +Output of configuartion files uploaded in the year 2020. diff --git a/tardis-setups/2020/plot_16d.py b/tardis-setups/2020/plot_16d.py new file mode 100644 index 0000000..09f85bb --- /dev/null +++ b/tardis-setups/2020/plot_16d.py @@ -0,0 +1,71 @@ +""" +Williamson et al. (2020) Figure 2 t_explosion=16 days +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/16d.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/hach_exact_csvy_16d.csvy +""" + + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Comment this line if you do not need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +conf = Configuration.from_yaml( + "../../2020/2020_williamson_94I/code_comp_setups/16d.yml" +) + +# %% +# Note: Here the configuration is slightly modified to allow +# the configuration file on a computer with lower configuration. + +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() + diff --git a/tardis-setups/2020/plot_22d.py b/tardis-setups/2020/plot_22d.py new file mode 100644 index 0000000..c19b93f --- /dev/null +++ b/tardis-setups/2020/plot_22d.py @@ -0,0 +1,66 @@ +""" +Williamson et al. (2020) Figure 2 t_explosion=22 days +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/22d.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/hach_exact_csvy_22d.csvy +""" + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Uncomment this line if you need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +# Runs the example + +conf = Configuration.from_yaml( + "../../2020/2020_williamson_94I/code_comp_setups/22d.yml" +) +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() diff --git a/tardis-setups/2020/plot_22d_he_01.py b/tardis-setups/2020/plot_22d_he_01.py new file mode 100644 index 0000000..18856d0 --- /dev/null +++ b/tardis-setups/2020/plot_22d_he_01.py @@ -0,0 +1,65 @@ +""" +Williamson et al. (2020) Figure 3 g He=0.01M⊙ +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/he_setups/22d_he_01.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/he_setups/22d_He_0.01.csvy +""" + + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Uncomment this line if you need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +# Runs the example + +conf = Configuration.from_yaml("../../2020/2020_williamson_94I/he_setups/22d_he_01.yml") +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() diff --git a/tardis-setups/2020/plot_22d_he_05.py b/tardis-setups/2020/plot_22d_he_05.py new file mode 100644 index 0000000..5e22772 --- /dev/null +++ b/tardis-setups/2020/plot_22d_he_05.py @@ -0,0 +1,65 @@ +""" +Williamson et al. (2020) Figure 3 g He=0.05M⊙ +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/he_setups/22d_he_05.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/he_setups/22d_He_0.05.csvy +""" + + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Uncomment this line if you need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +# Runs the example + +conf = Configuration.from_yaml("../../2020/2020_williamson_94I/he_setups/22d_he_05.yml") +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() diff --git a/tardis-setups/2020/plot_22d_he_10.py b/tardis-setups/2020/plot_22d_he_10.py new file mode 100644 index 0000000..f3d1494 --- /dev/null +++ b/tardis-setups/2020/plot_22d_he_10.py @@ -0,0 +1,65 @@ +""" +Williamson et al. (2020) Figure 3 g He=0.10M⊙ +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/he_setups/22d_he_10.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/he_setups/22d_He_0.10.csvy +""" + + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Uncomment this line if you need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +# Runs the example + +conf = Configuration.from_yaml("../../2020/2020_williamson_94I/he_setups/22d_he_10.yml") +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() diff --git a/tardis-setups/2020/plot_30d.py b/tardis-setups/2020/plot_30d.py new file mode 100644 index 0000000..bd7e526 --- /dev/null +++ b/tardis-setups/2020/plot_30d.py @@ -0,0 +1,66 @@ +""" +Williamson et al. (2020) Figure 2 t_explosion=30 days +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/30d.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/hach_exact_csvy_30d.csvy +""" + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Uncomment this line if you need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +# Runs the example + +conf = Configuration.from_yaml( + "../../2020/2020_williamson_94I/code_comp_setups/30d.yml" +) +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() diff --git a/tardis-setups/2020/plot_40d.py b/tardis-setups/2020/plot_40d.py new file mode 100644 index 0000000..4d11ef9 --- /dev/null +++ b/tardis-setups/2020/plot_40d.py @@ -0,0 +1,67 @@ +""" +Williamson et al. (2020) Figure 2 t_explosion=40 days +========================== + + +Article: Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam 2021, ApJ, +“Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?” (`ADS Link`_). + +Original Input Files: `YAML`_, `CSVY`_ + +Original Atomic Dataset: Data missing + +Original Spectra: Data missing + +Notes: Please note that the spectra obtained below is obtained by using a slightly +modified configuration file. This is done to ensure that the spectra can be +obtained using the computers hosted by us. + +.. _ADS Link: https://ui.adsabs.harvard.edu/abs/2021ApJ...908..150W +.. _YAML: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/40d.yml +.. _CSVY: https://github.com/tardis-sn/tardis-setups/blob/master/2020/2020_williamson_94I/code_comp_setups/hach_exact_csvy_40d.csvy +""" + + +from tardis import run_tardis +from tardis.io.config_reader import Configuration +from tardis.io.atom_data.util import download_atom_data +import matplotlib.pyplot as plt + +import sys + +sys.path.append("../") +from setup_utils import config_modifier + +# %% +# Uncomment this line if you need to download the dataset. + + +download_atom_data("kurucz_cd23_chianti_H_He") + +# %% +# Runs the example + +conf = Configuration.from_yaml( + "../../2020/2020_williamson_94I/code_comp_setups/40d.yml" +) +conf = config_modifier(conf) +# %% +sim = run_tardis(conf) + + +spectrum = sim.runner.spectrum +spectrum_virtual = sim.runner.spectrum_virtual +spectrum_integrated = sim.runner.spectrum_integrated + +plt.figure(figsize=(10, 6.5)) + +spectrum.plot(label="Normal packets") +spectrum_virtual.plot(label="Virtual packets") +spectrum_integrated.plot(label="Formal integral") + +plt.xlim(500, 9000) +plt.title("TARDIS example model spectrum") +plt.xlabel("Wavelength [$\AA$]") +plt.ylabel("Luminosity density [erg/s/$\AA$]") +plt.legend() +plt.show() diff --git a/tardis-setups/setup_utils/__init__.py b/tardis-setups/setup_utils/__init__.py new file mode 100644 index 0000000..25b45c7 --- /dev/null +++ b/tardis-setups/setup_utils/__init__.py @@ -0,0 +1,2 @@ +from setup_utils.config import * +from setup_utils.download import * diff --git a/tardis-setups/setup_utils/config.py b/tardis-setups/setup_utils/config.py new file mode 100644 index 0000000..dc6df1b --- /dev/null +++ b/tardis-setups/setup_utils/config.py @@ -0,0 +1,25 @@ +import os + + +def find_file(name, path): + for dirpath, _, filename in os.walk(path): + if name in filename: + return os.path.join(dirpath, name) + return name + + +def config_modifier(conf): + conf["montecarlo"]["nthreads"] = 1 + conf["montecarlo"]["last_no_of_packets"] = 1.0e5 + conf["montecarlo"]["no_of_virtual_packets"] = 10 + + conf["atom_data"] = os.path.join( + os.path.expanduser("~"), "Downloads", "tardis-data", conf["atom_data"] + ) + + if os.path.exists(conf["atom_data"]) == False: + conf["atom_data"] = find_file(conf["atom_data"], "/") + if os.path.exists(conf["atom_data"]) == False: + raise + + return conf diff --git a/tardis-setups/setup_utils/download.py b/tardis-setups/setup_utils/download.py new file mode 100644 index 0000000..6d8c2ff --- /dev/null +++ b/tardis-setups/setup_utils/download.py @@ -0,0 +1,13 @@ +import requests +import os + + +def download_from_url(url): + try: + r = requests.get(url) + fname = r.headers.get("Content-Disposit").split("filename=")[1] + except AttributeError: + fname = url.split("/")[-1].split("?")[0] + + file_path = os.path.join(os.path.expanduser("~"), "Downloads", "tardis-data", fname) + open(file_path, "wb").write(r.content)