diff --git a/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py b/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py index f5b51c48449b725d9ee58e5d71eb89b69b52931b..3b363b2b0e62d125d5f19242827cc24b1193eb81 100644 --- a/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py +++ b/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py @@ -36,9 +36,13 @@ class HB2AReduce(PythonAlgorithm): def PyInit(self): self.declareProperty(MultipleFileProperty(name="Filename", action=FileAction.OptionalLoad, extensions=[".dat"]), "Data files to load") + condition = EnabledWhenProperty("Filename", PropertyCriterion.IsDefault) self.declareProperty('IPTS', Property.EMPTY_INT, "IPTS number to load from") + self.setPropertySettings("IPTS", condition) self.declareProperty('Exp', Property.EMPTY_INT, "Experiment number to load from") + self.setPropertySettings("Exp", condition) self.declareProperty(IntArrayProperty("ScanNumbers", []), 'Scan numbers to load') + self.setPropertySettings("ScanNumbers", condition) self.declareProperty(FileProperty(name="Vanadium", defaultValue="", action=FileAction.OptionalLoad, extensions=[".dat", ".txt"]), doc="Vanadium file, can be either the vanadium scan file or the reduced vcorr file. " "If not provided the vcorr file adjacent to the data file will be used") @@ -66,10 +70,16 @@ class HB2AReduce(PythonAlgorithm): issues = dict() if not self.getProperty("Filename").value: - if ((self.getProperty("IPTS").value == Property.EMPTY_INT) or - (self.getProperty("Exp").value == Property.EMPTY_INT) or - len(self.getProperty("ScanNumbers").value) is 0): - issues["Filename"] = 'Must specify either Filename or IPTS AND Exp AND ScanNumbers' + ipts = self.getProperty("IPTS").value + + if ((ipts == Property.EMPTY_INT) or len(self.getProperty("ScanNumbers").value) is 0): + issues["Filename"] = 'Must specify either Filename or IPTS AND ScanNumbers' + + if self.getProperty("Exp").value == Property.EMPTY_INT: + exp_list = sorted(e for e in os.listdir('/HFIR/HB2A/IPTS-{0}'.format(ipts)) if 'exp' in e) + if len(exp_list)>1: + exps = ','.join(e.replace('exp','') for e in exp_list) + issues["Exp"] = 'Multiple experiments found in IPTS-{}. You must set Exp to one of {}'.format(ipts, exps) return issues @@ -80,6 +90,8 @@ class HB2AReduce(PythonAlgorithm): if not filenames: ipts = self.getProperty("IPTS").value exp = self.getProperty("Exp").value + if self.getProperty("Exp").value == Property.EMPTY_INT: + exp = int([e for e in os.listdir('/HFIR/HB2A/IPTS-{0}'.format(ipts)) if 'exp' in e][0].replace('exp','')) filenames = ['/HFIR/HB2A/IPTS-{0}/exp{1}/Datafiles/HB2A_exp{1:04}_scan{2:04}.dat'.format(ipts, exp, scan) for scan in self.getProperty("ScanNumbers").value] diff --git a/docs/source/algorithms/HB2AReduce-v1.rst b/docs/source/algorithms/HB2AReduce-v1.rst index 2f7a8f32c5520b5401df116cbb2f7fccffdb6895..1b09da2ab887bce26c5a2492651e32972cef127d 100644 --- a/docs/source/algorithms/HB2AReduce-v1.rst +++ b/docs/source/algorithms/HB2AReduce-v1.rst @@ -11,7 +11,7 @@ Description This algorithm reduces HFIR POWDER (HB-2A) data. -You can either specify the filenames of data you want to reduce or provide the IPTS, exp and scan number. *e.g.* the following are equivalent: +You can either specify the filenames of data you want to reduce or provide the IPTS, exp and scan number. If only one experiment exists in an IPTS then exp can be omitted. *e.g.* the following are equivalent: .. code-block:: python