From e281e8cacefb850b54bb9e1245e51d898798094a Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:18:34 +0100 Subject: [PATCH] add writing of CPS data to vms reader --- pynxtools_xps/vms/vamas.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pynxtools_xps/vms/vamas.py b/pynxtools_xps/vms/vamas.py index 4957f913..e5ef1f6b 100644 --- a/pynxtools_xps/vms/vamas.py +++ b/pynxtools_xps/vms/vamas.py @@ -187,7 +187,8 @@ def _update_xps_dict_with_spectrum(self, spectrum, key_map): detector_data_key = f'{path_map["detector"]}/{detector_data_key_child}/counts' energy = np.array(spectrum["data"]["x"]) - intensity = np.array(spectrum["data"]["y"]) + intensity_raw = np.array(spectrum["data"]["y"]) + intensity_cps = np.array(spectrum["data"]["y_cps"]) if entry not in self._xps_dict["data"]: self._xps_dict["data"][entry] = xr.Dataset() @@ -203,7 +204,7 @@ def _update_xps_dict_with_spectrum(self, spectrum, key_map): averaged_scans = np.mean(all_scan_data, axis=0) if averaged_scans.size == 1: # on first scan in cycle - averaged_scans = intensity + averaged_scans = intensity_cps try: self._xps_dict["data"][entry][scan_key.split("_")[0]] = xr.DataArray( @@ -213,13 +214,12 @@ def _update_xps_dict_with_spectrum(self, spectrum, key_map): except ValueError: pass - # Write scan data to 'data'. self._xps_dict["data"][entry][scan_key] = xr.DataArray( - data=intensity, coords={"energy": energy} + data=intensity_cps, coords={"energy": energy} ) # Write raw intensities to 'detector'. - self._xps_dict[detector_data_key] = intensity + self._xps_dict[detector_data_key] = intensity_raw class VamasParser(ABC): @@ -603,9 +603,16 @@ def build_list(self): for var in range(int(block.no_variables)): if var == 0: key = "y" + + data["y"] = getattr(block, "y") + + if block.variable_label_1 == "Intensity": + y_cps = [np.round(y / block.dwell_time, 2) for y in block.y] + data["y_cps"] = y_cps + else: key = "y" + str(var) - data[key] = getattr(block, key) + data[key] = getattr(block, key) spec_dict = { "time_stamp": date_time,