Skip to content

Migrate offspec #146

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

Merged
merged 12 commits into from
Apr 24, 2025
Merged

Migrate offspec #146

merged 12 commits into from
Apr 24, 2025

Conversation

jokasimr
Copy link
Contributor

Fixes #32

jokasimr and others added 8 commits April 11, 2025 11:41

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…nto migrate-offspec
@github-project-automation github-project-automation bot moved this to In progress in Development Board Apr 15, 2025
@jokasimr jokasimr moved this from In progress to Selected in Development Board Apr 15, 2025
graph: CoordTransformationGraph[ReferenceRun],
) -> MonitorData[RunType]:
full = sc.io.load_hdf5(filename)
mon = full["monitors"]["monitor2"]["data"].transform_coords(
Copy link
Member

Choose a reason for hiding this comment

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

Please make the monitor name a parameter. See, e.g., cell 5 in https://scipp.github.io/esssans/user-guide/isis/sans2d.html

@@ -0,0 +1,32 @@
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
Copy link
Member

Choose a reason for hiding this comment

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

Missing the first line of the license header. Also in other files.

@@ -0,0 +1,38 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
Copy link
Member

Choose a reason for hiding this comment

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

Please update the year in all files.

Copy link
Member

Choose a reason for hiding this comment

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

It looks like the workflow has changed. The old one normalised in wavelength and then converted to Q. This one converts to Q first and then normalises. Did you check with the scientists that this makes sense? This workflow was meant to replicate the ISIS workflow for OFFSPEC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't check with any scientist, but I'm sure it's not a problem, and I don't think we should bother them with this since it's a one-off workflow for an instrument at a different facility.

Maybe you want me to check with them anyway, but let me at least try to convince you that what we are doing here is fine.

This is how the measured intensities are modeled, I s is the sample measurement and I r is the reference measurement

I s ( λ ) = D ( λ ) M s ( λ ) R ( Q ( λ ) ) I r ( λ ) = D ( λ ) M r ( λ ) .

To estimate R ( q i ) , move the monitor term to the lhs and integrate over a small Q -bin Δ i = [ q i 1 2 , q i + 1 2 ]

Q Δ i I s ( λ ) M s ( λ )   d λ Q Δ i D ( λ )   d λ   R ( q i ) R ( q i ) Q Δ i I s ( λ ) M s ( λ )   d λ Q Δ i D ( λ )   d λ where the integral of D is estimated using the reference measurement Q Δ i I r ( λ ) M r ( λ )   d λ = Q Δ i D ( λ )   d λ so that R ( q i ) Q Δ i I s ( λ ) M s ( λ )   d λ Q Δ i I r ( λ ) M r ( λ )   d λ .

In the above expression it's natural to think about it like we are integrating over Q -bins. But we could equally well think about it like we are integrating over λ -bins because Q ( λ ) is bijective and

Q Δ i λ [ λ ( q i + 1 2 ) , λ ( q i 1 2 ) ]

So doing the normalization in Q and doing the normalization in λ is equivalent, provided that you use equivalent grids.

)


def OffspecWorkflow() -> sciline.Pipeline:
Copy link
Member

Choose a reason for hiding this comment

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

Please move this into workflow.py. There should be no definitions in __init__.py, only imports.

@jokasimr jokasimr requested a review from jl-wynen April 24, 2025 09:54
@jokasimr jokasimr merged commit 4d8b1c0 into main Apr 24, 2025
4 checks passed
@jokasimr jokasimr deleted the migrate-offspec branch April 24, 2025 11:14
@github-project-automation github-project-automation bot moved this from Selected to Done in Development Board Apr 24, 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.

Migrate the collimated (offspec) reduction workflow
2 participants