From f3131868ca1807e0dca09250e8efcd664024a115 Mon Sep 17 00:00:00 2001 From: Tim-Oliver Husser Date: Mon, 18 Dec 2023 20:02:07 +0100 Subject: [PATCH 1/2] flat pointing script --- pyobs/robotic/scripts/flatfield/__init__.py | 1 + pyobs/robotic/scripts/flatfield/pointing.py | 75 +++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 pyobs/robotic/scripts/flatfield/__init__.py create mode 100644 pyobs/robotic/scripts/flatfield/pointing.py diff --git a/pyobs/robotic/scripts/flatfield/__init__.py b/pyobs/robotic/scripts/flatfield/__init__.py new file mode 100644 index 00000000..2c44069b --- /dev/null +++ b/pyobs/robotic/scripts/flatfield/__init__.py @@ -0,0 +1 @@ +from .pointing import Pointing diff --git a/pyobs/robotic/scripts/flatfield/pointing.py b/pyobs/robotic/scripts/flatfield/pointing.py new file mode 100644 index 00000000..89d51125 --- /dev/null +++ b/pyobs/robotic/scripts/flatfield/pointing.py @@ -0,0 +1,75 @@ +from __future__ import annotations +import logging +from typing import Any, Optional, Union, TYPE_CHECKING, Dict + +from pyobs.interfaces import ITelescope +from pyobs.robotic.scripts import Script +from pyobs.utils.skyflats.pointing import SkyFlatsBasePointing + +if TYPE_CHECKING: + from pyobs.robotic import TaskSchedule, TaskArchive, TaskRunner + +log = logging.getLogger(__name__) + + +class Pointing(Script): + """Script for pointing the telescope for flats.""" + + def __init__( + self, + telescope: Union[str, ITelescope], + pointing: Union[Dict[str, Any], SkyFlatsBasePointing], + **kwargs: Any, + ): + """Init a new Pointing script. + Args: + telescope: telescope to move. + pointing: pointing class to use. + """ + if "configuration" not in kwargs: + kwargs["configuration"] = {} + Script.__init__(self, **kwargs) + + # store modules + self._telescope = telescope + self._pointing = self.get_object(pointing) + + async def can_run(self) -> bool: + """Whether this config can currently run. + Returns: + True if script can run now. + """ + + # get modules + try: + tel = await self.comm.proxy(self._telescope, ITelescope) + except ValueError: + return False + + # we need a camera + if not await tel.is_ready(): + return False + + # seems alright + return True + + async def run( + self, + task_runner: TaskRunner, + task_schedule: Optional[TaskSchedule] = None, + task_archive: Optional[TaskArchive] = None, + ) -> None: + """Run script. + Raises: + InterruptedError: If interrupted + """ + # get modules + log.info("Getting proxy for telescope...") + telescope = await self.comm.proxy(self._telescope, ITelescope) + + # point + await self._pointing(telescope) + log.info("Finished pointing telescope.") + + +__all__ = ["Pointing"] From b1b28e9f7cbffc4c056e03fd531757e8d5875bf0 Mon Sep 17 00:00:00 2001 From: Tim-Oliver Husser Date: Mon, 18 Dec 2023 20:02:51 +0100 Subject: [PATCH 2/2] v1.7.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 65ada1d9..290f3f22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "pyobs-core" packages = [{ include = "pyobs" }] -version = "1.6.15" +version = "1.7.0" description = "robotic telescope software" authors = ["Tim-Oliver Husser "] license = "MIT"