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

Use ess.reduce.nexus NeXus workflows as basis for all workflows #160

Merged
merged 12 commits into from
Aug 29, 2024

Conversation

SimonHeybrock
Copy link
Member

@SimonHeybrock SimonHeybrock commented Aug 20, 2024

I left a couple comments below to explain some of the refactoring.

CI will fail until ESSreduce is fixed and released. (done)

Comment on lines +77 to +86
def to_detector_position_offset(
global_offset: DetectorBankOffset, beam_center: BeamCenter
) -> DetectorPositionOffset[RunType]:
return DetectorPositionOffset[RunType](global_offset - beam_center)


def to_monitor_position_offset(
global_offset: MonitorOffset[MonitorType],
) -> MonitorPositionOffset[RunType, MonitorType]:
return MonitorPositionOffset[RunType, MonitorType](global_offset)
Copy link
Member Author

Choose a reason for hiding this comment

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

These two helpers replace logic in the removed components.py, which was mostly duplicating more generic code.

@@ -23,46 +21,6 @@
CalibrationFilename = NewType('CalibrationFilename', str)


def read_xml_detector_masking(filename: PixelMaskFilename) -> MaskedDetectorIDs:
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to ess/sans: While strictly speaking ISIS-specific, our ess.loki unit tests were using this, introducing an annoying dependency of the ess.loki unit tests on ess.isissans.

SourcePosition = reduce_gt.SourcePosition

DetectorBankSizes = reduce_t.DetectorBankSizes
NeXusDetectorName = reduce_t.NeXusDetectorName
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 don't like this, but I think otherwise we would need to rewrite a lot more imports and type hints? This way users can still import from ess.sans.types and don't need to know which ones are defined in ess.reduce.nexus.... even though that is how the graph viz now displays them :(

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 know I am probably alone on this, but see this as another reason for considering #95 again.

Copy link
Member

Choose a reason for hiding this comment

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

Has the situation changed now that we have workflow objects with default parameters set?
I guess the arguments about inspecting intermediate results have not really changed...

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean the default params we introduced for the widgets? That is not merged and probably still in flux, so I cannot tell yet.

src/ess/isissans/general.py Outdated Show resolved Hide resolved
src/ess/isissans/general.py Outdated Show resolved Hide resolved
dg: LoadedFileContents[RunType], nexus_name: NeXusMonitorName[MonitorType]
) -> RawMonitor[RunType, MonitorType]:
# See https://github.com/scipp/sciline/issues/52 why copy needed
mon = dg['monitors'][nexus_name]['data'].copy()
Copy link
Member

Choose a reason for hiding this comment

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

Is the need for this copy now gone? The issue is still open...

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 think we are not actually accessing a value property here?

src/ess/loki/general.py Outdated Show resolved Hide resolved
src/ess/loki/general.py Outdated Show resolved Hide resolved
data_to_tof,
monitor_to_tof,
)


def LokiAtLarmorWorkflow() -> 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.

Does it make more sense to move this to the workflow.py file?
If so, this file would now be pretty empty. Can we remove it altogether? (move stuff to workflow.py or init.py?)

Copy link
Member Author

Choose a reason for hiding this comment

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

It does, but there are also in-flight modifications in the widgets branch, and workflow.py actually contains beamlime-specifics which should be renamed. In other words, let us do this later.

Comment on lines +70 to +74
workflow = loki.LokiAtLarmorWorkflow()
workflow.insert(_hist_monitor_wavelength)
workflow[NeXusMonitorName[Incident]] = "monitor_1"
workflow[NeXusMonitorName[Transmission]] = "monitor_2"
workflow[WavelengthBins] = sc.linspace("wavelength", 1.0, 13.0, 50 + 1)
Copy link
Member

Choose a reason for hiding this comment

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

👍

MaskedData[SampleRun],
NormWavelengthTerm[SampleRun],
ElasticCoordTransformGraph,
)
workflow = workflow.copy()
# Avoid reshape of detector, which would break boolean-indexing by cost function
workflow[DetectorBankSizes] = {}
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -296,8 +277,7 @@ def test_beam_center_from_center_of_mass_is_close_to_verified_result():


def test_phi_with_gravity():
params = make_params()
pipeline = sciline.Pipeline(loki_providers(), params=params)
pipeline = make_workflow()
pipeline[BeamCenter] = _compute_beam_center()
pipeline[CorrectForGravity] = False
data_no_grav = pipeline.compute(
Copy link
Member

Choose a reason for hiding this comment

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

I skimmed through the tests, it seemed it was mostly about refactoring by making a fixture that would create the workflows. I don't think there were fundamental changes to any of the tests.
Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct.

@SimonHeybrock SimonHeybrock merged commit 47941a9 into main Aug 29, 2024
4 checks passed
@SimonHeybrock SimonHeybrock deleted the ess-reduce-nexus-workflow branch August 29, 2024 08:26
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.

2 participants