예제 #1
0
def KBv(input_wavefront):
    optical_element = WOIdealLens(name='', focal_x=0.099946, focal_y=None)

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=0.000000,
            q=0.000000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x',
                                                     1.000000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(
        propagation_parameters=propagation_parameters,
        handler_name='FRESNEL_ZOOM_1D')
    return output_wavefront
예제 #2
0
파일: __init__.py 프로젝트: tschoonj/wofry
def initialize_default_propagator_1D():
    propagator = PropagationManager.Instance()

    propagator.add_propagator(Fraunhofer1D())
    propagator.add_propagator(Fresnel1D())
    propagator.add_propagator(FresnelConvolution1D())
    propagator.add_propagator(Integral1D())
    propagator.add_propagator(FresnelZoom1D())
    propagator.add_propagator(FresnelZoomScaling1D())
예제 #3
0
def propagate_in_vacuum(input_wavefront,magnification_x=10.0,propagator_flag='z'):
    #
    # Import section
    #
    import numpy
    from wofry.propagator.propagator import PropagationManager, PropagationElements, PropagationParameters
    from syned.beamline.beamline_element import BeamlineElement
    from syned.beamline.element_coordinates import ElementCoordinates
    from wofry.propagator.propagators1D.fresnel_zoom import FresnelZoom1D
    from wofry.propagator.propagators1D.integral import Integral1D
    #
    # info on current oe
    #
    #
    #    -------WOScreen1D---------
    #        -------BoundaryShape---------
    #

    #
    # define current oe
    #
    from wofry.beamline.optical_elements.ideal_elements.screen import WOScreen1D

    optical_element = WOScreen1D()

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(optical_element=optical_element,
                                       coordinates=ElementCoordinates(p=15.000000, q=0.000000,
                                                                      angle_radial=numpy.radians(0.000000),
                                                                      angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(wavefront=input_wavefront.duplicate(),
                                                   propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x', magnification_x)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
        propagator.add_propagator(Integral1D())
    except:
        pass

    if propagator_flag == 'z':
        handler_name = 'FRESNEL_ZOOM_1D'
    elif propagator_flag == 'i':
        handler_name = 'INTEGRAL_1D'

    output_wavefront = propagator.do_propagation(propagation_parameters=propagation_parameters,
                                                 handler_name=handler_name)

    return output_wavefront
예제 #4
0
def propagate_from_M1_to_M3(wf_in, magnification_x=2.0):
    #
    # ===== Example of python code to create propagate current element =====
    #

    #
    # Import section
    #
    import numpy
    from wofry.propagator.propagator import PropagationManager, PropagationElements, PropagationParameters
    from syned.beamline.beamline_element import BeamlineElement
    from syned.beamline.element_coordinates import ElementCoordinates
    from wofry.propagator.propagators1D.fresnel_zoom import FresnelZoom1D


    input_wavefront = wf_in.duplicate()

    #
    # info on current oe
    #
    #
    #    -------WOScreen1D---------
    #        -------BoundaryShape---------
    #

    #
    # define current oe
    #
    from wofry.beamline.optical_elements.ideal_elements.screen import WOScreen1D

    optical_element = WOScreen1D()

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(optical_element=optical_element,
                                       coordinates=ElementCoordinates(p=0.000000, q=13.599000,
                                                                      angle_radial=numpy.radians(0.000000),
                                                                      angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(wavefront=input_wavefront.duplicate(),
                                                   propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x', magnification_x)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(propagation_parameters=propagation_parameters,
                                                 handler_name='FRESNEL_ZOOM_1D')
    return output_wavefront
예제 #5
0
def apply_M3_focusing(wf_in,focal_x=2.407000):
    #
    # ===== Example of python code to create propagate current element =====
    #

    #
    # Import section
    #
    import numpy
    from wofry.propagator.propagator import PropagationManager, PropagationElements, PropagationParameters
    from syned.beamline.beamline_element import BeamlineElement
    from syned.beamline.element_coordinates import ElementCoordinates
    from wofry.propagator.propagators1D.fresnel_zoom import FresnelZoom1D

    input_wavefront = wf_in.duplicate()

    #
    # info on current oe
    #
    #
    #    -------WOIdealLens---------
    #        focal_x: 2.407 m # Focal length in x [horizontal]
    #        focal_y: None m # Focal length in y [vertical]
    #

    #
    # define current oe
    #
    from wofry.beamline.optical_elements.ideal_elements.lens import WOIdealLens

    optical_element = WOIdealLens(name='', focal_x=focal_x, focal_y=None)

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(optical_element=optical_element,
                                       coordinates=ElementCoordinates(p=0.000000, q=0.000000,
                                                                      angle_radial=numpy.radians(0.000000),
                                                                      angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(wavefront=input_wavefront.duplicate(),
                                                   propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x', 1.000000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(propagation_parameters=propagation_parameters,
                                                 handler_name='FRESNEL_ZOOM_1D')
    return output_wavefront
예제 #6
0
    def _back_propagation_for_size_calculation(self,theta,radiation_flux,photon_energy,
                                                distance=100.0,magnification=0.010000):
        """
        Calculate the radiation_flux vs theta at a "distance"
        Back propagate to -distance
        The result is the size distrubution

        :param theta:
        :param radiation_flux:
        :param photon_energy:
        :param distance:
        :param magnification:
        :return: None; stores results in self._photon_size_distribution
        """

        from wofry.propagator.wavefront1D.generic_wavefront import GenericWavefront1D
        from wofry.propagator.propagator import PropagationManager, PropagationElements, PropagationParameters
        from syned.beamline.beamline_element import BeamlineElement
        from syned.beamline.element_coordinates import ElementCoordinates
        from wofry.propagator.propagators1D.fresnel_zoom import FresnelZoom1D
        from wofry.beamline.optical_elements.ideal_elements.screen import WOScreen1D


        input_wavefront = GenericWavefront1D().initialize_wavefront_from_arrays(theta*distance,numpy.sqrt(radiation_flux)+0j)
        input_wavefront.set_photon_energy(photon_energy)
        input_wavefront.set_spherical_wave(radius=distance,complex_amplitude=numpy.sqrt(radiation_flux)+0j)
        # input_wavefront.save_h5_file("tmp2.h5","wfr")

        optical_element = WOScreen1D()
        #
        # propagating
        #
        #
        propagation_elements = PropagationElements()
        beamline_element = BeamlineElement(optical_element=optical_element,
                        coordinates=ElementCoordinates(p=0.0,q=-distance,
                        angle_radial=numpy.radians(0.000000),
                        angle_azimuthal=numpy.radians(0.000000)))
        propagation_elements.add_beamline_element(beamline_element)
        propagation_parameters = PropagationParameters(wavefront=input_wavefront.duplicate(),propagation_elements = propagation_elements)
        propagation_parameters.set_additional_parameters('magnification_x', magnification)

        #
        propagator = PropagationManager.Instance()
        try:
            propagator.add_propagator(FresnelZoom1D())
        except:
            pass
        output_wavefront = propagator.do_propagation(propagation_parameters=propagation_parameters,handler_name='FRESNEL_ZOOM_1D')

        self._result_photon_size_distribution = {"x":output_wavefront.get_abscissas(),"y":output_wavefront.get_intensity()}
예제 #7
0
def Screen_v(input_wavefront, fresnel=True):
    boundary_shape = Rectangle(x_left=-0.5,
                               x_right=0.5,
                               y_bottom=-0.5,
                               y_top=0.5)

    from wofry.beamline.optical_elements.absorbers.slit import WOSlit1D
    optical_element = WOSlit1D(boundary_shape=boundary_shape)

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=0.050000,
            q=0.000000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x',
                                                     0.000020)
    #
    propagator = PropagationManager.Instance()
    try:
        if fresnel:
            propagator.add_propagator(FresnelZoom1D())
        else:
            propagator.add_propagator(Integral1D())
    except:
        pass

    if fresnel:
        output_wavefront = propagator.do_propagation(
            propagation_parameters=propagation_parameters,
            handler_name='FRESNEL_ZOOM_1D')
    else:
        output_wavefront = propagator.do_propagation(
            propagation_parameters=propagation_parameters,
            handler_name='INTEGRAL_1D')

    return output_wavefront
예제 #8
0
def Aperture_40m(input_wavefront):
    # from syned.beamline.shape import Rectangle
    # note that wavefront 1d will be clipped using the first two coordinates!
    boundary_shape = Rectangle(x_left=-2.5e-05,
                               x_right=2.5e-05,
                               y_bottom=-2.5e-05,
                               y_top=2.5e-05)

    from wofry.beamline.optical_elements.absorbers.slit import WOSlit1D
    optical_element = WOSlit1D(boundary_shape=boundary_shape)

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=11.700000,
            q=0.000000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x',
                                                     0.010000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())

    except:
        pass

    output_wavefront = propagator.do_propagation(
        propagation_parameters=propagation_parameters,
        handler_name='FRESNEL_ZOOM_1D')

    return output_wavefront
예제 #9
0
def ML_size(input_wavefront):
    # note that wavefront 1d will be clipped using the first two coordinates!
    boundary_shape = Rectangle(x_left=-0.0018849,
                               x_right=0.0018849,
                               y_bottom=-0.0018849,
                               y_top=0.0018849)

    optical_element = WOSlit1D(boundary_shape=boundary_shape)

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #

    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=0.000000,
            q=0.000000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)

    propagation_parameters.set_additional_parameters('magnification_x',
                                                     1.000000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(
        propagation_parameters=propagation_parameters,
        handler_name='FRESNEL_ZOOM_1D')

    return output_wavefront
예제 #10
0
def Aperture_40m_V_open(input_wavefront):
    boundary_shape = Rectangle(x_left=-0.5,
                               x_right=0.5,
                               y_bottom=-0.5,
                               y_top=0.5)

    optical_element = WOSlit1D(boundary_shape=boundary_shape)

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=11.700000,
            q=0.000000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x',
                                                     0.640000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(
        propagation_parameters=propagation_parameters,
        handler_name='FRESNEL_ZOOM_1D')

    return output_wavefront
예제 #11
0
#
# propagating
#
#
propagation_elements = PropagationElements()
beamline_element = BeamlineElement(
    optical_element=optical_element,
    coordinates=ElementCoordinates(p=-100.000000,
                                   q=0.000000,
                                   angle_radial=numpy.radians(0.000000),
                                   angle_azimuthal=numpy.radians(0.000000)))
propagation_elements.add_beamline_element(beamline_element)
propagation_parameters = PropagationParameters(
    wavefront=input_wavefront.duplicate(),
    propagation_elements=propagation_elements)
propagation_parameters.set_additional_parameters('magnification_x',
                                                 0.01)  #0.010000)

#
propagator = PropagationManager.Instance()
try:
    propagator.add_propagator(FresnelZoom1D())
except:
    pass
output_wavefront = propagator.do_propagation(
    propagation_parameters=propagation_parameters,
    handler_name='FRESNEL_ZOOM_1D')

plot(output_wavefront.get_abscissas() * 1e6, output_wavefront.get_intensity())
예제 #12
0
def run_whole_beamline(
        error_file_M1="/home/manuel/Oasys/dabam_profile_140327232022424.dat",
        correction_file_M3=None,
        calculate_correction=True):
    #
    # source
    #
    output_wavefront = calculate_wavefront1D(wavelength=4.9593679373280105e-09,
                                             wavefront_position=1,
                                             undulator_length=3.98,
                                             undulator_distance=13.73,
                                             x_min=-0.00147,
                                             x_max=0.00147,
                                             number_of_points=3000,
                                             add_random_phase=False)

    #
    # M1
    #
    input_wavefront = output_wavefront
    output_wavefront, abscissas_on_mirror, height = calculate_output_wavefront_after_reflector1D(
        input_wavefront,
        radius=496600.0,
        grazing_angle=0.0218,
        error_flag=1,
        error_file=error_file_M1,
        write_profile=1)

    #
    # screen at M3 position
    #

    #
    # Import section
    #
    from wofry.propagator.propagator import PropagationManager, PropagationElements, PropagationParameters
    from syned.beamline.beamline_element import BeamlineElement
    from syned.beamline.element_coordinates import ElementCoordinates
    from wofry.propagator.propagators1D.fresnel_zoom import FresnelZoom1D

    input_wavefront = output_wavefront

    #
    # info on current oe
    #
    #
    #    -------WOScreen1D---------
    #        -------BoundaryShape---------
    #

    #
    # define current oe
    #
    from wofry.beamline.optical_elements.ideal_elements.screen import WOScreen1D

    optical_element = WOScreen1D()

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=0.000000,
            q=13.599000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x',
                                                     2.000000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(
        propagation_parameters=propagation_parameters,
        handler_name='FRESNEL_ZOOM_1D')

    #
    # M3 circlular mirror
    #

    input_wavefront = output_wavefront
    output_wavefront, abscissas_on_mirror, height = calculate_output_wavefront_after_reflector1D(
        input_wavefront,
        radius=220.71532,
        grazing_angle=0.02181,
        error_flag=0,
        error_file="",
        write_profile=0)

    #
    # M3 corrector (not needed)
    #

    if calculate_correction:
        input_wavefront = output_wavefront

        output_wavefront, target_wavefront, abscissas_on_mirror, height = calculate_output_wavefront_after_corrector1D(
            input_wavefront,
            grazing_angle=0.02181,
            focus_at=2.64,
            apodization=0,
            apodization_ratio=6.0,
            write_correction_profile=1)

    # from srxraylib.plot.gol import plot
    # plot(output_wavefront.get_abscissas(),output_wavefront.get_intensity())

    if correction_file_M3 is not None:
        #
        # M3 corrector from external file
        #

        input_wavefront = output_wavefront
        output_wavefront, abscissas_on_mirror, height = calculate_output_wavefront_after_reflector1D(
            input_wavefront,
            radius=100000000.0,
            grazing_angle=0.02181,
            error_flag=1,
            error_file=correction_file_M3,
            write_profile=0)

    #
    # propagation to sample
    #

    input_wavefront = output_wavefront

    #
    # define current oe
    #
    from wofry.beamline.optical_elements.ideal_elements.screen import WOScreen1D

    optical_element = WOScreen1D()

    #
    # propagating (***  ONLY THE ZOOM PROPAGATOR IS IMPLEMENTED ***)
    #
    #
    propagation_elements = PropagationElements()
    beamline_element = BeamlineElement(
        optical_element=optical_element,
        coordinates=ElementCoordinates(
            p=0.000000,
            q=2.640000,
            angle_radial=numpy.radians(0.000000),
            angle_azimuthal=numpy.radians(0.000000)))
    propagation_elements.add_beamline_element(beamline_element)
    propagation_parameters = PropagationParameters(
        wavefront=input_wavefront.duplicate(),
        propagation_elements=propagation_elements)
    # self.set_additional_parameters(propagation_parameters)
    #
    propagation_parameters.set_additional_parameters('magnification_x',
                                                     0.020000)
    #
    propagator = PropagationManager.Instance()
    try:
        propagator.add_propagator(FresnelZoom1D())
    except:
        pass
    output_wavefront = propagator.do_propagation(
        propagation_parameters=propagation_parameters,
        handler_name='FRESNEL_ZOOM_1D')

    return output_wavefront