Skip to content

Commit

Permalink
Implement Goto Field for LCO (#16)
Browse files Browse the repository at this point in the history
* Add method to select macros based on observatory

* Add mock FFLCOHelper

* Big refactor of goto-field with initial support for LCO

* More updates and testing

* Update deps

* Add differences in acquisition and guiding for APO/LCO

* Try to set observatory in macro if not set in class

* Fix super call in GotoFieldLCOMacro

* Do not cover GoToFieldLCOMacro

* LCO arc time 45s

* Remove default guider time in command

* Fix super() of __init__ in AutoModeMacro

* Fixes to boss_hartmann()

* Do not command screen for now
  • Loading branch information
albireox authored Dec 15, 2023
1 parent cb2fa58 commit 9393be6
Show file tree
Hide file tree
Showing 13 changed files with 792 additions and 390 deletions.
366 changes: 204 additions & 162 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pytest-asyncio = ">=0.10.0"
pytest-cov = ">=2.8.1"
pytest-mock = ">=1.13.0"
pytest-sugar = ">=0.9.2"
codecov = ">=2.0.15"
coverage = {version = ">=5.0", extras = ["toml"]}
ipdb = ">=0.12.3"
rstcheck = ">=3.3.1"
Expand Down
24 changes: 18 additions & 6 deletions src/hal/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, *args, **kwargs):
if self.observatory == "APO":
kwargs["models"] += ["tcc", "mcp", "boss"]
elif self.observatory == "LCO":
kwargs["models"] += ["yao"]
kwargs["models"] += ["yao", "lcolamps"]

super().__init__(*args, schema=schema, **kwargs)

Expand Down Expand Up @@ -73,7 +73,8 @@ def __init__(self, actor: HALActor):
FFSHelper,
HALHelper,
JaegerHelper,
LampsHelper,
LampsHelperAPO,
LampsHelperLCO,
Scripts,
TCCHelper,
)
Expand All @@ -85,10 +86,16 @@ def __init__(self, actor: HALActor):
self.apogee = APOGEEHelper(actor)
self.boss = BOSSHelper(actor)
self.cherno = ChernoHelper(actor)
self.ffs = FFSHelper(actor)
self.jaeger = JaegerHelper(actor)
self.lamps = LampsHelper(actor)
self.tcc = TCCHelper(actor)

if self.observatory == "APO":
self.ffs = FFSHelper(actor)
self.lamps = LampsHelperAPO(actor)
self.tcc = TCCHelper(actor)
else:
self.ffs = None
self.lamps = LampsHelperLCO(actor)
self.tcc = None

self.bypasses: set[str] = set(actor.config["bypasses"])
self._available_bypasses = ["all"]
Expand All @@ -100,4 +107,9 @@ def __init__(self, actor: HALActor):

self.scripts = Scripts(actor, actor.config["scripts"][self.observatory])

self.macros = {macro.name: macro for macro in all_macros}
self.macros = {
macro.name: macro
for macro in all_macros
if macro.observatory is None
or macro.observatory.lower() == self.observatory.lower()
}
12 changes: 6 additions & 6 deletions src/hal/actor/commands/goto_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
@click.option(
"--guider-time",
type=float,
default=config["macros"]["goto_field"]["guider_time"],
show_default=True,
help="Exposure time for guiding/acquisition.",
)
@click.option(
Expand Down Expand Up @@ -98,6 +96,7 @@ async def goto_field(

assert command.actor

observatory = command.actor.observatory
jaeger_helper = command.actor.helpers.jaeger

if stages is not None and auto is True:
Expand All @@ -111,17 +110,18 @@ async def goto_field(
# previous configuration has the same field_id, regardless of whether it
# was observed or not.
previous = jaeger_helper._previous[-1] if jaeger_helper._previous else None
auto_mode_stages = config["macros"]["goto_field"]["auto_mode"]

if configuration is None:
return command.fail("No configuration loaded. Auto mode cannot be used.")
elif configuration.cloned is True:
stages = config["macros"]["goto_field"]["cloned_stages"]
stages = auto_mode_stages["cloned_stages"][observatory]
elif previous and previous.field_id == configuration.field_id:
stages = config["macros"]["goto_field"]["repeat_field_stages"]
stages = auto_mode_stages["repeat_field_stages"][observatory]
elif configuration.is_rm_field is True:
stages = config["macros"]["goto_field"]["rm_field_stages"]
stages = auto_mode_stages["rm_field_stages"][observatory]
else:
stages = config["macros"]["goto_field"]["new_field_stages"]
stages = auto_mode_stages["new_field_stages"][observatory]

if stages is not None and len(stages) == 0:
return command.finish("No stages to run.")
Expand Down
127 changes: 92 additions & 35 deletions src/hal/etc/hal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,44 +46,101 @@ lamp_warmup:

macros:
goto_field:
arc_time: 4
flat_time: 25
guider_time: 15.
acquisition_target_rms: 1.0
acquisition_min_rms: 3.0
acquisition_max_iterations: 4
fvc_az: 121
fvc_alt: 70
fvc_rot: 190
fvc:
az: 121
alt: 70
rot: 190
keep_offsets: true
fixed_rot: false
fixed_altaz: false
cloned_stages: []
new_field_stages:
[
'slew',
'reconfigure',
'fvc',
'reslew',
'lamps',
'boss_arcs',
'acquire',
'guide',
]
repeat_field_stages:
['slew', 'reconfigure', 'fvc', 'reslew', 'lamps', 'acquire', 'guide']
rm_field_stages:
[
'slew',
'reconfigure',
'fvc',
'reslew',
'lamps',
'boss_arcs',
'boss_flat',
'acquire',
'guide',
]
arc_time:
APO: 4
LCO: 45
flat_time:
APO: 25
LCO: 100
acquisition:
APO:
exposure_time: 15
target_rms: 1.0
min_rms: 3.0
max_iterations: 4
wait_time: null
LCO:
exposure_time: 15
target_rms: 0.8
min_rms: 3.0
max_iterations: 5
wait_time: 5
guide:
APO:
exposure_time: 15
wait_time: null
LCO:
exposure_time: 15
wait_time: 10
auto_mode:
cloned_stages:
APO: []
LCO: []
new_field_stages:
APO:
- slew
- reconfigure
- fvc
- reslew
- lamps
- boss_arcs
- acquire
- guide
LCO:
- slew
- reconfigure
- fvc
- reslew
- lamps
- boss_arcs
- boss_flat
- acquire
- guide
repeat_field_stages:
APO:
- slew
- reconfigure
- fvc
- reslew
- lamps
- acquire
- guide
LCO:
- slew
- reconfigure
- fvc
- reslew
- lamps
- acquire
- guide
rm_field_stages:
APO:
- slew
- reconfigure
- fvc
- reslew
- lamps
- boss_arcs
- boss_flat
- acquire
- guide
LCO:
- slew
- reconfigure
- fvc
- reslew
- lamps
- boss_arcs
- boss_flat
- acquire
- guide

expose:
boss_exptime: null
Expand Down
14 changes: 13 additions & 1 deletion src/hal/helpers/cherno.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ async def acquire(
target_rms: float | None = None,
wait: bool | None = None,
max_iterations: int | None = None,
wait_time: float | None = None,
):
"""Runs the acquisition command.
Expand All @@ -126,6 +127,9 @@ async def acquire(
block only if ``target_rms`` has been defined.
max_iterations
Maximum number of iterations before failing.
wait_time
Time to wait between iterations, for example to let the telescope
settle.
"""

Expand All @@ -137,6 +141,9 @@ async def acquire(
if max_iterations:
command_str += f" -x {max_iterations}"

if wait_time:
command_str += f" -w {wait_time}"

if block:
await self._send_command(command, "cherno", command_str)
else:
Expand All @@ -148,11 +155,16 @@ async def guide(
self,
command: HALCommandType,
exposure_time: float = 15,
wait_time: float | None = None,
wait: bool = False,
):
"""Start the guide loop."""

coro = self._send_command(command, "cherno", f"guide -t {exposure_time}")
command_str = f"guide -t {exposure_time}"
if wait_time:
command_str += f" -w {wait_time}"

coro = self._send_command(command, "cherno", command_str)

if wait:
await coro
Expand Down
2 changes: 1 addition & 1 deletion src/hal/helpers/ffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from hal.actor import HALCommandType


__all__ = ["FFSHelper"]
__all__ = ["FFSHelper", "FFSStatus"]


class FFSHelper(HALHelper):
Expand Down
Loading

0 comments on commit 9393be6

Please sign in to comment.