-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rectangular approximation for cylinder solid angle #29
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,11 @@ | |
from .common import gravity_vector | ||
from .types import ( | ||
DetectorEdgeMask, | ||
DetectorPixelShape, | ||
DirectBeam, | ||
DirectBeamFilename, | ||
Filename, | ||
LabFrameTransform, | ||
LoadedFileContents, | ||
MaskedData, | ||
MonitorType, | ||
|
@@ -39,8 +41,6 @@ def pooch_load(filename: Filename[RunType]) -> LoadedFileContents[RunType]: | |
data = dg['data'] | ||
if 'gravity' not in data.coords: | ||
data.coords["gravity"] = gravity_vector() | ||
data.coords['pixel_width'] = sc.scalar(0.002033984375, unit='m') | ||
data.coords['pixel_height'] = sc.scalar(0.0035, unit='m') | ||
|
||
# Some fixes specific for these Sans2d runs | ||
sample_pos_z_offset = 0.053 * sc.units.m | ||
|
@@ -133,6 +133,38 @@ def run_title(dg: LoadedFileContents[SampleRun]) -> RunTitle: | |
return RunTitle(dg['run_title'].value) | ||
|
||
|
||
def sans2d_tube_detector_pixel_shape() -> DetectorPixelShape[RunType]: | ||
# Pixel radius and length | ||
# found here: | ||
# https://github.com/mantidproject/mantid/blob/main/instrument/SANS2D_Definition_Tubes.xml | ||
R = 0.00405 | ||
L = 0.002033984375 | ||
Comment on lines
+140
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to remove to old values above (around line 40) |
||
pixel_shape = sc.DataGroup( | ||
{ | ||
'vertices': sc.vectors( | ||
dims=['vertex'], | ||
values=[ | ||
# Coordinates in pixel-local coordinate system | ||
# Bottom face center | ||
[0, 0, 0], | ||
# Bottom face edge | ||
[R, 0, 0], | ||
# Top face center | ||
[0, L, 0], | ||
Comment on lines
+147
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought Sans2d has horizontal tubes? This looks vertical to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the transform turns them horizontal. |
||
], | ||
unit='m', | ||
), | ||
'nexus_class': 'NXcylindrical_geometry', | ||
} | ||
) | ||
return pixel_shape | ||
|
||
|
||
def lab_frame_transform() -> LabFrameTransform[RunType]: | ||
# Rotate +y to -x | ||
return sc.spatial.rotation(value=[0, 0, 1 / 2**0.5, 1 / 2**0.5]) | ||
|
||
|
||
providers = ( | ||
pooch_load_direct_beam, | ||
pooch_load, | ||
|
@@ -143,6 +175,8 @@ def run_title(dg: LoadedFileContents[SampleRun]) -> RunTitle: | |
mask_detectors, | ||
run_number, | ||
run_title, | ||
lab_frame_transform, | ||
sans2d_tube_detector_pixel_shape, | ||
) | ||
""" | ||
Providers for loading and masking Sans2d data. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as
length
? Why does the caller have to provide that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direction of$cos (\alpha)$ . Yes I guess it's length ought to be 1 but normalizing it makes sure it can't even become an issue if someone forgets to make it length 1.
cylinder_axis
is required to computeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But
norm_ca
is the same aslength
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I understand the function interface now. I found it a bit surprising, but you can leave it.