-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from igmhub/update_forecast
Update mock_data and sampler book-keeping
- Loading branch information
Showing
16 changed files
with
1,939 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore | ||
!README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Some scripts will point to this folder to store emcee chains | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,48 @@ | ||
from lace.emulator import gp_emulator | ||
from cup1d.data import base_p1d_data | ||
from cup1d.data import data_Chabanier2019 | ||
from cup1d.data import data_Karacayli2022 | ||
from cup1d.data import data_QMLE_Ohio | ||
from cup1d.likelihood import lya_theory | ||
|
||
|
||
class Mock_P1D(base_p1d_data.BaseDataP1D): | ||
""" Class to generate a mock P1D from another P1D object and a theory""" | ||
|
||
def __init__(self,data,theory): | ||
def __init__(self,emulator=None,data_label="Chabanier2019", | ||
zmin=2.0,zmax=4.5): | ||
""" Copy data and replace P1D signal using theory""" | ||
|
||
# keep theory in case you need it later | ||
self.theory=theory | ||
# load original data | ||
self.data_label=data_label | ||
if data_label=="Chabanier2019": | ||
data=data_Chabanier2019.P1D_Chabanier2019(zmin=zmin,zmax=zmax) | ||
elif data_label=="QMLE_Ohio": | ||
data=data_QMLE_Ohio.P1D_QMLE_Ohio(zmin=zmin,zmax=zmax) | ||
elif data_label=="Karacayli2022": | ||
data=data_Karacayli2022.P1D_Karacayli2022(zmin=zmin,zmax=zmax) | ||
else: | ||
raise ValueError("Unknown data_label",data_label) | ||
|
||
# check if emulator was provided | ||
if emulator is None: | ||
emulator=gp_emulator.GPEmulator() | ||
|
||
# evaluate theory at k_kms, for all redshifts | ||
emu_p1d_kms=theory.get_p1d_kms(data.k_kms) | ||
# setup and store theory (we will need it later) | ||
self.theory=lya_theory.Theory(zs=data.z,emulator=emulator) | ||
|
||
# at each z, update value of p1d | ||
# at each z will update value of p1d | ||
Pk_kms=data.Pk_kms.copy() | ||
for iz,z in enumerate(data.z): | ||
Pk_kms[iz]=emu_p1d_kms[iz] | ||
|
||
# copy data | ||
# if emulator is not trained, skip mock making | ||
if emulator.trained: | ||
# evaluate theory at k_kms, for all redshifts | ||
emu_p1d_kms=self.theory.get_p1d_kms(data.k_kms) | ||
for iz,z in enumerate(data.z): | ||
Pk_kms[iz]=emu_p1d_kms[iz] | ||
else: | ||
print('emulator not trained, will not make mock') | ||
|
||
base_p1d_data.BaseDataP1D.__init__(self,z=data.z,k_kms=data.k_kms, | ||
Pk_kms=Pk_kms,cov_Pk_kms=data.cov_Pk_kms) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.