Skip to content

Commit

Permalink
fix: type and better name and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Nov 16, 2023
1 parent 574973e commit 1041691
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/esssans/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/esssans/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""


Expand Down

0 comments on commit 1041691

Please sign in to comment.