Example #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')
Example #2
0
def spectrum(z):
        if (type(z) is not type([1])) and (type(z) is not type(np.array(1))):
            x = np.array([z])
        else:
            x = np.array(z)
        return np.piecewise(x, [x < 0, ((x < max_energy) & (x > 0)), (x >= max_energy)], [0, 1./max_energy, 0])

source_distance = -1.496e+13      ## cm
offaxis_angle_arcminX = 21.0      ## 
offaxis_angle_arcminY = 0.17      ## 

source = Source(type='point', center=[source_distance * np.sin(np.deg2rad(offaxis_angle_arcminX / 60.0)),
                                      source_distance * np.sin(np.deg2rad(offaxis_angle_arcminY / 60.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')
print('teo-input-spect.png')
plt.savefig("teo-input-spect.png", dpi=100)


''' Creating the FOXSI telescope '''

module = Module(radii = [5.151,4.9,4.659,4.429,4.21,4.0,3.799], #7Shells
#module = Module(radii = [5.151,4.9,4.659,4.429,4.21,4.0,3.799,3.59,3.38,3.17], #10Shells
                core_radius=(fbr,rbr))

''' Generating rays '''
Example #3
0
    tstart = datetime.now()

    source_distance = 1e4
    source = Source(type='point', center=[0, 0, -source_distance], color=[1, 0, 0])

    # spectrum = lambda x: np.exp(-x)
    max_energy = 30.0

    def spectrum(z):
        if (type(z) is not type([1])) and (type(z) is not type(np.array(1))):
            x = np.array([z])
        else:
            x = np.array(z)
        return np.piecewise(x, [x < 0, (x < max_energy) & (x > 0), (x >= max_energy)], [0, 1 / max_energy, 0])

    source.loadSpectrum(spectrum)
    plot(source)

    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

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

    plot(source)