Skip to content
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

error when using LiveTiffExporter #1

Open
ykchenwiegart opened this issue Jun 16, 2017 · 0 comments
Open

error when using LiveTiffExporter #1

ykchenwiegart opened this issue Jun 16, 2017 · 0 comments

Comments

@ykchenwiegart
Copy link

We implemented LiveTiffExporter in 91-userscans.py, but it has problem related to 'db'.
It's unclear why db is None in the broker.py name space.

error trace-back:

In [7]: RE(xrfmap(xstart=49.0, xnumstep=3, xstepsize=0.1, ystart=51.0, ynumstep=3, ystepsize=0.1, rois=[sclr.channels.chan5.name]))
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-92b9228ecf29> in <module>()
----> 1 RE(xrfmap(xstart=49.0, xnumstep=3, xstepsize=0.1, ystart=51.0, ynumstep=3, ystepsize=0.1, rois=[sclr.channels.chan5.name]))

/opt/conda_envs/collection-17Q2.0/lib/python3.6/site-packages/bluesky/run_engine.py in __call__(self, plan, subs, raise_if_interrupted, **metadata_kw)
    597                     # it (unless it is a canceled error)
    598                     if exc is not None:
--> 599                         raise exc
    600 
    601             if raise_if_interrupted and self._interrupted:

/opt/conda_envs/collection-17Q2.0/lib/python3.6/site-packages/bluesky/run_engine.py in _run(self)
   1021             self.log.error("Run aborted")
   1022             self.log.error("%r", err)
-> 1023             raise err
   1024         finally:
   1025             # Some done_callbacks may still be alive in other threads.

/opt/conda_envs/collection-17Q2.0/lib/python3.6/site-packages/bluesky/run_engine.py in _run(self)
    919                         resp = self._response_stack.pop()
    920                         try:
--> 921                             msg = self._plan_stack[-1].send(resp)
    922                         # We have exhausted the top generator
    923                         except StopIteration:

/home/xf08bm/.ipython/profile_collection/startup/91-userscans.py in xrfmap(xstart, xnumstep, xstepsize, ystart, ynumstep, ystepsize, rois)
     39         #setup LiveOutput
     40         xrfmapOutputTiffTemplate = xrfmapTiffOutputDir+"xrfmap_scan{start[scan_id]}" +roi+ ".tiff"
---> 41         xrfmapTiffexporter = LiveTiffExporter(roi, xrfmapOutputTiffTemplate)
     42         callbackToken = RE.subscribe('all', post_run(xrfmapTiffexporter))#check to see if this is the right way to have RE here...
     43         callbackTokenList.append(callbackToken)

/opt/conda_envs/collection-17Q2.0/lib/python3.6/site-packages/bluesky/callbacks/broker.py in __init__(self, field, template, dryrun, overwrite, db)
    208 
    209         if db is None:
--> 210             from databroker import DataBroker as db
    211 
    212         self.db = db

ImportError: cannot import name 'DataBroker'

91-userscnas code:

from bluesky.callbacks.broker import LiveTiffExporter

testevents = list(db.get_events(db[-1]))

xrfmapTiffOutputDir = '/home/xf08bm/DATA2017/Comissioning/20170616/'
#hard-coded for testing now; need to be set to automatically use SAF, today's date, etc.

def xrfmap(*, xstart, xnumstep, xstepsize,
            ystart, ynumstep, ystepsize,
            rois = []
            #shutter = True, align = False,
            #acqtime, numrois=1, i0map_show=True, itmap_show=False, record_cryo = False,
            #setenergy=None, u_detune=None, echange_waittime=10
            ):

    '''
    input:
         xstart, xnumstep, xstepsize (float)
         ystart, ynumstep, ystepsize (float)

    '''

    #define detector used for xrf mapping functions
    xrfdet = [sclr] #currently only the scalar; to-do: save full spectra

    xstop = xstart + xnumstep*xstepsize
    ystop = ystart + ynumstep*ystepsize

    #setup live callbacks:

    livetableitem = [xy_stage.x, xy_stage.y]
    livecallbacks = []
    callbackTokenList = []

    for roi in rois:
        livecallbacks.append(LiveGrid((ynumstep+1, xnumstep+1), roi, xlabel = 'x (mm)', ylabel = 'y (mm)', extent=[xstart, xstop, ystart, ystop]))
        livetableitem.append(roi)

        #setup LiveOutput
        xrfmapOutputTiffTemplate = xrfmapTiffOutputDir+"xrfmap_scan{start[scan_id]}" +roi+ ".tiff"
        xrfmapTiffexporter = LiveTiffExporter(roi, xrfmapOutputTiffTemplate)
        callbackToken = RE.subscribe('all', post_run(xrfmapTiffexporter))#check to see if this is the right way to have RE here...
        callbackTokenList.append(callbackToken)

    livecallbacks.append(LiveTable(livetableitem))

    xrfmap_scanplan = outer_product_scan(xrfdet, xy_stage.y, ystart, ystop, ynumstep+1, xy_stage.x, xstart, xstop, xnumstep+1, False)
    xrfmap_scanplan = bp.subs_wrapper(xrfmap_scanplan, livecallbacks)

    scaninfo = yield from xrfmap_scanplan

    for callbackToken in callbackTokenList:
        RE.unsubscribe(callbackToken)

    return xrfmap_scanplan
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

No branches or pull requests

1 participant