def test_that_converts_detector_name_to_type(self): self.assertTrue( convert_bank_name_to_detector_type_isis("rEar-detector") is DetectorType.LAB) self.assertTrue( convert_bank_name_to_detector_type_isis("MAIN-detector-BANK") is DetectorType.LAB) self.assertTrue( convert_bank_name_to_detector_type_isis("DeTectorBench") is DetectorType.LAB) self.assertTrue( convert_bank_name_to_detector_type_isis("rear") is DetectorType.LAB ) self.assertTrue( convert_bank_name_to_detector_type_isis("MAIN") is DetectorType.LAB ) self.assertTrue( convert_bank_name_to_detector_type_isis("FRoNT-DETECTOR") is DetectorType.HAB) self.assertTrue( convert_bank_name_to_detector_type_isis("HaB") is DetectorType.HAB) self.assertTrue( convert_bank_name_to_detector_type_isis("front") is DetectorType.HAB) self.assertRaises(RuntimeError, convert_bank_name_to_detector_type_isis, "test")
def test_that_converts_detector_name_to_type(self): self.assertTrue(convert_bank_name_to_detector_type_isis("rEar-detector") is DetectorType.LAB) self.assertTrue(convert_bank_name_to_detector_type_isis("MAIN-detector-BANK") is DetectorType.LAB) self.assertTrue(convert_bank_name_to_detector_type_isis("DeTectorBench") is DetectorType.LAB) self.assertTrue(convert_bank_name_to_detector_type_isis("rear") is DetectorType.LAB) self.assertTrue(convert_bank_name_to_detector_type_isis("MAIN") is DetectorType.LAB) self.assertTrue(convert_bank_name_to_detector_type_isis("FRoNT-DETECTOR") is DetectorType.HAB) self.assertTrue(convert_bank_name_to_detector_type_isis("HaB") is DetectorType.HAB) self.assertTrue(convert_bank_name_to_detector_type_isis("front") is DetectorType.HAB) self.assertRaises(RuntimeError, convert_bank_name_to_detector_type_isis, "test")
def SetDetectorFloodFile(filename, detector_name="REAR"): """ Sets the pixel correction file for a particular detector @param filename: the name of the file. @param detector_name: the name of the detector """ file_name = find_full_file_path(filename) detector_name = convert_bank_name_to_detector_type_isis(detector_name) flood_command = NParameterCommand(command_id=NParameterCommandId.FLOOD_FILE, values=[file_name, detector_name]) director.add_command(flood_command)
def SetDetectorFloodFile(filename, detector_name="REAR"): """ Sets the pixel correction file for a particular detector @param filename: the name of the file. @param detector_name: the name of the detector """ file_name = find_full_file_path(filename) detector_name = convert_bank_name_to_detector_type_isis(detector_name) flood_command = NParameterCommand(command_id=NParameterCommandId.flood_file, values=[file_name, detector_name]) director.add_command(flood_command)
def Detector(det_name): """ Sets the detector which is being used for the reduction. Previous comment: Sets the detector bank to use for the reduction e.g. 'front-detector'. The main detector is assumed if this line is not given @param det_name: the detector's name """ print_message('Detector("' + det_name + '")') detector_type = convert_bank_name_to_detector_type_isis(det_name) reduction_mode = ReductionMode.HAB if detector_type is DetectorType.HAB else ReductionMode.LAB detector_command = NParameterCommand(command_id=NParameterCommandId.DETECTOR, values=[reduction_mode]) director.add_command(detector_command)
def Detector(det_name): """ Sets the detector which is being used for the reduction. Previous comment: Sets the detector bank to use for the reduction e.g. 'front-detector'. The main detector is assumed if this line is not given @param det_name: the detector's name """ print_message('Detector("' + det_name + '")') detector_type = convert_bank_name_to_detector_type_isis(det_name) reduction_mode = ISISReductionMode.HAB if detector_type is DetectorType.HAB else ISISReductionMode.LAB detector_command = NParameterCommand(command_id=NParameterCommandId.detector, values=[reduction_mode]) director.add_command(detector_command)
def SetCentre(xcoord, ycoord, bank='rear'): """ Configure the Beam Center position. It support the configuration of the centre for both detectors bank (low-angle bank and high-angle bank detectors) It allows defining the position for both detector banks. :param xcoord: X position of beam center in the user coordinate system. :param ycoord: Y position of beam center in the user coordinate system. :param bank: The selected bank ('rear' - low angle or 'front' - high angle) Introduced #5942 """ xcoord = float(xcoord) ycoord = float(ycoord) print_message('SetCentre(' + str(xcoord) + ', ' + str(ycoord) + ')') detector_type = convert_bank_name_to_detector_type_isis(bank) centre_command = NParameterCommand(command_id=NParameterCommandId.CENTRE, values=[xcoord, ycoord, detector_type]) director.add_command(centre_command)
def SetCorrectionFile(bank, filename): # 10/03/15 RKH, create a new routine that allows change of "direct beam file" = correction file, # for a given detector, this simplify the iterative process used to adjust it. # Will still have to keep changing the name of the file # for each iteratiom to avoid Mantid using a cached version, but can then use # only a single user (=mask) file for each set of iterations. # Modelled this on SetDetectorOffsets above ... """ @param bank: Must be either 'front' or 'rear' (not case sensitive) @param filename: self explanatory """ print_message("SetCorrectionFile(" + str(bank) + ', ' + filename + ')') detector_type = convert_bank_name_to_detector_type_isis(bank) file_name = find_full_file_path(filename) flood_command = NParameterCommand(command_id=NParameterCommandId.WAVELENGTH_CORRECTION_FILE, values=[file_name, detector_type]) director.add_command(flood_command)
def SetCentre(xcoord, ycoord, bank='rear'): """ Configure the Beam Center position. It support the configuration of the centre for both detectors bank (low-angle bank and high-angle bank detectors) It allows defining the position for both detector banks. :param xcoord: X position of beam center in the user coordinate system. :param ycoord: Y position of beam center in the user coordinate system. :param bank: The selected bank ('rear' - low angle or 'front' - high angle) Introduced #5942 """ xcoord = float(xcoord) ycoord = float(ycoord) print_message('SetCentre(' + str(xcoord) + ', ' + str(ycoord) + ')') detector_type = convert_bank_name_to_detector_type_isis(bank) centre_command = NParameterCommand(command_id=NParameterCommandId.centre, values=[xcoord, ycoord, detector_type]) director.add_command(centre_command)
def SetCorrectionFile(bank, filename): # 10/03/15 RKH, create a new routine that allows change of "direct beam file" = correction file, # for a given detector, this simplify the iterative process used to adjust it. # Will still have to keep changing the name of the file # for each iteratiom to avoid Mantid using a cached version, but can then use # only a single user (=mask) file for each set of iterations. # Modelled this on SetDetectorOffsets above ... """ @param bank: Must be either 'front' or 'rear' (not case sensitive) @param filename: self explanatory """ print_message("SetCorrectionFile(" + str(bank) + ', ' + filename + ')') detector_type = convert_bank_name_to_detector_type_isis(bank) file_name = find_full_file_path(filename) flood_command = NParameterCommand(command_id=NParameterCommandId.wavelength_correction_file, values=[file_name, detector_type]) director.add_command(flood_command)
def SetDetectorOffsets(bank, x, y, z, rot, radius, side, xtilt=0.0, ytilt=0.0): """ Adjust detector position away from position defined in IDF. On SANS2D the detector banks can be moved around. This method allows fine adjustments of detector bank position in the same way as the DET/CORR userfile command works. Hence please see http://www.mantidproject.org/SANS_User_File_Commands#DET for details. The comment below is not true any longer: Note, for now, this command will only have an effect on runs loaded after this command have been executed (because it is when runs are loaded that components are moved away from the positions set in the IDF) @param bank: Must be either 'front' or 'rear' (not case sensitive) @param x: shift in mm @param y: shift in mm @param z: shift in mm @param rot: shift in degrees @param radius: shift in mm @param side: shift in mm @param xtilt: xtilt in degrees @param ytilt: ytilt in degrees """ x = float(x) y = float(y) z = float(z) rot = float(rot) radius = float(radius) side = float(side) xtilt = float(xtilt) ytilt = float(ytilt) print_message("SetDetectorOffsets(" + str(bank) + ', ' + str(x) + ',' + str(y) + ',' + str(z) + ',' + str(rot) + ',' + str(radius) + ',' + str(side) + ',' + str(xtilt) + ',' + str(ytilt) + ')') detector_type = convert_bank_name_to_detector_type_isis(bank) detector_offsets = NParameterCommand(command_id=NParameterCommandId.DETECTOR_OFFSETS, values=[detector_type, x, y, z, rot, radius, side, xtilt, ytilt]) director.add_command(detector_offsets)
def SetDetectorOffsets(bank, x, y, z, rot, radius, side, xtilt=0.0, ytilt=0.0): """ Adjust detector position away from position defined in IDF. On SANS2D the detector banks can be moved around. This method allows fine adjustments of detector bank position in the same way as the DET/CORR userfile command works. Hence please see http://www.mantidproject.org/SANS_User_File_Commands#DET for details. The comment below is not true any longer: Note, for now, this command will only have an effect on runs loaded after this command have been executed (because it is when runs are loaded that components are moved away from the positions set in the IDF) @param bank: Must be either 'front' or 'rear' (not case sensitive) @param x: shift in mm @param y: shift in mm @param z: shift in mm @param rot: shift in degrees @param radius: shift in mm @param side: shift in mm @param xtilt: xtilt in degrees @param ytilt: ytilt in degrees """ x = float(x) y = float(y) z = float(z) rot = float(rot) radius = float(radius) side = float(side) xtilt = float(xtilt) ytilt = float(ytilt) print_message("SetDetectorOffsets(" + str(bank) + ', ' + str(x) + ',' + str(y) + ',' + str(z) + ',' + str(rot) + ',' + str(radius) + ',' + str(side) + ',' + str(xtilt) + ',' + str(ytilt) + ')') detector_type = convert_bank_name_to_detector_type_isis(bank) detector_offsets = NParameterCommand(command_id=NParameterCommandId.detector_offsets, values=[detector_type, x, y, z, rot, radius, side, xtilt, ytilt]) director.add_command(detector_offsets)