Skip to content
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

numpy.isclose too restrictive when creating AcquisitionGeometry #1804

Open
effepivi opened this issue May 14, 2024 · 0 comments
Open

numpy.isclose too restrictive when creating AcquisitionGeometry #1804

effepivi opened this issue May 14, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@effepivi
Copy link

Description

epsilon may be too small in File ~\AppData\Local\miniconda3\envs\dXCT2024\lib\site-packages\cil\framework\framework.py:657, in Detector2D.set_direction(self,

    655 dot_product = x.dot(y)
    656 if not numpy.isclose(dot_product, 0):
--> 657     raise ValueError("vectors detector.direction_x and detector.direction_y must be orthogonal")

with some experimental data. I got the position of the centre of the imager, its top and right.

Centre Top Right
imager_centre imager_top imager_right
-2.82322, -190.014, -459.137 -3.44796, -46.6199, -458.012 140.575 , -189.388, -459.257

We can compute the detector_direction_x and detector_direction_y vectors as follows:

    detector_direction_x = imager_right - imager_centre
    detector_half_width = np.linalg.norm(detector_direction_x)
    detector_direction_x /= detector_half_width
    
    detector_direction_y = imager_top - imager_centre
    detector_half_height = np.linalg.norm(detector_direction_y)
    detector_direction_y /= detector_half_height

The dot product between these two perpendicular vectors must be close to 0.0.

    dot_product = np.dot(detector_direction_x, detector_direction_y)

It is 2.0960759873050085e-06, which is relatively close to zero.

We can compute the angle between these two vectors as follows:

math.acos(dot_product) * 180.0 / math.pi

The angle is 89.99987990369239. One might argue that it is 90 degrees once we account for numerical inaccuracies.
However, it raises an error as numpy.isclose(dot_product, 0) returns False.

It would be great if the user could overwrite the tolerance parameters.

Environment

23.1.0 -1 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:27:34) [MSC v.1937 64 bit (AMD64)] win32

@effepivi effepivi added the enhancement New feature or request label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant