need to also store the norm between iterations; added some comments on why the center/rad/norm are reset and where; r_min/r_max need to be re-calclated every time (or also stored); added todo note

This commit is contained in:
2024-08-02 17:23:11 +02:00
parent ac732cc4b7
commit bbc58ca5e6
2 changed files with 12 additions and 10 deletions

View File

@ -1,18 +1,19 @@
import numpy as np
def calc_radial_integration(results, data, pixel_mask_pf, center, rad):
def calc_radial_integration(results, data, pixel_mask_pf, center, rad, norm):
if center is None:
center = [
results["beam_center_x"],
results["beam_center_y"]
]
rad = None
rad = norm = None
if rad is None:
if rad is None or norm is None:
rad, norm = prepare_radial_profile(data, center, keep_pixels=pixel_mask_pf)
r_min = int(np.min(rad))
r_max = int(np.max(rad)) + 1
r_min = int(np.min(rad))
r_max = int(np.max(rad)) + 1
apply_threshold = results.get("apply_threshold", False)
@ -44,7 +45,7 @@ def calc_radial_integration(results, data, pixel_mask_pf, center, rad):
rp = rp / integral_silent_region
results["radint_normalised"] = [silent_min, silent_max]
results["radint_I"] = rp[r_min:].tolist()
results["radint_I"] = rp[r_min:].tolist() #TODO: why not stop at r_max?
results["radint_q"] = [r_min, r_max]
return center, rad

View File

@ -55,8 +55,9 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host
# all the normal workers
worker = 1
rad_radial_integration = None
center_radial_integration = None
rad_radial_integration = None
norm_radial_integration = None
results = {}
@ -80,7 +81,7 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host
sleep(0.5)
peakfinder_parameters = json_load(fn_peakfinder_parameters)
peakfinder_parameters_time = new_time
center_radial_integration = None
center_radial_integration = None # beam_center_x/beam_center_y might have changed
if worker == 0:
print(f"({pulse_id}) update peakfinder parameters {old_peakfinder_parameters}", flush=True)
print(f" --> {peakfinder_parameters}", flush=True)
@ -143,7 +144,7 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host
id_pixel_mask_2 = id(pixel_mask_corrected)
if id_pixel_mask_1 != id_pixel_mask_2:
rad_radial_integration = None
rad_radial_integration = norm_radial_integration = None # if the pixel mask changes, the radii and normalization need to be re-calculated
if pixel_mask_corrected is not None:
pixel_mask_pf = np.ascontiguousarray(pixel_mask_corrected)
calc_apply_additional_mask(results, pixel_mask_pf) # changes pixel_mask_pf in place
@ -161,7 +162,7 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host
# pump probe analysis
do_radial_integration = results.get("do_radial_integration", False)
if do_radial_integration:
center_radial_integration, rad_radial_integration = calc_radial_integration(results, data, pixel_mask_pf, center_radial_integration, rad_radial_integration)
center_radial_integration, rad_radial_integration, norm_radial_integration = calc_radial_integration(results, data, pixel_mask_pf, center_radial_integration, rad_radial_integration, norm_radial_integration)
#copy image to work with peakfinder, just in case