diff --git a/scripts/SANS/sans/user_file/state_director.py b/scripts/SANS/sans/user_file/state_director.py index 606b58507669c9d0e59e1f7c1683c7a08f88c9a2..8ca3dd696f396185d9df84b0c3d3c5452298b9ae 100644 --- a/scripts/SANS/sans/user_file/state_director.py +++ b/scripts/SANS/sans/user_file/state_director.py @@ -666,8 +666,8 @@ class StateDirectorISIS(object): start_times_hab.append(times.start) stop_times_hab.append(times.stop) elif times.detector_type is DetectorType.LAB: - start_times_hab.append(times.start) - stop_times_hab.append(times.stop) + start_times_lab.append(times.start) + stop_times_lab.append(times.stop) else: RuntimeError("UserFileStateDirector: The specified detector {0} is not " "known".format(times.detector_type)) diff --git a/scripts/SANS/sans/user_file/user_file_parser.py b/scripts/SANS/sans/user_file/user_file_parser.py index 0dafbe2c88eb78571b32ef9449ff9ea6e2b1d4ec..7365bc41db2cb07b7541ac9bcb8c701f10cba861 100644 --- a/scripts/SANS/sans/user_file/user_file_parser.py +++ b/scripts/SANS/sans/user_file/user_file_parser.py @@ -839,9 +839,10 @@ class MaskParser(UserFileComponentParser): # Time Mask self._time_or_t = "\\s*(TIME|T)\\s*" - self._detector_time = "\\s*((" + self._hab + "|" + self._lab + ")"+"\\s*/\\s*)?\\s*" - self._time_pattern = re.compile(start_string + self._detector_time + self._time_or_t + space_string + - self._two_floats + end_string) + self._detector_time = "\\s*((" + self._hab + "|" + self._lab + ")"+"\\s*)?\\s*" + self._time_pattern = re.compile(start_string + self._detector_time + "/?" + self._time_or_t + space_string + + self._two_floats + end_string + "|" + start_string + self._time_or_t + + "/?" + self._detector_time + space_string + self._two_floats + end_string) # Block mask self._v_plus_h = "\\s*" + self._v + integer_number + "\\s*\\+\\s*" + self._h + integer_number @@ -859,7 +860,6 @@ class MaskParser(UserFileComponentParser): def parse_line(self, line): # Get the settings, ie remove command setting = UserFileComponentParser.get_settings(line, MaskParser.get_type_pattern()) - # Determine the qualifier and extract the user setting if self._is_block_mask(setting): output = self._extract_block_mask(setting) @@ -983,12 +983,13 @@ class MaskParser(UserFileComponentParser): if has_hab is not None or has_lab is not None: key = MaskId.time_detector detector_type = DetectorType.HAB if has_hab is not None else DetectorType.LAB - regex_string = "\s*(" + self._hab + ")\s*/\s*" if has_hab else "\s*(" + self._lab + ")\s*/\s*" + regex_string = "\s*(" + self._hab + ")\s*" if has_hab else "\s*(" + self._lab + ")\s*" min_and_max_time_range = re.sub(regex_string, "", line) else: key = MaskId.time detector_type = None min_and_max_time_range = line + min_and_max_time_range = re.sub("\s*/\s*", "", min_and_max_time_range) min_and_max_time_range = re.sub(self._time_or_t, "", min_and_max_time_range) min_and_max_time = extract_float_range(min_and_max_time_range) return {key: range_entry_with_detector(start=min_and_max_time[0], stop=min_and_max_time[1], diff --git a/scripts/test/SANS/user_file/user_file_parser_test.py b/scripts/test/SANS/user_file/user_file_parser_test.py index 918eec84912c2b7f6bc369638304f4678af530a2..18d8ec015d110cb7f3eea8028401afa35f7ed917 100644 --- a/scripts/test/SANS/user_file/user_file_parser_test.py +++ b/scripts/test/SANS/user_file/user_file_parser_test.py @@ -8,7 +8,7 @@ from sans.user_file.user_file_parser import (DetParser, LimitParser, MaskParser, MaskFileParser, MonParser, PrintParser, BackParser, SANS2DParser, LOQParser, UserFileParser, LARMORParser, CompatibilityParser) from sans.user_file.settings_tags import (DetectorId, BackId, range_entry, back_single_monitor_entry, - single_entry_with_detector, mask_angle_entry, LimitsId, rebin_string_values, + single_entry_with_detector, mask_angle_entry, LimitsId, simple_range, complex_range, MaskId, mask_block, mask_block_cross, mask_line, range_entry_with_detector, SampleId, SetId, set_scales_entry, position_entry, TransId, TubeCalibrationFileId, QResolutionId, FitId, @@ -316,7 +316,11 @@ class MaskParserTest(unittest.TestCase): "MASK/REAR/T 13 35": {MaskId.time_detector: range_entry_with_detector(start=13, stop=35, detector_type=DetectorType.LAB)}, "MASK/FRONT/TIME 33 35": {MaskId.time_detector: range_entry_with_detector(start=33, stop=35, - detector_type=DetectorType.HAB)} + detector_type=DetectorType.HAB)}, + "MASK/TIME/REAR 13 35": {MaskId.time_detector: range_entry_with_detector(start=13, stop=35, + detector_type=DetectorType.LAB)}, + "MASK/T/FRONT 33 35": {MaskId.time_detector: range_entry_with_detector(start=33, stop=35, + detector_type=DetectorType.HAB)} } invalid_settings = {"MASK/TIME 12 34 4 ": RuntimeError, @@ -1069,5 +1073,6 @@ class UserFileParserTest(unittest.TestCase): # Act + Assert self.assertRaises(ValueError, user_file_parser.parse_line, "DetT/DKDK/ 23 23") + if __name__ == "__main__": unittest.main()