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

added alignments plans #31

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
python-version: ${{ matrix.python-version }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

container:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_container.yml
permissions:
contents: read
packages: write
docs:
needs: check
if: needs.check.outputs.branch-pr == ''
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-yaml
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies = [
"dls-dodal",
"ophyd-async",
"bluesky",
"p99_bluesky",


#usefull stuff for testing or running without blue api
Expand Down
Empty file.
41 changes: 41 additions & 0 deletions src/i10_bluesky/plans/align_slits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# from enum import Enum

# from bluesky import preprocessors as bpp
# from bluesky.callbacks.fitting import PeakStats
# from bluesky.plan_stubs import abs_set
# from bluesky.plans import scan
# from dodal.common.types import MsgGenerator
# from dodal.devices.i10.slits import I10Slits
# from ophyd_async.core import StandardReadable
# from ophyd_async.epics.motor import Motor


# class PeakPosition(int, Enum):
# COM = 2
# CEN = 3


# def scan_and_move(
# det: StandardReadable,
# motor: Motor,
# start: float,
# end: float,
# num: int,
# loc: PeakPosition = PeakPosition.CEN,
# ) -> MsgGenerator:
# ps = yield from find_peak_centre(
# motor=motor, det=det, start=start, end=end, num=num
# )
# yield from abs_set(motor, ps["stats"][loc], wait=True)


# def find_peak_centre(
# det: StandardReadable, motor: Motor, start: float, end: float, num: int
# ) -> MsgGenerator:
# ps = PeakStats(f"{motor.name}", f"{det.name}")

# yield from bpp.subs_wrapper(
# scan([det], motor, start, end, num=num),
# ps,
# )
# return ps
3 changes: 3 additions & 0 deletions src/i10_bluesky/plans/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .alignments import PeakPosition, fast_scan_and_move_cen, scan_and_move_cen

__all__ = ["fast_scan_and_move_cen", "scan_and_move_cen", "PeakPosition"]
57 changes: 57 additions & 0 deletions src/i10_bluesky/plans/utils/alignments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from collections.abc import Callable
from enum import Enum

from bluesky import preprocessors as bpp
from bluesky.callbacks.fitting import PeakStats
from bluesky.plan_stubs import abs_set
from bluesky.plans import scan
from dodal.common.types import MsgGenerator
from ophyd_async.core import StandardReadable
from ophyd_async.epics.motor import Motor
from p99_bluesky.plans.fast_scan import fast_scan_1d


class PeakPosition(int, Enum):
COM = 2
CEN = 3


def scan_and_move_cen(funcs) -> Callable:
def inner(**kwargs):
ps = PeakStats(

Check warning on line 21 in src/i10_bluesky/plans/utils/alignments.py

View check run for this annotation

Codecov / codecov/patch

src/i10_bluesky/plans/utils/alignments.py#L21

Added line #L21 was not covered by tests
f"{kwargs['motor'].name}",
f"{kwargs['det'].name}",
calc_derivative_and_stats=True,
)

yield from bpp.subs_wrapper(

Check warning on line 27 in src/i10_bluesky/plans/utils/alignments.py

View check run for this annotation

Codecov / codecov/patch

src/i10_bluesky/plans/utils/alignments.py#L27

Added line #L27 was not covered by tests
funcs(**kwargs),
ps,
)
yield from abs_set(kwargs["motor"], ps["stats"][kwargs["loc"]], wait=True)

Check warning on line 31 in src/i10_bluesky/plans/utils/alignments.py

View check run for this annotation

Codecov / codecov/patch

src/i10_bluesky/plans/utils/alignments.py#L31

Added line #L31 was not covered by tests

return inner


@scan_and_move_cen
def step_scan_and_move_cen(
det: StandardReadable,
motor: Motor,
start: float,
end: float,
num: int,
loc: PeakPosition = PeakPosition.CEN,
) -> MsgGenerator:
return scan([det], motor, start, end, num=num)

Check warning on line 45 in src/i10_bluesky/plans/utils/alignments.py

View check run for this annotation

Codecov / codecov/patch

src/i10_bluesky/plans/utils/alignments.py#L45

Added line #L45 was not covered by tests


@scan_and_move_cen
def fast_scan_and_move_cen(
det: StandardReadable,
motor: Motor,
start: float,
end: float,
motor_speed: float | None = None,
loc: PeakPosition = PeakPosition.CEN,
) -> MsgGenerator:
return fast_scan_1d([det], motor, start, end, motor_speed=motor_speed)

Check warning on line 57 in src/i10_bluesky/plans/utils/alignments.py

View check run for this annotation

Codecov / codecov/patch

src/i10_bluesky/plans/utils/alignments.py#L57

Added line #L57 was not covered by tests
Loading