Workflows#
He3 Cell Workflow#
The he3
submodule provides a helper He3CellWorkflow
:
[1]:
from ess import polarization as pol
print(pol.he3.He3CellWorkflow.__doc__)
Workflow for computing transmission functions for He3 cells.
This can handle polarizers as well as analyzers.
Parameters
----------
in_situ :
Whether to use an in-situ definition of the cell opacity based on cell
parameters, or an ex-situ definition based on direct beam data. The latter
requires a direct-beam measurement with depolarized cells.
incoming_polarized :
Whether the incoming beam for computing the analyzer transmission is polarized.
This is the case in beamlines with a supermirror polarizer, but also if the
polarizer is not removed from the beam during the analyzer transmission
measurement.
Opacity#
There are two ways of computing the opacity, from cell parameters and from direct-beam measurements.
[2]:
workflow = pol.he3.He3CellWorkflow(in_situ=True) # True is the default
workflow.visualize(pol.He3OpacityFunction[pol.Polarizer])
[2]:
[3]:
workflow = pol.he3.He3CellWorkflow(in_situ=False)
workflow.visualize(pol.He3OpacityFunction[pol.Polarizer])
[3]:
Transmission function#
The opacity can be used to obtain the transmission function of the cells. We show the in-situ case, but it works equivalently for the more precise definition of opacity:
[4]:
workflow = pol.he3.He3CellWorkflow(in_situ=True, incoming_polarized=False)
workflow.visualize(
pol.TransmissionFunction[pol.Polarizer], graph_attr={"rankdir": "LR"}
)
[4]:
There is a variant of the workflow using an incoming polarized beam for computing the transmission function of the analyzer. Note that the incoming polarized case only applies to the analyzer, since for the polarizer the incoming neutron beam will always be unpolarized:
[5]:
workflow = pol.he3.He3CellWorkflow(in_situ=True, incoming_polarized=True)
workflow.visualize(
(pol.TransmissionFunction[pol.Polarizer], pol.TransmissionFunction[pol.Analyzer]),
graph_attr={"rankdir": "LR"},
)
[5]:
Supermirror Workflow#
The supermirror
submodule provides a helper SupermirrorWorkflow
:
[6]:
from ess import polarization as pol
workflow = pol.supermirror.SupermirrorWorkflow()
print(workflow.__doc__)
A container for providers that can be assembled into a task graph.
[7]:
workflow.visualize(pol.TransmissionFunction[pol.Polarizer])
[7]:
Full pipeline#
On-the-fly reduction: opacity from cell parameters#
In total, we can choose to use either He3-cells or supermirrors for both the polarizer and analyzer. Following cell shows an example of using a polarizer supermirror and analyzer He3-cell with an incoming polarized beam and an in-situ opacity calculation:
[8]:
he3_workflow = pol.He3CellWorkflow(in_situ=True, incoming_polarized=True)
sm_workflow = pol.supermirror.SupermirrorWorkflow()
workflow = pol.PolarizationAnalysisWorkflow(
analyzer_workflow=he3_workflow, polarizer_workflow=sm_workflow
)
results = (
pol.PolarizationCorrectedData[pol.Up, pol.Up],
pol.PolarizationCorrectedData[pol.Up, pol.Down],
pol.PolarizationCorrectedData[pol.Down, pol.Up],
pol.PolarizationCorrectedData[pol.Down, pol.Down],
)
workflow.visualize(results, graph_attr={"rankdir": "LR"})
[8]:
Precise reduction: opacity from direct-beam measurements of unpolarized cells#
Here, an example is presented using the opacity calculation from direct-beam measurements (ex-situ case) for having 2x He3-cells as analyzer and polarizer. Note that the incoming-polarized beam only applies to the analyzer, since the polarizer will always use an incoming-unpolarized beam. Hence, one could alternatively use the same command is described under Transmission function for 2x He3-cells.
[9]:
he3_polarizer_workflow = pol.He3CellWorkflow(in_situ=False, incoming_polarized=False)
he3_analyzer_workflow = pol.He3CellWorkflow(in_situ=False, incoming_polarized=True)
workflow = pol.PolarizationAnalysisWorkflow(
analyzer_workflow=he3_analyzer_workflow, polarizer_workflow=he3_polarizer_workflow
)
workflow.visualize(results, graph_attr={"rankdir": "LR"})
[9]:
Correction workflow#
The correction worklow on its own looks as follows:
[10]:
from ess.polarization.correction import CorrectionWorkflow
workflow = CorrectionWorkflow()
workflow.visualize(results, graph_attr={"rankdir": "LR"})
[10]:
There is also a half-polarized version of the workflow, in case only a polarizer is used:
[11]:
from ess.polarization.correction import CorrectionWorkflow
results = (
pol.HalfPolarizedCorrectedData[pol.Up],
pol.HalfPolarizedCorrectedData[pol.Down],
)
workflow = CorrectionWorkflow(half_polarized=True)
workflow.visualize(results, graph_attr={"rankdir": "LR"})
[11]:
Note that in parts of the workflow Up
is used as a dummy value for the spin of the analyzer that is not present.