diff --git a/xpcs/src/xpcs/xpcs.py b/xpcs/src/xpcs/xpcs.py index c7ae062bfc59da40a402797a7900b29a792f925b..cb8cb6aa355783e787fc4919ff16ba419b72bbf8 100644 --- a/xpcs/src/xpcs/xpcs.py +++ b/xpcs/src/xpcs/xpcs.py @@ -13,6 +13,8 @@ class Xpcs(BaseCorrectionAddon): def __init__(self, config): self._ttcdata = TTCdata() self._mask_path = config["mask_path"] + self._photon_energy = config.get("photonEnergy") + self._module_no = None self._current_image_mean = 0 @@ -20,6 +22,7 @@ class Xpcs(BaseCorrectionAddon): self._sparse_array = None self._cal_mask = None + global cupy import cupy @@ -41,6 +44,18 @@ class Xpcs(BaseCorrectionAddon): .defaultValue("") .reconfigurable() .commit(), + + + # value of the photon energy. used for the photonization step + DOUBLE_ELEMENT(schema) + .key(f"{prefix}.photonEnergy") + .tags("managed") + .assignmentOptional() + .defaultValue(8.0) + .reconfigurable() + .commit(), + + ) @staticmethod @@ -72,6 +87,10 @@ class Xpcs(BaseCorrectionAddon): self._mask_path = changed_config["mask_path"] self.set_mask() + if changed_config.has("photonEnergy"): + self._photon_energy = changed_config["photonEnergy"] + + def post_correction(self, data, cell_table, pulse_table, output_hash): global cupy @@ -79,11 +98,11 @@ class Xpcs(BaseCorrectionAddon): data[0] = 0 # Photonize + # print(f"Unphotonized mean ({data.shape}): {np.nanmean(data)}") - start = time.time() - data /= 10 - data[data < 0] = 0 + data /= self._photon_energy np.around(data, out=data) + # print(f"Photonized mean: {np.nanmean(data)}") # Sparsify