diff --git a/pyobs/images/processors/astrometry/dotnet.py b/pyobs/images/processors/astrometry/dotnet.py index 29e5f8cb..37b4994d 100644 --- a/pyobs/images/processors/astrometry/dotnet.py +++ b/pyobs/images/processors/astrometry/dotnet.py @@ -60,6 +60,8 @@ async def __call__(self, image: Image) -> Image: # get catalog if img.catalog is None: log.warning("No catalog found in image.") + if self.exceptions: + raise exc.ImageError("No catalog found in image.") return image cat = img.catalog[["x", "y", "flux", "peak"]].to_pandas().dropna() @@ -67,6 +69,8 @@ async def __call__(self, image: Image) -> Image: if cat is None or len(cat) < 3: log.warning("Not enough sources for astrometry.") img.header["WCSERR"] = 1 + if self.exceptions: + raise exc.ImageError("Not enough sources for astrometry.") return img # sort it, remove saturated stars and take N brightest sources @@ -78,6 +82,8 @@ async def __call__(self, image: Image) -> Image: if "CDELT1" not in img.header: log.warning("No CDELT1 found in header.") img.header["WCSERR"] = 1 + if self.exceptions: + raise exc.ImageError("No CDELT1 found in header.") return img # build request data diff --git a/pyobs/modules/camera/basecamera.py b/pyobs/modules/camera/basecamera.py index d56f28e4..51a3272c 100644 --- a/pyobs/modules/camera/basecamera.py +++ b/pyobs/modules/camera/basecamera.py @@ -425,18 +425,5 @@ def set_biassec_trimsec(hdr: fits.Header, left: int, top: int, width: int, heigh bottom_binned = np.ceil((is_top - hdr["YORGSUBF"]) / hdr["YBINNING"]) hdr["BIASSEC"] = ("[1:%d,1:%d]" % (hdr["NAXIS1"], bottom_binned), c1) - async def list_binnings(self, **kwargs: Any) -> List[Tuple[int, int]]: - """List available binnings. - - Returns: - List of available binnings as (x, y) tuples. - """ - - warnings.warn( - "The default implementation for list_binnings() in BaseCamera will be removed in future versions", - DeprecationWarning, - ) - return [(1, 1), (2, 2), (3, 3)] - __all__ = ["BaseCamera", "CameraException"] diff --git a/pyobs/modules/camera/dummycamera.py b/pyobs/modules/camera/dummycamera.py index 1128ead2..30706f1d 100644 --- a/pyobs/modules/camera/dummycamera.py +++ b/pyobs/modules/camera/dummycamera.py @@ -2,7 +2,7 @@ import glob import logging from datetime import datetime -from typing import Tuple, NamedTuple, Dict, Any, Optional, TYPE_CHECKING +from typing import Tuple, NamedTuple, Dict, Any, Optional, TYPE_CHECKING, List from pyobs.interfaces import IWindow, IBinning, ICooling, IGain from pyobs.modules.camera.basecamera import BaseCamera @@ -192,6 +192,15 @@ async def set_window(self, left: int, top: int, width: int, height: int, **kwarg log.info("Set window to %dx%d at %d,%d.", width, height, top, left) self._camera.window = (left, top, width, height) + async def list_binnings(self, **kwargs: Any) -> List[Tuple[int, int]]: + """List available binnings. + + Returns: + List of available binnings as (x, y) tuples. + """ + + return [(1, 1), (2, 2), (3, 3)] + async def get_binning(self, **kwargs: Any) -> Tuple[int, int]: """Returns the camera binning. diff --git a/pyobs/robotic/scripts/parallel.py b/pyobs/robotic/scripts/parallel.py index 6f30112d..c97c1c88 100644 --- a/pyobs/robotic/scripts/parallel.py +++ b/pyobs/robotic/scripts/parallel.py @@ -2,7 +2,6 @@ import logging from typing import Any, Dict, Optional, List -from pyobs.object import get_object from pyobs.robotic import TaskRunner, TaskSchedule, TaskArchive from pyobs.robotic.scripts import Script @@ -25,12 +24,7 @@ def __init__( Args: scripts: list or dict of scripts to run in parallel. """ - if "configuration" not in kwargs: - kwargs["configuration"] = {} Script.__init__(self, **kwargs) - - for script in scripts: - script["comm"] = self.comm self.scripts = scripts async def can_run(self) -> bool: @@ -43,7 +37,7 @@ async def run( task_archive: Optional[TaskArchive] = None, ) -> None: tasks = [ - asyncio.create_task(get_object(s, Script).run(task_runner, task_schedule, task_archive)) + asyncio.create_task(self.get_object(s, Script).run(task_runner, task_schedule, task_archive)) for s in self.scripts ] await asyncio.gather(*tasks) diff --git a/pyobs/robotic/scripts/script.py b/pyobs/robotic/scripts/script.py index b43ad332..9522a4ca 100644 --- a/pyobs/robotic/scripts/script.py +++ b/pyobs/robotic/scripts/script.py @@ -1,6 +1,6 @@ from __future__ import annotations import logging -from typing import Any, TypeVar, Optional, List, Dict, TYPE_CHECKING +from typing import Any, TypeVar, Optional, List, Dict, TYPE_CHECKING, Union from pyobs.object import Object @@ -14,7 +14,7 @@ class Script(Object): - def __init__(self, configuration: Any, **kwargs: Any): + def __init__(self, configuration: Optional[Any], **kwargs: Any): """Init Script. Args: diff --git a/pyobs/robotic/scripts/sequential.py b/pyobs/robotic/scripts/sequential.py index fba92a13..c2fb3673 100644 --- a/pyobs/robotic/scripts/sequential.py +++ b/pyobs/robotic/scripts/sequential.py @@ -1,6 +1,5 @@ import logging -from pyobs.modules.robotic import ScriptRunner -from typing import Any, Dict, Optional, Union, List +from typing import Any, Dict, Optional, List from pyobs.object import get_object from pyobs.robotic import TaskRunner, TaskSchedule, TaskArchive @@ -24,12 +23,7 @@ def __init__( Args: script: list or dict of scripts to run in a sequence. """ - if "configuration" not in kwargs: - kwargs["configuration"] = {} Script.__init__(self, **kwargs) - - for script in scripts: - script["comm"] = self.comm self.scripts = scripts async def can_run(self) -> bool: @@ -42,7 +36,7 @@ async def run( task_archive: Optional[TaskArchive] = None, ) -> None: for s in self.scripts: - await get_object(s, Script).run(task_runner, task_schedule, task_archive) + await self.get_object(s, Script).run(task_runner, task_schedule, task_archive) __all__ = ["SequentialRunner"] diff --git a/pyproject.toml b/pyproject.toml index 2618cdc6..35e92d07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "pyobs-core" packages = [{ include = "pyobs" }] -version = "1.4.12" +version = "1.4.13" description = "robotic telescope software" authors = ["Tim-Oliver Husser "] license = "MIT"