-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: chxtools package update for 2.0.x #16
Changes from all commits
cdcdacb
8acbbc1
1a99e3c
9d3c1ec
ecf2131
eb2e599
bef1cc1
91dc6ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
by LW 03/20/2015 | ||
some wrapper functions for ophyd | ||
""" | ||
import Tkinter, tkFileDialog | ||
from __future__ import print_function | ||
|
||
|
||
def det_select(det): | ||
""" | ||
|
@@ -16,19 +17,19 @@ def det_select(det): | |
calling sequence: det_select(det) | ||
""" | ||
try: | ||
rm_det=ascan.user_detectors[0].name | ||
ascan.user_detectors.remove(session_mgr[rm_det]) | ||
rm_det=ascan.user_detectors[0].name | ||
ascan.user_detectors.remove(session_mgr[rm_det]) | ||
ascan.default_triggers = [] | ||
ascan.default_detectors = [] | ||
print 'removed previous default detector: ',rm_det | ||
except: print 'list of detectors appeared to be empty...' | ||
|
||
print('removed previous default detector: {}'.format(rm_det)) | ||
except: | ||
print('list of detectors appeared to be empty...') | ||
|
||
ascan.user_detectors.append(det) # add detector | ||
new_def_det=ascan.user_detectors[0].name | ||
|
||
print '' | ||
print 'new default detector: ',new_def_det | ||
|
||
new_def_det=ascan.user_detectors[0].name | ||
|
||
print('\nnew default detector: {}'.format(new_def_det)) | ||
|
||
|
||
def cw_ascan(mot,xmin,xmax,npoints,acqt='default',pos_ret=True): | ||
""" | ||
|
@@ -43,30 +44,32 @@ def cw_ascan(mot,xmin,xmax,npoints,acqt='default',pos_ret=True): | |
WILL NOT WORK FOR A LIST OF DETECTORS! | ||
""" | ||
# gather beamline information prior to starting the scan: | ||
ini_motpos=caget(mot.record+'.RBV') | ||
ini_motpos = caget(mot.record+'.RBV') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# current detector: | ||
acq_pv=session_mgr[ascan.user_detectors[0].name].pvname | ||
acq_pv = session_mgr[ascan.user_detectors[0].name].pvname | ||
|
||
# set different exposure time for the scan, if requested: | ||
if acqt!='default': | ||
if acqt != 'default': | ||
try: | ||
ini_expt=caget(acq_pv[2]) # initial exposure time | ||
ini_expt = caget(acq_pv[2]) # initial exposure time | ||
session_mgr[ascan.user_detectors[0].name].acquire_time = acqt | ||
print 'successfully set exposure time to [s]: ',acqt | ||
except: print 'could not set exposure time to ',acqt | ||
|
||
print('successfully set exposure time to [s]: {}'.format(acqt)) | ||
except: | ||
print('could not set exposure time to {}'.format(acqt)) | ||
|
||
# execute the scan | ||
ascan(mot,xmin,xmax,npoints) | ||
|
||
# put beamline back into initial state | ||
if pos_ret==True: | ||
if pos_ret is True: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
caput(mot.record+'.VAL',ini_motpos) | ||
print 'returned axes to: ',ini_motpos | ||
if acqt!='default': | ||
print('returned axes to: {}'.format(ini_motpos)) | ||
if acqt != 'default': | ||
try: | ||
session_mgr[ascan.user_detectors[0].name].acquire_time = ini_expt | ||
print 'successfully reset exposure time to [s]: ',ini_expt | ||
except: print 'could not reset exposure time to ',ini_expt | ||
print('successfully reset exposure time to [s]: {}'.format(ini_expt)) | ||
except: | ||
print('could not reset exposure time to {}'.format(ini_expt)) | ||
|
||
def cw_dscan(mot,mdx,pdx,npoints,acqt='default',pos_ret=True): | ||
""" | ||
|
@@ -78,25 +81,27 @@ def cw_dscan(mot,mdx,pdx,npoints,acqt='default',pos_ret=True): | |
WILL NOT WORK FOR A LIST OF DETECTORS! | ||
""" | ||
# current detector: | ||
acq_pv=session_mgr[ascan.user_detectors[0].name].pvname | ||
acq_pv = session_mgr[ascan.user_detectors[0].name].pvname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# set different exposure time for the scan, if requested: | ||
if acqt!='default': | ||
if acqt != 'default': | ||
try: | ||
ini_expt=caget(acq_pv[2]) # initial exposure time | ||
session_mgr[ascan.user_detectors[0].name].acquire_time = acqt | ||
print 'successfully set exposure time to [s]: ',acqt | ||
except: print 'could not set exposure time to ',acqt | ||
|
||
print('successfully set exposure time to [s]: {}'.format(acqt)) | ||
except: | ||
print('could not set exposure time to {}'.format(acqt)) | ||
|
||
# execute the scan | ||
dscan(mot,mdx,pdx,npoints) | ||
#print 'finished scan' | ||
if acqt!='default': | ||
#print('finished scan') | ||
|
||
if acqt != 'default': | ||
try: | ||
session_mgr[ascan.user_detectors[0].name].acquire_time = ini_expt | ||
print 'successfully reset exposure time to [s]: ',ini_expt | ||
except: print 'could not reset exposure time to ',ini_expt | ||
print('successfully reset exposure time to [s]: {}'.format(ini_expt)) | ||
except: | ||
print('could not reset exposure time to {}'.format(ini_expt)) | ||
|
||
def cw_CCDseries(folder,filename,detector,imnum='default',startn=1,acqt='default',acqperiod='default'): | ||
""" | ||
|
@@ -118,7 +123,7 @@ def cw_CCDseries(folder,filename,detector,imnum='default',startn=1,acqt='default | |
# get the detector name:: | ||
detector.pvname.split('}')[0]+'}' | ||
#get folder interactively: | ||
|
||
if folder == 'ia': | ||
root=Tkinter.Tk() | ||
root.withdraw() | ||
|
@@ -127,116 +132,125 @@ def cw_CCDseries(folder,filename,detector,imnum='default',startn=1,acqt='default | |
# check whether target directory exists and create it, if it doesn't | ||
if not os.path.exists(folder): | ||
os.mkdir(folder) | ||
os.chmod(folder,436) #make sure everybody can read an write | ||
os.chmod(folder,436) #make sure everybody can read an write | ||
os.chmod(folder,stat.S_IRWXO) | ||
print 'successfully created new directory: ',folder | ||
|
||
|
||
print('successfully created new directory: {}'.format(folder)) | ||
|
||
# put folder: | ||
r=caput(detector.pvname.split('}')[0]+'}TIFF1:FilePath', folder) # have some problem with syntax here... | ||
if r==1: | ||
print 'changed saving directory to: ',folder | ||
else: print 'error: could not change directory for saving data files.' | ||
if r == 1: | ||
print('changed saving directory to: {}'.format(folder)) | ||
else: | ||
print('error: could not change directory for saving data files.') | ||
# put the filename: | ||
r=caput(detector.pvname.split('}')[0]+'}TIFF1:FileName', filename) # have some problem with syntax here... | ||
if r==1: | ||
print 'filename for saving: ',filename | ||
else: print 'error: could not change file name for saving.' | ||
if r == 1: | ||
print('filename for saving: {}'.format(filename)) | ||
else: | ||
print('error: could not change file name for saving.') | ||
|
||
|
||
# put start number | ||
caput(detector.pvname.split('}')[0]+'}TIFF1:FileNumber',startn) | ||
|
||
#gather information about current camera settings | ||
acq_pv=session_mgr[ascan.user_detectors[0].name].pvname | ||
ini_acq=caget(acq_pv.split('}')[0]+'}cam1:Acquire') # initial state: started or stopped | ||
ini_mode=caget(acq_pv.split('}')[0]+'}cam1:ImageMode') # initial image mode: single [0], multiple [1], continous [2] | ||
ini_expt=caget(acq_pv.split('}')[0]+'}cam1:AcquireTime') # initial exposure time | ||
ini_acqperiod=caget(acq_pv.split('}')[0]+'}cam1:AcquirePeriod') # initial acquiring period | ||
ini_imnum=caget(acq_pv.split('}')[0]+'}cam1:NumImages') # initial image number | ||
if acqt!='default': | ||
acq_pv = session_mgr[ascan.user_detectors[0].name].pvname | ||
ini_acq = caget(acq_pv.split('}')[0]+'}cam1:Acquire') # initial state: started or stopped | ||
ini_mode = caget(acq_pv.split('}')[0]+'}cam1:ImageMode') # initial image mode: single [0], multiple [1], continous [2] | ||
ini_expt = caget(acq_pv.split('}')[0]+'}cam1:AcquireTime') # initial exposure time | ||
ini_acqperiod = caget(acq_pv.split('}')[0]+'}cam1:AcquirePeriod') # initial acquiring period | ||
ini_imnum = caget(acq_pv.split('}')[0]+'}cam1:NumImages') # initial image number | ||
|
||
if acqt != 'default': | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:AcquireTime',acqt) | ||
print 'successfully set exposure time to [s]: ',acqt | ||
except: print 'could not set exposure time to ',acqt | ||
print('successfully set exposure time to [s]: {}'.format(acqt)) | ||
except: | ||
print('could not set exposure time to {}'.format(acqt)) | ||
# stop camara: | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',0) | ||
print 'successfully stopped camera' | ||
except: print 'could not stop camera' | ||
print('successfully stopped camera') | ||
except: | ||
print('could not stop camera') | ||
# try to set image mode to multiple | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:ImageMode',1) | ||
print 'successfully set ImageMode to "multiple"' | ||
except: print 'could not set ImageMode to "multiple"' | ||
if acqperiod!='default': | ||
try: | ||
print('successfully set ImageMode to "multiple"') | ||
except: | ||
print('could not set ImageMode to "multiple"') | ||
if acqperiod != 'default': | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:AcquirePeriod',acqperiod) | ||
print 'successfully set acquiering period to: ',acqperiod | ||
except: print 'could not set aquireing period to ',acqperiod | ||
print('successfully set acquiering period to: {}'.format(acqperiod)) | ||
except: | ||
print('could not set aquireing period to {}'.format(acqperiod)) | ||
|
||
# set number of images to be taken: | ||
if imnum!='default': | ||
if imnum != 'default': | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:NumImages',imnum) | ||
print 'successfully set number of images to: ',imnum | ||
except: print 'could not set number of images to ',imnum | ||
print 'going to start the acquisition...' | ||
caput(acq_pv.split('}')[0]+'}cam1:NumImages', imnum) | ||
print('successfully set number of images to: {}'.format(imnum)) | ||
except: | ||
print('could not set number of images to {}'.format(imnum)) | ||
print('going to start the acquisition...') | ||
time.sleep(1) | ||
# start the acquisition!!! | ||
caput(acq_pv.split('}')[0]+'}cam1:ArrayCounter',0)#set Images acquired (image counter) to 0 | ||
caput(detector.pvname.split('}')[0]+'}TIFF1:AutoSave',1) # start auto save | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',1) # start series acquisition | ||
caput(acq_pv.split('}')[0]+'}cam1:ArrayCounter',0) # set Images acquired (image counter) to 0 | ||
|
||
caput(detector.pvname.split('}')[0]+'}TIFF1:AutoSave',1) # start auto save | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',1) # start series acquisition | ||
|
||
counting=0 | ||
current_file=caget(detector.pvname.split('}')[0]+'}TIFF1:FullFileName_RBV',as_string=True) | ||
while counting==0: | ||
time.sleep(.5) | ||
if caget(acq_pv.split('}')[0]+'}cam1:ArrayCounter_RBV')==imnum: counting=1 | ||
if caget(detector.pvname.split('}')[0]+'}TIFF1:FullFileName_RBV',as_string=True)!=current_file: | ||
current_file=caget(detector.pvname.split('}')[0]+'}TIFF1:FullFileName_RBV',as_string=True) | ||
print 'file written: ',current_file | ||
time.sleep(.1) | ||
|
||
print 'going to stop the acquisition...' | ||
time.sleep(.5) | ||
if caget(acq_pv.split('}')[0]+'}cam1:ArrayCounter_RBV') == imnum: | ||
counting=1 | ||
if caget(detector.pvname.split('}')[0]+'}TIFF1:FullFileName_RBV',as_string=True) != current_file: | ||
current_file=caget(detector.pvname.split('}')[0]+'}TIFF1:FullFileName_RBV',as_string=True) | ||
print('file written: {}'.format(current_file)) | ||
time.sleep(.1) | ||
|
||
print('going to stop the acquisition...') | ||
time.sleep(.5) | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',0) # stop series acquisition (redundent...should have stopped already | ||
caput(detector.pvname.split('}')[0]+'}TIFF1:AutoSave',0) # stop auto save | ||
print 'going to reset camera...' | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',0) # stop series acquisition (redundent...should have stopped already | ||
caput(detector.pvname.split('}')[0]+'}TIFF1:AutoSave',0) # stop auto save | ||
|
||
print('going to reset camera...') | ||
#time.sleep(5) | ||
# put camera back into initial state: | ||
if acqt!='default': | ||
if acqt != 'default': | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:AcquireTime',ini_expt) | ||
print 'successfully reset exposure time to [s]: ',ini_expt | ||
except: print 'could not reset exposure time to ',ini_expt | ||
print('successfully reset exposure time to [s]: {}'.format(ini_expt)) | ||
except: | ||
print('could not reset exposure time to {}'.format(ini_expt)) | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:ImageMode',ini_mode) | ||
print 'successfully reset ImageMode' | ||
except: print 'could not reset ImageMode' | ||
caput(acq_pv.split('}')[0]+'}cam1:ImageMode', ini_mode) | ||
print('successfully reset ImageMode') | ||
except: | ||
print('could not reset ImageMode') | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',ini_acq) | ||
print 'successfully reset camera acqusition mode' | ||
except: print 'could not reset camera acquisition mode' | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire', ini_acq) | ||
print('successfully reset camera acqusition mode') | ||
except: | ||
print('could not reset camera acquisition mode') | ||
if acqperiod!='default': | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:AcquirePeriod',ini_acqperiod) | ||
print 'successfully reset acquisition period to [s]: ',ini_acqperiod | ||
except: print 'could not reset acquisition period to ',ini_acqperiod | ||
caput(acq_pv.split('}')[0]+'}cam1:AcquirePeriod', ini_acqperiod) | ||
print('successfully reset acquisition period to [s]: {}'.format(ini_acqperiod)) | ||
except: | ||
print('could not reset acquisition period to {}'.format(ini_acqperiod)) | ||
if imnum!='default': | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:NumImages',ini_imnum) | ||
print 'successfully reset image numbers to: ',ini_imnum | ||
except: print 'could not reset image numbers to ',ini_imnum | ||
caput(acq_pv.split('}')[0]+'}cam1:NumImages', ini_imnum) | ||
print('successfully reset image numbers to: {}'.format(ini_imnum)) | ||
except: | ||
print('could not reset image numbers to {}'.format(ini_imnum)) | ||
time.sleep(.5) | ||
try: | ||
caput(acq_pv.split('}')[0]+'}cam1:Acquire',ini_acq) # restart camera if it was running before taking the series | ||
print 'restarted camera' | ||
except: print 'could not restart camera...' | ||
|
||
|
||
|
||
|
||
|
||
caput(acq_pv.split('}')[0]+'}cam1:Acquire', ini_acq) # restart camera if it was running before taking the series | ||
print('restarted camera') | ||
except: | ||
print('could not restart camera...') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import numpy as np | ||
import h5py | ||
from pims import FramesSequence, Frame | ||
from databroker import db | ||
from databroker import Broker | ||
from .handlers import LazyEigerHandler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eventually, should be But let's keep it as is for now. There are some things I need to check back with Yugang on. Just to summarize what needs to be fixed with this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
class EigerImages2(FramesSequence): | ||
|
@@ -96,8 +97,11 @@ def __call__(self, seq_id): | |
# TODO Return a multi-dimensional PIMS seq. | ||
return EigerImages2(master_path, self._images_per_file, md=md) | ||
|
||
db.fs.deregister_handler('AD_EIGER') | ||
db.fs.deregister_handler('AD_EIGER2') | ||
db = Broker.named('chx') | ||
|
||
db.reg.deregister_handler('AD_EIGER') | ||
db.reg.deregister_handler('AD_EIGER2') | ||
|
||
db.reg.register_handler('AD_EIGER2', EigerHandler2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could remove the previous two lines and add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blessed! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
db.reg.register_handler('AD_EIGER', LazyEigerHandler) | ||
|
||
db.fs.register_handler('AD_EIGER2', EigerHandler2) | ||
db.fs.register_handler('AD_EIGER', LazyEigerHandler) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ | |
import numpy as np | ||
import time | ||
|
||
from skxray.core import roi | ||
from skxray.core.utils import bin_edges_to_centers, geometric_series | ||
from skbeam.core import roi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for some history: |
||
from skbeam.core.utils import bin_edges_to_centers, geometric_series | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
atom | ||
cython | ||
databroker | ||
enaml | ||
fabio | ||
h5py | ||
matplotlib | ||
numpy | ||
ophyd | ||
pandas | ||
pims | ||
pyepics | ||
scikit-beam | ||
scipy | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using very old ophyd API that definitely no longer works. It took me a minute to even remember
.user_detectors
; I think it goes back to the days when the RunEngine was part of ophyd and there was no such thing as plans. @mrakitin Can you open an issue to revisit this function?