def load_data_from_URLs(self, URLs): # -> create data[BE,kx,ky] # Last element in URLs are the parameters. All other elements # are individual orbitals to load. Each is a list of length 2 # with first entry being the URL, the second the meta_data # dictionary *orbitals, options = URLs name, *parameters = options self.data = SlicedData.init_from_orbitals(name, orbitals, parameters) self.change_slice(0, 0)
def load_data_from_URL(self, URL): # -> create data[photon_energy,kx,ky] # Last element in URL are the parameters. The first element # is the orbital to load as a list of length 2 # with first entry being the URL, the second the meta_data # dictionary *orbital, options = URL name, *parameters = options self.data = SlicedData.init_from_orbital_photonenergy( name, orbital, parameters) self.change_slice(0, 0)
def load_data_from_cube(self, URL): # -> create either psi[x,y,z] # or psik[kx,ky,kz] # Last element in URL are the parameters. The first element # is the orbital to load as a list of length 2 # with first entry being the URL, the second the meta_data # dictionary *orbital, options = URL name, *parameters = options self.data = SlicedData.init_from_orbital_cube( name, orbital, parameters) self.change_slice(0, 0)
def load_data_from_URL(self, URL, ID=None): # -> create data[photon_energy,kx,ky] # Last element in URL are the parameters. The first element # is the orbital to load as a list of length 2 # with first entry being the URL, the second the meta_data # dictionary *orbital, options = URL name, *parameters = options s_share = float(config.get_key('orbital', 's_share_sliced')) self.data = SlicedData.init_from_orbital_photonenergy( name, orbital, parameters, s_share=s_share, ID=ID) self.load_data = ['load_from_URL', URL] self.change_slice(0, 0)
def load_data_from_URLs(self, URLs, ID=None): # -> create data[BE,kx,ky] # Last element in URLs are the parameters. All other elements # are individual orbitals to load. Each is a list of length 2 # with first entry being the URL, the second the meta_data # dictionary *orbitals, options = URLs name, *parameters = options s_share = float(config.get_key('orbital', 's_share_sliced')) self.data = SlicedData.init_from_orbitals(name, orbitals, parameters, s_share=s_share, ID=ID) self.load_data = ['load_from_URLs', URLs] self.change_slice(0, 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')
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' })
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')
# 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
0.0, # fermi_energy (float): Fermi energy in eV 0.4, # energy_broadening (float): FWHM of Gaussian energy broadenening in eV 0.03, # dk (float): Desired k-resolution in kmap in Angstroem^-1. 0, # phi (float): Euler orientation angle phi in degree. 0, # theta (float): Euler orientation angle phi in degree. 0, # psi (float): Euler orientation angle phi in degree. 'no', # Ak_type (string): Treatment of |A.k|^2: either 'no', 'toroid' or 'NanoESCA'. 'p', # polarization (string): Either 'p', 's', 'C+', 'C-' or 'CDAD'. 0, # alpha (float): Angle of incidence plane in degree. 0, # beta (float): Azimuth of incidence plane in degree. 'auto', # gamma (float/str): Damping factor for final state in Angstroem^-1. str = 'auto' sets gamma automatically 'no' ] # symmetrization (str): either 'no', '2-fold', '2-fold+mirror', # '3-fold', '3-fold+mirror','4-fold', '4-fold+mirror' # initialize SlicedData object kmap_stack = SlicedData.init_from_orbitals(name, orbitals, parameters) # Plot some slices fig, _ax = plt.subplots(3, 3) ax = _ax.flatten() nplots = len(ax) nslice = kmap_stack.data.shape[0] count = 0 for i in range(0, nslice, 1 + nslice // nplots): plot_data = kmap_stack.slice_from_index(i) ax[count].imshow(plot_data.data) count += 1 plt.show()
# ... or choose URL pointing to cubefile #cube_file = 'http://143.50.77.12/OrganicMolecule/B3LYP/5A/charge0mult1/5A_MO_73' # Create SlicedData object orbital = [[cube_file, {}]] name = '5A H**O' parameters = [ 'k-space', # either 'real-space' or 'k-space' 0.15, # desired resolution for 3D-Fourier-Transform. 150, # maximum kinetic energy in eV 'real' ] # choose between 'real', 'imag', 'abs' or 'abs2' # for Re(), Im(), |..| or |..|^2 orbital_slices = SlicedData.init_from_orbital_cube(name, orbital, parameters) # Plot some slices fig, _ax = plt.subplots(3, 3) ax = _ax.flatten() nplots = len(ax) nslice = orbital_slices.data.shape[0] count = 0 for i in range(0, nslice, 1 + nslice // nplots): plot_data = orbital_slices.slice_from_index(i) ax[count].imshow(plot_data.data) count += 1 plt.show()
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)
# 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')
0.0, # fermi_energy (float): Fermi energy in eV 0.02, # dk (float): Desired k-resolution in kmap in Angstroem^-1. 0, # phi (float): Euler orientation angle phi in degree. 0, # theta (float): Euler orientation angle phi in degree. 0, # psi (float): Euler orientation angle phi in degree. 'no', # Ak_type (string): Treatment of |A.k|^2: either 'no', 'toroid' or 'NanoESCA'. 'p', # polarization (string): Either 'p', 's', 'C+', 'C-' or 'CDAD'. 0, # alpha (float): Angle of incidence plane in degree. 0, # beta (float): Azimuth of incidence plane in degree. 'auto', # gamma (float/str): Damping factor for final state in Angstroem^-1. str = 'auto' sets gamma automatically 'no' ] # symmetrization (str): either 'no', '2-fold', '2-fold+mirror', # '3-fold', '3-fold+mirror','4-fold', '4-fold+mirror' # initialize SlicedData object kmap_stack = SlicedData.init_from_orbital_photonenergy(name, orbital, parameters) # Plot some slices fig, _ax = plt.subplots(3, 3) ax = _ax.flatten() nplots = len(ax) nslice = kmap_stack.data.shape[0] count = 0 for i in range(0, nslice, 1 + nslice // nplots): plot_data = kmap_stack.slice_from_index(i) ax[count].imshow(plot_data.data) count += 1 plt.show()
# 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()