Пример #1
0
def propagate(wfr_directory, sdir, focus, analysis = False, crop = [], append = None, descriptor = "", VERBOSE = True):
    
    print("info")
    print("wavefront directory: {}".format(wfr_directory))
    print("save directory: {}".format(sdir))
    print("focus (i.e. beamline option): {}".format(focus))
    print("analysis: {}".format(analysis))
    print("crop: {}".format(crop))
    print("append: {}".format(append))
    
    for item in descriptor:
        print(item)
    
    wfr = Wavefront()
    wfr.load_hdf5(wdir)
    sdir = sdir + "/{}/".format(focus)
    
    bl = get_beamline_object(ekev = 4.96, options = focus, crop = crop)

    
    if append is not None:

        for item in append:
            bl.append(item[0],item[1])

    wfr.log(bl, descriptor)
    
    bl.propagate(wfr)
    
    if analysis: 
        wfr.analysis()
        
    wfr.store_hdf5(sdir)
Пример #2
0
def propagate_NVE():
            
    wfr_directory = sys.argv[1].replace("*", "/")
 
    job_name = "NKB_4980eV_250pC_NVE_to_EHC"
    python_command = propagate_NVE
    input_directory = dCache + "/NanoKB-Pulse/NVE/"
    
    save_directory = input_directory.replace("/NVE/", "/EHC/")
    mkdir_p(save_directory)
    
    log_directory = logs
    
    focus = "nano"
    analysis = False
    
    filename = __file__
    dt = datetime.now().__str__()
    function = python_command.__name__
    
    description = "Propagate NanoKB Pulses 4.98 keV, 250 pC from Undulator NVE mirror to the EHC Screen"
    
    append = None
    
    print("info")
    print("wavefront directory: {}".format(wfr_directory))
    print("save directory: {}".format(save_directory))
    print("focus (i.e. beamline option): {}".format(focus))
    print("analysis: {}".format(analysis))
    print("datetime: {}".format(dt))
    print("filename: {}".format(filename))
    print("function: {}".format(function))
    print("description: {}".format(description))
    
  
    wfr = Wavefront()
    wfr.load_hdf5(wfr_directory)
     
    bl = Beamline()
    bl.append(Drift(2.2+3.5), propagation_parameters(1/3,1,1/3,1,'quadratic'))
    bl.propagate(wfr)
    
    wfr.custom_fields['focus'] = focus
    wfr.custom_fields['job name'] = job_name
    wfr.custom_fields['input directory'] = wfr_directory
    wfr.custom_fields['datetime'] = dt
    wfr.custom_fields['function'] = function
    wfr.custom_fields['filename'] = filename
    wfr.custom_fields['description'] = description
    #wfr.custom_fields['bl'] = bl.__str__
                
    if analysis: 
        wfr.analysis()
        
    wfr.store_hdf5(wfr_directory.replace("/NVE/", "/EHC/"))
def propagate_NVE():

    wfr_directory = sys.argv[1].replace("*", "/")

    job_name = "NKB_4980eV_250pC_Source_to_NVE"
    python_command = propagate_NVE
    input_directory = dCache + "/NanoKB-Pulse/source/"

    save_directory = input_directory.replace("/source/", "/NVE/")
    mkdir_p(save_directory)

    log_directory = logs

    focus = "nano"
    analysis = False

    filename = __file__
    dt = datetime.now().__str__()
    function = python_command.__name__

    description = "Propagate NanoKB Pulses 4.98 keV, 250 pC from Undulator-exit to the NVE"

    crop = 'NVE'
    append = None

    print("info")
    print("wavefront directory: {}".format(wfr_directory))
    print("save directory: {}".format(save_directory))
    print("focus (i.e. beamline option): {}".format(focus))
    print("analysis: {}".format(analysis))
    print("datetime: {}".format(dt))
    print("filename: {}".format(filename))
    print("function: {}".format(function))
    print("description: {}".format(description))

    wfr = Wavefront()
    wfr.load_hdf5(wfr_directory)
    wfr.set_electric_field_representation('frequency')

    wfr = scale(wfr)

    print("wfr domain: {}".format(wfr.params.wDomain))

    bl = get_beamline_object(ekev=4.96,
                             options=focus,
                             crop=crop,
                             theta_KB=5e-03,
                             theta_HOM=3.5e-03)

    wfr.custom_fields['focus'] = focus
    wfr.custom_fields['job name'] = job_name
    wfr.custom_fields['input directory'] = wfr_directory
    wfr.custom_fields['datetime'] = dt
    wfr.custom_fields['function'] = function.__str__()
    wfr.custom_fields['filename'] = filename
    wfr.custom_fields['description'] = description
    #wfr.custom_fields['bl'] = bl.__str__

    bl.propagate(wfr)

    if analysis:
        wfr.analysis()

    wfr.store_hdf5(wfr_directory.replace("/source/", "/NVE/"))
Пример #4
0
# -*- coding: utf-8 -*-

import sys

from felpy.model.wavefront import Wavefront
from felpy.model.beamline import Beamline
from wpg.optical_elements import Drift
from felpy.model.tools import propagation_parameters
from felpy.utils.os_utils import mkdir_p

if __name__ == '__main__':
    print("working")
    in_directory = sys.argv[1]
    print("in: ", in_directory)
    out_directory = sys.argv[2]
    print("out: ", out_directory)
    wfr = Wavefront()
    wfr.load_hdf5(in_directory)
    print("wfr loaded")
    bl = Beamline()
    bl.append(Drift(3.644 - 2.2),
              propagation_parameters(1, 1, 1, 1, 'quadratic'))
    bl.propagate(wfr)
    print("wfr propagated")
    wfr.store_hdf5(out_directory)
    print("wfr stored")
    wfr.analysis(VERBOSE=True, DEBUG=True)
    #print(wfr.custom_fields) ## good debug