Skip to content

Commit

Permalink
add writing of CPS data to vms reader
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Feb 20, 2024
1 parent c384412 commit e281e8c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pynxtools_xps/vms/vamas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e281e8c

Please sign in to comment.