Example #1
0
 def prepset(self, subdir):
     self.config = {p: config[p] for p in ('default.facility',
                                           'default.instrument',
                                           'datasearch.directories')}
     config['default.facility'] = 'SNS'
     config['default.instrument'] = 'BASIS'
     config.appendDataSearchSubDir('BASIS/{}/'.format(subdir))
Example #2
0
 def setUpClass(cls):
     cls.workspaces_temporary = list(
     )  # workspaces to be deleted at tear-down
     # Load a CORELLI file containing data for bank number 20 (16 tubes)
     config.appendDataSearchSubDir('CORELLI/calibration')
     for directory in config.getDataSearchDirs():
         if 'UnitTest' in directory:
             data_dir = path.join(directory, 'CORELLI', 'calibration')
             break
     wire_positions_pixels = [
         0.03043, 0.04544, 0.06045, 0.07546, 0.09047, 0.10548, 0.12049,
         0.13550, 0.15052, 0.16553, 0.18054, 0.19555, 0.21056, 0.22557
     ]  # in mili-meters, 14 wires
     workspace = 'CORELLI_123455_bank20'
     LoadNexusProcessed(Filename=path.join(data_dir, workspace + '.nxs'),
                        OutputWorkspace=workspace)
     cls.workspaces_temporary.append(
         workspace)  # delete workspace at tear-down
     wire_positions_pixels = wire_positions(units='pixels')[1:-1]
     wire_count = len(wire_positions_pixels)
     fit_parameters = TubeCalibFitParams(wire_positions_pixels,
                                         height=-1000,
                                         width=4,
                                         margin=7)
     fit_parameters.setAutomatic(True)
     cls.corelli = {
         'workspace': workspace,
         'bank_name': 'bank20',
         'wire_positions': wire_positions(units='meters')[1:-1],
         'peaks_form': [1] *
         wire_count,  # signals we'll be fitting dips (peaks with negative heights)
         'fit_parameters': fit_parameters,
     }
Example #3
0
    def setUpClass(
            cls):  # called only before running all tests in the test case
        cls.workspaces_temporary = list(
        )  # workspaces to be deleted at tear-down

        # Single tube data. Tube dimensions appropriate for a CORELLI tube
        def y_quad(n: float) -> float:
            r"""
            Example quadratic function, returning the Y-coordinate (meters) versus pixel index `i

            y_quad(n) = c0 + c1 * n + c2 * n^2.
            Coefficients c0, c1, and c2 obtained by solving the following equations:
                y(0) = -0.502
                y(128) = 0.001
                y(255) = 0.393  # assume a tube with 256 pixels
            Obtaining:
                c0 = -0.502
                c1 = 0.00435287724834028
                c2 = -3.306169908908442e-06

            :param n: pixel coordinate
            """
            return -0.502 + 0.00435287724834028 * n - 3.306169908908442e-06 * n * n

        # assume 11 slits(wires) casting 11 peaks(shadows) onto the tube at the following pixel numbers
        tube_points = np.linspace(5, 245, 11,
                                  endpoint=True)  # 5, 29, 53,...,221, 245
        # assume the Y-coordinates of the peaks(shadows) given by our quadratic example function
        ideal_tube_coordinates = [y_quad(n) for n in tube_points]
        cls.y_quad_data = {
            'detector_count': 256,
            'peak_count': 11,
            'y_quad': y_quad,
            'coefficients': {
                'A0': -0.502,
                'A1': 0.00435287724834028,
                'A2': -3.306169908908442e-06
            },
            'tube_points': tube_points,
            'ideal_tube_coordinates': ideal_tube_coordinates
        }

        # Load a CORELLI file containing data for bank number 20 (16 tubes)
        config.appendDataSearchSubDir('CORELLI/calibration')
        for directory in config.getDataSearchDirs():
            if 'UnitTest' in directory:
                data_dir = path.join(directory, 'CORELLI', 'calibration')
                break
        workspace = 'CORELLI_123455_bank20'
        LoadNexusProcessed(Filename=path.join(data_dir, workspace + '.nxs'),
                           OutputWorkspace=workspace)
        assert AnalysisDataService.doesExist(workspace)
        cls.workspaces_temporary.append(
            workspace)  # delete workspace at tear-down
        cls.corelli = {
            'tube_length': 0.900466,  # in meters
            'pixels_per_tube': 256,
            'workspace': workspace
        }
Example #4
0
    def setUp(self):
        # these must be set, so the required files
        # without instrument name can be retrieved
        config['default.facility'] = 'ILL'
        config['default.instrument'] = 'IN16B'
        config.appendDataSearchSubDir('ILL/IN16B/')

        self.params = {'Tolerance': 1e-3, 'CheckInstrument': False}
Example #5
0
    def setUp(self):
        # cache default instrument and datadirs
        self.facility = config['default.facility']
        self.instrument = config['default.instrument']
        self.datadirs = config['datasearch.directories']

        config['default.facility'] = 'ILL'
        config['default.instrument'] = 'D20'
        config.appendDataSearchSubDir('ILL/D20/')
    def setUp(self):
        # these must be set, so the required files
        # without instrument name can be retrieved
        config['default.facility'] = 'ILL'
        config['default.instrument'] = 'IN16B'
        config.appendDataSearchSubDir('ILL/IN16B/')

        self.params = {'Tolerance':1e-3,
                       'CheckInstrument':False}
 def setUp(self):
     self.config = {
         p: config[p]
         for p in ('default.facility', 'default.instrument',
                   'datasearch.directories')
     }
     config['default.facility'] = 'SNS'
     config['default.instrument'] = 'BASIS'
     config.appendDataSearchSubDir('BASIS/BASISDiffraction')
    def setUpClass(cls):
        # cache the def instrument and data search dirs
        cls.facility = config['default.facility']
        cls.instrument = config['default.instrument']
        cls.data_dir = config['datasearch.directories']

        # set instrument and append datasearch directory
        config['default.facility'] = 'ILL'
        config['default.instrument'] = 'IN16B'
        config.appendDataSearchSubDir('ILL/IN16B/')
Example #9
0
 def setUpClass(cls) -> None:
     r"""
     Load the tests cases for calibrate_bank, consisting of data for only one bank
     CORELLI_124023_bank10, tube 13 has shadows at pixel numbers quite different from the rest
     """
     config.appendDataSearchSubDir('CORELLI/calibration')
     for directory in config.getDataSearchDirs():
         if 'UnitTest' in directory:
             data_dir = path.join(directory, 'CORELLI', 'calibration')
             break
     cls.workspaces_temporary = list()
     cls.cases = dict()
     for bank_case in ('124016_bank10', '123454_bank58', '124023_bank10', '124023_banks_14_15'):
         workspace = 'CORELLI_' + bank_case
         LoadNexusProcessed(Filename=path.join(data_dir, workspace + '.nxs'), OutputWorkspace=workspace)
         cls.cases[bank_case] = workspace
         cls.workspaces_temporary.append(workspace)
Example #10
0
    def setUpClass(cls):
        r"""
        Load the tests cases for calibrate_bank, consisting of data for only one bank
        CORELLI_123455_bank20, control bank, it has no problems
        CORELLI_123454_bank58, beam center intensity spills over adjacent tubes, tube15 and tube16
        CORELLI_124018_bank45, tube11 is not working at all
        CORELLI_123555_bank20, insufficient intensity for all tubes in the bank
        CORELLI_124023_bank10, tube 13 has shadows at pixel numbers quite different from the rest
        CORELLI_124023_bank14, wire shadows very faint, only slightly larger than fluctuations of the background
        CORELLI_124023_bank15, one spurious shadow in tube14
        Load the test case for calibrate_banks, consisting of data for two banks
        CORELLI_124023_banks_14_15
        """
        config.appendDataSearchSubDir('CORELLI/calibration')
        for directory in config.getDataSearchDirs():
            if 'UnitTest' in directory:
                data_dir = path.join(directory, 'CORELLI', 'calibration')
                break
        cls.cases = dict()
        for bank_case in ('123454_bank58', '124018_bank45', '123555_bank20', '123455_bank20',
                          '124023_bank10', '124023_bank14', '124023_bank15', '124023_banks_14_15'):
            workspace = 'CORELLI_' + bank_case
            LoadNexusProcessed(Filename=path.join(data_dir, workspace + '.nxs'), OutputWorkspace=workspace)
            cls.cases[bank_case] = workspace

        def assert_missing_tube(cls_other, calibration_table, tube_number):
            r"""Check detector ID's from a failing tube are not in the calibration table"""
            table = mtd[str(calibration_table)]
            first = table.cell('Detector ID', 0)  # first detector ID
            # Would-be first and last detectors ID's for the failing tube
            begin, end = first + (tube_number - 1) * 256, first + tube_number * 256 - 1
            detectors_ids = table.column(0)
            assert begin not in detectors_ids
            assert end not in detectors_ids
        # sneak in a class method, make sure it's loaded before any tests is executed
        cls.assert_missing_tube = assert_missing_tube
Example #11
0
 def setUp(self):
     # set instrument and append datasearch directory
     config['default.facility'] = 'ILL'
     config['default.instrument'] = 'IN16B'
     config.appendDataSearchSubDir('ILL/IN16B/')
 def setUp(self):
     # these must be set, so the required files
     # without instrument name can be retrieved
     config['default.facility'] = 'ILL'
     config['default.instrument'] = 'IN16B'
     config.appendDataSearchSubDir('ILL/IN16B/')
Example #13
0
 def setUp(self):
     config['default.facility'] = 'ILL'
     config['default.instrument'] = 'D20'
     config.appendDataSearchSubDir('ILL/D20/')
 def setUp(self):
     # set instrument and append datasearch directory
     config['default.facility'] = 'ILL'
     config['default.instrument'] = 'IN16B'
     config.appendDataSearchSubDir('ILL/IN16B/')
 def setUp(self):
     # these must be set, so the required files
     # without instrument name can be retrieved
     config['default.facility'] = 'ILL'
     config['default.instrument'] = 'IN16B'
     config.appendDataSearchSubDir('ILL/IN16B/')
Example #16
0
 def setUp(self):
     config['default.facility'] = 'ILL'
     config['default.instrument'] = 'D20'
     config.appendDataSearchSubDir('ILL/D20/')
     self._m_tmp_file = path.join(gettempdir(), 'D20Calib1stIteration.nxs')
 def setUpClass(cls):
     config.appendDataSearchSubDir('ILL/D20/')