Skip to content

Commit

Permalink
Correct nan value for mc uncertainties
Browse files Browse the repository at this point in the history
  • Loading branch information
achiefa committed Nov 10, 2024
1 parent 3c0f9fb commit 597a023
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 165 deletions.
16 changes: 12 additions & 4 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0J_8TEV/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
CHECK = True


def check_unc_with_legacy(observable, rtol=1e-3):
def check_unc_with_legacy(observable, variant=None, rtol=1e-3):
"""
Utility function that compare the yaml file for the legacy uncertainties
with the yaml file for the new implementation of the uncertainties. If an
Expand All @@ -18,11 +18,17 @@ def check_unc_with_legacy(observable, rtol=1e-3):
logging.info(
f"Comparing the new uncertainty implementation with the legacy version for {observable} using rtol = {rtol}."
)

with open('./uncertainties_' + observable + '.yaml', 'r') as file:
if variant == 'sys_10':
file_name = './uncertainties_sys_10_'
legacy_file_name = './uncertainties_legacy_sys_10_'
else:
file_name = './uncertainties_'
legacy_file_name = './uncertainties_legacy_'

with open(file_name + observable + '.yaml', 'r') as file:
new_uncs = yaml.safe_load(file)

with open('./uncertainties_legacy_' + observable + '.yaml', 'r') as file:
with open(legacy_file_name + observable + '.yaml', 'r') as file:
legacy_uncs = yaml.safe_load(file)

for i, (new_unc, legacy_unc) in enumerate(zip(new_uncs['bins'], legacy_uncs['bins'])):
Expand Down Expand Up @@ -73,5 +79,7 @@ def check_dat_with_legacy(observable, rtol=1e-03):
if CHECK:
check_dat_with_legacy('PT-Y')
check_unc_with_legacy('PT-Y')
check_unc_with_legacy('PT-Y', variant='sys_10')
check_dat_with_legacy('PT-M')
check_unc_with_legacy('PT-M')
check_unc_with_legacy('PT-M', variant='sys_10')
13 changes: 8 additions & 5 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0J_8TEV/filter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,17 @@ def generate_uncertainties(self, resource_folder, mc_uncertainity=False):
]
)
if mc_uncertainity:
combined_lines = np.append(
combined_lines,
[[MCUNCERTAINTY] for _ in range(combined_lines.shape[0])],
axis=1,
)
columns = np.append(columns, "sys_mc_uncorr")
dirty_flag = True

# Add MC uncertainty
if mc_uncertainity:
combined_lines = np.append(
combined_lines,
[[MCUNCERTAINTY] for _ in range(combined_lines.shape[0])],
axis=1,
)

dfs.append(pd.DataFrame(combined_lines[:, 1:]))
MultiIndex.append([(np.mean(kin_range), pt) for pt in combined_lines[:, 0]])

Expand Down
Loading

0 comments on commit 597a023

Please sign in to comment.