-
Notifications
You must be signed in to change notification settings - Fork 3
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
Estia #108
base: main
Are you sure you want to change the base?
Estia #108
Changes from all commits
8c26f15
b10a2c0
f84db80
b643492
baca44b
4e5fb07
43e63c9
2b32c7e
aa4b6a0
10ac274
ec0b317
e8b23f6
c3a6afe
dd1b7c0
9ac64dc
95cf51e
4db26a8
df83bfe
e516537
8ab311a
e03119e
9481703
ac1063e
8ece26c
6539130
a427864
a27676d
1f9f48c
40f641f
2dea495
d9610b8
7b68c2c
7efcc91
fbc77b1
9d48bc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp) | ||
import importlib.metadata | ||
|
||
import sciline | ||
import scipp as sc | ||
|
||
from ..reflectometry import providers as reflectometry_providers | ||
from ..reflectometry import supermirror | ||
from ..reflectometry.types import ( | ||
BeamDivergenceLimits, | ||
BeamSize, | ||
DetectorSpatialResolution, | ||
NeXusDetectorName, | ||
RunType, | ||
SamplePosition, | ||
) | ||
from . import conversions, load, maskings, normalization, resolution, workflow | ||
from .types import ( | ||
AngularResolution, | ||
SampleSizeResolution, | ||
WavelengthResolution, | ||
) | ||
|
||
try: | ||
__version__ = importlib.metadata.version(__package__ or __name__) | ||
except importlib.metadata.PackageNotFoundError: | ||
__version__ = "0.0.0" | ||
|
||
|
||
providers = ( | ||
*reflectometry_providers, | ||
*load.providers, | ||
*conversions.providers, | ||
*maskings.providers, | ||
*workflow.providers, | ||
*normalization.providers, | ||
) | ||
""" | ||
List of providers for setting up a Sciline pipeline. | ||
|
||
This provides a default Estia workflow including providers for loadings files. | ||
""" | ||
|
||
|
||
def default_parameters() -> dict: | ||
return { | ||
supermirror.MValue: sc.scalar(5, unit=sc.units.dimensionless), | ||
supermirror.CriticalEdge: 0.022 * sc.Unit("1/angstrom"), | ||
supermirror.Alpha: sc.scalar(0.25 / 0.088, unit=sc.units.angstrom), | ||
BeamSize[RunType]: 2.0 * sc.units.mm, | ||
DetectorSpatialResolution[RunType]: 0.0025 * sc.units.m, | ||
SamplePosition[RunType]: sc.vector([0, 0, 0], unit="m"), | ||
NeXusDetectorName[RunType]: "detector", | ||
BeamDivergenceLimits: ( | ||
sc.scalar(-0.75, unit='deg'), | ||
sc.scalar(0.75, unit='deg'), | ||
), | ||
} | ||
|
||
|
||
def EstiaWorkflow() -> sciline.Pipeline: | ||
""" | ||
Workflow with default parameters for the Estia instrument. | ||
""" | ||
return sciline.Pipeline(providers=providers, params=default_parameters()) | ||
|
||
|
||
__all__ = [ | ||
"AngularResolution", | ||
"EstiaWorkflow", | ||
"SampleSizeResolution", | ||
"WavelengthResolution", | ||
"conversions", | ||
"default_parameters", | ||
"load", | ||
"providers", | ||
"resolution", | ||
"supermirror", | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp) | ||
import scipp as sc | ||
|
||
from ..reflectometry.conversions import reflectometry_q | ||
from ..reflectometry.types import ( | ||
CoordTransformationGraph, | ||
) | ||
|
||
|
||
def theta( | ||
divergence_angle: sc.Variable, | ||
sample_rotation: sc.Variable, | ||
): | ||
''' | ||
Angle of reflection. | ||
|
||
Computes the angle between the scattering direction of | ||
the neutron and the sample surface. | ||
|
||
Parameters | ||
------------ | ||
divergence_angle: | ||
Divergence angle of the scattered beam. | ||
sample_rotation: | ||
Rotation of the sample from to its zero position. | ||
|
||
Returns | ||
----------- | ||
The reflection angle of the neutron. | ||
''' | ||
return divergence_angle + sample_rotation.to(unit=divergence_angle.unit) | ||
|
||
|
||
def divergence_angle( | ||
position: sc.Variable, | ||
sample_position: sc.Variable, | ||
detector_rotation: sc.Variable, | ||
): | ||
""" | ||
Angle between the scattering ray and | ||
the ray that travels parallel to the sample surface | ||
when the sample rotation is zero. | ||
|
||
Parameters | ||
------------ | ||
position: | ||
Detector position where the neutron was detected. | ||
sample_position: | ||
Position of the sample. | ||
detector_rotation: | ||
Rotation of the detector from its zero position. | ||
Returns | ||
---------- | ||
The divergence angle of the scattered beam. | ||
""" | ||
p = position - sample_position.to(unit=position.unit) | ||
return sc.atan2(y=p.fields.x, x=p.fields.z) - detector_rotation.to(unit='rad') | ||
|
||
|
||
def wavelength( | ||
event_time_offset, | ||
# Other inputs | ||
): | ||
"Converts event_time_offset to wavelength" | ||
# Use frame unwrapping from scippneutron | ||
raise NotImplementedError() | ||
|
||
|
||
def coordinate_transformation_graph() -> CoordTransformationGraph: | ||
return { | ||
"wavelength": wavelength, | ||
"theta": theta, | ||
"divergence_angle": divergence_angle, | ||
"Q": reflectometry_q, | ||
"L1": lambda source_position, sample_position: sc.norm( | ||
sample_position - source_position | ||
), # + extra correction for guides? | ||
"L2": lambda position, sample_position: sc.norm(position - sample_position), | ||
Comment on lines
+76
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use/import this from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is something that's come up before, but I really don't think it's useful to import these two tiny definitions from a separate package.
Besides, it's plausible that the L1 definition will change to take into account the non-straight (focused) beam. |
||
} | ||
|
||
|
||
providers = (coordinate_transformation_graph,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add descriptions of the parameters in the docstring?