Skip to content

Lookup relative error threshold#246

Merged
jl-wynen merged 6 commits intomainfrom
lookup-error-threshold
Mar 17, 2026
Merged

Lookup relative error threshold#246
jl-wynen merged 6 commits intomainfrom
lookup-error-threshold

Conversation

@jl-wynen
Copy link
Member

@jl-wynen jl-wynen commented Mar 9, 2026

Adapt the LookupTableRelativeErrorThreshold to be defined per component, as per scipp/essreduce#319

Also:
Fixes #244

@jl-wynen jl-wynen requested a review from nvaytet March 9, 2026 16:51
Copy link
Member

@nvaytet nvaytet left a comment

Choose a reason for hiding this comment

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

I don't understand why CI is failing... a vector coordinate mismatch does not seem to originate from these changes...

email-validator==2.3.0
# via scippneutron
essreduce==26.1.1
essreduce==26.3.1
Copy link
Member

Choose a reason for hiding this comment

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

Should this be set as a lower bound in the pyproject.toml?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jl-wynen jl-wynen force-pushed the lookup-error-threshold branch from 9a0b187 to edb8ec9 Compare March 10, 2026 06:29
@jl-wynen
Copy link
Member Author

I don't understand why CI is failing... a vector coordinate mismatch does not seem to originate from these changes...

This is related to a change in ESSreduce. Not sure yet which, but the coord transform from time to wavelength no longer removes the position. Do you know why?

@nvaytet
Copy link
Member

nvaytet commented Mar 16, 2026

I now tracked it down to scipp/essreduce#302

@nvaytet
Copy link
Member

nvaytet commented Mar 16, 2026

My guess is that we now assign Ltotal here and after that, we do

da.transform_coords(
        'wavelength', graph={"wavelength": wavelength_from_tof}, keep_intermediate=False
    )

here.

Because the Ltotal is already present, the position no longer gets consumed (even though we have keep_intermediate=False) and so it is still there on the WavelengthMonitor?

@nvaytet
Copy link
Member

nvaytet commented Mar 16, 2026

Suggestion for a fix: we manually remove the position coords here when we compute the transmission fraction.
We can then remove that once scipp/ess#247 is implemented.

@nvaytet
Copy link
Member

nvaytet commented Mar 16, 2026

See #244

nvaytet and others added 3 commits March 17, 2026 08:39
…as not needed in the first place after we introduced WavelengthMonitor in generic workflow. That provider can be removed once we fix it in essreduce
"""I(Qx, Qy) with background (given by I(Qx, Qy) of the background run) subtracted"""


class WavelengthMonitor(
Copy link
Member

Choose a reason for hiding this comment

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

Instead, we can just use the WavelengthMonitor from essreduce.

)


def monitor_to_wavelength(
Copy link
Member

Choose a reason for hiding this comment

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

This provider was not really needed in the first place. We could have just used the one from essreduce that provides WavelengthMonitor. We now use it to 'fix' the monitors (by stripping the position coord).
The entire provider can be removed once we fix this in essreduce.

use the ``WavelengthMonitor`` provided by the generic essreduce workflow.
"""

out = monitor.transform_coords('wavelength', graph=graph, keep_intermediate=False)
Copy link
Member

Choose a reason for hiding this comment

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

Note here that we went from keep_inputs=False (before) to keep_intermediate=False (now).
The input now has both position and Ltotal coords. With keep_inputs=False, the Ltotal would disappear and the position would remain.
Now, keep_intermediate=False removes nothing (maybe we don't need the kwarg at all?), and we manually remove position to only leave Ltotal at the end.

@nvaytet
Copy link
Member

nvaytet commented Mar 17, 2026

@jl-wynen can you take another look to check I didn't mess anything up?

Copy link
Member Author

@jl-wynen jl-wynen left a comment

Choose a reason for hiding this comment

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

Looks good. But I can't approve myself because I opened this PR,

@jl-wynen jl-wynen merged commit 2fcb973 into main Mar 17, 2026
4 checks passed
@jl-wynen jl-wynen deleted the lookup-error-threshold branch March 17, 2026 08:44
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.

Position coord on CorrectedMonitor causes transmission_fraction to fail

2 participants