cleanup; logic also works correctly for number_of_spots == 0

This commit is contained in:
2024-07-30 19:48:32 +02:00
parent 96878e1b67
commit 7b2a1c3935

View File

@ -8,6 +8,7 @@ from peakfinder8_extension import peakfinder_8
def calc_peakfinder_analysis(results, data, pixel_mask_pf): def calc_peakfinder_analysis(results, data, pixel_mask_pf):
x_beam = results["beam_center_x"] - 0.5 # to coordinates where position of first pixel/point is 0.5, 0.5 x_beam = results["beam_center_x"] - 0.5 # to coordinates where position of first pixel/point is 0.5, 0.5
y_beam = results["beam_center_y"] - 0.5 # to coordinates where position of first pixel/point is 0.5, 0.5 y_beam = results["beam_center_y"] - 0.5 # to coordinates where position of first pixel/point is 0.5, 0.5
hitfinder_min_snr = results["hitfinder_min_snr"] hitfinder_min_snr = results["hitfinder_min_snr"]
hitfinder_min_pix_count = int(results["hitfinder_min_pix_count"]) hitfinder_min_pix_count = int(results["hitfinder_min_pix_count"])
hitfinder_adc_thresh = results["hitfinder_adc_thresh"] hitfinder_adc_thresh = results["hitfinder_adc_thresh"]
@ -42,17 +43,12 @@ def calc_peakfinder_analysis(results, data, pixel_mask_pf):
number_of_spots = len(peak_list_x) number_of_spots = len(peak_list_x)
results["number_of_spots"] = number_of_spots results["number_of_spots"] = number_of_spots
if number_of_spots != 0:
results["spot_x"] = [-1.0] * number_of_spots results["spot_x"] = [-1.0] * number_of_spots
results["spot_y"] = [-1.0] * number_of_spots results["spot_y"] = [-1.0] * number_of_spots
results["spot_intensity"] = copy(peak_list_value) results["spot_intensity"] = copy(peak_list_value)
for i in range(number_of_spots): for i in range(number_of_spots):
results["spot_x"][i] = peak_list_x[i] + 0.5 results["spot_x"][i] = peak_list_x[i] + 0.5
results["spot_y"][i] = peak_list_y[i] + 0.5 results["spot_y"][i] = peak_list_y[i] + 0.5
else:
results["spot_x"] = []
results["spot_y"] = []
results["spot_intensity"] = []
npeaks_threshold_hit = results.get("npeaks_threshold_hit", 15) npeaks_threshold_hit = results.get("npeaks_threshold_hit", 15)