id4_common.plans.peak_position_legacy#

DEPRECATED — kept temporarily for reference (issue #59).

This is the pre-#59 peak_position.py (xy_statistics-based peak / pmax / pmin / peak_pos). The new peak_position.py alongside it provides scipy-backed cen / com / maxi / mini with native 2D grid_scan support, plus backward-compatible peak / pmax / pmin aliases.

This file is not imported by anything — verify with grep -rn 'peak_position_legacy' src/ before deleting.

TODO(#59): remove after the new module has been validated at the beamline.

Module Contents#

id4_common.plans.peak_position_legacy.peak_pos(scan_id=-1, x=None, y=None)#

Compute peak statistics for one or more detectors of a previous scan.

Loads scan data from the shared session catalog (id4_common.utils.run_engine.cat) and computes statistics with apstools.utils.xy_statistics() — the same numpy-based machinery used by apstools.plans.alignment.lineup2.

Parameters:
  • scan_id (int, optional) – Catalog index. Default -1 (last scan); negative indices count from the end.

  • x (str, optional) – Motor (x-axis) field name. If None, uses the first entry in the scan’s start["motors"].

  • y (str or list of str, optional) – Detector (y-axis) field name(s). If None, uses every entry in start["hints"]["detectors"].

Returns:

Nested dict mirroring bluesky.callbacks.best_effort.peaks:

{
    "com":  {detector: x_centroid, ...},
    "max":  {detector: (x_at_max_y, max_y), ...},
    "min":  {detector: (x_at_min_y, min_y), ...},
    "fwhm": {detector: fwhm, ...},
}

Return type:

dict

id4_common.plans.peak_position_legacy.peak(scan_id=-1, feature='centroid', positioner=None, detector=None, confirm=True)#

Plan that moves a positioner to the peak position of a previous scan.

Uses peak_pos() (which calls apstools.utils.xy_statistics()) to compute the requested feature from the scan data, then moves positioner there.

For multi-positioner scans (hklscan, …) the fastest-changing motor (largest range) is used as the default, but the user is prompted to confirm or pick a different scan motor. th2th scans are a special case: 2θ (gamma) is always the right axis, so no prompt is shown. Pass confirm=False to skip every interactive prompt (positioner choice and the >5-min move confirmation).

Parameters:
  • scan_id (int, optional) – Catalog index. Default -1 (last scan).

  • feature (str, optional) – Statistical measure to move to. Default "centroid".

  • positioner (ophyd object, optional) – Device to move. If None, the scan’s fastest-changing motor is used (with an interactive override for multi-motor scans).

  • detector (str, optional) – Detector field name passed through to peak_pos() as y.

  • confirm (bool, optional) – If True (default), interactive prompts are shown when appropriate (positioner selection for multi-motor scans and the >5-min move confirmation). If False, all such prompts are skipped.

id4_common.plans.peak_position_legacy.pmax(scan_id=-1, positioner=None, detector=None, confirm=True)#

Plan that moves a positioner to the x value at peak maximum.

Convenience wrapper for peak() with feature="x_at_max_y".

Parameters:
  • scan_id (int, optional) – Catalog index of the scan to analyse. Default -1 (last scan); negative indices count from the end.

  • positioner (ophyd object, optional) – Device to move. If None, the scan’s fastest-changing motor is used (with an interactive override for multi-motor scans).

  • detector (str, optional) – Detector field name passed through to peak_pos() as y.

  • confirm (bool, optional) – If True (default), interactive prompts are shown when appropriate (positioner selection for multi-motor scans and the >5-min move confirmation). If False, all such prompts are skipped.

See also

peak(), pmin(), peak_pos()

id4_common.plans.peak_position_legacy.pmin(scan_id=-1, positioner=None, detector=None, confirm=True)#

Plan that moves a positioner to the x value at peak minimum.

Convenience wrapper for peak() with feature="x_at_min_y".

Parameters:
  • scan_id (int, optional) – Catalog index of the scan to analyse. Default -1 (last scan); negative indices count from the end.

  • positioner (ophyd object, optional) – Device to move. If None, the scan’s fastest-changing motor is used (with an interactive override for multi-motor scans).

  • detector (str, optional) – Detector field name passed through to peak_pos() as y.

  • confirm (bool, optional) – If True (default), interactive prompts are shown when appropriate (positioner selection for multi-motor scans and the >5-min move confirmation). If False, all such prompts are skipped.

See also

peak(), pmax(), peak_pos()