def create_geometry(file_name=None, tube_width=TUBE_WIDTH, tube_length=TUBE_SIZE): """ Create a geometry file @param file_name: name of the output file [optional] @param tube_width: width of the tubes (pixel width) @param tube_length: length of the tubes (number of pixels times pixel height) """ # Get geometry information file inst_name = "EQ-SANS" if file_name is None: xml_outfile = inst_name + "_Definition.xml" else: xml_outfile = file_name det = MantidGeom(inst_name) det.addSnsDefaults() det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-14.122) det.addSamplePosition() det.addComment("MONITORS") det.addMonitors(names=["monitor1"], distance=["-0.23368"]) id_str = "detector1" det.addComponent(id_str, id_str) doc_handle = det.makeTypeElement(id_str) det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (tube_width / 2.0), (tube_length / NUM_PIXELS_PER_TUBE)) for i in range(0, NUM_BANKS / 2): i_low_bank = i i_high_bank = i + NUM_BANKS / 2 low_bank = "bank" + str(i_low_bank + 1) high_bank = "bank" + str(i_high_bank + 1) # FRONT plane for j in range(NUM_TUBES_PER_BANK): tube_id = "bank" + str(i_low_bank + 1) + "_tube" + str(j + 1) x, y, z = get_position(i_low_bank, j, tube_width) det.addComponent(tube_id, root=doc_handle) det.addPixelatedTube('_' + tube_id, NUM_PIXELS_PER_TUBE, tube_length, type_name="pixel") det.addDetector(x, y, z, "0", "0", "0", tube_id, '_' + tube_id) # BACK plane for j in range(NUM_TUBES_PER_BANK): tube_id = "bank" + str(i_high_bank + 1) + "_tube" + str(j + 1) x, y, z = get_position(i_high_bank, j, tube_width) det.addComponent(tube_id, root=doc_handle) det.addPixelatedTube('_' + tube_id, NUM_PIXELS_PER_TUBE, tube_length, type_name="pixel") det.addDetector(x, y, z, "0", "0", "0", tube_id, '_' + tube_id) det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("DETECTOR IDs") id_list = [ 0, NUM_BANKS * NUM_TUBES_PER_BANK * NUM_PIXELS_PER_TUBE - 1, None ] det.addDetectorIds(id_str, id_list) det.addComment("MONITOR IDs") det.addMonitorIds(["-1"]) det.writeGeom(xml_outfile)
def create_geometry(file_name=None, tube_width=TUBE_WIDTH, tube_length=TUBE_SIZE): """ Create a geometry file @param file_name: name of the output file [optional] @param tube_width: width of the tubes (pixel width) @param tube_length: length of the tubes (number of pixels times pixel height) """ # Get geometry information file inst_name = "EQ-SANS" if file_name is None: xml_outfile = inst_name+"_Definition.xml" else: xml_outfile = file_name det = MantidGeom(inst_name) det.addSnsDefaults() det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-14.122) det.addSamplePosition() det.addComment("MONITORS") det.addMonitors(names=["monitor1"], distance=["-0.23368"]) id_str = "detector1" det.addComponent(id_str, id_str) doc_handle = det.makeTypeElement(id_str) det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (tube_width/2.0), (tube_length/NUM_PIXELS_PER_TUBE)) for i in range(0, NUM_BANKS/2): i_low_bank = i i_high_bank = i+NUM_BANKS/2 low_bank = "bank"+str(i_low_bank+1) high_bank = "bank"+str(i_high_bank+1) # FRONT plane for j in range(NUM_TUBES_PER_BANK): tube_id = "bank"+str(i_low_bank+1)+"_tube"+str(j+1) x, y, z = get_position(i_low_bank, j, tube_width) det.addComponent(tube_id, root=doc_handle) det.addPixelatedTube('_'+tube_id, NUM_PIXELS_PER_TUBE, tube_length, type_name="pixel") det.addDetector(x, y, z, "0", "0", "0", tube_id, '_'+tube_id) # BACK plane for j in range(NUM_TUBES_PER_BANK): tube_id = "bank"+str(i_high_bank+1)+"_tube"+str(j+1) x, y, z = get_position(i_high_bank, j, tube_width) det.addComponent(tube_id, root=doc_handle) det.addPixelatedTube('_'+tube_id, NUM_PIXELS_PER_TUBE, tube_length, type_name="pixel") det.addDetector(x, y, z, "0", "0", "0", tube_id, '_'+tube_id) det.addComment("MONITOR SHAPE") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) det.addComment("DETECTOR IDs") id_list = [0, NUM_BANKS*NUM_TUBES_PER_BANK*NUM_PIXELS_PER_TUBE-1, None] det.addDetectorIds(id_str, id_list) det.addComment("MONITOR IDs") det.addMonitorIds(["-1"]) det.writeGeom(xml_outfile)
def create_geometry(file_name=None, pixel_width=None, pixel_height=None): inst_name = "REF_L" short_name = "REF_L" if pixel_width is None: pixel_width = PIXEL_WIDTH if pixel_height is None: pixel_height = PIXEL_HEIGHT if file_name is None: xml_outfile = inst_name+"_Definition.xml" else: xml_outfile = file_name det = MantidGeom(inst_name) det.addSnsDefaults() det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-13.63) #was 13.601 det.addSamplePosition() det.addComment("MONITORS") det.addMonitors(names=["monitor1"], distance=["-0.23368"]) det.addComment("DETECTOR") id_str = "detector1" det.addComponent("detector1", id_str) doc_handle = det.makeTypeElement(id_str) det.addPixelatedTube("tube", NUM_PIXELS_PER_TUBE, PIXEL_HEIGHT*NUM_PIXELS_PER_TUBE, type_name="pixel") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), pixel_width/2.0, pixel_height) for i in range(0, NUM_TUBES): det.addComponent("tube%d" % i, root=doc_handle) det.addDetector(str((i-NUM_TUBES/2+0.5)*pixel_width), "0", "+1.28", "0", "0", "0", "tube%d"%i, "tube") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) id_list = [0, NUM_TUBES*NUM_PIXELS_PER_TUBE-1, None] det.addDetectorIds(id_str, id_list) det.addMonitorIds(["-1"]) det.writeGeom(xml_outfile)
def create_geometry(file_name=None, pixel_width=None, pixel_height=None): inst_name = "REF_L" short_name = "REF_L" if pixel_width is None: pixel_width = PIXEL_WIDTH if pixel_height is None: pixel_height = PIXEL_HEIGHT if file_name is None: xml_outfile = inst_name + "_Definition.xml" else: xml_outfile = file_name det = MantidGeom(inst_name) det.addSnsDefaults() det.addComment("SOURCE AND SAMPLE POSITION") det.addModerator(-13.63) #was 13.601 det.addSamplePosition() det.addComment("MONITORS") det.addMonitors(names=["monitor1"], distance=["-0.23368"]) det.addComment("DETECTOR") id_str = "detector1" det.addComponent("detector1", id_str) doc_handle = det.makeTypeElement(id_str) det.addPixelatedTube("tube", NUM_PIXELS_PER_TUBE, PIXEL_HEIGHT * NUM_PIXELS_PER_TUBE, type_name="pixel") det.addCylinderPixel("pixel", (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), pixel_width / 2.0, pixel_height) for i in range(0, NUM_TUBES): det.addComponent("tube%d" % i, root=doc_handle) det.addDetector(str((i - NUM_TUBES / 2 + 0.5) * pixel_width), "0", "+1.28", "0", "0", "0", "tube%d" % i, "tube") det.addComment("FIXME: Do something real here.") det.addDummyMonitor(0.01, 0.03) id_list = [0, NUM_TUBES * NUM_PIXELS_PER_TUBE - 1, None] det.addDetectorIds(id_str, id_list) det.addMonitorIds(["-1"]) det.writeGeom(xml_outfile)