Skip to content

Commit

Permalink
updates on 2024_06_18
Browse files Browse the repository at this point in the history
  • Loading branch information
FXI Operator committed Jun 18, 2024
1 parent 727a839 commit b30f159
Show file tree
Hide file tree
Showing 15 changed files with 1,808 additions and 5,196 deletions.
4,823 changes: 0 additions & 4,823 deletions 1146

This file was deleted.

38 changes: 30 additions & 8 deletions startup/10-area-detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
from ophyd.areadetector.cam import AreaDetectorCam
from ophyd.areadetector.detectors import DetectorBase
from nslsii.ad33 import StatsPluginV33, CamV33Mixin
#from nslsii.ad33 import SingleTriggerV33


from nslsii.ad33 import SingleTriggerV33


from ophyd.areadetector.trigger_mixins import TriggerBase, ADTriggerStatus
from ophyd.device import Staged
from ophyd.status import SubscriptionStatus
Expand All @@ -44,7 +48,7 @@ def describe(self):
)
return res


'''
class SingleTriggerV33(TriggerBase):
_status_type = ADTriggerStatus
Expand All @@ -68,7 +72,7 @@ def acquire_complete(*args, old_value, value, **kwargs):
self.dispatch(self._image_name, ttime.time())
return status

'''
class AndorCam(CamV33Mixin, AreaDetectorCam):
def __init__(self, *args, **kwargs):
AreaDetectorCam.__init__(self, *args, **kwargs)
Expand Down Expand Up @@ -219,7 +223,7 @@ def resume(self):
self.hdf5._generate_resource(res_kwargs)
return super().resume()

@timing
#@timing
def stage(self):
import itertools
if self.cam.detector_state.get() != 0:
Expand All @@ -237,7 +241,7 @@ def stage(self):
else:
raise

@timing
#@timing
def unstage(self, *args, **kwargs):
import itertools
#self._acquisition_signal.put(0, wait=True)
Expand Down Expand Up @@ -275,9 +279,12 @@ class Manta(SingleTrigger, AreaDetector):
HDF5PluginWithFileStore,
suffix="HDF1:",
# write_path_template="/nsls2/data/fxi-new/legacy/Andor/%Y/%m/%d/",
write_path_template="/nsls2/data/fxi-new/legacy/Andor//%Y/%m/%d/",
# write_path_template = '/dev/shm/',
root="/nsls2/data/fxi-new/legacy/Andor/",
write_path_template="/nsls2/data/fxi-new/legacy/Oryx/%Y/%m/%d/",
# write_path_template='/tmp/test_2022/%Y/%m/%d/' ,
# write_path_template="/nsls2/data/fxi-new/assets/default/%Y/%m/%d/",
# write_path_template="/nsls2/data/fxi-new/legacy/Andor//%Y/%m/%d/",
# root="/nsls2/data/fxi-new/assets/default",
root="/nsls2/data/fxi-new/legacy/Oryx",
# write_path_template='/tmp/',
# root='/',
)
Expand Down Expand Up @@ -362,6 +369,9 @@ def resume(self):
getattr(Andor, k).ensure_nonblocking()
Andor.hdf5.time_stamp.name = "Andor_timestamps"

#########################################
''' comment away this section when Marana is disconnected
# added by XH
Marana = AndorKlass("XF:18IDB-ES{Det:Marana1}", name="Andor")
Marana.cam.ensure_nonblocking()
Expand All @@ -378,6 +388,8 @@ def resume(self):
getattr(Marana, k).ensure_nonblocking()
Marana.hdf5.time_stamp.name = "Andor_timestamps"
'''
#############################################
# vlm = Manta("XF:18IDB-BI{VLM:1}", name="vlm")
# detA1.read_attrs = ['hdf5', 'stats1', 'stats5']
# detA1.read_attrs = ['hdf5']
Expand All @@ -387,6 +399,16 @@ def resume(self):
# vlm.hdf5.read_attrs = []


Oryx = Manta("XF:18IDB-ES{Det:Oryx1}", name="Oryx")
#Oryx.cam.ensure_nonblocking()
Oryx.read_attrs = ["hdf5"]
#Oryx.stats1.read_attrs = ["total"]
Oryx.hdf5.read_attrs = ["time_stamp"]
Oryx.stage_sigs["cam.image_mode"] = 1
for k in ("image", ):
getattr(Oryx, k).ensure_nonblocking()
Oryx.hdf5.time_stamp.name = "Oryx_timestamps"

#for det in [detA1, Andor]:
for det in [detA1]:
det.stats1.total.kind = "hinted"
Expand Down
9 changes: 5 additions & 4 deletions startup/11-txm_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,16 @@ class BetrandLens(Device):
x = Cpt(MyEpicsMotor, "{BLens:1-Ax:X}Mtr")
#y = Cpt(MyEpicsMotor, "{BLens:1-Ax:Y}Mtr")
y = Cpt(MyEpicsMotor, "{ZP:1-Ax:Y}Mtr")
z = Cpt(MyBaseMotor, "{BLens:1-Ax:Z}Mtr")
#z = Cpt(MyBaseMotor, "{BLens:1-Ax:Z}Mtr")


class TXMSampleStage(Device):
sx = Cpt(MyEpicsMotor, "{Env:1-Ax:Xl}Mtr")
sy = Cpt(MyEpicsMotor, "{Env:1-Ax:Yl}Mtr")
sz = Cpt(MyEpicsMotor, "{Env:1-Ax:Zl}Mtr")
pi_x = Cpt(MyBaseMotor, "{TXM:1-Ax:X}Mtr")
# pi_x = Cpt(MyBaseMotor, "{TXM:1-Ax:X}Mtr")
pi_r = Cpt(MyEpicsMotor, "{TXM:2-Ax:R}Mtr")
#pi_r = Cpt(MyEpicsMotor, "{TXM:1-Ax:R}Mtr")


class DetSupport(Device):
Expand Down Expand Up @@ -243,11 +244,11 @@ class Scint(Device):
#phase_ring.z,
betr.x,
betr.y,
betr.z,
#betr.z,
zps.sx,
zps.sy,
zps.sz,
zps.pi_x,
#zps.pi_x,
zps.pi_r,
DetU.x,
DetU.y,
Expand Down
34 changes: 19 additions & 15 deletions startup/18-zebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,6 @@ def complete(self):
whether that is true, so it will obligingly stop immediately. It is
up to the caller to ensure that the motion is actually complete.
"""

print("\nin complet: complete starts")

# Our acquisition complete PV is: XF:05IDD-ES:1{Dev:Zebra1}:ARRAY_ACQ
t0 = ttime.monotonic()
while self._encoder.pc.data_in_progress.get() == 1:
Expand Down Expand Up @@ -744,10 +741,10 @@ def get_zebra_data():
self._last_bulk["timestamps"].update(
{k: v["timestamp"] for k, v in reading.items()}
)
print(
f"\nin complete: {type(self._last_bulk)=}\n{type(self._document_cache)=}\n"
)
print(f"\nin complete: {(self._last_bulk)=}\n{(self._document_cache)=}\n")
# print(
# f"\nin complete: {type(self._last_bulk)=}\n{type(self._document_cache)=}\n"
# )
# print(f"\nin complete: {(self._last_bulk)=}\n{(self._document_cache)=}\n")

return NullStatus()

Expand Down Expand Up @@ -829,7 +826,7 @@ def resume(self):
def preset_flyer(self, scn_cfg):
yield from FXITomoFlyer.bin_det(self.detectors[0], scn_cfg["bin_fac"])
yield from FXITomoFlyer.init_mot_r(scn_cfg)
yield from FXITomoFlyer.set_cam_mode(self.detectors[0], stage="pre-scan")
# yield from FXITomoFlyer.set_cam_mode(self.detectors[0], stage="pre-scan")
scn_cfg = FXITomoFlyer.cal_cam_rot_params(self.detectors[0], scn_cfg)
pc_cfg = FXITomoFlyer.cal_zebra_pc_params(scn_cfg)
yield from self.preset_zebra(pc_cfg)
Expand Down Expand Up @@ -1075,15 +1072,22 @@ def prime_det(det):
yield from abs_set(det.cam.num_images, 5, wait=True)
yield from abs_set(det.cam.acquire, 1, wait=False)

@staticmethod
def stop_det(det):
for _ in range(5):
yield from abs_set(det.cam.acquire, 0, wait=True)
yield from abs_set(det.hdf5.capture, 0, wait=True)

@staticmethod
def bin_det(det, bin_fac):
yield from abs_set(det.cam.acquire, 0, wait=False)
if bin_fac is None:
bin_fac = 0
if int(bin_fac) not in [0, 1, 2, 3, 4]:
raise ValueError("binnng must be in [0, 1, 2, 3, 4]")
yield from abs_set(det.binning, bin_fac, wait=True)
FXITomoFlyer.prime_det(det)
if det.binning.value != bin_fac:
yield from abs_set(det.cam.acquire, 0, wait=False)
if bin_fac is None:
bin_fac = 0
if int(bin_fac) not in [0, 1, 2, 3, 4]:
raise ValueError("binnng must be in [0, 1, 2, 3, 4]")
yield from abs_set(det.binning, bin_fac, wait=True)
FXITomoFlyer.prime_det(det)

@staticmethod
def def_abs_out_pos(
Expand Down
5 changes: 5 additions & 0 deletions startup/20-global_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@
CALIBER_FLAG = 1

CALIBER = {}

ZP_8keV = {"D": 244,
"dr": 30}
ZP_9keV = {"D": 550,
"dr": 50}
6 changes: 6 additions & 0 deletions startup/40-scan_pre_define.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,9 @@ def _take_ref_image(
yield from _set_Andor_chunk_size(cams, chunk_size)
yield from _take_image(cams, [], num, stream_name=stream_name)


def _prime_cam(cam=Andor):
yield from abs_set(cam.cam.image_mode, 0, wait=True)
yield from abs_set(cam.cam.num_images, 5, wait=True)
yield from abs_set(cam.cam.acquire, 1, wait=True)

47 changes: 30 additions & 17 deletions startup/41-scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ def fly_scan(
@bpp.monitor_during_decorator([zps.pi_r])
@run_decorator(md=_md)
def fly_inner_scan():
'''

for flt in filters:
yield from mv(flt, 1)
yield from mv(flt, 1)
yield from bps.sleep(1)
'''

# close shutter, dark images: numer=chunk_size (e.g.20)
print("\nshutter closed, taking dark images...")
yield from _take_dark_image(
Expand Down Expand Up @@ -622,9 +622,11 @@ def xanes_scan2(
filters=[],
rot_first_flag=1,
simu=False,
return_ini=True,
md=None,
):
"""
changed something
Different from xanes_scan: In xanes_scan2, it moves out sample and take background image at each energy
Scan the energy and take 2D image
Expand Down Expand Up @@ -736,10 +738,12 @@ def xanes_scan2(
@stage_decorator(list(detectors) + motor)
@run_decorator(md=_md)
def xanes_inner_scan():
'''
if len(filters):
for filt in filters:
yield from mv(filt, 1)
yield from bps.sleep(0.5)
'''
yield from _set_rotation_speed(rs=30)
# take dark image
print(f"\ntake {chunk_size} dark images...")
Expand All @@ -753,6 +757,10 @@ def xanes_inner_scan():
yield from _open_shutter(simu)

for eng in eng_list:
if len(filters):
for filt in filters:
yield from mv(filt, 0)
yield from bps.sleep(0.5)
yield from _xanes_per_step(
eng,
detectors,
Expand All @@ -762,7 +770,10 @@ def xanes_inner_scan():
info_flag=0,
stream_name="primary",
)

if len(filters):
for filt in filters:
yield from mv(filt, 1)
yield from bps.sleep(0.5)
yield from _take_bkg_image(
motor_x_out,
motor_y_out,
Expand All @@ -784,13 +795,20 @@ def xanes_inner_scan():
repeat=2,
trans_first_flag=rot_first_flag,
)
'''
if len(filters):
for filt in filters:
yield from mv(filt, 0)
yield from bps.sleep(0.5)
yield from move_zp_ccd(eng_ini, move_flag=1, info_flag=0)
'''
if return_ini:
yield from move_zp_ccd(eng_ini, move_flag=1, info_flag=0)
print("closing shutter")
yield from _close_shutter(simu=simu)
if len(filters):
for filt in filters:
yield from mv(filt, 0)
yield from bps.sleep(0.5)

yield from xanes_inner_scan()
yield from mv(Andor.cam.image_mode, 1)
Expand Down Expand Up @@ -963,6 +981,8 @@ def xanes_inner_scan():
repeat=2,
rot_first_flag=rot_first_flag,
)
yield from move_zp_ccd(eng_list[0])
yield from bps.sleep(5)
print(f"\ntake bkg image after xanes scan, {chunk_size} per each energy...")
for eng in eng_list:
yield from _xanes_per_step(
Expand Down Expand Up @@ -1836,11 +1856,7 @@ def raster_2D_scan(
@stage_decorator(list(detectors) + motor)
@run_decorator(md=_md)
def raster_2D_inner():

if len(filters):
for filt in filters:
yield from mv(filt, 1)
yield from bps.sleep(0.5)
select_filters(filters)

# take dark image
print("take 5 dark image")
Expand Down Expand Up @@ -1890,12 +1906,9 @@ def raster_2D_inner():
repeat=1,
trans_first_flag=1 - rot_first_flag,
)
if len(filters):
for filt in filters:
yield from mv(filt, 0)
yield from bps.sleep(0.5)
select_filters([])
print("closing shutter")
yield from _close_shutter(simu)
yield from _close_shutter(simu=simu)

yield from raster_2D_inner()
txt = get_scan_parameter()
Expand Down Expand Up @@ -2391,7 +2404,6 @@ def multipos_2D_xanes_scan2(
out_y=None,
out_z=None,
out_r=None,
repeat_num=1,
exposure_time=0.2,
sleep_time=1,
chunk_size=5,
Expand Down Expand Up @@ -2459,6 +2471,7 @@ def multipos_2D_xanes_scan2(
note: string
"""
repeat_num = 1
print(eng_list)
print(x_list)
print(y_list)
Expand Down Expand Up @@ -3106,6 +3119,7 @@ def xanes_3D(
simu=False,
relative_move_flag=1,
rot_first_flag=1,
filters=[],
note="",
binning=[2, 2],
):
Expand All @@ -3129,6 +3143,7 @@ def xanes_3D(
out_r=out_r,
rs=rs,
relative_move_flag=relative_move_flag,
filters=filters,
note=my_note,
simu=simu,
rot_first_flag=rot_first_flag,
Expand Down Expand Up @@ -3363,5 +3378,3 @@ def tomo_mosaic_scan(
txt = txt1 + txt4 + txt3
insert_text(txt)


#
Loading

0 comments on commit b30f159

Please sign in to comment.