Skip to content

Commit

Permalink
Adding autodocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Relm-Arrowny committed Jan 23, 2025
1 parent 162ec3d commit e6ea6f0
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 41 deletions.
4 changes: 3 additions & 1 deletion src/i10_bluesky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Version number as calculated by https://github.com/pypa/setuptools_scm
"""

from . import plans
from ._version import __version__
from .plans import utils

__all__ = ["__version__"]
__all__ = ["__version__", "plans", "utils"]
2 changes: 0 additions & 2 deletions src/i10_bluesky/plans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
centre_tth,
move_pin_origin,
)

# from .centre_direct_beam import clear_beam_path
from .open_beam_path import (
clear_beam_path,
direct_beam_polan,
Expand Down
7 changes: 7 additions & 0 deletions src/i10_bluesky/plans/align_slits.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def move_dsu(
wait: bool = True,
group: Hashable | None = None,
) -> MsgGenerator:
"""Move up stream detector slit either by it size in slit motor table or by motor
position."""
yield from move_motor_with_look_up(
slit=det_slits().upstream,
size=size,
Expand All @@ -55,6 +57,8 @@ def move_dsd(
wait: bool = True,
group: Hashable | None = None,
) -> MsgGenerator:
"""Move down stream detector slit either by it size in slit motor table or by motor
position."""
yield from move_motor_with_look_up(
slit=det_slits().downstream,
size=size,
Expand All @@ -68,6 +72,7 @@ def move_dsd(
def align_dsu(
size: float, det: StandardReadable | None = None, det_name: str | None = None
) -> MsgGenerator:
"""Align the down stream detector slit"""
if det is None:
det, det_name = get_rasor_default_det()
yield from align_slit_with_look_up(
Expand All @@ -83,6 +88,7 @@ def align_dsu(
def align_dsd(
size: float, det: StandardReadable | None = None, det_name: str | None = None
) -> MsgGenerator:
"""Align the up stream detector slit"""
if det is None:
det, det_name = get_rasor_default_det()
yield from align_slit_with_look_up(
Expand All @@ -96,6 +102,7 @@ def align_dsd(


def align_pa_slit(dsd_size: float, dsu_size: float) -> MsgGenerator:
"""Align both detector slits"""
yield from move_dsd(5000, wait=True)
yield from align_dsu(dsu_size)
yield from align_dsd(dsd_size)
Expand Down
7 changes: 5 additions & 2 deletions src/i10_bluesky/plans/open_beam_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def open_dsd_dsu(
group: Hashable | None = None,
) -> MsgGenerator:
"""Remove both detector slits
Parameters
----------
open_position: float
Expand Down Expand Up @@ -72,6 +73,7 @@ def remove_pin_hole(
group: Hashable | None = None,
) -> MsgGenerator:
"""Move pin hole out of the way of the pin
Parameters
----------
open_position: float
Expand All @@ -92,8 +94,8 @@ def remove_pin_hole(


def direct_beam_polan(wait: bool = True, group: Hashable | None = None) -> MsgGenerator:
"""
Move polarization analyzer out of the way of the beam.
"""Move polarization analyzer out of the way of the beam.
Parameters
----------
wait: bool
Expand All @@ -116,6 +118,7 @@ def direct_beam_polan(wait: bool = True, group: Hashable | None = None) -> MsgGe

def clear_beam_path(wait: bool = True, group: Hashable | None = None) -> MsgGenerator:
"""Move everything out of the way of the direct beam
Parameters
----------
wait: bool
Expand Down
72 changes: 38 additions & 34 deletions src/i10_bluesky/plans/utils/alignments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable
from enum import Enum
from functools import wraps
from typing import TypeVar, cast

from bluesky import preprocessors as bpp
Expand All @@ -17,13 +18,12 @@


class PeakPosition(tuple, Enum):
"""
Data table to help access the fit data.
Com: Centre of mass
CEN: Peak position
MIN: Minimum value
MAX: Maximum value
D_: Differential
"""Data table to help access the fit data.\n
Com: Centre of mass\n
CEN: Peak position\n
MIN: Minimum value\n
MAX: Maximum value\n
With prefix D: Differential
"""

COM = ("stats", "com")
Expand All @@ -41,8 +41,9 @@ class PeakPosition(tuple, Enum):

def scan_and_move_cen(funcs: TCallable) -> TCallable:
"""Wrapper to add PeakStats call back before performing scan
and move to the fitted position after scan"""
and move to the fitted position after scan."""

@wraps(funcs)
def inner(**kwargs):
# Add default value if they are None or missing.
if "motor_name" not in kwargs or kwargs["motor_name"] is None:
Expand Down Expand Up @@ -79,25 +80,26 @@ def step_scan_and_move_cen(
det_name: str | None = None,
loc: PeakPosition | None = None,
) -> MsgGenerator:
"""Does a step scan and move to the fitted position
Parameters
"""Does a step scan and move to the fitted position.
Parameters
----------
det: StandardReadable,
det: StandardReadable
Detector to be use for alignment.
motor: Motor
Motor devices that is being centre.
start: float,
start: float
Starting position for the scan.
end: float,
end: float
Ending position for the scan.
num:int
Number of step.
motor_name: str | None = None,
motor_name: str | None
Name extension for the motor.
det_name: str | None = None,
det_name: str | None
Name extension for the det.
loc: PeakPosition | None = None,
Which fitted position to move to see PeakPosition
loc: PeakPosition | None
Which fitted position to move to see PeakPosition.
"""
LOGGER.info(
f"Step scanning {motor}{motor_name} with {det}{det_name} pro-scan move to {loc}"
Expand All @@ -116,25 +118,26 @@ def fast_scan_and_move_cen(
loc: PeakPosition | None = None,
motor_speed: float | None = None,
) -> MsgGenerator:
"""Does a fast non-stopping scan and move to the fitted position
"""Does a fast non-stopping scan and move to the fitted position.
Parameters
----------
det: StandardReadable,
Detector to be use for alignment.
motor: Motor
Motor devices that is being centre.
start: float,
Starting position for the scan.
end: float,
Ending position for the scan.
det_name: str | None = None,
Name extension for the det.
motor_name: str | None = None,
Name extension for the motor.
loc: PeakPosition | None = None,
Which fitted position to move to see PeakPosition.
motor_speed: float | None = None,
Speed of the motor.
det: StandardReadable,
Detector to be use for alignment.
motor: Motor
Motor devices that is being centre.
start: float
Starting position for the scan.
end: float
Ending position for the scan.
det_name: str | None = None,
Name extension for the det.
motor_name: str | None = None,
Name extension for the motor.
loc: PeakPosition | None = None,
Which fitted position to move to see PeakPosition.
motor_speed: float | None = None,
Speed of the motor.
"""
LOGGER.info(
f"Fast scaning {motor}{motor_name} with {det}{det_name} pro-scan move to {loc}"
Expand Down Expand Up @@ -167,6 +170,7 @@ def align_slit_with_look_up(
"""Perform a step scan with the the range and starting motor position
given/calculated by using a look up table(dictionary).
Move to the peak position after the scan and update the lookup table.
Parameters
----------
motor: Motor
Expand Down
2 changes: 1 addition & 1 deletion src/i10_bluesky/plans/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def cal_range_num(cen, range, size) -> tuple[float, float, int]:
"""Calculate the start, end and the number of step for the scan"""
"""Calculate the start, end and the number of step for scan."""
start_pos = cen - range
end_pos = cen + range
num = math.ceil(abs(range * 4.0 / size))
Expand Down
3 changes: 2 additions & 1 deletion src/i10_bluesky/plans/utils/motions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def move_motor_with_look_up(
"""Perform a step scan with the the range and starting motor position
given/calculated by using a look up table(dictionary).
Move to the peak position after the scan and update the lookup table.
Parameters
----------
motor: Motor
Expand Down Expand Up @@ -61,7 +62,7 @@ def set_slit_size(
wait: bool = True,
group: Hashable | None = None,
) -> MsgGenerator:
"""Set opening of an x-y slit.
"""Set opening of x-y slit.
Parameters
----------
Expand Down

0 comments on commit e6ea6f0

Please sign in to comment.