Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Oct 20, 2023
1 parent be891e0 commit de67273
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
11 changes: 9 additions & 2 deletions src/essreflectometry/amor/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def load(filename: Filename[Run], beamline: BeamlineParams[Run]) -> Raw[Run]:
:
Data array object for Amor dataset.
"""
filename = get_path("sample.nxs")
filename = get_path(filename)
get_logger('amor').info(
"Loading '%s' as an Amor NeXus file",
filename.filename if hasattr(filename, 'filename') else filename,
Expand Down Expand Up @@ -128,7 +128,14 @@ def load(filename: Filename[Run], beamline: BeamlineParams[Run]) -> Raw[Run]:
# data.attrs['orso'] = sc.scalar(orso)

# Perform tof correction and fold two pulses
return Raw[Run](_tof_correction(data))
data = _tof_correction(data)

# Ad-hoc correction described in
# https://scipp.github.io/ess/instruments/amor/amor_reduction.html
data.coords['position'].fields.y += data.coords['position'].fields.z * sc.tan(
2.0 * data.coords['sample_rotation'] - (0.955 * sc.units.deg)
)
return data


def populate_orso(orso: Any, data: sc.DataGroup, filename: str) -> Any:
Expand Down
47 changes: 15 additions & 32 deletions src/essreflectometry/amor/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,25 @@
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
import scipp as sc

from ..reflectometry.types import (
FootprintCorrected,
QData,
QDataWithResolutions,
Resolutions,
Sample,
)
from ..reflectometry.types import QData, QDataWithResolutions, Sample
from .tools import fwhm_to_std


def compute_resolution(da: FootprintCorrected[Sample]) -> Resolutions:
return Resolutions(
{
'wavelength_resolution': wavelength_resolution(
chopper_1_position=da.coords['source_chopper_1'].value['position'],
chopper_2_position=da.coords['source_chopper_2'].value['position'],
pixel_position=da.coords['position'],
),
'angular_resolution': angular_resolution(
pixel_position=da.coords['position'],
theta=da.bins.coords['theta'],
detector_spatial_resolution=da.coords['detector_spatial_resolution'],
),
'sample_size_resolution': sample_size_resolution(
pixel_position=da.coords['position'],
sample_size=da.coords['sample_size'],
),
}
def compute_resolution(da: QData[Sample]) -> QDataWithResolutions:
da.coords['wavelength_resolution'] = wavelength_resolution(
chopper_1_position=da.coords['source_chopper_1'].value['position'],
chopper_2_position=da.coords['source_chopper_2'].value['position'],
pixel_position=da.coords['position'],
)
da.coords['angular_resolution'] = angular_resolution(
pixel_position=da.coords['position'],
theta=da.bins.coords['theta'],
detector_spatial_resolution=da.coords['detector_spatial_resolution'],
)
da.coords['sample_size_resolution'] = sample_size_resolution(
pixel_position=da.coords['position'],
sample_size=da.coords['sample_size'],
)


def add_resolutions(
da: QData[Sample], resolutions: Resolutions
) -> QDataWithResolutions:
for coord, value in resolutions.items():
da.coords[coord] = value
return QDataWithResolutions(da)


Expand Down

0 comments on commit de67273

Please sign in to comment.