コード例 #1
0
ファイル: coherent.py プロジェクト: twguest/FELpy
def construct_gaussian(nx, ny, ekev, extent, sigX, sigY, divergence, xoff = 0, yoff = 0, tau = 1, mx = 0, my = 0, tiltX = 0, tiltY = 0):
    gsnBm = build_gaussian(nx, ny, ekev, xMin = extent[0], xMax = extent[1], yMin = extent[2], yMax = extent[3],
                           sigX = sigX, sigY = sigY, d2waist = 1, xoff = xoff, yoff = yoff, pulseTau = tau, _mx = mx, _my = my, tiltX= tiltX, tiltY = tiltY)

    wfr = Wavefront(gsnBm)
    wfr.params.wavelength = ekev2wav(ekev)
    
    modify_beam_divergence(wfr,sigX, divergence) 
    return wfr
コード例 #2
0
    def generator(self, outdir, N=1):
        """
        this is the emission process, and generates N wavefronts according to the rules given by the source paramters file.
        
        currently, it will only support cases where the input dictionary has values in the form of a single value or list.
        
        :param
        """

        for n in range(N):
            self.set_empirical_values()

            self.build_properties()

            for itr in range(self._control):
                pulse_properties = {
                    item: self.source_properties[item][itr]
                    for item in self.source_properties
                }
                tp = self.get_temporal_profile(pulse_properties)
                pulse_properties['nz'] = len(tp)
                tilt = wavefront_tilt(
                    np.meshgrid(
                        np.linspace(pulse_properties['xMin'],
                                    pulse_properties['xMax'],
                                    pulse_properties['nx']),
                        np.linspace(pulse_properties['yMin'],
                                    pulse_properties['yMax'],
                                    pulse_properties['ny'])),
                    2 * np.pi * np.sin(pulse_properties['theta_x']) /
                    ekev2wav(pulse_properties['ekev']),
                    2 * np.pi * np.sin(pulse_properties['theta_y']) /
                    ekev2wav(pulse_properties['ekev']))

                efield = self.generate_beam_envelope(
                    pulse_properties)[:, :, np.newaxis] * tp * tilt[:, :,
                                                                    np.newaxis]

                self.generate(efield,
                              pulse_properties,
                              outdir=outdir + "_{:02}_{:04}.h5".format(n, itr))
コード例 #3
0
    for r in dr:
        theta_r = phase_gradient(x, r, k, delta, offset=r)
        ax1.plot(x * M * 1e3, theta_r, label="{} mm".format(r * 1e3))

    ax1.set_xlim([0, 15])

    ax1.set_xlabel("x (mm)")
    ax1.set_ylabel("Phase Gradient ($\mu rad$)")
    plt.legend()


if __name__ == '__main__':
    delta = 4e-07  ### perspex
    ekev = 25
    wav = ekev2wav(ekev)

    k = (np.pi * 2) / wav
    N = 5000

    x = np.linspace(-5e-02, 5e-02, N)

    z1 = .1
    z2 = 2

    print("Angular Sensitivity: {}".format(angular_sensitivity(6.5e-06, z2)))

    M = fresnel_magnification(z1, z2)

    # =============================================================================
    #     plot_fullfield_image(r = 15e-03)
コード例 #4
0
ファイル: speckle.py プロジェクト: twguest/FELpy
def define_speckle_mask(sample_directory,
                        rx,
                        ry,
                        sample_thickness,
                        sample_delta,
                        ekev=None,
                        xc=0,
                        yc=0,
                        plot=False):

    arr = load_tif(sample_directory)

    sample_thicc = arr / 255 * sample_thickness

    if plot:
        plt.style.use(['science', 'ieee'])

        ### plot sample thickness

        fig, ax1 = plt.subplots()
        img = ax1.imshow(sample_thicc * 1e6,
                         cmap="bone",
                         norm=colors.Normalize())

        ax1.set_xlabel("x (mm)")
        ax1.set_ylabel("y (mm)")

        divider = make_axes_locatable(ax1)
        cax = divider.append_axes('right', size='7.5%', pad=0.05)

        cbar = fig.colorbar(img, cax)
        cbar.set_label("Thickness ($\mu$m)")

    if plot and ekev is not None:
        plt.style.use(['science', 'ieee'])

        ### plot sample phase-shift

        fig, ax1 = plt.subplots()
        img = ax1.imshow(wrap_phase(
            get_phase_shift(sample_thicc, ekev2wav(ekev))),
                         cmap="hsv")

        ax1.set_xlabel("x (mm)")
        ax1.set_ylabel("y (mm)")

        divider = make_axes_locatable(ax1)
        cax = divider.append_axes('right', size='7.5%', pad=0.05)

        cbar = fig.colorbar(img, cax)
        cbar.set_label("Phase Shift (rad)")

        cax.set_xlim([-np.pi, np.pi])

    s = Sample(sample_directory,
               rx=rx,
               ry=ry,
               thickness=sample_thicc,
               delta=sample_delta,
               atten_len=1,
               xc=xc,
               yc=yc,
               invert=True)

    return s
コード例 #5
0
from wpg.wpg_uti_wf import plot_intensity_map

from .examples.NFS.cylinder_phase_mask import phase, cylinder_thickness
import numpy as np
from felpy.utils.opt_utils import ekev2wav
from felpy.model.tools import propagation_parameters
from wpg.optical_elements import Drift
from wpg.beamline import Beamline
from .examples.NFS.speckle import define_speckle_mask

from felpy.analysis.statistics.correlation import norm

from PIL import Image

ekev = 25
wav = ekev2wav(25)
k = np.pi * 2 / wav
delta = 4e-07
d2waist = (wav) / (np.arctan(.27 / 8) * np.pi)

r = 75e-03

wfr = Wavefront(
    construct_gaussian(1024, 1024, 25, -15e-02, 15e-02, -15e-02, 15e-02, 3e-2,
                       3e-02, d2waist))

### PLOT 1
plot_intensity_map(wfr)

bl = Beamline()
コード例 #6
0
    #     images = [load_tif(fdir + a)[700:800,700:800] for a in os.listdir(fdir)]
    #     #images = [load_tif(fdir + a) for a in os.listdir(fdir)]
    #
    #     reference = images[0]
    #     images = images[1:]
    # =============================================================================

    ### using thibault speckle
    reference, images = get_measurements()
    images = list(images)

    plot_images(reference, images, cmap='bone', clabel="Projected Thickness")

    reference_map = paganin_method(I=reference,
                                   n_ratio=100,
                                   wav=ekev2wav(6.2),
                                   z=.15)

    distorted_maps = [
        paganin_method(I=a, n_ratio=100, wav=ekev2wav(6.2), z=.15)
        for a in images
    ]

    reference_thickness = determine_thickness(reference_map,
                                              ekev2wav(6.2),
                                              delta=4e-07)

    distorted_thickness = []
    for item in distorted_maps:
        distorted_thickness.append(
            determine_thickness(item, ekev2wav(6.2), delta=4e-07))