Work for setting file name and directory path

This commit is contained in:
gac-x05la
2024-12-17 16:28:39 +01:00
parent 476a454dd3
commit 8de91cc834
3 changed files with 144 additions and 52 deletions

View File

@@ -42,6 +42,9 @@ class StdDaqMixin(CustomDeviceMixin):
d['image_width'] = scanargs['image_width']
if 'image_height' in scanargs and scanargs['image_height'] != None:
d['image_height'] = scanargs['image_height']
if 'file_path' in scanargs and scanargs['file_path']!=None:
self.parent.file_path.set(scanargs['file_path']).wait()
if "daq_num_points" in scanargs:
@@ -288,14 +291,14 @@ class StdDaqClient(PSIDeviceBase):
* 4: Invert pixel values, but do not apply any linearity correction
* 5: Apply the full linearity correction
"""
if 'image_width' in d:
print(d)
if 'image_width' in d and d['image_width']!=None:
self.cfg_pixel_width.set(d['image_width']).wait()
if 'image_height' in d:
if 'image_height' in d and d['image_height']!=None:
self.cfg_pixel_height.set(d['image_height']).wait()
if 'num_points_total' in d:
self.num_images.set(d['num_points_total']).wait()
if 'file_path' in d:
if 'file_path' in d and d['file_path']!=None:
self.file_path.set(d['file_path']).wait()
# Restart the DAQ if resolution changed

View File

@@ -29,6 +29,8 @@ class AcquireDark(Acquire):
ROI size in the y-direction [pixels]
acq_mode : str, optional
Predefined acquisition mode (default=)
file_path : str, optional
File path for standard daq
Returns:
ScanReport

View File

@@ -1,57 +1,144 @@
def fede_darks(nimages_dark, exposure_time=None, exposure_period=None, roix=None, roiy=None, acq_mode=None):
import os.path
class Measurement:
"""
Acquire a set of dark images with shutters closed.
Parameters
----------
nimages_dark : int
Number of dark images to acquire (no default)
exposure_time : float, optional
Exposure time [ms]. If not specified, the currently configured value on the camera will be used
exposure_period : float, optional
Exposure period [ms]
roix : int, optional
ROI size in the x-direction [pixels]
roiy : int, optional
ROI size in the y-direction [pixels]
acq_mode : str, optional
Predefined acquisition mode (default=)
Example:
--------
fede_darks(100, exposure_time=5)
This class provides a standard set of tomographic measurement functions
that can be used to acquire data at the TOMCAT beamline
"""
dev.es1_tasks.enabled = False
dev.es1_psod.enabled = False
dev.es1_ddaq.enabled = False
dev.es1_ismc.enabled = False
dev.es1_roty.enabled = False
dev.gfcam.enabled = True
dev.gfdaq.enabled = True
dev.daq_stream0.enabled = True
dev.daq_stream1.enabled = False
def __init__(self):
self.sample_name = 'tmp'
self.data_path = 'disk_test'
self.nimages = 1000
self.nimages_dark = 50
self.nimages_white = 100
# To be able to keep what is already set on the camera
self.exposure_time = None
self.exposure_period = None
self.roix = None
self.roiy = None
bec.system_config.file_suffix = self.sample_name
bec.system_config.file_directory = os.path.join(self.data_path,self.sample_name)
self.build_filename()
def build_filename(self):
"""
Build and set filename for bec and stddaq
"""
bec.system_config.file_suffix = self.sample_name
bec.system_config.file_directory = os.path.join(self.data_path,self.sample_name)
self.file_path = '/gpfs/test/test-beamline'
def configure(self,sample_name=None, data_path=None, exposure_time=None,
exposure_period=None, roix=None, roiy=None,nimages=None,
nimages_dark=None, nimages_white=None):
"""
Reconfigure the measurement with any number of new parameter
Parameters
----------
sample_name : string, optional
Name of the sample or measurement. This name will be used to construct
the name of the measurement directory (default=None)
data_path : string, optional
Information used to build the data directory for the measurement
(default=None)
exposure_time : float, optional
Exposure time [ms] (default=None)
exposure_period : float, optional
Exposure period [ms] (default=None)
roix : int, optional
ROI size in the x-direction [pixels] (default=None)
roiy : int, optional
ROI size in the y-direction [pixels] (default=None)
nimages : int, optional
Number of images to acquire (default=None)
nimages_dark : int, optional
Number of dark images to acquire (default=None)
nimages_white : int, optional
Number of white images to acquire (default=None)
"""
if sample_name != None:
self.sample_name = sample_name
if data_path != None:
self.data_path = data_path
if nimages != None:
self.nimages = nimages
if nimages_dark != None:
self.nimages_dark = nimages_dark
if nimages_white != None:
self.nimages_white = nimages_white
if exposure_time != None:
self.exposure_time = exposure_time
if exposure_period != None:
self.exposure_period = exposure_period
if roix != None:
self.roix = roix
if roiy != None:
self.roiy = roiy
self.build_filename()
def acquire_darks(self,nimages_dark, exposure_time=None, exposure_period=None, roix=None, roiy=None, acq_mode=None,
file_path=None):
"""
Acquire a set of dark images with shutters closed.
Parameters
----------
nimages_dark : int
Number of dark images to acquire (no default)
exposure_time : float, optional
Exposure time [ms]. If not specified, the currently configured value on the camera will be used
exposure_period : float, optional
Exposure period [ms]
roix : int, optional
ROI size in the x-direction [pixels]
roiy : int, optional
ROI size in the y-direction [pixels]
acq_mode : str, optional
Predefined acquisition mode (default=None)
file_path : str, optional
File path for standard daq (default=None)
Example:
--------
fede_darks(100, exposure_time=5)
"""
dev.es1_tasks.enabled = False
dev.es1_psod.enabled = False
dev.es1_ddaq.enabled = False
dev.es1_ismc.enabled = False
dev.es1_roty.enabled = False
dev.gfcam.enabled = True
dev.gfdaq.enabled = True
dev.daq_stream0.enabled = True
dev.daq_stream1.enabled = False
dev.gfcam.cfgAcqMode.set(1).wait()
dev.gfcam.cmdSetParam.set(1).wait()
dev.gfcam.cfgEnableExt.set(0).wait()
dev.gfcam.cfgEnableSoft.set(0).wait()
dev.gfcam.cfgEnableAlways.set(1).wait()
dev.gfcam.cfgAcqMode.set(1).wait()
dev.gfcam.cmdSetParam.set(1).wait()
dev.gfcam.cfgEnableExt.set(0).wait()
dev.gfcam.cfgEnableSoft.set(0).wait()
dev.gfcam.cfgEnableAlways.set(1).wait()
dev.gfcam.cfgTrigExt.set(0).wait()
dev.gfcam.cfgTrigSoft.set(0).wait()
dev.gfcam.cfgTrigTimer.set(0).wait()
dev.gfcam.cfgTrigAuto.set(1).wait()
dev.gfcam.cfgTrigExt.set(0).wait()
dev.gfcam.cfgTrigSoft.set(0).wait()
dev.gfcam.cfgTrigTimer.set(0).wait()
dev.gfcam.cfgTrigAuto.set(1).wait()
dev.gfcam.cfgExpExt.set(0).wait()
dev.gfcam.cfgExpSoft.set(0).wait()
dev.gfcam.cfgExpTimer.set(1).wait()
dev.gfcam.cfgExpExt.set(0).wait()
dev.gfcam.cfgExpSoft.set(0).wait()
dev.gfcam.cfgExpTimer.set(1).wait()
dev.gfcam.cfgCntStartBit.set(0).wait()
dev.gfcam.cfgCntStartBit.set(0).wait()
# Commit changes to GF
dev.gfcam.cmdSetParam.set(1).wait()
# Commit changes to GF
dev.gfcam.cmdSetParam.set(1).wait()
### TODO: camera reset
print("Handing over to 'scans.acquire_dark")
scans.acquire_dark(exp_burst=nimages_dark, exp_time=exposure_time, exp_period=exposure_period, image_width=roix, image_height=roiy, acq_mode=acq_mode)
### TODO: camera reset
print("Handing over to 'scans.acquire_dark")
scans.acquire_dark(exp_burst=nimages_dark, exp_time=exposure_time, exp_period=exposure_period, image_width=roix,
image_height=roiy, acq_mode=acq_mode, file_path=file_path)