From 67efbf38caa038c803a9341ae70c07d66f7947cd Mon Sep 17 00:00:00 2001 From: Jan Kotanski Date: Fri, 19 Jul 2024 08:03:40 +0200 Subject: [PATCH] add ScanNamesNoMetadata and ScanNamesNoGrouping variable --- ChangeLog | 4 ++++ README.rst | 8 ++++++- man/sardananxsrecorder.1 | 39 +++++++++++++++++++------------ sardananxsrecorder/__init__.py | 2 +- sardananxsrecorder/nxsrecorder.py | 30 +++++++++++++++--------- 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1c2e07..02fd462 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-07-19 Jan Kotanski + * add ScanNamesNoMetadata and ScanNamesNoGrouping variables (#145) + * tagged as 3.29.0 + 2024-07-15 Jan Kotanski * do not restart the measurement in the grouping mode (#142) * tagged as 3.28.1 diff --git a/README.rst b/README.rst index 606ccae..2e5344b 100644 --- a/README.rst +++ b/README.rst @@ -227,4 +227,10 @@ The NeXus file recorder uses the following sardana environment variables * **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 * **NeXusWriterModes** *(list)* - a list of strategy modes e.g. ``NOINIT``, ``NOSTEP``, ``NOFINAL``, ``MESH``, ``VDS`` separated by commas - +* **ScanNames** *(bool)* - special mode of using ScanName directories i.e. + * ``True``: the master file in ScanName directory, + * ``False``: Themaster file in grouping ScanName directory, + * ``None`` (or undefined): standard mode where the master files are outside ScanName directory +* **ScanNamesNoGrouping** *(bool)* - do not perform grouping when ``ScanNames`` is ``False`` +* **ScanNamesNoMetadata** *(bool)* - do not perform master file metadata ingestion when ``ScanNames`` is ``False`` + diff --git a/man/sardananxsrecorder.1 b/man/sardananxsrecorder.1 index dc84047..05abb0b 100644 --- a/man/sardananxsrecorder.1 +++ b/man/sardananxsrecorder.1 @@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "SARDANANXSRECORDER" "1" "Jul 14, 2024" "3.28" "Sardana NeXus Recorder" +.TH "SARDANANXSRECORDER" "1" "Jul 19, 2024" "3.29" "Sardana NeXus Recorder" .SH NAME sardananxsrecorder \- sardananxsrecorder Documentation .sp @@ -359,6 +359,15 @@ The NeXus file recorder uses the following sardana environment variables \fBNeXusMeshScanID\fP \fI(int)\fP \- ScanID used for composed scans e.g. mesh scan combined from many linear scans .IP \(bu 2 \fBNeXusWriterModes\fP \fI(list)\fP \- a list of strategy modes e.g. \fBNOINIT\fP, \fBNOSTEP\fP, \fBNOFINAL\fP, \fBMESH\fP, \fBVDS\fP separated by commas +.IP \(bu 2 +\fBScanNames\fP \fI(bool)\fP \- special mode of using ScanName directories i.e. +* \fBTrue\fP: the master file in ScanName directory, +* \fBFalse\fP: Themaster file in grouping ScanName directory, +* \fBNone\fP (or undefined): standard mode where the master files are outside ScanName directory +.IP \(bu 2 +\fBScanNamesNoGrouping\fP \fI(bool)\fP \- do not perform grouping when \fBScanNames\fP is \fBFalse\fP +.IP \(bu 2 +\fBScanNamesNoMetadata\fP \fI(bool)\fP \- do not perform master file metadata ingestion when \fBScanNames\fP is \fBFalse\fP .UNINDENT .sp Contents: @@ -380,9 +389,9 @@ constructor .B Parameters .INDENT 7.0 .IP \(bu 2 -\fBfilename\fP (\fI\%str\fP) – ScanFile name +\fBfilename\fP (\fI\%str\fP) \-\- ScanFile name .IP \(bu 2 -\fBmacro\fP (\fI\%sardana.macroserver.macro.Macro\fP) – macro object +\fBmacro\fP (\fI\%sardana.macroserver.macro.Macro\fP) \-\- macro object .UNINDENT .UNINDENT .INDENT 7.0 @@ -394,13 +403,13 @@ adds custom data to configuration variables, i.e. from macros .B Parameters .INDENT 7.0 .IP \(bu 2 -\fBvalue\fP (\fIany\fP) – variable value +\fBvalue\fP (\fIany\fP) \-\- variable value .IP \(bu 2 -\fBname\fP (\fI\%str\fP) – variable name +\fBname\fP (\fI\%str\fP) \-\- variable name .IP \(bu 2 -\fBgroup\fP (\fI\%str\fP) – variable group inside variable dictionary +\fBgroup\fP (\fI\%str\fP) \-\- variable group inside variable dictionary .IP \(bu 2 -\fBremove\fP (\fI\%bool\fP) – if True variable will be removed +\fBremove\fP (\fI\%bool\fP) \-\- if True variable will be removed .UNINDENT .UNINDENT .UNINDENT @@ -415,7 +424,7 @@ and closes the nexus file .INDENT 7.0 .TP .B Parameters -\fBrecordlist\fP (\fBsardana.macroserver.scan.scandata.RecordList\fP) – sardana record list +\fBrecordlist\fP (\fBsardana.macroserver.scan.scandata.RecordList\fP) \-\- sardana record list .UNINDENT .UNINDENT .INDENT 7.0 @@ -429,7 +438,7 @@ and records in INIT mode .INDENT 7.0 .TP .B Parameters -\fBrecordlist\fP (\fBsardana.macroserver.scan.scandata.RecordList\fP) – sardana record list +\fBrecordlist\fP (\fBsardana.macroserver.scan.scandata.RecordList\fP) \-\- sardana record list .UNINDENT .UNINDENT .INDENT 7.0 @@ -443,7 +452,7 @@ and records in INIT mode .INDENT 7.0 .TP .B Parameters -\fBrecord\fP (\fBsardana.macroserver.scan.scandata.Record\fP) – sardana record list +\fBrecord\fP (\fBsardana.macroserver.scan.scandata.Record\fP) \-\- sardana record list .UNINDENT .UNINDENT .INDENT 7.0 @@ -501,12 +510,12 @@ indent level. An indent level of 0 will only insert newlines. None is the most compact representation. .sp If specified, separators should be an (item_separator, key_separator) -tuple. The default is (’, ‘, ‘: ‘) if \fIindent\fP is \fBNone\fP and -(‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, -you should specify (‘,’, ‘:’) to eliminate whitespace. +tuple. The default is (\(aq, \(aq, \(aq: \(aq) if \fIindent\fP is \fBNone\fP and +(\(aq,\(aq, \(aq: \(aq) otherwise. To get the most compact JSON representation, +you should specify (\(aq,\(aq, \(aq:\(aq) to eliminate whitespace. .sp If specified, default is a function that gets called for objects -that can’t otherwise be serialized. It should return a JSON encodable +that can\(aqt otherwise be serialized. It should return a JSON encodable version of the object or raise a \fBTypeError\fP\&. .INDENT 7.0 .TP @@ -515,7 +524,7 @@ default encoder .INDENT 7.0 .TP .B Parameters -\fBobj\fP (\fI\%object\fP or \fIany\fP) – numpy array object +\fBobj\fP (\fI\%object\fP or \fIany\fP) \-\- numpy array object .UNINDENT .UNINDENT .UNINDENT diff --git a/sardananxsrecorder/__init__.py b/sardananxsrecorder/__init__.py index abe315e..17706a3 100644 --- a/sardananxsrecorder/__init__.py +++ b/sardananxsrecorder/__init__.py @@ -20,4 +20,4 @@ """ Sardana Scan Recorders """ #: package version -__version__ = "3.28.1" +__version__ = "3.29.0" diff --git a/sardananxsrecorder/nxsrecorder.py b/sardananxsrecorder/nxsrecorder.py index 5beee2b..2527550 100644 --- a/sardananxsrecorder/nxsrecorder.py +++ b/sardananxsrecorder/nxsrecorder.py @@ -1348,6 +1348,8 @@ def __appendSciCatDataset(self, hostname=None): sid = self.__serial fdir, fname = os.path.split(self.filename) snmode = self.__getEnvVar("ScanNames", None) + nometa = self.__getEnvVar("ScanNamesNoMetadata", False) + nogrouping = self.__getEnvVar("ScanNamesNoGrouping", False) appendentry = self.__getConfVar("AppendEntry", False) pdir = None if snmode is not None: @@ -1406,22 +1408,28 @@ def __appendSciCatDataset(self, hostname=None): if fdir in sm.keys(): cgrp = sm[fdir] if cgrp != scanname: - commands.append("__command__ stop") - commands.append("%s:%s" % (cgrp, time.time())) - commands.append("__command__ start %s" % scanname) + if not nogrouping and not nometa: + commands.append("__command__ stop") + commands.append("%s:%s" % (cgrp, time.time())) + commands.append("__command__ start %s" % scanname) else: - commands.append("__command__ start %s" % scanname) - commands.append(sname) - commands.append("__command__ stop") - commands.append("%s:%s" % (scanname, time.time())) - # commands.append("__command__ start %s" % scanname) + if not nogrouping and not nometa: + commands.append("__command__ start %s" % scanname) + if not nometa: + commands.append(sname) + if not nogrouping and not nometa: + commands.append("__command__ stop") + if not nogrouping: + commands.append("%s:%s" % (scanname, time.time())) sname = "\n".join(commands) - sm[fdir] = scanname + if not nogrouping and not nometa: + sm[fdir] = scanname self.__env['SciCatMeasurements'] = sm - with open(dslfile, "a+") as fl: - fl.write("\n%s" % sname) + if sname: + with open(dslfile, "a+") as fl: + fl.write("\n%s" % sname) def __createMeasurementFile(self): """ create measurement file """