예제 #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')
예제 #2
0
    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])
    plt.show()

    print('Number of rays on Detector ' + str(rays_on_detector))
    print('Time total: ' + str((datetime.now() - tstart).seconds) + ' seconds')
    print('Time per ray (s): ' +
          str(rays_on_detector / float((datetime.now() - tstart).seconds)))
예제 #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()
예제 #4
0
    # Normalize the input spectrum
    fy = fy / fy.sum()
    # Define a 2xN array as Input to the source
    flarespectrum = np.array((fx, fy))

    # Create the FOXSI telescope
    module = Module(
        radii=[5.151, 4.9, 4.659, 4.429, 4.21, 4.0, 3.799, 3.59, 3.38, 3.17],
        core_radius=(fbr, rbr))
    Sdist = 1.496e+13  # 1AU in cm
    source = Source(type='point',
                    center=[0., 0., -Sdist],
                    spectrum=flarespectrum)
    rays = source.generateRays(module.targetFront, nrays)
    # Passing rays
    module.passRays(rays)
    # Plot the Input and output spectra
    energies = [r.energy for r in rays]
    plt.hist(energies,
             bins=20,
             density=True,
             histtype='stepfilled',
             alpha=.7,
             label='output spec')
    plt.plot(fx, 50 * fy, '-', alpha=.7, label='Input flare spec')
    plt.yscale('log')
    plt.xlim(3, 20.5)
    plt.xlabel('Energy [keV]')
    plt.title('Normalized M3 flare spectrum', fontsize=18)
    plt.legend()
    plt.show()