コード例 #1
0
ファイル: source_blur.py プロジェクト: ufo-kit/syris
def main():
    args = parse_args()
    syris.init()
    n = 1024
    d = args.propagation_distance * q.m
    shape = (n, n)
    ps = 1 * q.um
    energy = 20 * q.keV
    tr = Trajectory([(n / 2, n / 2, 0)] * ps, pixel_size=ps)
    sample = make_sphere(n, n / 30 * ps, pixel_size=ps, material=get_material('air_5_30_kev.mat'))

    bm = make_topotomo(pixel_size=ps, trajectory=tr)
    print 'Source size FWHM (height x width): {}'.format(bm.size.rescale(q.um))

    u = bm.transfer(shape, ps, energy, t=0 * q.s)
    u = sample.transfer(shape, ps, energy)
    intensity = propagate([sample], shape, [energy], d, ps).get()
    incoh = bm.apply_blur(intensity, d, ps).get()

    region = (n / 4, n / 4, n / 2, n / 2)
    intensity = ip.crop(intensity, region).get()
    incoh = ip.crop(incoh, region).get()

    show(intensity, title='Coherent')
    show(incoh, title='Applied source blur')
    plt.show()
コード例 #2
0
ファイル: source_blur.py プロジェクト: flmiot/syris-1
def main():
    args = parse_args()
    syris.init()
    n = 1024
    d = args.propagation_distance * q.m
    shape = (n, n)
    ps = 1 * q.um
    energy = 20 * q.keV
    tr = Trajectory([(n / 2, n / 2, 0)] * ps, pixel_size=ps)
    sample = make_sphere(n,
                         n / 30 * ps,
                         pixel_size=ps,
                         material=get_material('air_5_30_kev.mat'))

    bm = make_topotomo(pixel_size=ps, trajectory=tr)
    print 'Source size FWHM (height x width): {}'.format(bm.size.rescale(q.um))

    u = bm.transfer(shape, ps, energy, t=0 * q.s)
    u = sample.transfer(shape, ps, energy)
    intensity = propagate([sample], shape, [energy], d, ps).get()
    incoh = bm.apply_blur(intensity, d, ps).get()

    region = (n / 4, n / 4, n / 2, n / 2)
    intensity = ip.crop(intensity, region).get()
    incoh = ip.crop(incoh, region).get()

    show(intensity, title='Coherent')
    show(incoh, title='Applied source blur')
    plt.show()
コード例 #3
0
ファイル: experiment.py プロジェクト: ufo-kit/syris
def make_devices(n, energies, camera=None, highspeed=True, scintillator=None):
    """Create devices with image shape (*n*, *n*), X-ray *energies*, *camera* and use the high speed
    setup if *highspeed* is True.
    """
    shape = (n, n)
    dE = energies[1] - energies[0]

    if not camera:
        vis_wavelengths = np.arange(500, 700) * q.nm
        camera = Camera(11 * q.um, .1, 500, 23, 32, shape, exp_time=1 * q.ms, fps=1000 / q.s,
                        quantum_efficiencies=0.5 * np.ones(len(vis_wavelengths)),
                        wavelengths=vis_wavelengths, dtype=np.float32)
    else:
        vis_wavelengths = camera.wavelengths.rescale(q.nm)

    x = vis_wavelengths.rescale(q.nm).magnitude
    dx = x[1] - x[0]
    if scintillator == 'lso' or not (scintillator or highspeed):
        sigma = fwnm_to_sigma(50)
        emission = np.exp(-(x - 545) ** 2 / (2 * sigma ** 2)) / (sigma * np.sqrt(2 * np.pi))
        lso = get_material('lso_5_30_kev.mat')
        scintillator = Scintillator(13 * q.um,
                                    lso,
                                    36 * np.ones(len(energies)) / q.keV,
                                    energies,
                                    emission / q.nm,
                                    vis_wavelengths,
                                    1.82)
    elif scintillator == 'luag' or (not scintillator and highspeed):
        sigma = fwnm_to_sigma(50)
        emission = np.exp(-(x - 450) ** 2 / (2 * sigma ** 2)) / (sigma * np.sqrt(2 * np.pi))
        luag = get_material('luag.mat')
        scintillator = Scintillator(50 * q.um,
                                    luag,
                                    14 * np.ones(len(energies)) / q.keV,
                                    energies,
                                    emission / q.nm,
                                    vis_wavelengths,
                                    1.84)

    if highspeed:
        # High speed setup
        lens = Lens(3, f_number=1.4, focal_length=50 * q.mm, transmission_eff=0.7, sigma=None)
    else:
        # High resolution setup
        lens = Lens(9, na=0.28, sigma=None)

    detector = Detector(scintillator, lens, camera)
    source_trajectory = Trajectory([(n / 2, n / 2, 0)] * detector.pixel_size)
    bm = make_topotomo(dE=dE, trajectory=source_trajectory, pixel_size=detector.pixel_size)

    return bm, detector
コード例 #4
0
ファイル: energy_filter.py プロジェクト: flmiot/syris-1
def main():
    args = parse_args()
    syris.init()
    n = 1024
    shape = (n, n)
    ps = 1 * q.um
    tr = Trajectory([(n / 2, n / 2, 0)] * ps, pixel_size=ps)
    energy_center = args.energy_center * q.keV
    fwhm = args.energy_resolution * energy_center
    sigma = smath.fwnm_to_sigma(fwhm, n=2)
    # Make sure we resolve the curve nicely
    energies = np.arange(max(1 * q.keV, energy_center - 2 * fwhm),
                         energy_center + 2 * fwhm, fwhm / 25) * q.keV
    dE = energies[1] - energies[0]
    print 'Energy from, to, step, number:', energies[0], energies[-1], dE, len(
        energies)

    bm = make_topotomo(dE=dE, pixel_size=ps, trajectory=tr)
    spectrum_energies = np.arange(1, 50, 1) * q.keV
    native_spectrum = get_spectrum(bm, spectrum_energies, ps)

    fltr = GaussianFilter(energies, energy_center, sigma)
    gauss = get_gauss(energies.magnitude, energy_center.magnitude,
                      sigma.magnitude)
    filtered_spectrum = get_spectrum(bm, energies, ps) * gauss

    intensity = propagate([bm, fltr], shape, energies, 0 * q.m, ps).get()

    show(intensity,
         title='Intensity for energy range {} - {}'.format(
             energies[0], energies[-1]))

    plt.figure()
    plt.plot(spectrum_energies.magnitude, native_spectrum)
    plt.title('Source Spectrum')
    plt.xlabel('Energy [keV]')
    plt.ylabel('Intensity')

    plt.figure()
    plt.plot(energies.magnitude, gauss)
    plt.title('Gaussian Filter')
    plt.xlabel('Energy [keV]')
    plt.ylabel('Transmitted intensity')

    plt.figure()
    plt.plot(energies.magnitude, filtered_spectrum)
    plt.title('Filtered Spectrum')
    plt.xlabel('Energy [keV]')
    plt.ylabel('Intensity')
    plt.show()
コード例 #5
0
ファイル: energy_filter.py プロジェクト: ufo-kit/syris
def main():
    args = parse_args()
    syris.init()
    n = 1024
    shape = (n, n)
    ps = 1 * q.um
    tr = Trajectory([(n / 2, n / 2, 0)] * ps, pixel_size=ps)
    energy_center = args.energy_center * q.keV
    fwhm = args.energy_resolution * energy_center
    sigma = smath.fwnm_to_sigma(fwhm, n=2)
    # Make sure we resolve the curve nicely
    energies = np.arange(max(1 * q.keV, energy_center - 2 * fwhm),
                         energy_center + 2 * fwhm,
                         fwhm / 25) * q.keV
    dE = energies[1] - energies[0]
    print 'Energy from, to, step, number:', energies[0], energies[-1], dE, len(energies)

    bm = make_topotomo(dE=dE, pixel_size=ps, trajectory=tr)
    spectrum_energies = np.arange(1, 50, 1) * q.keV
    native_spectrum = get_spectrum(bm, spectrum_energies, ps)

    fltr = GaussianFilter(energies, energy_center, sigma)
    gauss = get_gauss(energies.magnitude, energy_center.magnitude, sigma.magnitude)
    filtered_spectrum = get_spectrum(bm, energies, ps) * gauss

    intensity = propagate([bm, fltr], shape, energies, 0 * q.m, ps).get()

    show(intensity, title='Intensity for energy range {} - {}'.format(energies[0], energies[-1]))

    plt.figure()
    plt.plot(spectrum_energies.magnitude, native_spectrum)
    plt.title('Source Spectrum')
    plt.xlabel('Energy [keV]')
    plt.ylabel('Intensity')

    plt.figure()
    plt.plot(energies.magnitude, gauss)
    plt.title('Gaussian Filter')
    plt.xlabel('Energy [keV]')
    plt.ylabel('Transmitted intensity')

    plt.figure()
    plt.plot(energies.magnitude, filtered_spectrum)
    plt.title('Filtered Spectrum')
    plt.xlabel('Energy [keV]')
    plt.ylabel('Intensity')
    plt.show()
コード例 #6
0
ファイル: edge_enhancement.py プロジェクト: flmiot/syris-1
def main():
    args = parse_args()
    syris.init()
    # Propagate to 20 cm
    d = 20 * q.cm
    # Compute grid
    n_camera = 256
    n = n_camera * args.supersampling
    shape = (n, n)
    material = get_material('pmma_5_30_kev.mat')
    energies = material.energies
    dE = energies[1] - energies[0]
    # Lens with magnification 5 and numerical aperture 0.25
    lens = Lens(5, na=0.25)
    # Considered visible light wavelengths
    vis_wavelengths = np.arange(500, 700) * q.nm
    # Simple camera quantum efficiencies
    cam_qe = 0.1 * np.ones(len(vis_wavelengths))
    camera = Camera(10 * q.um, 0.1, 500, 23, 32, (256, 256), exp_time=args.exposure * q.ms,
                    fps=1 / q.s, quantum_efficiencies=cam_qe, wavelengths=vis_wavelengths,
                    dtype=np.float32)
    # Scintillator emits visible light into a region given by a Gaussian distribution
    x = camera.wavelengths.rescale(q.nm).magnitude
    sigma = fwnm_to_sigma(50)
    emission = np.exp(-(x - 600) ** 2 / (2 * sigma ** 2)) / (sigma * np.sqrt(2 * np.pi))
    # Scintillator 50 um thick, light yield 14 and refractive index 1.84
    luag = get_material('luag.mat')
    scintillator = Scintillator(50 * q.um,
                                luag,
                                14 * np.ones(len(energies)) / q.keV,
                                energies,
                                emission / q.nm,
                                camera.wavelengths,
                                1.84)
    detector = Detector(scintillator, lens, camera)
    # Pixel size used for propagation
    ps = detector.pixel_size / args.supersampling

    fmt = 'Pixel size used for propagation: {}'
    print fmt.format(ps.rescale(q.um))
    fmt = '  Effective detector pixel size: {}'
    print fmt.format(detector.pixel_size.rescale(q.um))
    print '                  Field of view: {}'.format(n * ps.rescale(q.um))

    # Bending magnet source
    trajectory = Trajectory([(n / 2, n / 2, 0)] * ps)
    source = make_topotomo(dE=dE, trajectory=trajectory, pixel_size=ps)

    sample = make_sphere(n, n / 4. * ps, pixel_size=ps, material=material)
    # Propagation with a monochromatic plane incident wave
    coherent = propagate([source, sample], shape, [15 * q.keV], d, ps, t=0 * q.s,
                         detector=detector).get()
    coherent *= camera.exp_time.simplified.magnitude
    # Decimate to fit the effective pixel size of the detector system
    coherent_ld = camera.get_image(coherent, shot_noise=False, amplifier_noise=False)

    # Propagation which takes into account polychromaticity
    poly = propagate([source, sample], shape, range(10, 30) * q.keV, d, ps, t=0 * q.s,
                     detector=detector).get()
    poly *= camera.exp_time.simplified.magnitude
    poly_ld = camera.get_image(poly, shot_noise=args.noise, amplifier_noise=args.noise)

    # Compute and show some of the used propagators
    propagator_10 = get_propagator_psf(n, d, ps, 10 * q.keV)
    propagator_30 = get_propagator_psf(n, d, ps, 30 * q.keV)

    show(coherent, title='Coherent Supersampled')
    show(coherent_ld, title='Coherent Detector')
    show(propagator_10.real, title='Propagator PSF for 10 keV (real part)')
    show(propagator_30.real, title='Propagator PSF for 30 keV (real part)')
    show(poly, title='Polychromatic Supersampled')
    show(poly_ld, title='Polychromatic Detector')
    plt.show()
コード例 #7
0
def make_devices(n, energies, camera=None, highspeed=True, scintillator=None):
    """Create devices with image shape (*n*, *n*), X-ray *energies*, *camera* and use the high speed
    setup if *highspeed* is True.
    """
    shape = (n, n)
    dE = energies[1] - energies[0]

    if not camera:
        vis_wavelengths = np.arange(500, 700) * q.nm
        camera = Camera(11 * q.um,
                        .1,
                        500,
                        23,
                        32,
                        shape,
                        exp_time=1 * q.ms,
                        fps=1000 / q.s,
                        quantum_efficiencies=0.5 *
                        np.ones(len(vis_wavelengths)),
                        wavelengths=vis_wavelengths,
                        dtype=np.float32)
    else:
        vis_wavelengths = camera.wavelengths.rescale(q.nm)

    x = vis_wavelengths.rescale(q.nm).magnitude
    dx = x[1] - x[0]
    if scintillator == 'lso' or not (scintillator or highspeed):
        sigma = fwnm_to_sigma(50)
        emission = np.exp(-(x - 545)**2 /
                          (2 * sigma**2)) / (sigma * np.sqrt(2 * np.pi))
        lso = get_material('lso_5_30_kev.mat')
        scintillator = Scintillator(13 * q.um, lso,
                                    36 * np.ones(len(energies)) / q.keV,
                                    energies, emission / q.nm, vis_wavelengths,
                                    1.82)
    elif scintillator == 'luag' or (not scintillator and highspeed):
        sigma = fwnm_to_sigma(50)
        emission = np.exp(-(x - 450)**2 /
                          (2 * sigma**2)) / (sigma * np.sqrt(2 * np.pi))
        luag = get_material('luag.mat')
        scintillator = Scintillator(50 * q.um, luag,
                                    14 * np.ones(len(energies)) / q.keV,
                                    energies, emission / q.nm, vis_wavelengths,
                                    1.84)

    if highspeed:
        # High speed setup
        lens = Lens(3,
                    f_number=1.4,
                    focal_length=50 * q.mm,
                    transmission_eff=0.7,
                    sigma=None)
    else:
        # High resolution setup
        lens = Lens(9, na=0.28, sigma=None)

    detector = Detector(scintillator, lens, camera)
    source_trajectory = Trajectory([(n / 2, n / 2, 0)] * detector.pixel_size)
    bm = make_topotomo(dE=dE,
                       trajectory=source_trajectory,
                       pixel_size=detector.pixel_size)

    return bm, detector