Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt thomasaarholt/SAMFire2.py
Last active Dec 2, 2016

Embed
What would you like to do?
Issue with SAMFire with a "homemade" component added
>>> m = sc.create_model()
>>> m.components
# | Attribute Name | Component Name | Component Type
---- | ------------------- | ------------------- | -------------------
0 | background_order_6 | background_order_6 | Polynomial
1 | Al_Ka | Al_Ka | Gaussian
2 | Al_Kb | Al_Kb | Gaussian
3 | C_Ka | C_Ka | Gaussian
4 | Ca_Ka | Ca_Ka | Gaussian
...
52 | S_Kb | S_Kb | Gaussian
53 | Si_Ka | Si_Ka | Gaussian
54 | Si_Kb | Si_Kb | Gaussian
>>> unknown = hs.model.components1D.Gaussian(centre=1.255, sigma=0.03253)
>>> unknown.name = "Unknown Peak"
>>> unknown.A.bmin = 0.0
>>> unknown.centre.free = False
>>> unknown.sigma.free = False
>>> m.append(unknown)
samf = m.create_samfire()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/component.py in _set_value(self, value)
212 # TypeError when calling. See issue #349.
--> 213 if len(value) != self._number_of_elements:
214 raise ValueError(
TypeError: object of type 'float' has no len()
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-223-6d0283fc8d9f> in <module>()
----> 1 samf = m.create_samfire()
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/model.py in create_samfire(self, workers, setup, **kwargs)
1780 from hyperspy.samfire import Samfire
1781 return Samfire(self, workers=workers,
-> 1782 setup=setup, **kwargs)
1783
1784
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/samfire.py in __init__(self, model, workers, setup, **kwargs)
192 self._workers = workers
193 if len(kwargs) or setup:
--> 194 self._setup(**kwargs)
195 self.refresh_database()
196
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/samfire.py in _setup(self, **kwargs)
222 self.pool = SamfirePool(**kwargs)
223 self._workers = self.pool.num_workers
--> 224 self.pool.prepare_workers(self)
225
226 def start(self, **kwargs):
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/samfire_utils/samfire_pool.py in prepare_workers(self, samfire)
131
132 mall = samfire.model
--> 133 model = mall.inav[mall.axes_manager.indices]
134 model.store('z')
135 m_dict = model.signal._to_dictionary(False)
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/model.py in __getitem__(self, slices)
1841 dims,
1842 (slices, array_slices),
-> 1843 self.isNavigation)
1844 twin_dict[id(po)] = ([id(i) for i in list(po._twins)], pn)
1845
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/misc/slicing.py in copy_slice_from_whitelist(_from, _to, dims, both_slices, isNav, order)
132 else:
133 # 'fn' in flag or no flags at all
--> 134 attrsetter(_to, key, target)
135 continue
136
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/misc/utils.py in attrsetter(target, attrs, value)
66 if where != -1:
67 target = attrgetter(attrs[:where])(target)
---> 68 setattr(target, attrs[where + 1:], value)
69
70
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/component.py in _set_value(self, value)
222 raise ValueError(
223 "The length of the parameter must be ",
--> 224 self._number_of_elements)
225 old_value = self.__value
226
ValueError: ('The length of the parameter must be ', 7)
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.