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

Fix chopper open and close times when direction is anticlockwise #51

Merged
merged 6 commits into from
Oct 2, 2024

Conversation

nvaytet
Copy link
Member

@nvaytet nvaytet commented Sep 30, 2024

There was a strange effect for anticlockwise choppers where when requesting more rotations, open and close times would just go more and more negative, instead of going the other way.
This PR fixes this.

Example:

import scipp as sc
import tof

Hz = sc.Unit('Hz')
deg = sc.Unit('deg')
meter = sc.Unit('m')
sec = sc.Unit('s')

chopper = tof.Chopper(
    frequency=10.0 * Hz,
    open=sc.array(dims=['cutout'], values=[10.0, 90.0], unit='deg'),
    close=sc.array(dims=['cutout'], values=[20.0, 130.0], unit='deg'),
    distance=10.0 * meter,
    phase=0 * deg,
    direction=tof.AntiClockwise,
    
)

print(chopper.open_close_times(0.0 * sec)[0].values)  # 2 rotations
print(chopper.open_close_times(0.2 * sec)[0].values)  # 3 rotations

Before:

array([0.06388889, 0.09444444, 0.16388889, 0.19444444])
array([-0.03611111, -0.00555556,  0.06388889,  0.09444444,  0.16388889, 0.19444444])

After:

array([-0.03611111, -0.00555556,  0.06388889,  0.09444444])
array([-0.03611111, -0.00555556,  0.06388889,  0.09444444,  0.16388889, 0.19444444])

@nvaytet nvaytet added the bug Something isn't working label Sep 30, 2024
Copy link
Member

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow 100% but the test seems to make sense.

@nvaytet nvaytet merged commit c232ce9 into main Oct 2, 2024
3 checks passed
@nvaytet nvaytet deleted the fix-open-times-anticlockwise branch October 2, 2024 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants