scippneutron.chopper.disk_chopper.DiskChopper#

class scippneutron.chopper.disk_chopper.DiskChopper(axle_position, frequency, beam_position, phase, slit_begin, slit_end, slit_height=None, radius=None)[source]#

A disk chopper.

This is a dataclass that encodes parameters of a single disk chopper and provides methods for computing slit opening times.

This class requires that the chopper is in phase with the neutron source and that the rotation frequency is constant. It, therefore, does not accept time-dependent parameters. If your data is time-dependent, you need to select a time range where the chopper is in phase and compute a constant rotation frequency and phase for this range. In particular, the top-dead-center timestamps need to be subsumed by the phase together with the source frequency.

See also

scippneutron.chopper.disk_chopper

For detailed documentation of the definitions and calculations used by DiskChopper.

scippneutron.chopper.nexus_chopper.post_process_disk_chopper

A function for converting NeXus chopper data into a supported layout.

__init__(axle_position, frequency, beam_position, phase, slit_begin, slit_end, slit_height=None, radius=None)#

Methods

__init__(axle_position, frequency, ...[, ...])

from_nexus(chopper)

Construct a new DiskChopper from data loaded from NeXus.

make_svg([image_size])

Generate an SVG image for this chopper.

open_duration(*, pulse_frequency)

Return how long the chopper is open for.

time_offset_angle_at_beam(*, angle[, ...])

Return the time offset when an angle on the chopper is at the beam.

time_offset_close(*, pulse_frequency)

Return the opening time offsets of the chopper slits.

time_offset_open(*, pulse_frequency)

Return the opening time offsets of the chopper slits.

Attributes

angular_frequency

Rotation speed as an angular frequency in rad * frequency.unit.

is_clockwise

Return True if the chopper rotates clockwise.

n_slits

Number of slits.

radius

Radius of the chopper.

slit_height

Distance from chopper outer edge to bottom of slits.

axle_position

Position of the chopper.

frequency

Rotation frequency of the chopper.

beam_position

Angle where the beam crosses the chopper.

phase

Phase of the chopper rotation relative to the source pulses.

slit_begin

Begin-edges of the slits as angles measured anticlockwise from top-dead-center.

slit_end

Begin-edges of the slits as angles measured anticlockwise from top-dead-center.

property angular_frequency: Variable#

Rotation speed as an angular frequency in rad * frequency.unit.

axle_position: Variable#

Position of the chopper.

This is the center point of the chopper’s axle in the face towards the source. See https://manual.nexusformat.org/classes/base_classes/NXdisk_chopper.html

beam_position: Variable#

Angle where the beam crosses the chopper.

frequency: Variable#

Rotation frequency of the chopper.

classmethod from_nexus(chopper)[source]#

Construct a new DiskChopper from data loaded from NeXus.

Keys in the input correspond to the fields of NXdisk_chopper. The values have to be post-processed, e.g., with post_process_disk_chopper(). See its documentation for the required steps. Also, note the class docs of DiskChopper about time-dependent fields.

Parameters:

chopper (Mapping[str, Variable | DataArray]) – Data group with fields loaded from an NXdisk_chopper and post-processed as described above.

Returns:

DiskChopper – A new DiskChopper instance.

property is_clockwise: bool#

Return True if the chopper rotates clockwise.

make_svg(image_size=400)[source]#

Generate an SVG image for this chopper.

Parameters:

image_size (int, default: 400) – The size in pixels of the image.

Returns:

str – The SVG image as a string.

property n_slits: int#

Number of slits.

open_duration(*, pulse_frequency)[source]#

Return how long the chopper is open for.

Parameters:

pulse_frequency; – Frequency of the neutron source.

Returns:

Variable – Variable of opening durations.

phase: Variable#

Phase of the chopper rotation relative to the source pulses.

Defined as \(\phi = \omega (t_0 + \delta t - T_0)\), where \(t_0\) is a TDC timestamp, \(\delta t\) is the chopper delay, and \(T_0\) is the pulse time.

radius: Variable | None = None#

Radius of the chopper.

slit_begin: Variable#

Begin-edges of the slits as angles measured anticlockwise from top-dead-center.

The order is arbitrary but must match the order of slit_end.

slit_end: Variable#

Begin-edges of the slits as angles measured anticlockwise from top-dead-center.

The order is arbitrary but must match the order of slit_end.

slit_height: Variable | None = None#

Distance from chopper outer edge to bottom of slits.

time_offset_angle_at_beam(*, angle, n_repetitions=1)[source]#

Return the time offset when an angle on the chopper is at the beam.

The time is an offset from the given pulse time. It encodes the time when the given angle passes by the beam position.

Computes \(\Delta t_g(\theta)\) as defined in scippneutron.chopper.disk_chopper.

Parameters:
  • angle (Variable) – Angle to compute time for. Defined anticlockwise with respect to top-dead-center.

  • n_repetitions (int, default: 1) – How many chopper rotations to perform.

Returns:

Variable – Computed time offset.

time_offset_close(*, pulse_frequency)[source]#

Return the opening time offsets of the chopper slits.

Computes \(\Delta t_g(\theta)\) as defined in scippneutron.chopper.disk_chopper with \(\theta\) = slit_end for clockwise rotation and \(\theta\) = slit_start otherwise.

If the chopper spins at a multiple of the pulse frequency, each slit shows up multiple times in the result such that the array covers an entire pulse length. If the chopper spins slower than the pulse frequency, only one time per slit is returned, but the result covers more than one pulse in time. See the module documentation scippneutron.chopper.disk_chopper for details.

Parameters:

pulse_frequency; – Frequency of the neutron source.

Returns:

Variable – Variable of opening times as offsets from the pulse time.

time_offset_open(*, pulse_frequency)[source]#

Return the opening time offsets of the chopper slits.

Computes \(\Delta t_g(\theta)\) as defined in scippneutron.chopper.disk_chopper with \(\theta\) = slit_begin for clockwise rotation and \(\theta\) = slit_end otherwise.

If the chopper spins at a multiple of the pulse frequency, each slit shows up multiple times in the result such that the array covers an entire pulse length. If the chopper spins slower than the pulse frequency, only one time per slit is returned, but the result covers more than one pulse in time. See the module documentation scippneutron.chopper.disk_chopper for details.

Parameters:

pulse_frequency; – Frequency of the neutron source.

Returns:

Variable – Variable of opening times as offsets from the pulse time.