<jupyter_start><jupyter_text>Reconstruction of band using Markov Random Field Model  Model setup<jupyter_code># Import packages
import numpy as np
import matplotlib.pyplot as plt

from fuller.mrfRec import MrfRec
from fuller.utils import loadHDF
# Load preprocessed data
data = loadHDF('preprocessed_mpes_data.h5')
E = data['E']
kx = data['kx']
ky = data['ky']
I = data['V']
# Create MRF model
mrf = MrfRec(E=E, kx=kx, ky=ky, I=I, eta=.12)
mrf.I_normalized = True<jupyter_output><empty_output><jupyter_text>Initialization<jupyter_code># Initialize mrf model with band structure approximation from DFT
path_dft = 'WSe2_PBEsol_bands.mat'

band_index = 4
offset = -0.1
k_scale = 1.1

kx_dft, ky_dft, E_dft = mrf.loadBandsMat(path_dft)
mrf.initializeBand(kx=kx_dft, ky=ky_dft, Eb=E_dft[band_index,...], offset=offset, kScale=k_scale, flipKAxes=True)
# Plot slices with initialiation to check offset and scale
mrf.plotI(ky=0, plotBandInit=True, cmapName='coolwarm')
mrf.plotI(kx=0, plotBandInit=True, cmapName='coolwarm')<jupyter_output><empty_output><jupyter_text>Reconstruction<jupyter_code># Run optimization to perform reconstruction
eta = .1
n_epochs = 150

mrf.eta = eta
mrf.iter_para(n_epochs)
# Plot results
mrf.plotBands()
mrf.plotI(ky=0, plotBand=True, plotBandInit=True, plotSliceInBand=False, cmapName='coolwarm')
mrf.plotI(ky=0.5, plotBand=True, plotBandInit=True, plotSliceInBand=False, cmapName='coolwarm')
mrf.plotI(kx=0, plotBand=True, plotBandInit=True, plotSliceInBand=False, cmapName='coolwarm')
mrf.plotI(kx=0.5, plotBand=True, plotBandInit=True, plotSliceInBand=False, cmapName='coolwarm')
# Save results
path_save = 'reconstructed_bands'
mrf.saveBand(path_save + 'mrf_rec_%02i.h5' % band_index, index=band_index)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12329545454545454, 'fraction_numerical': 0.013636363636363636, 'mean_word_length': 8.077319587628866, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '575450', 'license': 'MIT', 'n_tokens_mistral': 729, 'n_tokens_neox': 699, 'n_words': 137, 'path': 'examples/04_mpes_reconstruction_mrf.ipynb', 'repo_name': 'mpes-kit/fuller', 'size': '1760'}