Skip to content
Snippets Groups Projects
Commit bc90d70a authored by WHITFIELDRE email's avatar WHITFIELDRE email
Browse files

HB2AReduce allow exp to be omitted

When there is only one experiment in an IPTS you now don't need to set exp.
parent 0c43fa90
No related branches found
No related tags found
No related merge requests found
......@@ -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")
......@@ -64,10 +68,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
......@@ -78,6 +88,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]
......
......@@ -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
......
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