Skip to content

Commit

Permalink
refactor: move general reflectometry types out of amor.types
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Oct 25, 2023
1 parent 00ac8ae commit 5328dd5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 44 deletions.
3 changes: 1 addition & 2 deletions docs/examples/amor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"import scipp as sc\n",
"import sciline\n",
"from essreflectometry.amor import providers, default_parameters\n",
"from essreflectometry.types import *\n",
"from essreflectometry.amor.types import SampleRotation"
"from essreflectometry.types import *"
]
},
{
Expand Down
10 changes: 9 additions & 1 deletion src/essreflectometry/amor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
import scipp as sc

from .. import providers as reflectometry_providers
from ..types import Run
from ..types import (
Alpha,
BeamSize,
CriticalEdge,
DetectorSpatialResolution,
Gravity,
MValue,
SampleSize,
)
from . import beamline, calibrations, conversions, load, normalize, resolution
from .beamline import instrument_view_components
from .instrument_view import instrument_view
Expand Down
14 changes: 8 additions & 6 deletions src/essreflectometry/amor/beamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@

from ..choppers import make_chopper
from ..logging import log_call
from ..types import Run
from ..types import (
BeamSize,
DetectorSpatialResolution,
Gravity,
Run,
SampleRotation,
SampleSize,
)
from .types import (
BeamlineParams,
BeamSize,
Chopper1Position,
Chopper2Position,
ChopperFrequency,
ChopperPhase,
DetectorSpatialResolution,
Gravity,
SampleRotation,
SampleSize,
)


Expand Down
10 changes: 8 additions & 2 deletions src/essreflectometry/amor/calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import scipp as sc

# from ..reflectometry import orso
from ..types import CalibratedReference, Histogrammed, Reference
from .types import Alpha, CriticalEdge, MValue
from ..types import (
Alpha,
CalibratedReference,
CriticalEdge,
Histogrammed,
MValue,
Reference,
)


def supermirror_calibration(
Expand Down
31 changes: 1 addition & 30 deletions src/essreflectometry/amor/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import NewType, TypeVar
from typing import NewType

import sciline
import scipp as sc
Expand All @@ -14,35 +14,6 @@ class BeamlineParams(sciline.Scope[Run, dict], dict):
"""Parameters describing the beamline"""


# TODO What do they mean?
# Supermirror parameters
MValue = NewType('MValue', sc.Variable)
CriticalEdge = NewType('CriticalEdge', sc.Variable)
Alpha = NewType('Alpha', sc.Variable)
SupermirrorParameter = TypeVar('SupermirrorParameter', MValue, CriticalEdge, Alpha)


class SampleRotation(sciline.Scope[Run, sc.Variable], sc.Variable):
"""The rotation of the sample / the reference sample."""


class BeamSize(sciline.Scope[Run, sc.Variable], sc.Variable):
"""FWHM of the neutron beam."""


class DetectorSpatialResolution(sciline.Scope[Run, sc.Variable], sc.Variable):
# TODO
"""Don't know what this is."""


class SampleSize(sciline.Scope[Run, sc.Variable], sc.Variable):
# TODO is this radius or total length?
"""Size of the sample."""


Gravity = NewType('Gravity', sc.Variable)


class ChopperFrequency(sciline.Scope[Run, sc.Variable], sc.Variable):
"""Frequency of the choppers used in the run."""

Expand Down
33 changes: 30 additions & 3 deletions src/essreflectometry/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class QData(sciline.Scope[Run, sc.DataArray], sc.DataArray):
"""Theta data transformed to momentum transfer"""


QResolution = NewType('QResolution', sc.Variable)


class FootprintCorrected(sciline.Scope[Run, sc.DataArray], sc.DataArray):
"""Experiment data corrected by footprint on sample"""

Expand All @@ -47,6 +44,7 @@ class Normalized(sciline.Scope[Run, sc.DataArray], sc.DataArray):


NormalizedIofQ = NewType('NormalizedIofQ', sc.DataArray)
QResolution = NewType('QResolution', sc.Variable)


''' Parameters for the workflow '''
Expand All @@ -56,3 +54,32 @@ class Normalized(sciline.Scope[Run, sc.DataArray], sc.DataArray):

class Filename(sciline.Scope[Run, str], str):
"""Filename of the raw data"""


# TODO What do they mean?
# Supermirror parameters
MValue = NewType('MValue', sc.Variable)
CriticalEdge = NewType('CriticalEdge', sc.Variable)
Alpha = NewType('Alpha', sc.Variable)
SupermirrorParameter = TypeVar('SupermirrorParameter', MValue, CriticalEdge, Alpha)


class SampleRotation(sciline.Scope[Run, sc.Variable], sc.Variable):
"""The rotation of the sample / the reference sample."""


class BeamSize(sciline.Scope[Run, sc.Variable], sc.Variable):
"""FWHM of the neutron beam."""


class DetectorSpatialResolution(sciline.Scope[Run, sc.Variable], sc.Variable):
# TODO
"""Don't know what this is."""


class SampleSize(sciline.Scope[Run, sc.Variable], sc.Variable):
# TODO is this radius or total length?
"""Size of the sample."""


Gravity = NewType('Gravity', sc.Variable)

0 comments on commit 5328dd5

Please sign in to comment.