Skip to content

Conversation

@jackbdoughty
Copy link
Contributor

@jackbdoughty jackbdoughty commented May 15, 2025

Description of work

  • Minor refactoring/additions to devices/DAE area

    • SimpleDae strategies now accept DAEs of type DAE rather than only SimpleDae. This is because some were needed by the new type of DAE being implemented.
    • Implements a new type of DAE, DualRunDae, which requires a flipper device to be provided
      and will perform two runs, changing the flipper device at the start and in between runs.
    • Creates two new types of reducers, one for normalising wavelength bounded spectra, and another which calculates polarisation and polarisation ratio given an up & down normalising wavelength bounded spectra. What this will give you is polarisation information per wavelength bound which is then plotted & fitted to.
    • A function, polarising_dae which instantiates a DualRunDae suited for spin echo / polarisation, with the two new types of reducer. It will do the following each time it is triggered by the run engine:
    1) change the state of the flipper (up)
    2) start counting
    3) do wavelength bounding & normalise 
    4) change the state of the flipper (down)
    5) start counting
    6) do wavelength bounding & normalise 
    7) calculate polarisation data
    
  • Addition to fitting area

    • Introduces a ChainedLiveFit callback which handles a sequence of LiveFit instances where the parameters from each
      completed fit serve as the initial guess for the subsequent fit. By passing a set of mpl axes to it, it handles LiveFitPlots which point to the LiveFits. Only this should be subscribed, not any LiveFits/LiveFitPlots.
  • LARMOR inst script/plan

    • A instrument script-like file that brings together the above additions into a spin-echo scan and autotuner, providing defaults and an interface for use on LARMOR.
    • Larmor spin echo plan #213 larmor plans, not to be merged to be put in inst scripts
  • Unit tests & documentation

To test

  • run unit tests & check for good coverage
  • put dae into event sim mode, with spreadevents on (with lots of events), and have two blocks set up like the following img, and run a script that uses the top level plans. You may need to tweak certain defaults such as log file locations to get it to run. happy to help if can't sort out test setup
    image
  • check that docs changes are verbose enough
  • probably best to squish to avoid having commits like "i <3 unit tests" and "remove a bit of code that idk where it came from?"
    and "polarisation consolidation transformation"

Also note:

@jackbdoughty jackbdoughty added the bluesky-Semver-Minor New functionality / back-compatible changes label May 15, 2025
- realised that PolarisingDae should not be a type of SimpleDae
- This meant that PolarisingDae could not use any of SimpleDae's controllers, waiters or reducers
- As a result, centralised all controllers, waiters and reducers to a subdirectory of dae called strategies, whereby they all accept Dae rather than SimpleDae/PolarisingDae unless required to
- Updated all references
- May put something in architectural decisions
@jackbdoughty jackbdoughty marked this pull request as ready for review June 26, 2025 10:46
Copy link
Contributor

@rerpha rerpha left a comment

Choose a reason for hiding this comment

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

some very initial thoughts


For complex use-cases, particularly those where the DAE may need to start and stop multiple
acquisitions per scan point (e.g. polarization measurements), [`SimpleDae`](ibex_bluesky_core.devices.simpledae.SimpleDae) is unlikely to be
acquisitions per scan point (e.g. Polarisation measurements), [`SimpleDae`](ibex_bluesky_core.devices.simpledae.SimpleDae) is unlikely to be
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this change.

image

@rerpha
Copy link
Contributor

rerpha commented Jun 30, 2025

probably best to squish to avoid having commits like "i <3 unit tests" and "remove a bit of code that idk where it came from?"
and "polarisation consolidation transformation"

OK will squash and git commit --amend -m "initial commit"

@rerpha
Copy link
Contributor

rerpha commented Jul 1, 2025

I get this after 2 points:

+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
|   seq_num |       time |        bob | DAE-reducer-_wavelength_bands-0-polarisation | DAE-reducer-_wavelength_bands-1-polarisation | DAE-reducer-_wavelength_bands-0-polarisation_stddev | DAE-reducer-_wavelength_bands-1-polarisation_stddev |
+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
|         1 | 13:11:11.8 |      0.000 |                                    -0.046238 |                                    -0.026738 |                                            0.057474 |                                            0.163024 |
|         2 | 13:11:26.0 |      1.111 |                                    -0.145277 |                                     0.079755 |                                            0.055797 |                                            0.178137 |
C:\Instrument\Apps\Python3\Lib\site-packages\uncertainties\core.py:1024: UserWarning: Using UFloat objects with std_dev==0 may give unexpected results.
  warn("Using UFloat objects with std_dev==0 may give unexpected results.")
|         3 | 13:11:40.5 |      2.222 |                                    -0.111412 |                                     0.222904 |                                            0.053564 |                                            0.154281 |
|         4 | 13:11:54.6 |      3.333 |                                    -0.004297 |                                     0.377670 |                                            0.060687 |                                            0.112492 |
|         5 | 13:12:08.9 |      4.444 |                                     0.064048 |                                    -0.012715 |                                            0.053104 |                                            0.151237 |
|         6 | 13:12:23.2 |      5.556 |                                     0.060740 |                                    -0.084991 |                                            0.058567 |                                            0.139122 |
|         7 | 13:12:37.5 |      6.667 |                                    -0.024282 |                                     0.211073 |                                            0.059050 |                                            0.164518 |
|         8 | 13:12:51.8 |      7.778 |                                    -0.098603 |                                     0.034672 |                                            0.057373 |                                            0.166516 |
|         9 | 13:13:06.5 |      8.889 |                                     0.042290 |                                     0.196634 |                                            0.056514 |                                            0.101424 |
|        10 | 13:13:20.7 |     10.000 |                                     0.044984 |                                     0.115505 |                                            0.053513 |                                            0.128628 |
+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
generator scan ['dfa177a4'] (scan num: 22)

also reproduceable in tests

@jackbdoughty
Copy link
Contributor Author

I get this after 2 points:

+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
|   seq_num |       time |        bob | DAE-reducer-_wavelength_bands-0-polarisation | DAE-reducer-_wavelength_bands-1-polarisation | DAE-reducer-_wavelength_bands-0-polarisation_stddev | DAE-reducer-_wavelength_bands-1-polarisation_stddev |
+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
|         1 | 13:11:11.8 |      0.000 |                                    -0.046238 |                                    -0.026738 |                                            0.057474 |                                            0.163024 |
|         2 | 13:11:26.0 |      1.111 |                                    -0.145277 |                                     0.079755 |                                            0.055797 |                                            0.178137 |
C:\Instrument\Apps\Python3\Lib\site-packages\uncertainties\core.py:1024: UserWarning: Using UFloat objects with std_dev==0 may give unexpected results.
  warn("Using UFloat objects with std_dev==0 may give unexpected results.")
|         3 | 13:11:40.5 |      2.222 |                                    -0.111412 |                                     0.222904 |                                            0.053564 |                                            0.154281 |
|         4 | 13:11:54.6 |      3.333 |                                    -0.004297 |                                     0.377670 |                                            0.060687 |                                            0.112492 |
|         5 | 13:12:08.9 |      4.444 |                                     0.064048 |                                    -0.012715 |                                            0.053104 |                                            0.151237 |
|         6 | 13:12:23.2 |      5.556 |                                     0.060740 |                                    -0.084991 |                                            0.058567 |                                            0.139122 |
|         7 | 13:12:37.5 |      6.667 |                                    -0.024282 |                                     0.211073 |                                            0.059050 |                                            0.164518 |
|         8 | 13:12:51.8 |      7.778 |                                    -0.098603 |                                     0.034672 |                                            0.057373 |                                            0.166516 |
|         9 | 13:13:06.5 |      8.889 |                                     0.042290 |                                     0.196634 |                                            0.056514 |                                            0.101424 |
|        10 | 13:13:20.7 |     10.000 |                                     0.044984 |                                     0.115505 |                                            0.053513 |                                            0.128628 |
+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
generator scan ['dfa177a4'] (scan num: 22)

also reproduceable in tests

yes im really not sure about this, initially we thought it was to do with chainedlivefit, carrying over parameter uncertainties between fits but its something I've seen on other ibc branches too e.g momentum scan one we're working on atm, and after making the chainedlivefit fix, it didn't change this, might be good to have a chat about it..

@rerpha
Copy link
Contributor

rerpha commented Jul 2, 2025

I get this after 2 points:

+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
|   seq_num |       time |        bob | DAE-reducer-_wavelength_bands-0-polarisation | DAE-reducer-_wavelength_bands-1-polarisation | DAE-reducer-_wavelength_bands-0-polarisation_stddev | DAE-reducer-_wavelength_bands-1-polarisation_stddev |
+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
|         1 | 13:11:11.8 |      0.000 |                                    -0.046238 |                                    -0.026738 |                                            0.057474 |                                            0.163024 |
|         2 | 13:11:26.0 |      1.111 |                                    -0.145277 |                                     0.079755 |                                            0.055797 |                                            0.178137 |
C:\Instrument\Apps\Python3\Lib\site-packages\uncertainties\core.py:1024: UserWarning: Using UFloat objects with std_dev==0 may give unexpected results.
  warn("Using UFloat objects with std_dev==0 may give unexpected results.")
|         3 | 13:11:40.5 |      2.222 |                                    -0.111412 |                                     0.222904 |                                            0.053564 |                                            0.154281 |
|         4 | 13:11:54.6 |      3.333 |                                    -0.004297 |                                     0.377670 |                                            0.060687 |                                            0.112492 |
|         5 | 13:12:08.9 |      4.444 |                                     0.064048 |                                    -0.012715 |                                            0.053104 |                                            0.151237 |
|         6 | 13:12:23.2 |      5.556 |                                     0.060740 |                                    -0.084991 |                                            0.058567 |                                            0.139122 |
|         7 | 13:12:37.5 |      6.667 |                                    -0.024282 |                                     0.211073 |                                            0.059050 |                                            0.164518 |
|         8 | 13:12:51.8 |      7.778 |                                    -0.098603 |                                     0.034672 |                                            0.057373 |                                            0.166516 |
|         9 | 13:13:06.5 |      8.889 |                                     0.042290 |                                     0.196634 |                                            0.056514 |                                            0.101424 |
|        10 | 13:13:20.7 |     10.000 |                                     0.044984 |                                     0.115505 |                                            0.053513 |                                            0.128628 |
+-----------+------------+------------+----------------------------------------------+----------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+
generator scan ['dfa177a4'] (scan num: 22)

also reproduceable in tests

yes im really not sure about this, initially we thought it was to do with chainedlivefit, carrying over parameter uncertainties between fits but its something I've seen on other ibc branches too e.g momentum scan one we're working on atm, and after making the chainedlivefit fix, it didn't change this, might be good to have a chat about it..

I get it on main - ignore it as a review comment on this PR

@rerpha rerpha merged commit 4f35fb9 into main Jul 2, 2025
13 checks passed
@rerpha rerpha deleted the Ticket_125 branch July 2, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bluesky-Semver-Minor New functionality / back-compatible changes size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants