-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: some fixes after comments from celine #137
base: main
Are you sure you want to change the base?
Conversation
"# and it expects `wavelength` to be the last dimension\n", | ||
"transmission_fraction_mantle = transmission_fraction_mantle.transpose((*(set(transmission_fraction_mantle.dims) - {'wavelength'}), 'wavelength'))\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"# and it expects `wavelength` to be the last dimension\n", | |
"transmission_fraction_mantle = transmission_fraction_mantle.transpose((*(set(transmission_fraction_mantle.dims) - {'wavelength'}), 'wavelength'))\n", |
I don't think that's necessary, I think it just works because we have dim='wavelength'
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's needed if we run method="medium"
or method="expensive"
instead of method="cheap"
. Then the transmission fraction is evaluated piecewise and not for the entire detector at once. This makes the returned value have a different shape. The instrument view requires the wavelength
dimension to be the last dimension of the data array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make the instrument view automatically transpose the input data it receives if it has the wrong shape.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instrument view requires the wavelength dimension to be the last dimension of the data array.
Where does it fail? Is it when it tries to flatten the dimensions?
Maybe we should make the instrument view automatically transpose the input data it receives if it has the wrong shape.
Yes, we should. The user should not have to worry about the order of dimensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does it fail? Is it when it tries to flatten the dimensions?
Yes exactly.
File [~/work/essdiffraction/src/ess/dream/instrument_view.py:64](http://localhost:8889/lab/tree/docs/user-guide/dream/src/ess/dream/instrument_view.py#line=63), in _pre_process(da, dim)
62 if dim is not None:
63 dims.remove(dim)
---> 64 out = da.flatten(dims=dims, to="pixel")
65 sel = sc.isfinite(out.coords["position"])
66 return out[sel]
File [~/mambaforge/envs/essdiffraction/lib/python3.10/site-packages/scipp/core/shape.py:363](http://localhost:8889/home/johannes/mambaforge/envs/essdiffraction/lib/python3.10/site-packages/scipp/core/shape.py#line=362), in flatten(x, dims, to)
357 if to is None:
358 # Note that this is a result of the fact that we want to support
359 # calling flatten without kwargs, and that in this case it semantically
360 # makes more sense for the dims that we want to flatten to come first
361 # in the argument list.
362 raise ValueError("The final flattened dimension is required.")
--> 363 return _call_cpp_func(_cpp.flatten, x, dims, to)
File [~/mambaforge/envs/essdiffraction/lib/python3.10/site-packages/scipp/core/_cpp_wrapper_util.py:27](http://localhost:8889/home/johannes/mambaforge/envs/essdiffraction/lib/python3.10/site-packages/scipp/core/_cpp_wrapper_util.py#line=26), in call_func(func, *args, **kwargs)
25 return data_group_nary(func, *args, **kwargs)
26 if out is None:
---> 27 return func(*args, **kwargs)
28 else:
29 return func(*args, **kwargs, out=out)
DimensionError: Can only flatten a contiguous set of dimensions in the correct order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you add the automatic transpose here or in a different PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do it here
" detector_position=dg['endcap_backward'].coords['position']['strip', 0].copy(),\n", | ||
" quadrature_kind='cheap',\n", | ||
")\n", | ||
"\n", | ||
"transmission_fraction_endcap.coords['position'] = transmission_fraction_endcap.coords.pop('detector_position')\n", | ||
"transmission_fraction_endcap = transmission_fraction_endcap.transpose((*(set(transmission_fraction_endcap.dims) - {'wavelength'}), 'wavelength'))\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"transmission_fraction_endcap = transmission_fraction_endcap.transpose((*(set(transmission_fraction_endcap.dims) - {'wavelength'}), 'wavelength'))\n", |
Co-authored-by: Neil Vaytet <[email protected]>
it becomes too hairy when different entries in the datagroup have different sets of dimensions
No description provided.