Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt thomasaarholt/
Last active Nov 4, 2016

What would you like to do?
Fitting linear components to hyperspy signals
# In
from numpy.linalg import lstsq as linear_lstsq
elif fitter == "linear_lstsq":
signal_axis = self.axis.axis[np.where(self.channel_switches)]
component_data = np.array([component.function(signal_axis) for component in self])
output = linear_lstsq(component_data.T, self.signal()[np.where(self.channel_switches)], **kwargs)
self.p0 = tuple([old*factor for old, factor in zip(self.p0, output[0])])
self.fit_output = output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.