Beispiel #1
0
def getFocusSize(ekev, q, focus = 'micron'):
    
    wfr = construct_SA1_wavefront(1024, 1024, ekev, q)
    
    spb = Instrument(overwrite_mirrors =  True)
    
    spb.setupHOMs(ekev, 2.2e-03)
    spb.setupKBs(ekev, 3.5e-03)
    
    spb.build_elements(focus = focus)
Beispiel #2
0
def test():
    
    from model.src.coherent import construct_SA1_wavefront
    
    wfr = construct_SA1_wavefront(1024, 1024, 1, 0.001, xoff = 0, yoff = -50e-06)
    
    arr = wfr.get_intensity()[:,:,0]
    
    cors = getFeatureSize(ii = arr, nWindows = 64, px = wfr.get_spatial_resolution()[0], bPlot = True)
    
    return cors    
Beispiel #3
0
def fresnel_prop(outdir, pp):
    wfr = construct_SA1_wavefront(1024,1024,6,1.0)
    
    bl = config(focus = "micron")
    Drift = SRWLOptD(50)
    Drift.name = 'drift'
    bl.propagation_options[0]['optical_elements'] = [Drift]
    bl.propagation_options[0]['propagation_parameters'] = [pp]
    
    bl.propagate_sequential(wfr, outdir = outdir + "fresnel/")

    print(wfr.params.Mesh.xMax - wfr.params.Mesh.xMin)
Beispiel #4
0
def constructCoherentEquiv(wfr, outdir, mode = 'direct'):
    
    cwfr = construct_SA1_wavefront(1024, 1024, wfr.params.photoEnergy/1000, 0.25)
    
    cwfr.initial_intensity = integral_intensity(cwfr)
    
    spb = Instrument()
    
    spb.setupHOMs(wfr.params.photonEnergy/1000, 2.2e-03)
    spb.setupKBs(wfr.params.photonEnergy/1000, 3.5e-03)
    
    spb.mirrorProfiles(toggle = "on", aperture = True, overwrite = True)
    
    spb.build_elements(focus = "micron")
Beispiel #5
0
def quadratic_prop(outdir):
    
    wfr = construct_SA1_wavefront(1024,1024,6,1.0)
    D1 = wfr.params.Mesh.xMax - wfr.params.Mesh.xMin
    
    bl = config(focus = "micron")
    Drift = SRWLOptD(50)
    Drift.name = 'drift'
    bl.propagation_options[0]['optical_elements'] = [Drift]
    bl.propagation_options[0]['propagation_parameters'] = [bl.propagation_options[0]['propagation_parameters'][0]]
    
    bl.propagate_sequential(wfr, outdir = outdir + "quadratic/")
    D2 = wfr.params.Mesh.xMax - wfr.params.Mesh.xMin
    print(D1, D2)
    
    return wfr.get_spatial_resolution()[0], D1, D2
Beispiel #6
0
if __name__ == "__main__":
    
    slc = 2
    N = 10
    
    nx, ny = 128, 128
    II = np.zeros((nx,ny,N))
    PH = np.zeros((nx,ny,N))
    PHz = np.zeros((nx,ny,N))
    A = np.zeros((N,N))
    B = np.zeros((N,1))
    
    
    val = nx//4
    
    wfr = construct_SA1_wavefront(nx,ny,4.96,0.25)
    wav = (h*c)/(wfr.params.photonEnergy*e)
    sp = phaseMask(np.random.rand(50,50), [ get_axis(wfr, axis = 'x').max()-
                                            get_axis(wfr, axis = 'x').min(),
                                            get_axis(wfr, axis = 'y').max()-
                                            get_axis(wfr, axis = 'y').min()], wav) ##speckle
    slc = 2
    N = 10
    
    nx, ny = 128, 128
    II = np.zeros((nx,ny,N))
    PH = np.zeros((nx,ny,N))
    PHz = np.zeros((nx,ny,N))
    A = np.zeros((N,N))
    B = np.zeros((N,1))
    
Beispiel #7
0
sys.path.append("/opt/WPG/") # LOCAL PATH
sys.path.append("/gpfs/exfel/data/user/guestt/WPG") # DESY MAXWELL PATH

sys.path.append("/opt/spb_model") # LOCAL PATH
sys.path.append("/gpfs/exfel/data/user/guestt/spb_model") # DESY MAXWELL PATH
###############################################################################
###############################################################################
from matplotlib import pyplot as plt
from poppy import zernike
from model.src.coherent import construct_SA1_wavefront
import numpy as np
from wpg.wpg_uti_wf import calculate_fwhm

 

wfr = construct_SA1_wavefront(1000, 1000, 12, 0.1)
ii = wfr.get_intensity()[:,:,0]
ph = wfr.get_phase()[:,:,0]


aperture = np.ones(ii.shape)
aperture[np.where(ii < ii.max()/10)] = 0
zc = zernike.opd_expand(ph, aperture = aperture)

opd = zernike.opd_from_zernikes(zc)

fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.bar(np.linspace(0,len(zc), len(zc)),zc)
ax1.set_xticks(np.linspace(0+1,len(zc)+1, len(zc)+1))
ax1.set_xticklabels(labels = ["$Z_{}$".format(int(z)) for z in np.linspace(0+1,len(zc)+1, len(zc)+1)])
Beispiel #8
0
    list_of_elements = ["MVE"]
    
    detector_pixel_size = 1e-06
    N_pixels = 1024
    detector_width = detector_pixel_size*N_pixels
    
    ekev = 9.2
    q = 0.25
    
    fdir = "samres_test"
    if os.path.exists(fdir) is False:
        os.mkdir(fdir)
    
    for element in list_of_elements:
            
        wfr = construct_SA1_wavefront(1024, 1024, ekev, q)
        
        spb = Instrument()
        spb.setupHOMs(ekev, 2.2e-03)
        spb.setupKBs(ekev, 3.5e-03)
        spb.mirrorProfiles(toggle = "on", overwrite = False)
        
        
        
        spb.build_elements(focus = "micron")
<<<<<<< HEAD
        spb.build_beamline(focus = "micron")
        spb.cropBeamline(element1 = element)
=======
        spb.buildBeamline(focus = "micron")
        spb.crop_beamline(element1 = element)
Beispiel #9
0
sys.path.append("/opt/spb_model") # LOCAL PATH
sys.path.append("/gpfs/exfel/data/user/guestt/spb_model") # DESY MAXWELL PATH
###############################################################################
###############################################################################

import multiprocessing

from model.beamline.structure import propagation_parameters
from model.beamline.structure import Instrument
from model.src.coherent import construct_SA1_wavefront
from wpg import srwlib

from wpg.srwlib import SRWLOptD as Drift

from felpy.model.wavefront import Wavefront
from felpy.model.beamline import Beamline

from wpg.wpg_uti_wf import calc_pulse_energy, calculate_fwhm, get_axial_power_density, get_centroid
from wpg.wpg_uti_wf import plot_intensity_map as plotIntensity

from wpg.misc import calcDivergence

from os import listdir

from tqdm import tqdm

if __name__ == '__main__':
    
    wfr = construct_SA1_wavefront(1124, 1423, 4.96, 0.25)

    centroid = get_centroid(wfr)
Beispiel #10
0
    spb.buildBeamline(focus = "nano")
>>>>>>> 108cfb9b6fc97d3841ee1db54862523eee5b184e
  
    bl = spb.get_beamline()
    
    print("Propagating Beamline")
    s = time.time()
    bl.propagate_sequential(wfr, outdir)
    f = time.time()
    print("Propagation Finished")
    print("Propagating Time: {} s".format(f-s))


def plotMirrorProfiles(outdir):

    spb = Instrument()
    spb.mirrorProfiles(toggle = "on", overwrite = True)
    
    spb.plotMirrorProfile("HOM1", outdir = outdir)
    spb.plotMirrorProfile("HOM2", outdir = outdir)
    spb.plotMirrorProfile("NHE", outdir = outdir)
    spb.plotMirrorProfile("NVE", outdir = outdir)


    
if __name__ == '__main__': 
    
    wfr = construct_SA1_wavefront(1024, 1024, 4.96, 0.250)
    
    testNano(wfr, outdir = "/opt/spb_model/data/beamlineTests/prop/")
Beispiel #11
0
def fresnel_prop(outdir, pp):
    wfr = construct_SA1_wavefront(1024,1024,6,1.0)
    
    bl = config(focus = "micron")
    Drift = SRWLOptD(50)
    Drift.name = 'drift'
    bl.propagation_options[0]['optical_elements'] = [Drift]
    bl.propagation_options[0]['propagation_parameters'] = [pp]
    
    bl.propagate_sequential(wfr, outdir = outdir + "fresnel/")

    print(wfr.params.Mesh.xMax - wfr.params.Mesh.xMin)
if __name__ == '__main__':

    outdir = "../../output/sampling_test/d1/"
    wfr = construct_SA1_wavefront(1024,1024,6,1.0)

    print("Comparing Propagation Algorithms")
    dx1, D1, D2 = quadratic_prop(outdir)
    print(dx1)
    dx2 = fresnel_sampling(50, wfr.params.wavelength, dx1, D2, D1)
    
    z = D2/D1
    s = dx2/(dx1)
    print("zoom: {}".format(z))
    print("scale: {}".format(s))
    print(s/z)
    print(dx2)
    fresnel_prop(outdir, [0,0,1,0,0,z,s/z,z,s/z,0,0])
    
    #fresnel_prop(outdir)