Skip to content

Commit

Permalink
add initial idgap alignment specific plan draft
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Aug 19, 2024
1 parent 945fe77 commit 69ce3cd
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 18 deletions.
25 changes: 25 additions & 0 deletions docs/alignment/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# alignment plan overview

sample stages T1X
T1Y

Expand Down Expand Up @@ -46,3 +47,27 @@ get the gaussian shape IT transmission detector we get the shape
or 50 micron beam - and then defocus to get to that

golden plate with wires is moved by some other location

## Alignment types

There are three major types of alignment:

- idgap
- pinhole
- wire scan

Other alignment (non exhaustive):

- KB mirror optimization (?)

Only the idgap one caches the results in a lookup table.

### IDGAP alignment details

moving the monochromator to a given Bragg angle, keeping it fixed and then scanning the undulator gap across a small range.

On the d7 diode the Bragg with a peak is that gap

2d scan of Bragg angle vs undulator gap, and peak compared to d7

### pinhole
11 changes: 0 additions & 11 deletions src/i18_bluesky/devices/LookupTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,3 @@ async def set(self, transmission: float):
await self._desired_transmission.set(transmission)
LOGGER.debug("Sending change filter command")
await self._change.trigger()

await asyncio.gather(
*[
wait_for_value(
self._filters_in_position[i],
await self._calculated_filter_states[i].get_value(),
None,
)
for i in range(16)
]
)
3 changes: 2 additions & 1 deletion src/i18_bluesky/plans/align_lookup_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from typing import Optional

import bluesky.plan_stubs as bps
from i18_bluesky.plans.align_lookup_2 import calculate_derivative_maxima
import numpy as np
import sympy as sp
from dodal.common import MsgGenerator, inject
from dodal.devices.undulator import Undulator

from i18_bluesky.plans.align_lookup_2 import calculate_derivative_maxima

monochromator = inject("monochromator")

I0 = inject("i0")
Expand Down
4 changes: 2 additions & 2 deletions src/i18_bluesky/plans/align_lookup_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def calculate_derivative_maxima(data: np.ndarray) -> List[float]:


@dataclass
class BeamlineAlignmentParams:
class IdGapAlignmentStatus:
target_energy: Optional[float] = 12.0
tolerance: Optional[float] = 0.1

Expand Down Expand Up @@ -111,7 +111,7 @@ def focus_kb_mirror_until_tolerance(

# todo multiple types of alignment were mixed in this plan and the plans above
def align_beamline(
undulator, monochromator, params: BeamlineAlignmentParams
undulator, monochromator, params: IdGapAlignmentStatus
) -> MsgGenerator:
yield from calibrate_monochromator(monochromator)

Expand Down
8 changes: 4 additions & 4 deletions src/i18_bluesky/plans/align_lookup_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def gaussian(x, amp, mean, sigma):


@dataclass
class Measurement:
class IdGapMeasurement:
bragg: float
gap: float

Expand All @@ -29,7 +29,7 @@ class Record:
detector: str
comment: str
harmonic: int
measurements: List[Measurement] = field(default_factory=list)
measurements: List[IdGapMeasurement] = field(default_factory=list)

def to_json(self):
return json.dumps(asdict(self), default=str, indent=4)
Expand All @@ -39,7 +39,7 @@ def from_json(cls, data: str):
data_dict = json.loads(data)
data_dict["date"] = datetime.fromisoformat(data_dict["date"])
data_dict["harmonic"] = int(data_dict["harmonic"])
measurements = [Measurement(**m) for m in data_dict["measurements"]]
measurements = [IdGapMeasurement(**m) for m in data_dict["measurements"]]
return cls(**data_dict, measurements=measurements)

def quadratic_regression(self):
Expand Down Expand Up @@ -103,7 +103,7 @@ async def scan(undulator, diode) -> Record:
detector="Diode",
comment="Measurement at peak diode value",
harmonic=undulator.harmonic,
measurements=[Measurement(peak_bragg, max(gap_array))],
measurements=[IdGapMeasurement(peak_bragg, max(gap_array))],
)

return record
Expand Down
21 changes: 21 additions & 0 deletions src/i18_bluesky/plans/alignment_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import bluesky.plan_stubs as bps
from bluesky.devices.monochromator import DCM as Monochromator
from dodal.common import MsgGenerator, inject
from dodal.devices.undulator import Undulator

UNDULATOR = inject("undulator")
DCM = inject("monochromator")


def align_idgap(
harmonic: int = 1,
undulator: Undulator = UNDULATOR,
monochromator: Monochromator = DCM,
) -> MsgGenerator:
"""
Bragg angle motor
"""

gap = yield from bps.rd(undulator.current_gap)
monochromator.bragg_in_degrees

0 comments on commit 69ce3cd

Please sign in to comment.