bluesky / tutorials

Tutorial materials related to data acquisition, management, and analysis
https://mybinder.org/v2/gh/bluesky/tutorials/main?urlpath=lab
BSD 3-Clause "New" or "Revised" License
20 stars 29 forks source link

Monochromator Optimization workbook fails if the rocking curve choices 'com' or 'fit' are used #74

Closed JunAishima closed 4 years ago

JunAishima commented 4 years ago

Line 4 - RE(rocking_curve()) works just fine

However, adding the options choice='fit' or choice='com' to rocking_curve causes exceptions.

fit: Run aborted Traceback (most recent call last): File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/run_engine.py", line 1353, in _run msg = self._plan_stack[-1].send(resp) File "/home/jaishima/code/tutorials/X-ray Absorption Fine Structure/plans.py", line 88, in rocking_curve yield from scan_dcm_pitch() File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/utils.py", line 1046, in dec_inner return (yield from plan) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/preprocessors.py", line 382, in subs_wrapper return (yield from finalize_wrapper(_inner_plan(), File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/preprocessors.py", line 509, in finalize_wrapper ret = yield from plan File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/preprocessors.py", line 380, in _inner_plan return (yield from plan) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/utils.py", line 1046, in dec_inner return (yield from plan) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/preprocessors.py", line 382, in subs_wrapper return (yield from finalize_wrapper(_inner_plan(), File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/preprocessors.py", line 509, in finalize_wrapper ret = yield from plan File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/bluesky/preprocessors.py", line 380, in _inner_plan return (yield from plan) File "/home/jaishima/code/tutorials/X-ray Absorption Fine Structure/plans.py", line 72, in scan_dcmpitch pars = mod.guess(signal, x=pitch) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/lmfit/models.py", line 900, in guess pars = guess_from_peak(self, data, x, negative) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/lmfit/models.py", line 47, in guess_from_peak x = x[sort_increasing] File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/series.py", line 910, in getitem return self._get_with(key) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/series.py", line 943, in _get_with return self.loc[key] File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/indexing.py", line 1768, in getitem return self._getitem_axis(maybe_callable, axis=axis) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/indexing.py", line 1954, in _getitem_axis return self._getitem_iterable(key, axis=axis) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/indexing.py", line 1595, in _getitem_iterable keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False) File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/indexing.py", line 1552, in _get_listlike_indexer self._validate_read_indexer( File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/indexing.py", line 1640, in _validate_read_indexer raise KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError: "None of [Int64Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n ...\n 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],\n dtype='int64', name='time', length=101)] are in the [index]"

com: Run aborted Traceback (most recent call last): File "/home/jaishima/anaconda3/envs/usermeeeting_tutorials_2020/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 2646, in get_loc return self._engine.get_loc(key) File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 386, in pandas._libs.hashtable.Float64HashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 393, in pandas._libs.hashtable.Float64HashTable.get_item KeyError: 69.0

bruceravel commented 4 years ago

It took me a while, but I finally got to the point where I could reproduce this in Jupyter. Thanks, Jun. Working in it. Hopefully I will have a PR soon. :crossed_fingers:

danielballan commented 4 years ago

Closed by #77