From 10416912b9d78b754aaa7a8f0e28d3dfa0013751 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Thu, 16 Nov 2023 10:40:50 +0100 Subject: [PATCH] fix: type and better name and docs --- src/esssans/normalization.py | 22 ++++++++++++---------- src/esssans/types.py | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/esssans/normalization.py b/src/esssans/normalization.py index 908f39d4..afd7949f 100644 --- a/src/esssans/normalization.py +++ b/src/esssans/normalization.py @@ -65,28 +65,32 @@ def solid_angle_rectangular_approximation( ) -def solid_angle_rectangular_approximation_cylinder( +def solid_angle( + data: CalibratedMaskedData[RunType], detector: DetectorGeometry[RunType], ) -> SolidAngle[RunType]: """ - Solid angle computed from cylindrical pixels. + Solid angle for cylindrical pixels. - Note that this approximation is only valid when the distance between sample - and pixel is much larger than the length or the radius of the pixel. + Note that the approximation is valid when the distance from sample + to pixel is much larger than the length or the radius of the pixels. Parameters ---------- + data: + The DataArray that contains the positions of the detector pixels in coords. + The positions must be in the sample reference frame. + detector: The DataGroup that contains the geometry of the detector. - Must contain pixel_shape, the transformation to the sample reference frame - and the position (center) of each pixel. + Must contain pixel_shape and the transformation from the + local reference frame of the detector to the sample reference frame. Returns ------- : The solid angle of the detector pixels, as viewed from the sample position. """ - face_1_center, face_1_edge, face_2_center = ( detector['pixel_shape']['vertices']['vertex', i] for i in range(3) ) @@ -98,9 +102,7 @@ def solid_angle_rectangular_approximation_cylinder( return SolidAngle[RunType]( approximate_solid_angle_for_cylinder_shaped_pixel_of_detector( - # Is there a way to get the positions of - # the pixels without going through the events? - pixel_position=detector['larmor_detector_events'].coords['position'], + pixel_position=data.coords['position'], cylinder_axis=cylinder_axis, radius=radius, length=length, diff --git a/src/esssans/types.py b/src/esssans/types.py index 8d587025..a8ad3bb5 100644 --- a/src/esssans/types.py +++ b/src/esssans/types.py @@ -106,7 +106,7 @@ class Filename(sciline.Scope[RunType, str], str): """Direct beam after resampling to required wavelength bins""" -class DetectorGeometry(sciline.Scope[RunType, sc.DataGroup], sc.DataArray): +class DetectorGeometry(sciline.Scope[RunType, sc.DataGroup], sc.DataGroup): """Geometry of the detector from description in nexus file."""