Skip to content

Commit

Permalink
Added dummy skyoffsets for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanHydrogen committed Jan 30, 2024
1 parent 5da6793 commit 73eba0c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyobs/images/processors/offsets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .projected import ProjectedOffsets
from .fitsheader import FitsHeaderOffsets
from .dummyoffsets import DummyOffsets
from .dummyskyoffsets import DummySkyOffsets

__all__ = [
"Offsets",
Expand All @@ -19,4 +20,5 @@
"FitsHeaderOffsets",
"BrightestStarOffsets",
"DummyOffsets",
"DummySkyOffsets"
]
24 changes: 24 additions & 0 deletions pyobs/images/processors/offsets/dummyskyoffsets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from copy import copy
from typing import Any, Union, Dict

from astropy.coordinates import SkyCoord

from pyobs.images import Image
from pyobs.images.meta import SkyOffsets
from pyobs.images.processors.offsets import Offsets
from pyobs.object import get_object


class DummySkyOffsets(Offsets):
def __init__(self, coord0: Union[SkyCoord, Dict[str, Any]], coord1: Union[SkyCoord, Dict[str, Any]], **kwargs: Any) -> None:
super().__init__(**kwargs)
sky_coord0 = get_object(coord0, SkyCoord)
sky_coord1 = get_object(coord1, SkyCoord)
self._offset = SkyOffsets(sky_coord0, sky_coord1)

async def __call__(self, image: Image) -> Image:
image.set_meta(copy(self._offset))
return image


__all__ = ["DummySkyOffsets"]
25 changes: 25 additions & 0 deletions tests/images/processors/offsets/test_dummyskyoffsets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
from astropy.coordinates import SkyCoord

from pyobs.images import Image
from pyobs.images.meta import SkyOffsets
from pyobs.images.processors.offsets import DummySkyOffsets


@pytest.mark.asyncio
async def test_call():
coord0 = SkyCoord(alt=90.0, az=0.0, unit="degree", frame="altaz")
coord1 = SkyCoord(alt=80.0, az=0.0, unit="degree", frame="altaz")

offsets = DummySkyOffsets(coord0, coord1)
image = Image()

result_image = await offsets(image)

result_offset = result_image.get_meta(SkyOffsets)

assert result_offset.coord0.alt.deg == 90.0
assert result_offset.coord0.az.deg == 0.0

assert result_offset.coord1.alt.deg == 80.0
assert result_offset.coord1.az.deg == 0.0

0 comments on commit 73eba0c

Please sign in to comment.