Skip to content
Snippets Groups Projects
Commit dde9ab6f authored by Jakobsen, Mads Bregenholt's avatar Jakobsen, Mads Bregenholt
Browse files

added photonization via photon energy

parent ed15b532
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,8 @@ class Xpcs(BaseCorrectionAddon): ...@@ -13,6 +13,8 @@ class Xpcs(BaseCorrectionAddon):
def __init__(self, config): def __init__(self, config):
self._ttcdata = TTCdata() self._ttcdata = TTCdata()
self._mask_path = config["mask_path"] self._mask_path = config["mask_path"]
self._photon_energy = config.get("photonEnergy")
self._module_no = None self._module_no = None
self._current_image_mean = 0 self._current_image_mean = 0
...@@ -20,6 +22,7 @@ class Xpcs(BaseCorrectionAddon): ...@@ -20,6 +22,7 @@ class Xpcs(BaseCorrectionAddon):
self._sparse_array = None self._sparse_array = None
self._cal_mask = None self._cal_mask = None
global cupy global cupy
import cupy import cupy
...@@ -41,6 +44,18 @@ class Xpcs(BaseCorrectionAddon): ...@@ -41,6 +44,18 @@ class Xpcs(BaseCorrectionAddon):
.defaultValue("") .defaultValue("")
.reconfigurable() .reconfigurable()
.commit(), .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 @staticmethod
...@@ -72,6 +87,10 @@ class Xpcs(BaseCorrectionAddon): ...@@ -72,6 +87,10 @@ class Xpcs(BaseCorrectionAddon):
self._mask_path = changed_config["mask_path"] self._mask_path = changed_config["mask_path"]
self.set_mask() 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): def post_correction(self, data, cell_table, pulse_table, output_hash):
global cupy global cupy
...@@ -79,11 +98,11 @@ class Xpcs(BaseCorrectionAddon): ...@@ -79,11 +98,11 @@ class Xpcs(BaseCorrectionAddon):
data[0] = 0 data[0] = 0
# Photonize # Photonize
# print(f"Unphotonized mean ({data.shape}): {np.nanmean(data)}") # print(f"Unphotonized mean ({data.shape}): {np.nanmean(data)}")
start = time.time() data /= self._photon_energy
data /= 10
data[data < 0] = 0
np.around(data, out=data) np.around(data, out=data)
# print(f"Photonized mean: {np.nanmean(data)}") # print(f"Photonized mean: {np.nanmean(data)}")
# Sparsify # Sparsify
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment