NSLS-II-CSX / profile_collection

BSD 3-Clause "New" or "Revised" License
0 stars 5 forks source link

mv(fccd.exposure()) doesn't finish "really" before next function is started #17

Closed ambarb closed 4 years ago

ambarb commented 5 years ago

@stuwilkins @tacaswell @danielballan @mrakitin @awalter-bnl I am not sure if the bug is with mv(fccd.exposure()) or with ct_dark_all. Both are defined in the profile.

Basically, I had to add a sleep so that the number of images where changed in time before the next function read what the number of images was before changing and then resetting.

def O_Kedge_25K():
    num_lights = 900#14400
    num_darks =20#100

    yield from mv(fccd.exposure,(0.1, 1, num_lights))
    yield from bps.sleep(2)        ###################  ADDED THIS LINE TO FIX BEHAVIOR  #####
    yield from ct_dark_all(num_darks)
    print('First lights with .1s exposure')
    yield from count([fccd],md={'purpose':'XPCS O K same exp time'})

Bad behavior

I wanted 900 images with count() and only got 20

In [287]: RE(O_Kedge_25K())                                                                                                                                         

Starting procedure to acquire darks 9.3Hz or 0.108s.

    Current number of images = 900.

    Setting to 20 images.

Gain bit set to 0 for a gain value of auto

Transient Scan ID: 120117     Time: 2019-06-27 23:39:47
Persistent Unique Scan ID: 'b1677387-5372-4d82-b483-6f4746401dfe'
New stream: 'baseline'
New stream: 'primary'                                                                                                                                               
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|   seq_num |       time | fccd_stats1_total | fccd_stats2_total | fccd_stats3_total | fccd_stats4_total | fccd_stats5_total |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|         1 | 23:40:11.0 |             -1133 |           -122723 |              -567 |           -308869 |          -1519351 |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
generator count ['b1677387'] (scan num: 120117)

Gain bit set to 1 for a gain value of x2

Transient Scan ID: 120118     Time: 2019-06-27 23:40:11
Persistent Unique Scan ID: 'b45229f8-4742-4d7e-8504-6e4ec30c037b'
New stream: 'baseline'
New stream: 'primary'                                                                                                                                               
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|   seq_num |       time | fccd_stats1_total | fccd_stats2_total | fccd_stats3_total | fccd_stats4_total | fccd_stats5_total |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|         1 | 23:40:35.9 |         -82821021 |       -3041218805 |         -12523402 |      -11983369898 |      -30074223585 |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
generator count ['b45229f8'] (scan num: 120118)

Gain bit set to 2 for a gain value of x1

Gain bit set to 2 for a gain value of x1

Transient Scan ID: 120119     Time: 2019-06-27 23:40:36
Persistent Unique Scan ID: '11a19b25-44fb-4cf6-8305-49a0e6565509'
New stream: 'baseline'
New stream: 'primary'                                                                                                                                               
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|   seq_num |       time | fccd_stats1_total | fccd_stats2_total | fccd_stats3_total | fccd_stats4_total | fccd_stats5_total |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|         1 | 23:41:00.7 |         -40897647 |       -1506658266 |          -6220041 |       -5937055523 |      -14935057947 |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
generator count ['11a19b25'] (scan num: 120119)

Returning to intial conditions (pre-count).
        Total images per trigger are NOW:        20                                                                                                                 
    FCCD FCRIC gain value is NOW:        auto

First lights with .1s exposure
Transient Scan ID: 120120     Time: 2019-06-27 23:41:03
Persistent Unique Scan ID: '3b22c776-e9ba-4c1f-9907-96b30b12969d'
New stream: 'baseline'
New stream: 'primary'                                                                                                                                               
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|   seq_num |       time | fccd_stats1_total | fccd_stats2_total | fccd_stats3_total | fccd_stats4_total | fccd_stats5_total |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|         1 | 23:41:27.7 |              1681 |             90179 |              -444 |           2495839 |           2590413 |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
generator count ['3b22c776'] (scan num: 120120)
Out[287]: 
('b1677387-5372-4d82-b483-6f4746401dfe',
 'b45229f8-4742-4d7e-8504-6e4ec30c037b',
 '11a19b25-44fb-4cf6-8305-49a0e6565509',
 '3b22c776-e9ba-4c1f-9907-96b30b12969d')

Excerpt from appropriate behavior after darks are collected

Gain bit set to 2 for a gain value of x1

Transient Scan ID: 120123     Time: 2019-06-27 23:44:45
Persistent Unique Scan ID: 'a031f6be-510b-4955-ba85-db486e293045'
New stream: 'baseline'
New stream: 'primary'                                                                                                                                               
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|   seq_num |       time | fccd_stats1_total | fccd_stats2_total | fccd_stats3_total | fccd_stats4_total | fccd_stats5_total |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
|         1 | 23:45:10.0 |         -40896549 |       -1506623794 |          -6219825 |       -5936917403 |      -14934642767 |
+-----------+------------+-------------------+-------------------+-------------------+-------------------+-------------------+
generator count ['a031f6be'] (scan num: 120123)

Returning to intial conditions (pre-count).
        Total images per trigger are NOW:        900                                                                                                                
    FCCD FCRIC gain value is NOW:        auto

First lights with .1s exposure
Transient Scan ID: 120124     Time: 2019-06-27 23:45:12
Persistent Unique Scan ID: '3b377bf7-9473-4ceb-8515-3e0a7e5a7874'
New stream: 'baseline'
danielballan commented 5 years ago

@ambarb See proposed fix in https://github.com/NSLS-II-CSX/xf23id1_profiles/pull/19

ambarb commented 5 years ago

OK. Looks like this might also help with abort and the camera not returning to the acquire state?

I can test. Let me know when it is ready..... do I git pull after making sure there is nothing out of sync with the current profile

ambarb commented 4 years ago

@danielballan @mrakitin @jklynch i meant that this is the change from yesterday that we should try to merge and test from https://github.com/danielballan/xf23id1_profiles/commit/87001ee3f7b573b95f24694d23200d92763e8021 . I think it will address this issue.