sardana-nxsrecorder 3.21.1__tar.gz → 3.23.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/ChangeLog +8 -0
  2. {sardana-nxsrecorder-3.21.1/sardana_nxsrecorder.egg-info → sardana-nxsrecorder-3.23.0}/PKG-INFO +4 -1
  3. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/README.rst +3 -0
  4. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/man/sardananxsrecorder.1 +32 -18
  5. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0/sardana_nxsrecorder.egg-info}/PKG-INFO +4 -1
  6. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardananxsrecorder/__init__.py +1 -1
  7. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardananxsrecorder/nxsrecorder.py +130 -33
  8. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/debian10_py2/Dockerfile +0 -0
  9. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/debian10_py3/Dockerfile +0 -0
  10. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/debian8_py2/Dockerfile +0 -0
  11. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/debian8_py3/Dockerfile +0 -0
  12. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/debian9_py2/Dockerfile +0 -0
  13. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/debian9_py3/Dockerfile +0 -0
  14. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/install.sh +0 -0
  15. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/run.sh +0 -0
  16. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/ubuntu16.04_py2/Dockerfile +0 -0
  17. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/ubuntu16.04_py3/Dockerfile +0 -0
  18. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/ubuntu18.04_py2/Dockerfile +0 -0
  19. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/ubuntu18.04_py3/Dockerfile +0 -0
  20. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.ci/ubuntu20.04_py3/Dockerfile +0 -0
  21. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.flake8 +0 -0
  22. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.github/workflows/tests.yml +0 -0
  23. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/.gitignore +0 -0
  24. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/COPYRIGHT +0 -0
  25. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/MANIFEST.in +0 -0
  26. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/doc/Makefile +0 -0
  27. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/doc/conf.py +0 -0
  28. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/doc/index.rst +0 -0
  29. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/doc/make.bat +0 -0
  30. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/doc/sardananxsrecorder.rst +0 -0
  31. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardana_nxsrecorder.egg-info/SOURCES.txt +0 -0
  32. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardana_nxsrecorder.egg-info/dependency_links.txt +0 -0
  33. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardana_nxsrecorder.egg-info/not-zip-safe +0 -0
  34. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardana_nxsrecorder.egg-info/requires.txt +0 -0
  35. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/sardana_nxsrecorder.egg-info/top_level.txt +0 -0
  36. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/setup.cfg +0 -0
  37. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/setup.py +0 -0
  38. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/test/__init__.py +0 -0
  39. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/test/__main__.py +0 -0
  40. {sardana-nxsrecorder-3.21.1 → sardana-nxsrecorder-3.23.0}/test/main.py +0 -0
@@ -1,3 +1,11 @@
1
+ 2024-06-04 Jan Kotanski <jankotan@gmail.com>
2
+ * skip acquisition for the modes listed in NeXusSkipAcquisitionModes variable (#117)
3
+ * tagged as 3.23.0
4
+
5
+ 2024-06-03 Jan Kotanski <jankotan@gmail.com>
6
+ * improve support for ScanFile formating wih _%05d and _{ScanID:05d} (#114)
7
+ * tagged as 3.22.0
8
+
1
9
  2024-05-23 Jan Kotanski <jankotan@gmail.com>
2
10
  * replace deprecated tz.localize() with datetime.replace() (#111)
3
11
  * tagged as 3.21.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sardana-nxsrecorder
3
- Version: 3.21.1
3
+ Version: 3.23.0
4
4
  Summary: NeXus Sardana Scan Recorder
5
5
  Home-page: https://github.com/nexdatas/sardana-nxs-filerecorder/
6
6
  Author: Jan Kotanski
@@ -234,6 +234,8 @@ The NeXus file recorder uses the following sardana environment variables
234
234
 
235
235
  * **ActiveMntGrp** *(str)* - active measurement group
236
236
  * **ScanID** *(int)* - the last scan identifier number, default: ``-1``
237
+ * **ScanDir** *(str)* - the scan directory
238
+ * **ScanFile** *(list)* - a list of scan files
237
239
  * **NeXusSelectorDevice** *(str)* - NXSRecSelector tango device if more installed, otherwise first one found
238
240
 
239
241
  * **NXSAppendSciCatDataset** *(bool)* - append scan name to scicat dataset list file, default: ``False``
@@ -247,4 +249,5 @@ The NeXus file recorder uses the following sardana environment variables
247
249
  * **MetadataScript** *(str)* - a python module file name containing ``main()`` which provides a dictionary with user metadata stored in the INIT mode, default: ``""``
248
250
  * **ScicatMeasurements** *(dict)* - a dictionary of measurement names indexed by ``ScanDir`` and used by ``scingestor``, default: ``{}``
249
251
  * **CreateMeasurementFile** *(bool)* - create a measurement file with its filename releated to ``ScicatMeasurements`` or ``ScanFile``, default: ``False``
252
+ * **NeXusSkipAcquisitionModes** *(list)* - a list of strategy modes for which acquisition is skip
250
253
 
@@ -209,6 +209,8 @@ The NeXus file recorder uses the following sardana environment variables
209
209
 
210
210
  * **ActiveMntGrp** *(str)* - active measurement group
211
211
  * **ScanID** *(int)* - the last scan identifier number, default: ``-1``
212
+ * **ScanDir** *(str)* - the scan directory
213
+ * **ScanFile** *(list)* - a list of scan files
212
214
  * **NeXusSelectorDevice** *(str)* - NXSRecSelector tango device if more installed, otherwise first one found
213
215
 
214
216
  * **NXSAppendSciCatDataset** *(bool)* - append scan name to scicat dataset list file, default: ``False``
@@ -222,4 +224,5 @@ The NeXus file recorder uses the following sardana environment variables
222
224
  * **MetadataScript** *(str)* - a python module file name containing ``main()`` which provides a dictionary with user metadata stored in the INIT mode, default: ``""``
223
225
  * **ScicatMeasurements** *(dict)* - a dictionary of measurement names indexed by ``ScanDir`` and used by ``scingestor``, default: ``{}``
224
226
  * **CreateMeasurementFile** *(bool)* - create a measurement file with its filename releated to ``ScicatMeasurements`` or ``ScanFile``, default: ``False``
227
+ * **NeXusSkipAcquisitionModes** *(list)* - a list of strategy modes for which acquisition is skip
225
228
 
@@ -1,8 +1,5 @@
1
1
  .\" Man page generated from reStructuredText.
2
2
  .
3
- .TH "SARDANANXSRECORDER" "1" "Nov 09, 2022" "3.12" "Sardana NeXus Recorder"
4
- .SH NAME
5
- sardananxsrecorder \- sardananxsrecorder Documentation
6
3
  .
7
4
  .nr rst2man-indent-level 0
8
5
  .
@@ -30,6 +27,9 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
30
27
  .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
31
28
  .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
32
29
  ..
30
+ .TH "SARDANANXSRECORDER" "1" "Jun 04, 2024" "3.23" "Sardana NeXus Recorder"
31
+ .SH NAME
32
+ sardananxsrecorder \- sardananxsrecorder Documentation
33
33
  .sp
34
34
  \fI\%\fP
35
35
  \fI\%\fP
@@ -79,7 +79,7 @@ defining the package location, e.g.
79
79
  .sp
80
80
  .SS Debian packages
81
81
  .sp
82
- Debian Bookworm, Bullseye, Buster and Ubuntu Lunar, Jammy, Focal packages can be found in the HDRI repository.
82
+ Debian Bookworm, Bullseye, Buster and Ubuntu Lunar, Jammy and Focal packages can be found in the HDRI repository.
83
83
  .sp
84
84
  To install the debian packages, add the PGP repository key
85
85
  .INDENT 0.0
@@ -326,21 +326,35 @@ The NeXus file recorder uses the following sardana environment variables
326
326
  .IP \(bu 2
327
327
  \fBScanID\fP \fI(int)\fP \- the last scan identifier number, default: \fB\-1\fP
328
328
  .IP \(bu 2
329
+ \fBScanDir\fP \fI(str)\fP \- the scan directory
330
+ .IP \(bu 2
331
+ \fBScanFile\fP \fI(list)\fP \- a list of scan files
332
+ .IP \(bu 2
329
333
  \fBNeXusSelectorDevice\fP \fI(str)\fP \- NXSRecSelector tango device if more installed, otherwise first one found
330
334
  .IP \(bu 2
331
335
  \fBNXSAppendSciCatDataset\fP \fI(bool)\fP \- append scan name to scicat dataset list file, default: \fBFalse\fP
332
336
  .IP \(bu 2
333
- \fBBeamtimeFilePath\fP \fI(str)\fP \- beamtime file path to search beamtime metadata file, default: \fB"/gpfs/current"\fP
337
+ \fBBeamtimeFilePath\fP \fI(str)\fP \- beamtime file path to search beamtime metadata file, default: \fB\(dq/gpfs/current\(dq\fP
334
338
  .IP \(bu 2
335
- \fBBeamtimeFilePrefix\fP \fI(str)\fP \- beamtime metadata file prefix, default: \fB"beamtime\-metadata\-"\fP
339
+ \fBBeamtimeFilePrefix\fP \fI(str)\fP \- beamtime metadata file prefix, default: \fB\(dqbeamtime\-metadata\-\(dq\fP
336
340
  .IP \(bu 2
337
- \fBBeamtimeFileExt\fP \fI(str)\fP \- beamtime metadata file extension, default: \fB".json"\fP
341
+ \fBBeamtimeFileExt\fP \fI(str)\fP \- beamtime metadata file extension, default: \fB\(dq.json\(dq\fP
338
342
  .IP \(bu 2
339
- \fBSciCatDatasetListFilePrefix\fP \fI(str)\fP \- scicat dataset list file prefix, default: \fB"scicat\-datasets\-"\fP
343
+ \fBSciCatDatasetListFilePrefix\fP \fI(str)\fP \- scicat dataset list file prefix, default: \fB\(dqscicat\-datasets\-\(dq\fP
340
344
  .IP \(bu 2
341
- \fBSciCatDatasetListFileExt\fP \fI(str)\fP \- scicat dataset list file extension, default: \fB".lst"\fP
345
+ \fBSciCatDatasetListFileExt\fP \fI(str)\fP \- scicat dataset list file extension, default: \fB\(dq.lst\(dq\fP
342
346
  .IP \(bu 2
343
347
  \fBSciCatDatasetListFileLocal\fP \fI(bool)\fP \- add the hostname to the scicat dataset list file extension, default: \fBFalse\fP
348
+ .IP \(bu 2
349
+ \fBSciCatAutoGrouping\fP \fI(bool)\fP \- group all scans with the measurement name set to the base scan filename, default: \fBFalse\fP
350
+ .IP \(bu 2
351
+ \fBMetadataScript\fP \fI(str)\fP \- a python module file name containing \fBmain()\fP which provides a dictionary with user metadata stored in the INIT mode, default: \fB\(dq\(dq\fP
352
+ .IP \(bu 2
353
+ \fBScicatMeasurements\fP \fI(dict)\fP \- a dictionary of measurement names indexed by \fBScanDir\fP and used by \fBscingestor\fP, default: \fB{}\fP
354
+ .IP \(bu 2
355
+ \fBCreateMeasurementFile\fP \fI(bool)\fP \- create a measurement file with its filename releated to \fBScicatMeasurements\fP or \fBScanFile\fP, default: \fBFalse\fP
356
+ .IP \(bu 2
357
+ \fBNeXusSkipAcquisitionModes\fP \fI(list)\fP \- a list of strategy modes for which acquisition is skip
344
358
  .UNINDENT
345
359
  .sp
346
360
  Contents:
@@ -351,8 +365,8 @@ Contents:
351
365
  This is the macro server scan data NeXus recorder module
352
366
  .INDENT 0.0
353
367
  .TP
354
- .B class sardananxsrecorder.nxsrecorder.NXS_FileRecorder(filename=None, macro=None, **pars)
355
- Bases: \fBsardana.macroserver.scan.recorder.storage.BaseFileRecorder\fP
368
+ .B class sardananxsrecorder.nxsrecorder.NXS_FileRecorder(filename=None, macro=None, **pars)
369
+ Bases: \fI\%BaseFileRecorder\fP
356
370
  .sp
357
371
  This recorder saves data to a NeXus file making use of NexDaTaS Writer
358
372
  .sp
@@ -430,7 +444,7 @@ and records in INIT mode
430
444
  .UNINDENT
431
445
  .INDENT 7.0
432
446
  .TP
433
- .B formats = {\(aqh5\(aq: \(aq.h5\(aq, \(aqndf\(aq: \(aq.ndf\(aq, \(aqnx\(aq: \(aq.nx\(aq, \(aqnxs\(aq: \(aq.nxs\(aq}
447
+ .B formats = {\(aqh5\(aq: \(aq.h5\(aq, \(aqndf\(aq: \(aq.ndf\(aq, \(aqnx\(aq: \(aq.nx\(aq, \(aqnxs\(aq: \(aq.nxs\(aq}
434
448
  (\fI\%dict\fP <\fI\%str\fP, \fI\%str\fP > ) recoder format
435
449
  .UNINDENT
436
450
  .INDENT 7.0
@@ -448,8 +462,8 @@ the output file format
448
462
  .UNINDENT
449
463
  .INDENT 7.0
450
464
  .TP
451
- .B class numpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
452
- Bases: \fBjson.encoder.JSONEncoder\fP
465
+ .B class numpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
466
+ Bases: \fBJSONEncoder\fP
453
467
  .sp
454
468
  numpy json encoder with list
455
469
  .sp
@@ -465,7 +479,7 @@ ensure_ascii is false, the output can contain non\-ASCII characters.
465
479
  .sp
466
480
  If check_circular is true, then lists, dicts, and custom encoded
467
481
  objects will be checked for circular references during encoding to
468
- prevent an infinite recursion (which would cause an OverflowError).
482
+ prevent an infinite recursion (which would cause an RecursionError).
469
483
  Otherwise, no such check takes place.
470
484
  .sp
471
485
  If allow_nan is true, then NaN, Infinity, and \-Infinity will be
@@ -507,11 +521,11 @@ default encoder
507
521
  Sardana Scan Recorders
508
522
  .INDENT 0.0
509
523
  .IP \(bu 2
510
- genindex
524
+ \fI\%Index\fP
511
525
  .IP \(bu 2
512
- modindex
526
+ \fI\%Module Index\fP
513
527
  .IP \(bu 2
514
- search
528
+ \fI\%Search Page\fP
515
529
  .UNINDENT
516
530
  .SH AUTHOR
517
531
  Author
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sardana-nxsrecorder
3
- Version: 3.21.1
3
+ Version: 3.23.0
4
4
  Summary: NeXus Sardana Scan Recorder
5
5
  Home-page: https://github.com/nexdatas/sardana-nxs-filerecorder/
6
6
  Author: Jan Kotanski
@@ -234,6 +234,8 @@ The NeXus file recorder uses the following sardana environment variables
234
234
 
235
235
  * **ActiveMntGrp** *(str)* - active measurement group
236
236
  * **ScanID** *(int)* - the last scan identifier number, default: ``-1``
237
+ * **ScanDir** *(str)* - the scan directory
238
+ * **ScanFile** *(list)* - a list of scan files
237
239
  * **NeXusSelectorDevice** *(str)* - NXSRecSelector tango device if more installed, otherwise first one found
238
240
 
239
241
  * **NXSAppendSciCatDataset** *(bool)* - append scan name to scicat dataset list file, default: ``False``
@@ -247,4 +249,5 @@ The NeXus file recorder uses the following sardana environment variables
247
249
  * **MetadataScript** *(str)* - a python module file name containing ``main()`` which provides a dictionary with user metadata stored in the INIT mode, default: ``""``
248
250
  * **ScicatMeasurements** *(dict)* - a dictionary of measurement names indexed by ``ScanDir`` and used by ``scingestor``, default: ``{}``
249
251
  * **CreateMeasurementFile** *(bool)* - create a measurement file with its filename releated to ``ScicatMeasurements`` or ``ScanFile``, default: ``False``
252
+ * **NeXusSkipAcquisitionModes** *(list)* - a list of strategy modes for which acquisition is skip
250
253
 
@@ -20,4 +20,4 @@
20
20
  """ Sardana Scan Recorders """
21
21
 
22
22
  #: package version
23
- __version__ = "3.21.1"
23
+ __version__ = "3.23.0"
@@ -102,6 +102,8 @@ class NXS_FileRecorder(BaseFileRecorder):
102
102
  BaseFileRecorder.__init__(self)
103
103
  #: (:obj:`str`) base filename
104
104
  self.__base_filename = filename
105
+ #: (:obj:`str`) raw filename
106
+ self.__raw_filename = ""
105
107
  self.__macro = weakref.ref(macro) if macro else None
106
108
  #: (:class:`tango.Database`) tango database
107
109
  self.__db = tango.Database()
@@ -153,6 +155,9 @@ class NXS_FileRecorder(BaseFileRecorder):
153
155
  #: (:obj:`dict` <:obj:`str` , :obj:`str`>) NeXus configuration
154
156
  self.__conf = {}
155
157
 
158
+ #: (:obj:`list` <:obj:`str`>) skip Acquisition Modes
159
+ self.skipAcquisitionModes = []
160
+
156
161
  #: (:obj:`dict` <:obj:`str` , `any`>) User data
157
162
  self.__udata = None
158
163
 
@@ -164,7 +169,7 @@ class NXS_FileRecorder(BaseFileRecorder):
164
169
  appendentry = self.__getConfVar("AppendEntry", True)
165
170
  scanID = self.__env["ScanID"] \
166
171
  if "ScanID" in self.__env.keys() else -1
167
- appendentry = not self.__setFileName(
172
+ self.__setFileName(
168
173
  self.__base_filename, not appendentry, scanID)
169
174
 
170
175
  def __command(self, server, command, *args):
@@ -339,10 +344,12 @@ class NXS_FileRecorder(BaseFileRecorder):
339
344
 
340
345
  :param filename: sardana scanfile name
341
346
  :type filename: :obj:`str`
342
- :param numer: True if append scanID
343
- :param numer: :obj:`bool`
347
+ :param number: True if append scanID
348
+ :param number: :obj:`bool`
344
349
  :param scanID: scanID to append
345
350
  :type scanID: :obj:`int`
351
+ :returns: True if append scanID
352
+ :rtype: :obj:`bool`
346
353
  """
347
354
  if scanID is not None and scanID < 0:
348
355
  return number
@@ -371,20 +378,30 @@ class NXS_FileRecorder(BaseFileRecorder):
371
378
 
372
379
  subs = (len([None for _ in list(re.finditer('%', filename))]) == 1)
373
380
  # construct the filename, e.g. : /dir/subdir/etcdir/prefix_00123.nxs
374
- if subs or number:
375
- if scanID is None:
376
- serial = self.recordlist.getEnvironValue('serialno')
377
- elif scanID >= 0:
378
- if isarver >= 304 or isarver == 0:
379
- serial = scanID
380
- else:
381
- serial = scanID + 1
381
+ if scanID is None:
382
+ serial = self.recordlist.getEnvironValue('serialno')
383
+ elif scanID >= 0:
384
+ if isarver >= 304 or isarver == 0:
385
+ serial = scanID
386
+ else:
387
+ serial = scanID + 1
388
+
382
389
  if subs:
383
390
  try:
384
391
  #: output file name
385
392
  self.filename = filename % serial
386
393
  except Exception:
387
394
  subs = False
395
+ if not self.__raw_filename:
396
+ self.__raw_filename = self.__rawfilename(serial)
397
+ self.debug('Raw Filename: %s' % str(self.__raw_filename))
398
+ if not subs and self.__raw_filename and \
399
+ "{ScanID" in self.__raw_filename:
400
+ try:
401
+ self.filename = self.__raw_filename.format(ScanID=serial)
402
+ subs = True
403
+ except Exception:
404
+ pass
388
405
 
389
406
  if not subs:
390
407
  if number:
@@ -958,12 +975,11 @@ class NXS_FileRecorder(BaseFileRecorder):
958
975
  self.__setNexusDevices()
959
976
 
960
977
  appendentry = self.__getConfVar("AppendEntry", True)
961
-
962
- appendentry = not self.__setFileName(
978
+ appendscanid = not self.__setFileName(
963
979
  self.__base_filename, not appendentry)
964
980
  envRec = self.recordlist.getEnviron()
965
981
  self.__vars["vars"]["serialno"] = ("_%05i" % envRec["serialno"]) \
966
- if appendentry else ""
982
+ if appendscanid else ""
967
983
  self.__vars["vars"]["scan_id"] = envRec["serialno"]
968
984
  self.__vars["vars"]["scan_title"] = envRec["title"]
969
985
  if self.__macro:
@@ -1007,6 +1023,10 @@ class NXS_FileRecorder(BaseFileRecorder):
1007
1023
  # self.debug('START_DATA: %s' % str(envRec))
1008
1024
 
1009
1025
  self.__nexuswriter_device.jsonrecord = rec
1026
+ self.skipAcquisitionModes = self.__skipAcquisitionModes()
1027
+ if "INIT" in self.skipAcquisitionModes:
1028
+ self.__nexuswriter_device.skipAcquisition = True
1029
+
1010
1030
  self.__command(self.__nexuswriter_device, "openEntry")
1011
1031
  except Exception:
1012
1032
  self.__removeDynamicComponent()
@@ -1093,6 +1113,8 @@ class NXS_FileRecorder(BaseFileRecorder):
1093
1113
  rec = json.dumps(
1094
1114
  envrecord, cls=NXS_FileRecorder.numpyEncoder)
1095
1115
  self.__nexuswriter_device.jsonrecord = rec
1116
+ if "STEP" in self.skipAcquisitionModes:
1117
+ self.__nexuswriter_device.skipAcquisition = True
1096
1118
 
1097
1119
  # self.debug('DATA: {"data":%s}' % json.dumps(
1098
1120
  # record.data,
@@ -1161,6 +1183,8 @@ class NXS_FileRecorder(BaseFileRecorder):
1161
1183
  rec = json.dumps(
1162
1184
  envrecord, cls=NXS_FileRecorder.numpyEncoder)
1163
1185
  self.__nexuswriter_device.jsonrecord = rec
1186
+ if "FINAL" in self.skipAcquisitionModes:
1187
+ self.__nexuswriter_device.skipAcquisition = True
1164
1188
  self.__command(self.__nexuswriter_device, "closeEntry")
1165
1189
  self.__command(self.__nexuswriter_device, "closeFile")
1166
1190
  except Exception:
@@ -1188,15 +1212,15 @@ class NXS_FileRecorder(BaseFileRecorder):
1188
1212
  """
1189
1213
  result = ""
1190
1214
  fpath = self.filename
1191
- if fpath.startswith(bmtfpath):
1192
- try:
1215
+ try:
1216
+ if fpath.startswith(bmtfpath):
1193
1217
  if os.path.isdir(bmtfpath):
1194
1218
  btml = [fl for fl in os.listdir(bmtfpath)
1195
1219
  if (fl.startswith(bmtfprefix)
1196
1220
  and fl.endswith(bmtfext))]
1197
1221
  result = btml[0][len(bmtfprefix):-len(bmtfext)]
1198
- except Exception:
1199
- pass
1222
+ except Exception:
1223
+ pass
1200
1224
  return result
1201
1225
 
1202
1226
  def beamtimeid(self):
@@ -1207,11 +1231,75 @@ class NXS_FileRecorder(BaseFileRecorder):
1207
1231
  beamtimeid = self.beamtime_id(bmtfpath, bmtfprefix, bmtfext)
1208
1232
  return beamtimeid or "00000000"
1209
1233
 
1234
+ def __skipAcquisitionModes(self):
1235
+ """ find skip acquisition modes
1236
+ """
1237
+ try:
1238
+ skip_acq = self.__macro().getEnv('NeXusSkipAcquisitionModes')
1239
+ except Exception:
1240
+ skip_acq = []
1241
+ if isinstance(skip_acq, str):
1242
+ skip_acq = re.split(r"[-;,.\s]\s*", skip_acq)
1243
+ if skip_acq:
1244
+ self.debug('Skip Acquisition Modes: %s' % str(skip_acq))
1245
+ return skip_acq
1246
+
1247
+ def __rawfilename(self, serial):
1248
+ """ find scan name
1249
+ """
1250
+ try:
1251
+ scan_file = self.__macro().getEnv('ScanFile')
1252
+ except Exception:
1253
+ scan_file = []
1254
+ try:
1255
+ scan_dir = self.__macro().getEnv('ScanDir')
1256
+ except Exception:
1257
+ scan_dir = "/"
1258
+ if isinstance(scan_file, str):
1259
+ scan_file = [scan_file]
1260
+ bfilename = ""
1261
+
1262
+ for sfile in scan_file:
1263
+ sfile = os.path.join(scan_dir, sfile)
1264
+ try:
1265
+ ffile = sfile.format(ScanID=serial)
1266
+ except KeyError:
1267
+ ffile = sfile
1268
+ if ffile == self.__base_filename:
1269
+ bfilename = sfile
1270
+ break
1271
+ bfilename = bfilename or self.__base_filename
1272
+ return bfilename
1273
+
1274
+ def __scanname(self, serial):
1275
+ """ find scan name
1276
+ """
1277
+ if not self.__raw_filename:
1278
+ self.__raw_filename = self.__rawfilename(serial)
1279
+ bfilename = self.__raw_filename
1280
+ _, bfname = os.path.split(bfilename)
1281
+ if bfname.endswith(".tmp"):
1282
+ bfname = bfname[:-4]
1283
+ sname, fext = os.path.splitext(bfname)
1284
+ scanname = os.path.commonprefix(
1285
+ [sname.format(ScanID=11111111),
1286
+ sname.format(ScanID=99999999)])
1287
+ if '%' in scanname:
1288
+ try:
1289
+ scanname = os.path.commonprefix(
1290
+ [scanname % 11111111,
1291
+ scanname % 99999999])
1292
+ except Exception:
1293
+ pass
1294
+ if scanname.endswith("_"):
1295
+ scanname = scanname[:-1]
1296
+ return scanname
1297
+
1210
1298
  def __appendSciCatDataset(self, hostname=None):
1211
1299
  """ append dataset to SciCat ingestion list """
1212
1300
 
1301
+ sid = self.__vars["vars"]["scan_id"]
1213
1302
  fdir, fname = os.path.split(self.filename)
1214
- _, bfname = os.path.split(self.__base_filename)
1215
1303
  sname, fext = os.path.splitext(fname)
1216
1304
  beamtimeid = self.beamtimeid()
1217
1305
  defprefix = "scicat-datasets-"
@@ -1231,15 +1319,22 @@ class NXS_FileRecorder(BaseFileRecorder):
1231
1319
  variables = self.__getConfVar("ConfigVariables", None, True)
1232
1320
  if isinstance(variables, dict) and "entryname" in variables:
1233
1321
  entryname = variables["entryname"]
1234
- try:
1235
- scanname, _ = os.path.splitext(bfname % "")
1236
- except Exception:
1237
- scanname, _ = os.path.splitext(bfname)
1238
1322
 
1239
- if appendentry is True:
1323
+ scanname = self.__scanname(sid)
1324
+ # _, bfname = os.path.split(self.__base_filename)
1325
+ # try:
1326
+ # scanname, _ = os.path.splitext(bfname % "")
1327
+ # except Exception:
1328
+ # scanname, _ = os.path.splitext(bfname)
1329
+
1330
+ if appendentry is True and \
1331
+ '%' not in self.__raw_filename and \
1332
+ "{ScanID" not in self.__raw_filename:
1240
1333
  sid = self.__vars["vars"]["scan_id"]
1241
1334
  sname = "%s::/%s_%05i;%s_%05i" % (
1242
1335
  scanname, entryname, sid, scanname, sid)
1336
+ if "INIT" in self.skipAcquisitionModes:
1337
+ sname = "%s:%s" % (sname, time.time())
1243
1338
 
1244
1339
  # auto grouping
1245
1340
  grouping = bool(self.__getEnvVar('SciCatAutoGrouping', False))
@@ -1274,15 +1369,17 @@ class NXS_FileRecorder(BaseFileRecorder):
1274
1369
  def __createMeasurementFile(self):
1275
1370
  """ create measurement file """
1276
1371
 
1372
+ sid = self.__vars["vars"]["scan_id"]
1277
1373
  fdir, fname = os.path.split(self.filename)
1278
- _, bfname = os.path.split(self.__base_filename)
1279
1374
  sname, fext = os.path.splitext(fname)
1280
1375
  # beamtimeid = self.beamtimeid()
1281
1376
 
1282
- try:
1283
- scanname, _ = os.path.splitext(bfname % "")
1284
- except Exception:
1285
- scanname, _ = os.path.splitext(bfname)
1377
+ scanname = self.__scanname(sid)
1378
+ # _, bfname = os.path.split(self.__base_filename)
1379
+ # try:
1380
+ # scanname, _ = os.path.splitext(bfname % "")
1381
+ # except Exception:
1382
+ # scanname, _ = os.path.splitext(bfname)
1286
1383
 
1287
1384
  try:
1288
1385
  sm = dict(self.__getEnvVar('SciCatMeasurements', {}))
@@ -1295,10 +1392,10 @@ class NXS_FileRecorder(BaseFileRecorder):
1295
1392
  if isinstance(variables, dict) and "entryname" in variables:
1296
1393
  entryname = variables["entryname"]
1297
1394
  if appendentry is True:
1298
- sid = self.__vars["vars"]["scan_id"]
1299
- entryname = entryname + ("_%05i" % sid)
1300
- sname = sname + ("_%05i" % sid)
1301
-
1395
+ if '%' not in self.__raw_filename and \
1396
+ "{ScanID" not in self.__raw_filename:
1397
+ sname = sname + ("_%05i" % sid)
1398
+ entryname = entryname + ("_%05i" % sid)
1302
1399
  mntname = scanname
1303
1400
  if fdir in sm.keys() and sm[fdir]:
1304
1401
  mntname = sm[fdir]