Skip to content

converters.py

AngleConverter

Accept any valid input value for an astropy.coordinates.Angle and ensure the returned value is a float in decimal degrees. The unit should be included in the input value.

Source code in vast_pipeline/converters.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class AngleConverter:
    """Accept any valid input value for an astropy.coordinates.Angle and ensure the
    returned value is a float in decimal degrees. The unit should be included in the input
    value."""
    regex = r"\d+(\.\d+)?\s?\w+"

    def to_python(self, value: Angle) -> float:
        """
        Return the decimal degrees from the coordinate input as an Angle object.

        Args:
            value: The value of the angle input.

        Returns:
            The angle returned as an Angle object.
        """
        return Angle(value).deg

    def to_url(self, value: Angle) -> str:
        """
        Return the string format of an Angle object from the coordinate input.

        Args:
            value: The value of the angle input.

        Returns:
            The string representation of the Angle object created from the input.
        """
        return value.to_string()

to_python(value)

Return the decimal degrees from the coordinate input as an Angle object.

Parameters:

Name Type Description Default
value Angle

The value of the angle input.

required

Returns:

Type Description
float

The angle returned as an Angle object.

Source code in vast_pipeline/converters.py
74
75
76
77
78
79
80
81
82
83
84
def to_python(self, value: Angle) -> float:
    """
    Return the decimal degrees from the coordinate input as an Angle object.

    Args:
        value: The value of the angle input.

    Returns:
        The angle returned as an Angle object.
    """
    return Angle(value).deg

to_url(value)

Return the string format of an Angle object from the coordinate input.

Parameters:

Name Type Description Default
value Angle

The value of the angle input.

required

Returns:

Type Description
str

The string representation of the Angle object created from the input.

Source code in vast_pipeline/converters.py
86
87
88
89
90
91
92
93
94
95
96
def to_url(self, value: Angle) -> str:
    """
    Return the string format of an Angle object from the coordinate input.

    Args:
        value: The value of the angle input.

    Returns:
        The string representation of the Angle object created from the input.
    """
    return value.to_string()

DeclinationConverter

Accept both decimal and sexigesimal representations of Dec and ensure the returned value is a float in decimal degrees. The input units are always assumed to be degrees.

Source code in vast_pipeline/converters.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class DeclinationConverter:
    """Accept both decimal and sexigesimal representations of Dec and ensure the returned
    value is a float in decimal degrees. The input units are always assumed to be degrees."""
    regex = r"(?:\+|-)?(?:\d{1,2}:\d{1,2}:\d{1,2}(?:\.\d+)?|\d+(?:\.\d+)?)"

    def to_python(self, value: str) -> float:
        """
        Return the decimal degrees from the coordinate input as a python float
        object.

        Args:
            value: The value of the declination input.

        Returns:
            The decimal degrees value.
        """
        return Latitude(value, unit="deg").deg

    def to_url(self, value: str) -> str:
        """
        Return the decimal degrees from the coordinate input in a URL format.

        Args:
            value: The value of the declination input.

        Returns:
            The decimal degrees value as a string.
        """
        return value.to_string(unit="deg", decimal=True)

to_python(value)

Return the decimal degrees from the coordinate input as a python float object.

Parameters:

Name Type Description Default
value str

The value of the declination input.

required

Returns:

Type Description
float

The decimal degrees value.

Source code in vast_pipeline/converters.py
42
43
44
45
46
47
48
49
50
51
52
53
def to_python(self, value: str) -> float:
    """
    Return the decimal degrees from the coordinate input as a python float
    object.

    Args:
        value: The value of the declination input.

    Returns:
        The decimal degrees value.
    """
    return Latitude(value, unit="deg").deg

to_url(value)

Return the decimal degrees from the coordinate input in a URL format.

Parameters:

Name Type Description Default
value str

The value of the declination input.

required

Returns:

Type Description
str

The decimal degrees value as a string.

Source code in vast_pipeline/converters.py
55
56
57
58
59
60
61
62
63
64
65
def to_url(self, value: str) -> str:
    """
    Return the decimal degrees from the coordinate input in a URL format.

    Args:
        value: The value of the declination input.

    Returns:
        The decimal degrees value as a string.
    """
    return value.to_string(unit="deg", decimal=True)

RightAscensionConverter

Accept both decimal and sexigesimal representations of RA and ensure the returned value is a float in decimal degrees. If the input is in sexigesimal format, assume it is in units of hourangle.

Source code in vast_pipeline/converters.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class RightAscensionConverter:
    """Accept both decimal and sexigesimal representations of RA and ensure the returned
    value is a float in decimal degrees. If the input is in sexigesimal format, assume
    it is in units of hourangle."""
    regex = r"(?:\d+(?:\.\d+)?|\d{1,2}:\d{1,2}:\d{1,2}(?:\.\d+)?)"

    def to_python(self, value: str) -> float:
        """
        Return the decimal degrees from the coordinate input as a python float
        object.

        Args:
            value: The value of the RA input.

        Returns:
            The decimal degrees value.
        """
        unit = "hourangle" if ":" in value else "deg"
        return Longitude(value, unit=unit).deg

    def to_url(self, value: str) -> str:
        """
        Return the decimal degrees from the coordinate input in a URL format.

        Args:
            value: The value of the RA input.

        Returns:
            The decimal degrees value as a string.
        """
        return value.to_string(unit="deg", decimal=True)

to_python(value)

Return the decimal degrees from the coordinate input as a python float object.

Parameters:

Name Type Description Default
value str

The value of the RA input.

required

Returns:

Type Description
float

The decimal degrees value.

Source code in vast_pipeline/converters.py
10
11
12
13
14
15
16
17
18
19
20
21
22
def to_python(self, value: str) -> float:
    """
    Return the decimal degrees from the coordinate input as a python float
    object.

    Args:
        value: The value of the RA input.

    Returns:
        The decimal degrees value.
    """
    unit = "hourangle" if ":" in value else "deg"
    return Longitude(value, unit=unit).deg

to_url(value)

Return the decimal degrees from the coordinate input in a URL format.

Parameters:

Name Type Description Default
value str

The value of the RA input.

required

Returns:

Type Description
str

The decimal degrees value as a string.

Source code in vast_pipeline/converters.py
24
25
26
27
28
29
30
31
32
33
34
def to_url(self, value: str) -> str:
    """
    Return the decimal degrees from the coordinate input in a URL format.

    Args:
        value: The value of the RA input.

    Returns:
        The decimal degrees value as a string.
    """
    return value.to_string(unit="deg", decimal=True)