Ejemplo n.º 1
0
def make_rays(angle,nrays,proc):
    fbr = 6.296              ## Front blocker radius
    rbr = 5.99               ## Rear blocker radius

    # Creating the FOXSI telescope
    module = Module(radii = [9.333,9.153,8.973,8.793,8.613,8.434,8.255,
                             8.076,7.897,7.718,7.540,7.362,7.184,7.006,
                             6.828,6.650,6.473,6.296], focal=1400.0, core_radius=(fbr,rbr))

    Sdist = -1.5e13         ## Source distance in cm
    Xs = -Sdist * np.sin(np.deg2rad(np.sqrt(2.) * angle / 120.0))
    Ys = -Sdist * np.sin(np.deg2rad(np.sqrt(2.) * angle / 120.0))
    source = Source(type='point', center=[Xs, Ys, Sdist ])
    source.loadSpectrum(spectrum)

    # Generating rays
    rays = source.generateRays(module.targetFront, nrays)
    # Passing rays
    module.passRays(rays)
    Trays = [ray for ray in rays if (ray.dead==False)] ## save only those alive rays
    save_rays(Trays,filename=f'rays_Angle_=_{angle}_{proc}.csv')
Ejemplo n.º 2
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)

    rays_on_detector = len(detector.rays)

    plot(detector, energy_range=[0, 15])
Ejemplo n.º 3
0
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)

    # show
    plt.show()
Ejemplo n.º 4
0
from foxsisim.detector import Detector
from foxsisim.source import Source
from foxsisim.plotting import scatterHist
from foxsisim.mymath import reflect
import matplotlib.pyplot as plt
from numpy.linalg import norm

if __name__ == '__main__':

    # create default shell/detector/source
    shell = Shell(conic=True)
    detector = Detector()
    source = Source()
    
    # generate 500 rays pointing at shell
    rays = source.generateRays(shell.targetFront, 500)
    
    # pass rays through shell
    surfaces = shell.getSurfaces() # each shell has two segments
    for ray in rays:
        while True:
            
            sol = None
            for surface in surfaces:
                
                # solve for intersection of ray with surface
                sol = surface.rayIntersect(ray)
                if sol is not None: break
            
            # if ray hits reflective surface
            if sol is not None:
Ejemplo n.º 5
0
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)

    # plot detector pixels
    plot(detector)

    # show
    plt.show()
Ejemplo n.º 6
0
                    center=[0,0,200.0+30.0],
                    reso =[256,256])


# In[3]:

source_distance = -2187.5
offaxis_angle_arcmin = 0.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])


# In[4]:

rays = source.generateRays(module.targetFront, 10)
module.passRays(rays, robust=True)
detector.catchRays(rays)


# In[5]:

plot(detector)


# In[6]:

scatterHist(rays)


# In[7]:
Ejemplo n.º 7
0
    
    # create a few sources of different types
    source1 = Source() # a white source 'at infinity' whose rays point perpendicular to module aperture
    
    source2 = Source(type='point',          # a point source
                     center=[10,10,-35000], # located at [x=10,y=10,z=-35000]
                     color=[1,0,0])         # and colored red
    
    source3 = Source(width=0.0001,          # a 1 micron
                     height=0.0001,         # by 1 micron
                     type='nonpoint',       # non-point source (a square region)
                     center=[5,-8,-20000],  # centered at [x=5,y=-8,z=20000]
                     color=[0,1,1])         # and colored light blue
    
    #  generate 500 rays from each source
    rays = source1.generateRays(module.targetFront,500)
    rays.extend(source2.generateRays(module.targetFront,500))
    rays.extend(source3.generateRays(module.targetFront,500))
    
    # pass rays through module
    module.passRays(rays, robust=True)
    
    # catch rays at detector
    detector.catchRays(rays)
    
    # plot detector pixels
    plot(detector)
    
    # show
    plt.show()
Ejemplo n.º 8
0
    )  # a white source 'at infinity' whose rays point perpendicular to module aperture

    source2 = Source(
        type='point',  # a point source
        center=[10, 10, -35000],  # located at [x=10,y=10,z=-35000]
        color=[1, 0, 0])  # and colored red

    source3 = Source(
        width=0.0001,  # a 1 micron
        height=0.0001,  # by 1 micron
        type='nonpoint',  # non-point source (a square region)
        center=[5, -8, -20000],  # centered at [x=5,y=-8,z=20000]
        color=[0, 1, 1])  # and colored light blue

    #  generate 500 rays from each source
    rays = source1.generateRays(module.targetFront, 500)
    rays.extend(source2.generateRays(module.targetFront, 500))
    rays.extend(source3.generateRays(module.targetFront, 500))

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

    # catch rays at detector
    detector.catchRays(rays)

    # plot detector pixels
    plot(detector)

    # show
    plt.show()
Ejemplo n.º 9
0
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,
                           nrays)  # this should run for about 7 hours

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')

from datetime import datetime
tstart = datetime.now()