CelestialSurveyor

Форк
0
/
known_object.py 
63 строки · 2.3 Кб
1
from astropy import units as u
2
from astropy.coordinates import SkyCoord
3
from astropy.wcs import WCS
4

5

6
class KnownObject:
7
    """
8
    Represents a known astronomical object.
9

10
    Attributes:
11
        name (str): The name of the object.
12
        coordinates (SkyCoord): The celestial coordinates of the object.
13
        magnitude (str): The visual magnitude of the object.
14
        _wcs (WCS): The World Coordinate System information of the object.
15
        __pixel_coordinates (None or array-like): The pixel coordinates of the object.
16
    """
17
    def __init__(self, properties: dict, wcs: WCS=None):
18
        self.name = properties["Object name"]
19
        self.coordinates = SkyCoord(
20
            ra=properties["Astrometric RA (hh:mm:ss)"].replace("'", "").replace('"', ''),
21
            dec=properties["Astrometric Dec (dd mm'ss\")"].replace("'", " ").replace('"', ''),
22
            unit=(u.hourangle, u.deg)
23
        )
24
        self.magnitude = properties["Visual magnitude (V)"]
25
        self._wcs = wcs
26
        self.__pixel_coordinates = None
27

28
    def __str__(self):
29
        return f"{self.name}:{self.magnitude}"
30

31
    @property
32
    def wcs(self) -> WCS:
33
        """World Coordinate System information of the object"""
34
        return self._wcs
35

36
    @wcs.setter
37
    def wcs(self, value: WCS):
38
        self._wcs = value
39

40
    @property
41
    def pixel_coordinates(self) -> tuple:
42
        """Pixel coordinates of the object on the image calculated from the World Coordinate System information"""
43
        if not isinstance(self._wcs, WCS):
44
            raise ValueError("WCS is not specified or is not an instance of class WCS")
45
        return self.wcs.world_to_pixel(self.coordinates) if self.__pixel_coordinates is None \
46
            else self.__pixel_coordinates
47

48

49
if __name__ == '__main__':
50
    params = {
51
        "Object name": "(2021 RP107)",
52
        "Astrometric RA (hh:mm:ss)": "03:14:38",
53
        "Astrometric Dec (dd mm'ss\")": "+31 41'05\"",
54
        "Dist. from center RA (\")": "-8.E3",
55
        "Dist. from center Dec (\")": "956.",
56
        "Dist. from center Norm (\")": "8268.",
57
        "Visual magnitude (V)": "19.9",
58
        "RA rate (\"/h)": "-4.002E+01",
59
        "Dec rate (\"/h)": "8.931E+00",
60
        "Est. error RA (\")": "2735.",
61
        "Est. error Dec (\")": "2735."
62
    }
63
    print(KnownObject(params))
64

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.