Ejemplo n.º 1
0
    def runTest(self):
    #here we are testing the LOQ setup
        ici.LOQ()
    #rear detector
        ici.Detector("main-detector-bank")
    #test batch mode, although only the analysis from the last line is checked
    # Find the file , this should really be in the BatchReduce reduction step

        f = open(self.csv_file,'w')
        print("sample_sans,99630-add,output_as, %s"%self.output_file, file=f)
        f.close()
        runnum = '99630'
        sansadd.add_runs((runnum, runnum),'LOQ','.RAW')

        ici.Set1D()
        ici.MaskFile('MASK.094AA')
        batch.BatchReduce(self.csv_file, 'nxs', plotresults=False, saveAlgs={'SaveNexus':'nxs'})

        print(' reduction without')

        ici._refresh_singleton()

        ici.LOQ()
        ici.Detector("main-detector-bank")
        ici.Set1D()
        ici.MaskFile('MASK.094AA')
        LOQ99630 = Load(runnum)
        LOQ99630 += LOQ99630
        ici.AssignSample(LOQ99630, reload=False)
        self.result = ici.WavRangeReduction()
Ejemplo n.º 2
0
    def test_full_setup_for_circular_apertures(self):
        # Arrange
        command_iface.Clean()
        command_iface.SANS2D()
        a1 = 2 # in mm
        a2 = 3 # in mm
        delta_r = 4 # in mm
        collimation_length = 10 # in m
        norm = reduction_steps.CalculateNormISIS()
        ReductionSingleton().to_Q = reduction_steps.ConvertToQISIS(norm)

        # Act
        command_iface.set_q_resolution_a1(a1 = a1)
        command_iface.set_q_resolution_a2(a2 = a2)
        command_iface.set_q_resolution_delta_r(delta_r = delta_r)
        command_iface.set_q_resolution_collimation_length(collimation_length = collimation_length)
        command_iface.set_q_resolution_use(use = True)
        ReductionSingleton().to_Q._set_up_q_resolution_parameters()

        # Assert
        a1_stored = ReductionSingleton().to_Q.get_q_resolution_a1() # in m 
        a1_expected = a1/1000.
        self.assertEqual(a1_stored, a1_expected)

        a2_stored = ReductionSingleton().to_Q.get_q_resolution_a2() # in m
        a2_expected = a2/1000.
        self.assertEqual(a2_stored, a2_expected)

        collimation_length_stored = ReductionSingleton().to_Q.get_q_resolution_collimation_length() # in m
        collimation_length_expected = collimation_length
        self.assertEqual(collimation_length_stored, collimation_length_expected)

        delta_r_stored = ReductionSingleton().to_Q.get_q_resolution_delta_r() # in m
        delta_r_expected = delta_r/1000.
        self.assertEqual(delta_r_stored, delta_r_expected)
 def test_that_correct_setting_can_be_passed_in(self):
     # Arrange
     run_number = "test12345"
     is_time = True
     is_mon = True
     is_mean = False
     mon_numbers = None
     command_iface.Clean()
     command_iface.LOQ()
     # Act
     command_iface.set_background_correction(run_number, is_time, is_mon, is_mean, mon_numbers)
     # Assert
     self._do_test_correct_setting(run_number, is_time, is_mon, is_mean, mon_numbers)
Ejemplo n.º 4
0
    def test_time_shifts_for_added_event_files(self):
        # Check for correct input
        shifts = '12, 13, 14'
        num_files = 4
        output = i.check_time_shifts_for_added_event_files(number_of_files = num_files, time_shifts=shifts)
        self.assertTrue(not output)

        # Check warning is produced for mismatch in number of shifts and files, ideally #shifts = N-1 and #files=N
        shifts2 = '12, 13'
        num_files2 = 4
        output2 = i.check_time_shifts_for_added_event_files(number_of_files = num_files2, time_shifts=shifts2)
        self.assertTrue(output2.startswith('Error: Expected N-1 time shifts '))

        # Check error is produced for lexically incorrect shifts, ie shifts which cannot be converted to float
        shifts3 = '12, 13, a'
        num_files3 = 4
        output3 = i.check_time_shifts_for_added_event_files(number_of_files = num_files3, time_shifts=shifts3)
        self.assertTrue(output3.startswith('Error: Elements of the time'))
Ejemplo n.º 5
0
    def runTest(self):
        self._success = False
        config["default.instrument"] = "SANS2D"
        ici.SANS2D()
        ici.MaskFile('MaskSANS2DReductionGUI.txt')
        ici.SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0)
        ici.SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0)
        ici.Gravity(False)
        ici.Set1D()

        ici.add_runs(('22048', '22023') ,'SANS2D', 'nxs', saveAsEvent=True)

        ici.AssignSample('22023-add.nxs')

        ici.WavRangeReduction(4.6, 12.85, False)

        # Need to do validation ourselves since we have to compare to sets of workspace-file pairs
        if self._validateWorkspaceToNeXusCustom():
            self._success = True
Ejemplo n.º 6
0
 def test_that_histogram_workspace_is_detected(self):
     # Arrange
     ws = CreateSampleWorkspace()
     self.addSampleLogEntry('proton_charge', ws, "2010-01-01T00:00:00", 0.0)
     file_name = self._create_file_name('dummy')
     SaveNexus(Filename= file_name, InputWorkspace=ws)
     # Act
     result = command_iface.check_if_event_workspace(file_name)
     self.assertFalse(result)
     # Clean Up
     self._clean_up(file_name)
     DeleteWorkspace(ws)
Ejemplo n.º 7
0
    def test_qx(self):  # GUI: q_min, q_max, q_dq, q_rebin, q_dq_opt
        def checkvalues(min_value, max_value, step_value, str_values):
            list_values = str_values.split(',')
            self.checkFloat(min_value, float(list_values[0]))
            self.checkFloat(max_value, float(list_values[2]))
            self.checkFloat(step_value, float(list_values[1]))

        def checklistvalues(str1, str2):
            list_v1 = str1.split(',')
            list_v2 = str2.split(',')
            self.checkFloat(len(list_v1), len(list_v2))
            for j in range(len(list_v1)):
                self.checkFloat(float(list_v1[j]), float(list_v2[j]))

        min_value, max_value, step_value = 0.01, 2.8, 0.02
        opt_pattern = "%f %f %f/%s"
        option = 'LIN'
        min_max_step_option = opt_pattern % (min_value, max_value, step_value,
                                             option)
        i.ReductionSingleton().user_settings.readLimitValues(
            'L/Q ' + min_max_step_option, i.ReductionSingleton())
        checkvalues(min_value, max_value, step_value,
                    i.ReductionSingleton().to_Q.binning)

        option = 'LOG'
        min_max_step_option = opt_pattern % (min_value, max_value, step_value,
                                             option)
        i.ReductionSingleton().user_settings.readLimitValues(
            'L/Q ' + min_max_step_option, i.ReductionSingleton())
        checkvalues(min_value, max_value, -step_value,
                    i.ReductionSingleton().to_Q.binning)

        rebining_option = ".001,.001,.0126,-.08,.2"
        i.ReductionSingleton().user_settings.readLimitValues(
            'L/Q ' + rebining_option, i.ReductionSingleton())
        checklistvalues(rebining_option, i.ReductionSingleton().to_Q.binning)
Ejemplo n.º 8
0
    def runTest(self):
        self.initialization()

        self.checkFirstPart()

        # add files (SAMPLE and CAN)
        import SANSadd2
        SANSadd2.add_runs(('22048','22048'),'SANS2D', '.nxs',
                          rawTypes=('.add','.raw','.s*'), lowMem=False)
        SANSadd2.add_runs(('22023','22023'),'SANS2D', '.nxs',
                          rawTypes=('.add','.raw','.s*'), lowMem=False)

        # load values:
        i.SetCentre('155.45','-169.6','rear')
        i.SetCentre('155.45','-169.6','front')
        i.AssignSample(r'SANS2D00022048-add.nxs',
                       reload = True, period = 1)
        i.AssignCan(r'SANS2D00022023-add.nxs',
                    reload = True, period = 1)
        i.TransmissionSample(r'SANS2D00022041.nxs', r'SANS2D00022024.nxs',
                             period_t=1, period_d=1)
        i.TransmissionCan(r'SANS2D00022024.nxs', r'SANS2D00022024.nxs',
                          period_t=1, period_d=1)

        self.checkAfterLoad()

        self.applyGUISettings()

        self.applySampleSettings()
        _user_settings_copy = copy.deepcopy(i.ReductionSingleton().user_settings)

        reduced = i.WavRangeReduction(full_trans_wav=False, resetSetup=False)
        RenameWorkspace(reduced, OutputWorkspace='trans_test_rear')

        self.checkFittingSettings()
        self.cleanReduction(_user_settings_copy)
Ejemplo n.º 9
0
    def test_that_2D_workspace_is_caught(self):
        #Arrange
        ws_name1 = "ws_fit_and_shift_test_1"
        ws_name2 = "ws_fit_and_shift_test_2"
        self._create_workspace(ws_name1)
        self._create_workspace(ws_name2)
        ws1 = mtd[ws_name1]
        ws2 = mtd[ws_name2]

        scale = 2.4
        shift = 1.1
        rAnds = instruments.DetectorBank._RescaleAndShift(scale, shift)

        # Act
        ret_scale, ret_shift = command_iface._fitRescaleAndShift(rAnds,ws1,ws2)

        # Assert
        self.assertTrue(ret_scale == scale)
        self.assertTrue(ret_shift == shift)

        # Clean up
        DeleteWorkspace(ws1)
        DeleteWorkspace(ws2)
Ejemplo n.º 10
0
    def test_incident_monitors(
            self):  # monitor_spec, monitor_interp, trans_monitor, trans_interp

        options = [(2, True), (4, False), (3, True)]

        for option in options:
            i.SetMonitorSpectrum(option[0], option[1])
            self.checkFloat(
                i.ReductionSingleton().instrument.get_incident_mon(),
                option[0])
            self.checkObj(
                i.ReductionSingleton().instrument.is_interpolating_norm(),
                option[1])

            i.SetTransSpectrum(option[0], option[1])
            self.checkFloat(
                i.ReductionSingleton().instrument.incid_mon_4_trans_calc,
                option[0])
            self.checkObj(
                i.ReductionSingleton().transmission_calculator.interpolate,
                option[1])
Ejemplo n.º 11
0
 def test_read_set_gravity(self):  # GUI: gravity_check
     i.Gravity(True)
     self.assertTrue(i.ReductionSingleton().to_Q.get_gravity())
     i.Gravity(False)
     self.assertTrue(not i.ReductionSingleton().to_Q.get_gravity())
Ejemplo n.º 12
0
 def checkPhiValues(option):
     self.checkFloat(i.ReductionSingleton().mask.phi_min, option[0])
     self.checkFloat(i.ReductionSingleton().mask.phi_max, option[1])
     self.checkObj(i.ReductionSingleton().mask.phi_mirror, option[2])
Ejemplo n.º 13
0
 def setUp(self):
     config['default.instrument'] = 'SANS2D'
     i.SANS2D()
     i.MaskFile(MASKFILE)
Ejemplo n.º 14
0
 def tearDown(self):
     ISIS._refresh_singleton()
Ejemplo n.º 15
0
 def runTest(self):
     import SANSBatchMode as batch
     i.SANS2D()
     i.MaskFile(MASKFILE)
     i.SetEventSlices("0.0-451, 5-10")
     batch.BatchReduce(BATCHFILE, '.nxs', saveAlgs={}, combineDet='rear')
    def test_full_setup_for_rectangular_apertures(self):
        # Arrange
        command_iface.Clean()
        command_iface.SANS2D()
        a1 = 2  # in mm
        a2 = 3  # in mm
        delta_r = 4  # in mm
        collimation_length = 10  # in m
        h1 = 9  # in mm
        w1 = 8  # in mm
        h2 = 7  # in mm
        w2 = 5  # in mm
        norm = reduction_steps.CalculateNormISIS()
        ReductionSingleton().to_Q = reduction_steps.ConvertToQISIS(norm)

        # Act
        command_iface.set_q_resolution_a1(a1=a1)
        command_iface.set_q_resolution_a2(a2=a2)
        command_iface.set_q_resolution_delta_r(delta_r=delta_r)
        command_iface.set_q_resolution_h1(h1=h1)
        command_iface.set_q_resolution_w1(w1=w1)
        command_iface.set_q_resolution_h2(h2=h2)
        command_iface.set_q_resolution_w2(w2=w2)
        command_iface.set_q_resolution_collimation_length(
            collimation_length=collimation_length)
        command_iface.set_q_resolution_use(use=True)
        ReductionSingleton().to_Q._set_up_q_resolution_parameters()

        # Assert
        a1_stored = ReductionSingleton().to_Q.get_q_resolution_a1()  # in m
        a1_expected = 2 * math.sqrt(
            (h1 / 1000. * h1 / 1000. + w1 / 1000. * w1 / 1000.) / 6)
        self.assertEqual(a1_stored, a1_expected)

        a2_stored = ReductionSingleton().to_Q.get_q_resolution_a2()  # in m
        a2_expected = 2 * math.sqrt(
            (h2 / 1000. * h2 / 1000. + w2 / 1000. * w2 / 1000.) / 6)
        self.assertEqual(a2_stored, a2_expected)

        collimation_length_stored = ReductionSingleton(
        ).to_Q.get_q_resolution_collimation_length()  # in m
        collimation_length_expected = collimation_length
        self.assertEqual(collimation_length_stored,
                         collimation_length_expected)

        delta_r_stored = ReductionSingleton().to_Q.get_q_resolution_delta_r(
        )  # in m
        delta_r_expected = delta_r / 1000.
        self.assertEqual(delta_r_stored, delta_r_expected)
Ejemplo n.º 17
0
    def runTest(self):

        i.SANS2DTUBES()
        i.MaskFile('USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt')
        i.SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0)
        i.SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0)
        i.Gravity(False)
        i.Set1D()

        # add files (SAMPLE and CAN)
        import SANSadd2
        SANSadd2.add_runs(('28827','28797'),'SANS2DTUBES', '.nxs',
                          rawTypes=('.add','.raw','.s*'), lowMem=False,
                          saveAsEvent=True, isOverlay = True)
        SANSadd2.add_runs(('28823','28793'),'SANS2DTUBES', '.nxs',
                          rawTypes=('.add','.raw','.s*'), lowMem=False,
                          saveAsEvent=True, isOverlay = True)

        i.AssignSample(r'SANS2D00028797-add.nxs', reload = True)
        i.AssignCan(r'SANS2D00028793-add.nxs', reload = True)
        i.TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs')
        i.TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs')

        i.WavRangeReduction()
Ejemplo n.º 18
0
 def runTest(self):
     import SANSBatchMode as batch
     i.SANS2D()
     i.MaskFile('MaskSANS2DReductionGUI.txt')
     batch_file = FileFinder.getFullPath('sans2d_reduction_gui_batch.csv')
     batch.BatchReduce(batch_file, '.nxs', combineDet='rear')
Ejemplo n.º 19
0
 def checkCentreResult(self):
     self.checkFloat(i.ReductionSingleton().get_beam_center('rear')[0],
                     0.165)
     self.checkFloat(i.ReductionSingleton().get_beam_center('rear')[1],
                     -0.145)
Ejemplo n.º 20
0
    def runTest(self):
        #here we are testing the LOQ setup
        ici.LOQ()
        #rear detector
        ici.Detector("main-detector-bank")
        #test batch mode, although only the analysis from the last line is checked
        # Find the file , this should really be in the BatchReduce reduction step

        f = open(self.csv_file, 'w')
        print >> f, "sample_sans,99630-add,output_as, %s" % self.output_file
        f.close()
        runnum = '99630'
        sansadd.add_runs((runnum, runnum), 'LOQ', '.RAW')

        ici.Set1D()
        ici.MaskFile('MASK.094AA')
        batch.BatchReduce(self.csv_file,
                          'nxs',
                          plotresults=False,
                          saveAlgs={'SaveNexus': 'nxs'})

        print ' reduction without'

        ici._refresh_singleton()

        ici.LOQ()
        ici.Detector("main-detector-bank")
        ici.Set1D()
        ici.MaskFile('MASK.094AA')
        LOQ99630 = Load(runnum)
        LOQ99630 += LOQ99630
        ici.AssignSample(LOQ99630, reload=False)
        self.result = ici.WavRangeReduction()
 def test_that_for_non_existing_false_is_returned(self):
     command_iface.Clean()
     selected_idf = "LARMOR_Definition_NONEXIST.xml"
     # Act + Assert
     self.assertFalse(command_iface.LARMOR(selected_idf),
                      "A non existant idf path should return false")
Ejemplo n.º 22
0
    def test_full_setup_for_rectangular_apertures_which_are_only_partially_specified(self):
        # Arrange
        command_iface.Clean()
        command_iface.SANS2D()
        a1 = 2 # in mm
        a2 = 3 # in mm
        delta_r = 4 # in mm
        collimation_length = 10 # in m
        h1 = 9 # in mm
        w1 = 8 # in mm
        h2 = 7 # in mm
        # We take out w2, hence we don't have a full rectangular spec
        norm = reduction_steps.CalculateNormISIS()
        ReductionSingleton().to_Q = reduction_steps.ConvertToQISIS(norm)

        # Act
        command_iface.set_q_resolution_a1(a1 = a1)
        command_iface.set_q_resolution_a2(a2 = a2)
        command_iface.set_q_resolution_delta_r(delta_r = delta_r)
        command_iface.set_q_resolution_h1(h1 = h1)
        command_iface.set_q_resolution_w1(w1 = w1)
        command_iface.set_q_resolution_h2(h2 = h2)

        command_iface.set_q_resolution_collimation_length(collimation_length = collimation_length)
        command_iface.set_q_resolution_use(use = True)
        ReductionSingleton().to_Q._set_up_q_resolution_parameters()

        # Assert
        a1_stored = ReductionSingleton().to_Q.get_q_resolution_a1() # in m 
        a1_expected = a1/1000.
        self.assertEqual(a1_stored, a1_expected)

        a2_stored = ReductionSingleton().to_Q.get_q_resolution_a2() # in m
        a2_expected = a2/1000.
        self.assertEqual(a2_stored, a2_expected)

        collimation_length_stored = ReductionSingleton().to_Q.get_q_resolution_collimation_length() # in m
        collimation_length_expected = collimation_length
        self.assertEqual(collimation_length_stored, collimation_length_expected)

        delta_r_stored = ReductionSingleton().to_Q.get_q_resolution_delta_r() # in m
        delta_r_expected = delta_r/1000.
        self.assertEqual(delta_r_stored, delta_r_expected)
Ejemplo n.º 23
0
    def test_full_setup_for_rectangular_apertures(self):
        # Arrange
        command_iface.Clean()
        command_iface.SANS2D()
        a1 = 2 # in mm
        a2 = 3 # in mm
        delta_r = 4 # in mm
        collimation_length = 10 # in m
        h1 = 9 # in mm
        w1 = 8 # in mm
        h2 = 7 # in mm
        w2 = 5 # in mm
        norm = reduction_steps.CalculateNormISIS()
        ReductionSingleton().to_Q = reduction_steps.ConvertToQISIS(norm)

        # Act
        command_iface.set_q_resolution_a1(a1 = a1)
        command_iface.set_q_resolution_a2(a2 = a2)
        command_iface.set_q_resolution_delta_r(delta_r = delta_r)
        command_iface.set_q_resolution_h1(h1 = h1)
        command_iface.set_q_resolution_w1(w1 = w1)
        command_iface.set_q_resolution_h2(h2 = h2)
        command_iface.set_q_resolution_w2(w2 = w2)
        command_iface.set_q_resolution_collimation_length(collimation_length = collimation_length)
        command_iface.set_q_resolution_use(use = True)
        ReductionSingleton().to_Q._set_up_q_resolution_parameters()

        # Assert
        a1_stored = ReductionSingleton().to_Q.get_q_resolution_a1() # in m 
        a1_expected = 2*math.sqrt((h1/1000.*h1/1000. + w1/1000.*w1/1000.)/6)
        self.assertEqual(a1_stored, a1_expected)

        a2_stored = ReductionSingleton().to_Q.get_q_resolution_a2() # in m
        a2_expected = 2*math.sqrt((h2/1000.*h2/1000. + w2/1000.*w2/1000.)/6)
        self.assertEqual(a2_stored, a2_expected)

        collimation_length_stored = ReductionSingleton().to_Q.get_q_resolution_collimation_length() # in m
        collimation_length_expected = collimation_length
        self.assertEqual(collimation_length_stored, collimation_length_expected)

        delta_r_stored = ReductionSingleton().to_Q.get_q_resolution_delta_r() # in m
        delta_r_expected = delta_r/1000.
        self.assertEqual(delta_r_stored, delta_r_expected)
Ejemplo n.º 24
0
 def loadAndAssign(self, run_spec,options=dict()):
     loadRun = steps.LoadRun(str(run_spec), **options)
     loadRun._assignHelper(ici.ReductionSingleton())
     return loadRun
Ejemplo n.º 25
0
    def runTest(self):

        i.SANS2DTUBES()
        i.MaskFile('USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt')
        i.SetDetectorOffsets('REAR', -16.0, 58.0, 0.0, 0.0, 0.0, 0.0)
        i.SetDetectorOffsets('FRONT', -44.0, -20.0, 47.0, 0.0, 1.0, 1.0)
        i.Gravity(False)
        i.Set1D()

        # add files (SAMPLE and CAN) using the ISISCommandInterface
        runs_sample = ('28827','28797')
        i.AddRuns(runs_sample, instrument = 'SANS2DTUBES', saveAsEvent=True)
        runs_can = ('28823','28793')
        i.AddRuns(runs_can, instrument = 'SANS2DTUBES', saveAsEvent=True)

        i.AssignSample(r'SANS2D00028797-add.nxs', reload = True)
        i.AssignCan(r'SANS2D00028793-add.nxs', reload = True)
        i.TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs')
        i.TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs')

        i.WavRangeReduction()
Ejemplo n.º 26
0
 def applyGUISettings(self):
     i.ReductionSingleton().instrument.setDetector('rear-detector')
     i.ReductionSingleton().to_Q.output_type = '1D'
     i.ReductionSingleton().user_settings.readLimitValues(
         'L/R ' + '41 ' + '-1 ' + '1', i.ReductionSingleton())
     i.LimitsWav(1.5, 12.5, 0.125, 'LIN')
     i.ReductionSingleton().user_settings.readLimitValues(
         'L/Q .001,.001,.0126,-.08,.2', i.ReductionSingleton())
     i.LimitsQXY(0.0, 0.05, 0.001, 'LIN')
     i.SetPhiLimit(-90.0, 90.0, True)
     i.SetDetectorFloodFile('', 'REAR')
     i.SetDetectorFloodFile('', 'FRONT')
     i.TransFit(mode='Logarithmic',
                lambdamin='1.5',
                lambdamax='12.5',
                selector='BOTH')
     i.SetFrontDetRescaleShift(scale=1.0, shift=0.0)
     i.Gravity(True)
     i.SetSampleOffset('53')
     i.SetMonitorSpectrum('1', True)
     i.SetTransSpectrum('1', True)
     i.SetCentre('155.45', '-169.6', 'rear')
     i.SetCentre('155.45', '-169.6', 'front')
     i.Mask('MASK/CLEAR')
     i.Mask('MASK/CLEAR/TIME')
     i.Mask('MASK/REAR H0')
     i.Mask('MASK/REAR H190>H191')
     i.Mask('MASK/REAR H167>H172')
     i.Mask('MASK/REAR V0')
     i.Mask('MASK/REAR V191')
     i.Mask('MASK/FRONT H0')
     i.Mask('MASK/FRONT H190>H191')
     i.Mask('MASK/FRONT V0')
     i.Mask('MASK/FRONT V191')
     i.Mask('MASK/FRONT H156>H159')
     i.Mask('MASK/TIME 17500 22000')
     i.Mask('L/PHI -90.0 90.0')
     i.SetVerboseMode(True)
    def test_full_setup_for_circular_apertures(self):
        # Arrange
        command_iface.Clean()
        command_iface.SANS2D()
        a1 = 2  # in mm
        a2 = 3  # in mm
        delta_r = 4  # in mm
        collimation_length = 10  # in m
        norm = reduction_steps.CalculateNormISIS()
        ReductionSingleton().to_Q = reduction_steps.ConvertToQISIS(norm)

        # Act
        command_iface.set_q_resolution_a1(a1=a1)
        command_iface.set_q_resolution_a2(a2=a2)
        command_iface.set_q_resolution_delta_r(delta_r=delta_r)
        command_iface.set_q_resolution_collimation_length(
            collimation_length=collimation_length)
        command_iface.set_q_resolution_use(use=True)
        ReductionSingleton().to_Q._set_up_q_resolution_parameters()

        # Assert
        a1_stored = ReductionSingleton().to_Q.get_q_resolution_a1()  # in m
        a1_expected = a1 / 1000.
        self.assertEqual(a1_stored, a1_expected)

        a2_stored = ReductionSingleton().to_Q.get_q_resolution_a2()  # in m
        a2_expected = a2 / 1000.
        self.assertEqual(a2_stored, a2_expected)

        collimation_length_stored = ReductionSingleton(
        ).to_Q.get_q_resolution_collimation_length()  # in m
        collimation_length_expected = collimation_length
        self.assertEqual(collimation_length_stored,
                         collimation_length_expected)

        delta_r_stored = ReductionSingleton().to_Q.get_q_resolution_delta_r(
        )  # in m
        delta_r_expected = delta_r / 1000.
        self.assertEqual(delta_r_stored, delta_r_expected)
Ejemplo n.º 28
0
 def applySampleSettings(self):
     i.ReductionSingleton().get_sample().geometry.shape = 3
     i.ReductionSingleton().get_sample().geometry.height = 8
     i.ReductionSingleton().get_sample().geometry.width = 8
     i.ReductionSingleton().get_sample().geometry.thickness = 2
    def test_full_setup_for_rectangular_apertures_which_are_only_partially_specified(
            self):
        # Arrange
        command_iface.Clean()
        command_iface.SANS2D()
        a1 = 2  # in mm
        a2 = 3  # in mm
        delta_r = 4  # in mm
        collimation_length = 10  # in m
        h1 = 9  # in mm
        w1 = 8  # in mm
        h2 = 7  # in mm
        # We take out w2, hence we don't have a full rectangular spec
        norm = reduction_steps.CalculateNormISIS()
        ReductionSingleton().to_Q = reduction_steps.ConvertToQISIS(norm)

        # Act
        command_iface.set_q_resolution_a1(a1=a1)
        command_iface.set_q_resolution_a2(a2=a2)
        command_iface.set_q_resolution_delta_r(delta_r=delta_r)
        command_iface.set_q_resolution_h1(h1=h1)
        command_iface.set_q_resolution_w1(w1=w1)
        command_iface.set_q_resolution_h2(h2=h2)

        command_iface.set_q_resolution_collimation_length(
            collimation_length=collimation_length)
        command_iface.set_q_resolution_use(use=True)
        ReductionSingleton().to_Q._set_up_q_resolution_parameters()

        # Assert
        a1_stored = ReductionSingleton().to_Q.get_q_resolution_a1()  # in m
        a1_expected = a1 / 1000.
        self.assertEqual(a1_stored, a1_expected)

        a2_stored = ReductionSingleton().to_Q.get_q_resolution_a2()  # in m
        a2_expected = a2 / 1000.
        self.assertEqual(a2_stored, a2_expected)

        collimation_length_stored = ReductionSingleton(
        ).to_Q.get_q_resolution_collimation_length()  # in m
        collimation_length_expected = collimation_length
        self.assertEqual(collimation_length_stored,
                         collimation_length_expected)

        delta_r_stored = ReductionSingleton().to_Q.get_q_resolution_delta_r(
        )  # in m
        delta_r_expected = delta_r / 1000.
        self.assertEqual(delta_r_stored, delta_r_expected)
Ejemplo n.º 30
0
 def cleanReduction(self, user_settings):
     i.ReductionSingleton.clean(isis_reducer.ISISReducer)
     i.ReductionSingleton().set_instrument(isis_instrument.SANS2D())
     #i.ReductionSingleton().user_file_path=''
     i.ReductionSingleton().user_settings = user_settings
     i.ReductionSingleton().user_settings.execute(i.ReductionSingleton())
Ejemplo n.º 31
0
 def test_read_set_radius(self): #GUI: rad_min, rad_max
     min_value, max_value = 1.2, 18.9
     i.ReductionSingleton().user_settings.readLimitValues('L/R %f %f'%(min_value, max_value),i.ReductionSingleton())
     self.checkFloat(i.ReductionSingleton().mask.min_radius, min_value/1000)
     self.checkFloat(i.ReductionSingleton().mask.max_radius, max_value/1000)
Ejemplo n.º 32
0
 def setUp(self):
     config['default.instrument'] = 'SANS2D'
     ici.SANS2D()
Ejemplo n.º 33
0
 def test_qy(self):  # qy_max, qy_dqy, qy_dqy_opt
     value_max, value_step = 0.06, 0.002
     i.LimitsQXY(0.0, value_max, value_step, 'LIN')
     self.checkFloat(i.ReductionSingleton().QXY2, value_max)
     self.checkFloat(i.ReductionSingleton().DQXY, value_step)
Ejemplo n.º 34
0
 def checkFirstPart(self):
     self.checkObj(i.ReductionSingleton().instrument.listDetectors(),
                   ('rear-detector', 'front-detector'))
     self.checkStr(i.ReductionSingleton().instrument.cur_detector().name(),
                   'rear-detector')
     self.checkFloat(i.ReductionSingleton().mask.min_radius, 0.041)
     self.checkFloat(i.ReductionSingleton().mask.max_radius, -0.001)
     self.checkFloat(i.ReductionSingleton().to_wavelen.wav_low, 1.5)
     self.checkFloat(i.ReductionSingleton().to_wavelen.wav_high, 12.5)
     self.checkFloat(i.ReductionSingleton().to_wavelen.wav_step, 0.125)
     self.checkStr(i.ReductionSingleton().to_Q.binning,
                   " .001,.001,.0126,-.08,.2")
     self.checkFloat(i.ReductionSingleton().QXY2, 0.05)
     self.checkFloat(i.ReductionSingleton().DQXY, 0.001)
     self.checkFloat(
         i.ReductionSingleton().transmission_calculator.lambdaMin('SAMPLE'),
         1.5)
     self.checkStr(
         i.ReductionSingleton().transmission_calculator.fitMethod('SAMPLE'),
         'LOGARITHMIC')
     self.checkFloat(
         i.ReductionSingleton().transmission_calculator.lambdaMin('CAN'),
         1.5)
     self.checkFloat(i.ReductionSingleton().instrument.WAV_RANGE_MIN, 2.0)
     self.checkFloat(i.ReductionSingleton().instrument.WAV_RANGE_MAX, 14.0)
     self.checkFloat(
         i.ReductionSingleton().transmission_calculator.lambdaMax('CAN'),
         12.5)
     self.checkStr(
         i.ReductionSingleton().transmission_calculator.fitMethod('CAN'),
         'LOGARITHMIC')
     self.checkFloat(
         i.ReductionSingleton().transmission_calculator.lambdaMin('SAMPLE'),
         1.5)
     self.checkStr(
         i.ReductionSingleton().transmission_calculator.fitMethod('SAMPLE'),
         'LOGARITHMIC')
     self.checkFloat(
         i.ReductionSingleton().instrument.getDetector(
             'FRONT').rescaleAndShift.scale, 1.0)
     self.checkFloat(
         i.ReductionSingleton().instrument.getDetector(
             'FRONT').rescaleAndShift.shift, 0.0)
     self.assertTrue(not i.ReductionSingleton().instrument.getDetector(
         'FRONT').rescaleAndShift.fitScale)
     self.assertTrue(not i.ReductionSingleton().instrument.getDetector(
         'FRONT').rescaleAndShift.fitShift)
     self.assertTrue(not i.ReductionSingleton().instrument.getDetector(
         'FRONT').rescaleAndShift.qRangeUserSelected)
     self.checkFloat(i.ReductionSingleton().instrument.get_incident_mon(),
                     1)
     self.checkFloat(
         i.ReductionSingleton().instrument.incid_mon_4_trans_calc, 1)
     self.assertTrue(
         i.ReductionSingleton().instrument.is_interpolating_norm())
     self.assertTrue(
         i.ReductionSingleton().transmission_calculator.interpolate)
     self.assertTrue("DIRECTM1_15785_12m_31Oct12_v12.dat" in i.
                     ReductionSingleton().instrument.detector_file('rear'))
     self.assertTrue("DIRECTM1_15785_12m_31Oct12_v12.dat" in i.
                     ReductionSingleton().instrument.detector_file('front'))
     self.checkStr(
         i.ReductionSingleton().prep_normalize.getPixelCorrFile('REAR'), "")
     self.checkStr(
         i.ReductionSingleton().prep_normalize.getPixelCorrFile('FRONT'),
         "")
     self.checkFloat(i.ReductionSingleton()._corr_and_scale.rescale, 7.4)
     self.checkFloat(i.ReductionSingleton().instrument.SAMPLE_Z_CORR, 0.053)
     self.assertDelta(i.ReductionSingleton().get_beam_center('rear')[0],
                      0.15545, 0.0001)
     self.checkFloat(i.ReductionSingleton().get_beam_center('rear')[1],
                     -0.16965)
     self.checkFloat(i.ReductionSingleton().get_beam_center('front')[0],
                     0.15545)
     self.checkFloat(i.ReductionSingleton().get_beam_center('front')[1],
                     -0.16965)
     self.assertTrue(i.ReductionSingleton().to_Q.get_gravity())
     self.checkStr(i.ReductionSingleton().instrument.det_selection, 'REAR')
     self.checkFloat(i.ReductionSingleton().mask.phi_min, -90.0)
     self.checkFloat(i.ReductionSingleton().mask.phi_max, 90.0)
     self.checkStr(i.ReductionSingleton().mask.spec_mask_r,
                   ",H0,H190>H191,H167>H172,V0,V191")
     self.checkStr(i.ReductionSingleton().mask.spec_mask_f,
                   ",H0,H190>H191,V0,V191,H156>H159")
     self.checkStr(i.ReductionSingleton().mask.time_mask, ";17500 22000")
     self.checkStr(i.ReductionSingleton().mask.time_mask_r, "")
     self.checkStr(i.ReductionSingleton().mask.time_mask_f, "")
     self.checkStr(i.ReductionSingleton().mask.time_mask_f, "")
     self.assertEqual(i.ReductionSingleton().mask.arm_width, None)
     self.assertEqual(i.ReductionSingleton().mask.arm_angle, None)
     self.assertEqual(i.ReductionSingleton().mask.arm_x, None)
     self.assertEqual(i.ReductionSingleton().mask.arm_y, None)
     self.assertTrue(i.ReductionSingleton().mask.phi_mirror)
Ejemplo n.º 35
0
    def runTest(self):
        # Select instrument and user file
        i.SANS2DTUBES()
        i.MaskFile(file_name='USER_SANS2D_143ZC_2p4_4m_M4_Knowles_12mm.txt')

        # Setup detector positions
        i.SetDetectorOffsets(bank='REAR',
                             x=-16.0,
                             y=58.0,
                             z=0.0,
                             rot=0.0,
                             radius=0.0,
                             side=0.0)
        i.SetDetectorOffsets(bank='FRONT',
                             x=-44.0,
                             y=-20.0,
                             z=47.0,
                             rot=0.0,
                             radius=1.0,
                             side=1.0)
        i.Gravity(False)

        # Set the front detector fitting
        i.SetFrontDetRescaleShift(scale=1.0,
                                  shift=0.0,
                                  fitScale=True,
                                  fitShift=True)
        i.Set1D()

        # Assign data
        i.AssignSample(r'SANS2D00028797.nxs', reload=True)
        i.AssignCan(r'SANS2D00028793.nxs', reload=True)
        i.TransmissionSample(r'SANS2D00028808.nxs', r'SANS2D00028784.nxs')
        i.TransmissionCan(r'SANS2D00028823.nxs', r'SANS2D00028784.nxs')

        # Run the reduction and request FRONT and BACK to be merged
        i.WavRangeReduction(combineDet="merged")
Ejemplo n.º 36
0
 def runTest(self):
     import SANSBatchMode as batch
     i.LOQ()
     i.MaskFile(MASKFILE)
     batch.BatchReduce(BATCHFILE, '.nxs', combineDet='merged', saveAlgs={})
Ejemplo n.º 37
0
    def test_scaling_options(self):
        # frontDetRescale, frontDetShift, frontDetRescaleCB, frontDetShiftCB
        # frontDetQmin, frontDetQmax, frontDetQrangeOnOff

        def testScalingValues(scale,
                              shift,
                              qMin=None,
                              qMax=None,
                              fitScale=False,
                              fitShift=False):
            self.checkFloat(
                i.ReductionSingleton().instrument.getDetector(
                    'FRONT').rescaleAndShift.scale, scale)
            self.checkFloat(
                i.ReductionSingleton().instrument.getDetector(
                    'FRONT').rescaleAndShift.shift, shift)
            self.checkObj(
                i.ReductionSingleton().instrument.getDetector(
                    'FRONT').rescaleAndShift.fitScale, fitScale)
            self.checkObj(
                i.ReductionSingleton().instrument.getDetector(
                    'FRONT').rescaleAndShift.fitShift, fitShift)
            if qMin is not None:
                self.assertTrue(i.ReductionSingleton().instrument.getDetector(
                    'FRONT').rescaleAndShift.qRangeUserSelected)
                self.checkFloat(
                    i.ReductionSingleton().instrument.getDetector(
                        'FRONT').rescaleAndShift.qMin, qMin)
                self.checkFloat(
                    i.ReductionSingleton().instrument.getDetector(
                        'FRONT').rescaleAndShift.qMax, qMax)
            else:
                self.assertTrue(
                    not i.ReductionSingleton().instrument.getDetector(
                        'FRONT').rescaleAndShift.qRangeUserSelected)

        options = [{
            'scale': 1.2,
            'shift': 0.3
        }, {
            'scale': 1.3,
            'shift': 0.4,
            'fitScale': True
        }, {
            'scale': 1.2,
            'shift': 0.3,
            'fitShift': True
        }, {
            'scale': 1.4,
            'shift': 0.32,
            'qMin': 0.5,
            'qMax': 2.1
        }, {
            'scale': 1.2,
            'shift': 0.41,
            'qMin': 0.53,
            'qMax': 2.12,
            'fitScale': True
        }]

        for option in options:
            i.SetFrontDetRescaleShift(**option)
            testScalingValues(**option)
Ejemplo n.º 38
0
 def runTest(self):
     import SANSBatchMode as batch
     i.LOQ()
     i.MaskFile('MaskLOQData.txt')
     batch_file = FileFinder.getFullPath('loq_batch_mode_reduction.csv')
     batch.BatchReduce(batch_file, '.nxs', combineDet='merged', saveAlgs={})
Ejemplo n.º 39
0
 def runTest(self):
     import SANSBatchMode as batch
     i.SANS2D()
     i.MaskFile(MASKFILE)
     batch.BatchReduce(BATCHFILE, '.nxs', combineDet='rear')
Ejemplo n.º 40
0
 def passWsAndAssign(self, ws, options=dict()):
     loadRun = steps.LoadRun(ws, **options)
     loadRun._assignHelper(ici.ReductionSingleton())
     return loadRun