Skip to content

Commit 6f8ba06

Browse files
committed
FIX: loading of incomplete step scans at SRX
1 parent 48ccd0c commit 6f8ba06

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

pyxrf/model/load_data_from_db.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,6 +2393,10 @@ def map_data2D_srx_new_tiled(
23932393
# NEW SRX STEP SCAN
23942394
# ===================================================================
23952395
if scan_doc["type"] == "XRF_STEP":
2396+
2397+
# The scan parameters are arranged differently than the parameters for the fly scan
2398+
fast_start, fast_stop, fast_step, slow_start, slow_stop, slow_step = scan_doc["scan_input"][:6]
2399+
23962400
data_primary = hdr.primary["data"]
23972401

23982402
# Define keys for motor data
@@ -2409,7 +2413,16 @@ def map_data2D_srx_new_tiled(
24092413
num_events = len(fast_pos)
24102414
n_scan_fast, n_scan_slow = scan_doc["shape"]
24112415
n_scan_fast, n_scan_slow = int(n_scan_fast), int(n_scan_slow)
2412-
num_rows = len(fast_pos) / n_scan_fast
2416+
num_rows_float = len(fast_pos) / n_scan_fast
2417+
num_rows = int(num_rows_float)
2418+
num_rows = num_rows if abs(num_rows_float - num_rows) < 1e-9 else num_rows + 1
2419+
n_missing_pts = num_rows * n_scan_fast - len(fast_pos)
2420+
2421+
if n_missing_pts:
2422+
_ = da.arange(fast_step, fast_step * n_missing_pts + fast_step / 2, fast_step) + fast_pos[-1]
2423+
fast_pos = da.concatenate((fast_pos, _))
2424+
slow_pos = da.concatenate((slow_pos, np.ones(n_missing_pts) * slow_pos[-1]))
2425+
24132426
fast_pos = da.reshape(fast_pos, (num_rows, n_scan_fast))
24142427
slow_pos = da.reshape(slow_pos, (num_rows, n_scan_fast))
24152428

@@ -2450,6 +2463,10 @@ def map_data2D_srx_new_tiled(
24502463
d_xs[i, :, :] = d
24512464
del d
24522465

2466+
if n_missing_pts:
2467+
_ = da.zeros([d_xs.shape[0], n_missing_pts, d_xs.shape[2]], dtype=d_xs.dtype)
2468+
d_xs = da.concatenate((d_xs, _), axis=1)
2469+
24532470
d_xs = da.reshape(d_xs, (N_xs, num_rows, n_scan_fast, N_bins))
24542471

24552472
# Sum data
@@ -2465,7 +2482,12 @@ def map_data2D_srx_new_tiled(
24652482
sclr_names.append(s)
24662483
if sclr_names:
24672484
sclr_list = [data_primary[_].read() for _ in sclr_names]
2468-
sclr_list = [da.reshape(_, (n_scan_slow, n_scan_fast)) for _ in sclr_list]
2485+
for n in range(len(sclr_list)):
2486+
sc = sclr_list[n]
2487+
if n_missing_pts:
2488+
sc = da.concatenate((sc, np.zeros(n_missing_pts, dtype=sc.dtype)))
2489+
sc = da.reshape(sc, (num_rows, n_scan_fast))
2490+
sclr_list[n] = sc
24692491
sclr = da.stack(sclr_list, axis=-1)
24702492
else:
24712493
sclr = None

0 commit comments

Comments
 (0)