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

Setting trapezoid area manually to 0 does not have an effect. #242

Closed
h3lg3 opened this issue Jan 23, 2025 · 2 comments
Closed

Setting trapezoid area manually to 0 does not have an effect. #242

h3lg3 opened this issue Jan 23, 2025 · 2 comments
Assignees

Comments

@h3lg3
Copy link
Contributor

h3lg3 commented Jan 23, 2025

Describe the bug
I wanted to quickly turn off a spoiler by manually setting its area to 0. However, this did not have an effect on the sequence.
I believe the issue is that in block.py the method get_block() calculates the area and flat_area parameters of the trapezoid itself instead of getting them from the event. Maybe somewhere the area and flat_area can be checked for consistency but I don't know where would be the right place to do so. Any help is appreciated. Kind regards, Helge.

def get_block(self, block_index: int) -> SimpleNamespace:

    lib_data = self.grad_library.data[event_ind[2 + i]]
    .
    .
    
    grad.amplitude = lib_data[0]
    grad.rise_time = lib_data[1]
    grad.flat_time = lib_data[2]
    grad.fall_time = lib_data[3]
    grad.delay = lib_data[4]
    grad.area = grad.amplitude * (
        grad.flat_time + grad.rise_time / 2 + grad.fall_time / 2
    )
    grad.flat_area = grad.amplitude * grad.flat_time

To Reproduce
Set the gradient area or flat_area to 0 and run the sequence again.

# Readout spoiler gradient
grad_ro_spr = pp.make_trapezoid(
    channel='x',
    system=system,
    area=500  
    duration=3e-3,
    )
grad_ro_spr.area = 0
@FrankZijlstra
Copy link
Collaborator

The correct way is to use grad_ro_spr.amplitude = 0.

Besides currently not being covered by the code (though perhaps we may be able to change this once changing the events to actual classes), changing area can be tricky to implement robustly. For example, should changing area allow changes to the duration of the gradient? E.g. increasing the area of a gradient with max_grad amplitude.

@h3lg3
Copy link
Contributor Author

h3lg3 commented Jan 24, 2025

Thanks for clarification! I agree that a robust implementation is tricky. I will implement the spoiler free sequence by setting the amplitude to 0.

@h3lg3 h3lg3 closed this as completed Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants