Skip to content

Commit

Permalink
update IGM files mpg sims
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavesmontero committed Nov 5, 2024
1 parent c8db0d7 commit d9fae21
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 52 deletions.
Binary file modified data/sim_suites/Australia20/IGM_histories.npy
Binary file not shown.
Binary file modified data/sim_suites/post_768/IGM_histories.npy
Binary file not shown.
122 changes: 82 additions & 40 deletions scripts/save_mpg_IGM.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,90 @@ def main():

ind_axis = "average"
ind_phase = "average"
val_scaling = 1

list_snap = np.unique(cabayol23_archive.ind_snap)
nz = len(list_snap)
dict_index = {}

for sim_label in cabayol23_archive.list_sim_cube:
cosmo_params, linP_params = cabayol23_archive._get_emu_cosmo(sim_label)
dict_index[sim_label] = {}
dict_index[sim_label]["z"] = np.zeros(nz)
dict_index[sim_label]["tau_eff"] = np.zeros(nz)
dict_index[sim_label]["gamma"] = np.zeros(nz)
dict_index[sim_label]["sigT_kms"] = np.zeros(nz)
dict_index[sim_label]["kF_kms"] = np.zeros(nz)
for ind_snap in list_snap:
for ind_book in range(len(training)):
if (
(training[ind_book]["ind_snap"] == ind_snap)
& (training[ind_book]["ind_axis"] == ind_axis)
& (training[ind_book]["ind_phase"] == ind_phase)
& (training[ind_book]["sim_label"] == sim_label)
& (training[ind_book]["val_scaling"] == val_scaling)
):
dict_index[sim_label]["z"][ind_snap] = training[ind_book][
"z"
]
dict_index[sim_label]["tau_eff"][ind_snap] = -np.log(
training[ind_book]["mF"]
)
dict_index[sim_label]["gamma"][ind_snap] = training[
ind_book
]["gamma"]
_ = thermal_broadening_kms(training[ind_book]["T0"])
dict_index[sim_label]["sigT_kms"][ind_snap] = _
(
cosmo_params,
linP_params,
star_params,
) = cabayol23_archive._get_emu_cosmo(sim_label)
for ind_rescaling in range(5):
lab = sim_label + "_" + str(ind_rescaling)
dict_index[lab] = {}
dict_index[lab]["z"] = np.zeros(nz)
dict_index[lab]["tau_eff"] = np.zeros(nz)
dict_index[lab]["mF"] = np.zeros(nz)
dict_index[lab]["gamma"] = np.zeros(nz)
dict_index[lab]["sigT_kms"] = np.zeros(nz)
dict_index[lab]["sigT_Mpc"] = np.zeros(nz)
dict_index[lab]["kF_kms"] = np.zeros(nz)
dict_index[lab]["kF_Mpc"] = np.zeros(nz)
dict_index[lab]["val_scaling"] = np.zeros(nz)

ind_z = np.argwhere(
training[ind_book]["z"] == linP_params["z"]
)[0, 0]
_ = (
training[ind_book]["kF_Mpc"]
/ linP_params["dkms_dMpc"][ind_z]
)
dict_index[sim_label]["kF_kms"][ind_snap] = _
for ind_snap in list_snap:
for ind_book in range(len(training)):
if (
(training[ind_book]["ind_snap"] == ind_snap)
& (training[ind_book]["ind_axis"] == ind_axis)
& (training[ind_book]["ind_phase"] == ind_phase)
& (training[ind_book]["sim_label"] == sim_label)
& (training[ind_book]["ind_rescaling"] == ind_rescaling)
):
dict_index[lab]["z"][ind_snap] = training[ind_book]["z"]
dict_index[lab]["val_scaling"][ind_snap] = training[
ind_book
]["val_scaling"]
dict_index[lab]["mF"][ind_snap] = training[ind_book][
"mF"
]
dict_index[lab]["sigT_Mpc"][ind_snap] = training[
ind_book
]["sigT_Mpc"]
dict_index[lab]["kF_Mpc"][ind_snap] = training[
ind_book
]["kF_Mpc"]
dict_index[lab]["tau_eff"][ind_snap] = -np.log(
training[ind_book]["mF"]
)
dict_index[lab]["gamma"][ind_snap] = training[ind_book][
"gamma"
]
_ = thermal_broadening_kms(training[ind_book]["T0"])
dict_index[lab]["sigT_kms"][ind_snap] = _

# testing
ind_z = np.argwhere(
training[ind_book]["z"] == linP_params["z"]
)[0, 0]
_ = (
training[ind_book]["kF_Mpc"]
/ linP_params["dkms_dMpc"][ind_z]
)
dict_index[lab]["kF_kms"][ind_snap] = _

ind_axis = "average"
ind_phase = "average"
val_scaling = 1
# testing
for sim_label in cabayol23_archive.list_sim_test:
cosmo_params, linP_params = cabayol23_archive._get_emu_cosmo(sim_label)
(
cosmo_params,
linP_params,
star_params,
) = cabayol23_archive._get_emu_cosmo(sim_label)
dict_index[sim_label] = {}
dict_index[sim_label]["z"] = np.zeros(nz)
dict_index[sim_label]["val_scaling"] = np.zeros(nz)
dict_index[sim_label]["tau_eff"] = np.zeros(nz)
dict_index[sim_label]["mF"] = np.zeros(nz)
dict_index[sim_label]["gamma"] = np.zeros(nz)
dict_index[sim_label]["sigT_kms"] = np.zeros(nz)
dict_index[sim_label]["sigT_Mpc"] = np.zeros(nz)
dict_index[sim_label]["kF_kms"] = np.zeros(nz)
dict_index[sim_label]["kF_Mpc"] = np.zeros(nz)
testing = cabayol23_archive.get_testing_data(sim_label)
for ind_snap in list_snap:
for ind_book in range(len(testing)):
Expand All @@ -89,6 +119,18 @@ def main():
dict_index[sim_label]["z"][ind_snap] = testing[ind_book][
"z"
]
dict_index[sim_label]["val_scaling"][ind_snap] = testing[
ind_book
]["val_scaling"]
dict_index[sim_label]["mF"][ind_snap] = testing[ind_book][
"mF"
]
dict_index[sim_label]["sigT_Mpc"][ind_snap] = testing[
ind_book
]["sigT_Mpc"]
dict_index[sim_label]["kF_Mpc"][ind_snap] = testing[
ind_book
]["kF_Mpc"]
dict_index[sim_label]["tau_eff"][ind_snap] = -np.log(
testing[ind_book]["mF"]
)
Expand All @@ -107,9 +149,9 @@ def main():
)
dict_index[sim_label]["kF_kms"][ind_snap] = _

folder = os.environ["LACE_REPO"] + "/src/lace/data/sim_suites/Australia20/"
folder = os.environ["LACE_REPO"] + "/data/sim_suites/Australia20/"
np.save(folder + "IGM_histories.npy", dict_index)
folder = os.environ["LACE_REPO"] + "/src/lace/data/sim_suites/post_768/"
folder = os.environ["LACE_REPO"] + "/data/sim_suites/post_768/"
np.save(folder + "IGM_histories.npy", dict_index)


Expand Down
14 changes: 2 additions & 12 deletions scripts/save_nyx_IGM.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def main():
if sim_label == "nyx_14":
continue

cosmo_params, linP_params = nyx_archive._get_emu_cosmo(
cosmo_params, linP_params, star_params = nyx_archive._get_emu_cosmo(
None, rsim_conv[sim_label]
)

Expand Down Expand Up @@ -92,7 +92,7 @@ def main():
# testing

for sim_label in nyx_archive.list_sim_test:
cosmo_params, linP_params = nyx_archive._get_emu_cosmo(
cosmo_params, linP_params, star_params = nyx_archive._get_emu_cosmo(
None, rsim_conv[sim_label]
)
if sim_label == "nyx_central":
Expand Down Expand Up @@ -160,13 +160,3 @@ def main():

if __name__ == "__main__":
main()


def metric_par(p0, p1, max_dist):
dist = (
((p0["mF"] - p1["mF"]) / max_dist["mF"]) ** 2
+ ((p0["sigT_Mpc"] - p1["sigT_Mpc"]) / max_dist["sigT_Mpc"]) ** 2
+ ((p0["gamma"] - p1["gamma"]) / max_dist["gamma"]) ** 2
+ ((p0["kF_Mpc"] - p1["kF_Mpc"]) / max_dist["kF_Mpc"]) ** 2
)
return np.sqrt(dist)

0 comments on commit d9fae21

Please sign in to comment.