Skip to content
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

Combine runs #99

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Combine runs #99

merged 3 commits into from
Oct 23, 2024

Conversation

jokasimr
Copy link
Contributor

@jokasimr jokasimr commented Oct 22, 2024

Fixes #58

Draft because:

  • needs tests
  • usage example will be added to docs <- will be done later

@jokasimr jokasimr marked this pull request as ready for review October 23, 2024 08:25
Comment on lines 24 to 34
def _set_first_if_lost(coord, da, das):
if coord not in da.coords:
da.coords[coord] = das[0].coords[coord]


def _concatenate_event_lists(*das):
da = sc.reduce(das).bins.concat()
_set_first_if_lost('position', da, das)
_set_first_if_lost('sample_rotation', da, das)
_set_first_if_lost('detector_rotation', da, das)
return da
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
def _set_first_if_lost(coord, da, das):
if coord not in da.coords:
da.coords[coord] = das[0].coords[coord]
def _concatenate_event_lists(*das):
da = sc.reduce(das).bins.concat()
_set_first_if_lost('position', da, das)
_set_first_if_lost('sample_rotation', da, das)
_set_first_if_lost('detector_rotation', da, das)
return da
def _concatenate_event_lists(*das):
return sc.reduce(das).bins.concat().assign_coords(das[0].coords)

but shouldn't we check that they are at lost close?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but shouldn't we check that they are at lost close?

No I don't think we can do that in any reasonable way. What is "close" depends on the context.

In this code we should just expect that what we're given is reasonable, and then we can add a validation layer at a higher level that takes the context into account.

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'll use this suggestion 👍
with the minor modification that I'll only propagate the coords that are explicitly listed,
to avoid propagating something that actually should be dropped.

Comment on lines 64 to 65
wf[OrsoSampleFilenames] = mapped[OrsoSampleFilenames].reduce(
index=axis_name, func=lambda *x: list(chain(*x))
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining the nested list handling here, it is not really obvious.

Comment on lines +117 to +120
result2 = pipeline.compute(ReflectivityOverQ).hist()
assert_allclose(
2 * sc.values(result.data), sc.values(result2.data), rtol=sc.scalar(1e-6)
)
Copy link
Member

Choose a reason for hiding this comment

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

Very weird that we need this factor here, can you explain / comment / link, since this needs to change once reflectivity is normalized correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not weird, for the reason you alluded to, the reflectivity is not normalized by the length of the run (or more precisely, by the total intensity over the period of the run).
There's an issue for this here: #78

Therefore there is currently generally no way for the workflow to distinguish the following two situations:

  • There is a large number of events because the sample reflectivity is high.
  • There is a large number of events because the run was longer than the reference run.

this needs to change once reflectivity is normalized correctly

Yes that is correct.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't the name "reflectivity" misleading / wrong then?

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 don't think so. It's just that the data is not congruent with the model for how the data was produced.

@jokasimr jokasimr merged commit 0c9dbb4 into main Oct 23, 2024
4 checks passed
@jokasimr jokasimr deleted the combine-runs branch October 23, 2024 13:18
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.

Support concatenating files
2 participants