Catalogs Data#

astropop offers an easy-to-use interface for working with sources catalogs, primarily for handling astrometric RA and Dec coordinates and photometric magnitudes, as well as cross-matching between catalogs. It can either work with offline data or access online catalogs through the astroquery package. However, it is not as comprehensive as astroquery and is intended to provide a straightforward and consistent way to interact with (RA, Dec) catalogs of sources, with limited capabilities by design.

The main class for this work is SourcesCatalog, which serves as a wrapper for SkyCoord, adding information such as source IDs and magnitudes. However, it is not derived from SkyCoord, so not all SkyCoord methods can be used on a SourcesCatalog object.

Manual (Offline) Catalog#

The SourcesCatalog class is created by providing almost the same arguments as SkyCoord, along with a list of source names and a dictionary of magnitudes. The code extracts the ids, mag, and query_table arguments and passes the rest to SkyCoord. However, it’s recommended to use ra and dec compatible arguments as described in the SourcesCatalog API to avoid issues with data access and cross-matching.

If you want to create a basic astrometric catalog without photometric data, simply pass a list of object ids and the appropriate astrometric information, as shown in the example provided.

In [1]: from astropop.catalogs import SourcesCatalog

In [2]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ...:                      dec=[4, 5, 6], unit='deg')
   ...: 

In [3]: cat.table()
Out[3]: 
<Table length=3>
 id     ra     dec  
       deg     deg  
str1 float64 float64
---- ------- -------
   a     1.0     4.0
   b     2.0     5.0
   c     3.0     6.0

For the additional magnitudes, a dictionary must be passed, with one list of magnitudes for each filter. The dictionary keys are the filter names, and the values are the corresponding lists of magnitudes. The example below shows how to create a catalog with three filters, 'g', 'r', and 'i'. These lists can be plain values for magnitudes without errors, or QFloat objects for magnitudes with errors. If errors are present, they will be extracted and stored in the *_error columns. If no errors are present, the *_error columns will be filled with zeros.

In [4]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ...:                      dec=[4, 5, 6], unit='deg',
   ...:                      mag={'g': [1, 2, 3],
   ...:                           'r': [4, 5, 6],
   ...:                           'i': [7, 8, 9]})
   ...: 

In [5]: cat.table()
Out[5]: 
<Table length=3>
 id     ra     dec      g    g_error    r    r_error    i    i_error
       deg     deg                                                  
str1 float64 float64 float64 float64 float64 float64 float64 float64
---- ------- ------- ------- ------- ------- ------- ------- -------
   a     1.0     4.0     1.0     0.0     4.0     0.0     7.0     0.0
   b     2.0     5.0     2.0     0.0     5.0     0.0     8.0     0.0
   c     3.0     6.0     3.0     0.0     6.0     0.0     9.0     0.0
In [6]: from astropop.math import QFloat

In [7]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ...:                      dec=[4, 5, 6], unit='deg',
   ...:                      mag={'g': QFloat([1, 2, 3], [0.1, 0.2, 0.3]),
   ...:                           'r': QFloat([4, 5, 6], [0.4, 0.5, 0.6]),
   ...:                           'i': QFloat([7, 8, 9], [0.7, 0.8, 0.9])})
   ...: 

In [8]: cat.table()
Out[8]: 
<Table length=3>
 id     ra     dec      g    g_error    r    r_error    i    i_error
       deg     deg                                                  
str1 float64 float64 float64 float64 float64 float64 float64 float64
---- ------- ------- ------- ------- ------- ------- ------- -------
   a     1.0     4.0     1.0     0.1     4.0     0.4     7.0     0.7
   b     2.0     5.0     2.0     0.2     5.0     0.5     8.0     0.8
   c     3.0     6.0     3.0     0.3     6.0     0.6     9.0     0.9

An optional table with additional informations can be passed as query_table argument. This table will be accessed only by query_table property and will also be filtered for cross-matching. However, it cannot be used for automatic extraction the default SourcesCatalog data.

In [9]: from astropy.table import Table

In [10]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ....:                      dec=[4, 5, 6], unit='deg',
   ....:                      query_table=Table({'id': ['a', 'b', 'c'],
   ....:                                         'z': [1, 2, 3]}))
   ....: 

In [11]: cat.table()
Out[11]: 
<Table length=3>
 id     ra     dec  
       deg     deg  
str1 float64 float64
---- ------- -------
   a     1.0     4.0
   b     2.0     5.0
   c     3.0     6.0

In [12]: cat.query_table
Out[12]: 
<Table length=3>
 id    z  
str1 int64
---- -----
   a     1
   b     2
   c     3

Properties Accessing#

The SourcesCatalog class provides several functions to get the data stored in the catalog. No setter function is present, to protect the catalog internally. So SourcesCatalog are inteded to be read-only objects.

Coordinates#

Coordinates can be accessed using the skycoord, ra_dec_list and get_coordinates functions. The difference is that in the first a SkyCoord object is returned, while in the second a list of tuples is returned. The last function is useful to get coordinates in SkyCoord format with space motion applied.

In [13]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ....:                      dec=[4, 5, 6], unit='deg')
   ....: 

In [14]: cat.skycoord()
Out[14]: 
<SkyCoord (ICRS): (ra, dec) in deg
    [(1., 4.), (2., 5.), (3., 6.)]>

In [15]: cat.ra_dec_list()
Out[15]: 
array([[1., 4.],
       [2., 5.],
       [3., 6.]])

In [16]: cat.get_coordinates()
Out[16]: 
<SkyCoord (ICRS): (ra, dec) in deg
    [(1., 4.), (2., 5.), (3., 6.)]>

You can also access separated arrays for RA and Dec coordinates using the ra and dec properties.

In [17]: cat.ra()
Out[17]: array([1., 2., 3.])

In [18]: cat.dec()
Out[18]: array([4., 5., 6.])

Soures IDs#

Sources IDs can be accessed using the sources_id property.

In [19]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ....:                      dec=[4, 5, 6], unit='deg')
   ....: 

In [20]: cat.sources_id()
Out[20]: array(['a', 'b', 'c'], dtype='<U1')

Magnitudes#

Magnitudes can be either accessed using magnitude or mag_list functions. For both of them, the band argument must be passed to access the magnitudes in a given filter. The difference is that the first function returns a QFloat object, while the second returns a list of tuples containing (magnitude, error). If the band argument is not passed, an error is raised. Also, the filter must be available in the catalog.

In [21]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ....:                      dec=[4, 5, 6], unit='deg',
   ....:                      mag={'g': [1, 2, 3],
   ....:                           'r': [4, 5, 6],
   ....:                           'i': [7, 8, 9]})
   ....: 

In [22]: cat.magnitude('g')
Out[22]: 
<QFloat at 0x7f6264f3fed0>
[1.0+-0.0, 2.0+-0.0, 3.0+-0.0] unit=mag

In [23]: cat.mag_list('g')
Out[23]: 
array([[1., 0.],
       [2., 0.],
       [3., 0.]])

Summary Table#

A summary table of the catalog can by obtained via table function. This table contains the sources IDs, coordinates, proper motion (if available) and magnitudes (if available). No additional information is included. See the examples present in Manual (Offline) Catalog section.

Object Matching#

To identify a list of sources in a SourcesCatalog, you can use the match_objects method. In this method, lists of ra and dec coordinates are passed and the catalog will find the closest sources within a limit_angle radius around them. A new SourcesCatalog instance is returned, containing only the matched sources in the exact order of the ra and dec lists passed to the method. To handle high proper motion, obstime argument can also be passed, but only is applied when proper motion is available in the catalog.

In [24]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ....:                      dec=[4, 5, 6], unit='deg')
   ....: 

In [25]: matched = cat.match_objects([1, 3], [4, 6], limit_angle='1 arcmin')

In [26]: matched.table()
Out[26]: 
<Table length=2>
 id     ra     dec  
       deg     deg  
str1 float64 float64
---- ------- -------
   a     1.0     4.0
   c     3.0     6.0

Magnitudes and additional query_table informations are also filtered and returned in the exact same order of the ra and dec lists passed to the method.

In [27]: cat = SourcesCatalog(ids=['a', 'b', 'c'], ra=[1, 2, 3],
   ....:                      dec=[4, 5, 6], unit='deg',
   ....:                      mag={'g': [1, 2, 3],
   ....:                           'r': [4, 5, 6],
   ....:                           'i': [7, 8, 9]},
   ....:                      query_table=Table({'id': ['a', 'b', 'c'],
   ....:                                         'z': [1, 2, 3]}))
   ....: 

In [28]: matched = cat.match_objects([1, 3], [4, 6], limit_angle='1 arcmin')

In [29]: matched.table()
Out[29]: 
<Table length=2>
 id     ra     dec      g    g_error    r    r_error    i    i_error
       deg     deg                                                  
str1 float64 float64 float64 float64 float64 float64 float64 float64
---- ------- ------- ------- ------- ------- ------- ------- -------
   a     1.0     4.0     1.0     0.0     4.0     0.0     7.0     0.0
   c     3.0     6.0     3.0     0.0     6.0     0.0     9.0     0.0

In [30]: matched.query_table
Out[30]: 
<Table length=2>
 id    z  
str1 int64
---- -----
   a     1
   c     3

Online Catalogs#

The astroquery package allows for querying online catalogs, but the astropop package offers a more user-friendly interface through the catalogs module. As the queries from astroquery is not exactly homogeneous and some manual work must be done some times, we offer specialized classes for pre-defined catalogs. See the following descriptions for more information.

astropop.catalogs Package#

Catalog managing and query.

Classes#

SourcesCatalog(*args[, ids, mag, query_table])

Manage and query a catalog of point sources objects.