Skip to content
Snippets Groups Projects
Commit a987b9ef authored by David Hammer's avatar David Hammer
Browse files

Handle fixed gain mode as operating condition, too

parent 00231fd2
No related branches found
No related tags found
2 merge requests!12Snapshot: field test deployed version as of end of run 202201,!3Base correction device, CalCat interaction, DSSC and AGIPD devices
......@@ -93,6 +93,8 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
g_gain_value=1,
):
self.gain_mode = gain_mode
# default gain only matters when not thresholding (missing constant or fixed)
# note: gain stage (result of thresholding) is 0, 1, or 2
if self.gain_mode is AgipdGainMode.ADAPTIVE_GAIN:
self.default_gain = cupy.uint8(gain_mode)
else:
......@@ -279,10 +281,6 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
def correct(self, flags):
if flags & CorrectionFlags.BLSHIFT:
raise NotImplementedError("Baseline shift not implemented yet")
if self.gain_mode is not AgipdGainMode.ADAPTIVE_GAIN and (
flags & CorrectionFlags.THRESHOLD
):
raise ValueError("Cannot do gain thresholding in fixed gain mode")
self.correction_kernel(
self.full_grid,
......@@ -376,11 +374,11 @@ class AgipdCalcatFriend(calcat_utils.BaseCalcatFriend):
.reconfigurable()
.commit(),
DOUBLE_ELEMENT(schema)
STRING_ELEMENT(schema)
.key(f"{param_prefix}.gainMode")
.assignmentOptional()
.defaultValue(0)
.reconfigurable()
.defaultValue("ADAPTIVE_GAIN")
.options("ADAPTIVE_GAIN,FIXED_HIGH_GAIN,FIXED_MEDIUM_GAIN,FIXED_LOW_GAIN")
.commit(),
DOUBLE_ELEMENT(schema)
......@@ -404,25 +402,25 @@ class AgipdCalcatFriend(calcat_utils.BaseCalcatFriend):
res["Pixels X"] = self._get_param("pixelsX")
res["Pixels Y"] = self._get_param("pixelsY")
res["Acquisition rate"] = self._get_param("acquisitionRate")
# TODO: make configurable whether or not to include gain setting?
# TODO: remove this workaround after CalCat update
integration_time = self._get_param("integrationTime")
if integration_time != 12:
res["Integration Time"] = integration_time
gain_mode = AgipdGainMode[self._get_param("gainMode")]
if gain_mode is not AgipdGainMode.ADAPTIVE_GAIN:
res["Gain Mode"] = gain_mode.value
# TODO: make configurable whether or not to include gain setting?
res["Gain Setting"] = self._get_param("gainSetting")
return res
def illuminated_condition(self):
res = calcat_utils.OperatingConditions()
res["Memory cells"] = self._get_param("memoryCells")
res["Sensor Bias Voltage"] = self._get_param("biasVoltage")
res["Pixels X"] = self._get_param("pixelsX")
res["Pixels Y"] = self._get_param("pixelsY")
res = self.dark_condition()
res["Source Energy"] = self._get_param("photonEnergy")
res["Acquisition rate"] = self._get_param("acquisitionRate")
integration_time = self._get_param("integrationTime")
if integration_time != 12:
res["Integration Time"] = integration_time
res["Gain Setting"] = self._get_param("gainSetting")
return res
......@@ -454,16 +452,6 @@ class AgipdCorrection(BaseCorrection):
.setNewDefaultValue("cell")
.commit(),
)
# WIP: fixed gain mode
(
STRING_ELEMENT(expected)
.key("gainMode")
.displayedName("Gain mode")
.assignmentOptional()
.defaultValue("ADAPTIVE_GAIN")
.options("ADAPTIVE_GAIN,FIXED_HIGH_GAIN,FIXED_MEDIUM_GAIN,FIXED_LOW_GAIN")
.commit(),
)
(
OUTPUT_CHANNEL(expected)
......@@ -595,8 +583,8 @@ class AgipdCorrection(BaseCorrection):
def __init__(self, config):
super().__init__(config)
# TODO: consider different gpu runner for fixed gain mode
self.gain_mode = AgipdGainMode[config.get("gainMode")]
# note: gain mode single sourced from constant retrieval node
self.gain_mode = AgipdGainMode[config.get("constantParameters.gainMode")]
try:
self.bad_pixel_mask_value = np.float32(
......
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