-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
7,433 additions
and
55 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
23 changes: 23 additions & 0 deletions
23
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_7TEV_36PB/data.yaml
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,23 @@ | ||
data_central: | ||
- 6.13257400e+05 | ||
- 6.13939929e+05 | ||
- 6.31746805e+05 | ||
- 6.26184703e+05 | ||
- 6.52630155e+05 | ||
- 6.59312827e+05 | ||
- 6.42534838e+05 | ||
- 6.40935479e+05 | ||
- 6.60983495e+05 | ||
- 6.39876031e+05 | ||
- 5.89205893e+05 | ||
- 4.54666184e+05 | ||
- 4.48492862e+05 | ||
- 4.63569622e+05 | ||
- 4.48034447e+05 | ||
- 4.36074909e+05 | ||
- 4.26723243e+05 | ||
- 3.94511949e+05 | ||
- 3.91211361e+05 | ||
- 3.82307923e+05 | ||
- 3.64073193e+05 | ||
- 3.37179513e+05 |
100 changes: 100 additions & 0 deletions
100
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_7TEV_36PB/filter.py
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,100 @@ | ||
""" | ||
When running `python filter.py` the relevant data yaml | ||
file will be created in the `nnpdf_data/commondata/ATLAS_WPWM_7TEV_46FB` directory. | ||
""" | ||
|
||
import yaml | ||
from filter_utils import get_data_values, get_kinematics, get_systematics | ||
|
||
from nnpdf_data.filter_utils.utils import prettify_float | ||
|
||
yaml.add_representer(float, prettify_float) | ||
|
||
|
||
def filter_ATLAS_WPWM_7TEV_36FB_data_kinematic(): | ||
""" | ||
This function writes the systematics to yaml files. | ||
""" | ||
|
||
central_values = get_data_values() | ||
|
||
kin = get_kinematics() | ||
|
||
data_central_yaml = {"data_central": central_values} | ||
|
||
kinematics_yaml = {"bins": kin} | ||
|
||
# write central values and kinematics to yaml file | ||
with open("data.yaml", "w") as file: | ||
yaml.dump(data_central_yaml, file, sort_keys=False) | ||
|
||
with open("kinematics.yaml", "w") as file: | ||
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() |
96 changes: 96 additions & 0 deletions
96
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_7TEV_36PB/filter_utils.py
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,96 @@ | ||
""" | ||
This module contains helper functions that are used to extract the data values | ||
from the rawdata files. | ||
""" | ||
|
||
import yaml | ||
import pandas as pd | ||
import numpy as np | ||
|
||
|
||
def get_data_values(): | ||
""" | ||
returns the central data values in the form of a list. | ||
""" | ||
|
||
data_central = [] | ||
|
||
tables = [5, 3] | ||
|
||
for table in tables: | ||
hepdata_table = f"rawdata/HEPData-ins928289-v1-Table_{table}.yaml" | ||
|
||
with open(hepdata_table, 'r') as file: | ||
input = yaml.safe_load(file) | ||
|
||
values = input['dependent_variables'][0]['values'] | ||
|
||
for value in values: | ||
# store data central and convert the units and apply the correction factor | ||
data_central.append(value['value'] * 1000 * 1.0187) | ||
|
||
return data_central | ||
|
||
|
||
def get_kinematics(): | ||
""" | ||
returns the kinematics in the form of a list of dictionaries. | ||
""" | ||
kin = [] | ||
|
||
tables = [5, 3] | ||
|
||
for table in tables: | ||
hepdata_table = f"rawdata/HEPData-ins928289-v1-Table_{table}.yaml" | ||
|
||
with open(hepdata_table, 'r') as file: | ||
input = yaml.safe_load(file) | ||
|
||
for i, M in enumerate(input["independent_variables"][0]['values']): | ||
kin_value = { | ||
'abs_eta': {'min': None, 'mid': (0.5 * (M['low'] + M['high'])), 'max': None}, | ||
'm_W2': {'min': None, 'mid': 6463.838404, 'max': None}, | ||
'sqrts': {'min': None, 'mid': 7000.0, 'max': None}, | ||
} | ||
kin.append(kin_value) | ||
|
||
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() |
Oops, something went wrong.