Skip to content

407 add automatic data analysis com gaussian fit 1st2nd derivatives after scans complete - #440

Open
Relm-Arrowny wants to merge 35 commits into
mainfrom
407-add-automatic-data-analysis-com-gaussian-fit-1st2nd-derivatives-after-scans-complete
Open

Relm-Arrowny wants to merge 35 commits into
mainfrom
407-add-automatic-data-analysis-com-gaussian-fit-1st2nd-derivatives-after-scans-complete

Conversation

@Relm-Arrowny

@Relm-Arrowny Relm-Arrowny commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #407

Changes

  • Add 1D scan analysis utilities in sm_bluesky.common.math:
    • fit_gaussian (Gaussian + linear background via lmfit)
    • calculate_com (centre of mass with optional baseline subtraction)
    • calculate_derivatives (1st/2nd derivatives, min/max slopes, and zero crossings)
  • Added scan fitting into src/sm_bluesky/common/clients/blueapi_session.py:
    • Auto-analyse scans on completion (auto_analyse=True) and added fitting result in to cached data.
    • Added fit_scan(), set_fit_axes(), and last_fit (centre, com, max_slope_x, min_slope_x, 'zero_crossings`) in the interactive IPython shell for scripting.
  • Filter scalar data and derived curves in InteractivePlotWindow for 1D and 2D plot modes.
  • Add unit tests and update the BlueAPISession tutorial documentation.

Instructions to reviewer on how to test:

  1. Ensure test pass can correctly test the behaviours.
  2. Try out the live ploting ensure fitting works and user "friendly enough".

Checks for reviewer

  • Would the PR title make sense to a user on a set of release notes
Image

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e448663) to head (f7e83d0).

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #440    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           40        41     +1     
  Lines         1916      2057   +141     
==========================================
+ Hits          1916      2057   +141     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanPorter DanPorter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great addition and provides the useful requested fitting capability.

I haven't tested this yet so will do so before approving, but I've also left some comments and queries that should be addressed.

Comment thread src/sm_bluesky/common/math/analysis.py Resolved
Comment thread src/sm_bluesky/common/math/analysis.py Resolved
Comment thread src/sm_bluesky/common/math/analysis.py Resolved
Comment thread src/sm_bluesky/common/math/analysis.py Resolved
Comment thread src/sm_bluesky/common/math/analysis.py Resolved
…-fit-1st2nd-derivatives-after-scans-complete
…-fit-1st2nd-derivatives-after-scans-complete

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add automatic data analysis (COM, Gaussian fit, 1st/2nd derivatives) after scans complete.

3 participants