Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat yadism matching data as level-2 closure test data #56

Merged
merged 6 commits into from
Oct 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/nnusf/data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,16 @@ def n_data(self):
@property
def central_values(self) -> np.ndarray:
"""Return the dataset central values."""
return self.table["data"].values
if self.name.endswith("_MATCHING"):
cholesky = np.linalg.cholesky(self.covariance_matrix)
np_rng_state = np.random.get_state()
np.random.seed(pow(self.table.shape[0], 3))
RoyStegeman marked this conversation as resolved.
Show resolved Hide resolved
random_samples = np.random.randn(self.table.shape[0])
np.random.set_state(np_rng_state)
shift_data = cholesky @ random_samples
return self.table["data"].values + shift_data
else:
return self.table["data"].values

@property
def covmat(self) -> np.ndarray:
Expand Down Expand Up @@ -246,19 +255,21 @@ def build_covariance_matrix(
"""
if "_MATCHING" in dataset_name:
sv_variations = []
for variation in pathlib.Path(f"{commondata_path}/matching/").iterdir():
for variation in pathlib.Path(
f"{commondata_path}/matching/"
).iterdir():
if dataset_name in variation.stem:
# central scale
# central scale
if "xif1_xir1" in variation.stem:
nrep_predictions = np.load(variation)
else:
sv_variations.append(np.load(variation))
# build th shift
th_shift = (sv_variations - nrep_predictions[:,0]).T
th_shift = (sv_variations - nrep_predictions[:, 0]).T
# build covaraince
pdf_covmat = np.cov(nrep_predictions[mask_predictions])
th_covamt = np.cov(th_shift[mask_predictions])
covmat = np.sqrt(th_covamt ** 2 + pdf_covmat ** 2)
covmat = np.sqrt(th_covamt**2 + pdf_covmat**2)
return clip_covmat(covmat, dataset_name)
else:
diagonal = np.power(unc_df["stat"], 2)
Expand Down