-
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
Zoom data reduction #50
Changes from 2 commits
d7d1aff
59b9a7b
1139da5
fdd5200
a574970
1ec5499
c84fedb
11b88fd
2b2e5e9
2bf3b34
78d9dd7
644258d
cddd003
0577a8d
ae45bf9
1cbcd01
c4e0f02
a62f630
3be36c6
1c0706b
30ba0cf
a52783f
db6cc19
88ba28c
ec3d713
a541769
7f945d4
818bf47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp) | ||
""" | ||
Plotting functions for ISIS data. | ||
""" | ||
from typing import Any | ||
|
||
import scipp as sc | ||
|
||
|
||
def plot_instrument(da: sc.DataArray, pixels_per_tube: int = 512, **kwargs: Any) -> Any: | ||
""" | ||
Plot a 2-D instrument view of a data array. | ||
|
||
This is an alternative to the `scn.instrument_view` function, avoiding the 3-D | ||
rendering of the instrument. The exact X and Y coordinates of the pixels are | ||
used for the 2-D plot. | ||
|
||
Parameters | ||
---------- | ||
da: | ||
The data array to plot. Must have a 'position' coord and a single dimension. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not possible to flatten if there are more than one dimension? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but this is for ISIS data, which has been loaded with Mantid, so why complicate things? It can be extended once/if required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had considered doing this, but then it would complicate since we would need to maybe support summing some dims but flattening others, I didn't think it was worth it at this point. After all, this is not an ESS instrument. |
||
pixels_per_tube: | ||
The number of pixels per tube. Defaults to 512. | ||
kwargs: | ||
Additional arguments passed to `sc.plot`. | ||
""" | ||
if da.bins is not None: | ||
da = da.hist() | ||
da.coords['x'] = da.coords['position'].fields.x.copy() | ||
da.coords['y'] = da.coords['position'].fields.y.copy() | ||
folded = da.fold(da.dim, sizes={'y': -1, 'x': pixels_per_tube}) | ||
y = folded.coords['y'] | ||
if sc.all(y.min('x') == y.max('x')): | ||
folded.coords['y'] = y.min('x') | ||
else: | ||
raise ValueError( | ||
'Cannot plot 2-D instrument view of data array with non-constant ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really have to raise or would it just make a ragged detector panel, like the other plots we have with 2d coords? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah maybe it's because the x coord is already 2d? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Scipp (and plotting, I guess?) do not support multiple 2-D coords. Or is Plopp supporting this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, we are not. |
||
'y coordinate along tubes. Use scippneutron.instrument_view instead.' | ||
) | ||
plot_kwargs = dict(aspect='equal', norm='log', figsize=(6, 10)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the |
||
plot_kwargs.update(kwargs) | ||
return folded.plot(**plot_kwargs) |
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.
Are you thinking this is generic enough that it can be used for other isis instruments? I guess it would work for sans2d as well. But then it should also work for other flat panels, not just isis panels?
Should we call it something else that implies it is plotting a flat panel? As it wouldn't work for something else.
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.
Are there any ISIS SANS instruments that do not have tubes that we have to worry about?
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 renamed it.