From d6df7d0b410f2d9e6aab97a2a7461e730089d83e Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Mon, 9 Feb 2026 23:17:25 +0100 Subject: [PATCH 1/2] remove [SampleRun] from EmptyCanSubtractedIofDspacing and EmptyCanSubtractedIofDspacingTwoTheta --- src/ess/powder/conversion.py | 2 +- src/ess/powder/correction.py | 4 ++-- src/ess/powder/types.py | 12 ++++++------ tests/dream/geant4_reduction_test.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ess/powder/conversion.py b/src/ess/powder/conversion.py index ada4da76..42f21743 100644 --- a/src/ess/powder/conversion.py +++ b/src/ess/powder/conversion.py @@ -262,7 +262,7 @@ def convert_reduced_to_tof( def convert_reduced_to_empty_can_subtracted_tof( - data: EmptyCanSubtractedIofDspacing[SampleRun], calibration: OutputCalibrationData + data: EmptyCanSubtractedIofDspacing, calibration: OutputCalibrationData ) -> EmptyCanSubtractedIntensityTof: return EmptyCanSubtractedIntensityTof( _convert_reduced_to_tof_impl(data, calibration) diff --git a/src/ess/powder/correction.py b/src/ess/powder/correction.py index 2e08a160..c328af08 100644 --- a/src/ess/powder/correction.py +++ b/src/ess/powder/correction.py @@ -389,14 +389,14 @@ def apply_lorentz_correction(da: sc.DataArray) -> sc.DataArray: def subtract_empty_can( data: IntensityDspacing[SampleRun], background: IntensityDspacing[EmptyCanRun], -) -> EmptyCanSubtractedIofDspacing[SampleRun]: +) -> EmptyCanSubtractedIofDspacing: return EmptyCanSubtractedIofDspacing(data.bins.concatenate(-background)) def subtract_empty_can_two_theta( data: IntensityDspacingTwoTheta[SampleRun], background: IntensityDspacingTwoTheta[EmptyCanRun], -) -> EmptyCanSubtractedIofDspacingTwoTheta[SampleRun]: +) -> EmptyCanSubtractedIofDspacingTwoTheta: return EmptyCanSubtractedIofDspacingTwoTheta(data.bins.concatenate(-background)) diff --git a/src/ess/powder/types.py b/src/ess/powder/types.py index 238270c2..228b0015 100644 --- a/src/ess/powder/types.py +++ b/src/ess/powder/types.py @@ -127,14 +127,14 @@ class IntensityDspacingTwoTheta(sciline.Scope[RunType, sc.DataArray], sc.DataArr """Data that has been normalized by a vanadium run, and grouped into 2theta bins.""" -class EmptyCanSubtractedIofDspacing(sciline.Scope[RunType, sc.DataArray], sc.DataArray): - """Intensity vs. d-spacing, subtracted by empty can measurement.""" +EmptyCanSubtractedIofDspacing = NewType("EmptyCanSubtractedIofDspacing", sc.DataArray) +"""Intensity vs. d-spacing, subtracted by empty can measurement.""" -class EmptyCanSubtractedIofDspacingTwoTheta( - sciline.Scope[RunType, sc.DataArray], sc.DataArray -): - """Intensity vs. d-spacing and 2theta, subtracted by empty can measurement.""" +EmptyCanSubtractedIofDspacingTwoTheta = NewType( + "EmptyCanSubtractedIofDspacingTwoTheta", sc.DataArray +) +"""Intensity vs. d-spacing and 2theta, subtracted by empty can measurement.""" IntensityTof = NewType("IntensityTof", sc.DataArray) diff --git a/tests/dream/geant4_reduction_test.py b/tests/dream/geant4_reduction_test.py index 6d051d6d..786c0b72 100644 --- a/tests/dream/geant4_reduction_test.py +++ b/tests/dream/geant4_reduction_test.py @@ -96,7 +96,7 @@ def make_workflow(params_for_det, *, run_norm): def test_pipeline_can_compute_dspacing_result(workflow): workflow = powder.with_pixel_mask_filenames(workflow, []) - result = workflow.compute(EmptyCanSubtractedIofDspacing[SampleRun]) + result = workflow.compute(EmptyCanSubtractedIofDspacing) assert result.sizes == {'dspacing': len(params[DspacingBins]) - 1} assert sc.identical(result.coords['dspacing'], params[DspacingBins]) @@ -113,7 +113,7 @@ def test_pipeline_can_compute_dspacing_result_without_empty_can(workflow): def test_pipeline_can_compute_dspacing_result_using_lookup_table_filename(workflow): workflow = powder.with_pixel_mask_filenames(workflow, []) workflow[TimeOfFlightLookupTableFilename] = dream.data.tof_lookup_table_high_flux() - result = workflow.compute(EmptyCanSubtractedIofDspacing[SampleRun]) + result = workflow.compute(EmptyCanSubtractedIofDspacing) assert result.sizes == {'dspacing': len(params[DspacingBins]) - 1} assert sc.identical(result.coords['dspacing'], params[DspacingBins]) @@ -191,7 +191,7 @@ def test_pipeline_normalizes_and_subtracts_empty_can_as_expected( workflow[FocussedDataDspacing[EmptyCanRun]] = empty_can workflow[UncertaintyBroadcastMode] = UncertaintyBroadcastMode.drop workflow = powder.with_pixel_mask_filenames(workflow, []) - result = workflow.compute(EmptyCanSubtractedIofDspacing[SampleRun]) + result = workflow.compute(EmptyCanSubtractedIofDspacing) subtracted = sample.bins.concatenate(-empty_can) expected = powder.correction.normalize_by_vanadium_dspacing( From f44a6e03da1beda03ab2c7e3c3eadae9c3d927f4 Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Mon, 9 Feb 2026 23:56:08 +0100 Subject: [PATCH 2/2] update docs --- .../dream/dream-advanced-powder-reduction.ipynb | 16 ++++++++-------- .../dream/dream-powder-reduction.ipynb | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/user-guide/dream/dream-advanced-powder-reduction.ipynb b/docs/user-guide/dream/dream-advanced-powder-reduction.ipynb index 0ec31290..94a1aee1 100644 --- a/docs/user-guide/dream/dream-advanced-powder-reduction.ipynb +++ b/docs/user-guide/dream/dream-advanced-powder-reduction.ipynb @@ -420,10 +420,10 @@ ").rename_axis(index='detector')\n", "\n", "all_detector_workflow = workflow.copy()\n", - "mapped = all_detector_workflow[EmptyCanSubtractedIofDspacing[SampleRun]].map(\n", + "mapped = all_detector_workflow[EmptyCanSubtractedIofDspacing].map(\n", " parameter_table\n", ")\n", - "all_detector_workflow[EmptyCanSubtractedIofDspacing[SampleRun]] = mapped.reduce(\n", + "all_detector_workflow[EmptyCanSubtractedIofDspacing] = mapped.reduce(\n", " func=powder.grouping.collect_detectors\n", ")" ] @@ -444,7 +444,7 @@ "outputs": [], "source": [ "all_detector_workflow.visualize(\n", - " EmptyCanSubtractedIofDspacing[SampleRun], graph_attr={\"rankdir\": \"LR\"}, compact=True\n", + " EmptyCanSubtractedIofDspacing, graph_attr={\"rankdir\": \"LR\"}, compact=True\n", ")" ] }, @@ -463,7 +463,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = all_detector_workflow.compute(EmptyCanSubtractedIofDspacing[SampleRun])" + "result = all_detector_workflow.compute(EmptyCanSubtractedIofDspacing)" ] }, { @@ -537,10 +537,10 @@ ").rename_axis(index='detector')\n", "\n", "all_detector_workflow = workflow.copy()\n", - "mapped = all_detector_workflow[EmptyCanSubtractedIofDspacingTwoTheta[SampleRun]].map(\n", + "mapped = all_detector_workflow[EmptyCanSubtractedIofDspacingTwoTheta].map(\n", " parameter_table\n", ")\n", - "all_detector_workflow[EmptyCanSubtractedIofDspacingTwoTheta[SampleRun]] = mapped.reduce(\n", + "all_detector_workflow[EmptyCanSubtractedIofDspacingTwoTheta] = mapped.reduce(\n", " func=powder.grouping.collect_detectors\n", ")" ] @@ -553,7 +553,7 @@ "outputs": [], "source": [ "all_detector_workflow.visualize(\n", - " EmptyCanSubtractedIofDspacingTwoTheta[SampleRun],\n", + " EmptyCanSubtractedIofDspacingTwoTheta,\n", " graph_attr={\"rankdir\": \"LR\"},\n", " compact=True,\n", ")" @@ -566,7 +566,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = all_detector_workflow.compute(EmptyCanSubtractedIofDspacingTwoTheta[SampleRun])" + "result = all_detector_workflow.compute(EmptyCanSubtractedIofDspacingTwoTheta)" ] }, { diff --git a/docs/user-guide/dream/dream-powder-reduction.ipynb b/docs/user-guide/dream/dream-powder-reduction.ipynb index 2b23c2f8..1c2199f8 100644 --- a/docs/user-guide/dream/dream-powder-reduction.ipynb +++ b/docs/user-guide/dream/dream-powder-reduction.ipynb @@ -122,10 +122,10 @@ "outputs": [], "source": [ "results = workflow.compute([\n", - " EmptyCanSubtractedIofDspacing[SampleRun],\n", + " EmptyCanSubtractedIofDspacing,\n", " ReducedEmptyCanSubtractedTofCIF\n", "])\n", - "intensity = results[EmptyCanSubtractedIofDspacing[SampleRun]]\n", + "intensity = results[EmptyCanSubtractedIofDspacing]\n", "cif_data = results[ReducedEmptyCanSubtractedTofCIF]" ] },