Skip to content

Commit

Permalink
Made uncertainties.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ecole41 committed Dec 18, 2024
1 parent 5896b93 commit ced0c60
Show file tree
Hide file tree
Showing 4 changed files with 982 additions and 24 deletions.
66 changes: 65 additions & 1 deletion nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_7TEV_36PB/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import yaml
from filter_utils import get_data_values, get_kinematics
from filter_utils import get_data_values, get_kinematics, get_systematics

from nnpdf_data.filter_utils.utils import prettify_float

Expand Down Expand Up @@ -32,5 +32,69 @@ def filter_ATLAS_WPWM_7TEV_36FB_data_kinematic():
yaml.dump(kinematics_yaml, file, sort_keys=False)


def filter_ATLAS_WPWM_7TEV_36FB_systematics():
"""
This function writes the systematics to a yaml file.
"""

with open("metadata.yaml", "r") as file:
metadata = yaml.safe_load(file)

systematics = get_systematics()

# error definition
error_definitions = {}
errors = []
counter_1 = 1
counter_2 = 0
for sys in systematics:
if sys[0]['name'] == 'stat':
error_definitions[sys[0]['name']] = {
"description": "Uncorrelated statistical uncertainties",
"treatment": "ADD",
"type": "UNCORR",
}

elif sys[0]['name'] == 'uncor':
error_definitions[sys[0]['name']] = {
"description": f"Sys uncertainty idx: {counter_1}",
"treatment": "MULT",
"type": "UNCORR",
}
counter_1 += 1

elif sys[0]['name'] == 'atlaslumi10':
error_definitions[sys[0]['name']] = {
"description": f"Sys uncertainty idx: {counter_1}",
"treatment": "MULT",
"type": "ATLASLUMI10",
}
counter_1 += 1

else:
error_definitions[sys[0]['name']] = {
"description": f"Sys uncertainty idx: {counter_1}",
"treatment": "MULT",
"type": f"ATLASWZRAP36PB_{counter_2}",
}
counter_1 += 1
counter_2 += 1

for i in range(metadata['implemented_observables'][0]['ndata']):
error_value = {}

for sys in systematics:
error_value[sys[0]['name']] = float(sys[0]['values'][i])

errors.append(error_value)

uncertainties_yaml = {"definitions": error_definitions, "bins": errors}

# write uncertainties
with open(f"uncertainties.yaml", 'w') as file:
yaml.dump(uncertainties_yaml, file, sort_keys=False)


if __name__ == "__main__":
filter_ATLAS_WPWM_7TEV_36FB_data_kinematic()
filter_ATLAS_WPWM_7TEV_36FB_systematics()
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,40 @@ def get_kinematics():
return kin


def get_systematics_dataframe():
"""
returns the absolute systematic uncertainties in the form of a pandas dataframe.
"""
sys_rawdata_path = "rawdata/ATLAS-36PB_WPWM.csv"

abs_unc_df_arr = []

data_central = get_data_values()

df = pd.read_csv(sys_rawdata_path)

# convert (MULT) percentage unc to absolute unc
abs_unc_df = (df.T[2:] * data_central).T / 100
abs_unc_df_arr.append(abs_unc_df)

return abs_unc_df


def get_systematics():
""" """
abs_unc_df = get_systematics_dataframe()

uncertainties = []

for i, unc_dp in enumerate(abs_unc_df.values.T):
name = f"{abs_unc_df.columns[i]}"
values = [unc_dp[j] for j in range(len(unc_dp))]
uncertainties.append([{"name": name, "values": values}])

return uncertainties


if __name__ == "__main__":
get_data_values()
get_kinematics()
get_systematics()
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
y_min,y_max,stat,uncor,atlaslumi10,ATLASWZRAP36PB_0,ATLASWZRAP36PB_1,ATLASWZRAP36PB_2,ATLASWZRAP36PB_3,ATLASWZRAP36PB_4,ATLASWZRAP36PB_5,ATLASWZRAP36PB_6,ATLASWZRAP36PB_7,ATLASWZRAP36PB_8,ATLASWZRAP36PB_9,ATLASWZRAP36PB_10,ATLASWZRAP36PB_11,ATLASWZRAP36PB_12,ATLASWZRAP36PB_13,ATLASWZRAP36PB_14,ATLASWZRAP36PB_15,ATLASWZRAP36PB_16,ATLASWZRAP36PB_17,ATLASWZRAP36PB_18,ATLASWZRAP36PB_19,ATLASWZRAP36PB_20,ATLASWZRAP36PB_21,ATLASWZRAP36PB_22,ATLASWZRAP36PB_23,ATLASWZRAP36PB_24,ATLASWZRAP36PB_25,ATLASWZRAP36PB_26,ATLASWZRAP36PB_27,ATLASWZRAP36PB_28
0.0,0.21,1.0,1.16,1.33,0.23,-0.18,0.09,0.2,0.03,-0.01,0.03,0.03,0.08,0.1,0.13,0.08,-0.43,0.03,-0.17,-0.22,-0.59,0.37,0.21,0.3,-0.18,-0.05,0.09,-0.08,-0.24,0.74,0.09,0.12,0.07,-0.18
0.21,0.42,0.93,0.99,1.17,0.23,-0.18,0.09,0.2,0.03,-0.01,0.03,0.03,0.08,0.11,0.12,0.08,-0.39,0.01,-0.15,-0.19,-0.6,0.34,0.31,0.2,-0.19,-0.08,0.08,-0.14,-0.13,0.45,0.16,0.21,0.06,-0.1
0.42,0.63,0.89,0.97,1.17,0.23,-0.18,0.09,0.2,0.03,-0.01,0.02,0.04,0.06,0.14,0.13,0.07,-0.4,0.04,-0.16,-0.17,-0.55,0.47,0.44,0.17,-0.28,-0.12,0.06,-0.05,0.06,0.05,0.23,0.25,0.03,-0.07
0.63,0.84,0.95,1.12,1.2,0.23,-0.18,0.09,0.2,0.04,-0.01,0.04,0.02,0.09,0.12,0.12,0.07,-0.47,0.01,-0.16,-0.23,-0.63,0.47,0.35,0.23,-0.1,-0.01,0.05,-0.13,-0.09,0.18,0.14,0.26,0.03,-0.09
0.84,1.05,0.94,1.07,1.26,0.23,-0.18,0.09,0.2,0.04,0.0,0.04,0.04,0.07,0.11,0.19,0.1,-0.48,0.05,-0.22,-0.23,-0.46,0.64,0.28,0.28,-0.31,-0.08,0.01,0.26,-0.03,0.04,0.13,0.18,0.05,-0.19
1.05,1.37,0.72,0.83,1.19,0.23,-0.18,0.09,0.2,0.04,-0.01,0.02,0.0,0.11,0.15,0.11,0.1,-0.46,0.08,-0.23,-0.22,-0.66,0.36,0.29,0.29,-0.17,0.0,-0.05,-0.04,0.02,0.22,0.18,0.21,0.05,-0.09
1.37,1.52,1.37,1.3,1.73,0.23,-0.18,0.09,0.2,0.06,-0.02,0.02,-0.03,0.17,0.18,0.12,0.07,-0.61,0.08,-0.18,-0.26,-1.0,0.4,0.1,0.48,-0.3,0.03,-0.19,-0.07,0.02,0.49,0.41,0.46,0.15,0.36
1.52,1.74,0.84,0.78,1.15,0.23,-0.18,0.09,0.2,0.04,-0.01,0.02,0.0,0.11,0.11,0.12,0.11,-0.49,0.06,-0.26,-0.21,-0.64,0.37,0.17,0.27,-0.11,0.01,-0.11,0.14,0.03,0.13,0.18,0.18,0.05,-0.03
1.74,1.95,0.88,0.88,1.29,0.23,-0.18,0.09,0.2,0.05,-0.01,0.02,0.0,0.12,0.12,0.13,0.11,-0.51,0.09,-0.26,-0.24,-0.62,0.46,0.28,0.37,-0.16,0.11,-0.1,-0.12,-0.02,0.27,0.22,0.29,0.08,-0.02
1.95,2.18,0.85,0.87,1.21,0.23,-0.18,0.09,0.2,0.03,0.0,0.03,0.03,0.11,0.12,0.13,0.11,-0.44,0.07,-0.26,-0.17,-0.6,0.36,0.21,0.25,-0.25,-0.01,-0.1,-0.03,-0.07,0.44,0.18,0.24,0.09,-0.06
2.18,2.5,0.89,0.98,1.39,0.23,-0.18,0.09,0.2,0.02,-0.01,0.08,-0.03,0.05,0.11,0.24,0.01,-0.48,0.05,-0.29,-0.24,-0.82,0.46,0.23,0.19,-0.33,0.08,-0.19,-0.04,-0.01,0.27,0.19,0.31,0.06,-0.02
0.0,0.21,1.16,1.29,1.3,0.1,0.18,0.23,0.19,0.03,-0.01,0.04,0.05,0.07,0.11,0.17,0.06,-0.42,0.08,-0.18,-0.29,-0.57,0.39,0.3,0.34,-0.41,-0.11,0.12,-0.11,-0.02,0.51,-0.08,0.11,0.07,-0.16
0.21,0.42,1.08,1.13,1.29,0.1,0.18,0.23,0.19,0.03,0.0,0.05,0.06,0.07,0.11,0.18,0.09,-0.42,0.05,-0.2,-0.29,-0.48,0.44,0.37,0.34,-0.38,-0.08,0.17,-0.18,-0.16,0.41,-0.15,0.21,0.07,-0.1
0.42,0.63,1.04,1.1,1.31,0.1,0.18,0.23,0.19,0.04,-0.01,0.06,0.03,0.07,0.09,0.16,0.06,-0.45,0.05,-0.2,-0.31,-0.52,0.5,0.32,0.32,-0.28,-0.08,0.19,-0.14,-0.14,0.5,-0.18,0.12,0.05,-0.1
0.63,0.84,1.12,1.3,1.35,0.1,0.18,0.23,0.19,0.04,-0.01,0.05,0.06,0.08,0.1,0.18,0.09,-0.49,0.08,-0.22,-0.31,-0.49,0.56,0.38,0.44,-0.36,-0.03,0.14,-0.09,-0.07,0.32,-0.08,0.21,0.07,-0.13
0.84,1.05,1.12,1.3,1.36,0.1,0.18,0.23,0.19,0.03,-0.01,0.04,0.06,0.05,0.11,0.21,0.07,-0.46,0.09,-0.23,-0.27,-0.61,0.53,0.26,0.29,-0.47,-0.09,0.07,-0.22,-0.12,0.36,-0.07,0.21,0.06,-0.14
1.05,1.37,0.9,0.95,1.37,0.1,0.18,0.23,0.19,0.04,0.0,0.05,0.03,0.11,0.13,0.18,0.13,-0.49,0.11,-0.32,-0.34,-0.6,0.37,0.33,0.45,-0.47,-0.02,0.03,-0.15,-0.11,0.25,-0.02,0.27,0.09,-0.1
1.37,1.52,1.79,1.35,1.67,0.1,0.18,0.23,0.19,0.05,-0.02,0.04,0.06,0.12,0.19,0.2,0.09,-0.62,0.14,-0.25,-0.38,-0.81,0.52,0.25,0.58,-0.53,-0.05,0.01,0.0,0.13,0.19,-0.25,0.34,0.12,0.31
1.52,1.74,1.11,0.93,1.47,0.1,0.18,0.23,0.19,0.04,0.0,0.06,0.04,0.11,0.15,0.2,0.13,-0.53,0.11,-0.36,-0.36,-0.74,0.35,0.23,0.4,-0.43,-0.01,0.01,-0.29,-0.22,0.26,-0.09,0.32,0.08,0.03
1.74,1.95,1.17,1.03,1.48,0.1,0.18,0.23,0.19,0.05,0.0,0.04,0.03,0.1,0.11,0.19,0.13,-0.54,0.13,-0.35,-0.37,-0.61,0.47,0.33,0.48,-0.44,-0.01,0.11,-0.23,-0.1,0.36,-0.08,0.25,0.08,-0.01
1.95,2.18,1.13,0.98,1.5,0.1,0.18,0.23,0.19,0.04,-0.01,0.04,0.05,0.1,0.1,0.2,0.14,-0.52,0.15,-0.36,-0.32,-0.64,0.36,0.15,0.53,-0.56,-0.02,0.06,-0.32,-0.04,0.42,0.0,0.25,0.09,-0.04
2.18,2.5,1.18,1.1,1.64,0.1,0.18,0.23,0.19,0.06,0.0,0.14,0.01,0.02,0.14,0.35,0.12,-0.49,0.16,-0.36,-0.31,-0.84,0.4,0.08,0.58,-0.55,-0.1,-0.01,-0.45,-0.04,0.24,0.09,0.29,0.09,0.0
y_min,y_max,stat,uncor,atlaslumi10,ATLASWZRAP36PB_0,ATLASWZRAP36PB_1,ATLASWZRAP36PB_2,ATLASWZRAP36PB_3,ATLASWZRAP36PB_4,ATLASWZRAP36PB_5,ATLASWZRAP36PB_6,ATLASWZRAP36PB_7,ATLASWZRAP36PB_8,ATLASWZRAP36PB_9,ATLASWZRAP36PB_10,ATLASWZRAP36PB_11,ATLASWZRAP36PB_12,ATLASWZRAP36PB_13,ATLASWZRAP36PB_14,ATLASWZRAP36PB_15,ATLASWZRAP36PB_16,ATLASWZRAP36PB_17,ATLASWZRAP36PB_18,ATLASWZRAP36PB_19,ATLASWZRAP36PB_20,ATLASWZRAP36PB_21,ATLASWZRAP36PB_22,ATLASWZRAP36PB_23,ATLASWZRAP36PB_24,ATLASWZRAP36PB_25,ATLASWZRAP36PB_26,ATLASWZRAP36PB_27,ATLASWZRAP36PB_28,ATLASWZRAP36PB_29
0.0,0.21,1.0,1.16,0.35,0.23,-0.18,0.09,0.2,0.03,-0.01,0.03,0.03,0.08,0.1,0.13,0.08,-0.43,0.03,-0.17,-0.22,-0.59,0.37,0.21,0.3,-0.18,-0.05,0.09,-0.08,-0.24,0.74,0.09,0.12,0.07,-0.18
0.21,0.42,0.93,0.99,0.35,0.23,-0.18,0.09,0.2,0.03,-0.01,0.03,0.03,0.08,0.11,0.12,0.08,-0.39,0.01,-0.15,-0.19,-0.6,0.34,0.31,0.2,-0.19,-0.08,0.08,-0.14,-0.13,0.45,0.16,0.21,0.06,-0.1
0.42,0.63,0.89,0.97,0.35,0.23,-0.18,0.09,0.2,0.03,-0.01,0.02,0.04,0.06,0.14,0.13,0.07,-0.4,0.04,-0.16,-0.17,-0.55,0.47,0.44,0.17,-0.28,-0.12,0.06,-0.05,0.06,0.05,0.23,0.25,0.03,-0.07
0.63,0.84,0.95,1.12,0.35,0.23,-0.18,0.09,0.2,0.04,-0.01,0.04,0.02,0.09,0.12,0.12,0.07,-0.47,0.01,-0.16,-0.23,-0.63,0.47,0.35,0.23,-0.1,-0.01,0.05,-0.13,-0.09,0.18,0.14,0.26,0.03,-0.09
0.84,1.05,0.94,1.07,0.35,0.23,-0.18,0.09,0.2,0.04,0.0,0.04,0.04,0.07,0.11,0.19,0.1,-0.48,0.05,-0.22,-0.23,-0.46,0.64,0.28,0.28,-0.31,-0.08,0.01,0.26,-0.03,0.04,0.13,0.18,0.05,-0.19
1.05,1.37,0.72,0.83,0.35,0.23,-0.18,0.09,0.2,0.04,-0.01,0.02,0.0,0.11,0.15,0.11,0.1,-0.46,0.08,-0.23,-0.22,-0.66,0.36,0.29,0.29,-0.17,0.0,-0.05,-0.04,0.02,0.22,0.18,0.21,0.05,-0.09
1.37,1.52,1.37,1.3,0.35,0.23,-0.18,0.09,0.2,0.06,-0.02,0.02,-0.03,0.17,0.18,0.12,0.07,-0.61,0.08,-0.18,-0.26,-1.0,0.4,0.1,0.48,-0.3,0.03,-0.19,-0.07,0.02,0.49,0.41,0.46,0.15,0.36
1.52,1.74,0.84,0.78,0.35,0.23,-0.18,0.09,0.2,0.04,-0.01,0.02,0.0,0.11,0.11,0.12,0.11,-0.49,0.06,-0.26,-0.21,-0.64,0.37,0.17,0.27,-0.11,0.01,-0.11,0.14,0.03,0.13,0.18,0.18,0.05,-0.03
1.74,1.95,0.88,0.88,0.35,0.23,-0.18,0.09,0.2,0.05,-0.01,0.02,0.0,0.12,0.12,0.13,0.11,-0.51,0.09,-0.26,-0.24,-0.62,0.46,0.28,0.37,-0.16,0.11,-0.1,-0.12,-0.02,0.27,0.22,0.29,0.08,-0.02
1.95,2.18,0.85,0.87,0.35,0.23,-0.18,0.09,0.2,0.03,0.0,0.03,0.03,0.11,0.12,0.13,0.11,-0.44,0.07,-0.26,-0.17,-0.6,0.36,0.21,0.25,-0.25,-0.01,-0.1,-0.03,-0.07,0.44,0.18,0.24,0.09,-0.06
2.18,2.5,0.89,0.98,0.35,0.23,-0.18,0.09,0.2,0.02,-0.01,0.08,-0.03,0.05,0.11,0.24,0.01,-0.48,0.05,-0.29,-0.24,-0.82,0.46,0.23,0.19,-0.33,0.08,-0.19,-0.04,-0.01,0.27,0.19,0.31,0.06,-0.02
0.0,0.21,1.16,1.29,0.35,0.1,0.18,0.23,0.19,0.03,-0.01,0.04,0.05,0.07,0.11,0.17,0.06,-0.42,0.08,-0.18,-0.29,-0.57,0.39,0.3,0.34,-0.41,-0.11,0.12,-0.11,-0.02,0.51,-0.08,0.11,0.07,-0.16
0.21,0.42,1.08,1.13,0.35,0.1,0.18,0.23,0.19,0.03,0.0,0.05,0.06,0.07,0.11,0.18,0.09,-0.42,0.05,-0.2,-0.29,-0.48,0.44,0.37,0.34,-0.38,-0.08,0.17,-0.18,-0.16,0.41,-0.15,0.21,0.07,-0.1
0.42,0.63,1.04,1.1,0.35,0.1,0.18,0.23,0.19,0.04,-0.01,0.06,0.03,0.07,0.09,0.16,0.06,-0.45,0.05,-0.2,-0.31,-0.52,0.5,0.32,0.32,-0.28,-0.08,0.19,-0.14,-0.14,0.5,-0.18,0.12,0.05,-0.1
0.63,0.84,1.12,1.3,0.35,0.1,0.18,0.23,0.19,0.04,-0.01,0.05,0.06,0.08,0.1,0.18,0.09,-0.49,0.08,-0.22,-0.31,-0.49,0.56,0.38,0.44,-0.36,-0.03,0.14,-0.09,-0.07,0.32,-0.08,0.21,0.07,-0.13
0.84,1.05,1.12,1.3,0.35,0.1,0.18,0.23,0.19,0.03,-0.01,0.04,0.06,0.05,0.11,0.21,0.07,-0.46,0.09,-0.23,-0.27,-0.61,0.53,0.26,0.29,-0.47,-0.09,0.07,-0.22,-0.12,0.36,-0.07,0.21,0.06,-0.14
1.05,1.37,0.9,0.95,0.35,0.1,0.18,0.23,0.19,0.04,0.0,0.05,0.03,0.11,0.13,0.18,0.13,-0.49,0.11,-0.32,-0.34,-0.6,0.37,0.33,0.45,-0.47,-0.02,0.03,-0.15,-0.11,0.25,-0.02,0.27,0.09,-0.1
1.37,1.52,1.79,1.35,0.35,0.1,0.18,0.23,0.19,0.05,-0.02,0.04,0.06,0.12,0.19,0.2,0.09,-0.62,0.14,-0.25,-0.38,-0.81,0.52,0.25,0.58,-0.53,-0.05,0.01,0.0,0.13,0.19,-0.25,0.34,0.12,0.31
1.52,1.74,1.11,0.93,0.35,0.1,0.18,0.23,0.19,0.04,0.0,0.06,0.04,0.11,0.15,0.2,0.13,-0.53,0.11,-0.36,-0.36,-0.74,0.35,0.23,0.4,-0.43,-0.01,0.01,-0.29,-0.22,0.26,-0.09,0.32,0.08,0.03
1.74,1.95,1.17,1.03,0.35,0.1,0.18,0.23,0.19,0.05,0.0,0.04,0.03,0.1,0.11,0.19,0.13,-0.54,0.13,-0.35,-0.37,-0.61,0.47,0.33,0.48,-0.44,-0.01,0.11,-0.23,-0.1,0.36,-0.08,0.25,0.08,-0.01
1.95,2.18,1.13,0.98,0.35,0.1,0.18,0.23,0.19,0.04,-0.01,0.04,0.05,0.1,0.1,0.2,0.14,-0.52,0.15,-0.36,-0.32,-0.64,0.36,0.15,0.53,-0.56,-0.02,0.06,-0.32,-0.04,0.42,0.0,0.25,0.09,-0.04
2.18,2.5,1.18,1.1,0.35,0.1,0.18,0.23,0.19,0.06,0.0,0.14,0.01,0.02,0.14,0.35,0.12,-0.49,0.16,-0.36,-0.31,-0.84,0.4,0.08,0.58,-0.55,-0.1,-0.01,-0.45,-0.04,0.24,0.09,0.29,0.09,0.0
Loading

0 comments on commit ced0c60

Please sign in to comment.