dodal.common.maths#
Functions
|
Converts between a positive number of seconds and an equivalent number of microseconds. |
|
Standard handling for converting from start, stop, step to start, stop, num Forces step to be same direction as length Includes a final point if it is within 1% of the final step, prevents floating point arithmatic errors from giving inconsistent shaped scans between steps of an outer axis. |
- dodal.common.maths.step_to_num(start: float, stop: float, step: float) Tuple[float, float, int] [source]#
Standard handling for converting from start, stop, step to start, stop, num Forces step to be same direction as length Includes a final point if it is within 1% of the final step, prevents floating point arithmatic errors from giving inconsistent shaped scans between steps of an outer axis.
- Parameters:
start (float) – Start of length, will be returned unchanged
stop (float) – End of length, if length/step does not divide cleanly will be returned extended up to 1% of step, or else truncated.
step (float) – Length of a step along the line formed from start to stop. If stop < start, will be coerced to be backwards.
- Return type:
- Returns:
start, adjusted_stop, num = Tuple[float, float, int] start will be returned unchanged adjusted_stop = start + (num - 1) * step num is the maximal number of steps that could fit into the length.
- dodal.common.maths.in_micros(t: float) int [source]#
Converts between a positive number of seconds and an equivalent number of microseconds.
- Parameters:
t (float) – A time in seconds
- Raises:
ValueError – if t < 0
- Returns:
A time in microseconds, rounded up to the nearest whole microsecond,
- Return type:
t (int)