BCDA-APS / bluesky_training

Bluesky training, including instrument package
https://bcda-aps.github.io/bluesky_training/
Other
11 stars 0 forks source link

HOWTO lineup #109

Open prjemian opened 1 year ago

prjemian commented 1 year ago

The Lineup a 1-D peak howto uses a custom two_pass_scan plan, then another custom findpeak_multipass plan.

Could this howto start with apstools.plans.lineup instead? (Seems very similar in objective.) The lineup plan was developed later, as a transition aid for SPEC users accustomed to the lup macro. The apstools package has its own HOWTO for the lineup plan.

prjemian commented 1 year ago

These two could be combined. In apstools.

plan difference
bluesky_training.bluesky.instrument.lup one pass
prints pysumreg statistics as dict
apstools.plans.lineup two passes
acceptance criteria as kwargs
no print of stats

BUT, the lup plan here is a demonstration of a local custom plan for the instrument. The peak statistics data is a value-added feature.

prjemian commented 1 year ago

The stats could be rendered in a table with columns for the (few) runs and rows for each statistical measure.

prjemian commented 7 months ago

Re-focus on apstools.plans.lineup2(), which works with the bluesky queueserver.

prjemian commented 6 months ago

Here's different plots from a recent 3-pass lineup2 scan. Note the time interval between successive runs is for the m1 motor to reposition for the next pass.

m1 v t

lineup2-example-1-m1-v-t

noisy v t

lineup2-example-2-noisy-v-t

noisy v m1

lineup2-example-3-noisy-v-m1

prjemian commented 3 months ago

Quick example

... from IPython console session:

In [7]: RE(lineup2(noisy, m1, -4, 4, 11, nscans=3, md=dict(title="demo lineup2()")))

Transient Scan ID: 115     Time: 2024-06-19 09:29:04
Persistent Unique Scan ID: 'bc25eab6-f435-4a1b-a25e-f733c130f29d'
New stream: 'label_start_motor'
New stream: 'primary'
+-----------+------------+------------+------------+
|   seq_num |       time |         m1 |      noisy |
+-----------+------------+------------+------------+
|         1 | 09:29:09.0 |    -3.0904 |   25.98132 |
|         2 | 09:29:10.3 |    -2.2904 |   42.21911 |
|         3 | 09:29:11.4 |    -1.4904 |   81.64758 |
|         4 | 09:29:12.5 |    -0.6904 |  204.34496 |
|         5 | 09:29:13.6 |     0.1096 | 1092.58111 |
|         6 | 09:29:14.7 |     0.9096 | 7549.78998 |
|         7 | 09:29:15.8 |     1.7096 |  376.92240 |
|         8 | 09:29:16.9 |     2.5096 |  112.89359 |
|         9 | 09:29:18.0 |     3.3096 |   54.58870 |
|        10 | 09:29:19.1 |     4.1096 |   34.08016 |
|        11 | 09:29:20.2 |     4.9096 |   22.33861 |
Motor: m1
========== ==================
statistic  noisy             
========== ==================
n          11                
centroid   0.8237310041584432
sigma      0.6472728236075987
x_at_max_y 0.90963           
max_y      7549.789982466793 
min_y      22.338609615249936
mean_y     872.4897763435542 
stddev_y   2236.733696611285 
========== ==================

+-----------+------------+------------+------------+
generator rel_scan ['bc25eab6'] (scan num: 115)

Transient Scan ID: 116     Time: 2024-06-19 09:29:24
Persistent Unique Scan ID: '387409ab-dc22-4d61-bdc6-7baece51bcb4'
New stream: 'label_start_motor'
New stream: 'primary'
+-----------+------------+------------+------------+
|   seq_num |       time |         m1 |      noisy |
+-----------+------------+------------+------------+
|         1 | 09:29:26.7 |    -0.7005 |  193.34469 |
|         2 | 09:29:27.3 |    -0.3956 |  329.31970 |
|         3 | 09:29:27.9 |    -0.0908 |  613.84696 |
|         4 | 09:29:28.5 |     0.2141 | 1645.08933 |
|         5 | 09:29:29.1 |     0.5189 | 11140.32421 |
|         6 | 09:29:29.7 |     0.8237 | 18849.63359 |
|         7 | 09:29:30.3 |     1.1286 | 1975.20802 |
|         8 | 09:29:30.9 |     1.4334 |  716.60402 |
|         9 | 09:29:31.5 |     1.7383 |  356.30054 |
|        10 | 09:29:32.1 |     2.0431 |  210.59486 |
|        11 | 09:29:32.7 |     2.3479 |  139.43093 |
Motor: m1
========== ===================
statistic  noisy              
========== ===================
n          11                 
centroid   0.718048929641832  
sigma      0.33585878451103834
x_at_max_y 0.8237300000000001 
max_y      18849.633586708278 
min_y      139.4309275963054  
mean_y     3288.154258754002  
stddev_y   6068.926075681249  
========== ===================

+-----------+------------+------------+------------+
generator rel_scan ['387409ab'] (scan num: 116)

Transient Scan ID: 117     Time: 2024-06-19 09:29:35
Persistent Unique Scan ID: 'a0c31ca1-892f-42c5-b680-bf7b26bf3ab8'
New stream: 'label_start_motor'
New stream: 'primary'
+-----------+------------+------------+------------+
|   seq_num |       time |         m1 |      noisy |
+-----------+------------+------------+------------+
|         1 | 09:29:36.1 |    -0.0728 |  627.62950 |
|         2 | 09:29:36.5 |     0.0853 | 1026.18044 |
|         3 | 09:29:36.9 |     0.2435 | 1818.55412 |
|         4 | 09:29:37.3 |     0.4017 | 4149.58224 |
|         5 | 09:29:37.7 |     0.5599 | 16678.71519 |
|         6 | 09:29:38.1 |     0.7181 | 80416.90301 |
|         7 | 09:29:38.5 |     0.8762 | 10680.36898 |
|         8 | 09:29:38.9 |     1.0344 | 3344.62974 |
|         9 | 09:29:39.3 |     1.1926 | 1582.72028 |
|        10 | 09:29:39.7 |     1.3508 |  871.69791 |
|        11 | 09:29:40.1 |     1.5089 |  566.20973 |
Motor: m1
========== ===================
statistic  noisy              
========== ===================
n          11                 
centroid   0.706045598180656  
sigma      0.17406872100692758
x_at_max_y 0.7180500000000001 
max_y      80416.90300899539  
min_y      566.2097286151765  
mean_y     11069.381013139486 
stddev_y   23554.256716357195 
========== ===================

+-----------+------------+------------+------------+
generator rel_scan ['a0c31ca1'] (scan num: 117)
Out[7]: 
('bc25eab6-f435-4a1b-a25e-f733c130f29d',
 '387409ab-dc22-4d61-bdc6-7baece51bcb4',
 'a0c31ca1-892f-42c5-b680-bf7b26bf3ab8')

The plot window:

image