Loading sample_simulation_mcvine/base/Snap.py 0 → 100644 +43 −0 Original line number Diff line number Diff line import mcvine, mcvine.components as mc import numpy as np # from EventMonitor_4D import EventMonitor_4D as E4D from detector import Detector def instrument(beam, sample_path, angleMons=[45, 135], detector_width=[0.5, 0.5], detector_height=[0.5, 0.5], sourceTosample_x=0., sourceTosample_y=0., sourceTosample_z=0., sampleTodetector_z=[0.5, 0.5], number_detectors=2, number_pixels_in_height=[256, 256], number_pixels_in_width=[256, 256], number_of_box_in_height=[3, 3], number_of_box_in_width=[3, 3]): instrument = mcvine.instrument() source = mc.sources.NeutronFromStorage('source', beam) instrument.append(source, position=(0,0,0)) samplexml = os.path.join(sample_path, 'sampleassembly.xml') sample = mc.samples.SampleAssemblyFromXml('sample', samplexml) instrument.append(sample, position=(0,0,0.5)) width = detector_width height = detector_height NpixelsPerPanel = 0 for i in range(number_detectors): angle = np.deg2rad(angleMons[i]) print('detector_angle: ', angleMons[i]) pixel_width = detector_width[i] / number_pixels_in_width[i] / number_of_box_in_width[i] # *1.00000001 pixel_height = height[i] / number_pixels_in_height[i] / number_of_box_in_height[i] NpixelsPerPanel += number_pixels_in_height[i] \ * number_of_box_in_height[i] \ * number_pixels_in_width[i] \ * number_of_box_in_width[i] instrument.append( Detector('detector{}'.format(i + 1), width[i], height[i], number_pixels_in_width[i], number_pixels_in_height[i], 'detector{}'.format(i + 1), start_index=NpixelsPerPanel * i), position=(sampleTodetector_z[i] * np.sin(angle), 0, sampleTodetector_z[i] * np.cos(angle)), orientation=(0, np.rad2deg(angle), 0), relativeTo=sample ) return instrument No newline at end of file Loading
sample_simulation_mcvine/base/Snap.py 0 → 100644 +43 −0 Original line number Diff line number Diff line import mcvine, mcvine.components as mc import numpy as np # from EventMonitor_4D import EventMonitor_4D as E4D from detector import Detector def instrument(beam, sample_path, angleMons=[45, 135], detector_width=[0.5, 0.5], detector_height=[0.5, 0.5], sourceTosample_x=0., sourceTosample_y=0., sourceTosample_z=0., sampleTodetector_z=[0.5, 0.5], number_detectors=2, number_pixels_in_height=[256, 256], number_pixels_in_width=[256, 256], number_of_box_in_height=[3, 3], number_of_box_in_width=[3, 3]): instrument = mcvine.instrument() source = mc.sources.NeutronFromStorage('source', beam) instrument.append(source, position=(0,0,0)) samplexml = os.path.join(sample_path, 'sampleassembly.xml') sample = mc.samples.SampleAssemblyFromXml('sample', samplexml) instrument.append(sample, position=(0,0,0.5)) width = detector_width height = detector_height NpixelsPerPanel = 0 for i in range(number_detectors): angle = np.deg2rad(angleMons[i]) print('detector_angle: ', angleMons[i]) pixel_width = detector_width[i] / number_pixels_in_width[i] / number_of_box_in_width[i] # *1.00000001 pixel_height = height[i] / number_pixels_in_height[i] / number_of_box_in_height[i] NpixelsPerPanel += number_pixels_in_height[i] \ * number_of_box_in_height[i] \ * number_pixels_in_width[i] \ * number_of_box_in_width[i] instrument.append( Detector('detector{}'.format(i + 1), width[i], height[i], number_pixels_in_width[i], number_pixels_in_height[i], 'detector{}'.format(i + 1), start_index=NpixelsPerPanel * i), position=(sampleTodetector_z[i] * np.sin(angle), 0, sampleTodetector_z[i] * np.cos(angle)), orientation=(0, np.rad2deg(angle), 0), relativeTo=sample ) return instrument No newline at end of file