Пример #1
0
def sliceFocus(wfr,
               ekev,
               focus='nano',
               nslices=500,
               axisName='x',
               outdir=None):

    spb = get_beamline_object(apertures=False, surface=False)

    el_n = len(spb.propagation_options[0]['optical_elements']) - 1

    spb.propagation_options[0]['optical_elements'][el_n].L *= 0.98
    slice_interval = 2.2 - copy(
        spb.propagation_options[0]['optical_elements'][el_n].L / nslices)

    spb.propagation_options[0]['propagation_parameters'][
        el_n] = propagation_parameters(5, 1, 5, 1, mode='fresnel')

    spb.propagate(wfr)
    plotIntensity(wfr)

    if axisName == 'x':
        data_focslice = np.zeros([nslices, np.shape(wfr.data.arrEhor)[0]])
    elif axisName == 'y':
        data_focslice = np.zeros([nslices, np.shape(wfr.data.arrEhor)[1]])

    for n in range(nslices):
        print("Slice {}/{}".format(n + 1, nslices))

        bl = Beamline()
        bl.append(SRWLOptD(slice_interval),
                  propagation_parameters(1, 1, 1, 1, mode='quadratic'))
        bl.propagate(wfr)
        plotIntensity(wfr)
        data_focslice[-n - 1, :] = wfr.get_intensity()[:, :, 0].sum(-1)
        #plt.plot(data_focslice[-n-1, :])
        plt.show()

    y = np.linspace(
        spb.bl.propagation_options[0]['optical_elements'][el_n].L,
        spb.bl.propagation_options[0]['optical_elements'][el_n].L +
        nslices * slice_interval, nslices)

    # =============================================================================
    #     ax1 =     colorbar_plot(data_focslice,
    #               get_mesh(data_focslice,
    #                                wfr.get_spatial_resolution()[0]*1e6,
    #                                y[1]-y[0]),
    #               aspect = 'auto',
    #               scale = 1,
    #               #norm=mpl.colors.LogNorm(),
    #               xlabel = "x($\mu m$)",
    #               ylabel = "z(m)",
    #               return_axes = True)
    #
    # =============================================================================
    return data_focslice
Пример #2
0
def simpleProp(wfr):
    
    print(calculate_fwhm(wfr))
    bl = Beamline()
    #bl.append(Aperture('c','a', 500e-06),propagation_parameters(1,1,1,1,mode = 'normal'))
    bl.append(Drift(100), propagation_parameters(1,1,1,1,mode = 'quadratic'))
    
    #bl.append(Drift(100), propagation_parameters(1,1,1,1,mode = 'quadratic'))
    bl.propagate(wfr)
    plotIntensity(wfr)
    print(calculate_fwhm(wfr))
Пример #3
0
def propagatePulses(fname):
    

    wfr = Wavefront()
    wfr.load_hdf5(indir + fname)
    
    srwlib.srwl.SetRepresElecField(wfr._srwl_wf, 'f')
    #storeWavefrontInfo(wfr)
    
 
    bl = getSPB(wfr)
    #bl = getSimpleBl()
    bl.propagate_sequential(wfr)
    
    wfr.store_hdf5(outdir + fname)
    

    plotIntensity(wfr)
Пример #4
0
    def propagate_sequential(self, wfr, outdir=None):
        """
        Propagate sequentially through each optical element in beamline.

        :param wfr: Input wavefront (will be re-writed after propagation)
        :param outdir: save directory
        """

        plotIntensity(wfr)

        print(outdir)
        if outdir is not None:

            if os.path.exists(outdir) == False:
                assert (ValueError, "Output Directory Could Not Be Found")
            else:
                pass

        if outdir is not None:
            wfr.write(outdir + "initialSource")
            plotIntensity(wfr, save=outdir + "source")

        for itr in range(len(self.propagation_options[0]['optical_elements'])):
            oe = self.propagation_options[0]['optical_elements'][itr]
            pp = self.propagation_options[0]['propagation_parameters'][itr]

            bl = srwlib.SRWLOptC([oe], [pp])

            print(oe.name)
            srwl.PropagElecField(wfr._srwl_wf, bl)

            if oe.name is None:
                oe.name = "el{}".format(itr)

            if outdir is not None:
                plotIntensity(wfr, save=outdir + oe.name)

                with open(outdir + "beamline_parameters.json", 'w') as f:
                    json.dump(self.params, f)

            elif outdir is None:
                plotIntensity(wfr)
Пример #5
0
    srwlib.srwl.SetRepresElecField(wfr._srwl_wf, 'f')
    #look_at_q_space(wfr)
    return wfr



def simpleProp(wfr):
    
    print(calculate_fwhm(wfr))
    bl = Beamline()
    #bl.append(Aperture('c','a', 500e-06),propagation_parameters(1,1,1,1,mode = 'normal'))
    bl.append(Drift(100), propagation_parameters(1,1,1,1,mode = 'quadratic'))
    
    #bl.append(Drift(100), propagation_parameters(1,1,1,1,mode = 'quadratic'))
    bl.propagate(wfr)
    plotIntensity(wfr)
    print(calculate_fwhm(wfr))

if __name__ == "__main__":
    

    
    #wfr = constructPulse()
    wfr = Wavefront()
    wfr.load_hdf5("../../data/h5/gauss.h5")
    srwlib.srwl.SetRepresElecField(wfr._srwl_wf, 'f')
    plotIntensity(wfr)
    
    simpleProp(wfr)
    
    #comparePulses(wfr, cwfr, "/data/")