Ramp
- class caqtus.shot_compilation.timed_instructions.Ramp(*args: object, **kwargs: object)
Bases:
TimedInstruction,GenericRepresents an instruction that linearly ramps between two values.
At index i, this instruction takes the value start + i * (stop - start) / length.
Use the
ramp()function to create instances of this class and don’t use the constructor directly.This class is generic over the data type of the ramp. Since a ramp only makes sense for floating point values, the type parameter is constrained to be a floating point type or a structured type with only floating point leaf fields.
- classmethod is_valid_dtype(dtype: dtype) bool
Indicates if the dtype is valid for the start and stop values of a ramp.
- Returns:
True if the dtype is a floating point type or a structured type with only floating point leaf fields, False otherwise.
- property start: T
The initial value of the ramp.
- property stop: T
The final value of the ramp.
- property dtype: np.dtype[T]
Returns the dtype of the instruction.
- property slope: float
The slope of the ramp.
Only applicable if the ramp is of floating point type.
- property intercept: float
The intercept of the ramp.
Only applicable if the ramp is of floating point type.
- as_type(
- dtype: dtype,
Returns a new instruction with the given dtype.
- property depth: Depth
Returns the number of nested instructions.
The invariant instruction.depth <= len(instruction) always holds.
- apply(func: Callable[[Array1D[T]], Array1D[S]]) TimedInstruction[S]
Map a function element-wise to the ramp.
Warning
Since an arbitrary function will not necessarily preserve linear ramps, the ramp is explicitly computed before applying the function. This may lead to poor performance and large memory usage for long ramps.