Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented May 21, 2024

This adds the framework for masking according to various coordinates (pixel_id, tof, wavelength, two_theta).

It also attempts to standardize the Powgen and dream-geant4 use cases, in terms of loading files and keeping logical dimensions.

This is part of #50, but it only implements the reduction workflow side of things, and not an interactive masking tool, which is defered to a later PR.

(Apologies about the noise with quotation marks, I accidentally ran black at some point on the files, after the config for black was removed due to the switch to ruff, and it therefore did not ignore quotation marks)

@nvaytet nvaytet marked this pull request as ready for review May 23, 2024 09:35
" | (x > sc.scalar(86e6, unit=\"ns\")),\n",
" # Mask in wavelength\n",
" WavelengthMask: lambda x: (x > sc.scalar(2.0, unit=\"angstrom\"))\n",
" & (x < sc.scalar(2.7, unit=\"angstrom\")),\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this mask come from? Is there an artefact in the data that needs to be masked?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there is no artifact. I was just to illustrate things.
I probably should make a separate example, either in a new section at the bottom or in a new notebook.

"source": [
"## Create pipeline using Sciline\n",
"\n",
"We use the basic providers available in `essdiffraction` as well as the specialised `powder` and `geant4` providers."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no basic providers, only ones for powder and geant4.

Comment on lines 11 to 13
- The high-resolution and SANS detectors have a very odd numbering scheme.
The scheme attempts to follows some sort of physical ordering in space (x,y,z),
but it is not possible to reshape the data into all the logical dimensions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The high-resolution and SANS detectors have a very odd numbering scheme.
The scheme attempts to follows some sort of physical ordering in space (x,y,z),
but it is not possible to reshape the data into all the logical dimensions.
- The high-resolution and SANS detectors have a very odd numbering scheme.
The scheme attempts to follows some sort of physical ordering in space (x,y,z),
but it is not possible to reshape the data into all the logical dimensions.

To get proper formatting. (Note the blank line)

@nvaytet
Copy link
Member Author

nvaytet commented May 24, 2024

@jl-wynen for now, the notebooks only work when computing d-spacing from positions, and not from a calibration file.
I looked at computing the other scattering coordinates from the d-spacing, if calibration is present, but it seemed more difficult than I thought.
Maybe you know of a good approach for this that I missed?

@jl-wynen
Copy link
Member

I know an approach but it may not be good. For CIF files we need to write data in tof. So the idea was to do the reduction in d-spacing and then convert back to tof using fake positions. You could use a similar approach here where you essentially determine calibrated positions by converting back from d-spacing.

There is some ambiguity here about how you define positions and tof, though. So you / we would have to make a judgement call. But since we need this anyway for CIF, we can use the same mechanism here.

Co-authored-by: Jan-Lukas Wynen <jan-lukas.wynen@ess.eu>
from ess.reduce import nexus

DETECTOR_BANK_RESHAPING = {
"endcap_backward_detector": lambda x: x.fold(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this into sizes, not lambdas

)
from .types import DetectorInfo

DETECTOR_BANK_SHAPES = {"powgen_detector": {"bank": 23, "column": 154, "row": 7}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shapes -> sizes

def focus_data(
data: MaskedData[RunType],
dspacing_bins: DspacingBins,
twotheta_bins: Optional[TwoThetaBins] = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe request a new data type to get data binned in theta, as in sans Qxy?

" TofMask: lambda x: (x < sc.scalar(0.0, unit=\"us\"))\n",
" | (x > sc.scalar(16666.67, unit=\"us\")),\n",
" # Mask in wavelength\n",
" WavelengthMask: lambda x: (x > sc.scalar(0.18, unit=\"angstrom\"))\n",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove wavelength mask

"""Data for tests and documentation with DREAM."""

from pathlib import Path
# from pathlib import Path
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

@nvaytet nvaytet merged commit 58bf575 into main May 30, 2024
@nvaytet nvaytet deleted the add-masking branch May 30, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants