Unverified Commit 8383cf1f authored by Jenna Delozier's avatar Jenna Delozier Committed by GitHub
Browse files

Merge pull request #30998 from mantidproject/PD195_filename_update

 Update filenames to match new convention - ornl-next
parents 1d14a3d5 3ce25838
......@@ -14,6 +14,7 @@ from mantid import logger
import numpy as np
import datetime
import os
import os.path
import re
import warnings
......@@ -229,7 +230,7 @@ class HB2AReduce(PythonAlgorithm):
# Get either vcorr file or vanadium data
vanadium_count, vanadium_monitor, vcorr = self.get_vanadium(detector_mask, data['m1'][0],
data['colltrans'][0], exp,
indir)
indir, metadata)
def_x = self.getProperty("DefX").value
if not def_x:
......@@ -318,7 +319,7 @@ class HB2AReduce(PythonAlgorithm):
detector_mask[exclude_detectors - 1] = False
return detector_mask
def get_vanadium(self, detector_mask, m1, colltrans, exp, indir):
def get_vanadium(self, detector_mask, m1, colltrans, exp, indir, metadata):
"""
This function returns either (vanadium_count, vanadium_monitor, None) or
(None, None, vcorr) depending what type of file is provided by getProperty("Vanadium")
......@@ -341,11 +342,21 @@ class HB2AReduce(PythonAlgorithm):
# m1 = 0 -> Ge 115, 1.54A
# m1 = 9.45 -> Ge 113, 2.41A
# colltrans is the collimator position, whether in or out of the beam
# colltrans = 0 -> IN
# colltrans = +/-80 -> OUT
vcorr_filename = 'HB2A_{}__Ge_{}_{}_vcorr.txt'.format(
exp, 115 if np.isclose(m1, 0, atol=0.1) else 113,
"IN" if np.isclose(colltrans, 0, atol=0.1) else "OUT")
new_convention = np.datetime64(datetime.datetime(2021, 2, 23))
date_created = self.get_date(metadata)
if date_created >= new_convention:
# colltrans = 0 -> OUT
# colltrans = +/-80 -> IN
vcorr_filename = 'HB2A_{}__Ge_{}_{}_vcorr.txt'.format(
exp, 115 if np.isclose(m1, 0, atol=0.1) else 113,
"OUT" if np.isclose(colltrans, 0, atol=0.1) else "IN")
elif date_created < new_convention:
# colltrans = +/-80 -> OUT
# colltrans = 0 -> IN
vcorr_filename = 'HB2A_{}__Ge_{}_{}_vcorr.txt'.format(
exp, 115 if np.isclose(m1, 0, atol=0.1) else 113,
"IN" if np.isclose(colltrans, 0, atol=0.1) else "OUT")
vcorr_filename = os.path.join(indir, vcorr_filename)
logger.notice("Using vcorr file: {}".format(vcorr_filename))
if not os.path.isfile(vcorr_filename):
......@@ -353,6 +364,13 @@ class HB2AReduce(PythonAlgorithm):
return None, None, np.genfromtxt(vcorr_filename)[detector_mask]
def get_date(self, metadata):
# Get correct start time
date_created = np.datetime64(
datetime.datetime.strptime(metadata['time'] + ' ' + metadata['date'],
'%I:%M:%S %p %m/%d/%Y'))
return date_created
def process(self,
counts,
scale,
......
......@@ -113,6 +113,12 @@ class HB2AReduceTest(unittest.TestCase):
os.path.exists(os.path.join(self._default_save_directory, f"{HB2AReduce_ws}.gss")))
HB2AReduce_ws.delete()
def test_new_convention(self):
HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat',
IndividualDetectors=True,
SaveData=False)
HB2AReduce_ws.delete()
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment