Skip to content
Snippets Groups Projects
Unverified Commit dce0cec6 authored by Savici, Andrei T.'s avatar Savici, Andrei T. Committed by GitHub
Browse files

Merge pull request #23502 from rosswhitfield/HB2AReduce_find_exp

HB2AReduce allow exp to be omitted
parents 10e71b95 bc90d70a
No related branches found
No related tags found
No related merge requests found
...@@ -36,9 +36,13 @@ class HB2AReduce(PythonAlgorithm): ...@@ -36,9 +36,13 @@ class HB2AReduce(PythonAlgorithm):
def PyInit(self): def PyInit(self):
self.declareProperty(MultipleFileProperty(name="Filename", action=FileAction.OptionalLoad, self.declareProperty(MultipleFileProperty(name="Filename", action=FileAction.OptionalLoad,
extensions=[".dat"]), "Data files to load") extensions=[".dat"]), "Data files to load")
condition = EnabledWhenProperty("Filename", PropertyCriterion.IsDefault)
self.declareProperty('IPTS', Property.EMPTY_INT, "IPTS number to load from") 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.declareProperty('Exp', Property.EMPTY_INT, "Experiment number to load from")
self.setPropertySettings("Exp", condition)
self.declareProperty(IntArrayProperty("ScanNumbers", []), 'Scan numbers to load') self.declareProperty(IntArrayProperty("ScanNumbers", []), 'Scan numbers to load')
self.setPropertySettings("ScanNumbers", condition)
self.declareProperty(FileProperty(name="Vanadium", defaultValue="", action=FileAction.OptionalLoad, extensions=[".dat", ".txt"]), 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. " 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") "If not provided the vcorr file adjacent to the data file will be used")
...@@ -66,10 +70,16 @@ class HB2AReduce(PythonAlgorithm): ...@@ -66,10 +70,16 @@ class HB2AReduce(PythonAlgorithm):
issues = dict() issues = dict()
if not self.getProperty("Filename").value: if not self.getProperty("Filename").value:
if ((self.getProperty("IPTS").value == Property.EMPTY_INT) or ipts = self.getProperty("IPTS").value
(self.getProperty("Exp").value == Property.EMPTY_INT) or
len(self.getProperty("ScanNumbers").value) is 0): if ((ipts == Property.EMPTY_INT) or len(self.getProperty("ScanNumbers").value) is 0):
issues["Filename"] = 'Must specify either Filename or IPTS AND Exp AND ScanNumbers' 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 return issues
...@@ -80,6 +90,8 @@ class HB2AReduce(PythonAlgorithm): ...@@ -80,6 +90,8 @@ class HB2AReduce(PythonAlgorithm):
if not filenames: if not filenames:
ipts = self.getProperty("IPTS").value ipts = self.getProperty("IPTS").value
exp = self.getProperty("Exp").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) 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] for scan in self.getProperty("ScanNumbers").value]
......
...@@ -11,7 +11,7 @@ Description ...@@ -11,7 +11,7 @@ Description
This algorithm reduces HFIR POWDER (HB-2A) data. 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 .. code-block:: python
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment