Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

_Sector method can't average reliably for circular regions. #43

Open
ehewins opened this issue Aug 4, 2023 · 0 comments · May be fixed by #47
Open

_Sector method can't average reliably for circular regions. #43

ehewins opened this issue Aug 4, 2023 · 0 comments · May be fixed by #47

Comments

@ehewins
Copy link
Contributor

ehewins commented Aug 4, 2023

Describe the bug
The class _Sector in sasdata/data_util/manipulations.py runs into issues when called with values for the args phi_min and phi_max which are 2pi radians apart. This behaviour can be observed by following the steps below:

To Reproduce

  1. In Sasview, Compute/Plot any 2D data from example_data/2d_data, using any model.
  2. Right click the plot and select either 'Wedge Averaging in Q' or 'Wedge Averaging in Phi'.
  3. Right click the plot again and select 'Edit Slicer Parameters', and set delta_phi [deg] to 180.
  4. Try moving the central line around, and note the error in the terminal: ValueError: Average Error: No points inside sector of ROI to average...

Sometimes the bug doesn't occur immediately, but it will usually show itself after trying a few different phi values. If dragging the central line via the GUI, you'll notice that the slicer won't stay put when you release your mouse button.

Additional context
I believe the issue begins with lines 875 and 876 of manipulations.py. If self.phi_min and self.phi_max are 2pi radians apart, then after being passed through the flip_phi() function the new variables phi_min and phi_max have the same value. There are then a load of checks for each of the points in the dataset to see if they're in the region enclosed by phi_min and phi_max. Instead of examining a circular region for valid datapoints, the _avg method examines an infinitesimal region which finishes immediately after it starts. Hence the error message: ValueError: Average Error: No points inside sector of ROI to average....

@ehewins ehewins linked a pull request Sep 17, 2023 that will close this issue
7 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant