From 64212f4cba95bc9ce20ab07799f3bc21b41791d0 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:57:08 +0100 Subject: [PATCH] update XPS xml reader and tests file --- .../readers/xps/config/config_xml_specs.json | 27 +-- .../readers/xps/xml/xml_specs.py | 47 +++-- .../dataconverter/readers/xps/eln_data.yaml | 193 +++++++++++++----- 3 files changed, 174 insertions(+), 93 deletions(-) diff --git a/pynxtools/dataconverter/readers/xps/config/config_xml_specs.json b/pynxtools/dataconverter/readers/xps/config/config_xml_specs.json index fe9a55def..1bc5df069 100644 --- a/pynxtools/dataconverter/readers/xps/config/config_xml_specs.json +++ b/pynxtools/dataconverter/readers/xps/config/config_xml_specs.json @@ -11,8 +11,6 @@ "experiment_facility":"@eln", "experiment_laboratory":"@eln", "entry_identifier":"@eln", - "duration":"@eln", - "duration/@units":"@eln", "method":"@xps_token:region/analysis_method", "program_name":"@eln" }, @@ -77,14 +75,7 @@ "resolution":"@xps_token:region/scan_delta", "resolution/@units":"eV" }, - "transmission_function":{ - "@default":"relative_intensity", - "@signal":"relative_intensity", - "@axes":["kinetic_energy"], - "kinetic_energy":"@xps_token:transmission_function/kinetic_energy", - "kinetic_energy/@units":"@xps_token:transmission_function/kinetic_energy/@units", - "relative_intensity":"@xps_token:collectioncolumn/transmission_function/relative_intensity" - }, + "transmission_function":"None", "COLLECTIONCOLUMN[collectioncolumn]":{ "scheme":"@eln", "lens_mode":"@xps_token:collectioncolumn/lens_mode", @@ -93,10 +84,6 @@ "spatial_acceptance":"None", "field_aperture":"None", "contrast_aperture":"None", - "iris":{ - "size":"@xps_token:collectioncolumn/iris_diameter", - "size/@units":"@xps_token:collectioncolumn/iris_diameter/@units" - }, "device_information":{ "vendor":"@eln", "model":"@eln", @@ -131,7 +118,7 @@ "@signal":"raw", "@default":"raw", "raw":"@detector_data:cycles/Cycle_", - "raw/@units":"@xps_token:detector/raw_data/raw/@units" + "raw/@units":"counts" } } }, @@ -226,12 +213,6 @@ "end_time":"@eln", "description":"@eln", "method":"@eln" - }, - "PHYSICAL_PROCESS[sample_loading]":{ - "start_time":"@eln", - "end_time":"@eln", - "description":"@eln", - "method":"@eln" } }, "temperature":{ @@ -260,8 +241,8 @@ "data":"@data:cycle", "data/@units":"counts", "energy":"@link:/entry/process/energy_calibration/calibrated_axis", - "energy/@type":"@xps_token:data/energy/@type", - "energy/@units":"@xps_token:data/energy/@units", + "energy/@type":"kinetic", + "energy/@units":"eV", "@energy_indices":"None", "@energy_depends":"None" } diff --git a/pynxtools/dataconverter/readers/xps/xml/xml_specs.py b/pynxtools/dataconverter/readers/xps/xml/xml_specs.py index 7e9d07ed7..f519bcadb 100644 --- a/pynxtools/dataconverter/readers/xps/xml/xml_specs.py +++ b/pynxtools/dataconverter/readers/xps/xml/xml_specs.py @@ -31,23 +31,6 @@ ) -def _construct_entry_name_xml(key): - """Construction entry name.""" - key_parts = key.split("/") - try: - # entry example : vendor__sample__name_of_scan_region - entry_name = ( - f"{key_parts[2]}" - f"__" - f'{key_parts[3].split("_", 1)[1]}' - f"__" - f'{key_parts[5].split("_", 1)[1]}' - ) - except IndexError: - entry_name = "" - return entry_name - - class XmlMapperSpecs(XPSMapper): """ Class for restructuring xml data file from @@ -180,13 +163,14 @@ def construct_data(self): f"{scan_nm}_chan_{row}" ] = xr.DataArray( data=channel_counts[row + 1, :], - coords={"BE": binding_energy}, + coords={"energy": binding_energy}, ) # Storing callibrated and after accumulated each scan counts if row == mcd_num - 1: self._xps_dict["data"][entry][scan_nm] = xr.DataArray( - data=channel_counts[0, :], coords={"BE": binding_energy} + data=channel_counts[0, :], + coords={"energy": binding_energy}, ) else: for row in np.arange(mcd_num): @@ -203,13 +187,14 @@ def construct_data(self): f"{scan_nm}_chan{row}" ] = xr.DataArray( data=channel_counts[row + 1, :], - coords={"BE": binding_energy}, + coords={"energy": binding_energy}, ) # Storing callibrated and after accumulated each scan counts if row == mcd_num - 1: self._xps_dict["data"][entry][scan_nm] = xr.DataArray( - data=channel_counts[0, :], coords={"BE": binding_energy} + data=channel_counts[0, :], + coords={"energy": binding_energy}, ) @@ -699,6 +684,7 @@ def collect_raw_data_to_construct_data(self): self.entry_to_data[entry]["raw_data"]["excitation_energy"] = val elif "region/scan_mode/name" in key: + val = self._convert_energy_scan_mode(val) self.entry_to_data[entry]["raw_data"]["scan_mode"] = val elif "region/kinetic_energy" in key: @@ -748,3 +734,22 @@ def collect_raw_data_to_construct_data(self): scan_name = f"cycle{cycle_num}_scan{scan_num}" self.entry_to_data[entry]["raw_data"]["scans"][scan_name] = val + + def _convert_energy_scan_mode(self, energy_scan_mode): + """ + Convert the native names for the energy scan modes to the ones + used in NXmpes. + + """ + energy_scan_mode_map = { + "FixedAnalyzerTransmission": "fixed_analyser_transmission", + "FixedRetardationRatio": "fixed_retardation_ratio", + "FixedEnergies": "fixed_energy", + "Snapshot": "snapshot", + } + + try: + energy_scan_mode = energy_scan_mode_map[energy_scan_mode] + except KeyError: + pass + return energy_scan_mode diff --git a/tests/data/dataconverter/readers/xps/eln_data.yaml b/tests/data/dataconverter/readers/xps/eln_data.yaml index 58e81f99e..5abaeca11 100644 --- a/tests/data/dataconverter/readers/xps/eln_data.yaml +++ b/tests/data/dataconverter/readers/xps/eln_data.yaml @@ -1,51 +1,146 @@ -Instrument: - Analyser: - Collectioncolumn: - scheme: "Angular dispersive" - mode: "Unknown" - description: "hemispherical" - name: null - Energydispersion: - entrance_slit: "Unknown" - scheme: "hemispherical" - energy_scan_mode: "fixed" - pass_energy: - unit: null - Detector: - amplifier_type: "channeltron" - detector_type: "Multi-anode" - Beam: +definition: + value: NXmpes + version: 1.0 +title: XPS Experiment +start_time: 2022-04-08T11:47:02.0200Z +end_time: 2022-04-08T12:32:06.0200Z +experiment_institution: BESSY II +program_name: SpecsLab 2 +user: + name: Lukas Pielsticker + email: lukas.pielsticker@cec.mpg.de +instrument: + device_information: + vendor: SPECS GmbH + model: XPS setup + identifier: null + energy_resolution: + type: calibrated + resolution: + value: 0.2 + unit: eV + source_probe: + type: Synchrotron X-ray Source + probe: x-ray + device_information: + vendor: null + model: null + identifier: null + beam_probe: distance: - unit: "mm" value: 0.0 - energy_resolution: - unit: null - value: null - Source: - type: "Synchrotron X-ray Source" - probe: "x-ray" -Sample: - name: "PBTTT" - chemical_formula: "(C42H62S4)n" - preparation_description: "From third party" - temperature: - unit: "K" - value: 298.0 - situation: "vacuum" - gas_pressure: - unit: "Pa" - value: 101325.0 - density: null - description: "A polymer material called PBTTT with chemical name poly[2,5-bis(3-dodecylthiophen-2-yl)thieno[3,2-b]thiophene]." -title: "XPS Experiment" -start_time: "2022-04-08T11:47:02.0200Z" -definition: - value: "NXmpes" - version: "1.0" -User: - name: "Ahmed Mansour" - email: "amansour@physik.hu-berlin.de" -Data: - BE: - unit: null - + unit: mm + analyser: + description: hemispherical + name: PHOIBOS 150 + device_information: + vendor: SPECS GmbH + model: PHOIBOS 150 + identifier: null + collectioncolumn: + scheme: angular dispersive + device_information: + vendor: null + model: null + identifier: null + energydispersion: + scheme: hemispherical + entrance_slit: unknown + energy_scan_mode: fixed_analyser_transmission + diameter: + unit: mm + value: 150 + device_information: + vendor: null + model: null + identifier: null + detector: + amplifier_type: channeltron + detector_type: Multi-anode + manipulator: + device_information: + vendor: SPECS GmbH + model: 5-axis manipulator + identifier: null + temperature_sensor: + name: type K thermocouple + measurement: temperature + attached_to: sample + type: type K thermocouple + value: + value: 298.0 + unit: K + sample_heater: + name: Coherent Compact Evolution IR Diode LASER (DILAS) + physical_quantity: temperature + type: IR diode laser + heater_power: + value: 0.0 + unit: W + pid: + setpoint: + value: 298.0 + unit: K + cryostat: + name: null + physical_quantity: null + type: null + pid: + setpoint: null + drain_current_amperemeter: + name: Amperemeter 1.0 + measurement: current + type: wire + value: + value: 0.0 + unit: A + sample_bias_voltmeter: + name: XPS sample voltmeter + measurement: voltage + attached_to: sample + type: oscilloscope + value: + value: 0.0 + unit: V + sample_bias_potentiostat: + name: XPS sample potentiostat + physical_quantity: voltage + type: potentiostat + pid: + setpoint: + value: 0.0 + unit: V + pressure_gauge: + name: Atmion + measurement: pressure + type: hot-filament ionization gauge + value: + value: 0.000000001 + unit: mbar + value_log: + value: + value: null + unit: null + flood_gun: + name: FG 22/35 + physical_quantity: current + type: low energy electron source + current: + value: 0.0 + unit: A + current_log: + value: + value: null + unit: null +sample: + description: A polymer material called PBTTT with chemical name poly[2,5-bis(3-dodecylthiophen-2-yl)thieno[3,2-b]thiophene]. + substance: + molecular_formula_hill: (C42H62S4)n + situation: vacuum + sample_history: + sample_preparation: + start_time: 2022-04-08T11:02:38.0200Z + end_time: 2022-04-08T11:06:42.200Z + description: From third party + method: null + \ No newline at end of file