#!/usr/bin/env python # coding: utf-8 # ## Install hyperspy and ipympl # In[ ]: get_ipython().run_line_magic('pip', 'install ipywidgets==8.1.3') get_ipython().run_line_magic('pip', 'install ipympl hyperspy[gui-jupyter]') # # Activate interactive matplotlib plotting (`widget` backend from ipympl library) # In[ ]: get_ipython().run_line_magic('matplotlib', 'widget') # ## Try hyperspy # In[ ]: import hyperspy.api as hs # In[ ]: dir(hs.data) # In[ ]: s = hs.data.two_gaussians() # In[ ]: s.plot() # In[ ]: s # In[ ]: m = s.create_model() # In[ ]: g1 = hs.model.components1D.GaussianHF() g2 = hs.model.components1D.GaussianHF() # In[ ]: g1.name = "wide" g2.name = "narrow" # In[ ]: m.extend([g1, g2]) # In[ ]: m.components # In[ ]: m.print_current_values() # In[ ]: m.axes_manager.indices = (0, 0) # In[ ]: m.components.narrow.centre.value = 60 m.components.wide.centre.value = 50 # In[ ]: m.fit() # In[ ]: m.plot() # In[ ]: m.multifit() # In[ ]: m.plot() # In[ ]: m.red_chisq.get_histogram().plot() # In[ ]: m.multifit(iterpath="serpentine") # In[ ]: m.plot() # In[ ]: