<jupyter_start><jupyter_text>Cutting band structure or band mapping data to the first Brillouin zone<jupyter_code>import numpy as np
import fuller
import scipy.io as sio
import matplotlib.pyplot as plt
from imp import reload
reload(fuller.utils)
reload(fuller.generator)<jupyter_output><empty_output><jupyter_text>1. Load data<jupyter_code>bs_hse = sio.loadmat(r'..\theory\WSe2_HSE06_bands.mat')
bshse = np.moveaxis(bs_hse['evb'][::2,...], 1, 2)
bs_hse['kxxsc'].shape<jupyter_output><empty_output><jupyter_text>2. Determine Brillouin zone boundary using landmarks<jupyter_code>bzn = fuller.generator.BrillouinZoner(bands=bshse, axis=0)
bzn.select_slice(selector=slice(0, 1))
bzn.findlandmarks(image=bzn.slice, method='daofind', sigma=25, fwhm=40, sigma_radius=4, image_ofs=[25,25,0,0])
bzn.visualize(bzn.slice, annotated=True, points=dict(pts=bzn.pouter_ord))
# plt.scatter(bzn.pcent[1], bzn.pcent[0], s=100, c='r')<jupyter_output><empty_output><jupyter_text>3. Calculate geometric parameters for creating data mask<jupyter_code>imr, imc = bzn.slice.shape
hexside = np.linalg.norm(bzn.pouter_ord[1,:] - bzn.pouter_ord[2,:])
hexdiag = np.linalg.norm(bzn.pouter_ord[1,:] - bzn.pouter_ord[4,:])
imside = min(bzn.slice.shape)
ptop = (imr - hexdiag) / 2
# Calculate the distance of twice of the apothem (apo diameter)
apod = np.abs(np.sqrt(3)*hexside)
pleft = (imc - hexdiag) / 2
bzn.maskgen(hexdiag=int(hexdiag), imside=imside, image=None, padded=True,
                               pad_top=int(ptop), pad_left=int(pleft), ret='all')
bzn.visualize(bzn.mask*bzn.slice, annotated=True, points=dict(pts=bzn.pouter_ord))
bzn.bandcutter(selector=slice(0, None))<jupyter_output><empty_output><jupyter_text>Energy band data sliced to the first Brillouin zone now bears the name `bandcuts`<jupyter_code>bzn.bandcuts.shape<jupyter_output><empty_output><jupyter_text>4. Save sliced data<jupyter_code>bzn.summary();
bzn.save_data(form='h5', save_addr=r'./wse2_hse_bandcuts.h5')
plt.imshow(bzn.bandcuts[0,...])
bzn.visualize(bzn.bandcuts[12,...])<jupyter_output><empty_output><jupyter_text>Load data using external functionDemonstration here using ``fuller.utils.load_multiple_bands()``<jupyter_code>fdir = r'E:\Momentoscope\WSe2\BandRecon_PBE'
bzn = fuller.generator.BrillouinZoner(folder=fdir)
bzn.load_data('', loadfunc=fuller.utils.load_multiple_bands, ret=False, ename='bands/Eb', kname='axes')
bzn.select_slice(selector=slice(0, 1))
bzn.visualize(bzn.slice, annotated=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14909819639278557, 'fraction_numerical': 0.01843687374749499, 'mean_word_length': 7.666666666666667, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '566609', 'license': 'MIT', 'n_tokens_mistral': 1057, 'n_tokens_neox': 998, 'n_words': 150, 'path': 'examples/02_Brillouin_zoning.ipynb', 'repo_name': 'mpes-kit/fuller', 'size': '2495'}