removed all manual array.tolist() conversions (and similar) that were needed for json serializability

This commit is contained in:
2025-11-03 19:45:37 +01:00
parent deb9253acf
commit 10701994ec
6 changed files with 9 additions and 10 deletions

View File

@@ -54,8 +54,8 @@ def calc_peakfinder_analysis(results, data, pixel_mask):
results["number_of_spots"] = number_of_spots
# to coordinates where position of first pixel/point is (1, 1)
results["spot_x"] = [x + 0.5 for x in peak_list_x]
results["spot_y"] = [y + 0.5 for y in peak_list_y]
results["spot_x"] = peak_list_x + 0.5
results["spot_y"] = peak_list_y + 0.5
results["spot_intensity"] = copy(peak_list_value) #TODO: why is this copy needed?
npeaks_threshold_hit = results.get("npeaks_threshold_hit", 15)

View File

@@ -33,7 +33,7 @@ def calc_radial_integration(results, data, pixel_mask):
rp = rp / integral_silent_region
results["radint_normalised"] = [silent_min, silent_max]
results["radint_I"] = rp[r_min:].tolist() #TODO: why not stop at r_max?
results["radint_I"] = rp[r_min:] #TODO: why not stop at r_max?
results["radint_q"] = [r_min, r_max]

View File

@@ -40,7 +40,7 @@ def calc_roi(results, data):
roi_sum_norm = np.nanmean(data_roi, dtype=float) # data_roi is np.float32, which cannot be json serialized
roi_indices_x = [ix1, ix2]
roi_proj_x = np.nansum(data_roi, axis=0).tolist()
roi_proj_x = np.nansum(data_roi, axis=0)
roi_intensities.append(roi_sum)
roi_intensities_normalised.append(roi_sum_norm)

View File

@@ -36,7 +36,7 @@ def calc_spi_analysis(results, data):
hit = (photon_percentage > spi_threshold_hit_percentage)
results["number_of_spots"] = photon_percentage
results["is_hit_frame"] = bool(hit) # json does not like numpy bool_ scalars
results["is_hit_frame"] = hit

View File

@@ -205,17 +205,16 @@ def _calc_streakfinder_analysis(results, snr, mask):
streak_lengths = np.sqrt(
np.power((streak_lines[..., 2] - streak_lines[..., 0]), 2) +
np.power((streak_lines[..., 2] - streak_lines[..., 0]), 2)
).tolist()
)
streak_lines = streak_lines.T
_, number_of_streaks = streak_lines.shape
list_result = streak_lines.tolist() # arr(4, n_lines); coord x0, y0, x1, y1
bragg_counts = [streak.total_mass() for streak in detected_streaks]
results["number_of_streaks"] = number_of_streaks
results["is_hit_frame"] = (number_of_streaks > min_hit_streaks)
results["streaks"] = list_result
results["streaks"] = streak_lines # arr(4, n_lines); coord x0, y0, x1, y1
results["streak_lengths"] = streak_lengths
results["bragg_counts"] = bragg_counts

View File

@@ -110,8 +110,8 @@ def work(backend_addr, accumulator_addr, visualisation_addr, fn_config, skip_fra
if pixel_mask is not None:
saturated_pixels_y, saturated_pixels_x = jfdata.get_saturated_pixels(raw_image, double_pixels)
results["saturated_pixels"] = len(saturated_pixels_x)
results["saturated_pixels_x"] = saturated_pixels_x.tolist()
results["saturated_pixels_y"] = saturated_pixels_y.tolist()
results["saturated_pixels_x"] = saturated_pixels_x
results["saturated_pixels_y"] = saturated_pixels_y
calc_radial_integration(results, image, pixel_mask)