Replies: 2 comments
-
I can't reproduce the issue: it doesn't raise an error. The error message doesn't make sense and this part of the code hasn't changed recently, so we wouldn't expect a recent regression. It may be worth trying something more streamlined which has been implemented recently: https://hyperspy.org/exspy/user_guide/eels.html#id1 To try to reproduce, here is the code that I adapted your example given above (simply changed the data) : import exspy
import hyperspy.api as hs
cluster_low_loss = exspy.data.EELS_low_loss()
cluster_high_loss = exspy.data.EELS_MnFe()
s_Mn_L = cluster_high_loss.isig[610.0:700.0].deepcopy()
s_Mn_L.add_elements(('Mn','O'))
model_Mn = s_Mn_L.create_model(low_loss=cluster_low_loss, auto_add_edges=False, auto_background=True,)
model_Mn.components
# hs.set_log_level('ERROR')
model_Mn.fit_component(model_Mn.components.PowerLaw, signal_range=(610.0, 630.0), fit_independent=True, only_current=True)
model_Mn.assign_current_values_to_all(components_list = [model_Mn.components.PowerLaw])
# model_Mn.fit_component(model_Mn.components.PowerLaw, signal_range=(610.0, 630.0), fit_independent=True, only_current=False)
# Create and set the 4 components
import exspy as epy
L3 = epy.components.EELSCLEdge("Mn_L3")
L2 = epy.components.EELSCLEdge("Mn_L2")
L3_white = hs.model.components1D.Gaussian()
L3_white.name = "Mn_L3 line"
L3_white.centre.bmin = 640.0
L3_white.centre.bmax = 645.0
L3_white.centre.value = (L3_white.centre.bmax + L3_white.centre.bmin) / 2 # Initial value of the centre. Must be set to initialise the twinning below.
L3_white.A.bmin = 0
L3_white.sigma.bmax=3
L2_white = hs.model.components1D.Gaussian()
L2_white.name = "Mn_L2 line"
L2_white.centre.bmin = 650.0
L2_white.centre.bmax = 655.0
L2_white.centre.value = (L2_white.centre.bmax + L2_white.centre.bmin) / 2
L2_white.A.bmin = 0
L2_white.sigma.bmax=3
L3.onset_energy.twin = L3_white.centre
L2.onset_energy.twin = L2_white.centre
# Add all four to the model
model_Mn.extend([L3_white, L3, L2_white, L2])
model_Mn.components
# The following sort of emulates smart_fit, but it is more appropriate than smart_fit,
# because smart_fit doesn't know that it should fit the gaussians between L3 and L2
# We fit "from the left", starting with the lowest energy
model_Mn.reset_signal_range()
model_Mn.fit_component(L3_white, signal_range=[L3_white.centre.bmin-3.0, L3_white.centre.bmax+3.0], bounded=True,) # get good values
model_Mn.assign_current_values_to_all(components_list = [L3_white]) # apply those good values to all pixels
model_Mn.fit_component(L3_white, signal_range=[L3_white.centre.bmin-3.0, L3_white.centre.bmax+3.0], bounded=True, only_current=False) |
Beta Was this translation helpful? Give feedback.
-
Thanks @ericpre. with the exspy data, it works well on my pc. I am checking my data. |
Beta Was this translation helpful? Give feedback.
-
Hi, Community
I am following the EELS fitting code of @thomasaarholt for Mn_L edge fine structure:
https://gist.github.com/thomasaarholt/9a123a23bb1ec96f9e42ad2e41483100
However it shows: 'AttributeError: 'GoshGOS' object has no attribute 'energy_shift', which I have no idea about it after I checked that part in github. Then I tried to modifying the code while looking the discussions, but it seems I could still not skip the Error.
I uploaded my jupyter file and relative data in the ZIP below. EELS.zip
it is appreciated for any suggestions!
relevant code as below :
Beta Was this translation helpful? Give feedback.
All reactions