Skip to content

Commit

Permalink
skip acquisition for the modes listed in NeXusSkipAcquisitionModes va…
Browse files Browse the repository at this point in the history
…riable
  • Loading branch information
jkotan committed Jun 4, 2024
1 parent 7a8ea3a commit ae50f2a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024-06-04 Jan Kotanski <jankotan@gmail.com>
* skip acquisition for the modes listed in NeXusSkipAcquisitionModes variable (#117)
* tagged as 3.23.0

2024-06-03 Jan Kotanski <jankotan@gmail.com>
* improve support for ScanFile formating wih _%05d and _{ScanID:05d} (#114)
* tagged as 3.22.0
Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ The NeXus file recorder uses the following sardana environment variables

* **ActiveMntGrp** *(str)* - active measurement group
* **ScanID** *(int)* - the last scan identifier number, default: ``-1``
* **ScanDir** *(str)* - the scan directory
* **ScanFile** *(list)* - a list of scan files
* **NeXusSelectorDevice** *(str)* - NXSRecSelector tango device if more installed, otherwise first one found

* **NXSAppendSciCatDataset** *(bool)* - append scan name to scicat dataset list file, default: ``False``
Expand All @@ -222,4 +224,5 @@ The NeXus file recorder uses the following sardana environment variables
* **MetadataScript** *(str)* - a python module file name containing ``main()`` which provides a dictionary with user metadata stored in the INIT mode, default: ``""``
* **ScicatMeasurements** *(dict)* - a dictionary of measurement names indexed by ``ScanDir`` and used by ``scingestor``, default: ``{}``
* **CreateMeasurementFile** *(bool)* - create a measurement file with its filename releated to ``ScicatMeasurements`` or ``ScanFile``, default: ``False``
* **NeXusSkipAcquisitionModes** *(list)* - a list of strategy modes for which acquisition is skip

2 changes: 1 addition & 1 deletion sardananxsrecorder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
""" Sardana Scan Recorders """

#: package version
__version__ = "3.22.0"
__version__ = "3.23.0"
24 changes: 24 additions & 0 deletions sardananxsrecorder/nxsrecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def __init__(self, filename=None, macro=None, **pars):
#: (:obj:`dict` <:obj:`str` , :obj:`str`>) NeXus configuration
self.__conf = {}

#: (:obj:`list` <:obj:`str`>) skip Acquisition Modes
self.skipAcquisitionModes = []

#: (:obj:`dict` <:obj:`str` , `any`>) User data
self.__udata = None

Expand Down Expand Up @@ -1020,6 +1023,10 @@ def _startRecordList(self, recordlist):
# self.debug('START_DATA: %s' % str(envRec))

self.__nexuswriter_device.jsonrecord = rec
self.skipAcquisitionModes = self.__skipAcquisitionModes(self)
if "INIT" in self.skipAcquisitionModes:
self.__nexuswriter_device.skipAcquisition = True

self.__command(self.__nexuswriter_device, "openEntry")
except Exception:
self.__removeDynamicComponent()
Expand Down Expand Up @@ -1106,6 +1113,8 @@ def _writeRecord(self, record):
rec = json.dumps(
envrecord, cls=NXS_FileRecorder.numpyEncoder)
self.__nexuswriter_device.jsonrecord = rec
if "STEP" in self.skipAcquisitionModes:
self.__nexuswriter_device.skipAcquisition = True

# self.debug('DATA: {"data":%s}' % json.dumps(
# record.data,
Expand Down Expand Up @@ -1174,6 +1183,8 @@ def _endRecordList(self, recordlist):
rec = json.dumps(
envrecord, cls=NXS_FileRecorder.numpyEncoder)
self.__nexuswriter_device.jsonrecord = rec
if "FINAL" in self.skipAcquisitionModes:
self.__nexuswriter_device.skipAcquisition = True
self.__command(self.__nexuswriter_device, "closeEntry")
self.__command(self.__nexuswriter_device, "closeFile")
except Exception:
Expand Down Expand Up @@ -1220,6 +1231,19 @@ def beamtimeid(self):
beamtimeid = self.beamtime_id(bmtfpath, bmtfprefix, bmtfext)
return beamtimeid or "00000000"

def __skipAcquisitionModes(self):
""" find skip acquisition modes
"""
try:
skip_acq = self.__macro().getEnv('NeXusSkipAcquisitionModes')
except Exception:
skip_acq = []
if isinstance(skip_acq, str):
skip_acq = re.split(r"[-;,.\s]\s*", skip_acq)
if skip_acq:
self.debug('Skip Acquisition Modes: %s' % str(skip_acq))
return skip_acq

def __rawfilename(self, serial):
""" find scan name
"""
Expand Down

0 comments on commit ae50f2a

Please sign in to comment.