Esempio n. 1
0
 def setUp(self):
     default_syris_init()
     lens = Lens(3.0, f_number=1.4, focal_length=100.0 * q.mm)
     camera = Camera(1 * q.um, 0.1, 10, 1.0, 12, (64, 64))
     detector = Detector(None, lens, camera)
     ps = detector.pixel_size
     t = np.linspace(0, 1, 10) * q.mm
     x = t
     y = np.zeros(len(t))
     z = np.zeros(len(t))
     points = list(zip(x, y, z)) * q.mm
     mb_0 = MetaBall(
         Trajectory(points,
                    pixel_size=ps,
                    furthest_point=1 * q.um,
                    velocity=1 * q.mm / q.s),
         1 * q.um,
     )
     mb_1 = MetaBall(
         Trajectory(points,
                    pixel_size=ps,
                    furthest_point=1 * q.um,
                    velocity=2 * q.mm / q.s),
         1 * q.um,
     )
     self.experiment = Experiment([mb_0, mb_1], None, detector, 0 * q.m,
                                  None)
Esempio n. 2
0
 def setUp(self):
     self.f_length = 100 * q.mm
     self.f_number = 1.4
     self.magnification = 1
     self.transmission_eff = 0.5
     self.psf_sigma = (1, 1) * q.um
     self.lens = Lens(self.magnification,
                      f_number=self.f_number,
                      focal_length=self.f_length,
                      transmission_eff=self.transmission_eff,
                      sigma=self.psf_sigma)
Esempio n. 3
0
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()
Esempio n. 4
0
 def setUp(self):
     self.lens = Lens(3., f_number=1.4, focal_length=100.0 * q.mm)
     self.camera = Camera(10 * q.um, 0.1, 10, 1, 12, None)
     self.detector = Detector(None, self.lens, self.camera)
Esempio n. 5
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
Esempio n. 6
0
#syris.init( loglevel = logging.DEBUG)
syris.init()

shape = (n, n)
dE_mono = 1e-4
energy = 20000
energies = np.linspace(
    energy - 2 * dE_mono * energy, energy + 2 * dE_mono * energy, num=4) * q.eV
dE = energies[1] - energies[0]

# === CAMERA ===
camera = make_kit_cmos(EXPOSURE_TIME)
camera.pixel_size = camera.pixel_size / SUPERSAMPLING
camera.shape = shape
# === LENS ===
lens = Lens(10, na=0.1, transmission_eff=0.6, sigma=None)
# === SCINTILLATOR ===
scintillator = CdWO4(100 * q.um, energies)
# === DETECTOR ===
detector = Detector(scintillator, lens, camera)

# === BENDING MAGNET SOURCE ===
"""
Sector 4	sigma
BeamAngleDelta.X[5][0]	0,089555518	urad
BeamAngleDelta.Y[5][0]	0,033106066	urad
BeamPositionDelta.X[5][0]	0,16299738	um
BeamPositionDelta.Y[5][0]	0,062605455	um
"""
fak = 0.6
k = 1
Esempio n. 7
0
 def test_na_supersedes_compute(self):
     gt = 0.5
     lens = Lens(1, na=gt, f_number=2, focal_length=100 * q.mm)
     self.assertEqual(gt, lens.na)
Esempio n. 8
0
 def test_constructor_args(self):
     self.assertRaises(ValueError, Lens, 1)
     Lens(1, na=1)
     Lens(1, f_number=1, focal_length=1 * q.m)
Esempio n. 9
0
 def test_given_numerical_aperture(self):
     gt = 1
     lens = Lens(1, na=gt)
     self.assertEqual(gt, lens.numerical_aperture)