Skip to content

Commit

Permalink
Continue adapting the amor procedures to sciline
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Oct 19, 2023
1 parent 0c96559 commit dfac0bc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
23 changes: 11 additions & 12 deletions src/essreflectometry/amor/beamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@

from ..choppers import make_chopper
from ..logging import log_call
from ..reflectometry.types import BeamlineParams, Run, SampleRotation


@log_call(
instrument='amor', message='Constructing AMOR beamline from default parameters'
)
BeamlineParams = NewType('Beamline', dict)

def make_beamline(
sample_rotation: sc.Variable,
beam_size: sc.Variable = None,
sample_size: sc.Variable = None,
detector_spatial_resolution: sc.Variable = None,
gravity: sc.Variable = None,
chopper_frequency: sc.Variable = None,
chopper_phase: sc.Variable = None,
chopper_1_position: sc.Variable = None,
chopper_2_position: sc.Variable = None,
) -> BeamlineParams:
sample_rotation: SampleRotation[Run],
) -> BeamlineParams[Run]:
beam_size: sc.Variable = None
sample_size: sc.Variable = None
detector_spatial_resolution: sc.Variable = None
gravity: sc.Variable = None
chopper_frequency: sc.Variable = None
chopper_phase: sc.Variable = None
chopper_1_position: sc.Variable = None
chopper_2_position: sc.Variable = None
"""
Amor beamline components.
Expand Down
9 changes: 5 additions & 4 deletions src/essreflectometry/amor/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
from datetime import datetime
from pathlib import Path
from typing import Any, Optional, Union, NewType, TypeVar
from typing import Any, Union

import scipp as sc
import scippnexus as snx

from ..logging import get_logger
from .beamline import make_beamline, BeamlineParams
from .types import Run, Raw, Filename
from ..reflectometry.types import BeamlineParams, Filename, Raw, Run
from .data import get_path


def _tof_correction(data: sc.DataArray, dim: str = 'tof') -> sc.DataArray:
Expand Down Expand Up @@ -84,7 +84,7 @@ def _load_nexus_entry(filename: Union[str, Path]) -> sc.DataGroup:
return f['entry'][()]


def load(filename: Filename[Run], beamline: BeamlineParams) -> Raw[Run]:
def load(filename: Filename[Run], beamline: BeamlineParams[Run]) -> Raw[Run]:
"""Load a single Amor data file.
Parameters
Expand All @@ -99,6 +99,7 @@ def load(filename: Filename[Run], beamline: BeamlineParams) -> Raw[Run]:
:
Data array object for Amor dataset.
"""
filename = get_path("sample.nxs")
get_logger('amor').info(
"Loading '%s' as an Amor NeXus file",
filename.filename if hasattr(filename, 'filename') else filename,
Expand Down
14 changes: 7 additions & 7 deletions src/essreflectometry/reflectometry/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
from scipp.constants import h, m_n, pi
from scippneutron._utils import elem_dtype, elem_unit
from scippneutron.conversion.graph import beamline, tof

# from . import orso
from .types import (
ThetaBins,
WavelengthBins,
Raw,
Run,
SpecularReflectionCoordTransformGraph,
ThetaBins,
ThetaData,
WavelengthBins,
WavelengthData,
Run,
Raw,
)

from . import orso


def theta(
gravity: sc.Variable,
Expand Down Expand Up @@ -262,4 +262,4 @@ def sum_bins(data_array: sc.DataArray):
return data_array_summed


providers = [specular_reflection, tof_to_wavelength, wavelength_to_theta]
providers = [tof_to_wavelength, wavelength_to_theta]
6 changes: 5 additions & 1 deletion src/essreflectometry/reflectometry/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ class FootprintCorrected(sciline.Scope[Run, sc.DataArray], sc.DataArray):
ThetaBins = NewType('ThetaBins', sc.Variable)


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


class BeamlineParams(sciline.Scope[Run, dict], dict):
"""Parameters describing the beamline"""


SpecularReflectionCoordTransformGraph = NewType(
'SpecularReflectionCoordTransformGraph', dict
)

0 comments on commit dfac0bc

Please sign in to comment.