Skip to content

Conversation

@jl-wynen
Copy link
Member

Fixes #283

Copy link
Member

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

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

Looks ok, but more detailed comments would make the rather involved logic/branching easier to follow.

Comment on lines +260 to +279
monitor: sc.DataArray,
dim: str,
*,
broadcast_to: sc.DataArray | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

Completely unrelated, but I really feel that having a better way of type-hinting details about DataArray (binned? dims? coords?) would make code much easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

Better?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

)
return detector / norm

case _HistogramNormalizationMode.BinsDifferentDim:
Copy link
Member

@SimonHeybrock SimonHeybrock Dec 2, 2025

Choose a reason for hiding this comment

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

Some comments here or clearer enum names would be really helpful. Took me a while to understand that this means "Histogram with (N-D) wavelength coord but not wavelength dim".

return _HistogramNormalizationMode.BinsDifferentDim


def _coord_midpoints(da: sc.DataArray, name: str) -> sc.Variable:
Copy link
Member

Choose a reason for hiding this comment

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

So it is not technically computing coord midpoints, but rather converting to bin-centers? Would be slightly less confusing when reading the code higher up.

*,
monitor: sc.DataArray,
uncertainty_broadcast_mode: UncertaintyBroadcastMode,
skip_range_check: bool = False,
Copy link
Member

Choose a reason for hiding this comment

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

I cannot see where this param is used, none of the providers seems to set it?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are no providers for this in essreduce. But see scipp/essdiffraction#216

Copy link
Member

Choose a reason for hiding this comment

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

Right. Can you clarify why you chose to "mask and skip check" there instead of masking here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I expanded the docstring. Is this clear enough?

@jl-wynen jl-wynen enabled auto-merge December 3, 2025 14:00
@jl-wynen jl-wynen force-pushed the monitor-norm-different-dims branch from fda9845 to 5eec2df Compare December 3, 2025 14:00
@jl-wynen jl-wynen mentioned this pull request Dec 4, 2025
@jl-wynen jl-wynen marked this pull request as draft December 4, 2025 13:54
auto-merge was automatically disabled December 4, 2025 13:54

Pull request was converted to draft

@jl-wynen jl-wynen marked this pull request as ready for review December 4, 2025 14:38
@jl-wynen jl-wynen force-pushed the monitor-norm-different-dims branch from 779797f to b99e8d8 Compare December 4, 2025 14:38
@jl-wynen
Copy link
Member Author

jl-wynen commented Dec 4, 2025

@nvaytet This seems to build now with a single threaded build. Should we merge it as is? Or do you want me to debug this further?

@nvaytet
Copy link
Member

nvaytet commented Dec 5, 2025

Go ahead an merge 👍

@nvaytet nvaytet merged commit 12b7adf into main Dec 5, 2025
4 checks passed
@nvaytet nvaytet deleted the monitor-norm-different-dims branch December 5, 2025 13:42
@github-project-automation github-project-automation bot moved this from In progress to Done in Development Board Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Monitor normalisation for detectors with different dimensions

4 participants