Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.6.11 #309

Merged
merged 6 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pyobs/mixins/fitsheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,14 @@ def v(k: str) -> Any:

# pixel size in world coordinates
if "DET-PIXL" in hdr and "TEL-FOCL" in hdr and "DET-BIN1" in hdr and "DET-BIN2" in hdr:
# calculate plate scale for 1x1 binning
tmp = 360.0 / (2.0 * math.pi) * v("DET-PIXL") / v("TEL-FOCL")

# any focal reduction factor?
if "FOCL-RED" in hdr:
tmp /= hdr["FOCL-RED"]

# set WCS
hdr["CDELT1"] = (-tmp * v("DET-BIN1"), "Coordinate increment on x-axis [deg/px]")
hdr["CDELT2"] = (+tmp * v("DET-BIN2"), "Coordinate increment on y-axis [deg/px]")
hdr["CUNIT1"] = ("deg", "Units of CRVAL1, CDELT1")
Expand Down
9 changes: 9 additions & 0 deletions pyobs/modules/camera/basecamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ async def __expose(self, exposure_time: float, image_type: ImageType, broadcast:
image.header["IMAGETYP"] = image_type.value

# add fits headers and format filename
await self.add_custom_fits_headers(image)
await self.add_requested_fits_headers(image, header_futures_before)
await self.add_requested_fits_headers(image, header_futures_after)
await self.add_fits_headers(image)
Expand Down Expand Up @@ -300,6 +301,14 @@ async def __expose(self, exposure_time: float, image_type: ImageType, broadcast:
log.info("Finished image %s.", filename)
return image, filename

async def add_custom_fits_headers(self, image: Image):
"""Add FITS headers in derived classes.

Args:
image: Image to write FITS headers to.
"""
pass

@timeout(calc_expose_timeout)
async def grab_data(self, broadcast: bool = True, **kwargs: Any) -> str:
"""Grabs an image ans returns reference.
Expand Down
4 changes: 4 additions & 0 deletions pyobs/robotic/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
from .script import Script
from .skyflats import SkyFlats
from .darkbias import DarkBias
from .sequential import SequentialRunner
from .parallel import ParallelRunner
from .selector import SelectorScript
6 changes: 4 additions & 2 deletions pyobs/robotic/scripts/parallel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations
import asyncio
import logging
from typing import Any, Dict, Optional, List
from typing import Any, Dict, Optional, List, TYPE_CHECKING

from pyobs.robotic import TaskRunner, TaskSchedule, TaskArchive
if TYPE_CHECKING:
from pyobs.robotic import TaskRunner, TaskSchedule, TaskArchive
from pyobs.robotic.scripts import Script


Expand Down
7 changes: 4 additions & 3 deletions pyobs/robotic/scripts/sequential.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
import logging
from typing import Any, Dict, Optional, List
from typing import Any, Dict, Optional, List, TYPE_CHECKING

from pyobs.object import get_object
from pyobs.robotic import TaskRunner, TaskSchedule, TaskArchive
if TYPE_CHECKING:
from pyobs.robotic import TaskRunner, TaskSchedule, TaskArchive
from pyobs.robotic.scripts import Script

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "pyobs-core"
packages = [{ include = "pyobs" }]
version = "1.6.10"
version = "1.6.11"
description = "robotic telescope software"
authors = ["Tim-Oliver Husser <[email protected]>"]
license = "MIT"
Expand Down
27 changes: 15 additions & 12 deletions tests/images/processors/astrometry/test_dotnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def mock_catalog(size: int):
flux = [1.0] * size + [np.nan, np.nan]
peak = [1.0] * size + [np.nan, np.nan]

cat = QTable([x, y, flux, peak], names=('x', 'y', 'flux', 'peak'))
cat = QTable([x, y, flux, peak], names=("x", "y", "flux", "peak"))

return cat

Expand Down Expand Up @@ -140,6 +140,7 @@ async def test_call_cdelt_w_exception():

class MockResponse:
"""https://stackoverflow.com/questions/57699218/how-can-i-mock-out-responses-made-by-aiohttp-clientsession"""

def __init__(self, text, status):
self._text = text
self.status = status
Expand Down Expand Up @@ -177,17 +178,19 @@ async def test_call_post_error_n_exception(mocker, mock_header):
data = mock.call_args_list[0].kwargs["json"]

assert data == {
"ra": image.header["TEL-RA"],
"dec": image.header["TEL-DEC"],
"scale_low": 3600 * 0.9,
"scale_high": 3600 * 1.1,
"radius": 3.0,
"nx": image.header["NAXIS1"],
"ny": image.header["NAXIS2"],
"x": [0.0, 0.0, 0.0, 0.0, 0.0],
"y": [0.0, 0.0, 0.0, 0.0, 0.0],
"flux": [1.0, 1.0, 1.0, 1.0, 1.0],
}
"crpix-x": image.header["CRPIX1"],
"crpix-y": image.header["CRPIX2"],
"ra": image.header["TEL-RA"],
"dec": image.header["TEL-DEC"],
"scale_low": 3600 * 0.9,
"scale_high": 3600 * 1.1,
"radius": 3.0,
"nx": image.header["NAXIS1"],
"ny": image.header["NAXIS2"],
"x": [0.0, 0.0, 0.0, 0.0, 0.0],
"y": [0.0, 0.0, 0.0, 0.0, 0.0],
"flux": [1.0, 1.0, 1.0, 1.0, 1.0],
}


@pytest.mark.asyncio
Expand Down