def test_that_good_input_is_accepted(self):
        # Arrange
        reducer = MockReducerQResolution()
        user_file = reduction_steps.UserFile()

        a1_val = 1
        a2_val = 2
        h1_val = 3
        w1_val = 4
        h2_val = 5
        w2_val = 6
        lcollim_val = 7
        delta_r_val = 8
        on_off_val = True
        values = ["QRESOL/A1=" + str(a1_val), "QRESOL/A2  =" + str(a2_val), "QRESOL/H1  =" + str(h1_val),
                  "QRESOL/W1 =" + str(w1_val), "QRESOL/H2=" + str(h2_val), "QRESOL/W2=  " + str(w2_val),
                  "QRESOL/LCOLLIM=  " + str(lcollim_val),"QRESOL/LCOLLIM=  " + str(lcollim_val),
                  "QRESOL/DELTAR=  " + str(delta_r_val),"QRESOL/ ON"]

        # Act
        for value in values:
            user_file.read_line(value, reducer)

        # Assert
        self.assertEqual(reducer.to_Q.a1,a1_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.a2,a2_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.h1,h1_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.h2,h2_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.w1,w1_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.w2,w2_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.delta_r,delta_r_val/1000., "Should be the input in meters")
        self.assertEqual(reducer.to_Q.collim,lcollim_val, "Should be the input in meters")
        self.assertEqual(reducer.to_Q.on_off,on_off_val, "Should be set to True")
Пример #2
0
 def test_that_non_float_type_for_a1_causes_error_warning(self):
     # Arrange
     reducer = MockReducerQResolution()
     user_file = reduction_steps.UserFile()
     a1_val = "sdf"
     value = "A1=" + str(a1_val)
     # Act
     error = user_file._read_q_resolution_line(value, reducer)
     # Assert
     self.assertNotEqual(error, None)
Пример #3
0
    def initialization(self):
        if i.ReductionSingleton().get_instrument() != 'SANS2D':
            i.ReductionSingleton.clean(isis_reducer.ISISReducer)
        i.ReductionSingleton().set_instrument(isis_instrument.SANS2D())

        i.ReductionSingleton.clean(isis_reducer.ISISReducer)
        i.ReductionSingleton().set_instrument(isis_instrument.SANS2D())
        i.ReductionSingleton().user_settings =isis_reduction_steps.UserFile(MASKFILE)
        i.ReductionSingleton().user_settings.execute(i.ReductionSingleton())
        return i
    def test_that_will_not_parse_DET_OVERLAP_with_three_subsequent_commands(self):
        # Arrange
        line = 'DET/OVERLAP 0.13 0.15 0.17'
        command_iface.Clean()
        command_iface.LOQ()
        user_file = reduction_steps.UserFile()

        # Act
        user_file.read_line(line=line, reducer=ReductionSingleton())
        merge_Range = ReductionSingleton().instrument.getDetector('FRONT').mergeRange

        # Assert
        self.assertEqual(merge_Range.q_min, None, 'The q_min should have been read in')
        self.assertEqual(merge_Range.q_max, None, 'The q_max should have been read in')
        self.assertEqual(merge_Range.q_merge_range, False, 'q_merge_range should be true')
    def test_can_parse_DET_OVERLAP_line(self):
        # Arrange
        line = 'DET/OVERLAP 0.13 0.15'
        command_iface.Clean()
        command_iface.LOQ()
        user_file = reduction_steps.UserFile()

        # Act
        user_file.read_line(line = line, reducer = ReductionSingleton())
        merge_Range = ReductionSingleton().instrument.getDetector('FRONT').mergeRange

        # Assert
        self.assertEqual(merge_Range.q_min, 0.13, 'The q_min should have been read in')
        self.assertEqual(merge_Range.q_max, 0.15, 'The q_max should have been read in')
        self.assertEqual(merge_Range.q_merge_range, True, 'q_merge_range should be true')
    def test_parse_line_for_back_trans_does_not_set_for_single_times(self):
        # Arrange
        start = 1000
        line = 'BACK/TRANS'+ str(start)
        command_iface.Clean()
        command_iface.LOQ()
        user_file = reduction_steps.UserFile()

        # Act
        user_file.read_line(line = line, reducer = ReductionSingleton())
        start_TOF_ROI, end_TOF_ROI = ReductionSingleton().inst.get_TOFs_for_ROI()

        # Assert
        self.assertEqual(None, start_TOF_ROI, 'The start time should not have been set')
        self.assertEqual(None, end_TOF_ROI, 'The end time should not have been set')
    def test_parse_line_for_back_trans(self):
        # Arrange
        start = 1000
        end = 2000
        line = 'BACK/TRANS'+ str(start) +' ' + str(end)
        command_iface.Clean()
        command_iface.LOQ()
        user_file = reduction_steps.UserFile()

        # Act
        user_file.read_line(line = line, reducer = ReductionSingleton())
        start_TOF_ROI, end_TOF_ROI = ReductionSingleton().inst.get_TOFs_for_ROI()

        # Assert
        self.assertEqual(start, start_TOF_ROI, 'The start time should be 1000 for ROI.')
        self.assertEqual(end, end_TOF_ROI, 'The end time should be 2000 for ROI.')
Пример #8
0
    def runTest(self):
        self.singleModePrepare()

        i.FindBeamCentre(rlow=41,
                         rupp=280,
                         MaxIter=3,
                         xstart=float(150) / 1000.,
                         ystart=float(-160) / 1000.,
                         tolerance=0.0001251)
        self.checkCentreResult()
        # clean up

        i.ReductionSingleton.clean(isis_reducer.ISISReducer)
        i.ReductionSingleton().set_instrument(isis_instrument.SANS2D())
        i.ReductionSingleton().user_settings = isis_reduction_steps.UserFile(
            sansgui.MASKFILE)
        i.ReductionSingleton().user_settings.execute(i.ReductionSingleton())