Exemple #1
0
    def setUpClass(cls):

        file_path = os.path.dirname(os.path.realpath(__file__))
        input_path = file_path + '/../../example/data/'

        sliced_path = input_path + 'example5_6584.hdf5'
        cls.sliced_data = SlicedData.init_from_hdf5(sliced_path)

        orbital_paths = [
            'PTCDA_C.cube', 'PTCDA_D.cube', 'PTCDA_E.cube', 'PTCDA_F.cube'
        ]
        cls.orbitals = [
            OrbitalData.init_from_file(input_path + path, ID)
            for ID, path in enumerate(orbital_paths)
        ]

        cls.expected = np.loadtxt(file_path + '/output/weights_PTCDA')
        cls.background_expected = np.loadtxt(file_path +
                                             '/output/background_expected')
Exemple #2
0
    def test_initialization_from_hdf5(self):
        sliced_data = SlicedData.init_from_hdf5(
            __directory__ / '../example/data/example5_6584.hdf5')

        npt.assert_almost_equal(sliced_data.slice_from_index(2).data[145, 235],
                                194.848388671875,
                                decimal=14)

        (sliced_data.name, '6584estep0.0170213final.txt')
        npt.assert_equal(
            sliced_data.meta_data, {
                'alias': 'M3 PTCDA/Ag(110)',
                'arcwidth': '0.7800000000000011',
                'fermiLevel': '28.2',
                'filenumber': '6584estep0.0170213final.txt',
                'kStepSize': '0.02',
                'negPolar_avgs': 'False',
                'polarshift': '0.0',
                'rotation': '-24.0',
                'sym_anglemax': '180.0',
                'sym_anglemin': '0.0',
                'symmode': '2-fold'
            })
Exemple #3
0
    def load_data_from_path(self, path, ID=None):
        log = logging.getLogger('kmap')
        possible_paths = [path]
        file_name = Path(path).name
        possible_paths.append(Path(config.get_key('paths', 'hdf5_start')) /
                file_name)
        for path in config.get_key('paths', 'path').split(','):
            possible_paths.append(Path(path) / file_name)

        for path in possible_paths:
            log.info(f'Looking for {file_name} in {path}.')
            if os.path.isfile(path):
                log.info(f'Found.')
                self.data = SlicedData.init_from_hdf5(path, ID=ID)
                self.load_data = ['load_from_path', path]
                self.change_slice(0, 0)
                
                return 
            else:
                continue

        # No path worked
        print(f'ERROR: File {file_name} wasn\'t found. Please add its location to the search path (general_settings.paths.path')
Exemple #4
0
# Third Party Imports
import matplotlib.pyplot as plt
import numpy as np

# kMap.py Imports
from kmap.library.sliceddata import SlicedData
from kmap.library.orbitaldata import OrbitalData
from kmap.model.lmfit_model import LMFitModel

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

# Load experimental data as SlicedData object
exp_data = SlicedData.init_from_hdf5(data_path / 'example5_6584.hdf5')

# Load orbitals for fitting as OrbitalData objects
orbital_paths = [
    'PTCDA_C.cube', 'PTCDA_D.cube', 'PTCDA_E.cube', 'PTCDA_F.cube'
]
orbitals = [
    OrbitalData.init_from_file(data_path / path, ID)
    for ID, path in enumerate(orbital_paths)
]

# Initialize fit as LMFitModel object
lmfit = LMFitModel(exp_data, orbitals)

# Set common range and delta-k-grid for exp. and sim. kmaps
range_, dk = [-3.0, 3.0], 0.04
Exemple #5
0
    def load_data_from_path(self, path):
        self.data = SlicedData.init_from_hdf5(path)
        self.load_data = ['load_from_path', path]

        self.change_slice(0, 0)
Exemple #6
0
# Third Party Imports
import matplotlib.pyplot as plt
import numpy as np

# kMap.py Imports
from kmap.library.sliceddata import SlicedData
from kmap.library.orbitaldata import OrbitalData
from kmap.model.lmfit_model import LMFitModel

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

# Load experimental data as SlicedData object
exp_data = SlicedData.init_from_hdf5(data_path / 'example4_3271.hdf5')

# Load orbital for fitting as OrbitalData objects
orbital_paths = ['pentacene_HOMO.cube']
orbitals = [OrbitalData.init_from_file(
            data_path / path, ID) for ID, path in enumerate(orbital_paths)]

# Initialize fit as LMFitModel object
lmfit = LMFitModel(exp_data, orbitals)

# Set common range and delta-k-grid for exp. and sim. kmaps
range_, dk = [-3.0, 3.0], 0.04
lmfit.set_axis_by_step_size(range_, dk)
lmfit.set_polarization('toroid', 'p')
lmfit.set_symmetrization('2-fold')
Exemple #7
0
# Python Imports
from pathlib import Path

# Third Party Imports
import matplotlib.pyplot as plt

# kMap.py Imports
from kmap.library.sliceddata import SlicedData

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

# Import the sliced data class from the model folder

# Get path to the directory this file is in
# ATTENTION FILE DOES NOT EXIT ANYMORE
file_path = str(data_path / 'example5_6584.hdf5')

# Loading from file (Initialisation methods are usually class members)
sliced_data = SlicedData.init_from_hdf5(file_path)

# Get a PlotData object consisting of the 10th slice and its axes
plot_data = sliced_data.slice_from_index(10)

# Plot
__, axes = plt.subplots()
axes.imshow(plot_data.data)
plt.show()