Last active
November 4, 2016 12:06
-
-
Save thomasaarholt/b413b47d6c77311c591390dce973803b to your computer and use it in GitHub Desktop.
Fitting linear components to hyperspy signals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In model.py | |
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]) | |
print(weights) | |
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