Stills: background clip follows the radial curve; signal disk from the lattice spacing
Two stills-only changes to the integration stencil.
1. Where the whole-frame radial curve is in use (the correction on), the ring's high-side clip
follows it: a ring pixel is clipped against the threshold plus the curve's rise from the
reflection's radius to its own (BraggIntegrationEngine::RadialClipOffset, rounded to whole counts
so CPU, CUDA and Metal keep the same pixels). On a background falling steeply away from the beam
the flat mean + 4 sqrt(mean) threshold cut the beam-side half of the ring as outliers, so the
background read low and reflections near the beam stop read 3-150x too strong. The empty-aperture
test's corrected column clips the same way, so the per-run correction decision sees it.
Measured with r1 6 (dimple R_free, battery arguments, all frames):
lcls222 0.196 -> 0.1856, pal86 0.216 -> 0.1997, sacla236 0.2559 -> 0.2559, alvra213_int16 0.1986 -> 0.1986.
2. The signal disk is taken from the lattice: it must not reach into the next node's spot. The
closest two nodes can come on the detector is the shortest reciprocal-lattice vector the centring
allows, s = F_px tan(2 asin(lambda / 2 d_max)), and a spot reaches 2 r80 (measured in the
pre-scan); r1 = the largest of 4, 5, 6 px not above s - 2 r80, never below 4, never above the
disk the run starts with (6). The empty apertures are measured for each candidate disk and the
ring is chosen on the chosen disk's tally. Pixel detectors keep 6 (sacla236 s 22 px, alvra213
20 px); the binned CCDs with a long axis shrink to 4 (lcls222 5.4 px, pal86 6.7 px), which the
radius scans there measured as the optimum; pal90 (s 21 px) and lcls242_s (15.5 px) keep 6.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
This commit is contained in:
1 parent
29000dd3d6
commit
61def00a1a
13 files changed
+228
-50
No files matched your search
@@ -203,3 +203,46 @@ TEST_CASE("BraggIntegrationEngineCPU_RadialCurveFromRings", "[Integration][porta
|
||||
engine.RadialBackgroundFromRings({}, 500, low_q, dq);
|
||||
CHECK(engine.GetRadialBackground().empty());
|
||||
}
|
||||
|
||||
// A ring on a background falling steeply away from the beam: the flat high-side clip cuts the beam-side
|
||||
// half of the ring and the background reads low. With the correction on, the clip follows the frame's
|
||||
// radial curve (RadialClipOffset) and the empty aperture reads zero.
|
||||
TEST_CASE("BraggIntegrationEngineCPU_ClipFollowsRadialCurve", "[Integration][portable]") {
|
||||
DiffractionExperiment experiment(DetJF(2));
|
||||
experiment.DetectorDistance_mm(100.0f).IncidentEnergy_keV(WVL_1A_IN_KEV).BeamX_pxl(400.0f).BeamY_pxl(400.0f);
|
||||
const float bx = 400.0f, by = 400.0f;
|
||||
const auto background = [](double r) { return 40000.0 - 100.0 * r; };
|
||||
const size_t width = experiment.GetXPixelsNum(), npixel = experiment.GetPixelsNum();
|
||||
ImagePreprocessorBuffer image(npixel);
|
||||
for (size_t i = 0; i < npixel; ++i)
|
||||
image[i] = static_cast<int32_t>(std::lround(std::max(0.0,
|
||||
background(std::hypot(static_cast<double>(i % width) - bx, static_cast<double>(i / width) - by)))));
|
||||
const float low_q = 0.05f, dq = 0.01f;
|
||||
const double F_px = 100.0 / 0.075, lambda = 1.0;
|
||||
std::vector<float> rings(500);
|
||||
for (size_t i = 0; i < rings.size(); ++i) {
|
||||
const double q = low_q + (i + 0.5) * dq;
|
||||
rings[i] = static_cast<float>(background(F_px * std::tan(2.0 * std::asin(q * lambda / (4.0 * PI)))));
|
||||
}
|
||||
Reflection r{};
|
||||
r.h = 1; r.k = 0; r.l = 0;
|
||||
r.predicted_x = bx + 200.0f;
|
||||
r.predicted_y = by;
|
||||
r.d = 2.0f;
|
||||
r.prescaling_corr = 1.0f;
|
||||
r.partiality = 1.0f;
|
||||
const std::vector<Reflection> predicted{r};
|
||||
auto background_read = [&](bool correct) {
|
||||
experiment.ImportBraggIntegrationSettings(BraggIntegrationSettings().BackgroundRadialCorrection(correct));
|
||||
BraggIntegrationEngineCPU engine(experiment, PixelMask(experiment));
|
||||
engine.RadialBackgroundFromRings(rings, static_cast<int32_t>(rings.size()), low_q, dq);
|
||||
const auto out = engine.Run(image, predicted, predicted.size(), 0);
|
||||
REQUIRE(out.size() == 1);
|
||||
return out[0].bkg;
|
||||
};
|
||||
// The kernel models the radial offset only; the ring's tangential reach adds the circle's own
|
||||
// curvature, slope * <v^2> / (2 r) = 100 * 51 / 400 = 13 counts, which it leaves.
|
||||
const double truth = background(200.0);
|
||||
CHECK(background_read(false) < truth - 100.0);
|
||||
CHECK(std::fabs(background_read(true) - truth) < 20.0);
|
||||
}
|
||||
Reference in new issue
Block a user