예제 #1
0
from snomtools.evaluation.pes import FermiEdge
import matplotlib.pyplot as plt
import numpy as np

# Define DataSet and rename target file
file = "HDF5 File"  # example : "example_data_set.hdf5"
full_data = ds.DataSet.from_h5(file, file.replace('.hdf5', '_Int.hdf5'))

energy_id = "energy-axis"  # example : 'energy'
E_laser = "photon energy"  # example : u.to_ureg(4.6, 'eV')

# Define a RoI in which the FermiEdge is located and excludes other peaks to perform a more accurate fit
fermi_boundaries = {}
fermi_boundaries[energy_id] = ["Channel1", "Channel2"]  # example : [0, 20]
# Initialize RoI:
fermi_area = ds.ROI(full_data, fermi_boundaries, by_index=True)

# Fermi fit used to extract the fermi edge
fermifit = FermiEdge(fermi_area, guess=None, normalize=False)
E_kin_fermi = fermifit.E_f

# Transforming energyscale to Final energy
final_axis = full_data.get_axis(energy_id) - E_kin_fermi + 2 * E_laser
# Transforming energyscale to Intermediate energy
interm_axis = full_data.get_axis(energy_id) - E_kin_fermi + E_laser
# Transforming energyscale to Binding energy
binding_axis = full_data.get_axis(energy_id) - E_kin_fermi

# Choose axis to which you want to scale # example : interm_axis
shifted_axis = interm_axis
예제 #2
0
파일: FFT.py 프로젝트: hartelt/snomtools
                # Do the whole thing at once, user says it should fit into RAM by not providing h5target
                df_out = outdata.get_datafield(
                    "spectral_" + self.indata.get_datafield(i_df).label)
                df_out.data = self.fftslice(np.s_[:], i_df)

        self.result = outdata
        return outdata


if __name__ == '__main__':
    testdatah5 = "PVL_r10_pol244_25µm_-50-150fs_run1.hdf5"
    testdata = ds.DataSet.in_h5(testdatah5,
                                chunk_cache_mem_size=1000 * 1024**2)
    testroi = ds.ROI(testdata, {
        'x': [500, 505],
        'y': [500, 506]
    },
                     by_index=True)

    # Test FFT in memory:
    fftdatah5 = testdatah5.replace(".hdf5", "_roi_FFT.hdf5")
    fft = FFT(testroi, 'delay', 'PHz')
    fftdata = fft.fft()
    fftdata.saveh5(fftdatah5)

    # Test Filtering in memory:
    filtereddatah5 = testdatah5.replace(".hdf5", "_roi_filtered.hdf5")
    filterobject = FrequencyFilter(testroi,
                                   (consts.c / u.to_ureg(800, 'nm')).to('PHz'),
                                   'delay',
                                   max_order=2,
예제 #3
0
파일: pes.py 프로젝트: hartelt/snomtools
            guess = tuple(guesslist)
        return curve_fit(fermi_edge, energies.magnitude, intensities.magnitude,
                         guess)


if __name__ == "__main__":
    # Generate some test data:
    E_f, d_E, c, d = 30, 1, 100, 1
    f = FermiEdge.from_coeffs((E_f, d_E, c, d))
    energies = u.to_ureg(np.linspace(25, 35, 1000), 'eV')
    intensities = u.to_ureg(
        f.fermi_edge(energies).magnitude + np.random.randn(1000) * 5, 'count')
    testdata = ds.DataSet("testdata",
                          (ds.DataArray(intensities, label="counts"), ),
                          (ds.Axis(energies, label="E"), ))
    testroi = ds.ROI(testdata, {'E': [u.to_ureg(29.8, 'eV'), None]})

    # Test the single modules:
    guess = FermiEdge.guess_parameters(energies, intensities)
    result = FermiEdge.fit_fermi_edge(energies, intensities, guess)
    print("result: {0}".format(result[0]))
    f = FermiEdge.from_xy(energies, intensities, guess)

    # Test the full thing:
    f = FermiEdge(testroi)
    print("result: {0}".format([f.E_f, f.dE, f.c, f.d]))

    from matplotlib import pyplot as plt

    plt.plot(energies, intensities)
    plt.plot(energies, f.fermi_edge(energies))
예제 #4
0
# Define laser FWHM as evaluated with a gaussfit in energys close to E_Fermi and "off state"
laser_fwhm = "laser FWHM value"  # example : u.to_ureg(25, 'um').to('fs', 'light')

infile = os.path.abspath(os.path.join(
    wd, "Kscaled HDF5"))  # example : "1. Durchlauf_e4_binned_int_kscaled.hdf5"
indata = ds.DataSet.from_h5(infile)
delay_apply_timescale(indata)
delay_axis = indata.get_axis('delay')
delay_axis -= time_zero

# Roi that will be simulated, as defined in the "cuda_eval_job" that calls this script on elwe2
# For smaller Roi (e.g. only part of one energy slice add : x binned x10':[43,43], 'y binned x10':[43,43] in Roi
roi_to_fit = ds.ROI(
    indata,
    {
        "energy-axis": [roi, roi],
        # example : 'energy binned x4'
    },
    by_index=True)

# Define start parameters for fitting algorithm
obeobject = snomtools.evaluation.cuda.obe_copol.OBEfit_Copol(
    roi_to_fit,
    laser_lambda=u.to_ureg(400, 'nm'),
    laser_AC_FWHM=laser_fwhm,
    time_zero=u.to_ureg(0, 'fs'),
    max_time_zero_offset=u.to_ureg(40, 'fs'),
    max_lifetime=u.to_ureg(50, 'fs'),
    fit_mode='gauss')

obeobject.optimize_gpu_blocksize()
예제 #5
0
import snomtools.data.transformation.project
import snomtools.plots.datasets
import numpy as np

# Define DataSet to display
k_h5 = os.path.abspath(
    "Kscaled HDF5")  # example : "example_data_set_Kscaled.hdf5"
data = ds.DataSet.from_h5(k_h5)

# Define energy slice to plot
sum_boundaries_index = {}
sum_boundaries_index["Energy Axis"] = ["Channel", "Channel"
                                       ]  # example : ['energy']  = [16,16]

# Initialize RoI:
sumroi = ds.ROI(data, sum_boundaries_index, by_index=True)

# Project RoI to k_||-plane and return data:
kmap = snomtools.data.transformation.project.project_2d(sumroi, 'k_y', 'k_x')

# Trigger for saving Image, with figname as name of saved file
save = False
figname = "k_map_name"  # example : 'sample_kspace_map_energy_channel'

# Plot settings :
plt.figure(figsize=(7, 4.8))
ax = plt.subplot(111)
lifetime_plot = snomtools.plots.datasets.project_2d(kmap,
                                                    ax,
                                                    'k_y',
                                                    'k_x',
예제 #6
0
def load_dispersion_data(data, y_axisid='y', x_axisid='x', e_axisid='energy', d_axisid='delay',
                         x_center=None, x_offset=0, x_window=10,
                         delay_center=None, delay_offset=0, delay_window=10):
    """
    Loads a n-D HDF5 file and projects it onto the energy- and pixel axis of the dispersion data (default ``energy``,
    ``y``) to create a dispersion plot.
    For better statistics, a number of slices along the *other* pixel axis (default ``x``) and time delay axis
    (default ``delay``) are summed up (``10``, ``10`` by default).

    :param data: n-D-DataSet with y-pixel, x-pixel, energy and a time (pulse delay) dimension.
    :type data: ds.DataSet

    :param y_axisid: The name (label) of the y-axis of the data, used as dispersion k direction. Default: ``y``
    :type y_axisid: str

    :param x_axisid: The name (label) of the x-axis of the data, used to sum over. If set to ``False`` or ``None``,
        no pixel summation is done and other ``x_``...-Parameters are ignored. Default: ``x``
    :type x_axisid: str or bool

    :param e_axisid: The name (label) of the energy-axis of the data, used for the dispersion. Default: ``energy``
    :type e_axisid: str

    :param d_axisid: The name (label) of the delay-axis of the data, used to sum over. If set to ``False`` or ``None``,
        no summation is done and other ``delay_``...-Parameters are ignored. Default: ``delay``
    :type d_axisid: str or bool

    :param x_center: The center position index along the x Axis around which shall be summed.
        Default: The "middle" of the axis, defined as half its length.
    :type x_center: int

    :param x_offset: An offset in pixels (array indices) relative to ``x_center``. For example using this with
        default ``x_center`` allows to provide a relative rather than absolute origin to sum over.
    :type x_offset: int

    :param x_window: A number of pixels around the center to sum over. Default: ``10``
    :type x_window: int

    :param delay_center: The center position index along the delay Axis around which shall be summed.
        Default: The "middle" of the axis, defined as half its length.
    :type delay_center: int

    :param delay_offset: An offset in energy channels (array indices) relative to ``delay_center``. For example using
        this with default ``delay_center`` allows to provide a relative rather than absolute origin to sum over.
    :type delay_offset: int

    :param delay_window: A number of energy channels around the center to sum over. Default: ``10``
    :type delay_window: int

    :return: The projection of the n-D-Dataset on the pixel and energy axis,
        with a summation over slices around time zero and pixel mean point
    :rtype: ds.DataSet
    """
    # Define RoI boundaries to sum over for better statistics:
    sum_boundaries_index = {}
    if d_axisid:
        if delay_center is None:
            delay_center = int(len(data.get_axis(d_axisid)) / 2)
        sum_boundaries_index[d_axisid] = [delay_center + delay_offset - int(delay_window / 2),
                                          delay_center + delay_offset + int(delay_window / 2)]
    if x_axisid:
        if x_center is None:
            x_center = int(len(data.get_axis(x_axisid)) / 2)
        sum_boundaries_index[x_axisid] = [x_center + x_offset - int(x_window / 2),
                                          x_center + x_offset + int(x_window / 2)]

    # Initialize RoI:
    sumroi = ds.ROI(data, sum_boundaries_index, by_index=True)

    # Project RoI to k_x-E-Plane and return data:
    return snomtools.data.transformation.project.project_2d(sumroi, e_axisid, y_axisid)
예제 #7
0
                     Center,
                     normparameter=False,
                     Phase=False)
    # LaserAC(ExpDelays,L,FWHM,Amp,Offset,Center):
    # IAC2 = LaserAC(Delays, L, FWHM, Amp, Offset, Center)
    endtime = time.time()
    print("... done in {0:.3f} seconds".format(endtime - starttime))
    # figure()
    # plot((-300,300),(5.0/3.0,5.0/3.0))
    # plot((-300,300),(2.0,2.0))
    # plot(Delays,normAC(IAC))

if class_test:
    # RUN THIS IN snomtools/test folder where testdata hdf5s are, or set your paths and parameters accordingly:
    testdata = ds.DataSet.from_h5file("cuda_OBEtest_copol.hdf5")
    testroi = ds.ROI(testdata, {'energy': [200, 202]}, by_index=True)
    testroida = testroi.get_DataSet()
    fitobject = OBEfit_Copol(testroida,
                             time_zero=-9.3,
                             laser_AC_FWHM=u.to_ureg(49, 'fs'),
                             max_time_zero_offset=u.to_ureg(
                                 40, 'fs'))  # neuer Parameter
    fitobject.optimize_gpu_blocksize(
    )  # hier wird die blocksize optimiert, muss vor obefit() aufgerufen werden.
    result = fitobject.obefit()

    #  How to view the fit results:
    # from matplotlib import pyplot as plt
    # plt.plot(*fitobject.dataAC(0))
    # plt.plot(*fitobject.resultAC(0))