Skip to content

Instantly share code, notes, and snippets.

@chiahaoliu
Last active March 9, 2017 19:23
Show Gist options
  • Select an option

  • Save chiahaoliu/9331c70d3f6bbb4df6d58e1fc8aeba9a to your computer and use it in GitHub Desktop.

Select an option

Save chiahaoliu/9331c70d3f6bbb4df6d58e1fc8aeba9a to your computer and use it in GitHub Desktop.
plan guide
import bluesky.plans as bp
from xpdacq.beamtime import _configure_area_det
import os
import numpy as np
import itertools
from bluesky.plans import (scan, subs_wrapper, abs_set, count, list_scan,
adaptive_scan, reset_positions_wrapper)
from bluesky.callbacks import LiveTable, LivePlot
from bluesky.plan_tools import print_summary
def Gas_Plan(gas_in = 'He', liveplot_key=None, totExpTime = 5, num_exp = 1, delay = 1, sample_num = 0):
"""
Example
-------
Set the gasses. They can be in any other, nothing to do with
the order they are used in the plan. But, should match the connections on switch.
>>> gas.gas_list = ['He', 'N2', 'CO2']
Parameters
----------
gas_in : string
e.g., 'He', default is 'He'
These gas must be in `gas.gas_list` but they may be in any order.
liveplot_key : str, optional
data key for LivePlot. default is None, which means no LivePlot
totExpTime : float
total exposure time per frame in seconds. Dafault value is 5 sec
num_exp : int
number of images/exposure, default is 1
delay: float
delay time between exposures in sec
Execute it
----------
gas_plan = Gas_Plan(gas_in = 'He', totExpTime = 5, num_exp = 1, delay = 1, sample_num = 0)
>>> xurn(<sample_num>, gas_plan)
"""
## switch gas
yield from abs_set(gas, gas_in)
#gas.set(gas_in) # switch to asked gas, default is 'He'
## configure the exposure time first
_configure_area_det(totExpTime) # 5 secs exposuretime
## ScanPlan you need
#Reference: http://nsls-ii.github.io/bluesky/bluesky.plans.count.html#bluesky.plans.count
#plan = bp.count([pe1c, rga, gas.current_gas], num=3, delay=5)
plan = bp.count([pe1c, gas.current_gas, rga], num=num_exp, delay= delay)
#plan = bp.subs_wrapper(plan, LiveTable([xpd_configuration['area_det'], rga])) # give you LiveTable
plan = bp.subs_wrapper(plan, LiveTable([xpd_configuration['area_det'], gas.current_gas, rga])) # LiveTable
if liveplot_key and isinstance(liveplot_key, str):
plan = bp.subs_wrapper(plan, LivePlot(liveplot_key))
yield from plan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment