Skip to content

moc.py

Simple class to interface and load the VAST MOCS.

Attributes:

Name Type Description
BASE_MOC_PATH str

The base MOC path (str) in relation to the package.

VASTMOCS

Bases: object

Class to interface with VAST MOC files included in the package.

Source code in vasttools/moc.py
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 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
 66
 67
 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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
class VASTMOCS(object):
    """
    Class to interface with VAST MOC files included in the package.
    """

    def __init__(self) -> None:
        '''
        Constructor method.

        Returns:
            None
        '''
        super(VASTMOCS, self).__init__()

    def load_pilot_stmoc(self) -> STMOC:
        """
        Load space and time MOC of all VAST Pilot observations.

        Returns:
            STMOC of the VAST Pilot survey. A `mocpy.STMOC` object.
        """
        stmoc_name = 'VAST_PILOT.stmoc.fits'

        with importlib.resources.path(
            "vasttools.data.mocs",
            stmoc_name
        ) as stmoc_path:
            stmoc_path = stmoc_path.resolve()
            print(stmoc_path)

        stmoc = STMOC.from_fits(stmoc_path)

        return stmoc

    def load_pilot_epoch_moc(self, epoch: str = '1') -> MOC:
        """
        Load MOC corresponding to one epoch of the pilot survey.

        Args:
            epoch: Epoch to load as a string with no zero padding.
                E.g. '3x'.

        Returns:
            MOC of the requested epoch. A `mocpy.MOC` object.

        Raises:
            Exception: Entered epoch is not recognised.
        """

        if epoch not in RELEASED_EPOCHS:
            raise Exception(
                "EPOCH {} not recognised".format(epoch)
            )

        epoch_str = RELEASED_EPOCHS[epoch]

        moc_name = 'VAST_PILOT_EPOCH{}.moc.fits'.format(epoch_str)

        with importlib.resources.path(
            "vasttools.data.mocs",
            moc_name
        ) as moc_path:
            moc_path = moc_path.resolve()

        moc = MOC.from_fits(moc_path)

        return moc

    def load_pilot_field_moc(self, field: Union[str, int]) -> MOC:
        """
        Load MOCs corresponding to the VAST Pilot 'field', which is a
        collection of tiles.

        Enter as a string ranging from fields 1 – 6.

        Args:
            field: Name of the VAST Pilot field requested.

        Returns:
            The field MOC. A `mocpy.MOC` object.

        Raises:
            Exception: VAST Pilot field is not valid (1 - 6).
        """
        # While this could be an int it's left as string to be consistent
        # with the other loads.
        fields = ['1', '2', '3', '4', '5', '6']

        if isinstance(field, int):
            field = str(field)

        if field not in fields:
            raise ValueError(
                f"VAST Pilot field #{field} is not valid - valid fields"
                " are numbered {}.".format(", ".join(fields))
            )

        moc_name = f'VAST_PILOT_FIELD_{field}.fits'

        with importlib.resources.path(
            "vasttools.data.mocs",
            moc_name
        ) as moc_path:
            moc_path = moc_path.resolve()

        moc = MOC.from_fits(moc_path)

        return moc

    def load_pilot_tile_moc(self, field: str, itype: str = 'COMBINED') -> MOC:
        """
        Load the MOC corresponding to the requested pilot tile field.

        Args:
            field: The name of field requested. For example, 'VAST_0012-06A'.
            itype: Image type (COMBINED or TILES), defaults to 'COMBINED'.

        Returns:
            Tile MOC. A `mocpy.MOC` object.

        Raises:
            Exception: Entered image type is not recognised
                ('COMBINED' or 'TILES').
            Exception: Entered field is not found.
        """
        types = ["COMBINED", "TILES"]

        itype = itype.upper()

        if itype not in types:
            raise Exception(
                "Image type not recognised. Valid entries are:"
                " {}.".format(", ".join(types))
            )

        field_centres = load_field_centres()
        field_list = field_centres['field'].to_numpy()
        if field not in field_list:
            field_stripped = field.rstrip('A')
            if field_stripped not in field_list:
                raise Exception(
                    "Field {} not recognised".format(field)
                )

        if not field.endswith('A'):
            field = f'{field}A'
        moc_name = f'{field}.EPOCH01.I.moc.fits'

        with importlib.resources.path(
            f"vasttools.data.mocs.{itype}",
            moc_name
        ) as moc_path:
            moc_path = moc_path.resolve()

        moc = MOC.from_fits(moc_path)

        return moc

    def _load_pilot_footprint(self, order: int = 10) -> MOC:
        """
        Load the complete footprint of the pilot survey

        Args:
            order: MOC order to use (10 corresponds to a spatial res of 3.5')

        Returns:
            MOC containing the pilot survey footprint
        """
        # There are 6 unique 'fields' in the pilot survey hence these are looped over in turn to load
        for i in range(5):
            moc = self.load_pilot_field_moc(i + 1)
            if i == 0:
                pilot_moc = moc
            else:
                pilot_moc = pilot_moc.union(moc)

        return pilot_moc.degrade_to_order(order)

    def _load_full_survey_footprint(self, order: int = 10) -> MOC:
        """
        Load the complete footprint of the full survey

        Args:
            order: MOC order to use (10 corresponds to a spatial res of 3.5')

        Returns:
            MOC containing the full survey footprint
        """

        for i, subsurvey in enumerate(['EQUATORIAL', 'HIGHDEC', 'GALACTIC']):
            moc_name = f'VAST_{subsurvey}.moc.fits'

            with importlib.resources.path(
                "vasttools.data.mocs",
                moc_name
            ) as moc_path:
                moc_path = moc_path.resolve()

            moc = MOC.from_fits(moc_path)

            if i == 0:
                survey_moc = moc
            else:
                survey_moc = survey_moc.union(moc)

        return survey_moc.degrade_to_order(order)

    def load_survey_footprint(self, survey: str, order: int = 10) -> MOC:
        """
        Load the footprint of either the pilot or full VAST surveys

        Args:
            survey: Survey requested (can be "pilot or "full")
            order: MOC order to use (10 corresponds to a spatial res of 3.5')

        Returns:
            Survey footprint in MOC format
        """

        if survey not in ['pilot', 'full']:
            raise Exception(
                f"Survey must be either 'pilot' or 'full', not {survey}"
            )
        if survey == 'pilot':
            return self._load_pilot_footprint(order=order)
        elif survey == 'full':
            return self._load_full_survey_footprint(order=order)

    def query_vizier_vast_pilot(
        self,
        table_id: str,
        max_rows: int = 10000
    ) -> Table:
        """
        Query the Vizier service for sources within Pilot footprint.

        Args:
            table_id: Vizier ID of table to query.
            max_rows: Maximum rows to return, defaults to 10000.

        Returns:
            Astropy table of Vizier results.
        """

        moc = self.load_pilot_epoch_moc('1')

        viz_table = moc.query_vizier_table(table_id, max_rows=max_rows)

        return viz_table

__init__()

Constructor method.

Returns:

Type Description
None

None

Source code in vasttools/moc.py
22
23
24
25
26
27
28
29
def __init__(self) -> None:
    '''
    Constructor method.

    Returns:
        None
    '''
    super(VASTMOCS, self).__init__()

load_pilot_epoch_moc(epoch='1')

Load MOC corresponding to one epoch of the pilot survey.

Parameters:

Name Type Description Default
epoch str

Epoch to load as a string with no zero padding. E.g. '3x'.

'1'

Returns:

Type Description
MOC

MOC of the requested epoch. A mocpy.MOC object.

Raises:

Type Description
Exception

Entered epoch is not recognised.

Source code in vasttools/moc.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def load_pilot_epoch_moc(self, epoch: str = '1') -> MOC:
    """
    Load MOC corresponding to one epoch of the pilot survey.

    Args:
        epoch: Epoch to load as a string with no zero padding.
            E.g. '3x'.

    Returns:
        MOC of the requested epoch. A `mocpy.MOC` object.

    Raises:
        Exception: Entered epoch is not recognised.
    """

    if epoch not in RELEASED_EPOCHS:
        raise Exception(
            "EPOCH {} not recognised".format(epoch)
        )

    epoch_str = RELEASED_EPOCHS[epoch]

    moc_name = 'VAST_PILOT_EPOCH{}.moc.fits'.format(epoch_str)

    with importlib.resources.path(
        "vasttools.data.mocs",
        moc_name
    ) as moc_path:
        moc_path = moc_path.resolve()

    moc = MOC.from_fits(moc_path)

    return moc

load_pilot_field_moc(field)

Load MOCs corresponding to the VAST Pilot 'field', which is a collection of tiles.

Enter as a string ranging from fields 1 – 6.

Parameters:

Name Type Description Default
field Union[str, int]

Name of the VAST Pilot field requested.

required

Returns:

Type Description
MOC

The field MOC. A mocpy.MOC object.

Raises:

Type Description
Exception

VAST Pilot field is not valid (1 - 6).

Source code in vasttools/moc.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
def load_pilot_field_moc(self, field: Union[str, int]) -> MOC:
    """
    Load MOCs corresponding to the VAST Pilot 'field', which is a
    collection of tiles.

    Enter as a string ranging from fields 1 – 6.

    Args:
        field: Name of the VAST Pilot field requested.

    Returns:
        The field MOC. A `mocpy.MOC` object.

    Raises:
        Exception: VAST Pilot field is not valid (1 - 6).
    """
    # While this could be an int it's left as string to be consistent
    # with the other loads.
    fields = ['1', '2', '3', '4', '5', '6']

    if isinstance(field, int):
        field = str(field)

    if field not in fields:
        raise ValueError(
            f"VAST Pilot field #{field} is not valid - valid fields"
            " are numbered {}.".format(", ".join(fields))
        )

    moc_name = f'VAST_PILOT_FIELD_{field}.fits'

    with importlib.resources.path(
        "vasttools.data.mocs",
        moc_name
    ) as moc_path:
        moc_path = moc_path.resolve()

    moc = MOC.from_fits(moc_path)

    return moc

load_pilot_stmoc()

Load space and time MOC of all VAST Pilot observations.

Returns:

Type Description
STMOC

STMOC of the VAST Pilot survey. A mocpy.STMOC object.

Source code in vasttools/moc.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def load_pilot_stmoc(self) -> STMOC:
    """
    Load space and time MOC of all VAST Pilot observations.

    Returns:
        STMOC of the VAST Pilot survey. A `mocpy.STMOC` object.
    """
    stmoc_name = 'VAST_PILOT.stmoc.fits'

    with importlib.resources.path(
        "vasttools.data.mocs",
        stmoc_name
    ) as stmoc_path:
        stmoc_path = stmoc_path.resolve()
        print(stmoc_path)

    stmoc = STMOC.from_fits(stmoc_path)

    return stmoc

load_pilot_tile_moc(field, itype='COMBINED')

Load the MOC corresponding to the requested pilot tile field.

Parameters:

Name Type Description Default
field str

The name of field requested. For example, 'VAST_0012-06A'.

required
itype str

Image type (COMBINED or TILES), defaults to 'COMBINED'.

'COMBINED'

Returns:

Type Description
MOC

Tile MOC. A mocpy.MOC object.

Raises:

Type Description
Exception

Entered image type is not recognised ('COMBINED' or 'TILES').

Exception

Entered field is not found.

Source code in vasttools/moc.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
def load_pilot_tile_moc(self, field: str, itype: str = 'COMBINED') -> MOC:
    """
    Load the MOC corresponding to the requested pilot tile field.

    Args:
        field: The name of field requested. For example, 'VAST_0012-06A'.
        itype: Image type (COMBINED or TILES), defaults to 'COMBINED'.

    Returns:
        Tile MOC. A `mocpy.MOC` object.

    Raises:
        Exception: Entered image type is not recognised
            ('COMBINED' or 'TILES').
        Exception: Entered field is not found.
    """
    types = ["COMBINED", "TILES"]

    itype = itype.upper()

    if itype not in types:
        raise Exception(
            "Image type not recognised. Valid entries are:"
            " {}.".format(", ".join(types))
        )

    field_centres = load_field_centres()
    field_list = field_centres['field'].to_numpy()
    if field not in field_list:
        field_stripped = field.rstrip('A')
        if field_stripped not in field_list:
            raise Exception(
                "Field {} not recognised".format(field)
            )

    if not field.endswith('A'):
        field = f'{field}A'
    moc_name = f'{field}.EPOCH01.I.moc.fits'

    with importlib.resources.path(
        f"vasttools.data.mocs.{itype}",
        moc_name
    ) as moc_path:
        moc_path = moc_path.resolve()

    moc = MOC.from_fits(moc_path)

    return moc

load_survey_footprint(survey, order=10)

Load the footprint of either the pilot or full VAST surveys

Parameters:

Name Type Description Default
survey str

Survey requested (can be "pilot or "full")

required
order int

MOC order to use (10 corresponds to a spatial res of 3.5')

10

Returns:

Type Description
MOC

Survey footprint in MOC format

Source code in vasttools/moc.py
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
def load_survey_footprint(self, survey: str, order: int = 10) -> MOC:
    """
    Load the footprint of either the pilot or full VAST surveys

    Args:
        survey: Survey requested (can be "pilot or "full")
        order: MOC order to use (10 corresponds to a spatial res of 3.5')

    Returns:
        Survey footprint in MOC format
    """

    if survey not in ['pilot', 'full']:
        raise Exception(
            f"Survey must be either 'pilot' or 'full', not {survey}"
        )
    if survey == 'pilot':
        return self._load_pilot_footprint(order=order)
    elif survey == 'full':
        return self._load_full_survey_footprint(order=order)

query_vizier_vast_pilot(table_id, max_rows=10000)

Query the Vizier service for sources within Pilot footprint.

Parameters:

Name Type Description Default
table_id str

Vizier ID of table to query.

required
max_rows int

Maximum rows to return, defaults to 10000.

10000

Returns:

Type Description
Table

Astropy table of Vizier results.

Source code in vasttools/moc.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
def query_vizier_vast_pilot(
    self,
    table_id: str,
    max_rows: int = 10000
) -> Table:
    """
    Query the Vizier service for sources within Pilot footprint.

    Args:
        table_id: Vizier ID of table to query.
        max_rows: Maximum rows to return, defaults to 10000.

    Returns:
        Astropy table of Vizier results.
    """

    moc = self.load_pilot_epoch_moc('1')

    viz_table = moc.query_vizier_table(table_id, max_rows=max_rows)

    return viz_table