Example #1
0
 def createDetector(self):
     '''
     Returns a Detector object based on gui input values
     '''
     focal = self.doubleSpinBox.value()
     seglen = self.doubleSpinBox_2.value()
     offset = self.doubleSpinBox_3.value()
     center = [0, 0, focal + seglen + offset]
     width = self.doubleSpinBox_4.value()
     height = self.doubleSpinBox_5.value()
     reso = [self.spinBox_2.value(), self.spinBox_3.value()]
     try:
         return Detector(center=center,
                         width=width,
                         height=height,
                         reso=reso)
     except:
         QMessageBox.warning(
             self, 'Warning',
             'Could not create detector. Check input values.')
         return None
Example #2
0
    # spectrum = lambda x: np.exp(-x)
    max_energy = 30.0
    min_energy = 1.0
    nrays = 500

    energies = numpy.random.rand(nrays) * (max_energy - min_energy) + min_energy
    source_distance = 1e4
    source = Source(type='point', center=[0, 0, -source_distance], color=[1, 0, 0], spectrum=energies)

    radii = [5.15100, 4.90000, 4.65900, 4.42900, 4.21000, 4.00000, 3.79900]  # 7 shell radii
    seglen = 30
    base = [0, 0, 0]
    focal_length = 200
    module = Module(radii=radii, seglen=seglen, base=base, angles=None, focal=focal_length, conic=True)

    detector = Detector(center=[0, 0, 230])  # focal point is at 230 by default

    #  generate nrays from the source
    rays = source.generateRays(module.targetFront, nrays)

    plt.figure()
    plt.hist([ray.energy for ray in rays], normed=True, label='generated rays')
    plt.legend()
    plt.show()

    # pass rays through module
    module.passRays(rays, robust=True)

    # catch rays at detector
    detector.catchRays(rays)
Example #3
0
Created on Aug 15, 2011

@author: rtaylor
'''
from foxsisim.module import Module
from foxsisim.detector import Detector
from foxsisim.source import Source
import matplotlib.pyplot as plt

if __name__ == '__main__':

    # create module using defaults
    module = Module()
    
    # create large detector facing aperture
    detector = Detector(center=[0,0,-100], normal=[0,0,1], width=50, height=50)
    
    # create a nonpoint source replacing the detector
    source = Source(center=[0,0,230], normal=[0,0,-1], width=2, height=2, type='nonpoint')
    
    #  generate 1000 rays at source and target them towards the **backend** of module
    rays = source.generateRays(module.targetBack, 1000)
    
    # simulate
    module.passRays(rays)
    detector.catchRays(rays)
    
    # plot detector pixels
    fig1 = plt.figure(figsize=(5,5))
    axes1 = fig1.gca()
    detector.plotImage(axes1)
Example #4
0
from foxsisim.plotting import plot
import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    # create module of 7 shells
    module = Module(radii=[5.151, 3.799],
                    seglen=30.0,
                    base=[0, 0, 0],
                    focal=200,
                    angles=None,
                    conic=False)

    detector = Detector(width=0.96,
                        height=0.96,
                        normal=[0, 0, 1],
                        center=[0, 0, 200.0 + 30.0],
                        reso=[128, 128])

    source_distance = -2187.5
    offaxis_angle_arcmin = 1.0
    source = Source(
        type='point',
        center=[
            source_distance * np.sin(np.deg2rad(offaxis_angle_arcmin / 60.0)),
            0.0, source_distance
        ],
        color=[0, 1, 1])

    rays = source.generateRays(module.targetFront, 2000)
    module.passRays(rays, robust=True)
Example #5
0
source_distance = -1e4  ##cm
source = Source(type='point', center=[0, 0, source_distance])
source.loadSpectrum(spectrum)
energies = np.arange(-10, 60, 0.1)
plt.plot(energies, source._spectrum(energies))
plt.xlabel('Energy [keV]')
plt.title('Source Spectrum')
#plt.show()
print('teo-input-spect.png')
plt.savefig('teo-input-spect.png')

module = Module(radii=[5.151, 4.9], focal=200.0)
detector = Detector(width=8,
                    height=8,
                    normal=[0, 0, 1],
                    center=[0, 0, 230],
                    reso=[1024, 1024])

rays = source.generateRays(module.targetFront, 7)

print('rays generated')

plt.figure()
plt.hist([ray.energy for ray in rays], normed=True, label='generated rays')
plt.xlabel('Energy [keV]')
plt.title('Histogram generated rays')
plt.legend()
#plt.show()
print('gen-input-spect.png')
plt.savefig('gen-input-spect.png')
Example #6
0
''' Example 2 using the geometry of the Hyp and Par. This should show
perfect focusing with all rays falling in a point.'''

from foxsisim.module import Module
from foxsisim.detector import Detector
from foxsisim.source import Source
from foxsisim.plotting import scatterHist
from foxsisim.plotting import plot

import matplotlib.pyplot as plt

if __name__ == '__main__':

    # create module/detector/source objects using defaults
    module = Module()
    detector = Detector()
    source = Source()

    # generate 1000 rays at source
    rays = source.generateRays(module.targetFront, 1000)

    # pass rays through module
    module.passRays(rays, robust=True)

    # catch rays at detector
    detector.catchRays(rays)

    # plot detector pixels
    plot(detector)

    # create scatter plot
Example #7
0
from foxsisim.module import Module
from foxsisim.detector import Detector
from foxsisim.source import Source
from foxsisim.plotting import scatterHist
from foxsisim.plotting import plot

import matplotlib.pyplot as plt

if __name__ == '__main__':

    # create module/detector/source objects using defaults
    module = Module()
    detector = Detector(tag='Det')
    source = Source(tag='Source')

    # generate 1000 rays at source
    rays = source.generateRays(module.targetFront, 1000)

    # pass rays through module
    module.passRays(rays, robust=True)

    # catch rays at detector
    detector.catchRays(rays)
    for ray in rays:
        print("{0} {1} {2}".format(ray.bounces, ray.dead, ray.tag))
Example #8
0
@author: rtaylor
'''
from foxsisim.module import Module
from foxsisim.detector import Detector
from foxsisim.source import Source
from foxsisim.plotting import plot
import matplotlib.pyplot as plt

if __name__ == '__main__':

    # create module using defaults
    module = Module(conic=True)

    # create large detector facing aperture
    detector = Detector(center=[0, 0, -100],
                        normal=[0, 0, 1],
                        width=50,
                        height=50)

    # create a nonpoint source replacing the detector
    source = Source(center=[0, 0, 230],
                    normal=[0, 0, -1],
                    width=2,
                    height=2,
                    type='nonpoint')

    #  generate 1000 rays at source and target them towards the **backend** of module
    rays = source.generateRays(module.targetBack, 1000)

    # simulate
    module.passRays(rays)
    detector.catchRays(rays)