Skip to content

Instantly share code, notes, and snippets.

def configure_pe1c(exp):
try:
from bluesky.plans import abs_set
except ImportError:
from bluesky.plan_stubs import abs_set
acq_time = pe1c.cam.acquire_time.get()
num_frame = np.ceil(exp/acq_time)
computed_exp = num_frame * acq_time
yield from abs_set(pe1c.images_per_set, num_frame, wait=True)
print("INFO: requested exposure time = {} - > computed exposure time"
@chiahaoliu
chiahaoliu / xpdacq_revisit.py
Created May 26, 2017 15:30
rethink about xpdacq
# whaht xpdacq has:
# dark frame:
# 1. dark frame before scan
# 2. update global dark frame information
# 3. inject associated dark frame information to each run
# tiff save (exporter):
# 1. read md from header to pull associated dark frame
# 2. dark subtraction
# 3. filename template
# device configuration :
import os
import yaml
import numpy as np
import pandas as pd
import tifffile as tif
# same engine as xpdan
from xpdan.glbl import an_glbl
from xpdan.data_reduction import xpd_data_proc
w_dir = os.path.join(an_glbl.home, 'tiff_base')
@chiahaoliu
chiahaoliu / pyFAI_integrate.py
Created March 23, 2017 16:30
pure pyFAI integration
"""example to do pure pyFAI integration"""
import os
import tifffile as tif
from pyFAI.azimuthalIntegrator import AzimuthalIntegrator
def pyFAI_integrate(data_dir, poni_fp, npt=1450, mask=None):
"""helper function to integrate a series of images inside data_dir with geometry and mask provided
Parameters
@chiahaoliu
chiahaoliu / advanced_cryostat.py
Last active March 23, 2017 02:32
170322_Ben_support: cryostat with expo changes
import os
import numpy as np
from itertools import product
from xpdacq.beamtime import _configure_area_det
import bluesky.plans as bp
from bluesky.plans import (scan, subs_wrapper, abs_set, count, list_scan,
adaptive_scan, reset_positions_wrapper)
from bluesky.callbacks import LiveTable, LivePlot
import os
import numpy as np
from itertools import product
from xpdacq.beamtime import _configure_area_det
import bluesky.plans as bp
from bluesky.plans import (scan, subs_wrapper, abs_set, count, list_scan,
adaptive_scan, reset_positions_wrapper)
from bluesky.callbacks import LiveTable, LivePlot
@chiahaoliu
chiahaoliu / GasPlan.py
Last active March 9, 2017 19:23
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
@chiahaoliu
chiahaoliu / quick_guide.py
Last active March 9, 2017 18:44
170307_Sanjit_support
import bluesky.plans as bp
from xpdacq.beamtime import _configure_area_det
## set up tiff name
xpd_data_proc.data_fields.append(('gas_current_gas', ''))
## switch gas
gas.set('He') # switch to 'He', available entries are defined by gas.gas_list. E.g. gas.gas_list= ['He', 'O2']
## configure the exposure time first
# you have two options:
# assume you are using diff_x for x-motor and diff_y for y-motor.
# CHECK with wh_pos() !!! (but I think it is)
import bluesky.plans as bp
from cycler import cycler
# option1 : continuous trajactory with sneak pattern. scan diff_x from 1 to 3 with 3 stepes, same for diff_y
# change the argument as needed
# every time we exit out from ipython, we need to configure devices
# in this example, we move sample_stage_2 in x direction (ss_stg2_x)
xpd_configuration['temp_controller'] = cryostat
xpd_configuration['stat_motor'] = ss_stg2_x
# scanplan : 1s expo, from 300k to 303k with 1k step
# sample_ind <1> at motor position 1.55
# sample_ind <3> at motor position 2.55
# sample_ind <7> at motor position 3.55
ScanPlan(bt, statTramp, 1, 300, 303, 1, {1:1.55, 3:2.55, 7:3.55})