Skip to content

Commit

Permalink
change to NeXusWriterModes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotan committed Jun 11, 2024
1 parent 8115f58 commit b91d3df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
2024-06-19 Jan Kotanski <[email protected]>
* replace NeXusSkipAcquisitionModes by NeXusAcquisitionModes variable (#127)
* replace NeXusSkipAcquisitionModes by NeXusWriterModes variable (#127)
* tagged as 3.26.0

2024-06-07 Jan Kotanski <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,5 @@ The NeXus file recorder uses the following sardana environment variables
* **CreateMeasurementFile** *(bool)* - create a measurement file with its filename releated to ``ScicatMeasurements`` or ``ScanFile``, default: ``False``
* **NeXusWriterProperties** *(dict)* - a dictionary of TangoDataWriter (NXSDataWriter) properties (starting with a small letter)
* **NeXusMeshScanID** *(int)* - ScanID used for composed scans e.g. mesh scan combined from many linear scans
* **NeXusAcquisitionModes** *(list)* - a list of strategy modes e.g. ``INIT``, ``NOINIT``, ``NOSTEP``, ``NOFINAL``, ``VDS`` separated by commas
* **NeXusWriterModes** *(list)* - a list of strategy modes e.g. ``NOINIT``, ``NOSTEP``, ``NOFINAL``, ``MESH``, ``VDS`` separated by commas

28 changes: 15 additions & 13 deletions sardananxsrecorder/nxsrecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def __init__(self, filename=None, macro=None, **pars):
self.__conf = {}

#: (:obj:`list` <:obj:`str`>) acquisition Modes
self.acquisitionModes = self.__variableList(
"NeXusAcquisitionModes")
self.writerModes = self.__variableList(
"NeXusWriterModes")

#: (:obj:`dict` <:obj:`str` , `any`>) User data
self.__udata = None
Expand All @@ -178,7 +178,8 @@ def __init__(self, filename=None, macro=None, **pars):

def _serial(self, scanID):
serial = None
if "NOINIT" in self.acquisitionModes:
if "NOINIT" in self.writerModes and \
"MESH" in self.writerModes:
if self.__macro:
serial = self.__macro().getEnv('NeXusMeshScanID', None)
if serial is None:
Expand All @@ -189,7 +190,8 @@ def _serial(self, scanID):
serial = scanID
else:
serial = scanID + 1
if "INIT" in self.acquisitionModes:
if "MESH" in self.writerModes and \
"NOINIT" not in self.writerModes:
if self.__macro:
self.__macro().setEnv('NeXusMeshScanID', serial)
return serial
Expand Down Expand Up @@ -1012,8 +1014,8 @@ def _startRecordList(self, recordlist):
self.__vars["vars"]["serialno"] = ("_%05i" % self.__serial) \
if appendscanid else ""
self.__vars["vars"]["scan_id"] = envRec["serialno"]
self.__vars["vars"]["acq_modes"] = \
",".join(self.acquisitionModes or [])
self.__vars["vars"]["writer_modes"] = \
",".join(self.writerModes or [])
self.__vars["vars"]["scan_title"] = envRec["title"]
if self.__macro:
if hasattr(self.__macro(), "integ_time"):
Expand Down Expand Up @@ -1056,9 +1058,9 @@ def _startRecordList(self, recordlist):
# self.debug('START_DATA: %s' % str(envRec))

self.__nexuswriter_device.jsonrecord = rec
self.acquisitionModes = self.__variableList(
"NeXusAcquisitionModes")
if "NOINIT" in self.acquisitionModes:
self.writerModes = self.__variableList(
"NeXusWriterModes")
if "NOINIT" in self.writerModes:
self.__nexuswriter_device.skipAcquisition = True

self.__command(self.__nexuswriter_device, "openEntry")
Expand Down Expand Up @@ -1147,7 +1149,7 @@ def _writeRecord(self, record):
rec = json.dumps(
envrecord, cls=NXS_FileRecorder.numpyEncoder)
self.__nexuswriter_device.jsonrecord = rec
if "NOSTEP" in self.acquisitionModes:
if "NOSTEP" in self.writerModes:
self.__nexuswriter_device.skipAcquisition = True

# self.debug('DATA: {"data":%s}' % json.dumps(
Expand Down Expand Up @@ -1217,7 +1219,7 @@ def _endRecordList(self, recordlist):
rec = json.dumps(
envrecord, cls=NXS_FileRecorder.numpyEncoder)
self.__nexuswriter_device.jsonrecord = rec
if "NOFINAL" in self.acquisitionModes:
if "NOFINAL" in self.writerModes:
self.__nexuswriter_device.skipAcquisition = True
self.__command(self.__nexuswriter_device, "closeEntry")
self.__command(self.__nexuswriter_device, "closeFile")
Expand Down Expand Up @@ -1265,7 +1267,7 @@ def beamtimeid(self):
beamtimeid = self.beamtime_id(bmtfpath, bmtfprefix, bmtfext)
return beamtimeid or "00000000"

def __variableList(self, variable='NeXusAcquisitionModes'):
def __variableList(self, variable='NeXusWriterModes'):
""" read variable list
"""
try:
Expand Down Expand Up @@ -1367,7 +1369,7 @@ def __appendSciCatDataset(self, hostname=None):
sid = self.__serial
sname = "%s::/%s_%05i;%s_%05i" % (
scanname, entryname, sid, scanname, sid)
if "NOINIT" in self.acquisitionModes:
if "NOINIT" in self.writerModes:
sname = "%s:%s" % (sname, time.time())

# auto grouping
Expand Down

0 comments on commit b91d3df

Please sign in to comment.