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

Derotator Offsets #357

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion pyobs/modules/telescope/basetelescope.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import asyncio
from abc import ABCMeta, abstractmethod
from typing import Dict, Any, Tuple, Union, List, Optional
from astropy.coordinates import SkyCoord, ICRS, AltAz

from astroplan import Observer
from astropy.coordinates import SkyCoord, ICRS, AltAz, EarthLocation
import astropy.units as u
import logging

Expand Down Expand Up @@ -308,5 +310,12 @@ async def _update_celestial_headers(self) -> None:
"SUNDIST": (None if sun_dist is None else float(sun_dist.degree), "Solar Distance from Target"),
}

def _get_derotator_offset_from_header(self, hdr, obstime):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to _calculate_derotator_position_from_header?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better: _calculate_derotator_position and don't use the header. The telescope itself knows best, where it's pointing...

lat, lon, height = hdr["LATITUDE"][0], hdr["LONGITUD"][0], hdr["HEIGHT"][0]
location = EarthLocation(lat=lat * u.deg, lon=lon * u.deg, height=height * u.m)
target = SkyCoord(ra=hdr["TEL-RA"][0] * u.deg, dec=hdr["TEL-DEC"][0] * u.deg, frame="gcrs")
parallactic = Observer(location=location).parallactic_angle(time=obstime, target=target).deg
return float(parallactic - hdr["TEL-ALT"][0] - hdr["TEL-ROT"][0])


__all__ = ["BaseTelescope"]
Empty file.
18 changes: 18 additions & 0 deletions tests/modules/telescope/test_basetelescope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
from pyobs.modules.telescope import DummyTelescope
from pyobs.utils.time import Time


def test_get_derotator_offset_from_header():
telescope = DummyTelescope()
obstime = Time("2024-03-21T20:11:52.281735")
hdr = {
"LATITUDE": (-32.375823, None),
"LONGITUD": (20.810807999999998, None),
"HEIGHT": (1798.0000000004793, None),
"TEL-RA": (138.01290730636728, None),
"TEL-DEC": (-64.86351112618202, None),
"TEL-ROT": (-138.68173828124998, None),
"TEL-ALT": (57.24036032917521, None),
}
np.testing.assert_almost_equal(telescope._get_derotator_offset_from_header(hdr, obstime), 90.22, decimal=2)
Loading