Skip to content

Commit

Permalink
Added EOS2021 theory line
Browse files Browse the repository at this point in the history
Added functionality to plot the AllGalaxies (EOS2021) model from Munoz+2021 (2110.13919).

The code in process_munoz_2021.py reads the data in the theory folder, both for the standard (EOS) and optimistic (OPT) parameters. Same structure as other theory dictionaries
  • Loading branch information
JulianBMunoz authored and bhazelton committed Feb 12, 2022
1 parent da92171 commit 23801e6
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 1 deletion.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 13 additions & 1 deletion eor_limits/plot_eor_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
from eor_limits.data import DATA_PATH

default_theory_params = {
"munoz_2021_AllGalaxies_z8.5": {
"paper": "munoz_2021",
"model": "EOS",
"redshift": 8.5,
"linewidth": 3,
},
"mesinger_2016_faint_nf0.8": {
"paper": "mesinger_2016",
"model": "faint",
Expand All @@ -39,7 +45,7 @@
"paper": "mesinger_2016",
"model": "bright",
"nf": 0.5,
"linewidth": 3,
"linewidth": 2,
},
"pagano_beta1_z8.5": {"paper": "pagano_liu_2020", "beta": 1, "redshift": 8.5},
"pagano_beta-1_z8.5": {"paper": "pagano_liu_2020", "beta": -1, "redshift": 8.5},
Expand Down Expand Up @@ -238,6 +244,12 @@ def make_plot(
dict_use = copy.deepcopy(theory)
dict_use.pop("paper")
paper_dict = get_pagano_2020_line(**dict_use)
elif theory["paper"] == "munoz_2021":
from eor_limits.process_munoz_2021 import get_munoz_2021_line

dict_use = copy.deepcopy(theory)
dict_use.pop("paper")
paper_dict = get_munoz_2021_line(**dict_use)
else:
raise ValueError(
"Theory paper " + theory["paper"] + " is not a yaml in the "
Expand Down
81 changes: 81 additions & 0 deletions eor_limits/process_munoz_2021.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#! /usr/bin/env python
# -*- mode: python; coding: utf-8 -*
# Copyright (c) 2019 Nichole Barry, Bryna Hazelton
# Licensed under the 2-clause BSD License
# (Slightly) modified by Julian Munoz in 2021
"""Process Munoz et al. 2021 spectra for plotting."""

import os

import numpy as np

from eor_limits.data import DATA_PATH



def get_munoz_2021_line(model="EOS", redshift=None, linewidth=1.0):
"""
Get the AllGalaxies model
Parameters
----------
model : str
Which model to use. Options are 'EOS' for standard EOS2021 (AllGalaxies) or OPT for 'optimistic' (More PopIII stars)
redshift : float
Which redshift to get a model for (the closest match).
"""

if model not in ["EOS", "OPT"]:
raise ValueError("Model must be either 'EOS' or 'OPT'.")

paper_dict = {
"author": "Mu\~noz",
"year": 2021,
"model": " ",
"doi": "arXiv: 2110.13919",
"type": "line",
"marker": ".",
"linewidth": linewidth,
}

if model == "EOS":
munoz_file_k = os.path.join(DATA_PATH, "theory", "munoz_2021_allgalaxies/1pt5Gpc_EOS_coeval_pow_kbins.bin")
munoz_file_z = os.path.join(DATA_PATH, "theory", "munoz_2021_allgalaxies/1pt5Gpc_EOS_coeval_pow_zlist.bin")
munoz_file_P21 = os.path.join(DATA_PATH, "theory", "munoz_2021_allgalaxies/1pt5Gpc_EOS_coeval_pow_P21.bin")
#munoz_file_errP21 = os.path.join(DATA_PATH, "theory", "munoz_2021_allgalaxies/1pt5Gpc_EOS_coeval_pow_errP21.bin")
paper_dict["linestyle"] = "solid"
paper_dict["model"] = "AllGalaxies"
else: ## model == "OPT"
munoz_file_k = os.path.join(DATA_PATH, "theory", "munoz_2021_optimistic/600Mpc_pt0_coeval_pow_kbins.bin")
munoz_file_z = os.path.join(DATA_PATH, "theory", "munoz_2021_optimistic/600Mpc_pt0_coeval_pow_zlist.bin")
munoz_file_P21 = os.path.join(DATA_PATH, "theory", "munoz_2021_optimistic/600Mpc_pt0_coeval_pow_P21.bin")
#munoz_file_errP21 = os.path.join(DATA_PATH, "theory", "munoz_2021_allgalaxies/600Mpc_pt0_coeval_pow_errP21.bin")
paper_dict["linestyle"] = "dashdotted"
paper_dict["model"] = "AllGalaxies (OPT)"







redshifts = np.fromfile(munoz_file_z)
k_arr = np.fromfile(munoz_file_k)
delta_squared_arr = np.fromfile(munoz_file_P21).reshape((redshifts.size, k_arr.size))



# Sort in order of ascending redshift
order = np.argsort(redshifts)
redshifts = redshifts[order]
delta_squared_arr = delta_squared_arr[order]

redshift_ind = np.argmin(np.abs(redshifts - redshift))

paper_dict["k"] = k_arr.tolist()
# redshift is the 1st index, k is the 2nd
paper_dict["delta_squared"] = delta_squared_arr[redshift_ind, :]
paper_dict["redshift"] = np.asarray(redshifts)[redshift_ind].tolist()

return paper_dict

0 comments on commit 23801e6

Please sign in to comment.