From 07fae5ab7d39af0452f49105e97e8bdd9f7ad474 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:24:35 +0100 Subject: [PATCH] change population of energy fields --- pynxtools/dataconverter/readers/xps/reader.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pynxtools/dataconverter/readers/xps/reader.py b/pynxtools/dataconverter/readers/xps/reader.py index 4fce8294b..3e60a28c4 100644 --- a/pynxtools/dataconverter/readers/xps/reader.py +++ b/pynxtools/dataconverter/readers/xps/reader.py @@ -144,7 +144,9 @@ def fill_data_group(key, key_part, entries_values, config_dict, template): data_group_key = data_field_key.rsplit("/data", 1)[0] if key_part == "energy": - energy_field_key = f"{data_group_key}/energy" + # Here, we need to take here if the data/entry is + # written directly in the future. + energy_field_key = data_group_key energy = np.array(xr_data.coords["energy"].values) template[energy_field_key] = energy @@ -253,8 +255,8 @@ def fill_template_with_value(key, value, template): value = value.isoformat() elif isinstance(value, dict) and LINK_TOKEN in value: - link_text = value[LINK_TOKEN] - link_text = link_text.replace("entry", f"{entry}") + initial_link_text = value[LINK_TOKEN] + link_text = initial_link_text.replace("entry", f"{entry}") value = {LINK_TOKEN: link_text} modified_key = key.replace("[entry]", f"[{entry}]") @@ -282,6 +284,14 @@ def fill_template_with_value(key, value, template): template[modified_key] = ", ".join(atom_types) +# ============================================================================= +# # Reset link to original +# if isinstance(value, dict) and LINK_TOKEN in value: +# print(value, template[modified_key]) +# value[LINK_TOKEN] = initial_link_text +# ============================================================================= + + def fill_template_with_xps_data(config_dict, xps_data_dict, template): """Collect the xps data from xps_data_dict and store them into template. We use searching_keys @@ -434,6 +444,10 @@ def read( if ("/ENTRY[entry]" not in key) and (val is not None): final_template[key] = val + for key, value in final_template.items(): + if isinstance(value, dict) and LINK_TOKEN in value: + print(value) + return final_template