from ase.io import read
from msspec.calculator import MSSPEC


cluster1 = read('copper.cif')
cluster2 = read('copper_3planes.cif')

# The "emitter" atom is located in the middle of the 3rd plane
cluster1.emitter = 10
cluster2.emitter = 8

# Create a "calculator"
calc = MSSPEC(spectroscopy='PED', algorithm='inversion')
calc.set_atoms(cluster1)
data = calc.get_theta_scan(level='2p3/2')

calc = MSSPEC(spectroscopy='PED', algorithm='inversion')
calc.set_atoms(cluster2)
data = calc.get_theta_scan(level='2p3/2', data=data)



dset = data[0]
dset.add_columns(cs2=data[1].cross_section)
view = dset.views[0]
view._plotopts['legend'][0] = '4 planes'

view.select('theta', 'cs2', legend="3 planes")

# Plot the result with the interactive GUI
data.view()
