Catalog

class mpdaf.sdetect.Catalog(*args, **kwargs)[source]

Bases: astropy.table.Table

This class inherits from astropy.table.Table. Its goal is to manage a list of objects.

Initialize a Catalog instance

Parameters:
idname : str, optional

Table column name containing object IDs

raname : str, optional

Table column name containing object RA coords

decname : str, optional

Table column name containing object DEC coords

Remaining args and kwargs are passed to `astropy.table.Table.__init__`.

Methods Summary

edgedist(self, wcs[, ra, dec]) Return the smallest distance of all catalog sources center to the edge of the WCS of the given image.
from_path(path[, fmt, pattern]) Construct a catalog from a list of source objects which are contains in the directory given as input.
from_sources(sources[, fmt]) Construct a catalog from a list of source objects.
hstack(self, cat2, \*\*kwargs) Peforms an astropy.table.hstack with another catalog, but also handles the metadata correctly.
join(self, cat2, \*\*kwargs) Peforms an astropy.table.join with another catalog, but also handles the metadata correctly.
masked_invalid(self) Mask where invalid values occur (NaNs or infs or -9999 or ‘’).
match(self, cat2[, radius, colc1, colc2, …]) Match elements of the current catalog with an other (in RA, DEC).
match3Dline(self, cat2, linecolc1, linecolc2) 3D Match elements of the current catalog with an other using spatial (RA, DEC) and list of spectral lines location.
nearest(self, coord[, colcoord, ksel, maxdist]) Return the nearest sources with respect to the given coordinate.
plot_symb(self, ax, wcs[, label, esize, …]) This function plots the sources location from the catalog.
select(self, wcs[, ra, dec, margin, mask]) Select all sources from catalog which are inside the given WCS and return a new catalog.
to_ds9_regions(self, outfile[, ra, dec, …]) Return an astropy.coordinates.SkyCoord object.
to_skycoord(self[, ra, dec, frame, unit]) Return an astropy.coordinates.SkyCoord object.
write(self, \*args, \*\*kwargs) Write this Table object out in the specified format.

Methods Documentation

edgedist(self, wcs, ra=None, dec=None)[source]

Return the smallest distance of all catalog sources center to the edge of the WCS of the given image.

Parameters:
wcs : WCS

Image WCS

ra : str

Name of the column that contains RA values in degrees

dec : str

Name of the column that contains DEC values in degrees

Returns:
numpy.ndarray

The distance in arcsec units.

classmethod from_path(path, fmt='default', pattern='*.fits')[source]

Construct a catalog from a list of source objects which are contains in the directory given as input.

The new catalog will contain all data stored in the primary headers and in the tables extensions of the sources:

  • a column per header fits (‘SIMPLE’, ‘BITPIX’, ‘NAXIS’, ‘EXTEND’, ‘DATE’, ‘AUTHOR’, ‘COM*’ and ‘HIST*’ are excluded)
  • two columns per magnitude band: [BAND] [BAND]_ERR
  • three columns per redshift Z_[Z_DESC], Z_[Z_DESC]_MIN and Z_[Z_DESC]_MAX
  • several columns per line.

The lines columns depend of the format. By default the columns names are created around unique LINE name [LINE]_[LINES columns names]. But it is possible to use a working format. [LINES columns names]_xxx where xxx is the number of lines present in each source.

Parameters:
path : str

Directory containing Source files

fmt : str ‘working’|’default’

Format of the catalog. The format differs for the LINES table.

pattern : str

Pattern used to select the files, default to *.fits.

classmethod from_sources(sources, fmt='default')[source]

Construct a catalog from a list of source objects.

The new catalog will contain all data stored in the primary headers and in the tables extensions of the sources:

  • a column per header fits (‘SIMPLE’, ‘BITPIX’, ‘NAXIS’, ‘EXTEND’, ‘DATE’, ‘AUTHOR’, ‘COM*’ and ‘HIST*’ are excluded)
  • two columns per magnitude band: [BAND] [BAND]_ERR
  • three columns per redshift Z_[Z_DESC], Z_[Z_DESC]_MIN and Z_[Z_DESC]_MAX
  • several columns per line.

The lines columns depend of the format. By default the columns names are created around unique LINE name [LINE]_[LINES columns names]. But it is possible to use a working format. [LINES columns names]_xxx where xxx is the number of lines present in each source.

Parameters:
sources : list< mpdaf.sdetect.Source >

List of mpdaf.sdetect.Source objects

fmt : str ‘working’|’default’

Format of the catalog. The format differs for the LINES table.

hstack(self, cat2, **kwargs)[source]

Peforms an astropy.table.hstack with another catalog, but also handles the metadata correctly.

Parameters:
cat2 : astropy.table.Table

Catalog to stack with.

Remaining args and kwargs are passed to `astropy.table.hstack`, excecpt
metadata_conflicts.
Returns:
stacked : Catalog object

New catalog containing the stacked data

join(self, cat2, **kwargs)[source]

Peforms an astropy.table.join with another catalog, but also handles the metadata correctly.

Parameters:
cat2 : astropy.table.Table

Right catalog to join with.

Remaining args and kwargs are passed to `astropy.table.join`, excecpt
metadata_conflicts.
Returns:
joined : Table object

New table containing the result of the join operation.

masked_invalid(self)[source]

Mask where invalid values occur (NaNs or infs or -9999 or ‘’).

match(self, cat2, radius=1, colc1=(None, None), colc2=(None, None), full_output=True, **kwargs)[source]

Match elements of the current catalog with an other (in RA, DEC).

Parameters:
cat2 : astropy.table.Table

Catalog to match.

radius : float

Matching size in arcsec (default 1).

colc1: tuple

Name of ra,dec columns in input table.

colc2: tuple

Name of ra,dec columns in cat2.

full_output: bool

output flag

**kwargs

Other arguments are passed to astropy.coordinates.match_coordinates_sky.

Returns:
out : astropy.Table, astropy.Table, astropy.Table

If full_output is True, return a tuple (match, nomatch1, nomatch2) where:

  • match: table of matched elements in RA,DEC.
  • nomatch1: sub-table of non matched elements of the current catalog.
  • nomatch2: sub-table of non matched elements of the catalog cat2.

If full_output is False, only match is returned.

match3Dline(self, cat2, linecolc1, linecolc2, spatial_radius=1, spectral_window=5, suffix=('_1', '_2'), full_output=True, colc1=(None, None), colc2=(None, None), **kwargs)[source]

3D Match elements of the current catalog with an other using spatial (RA, DEC) and list of spectral lines location.

Parameters:
cat2 : astropy.table.Table

Catalog to match.

linecolc1: list of float

List of column names containing the wavelengths of the input catalog.

linecolc2: list of float

List of column names containing the wavelengths of the cat2.

spatial_radius : float

Matching radius size in arcsec (default 1).

spectral_window : float (default 5)

Matching wavelength window in spectral unit (default 5).

colc1: tuple

(‘RA’,’DEC’) name of ra,dec columns of input catalog.

colc2: tuple

(‘RA’,’DEC’) name of ra,dec columns of cat2.

full_output: bool

output flag

**kwargs

Other arguments are passed to astropy.coordinates.match_coordinates_sky.

Returns:
out : astropy.Table, astropy.Table, astropy.Table

If full_output is True, return a tuple (match3d, match2d, nomatch1, nomatch2) where:

  • match3d, match2d: table of matched elements in RA,DEC.
  • nomatch1: sub-table of non matched elements of the current catalog.
  • nomatch2: sub-table of non matched elements of the catalog cat2.

If full_output is False, only match is returned.

nearest(self, coord, colcoord=(None, None), ksel=1, maxdist=None, **kwargs)[source]

Return the nearest sources with respect to the given coordinate.

Parameters:
coord: tuple

ra,dec in decimal degree, or HH:MM:SS,DD:MM:SS

colcoord: tuple of str

column names of coordinate: default (‘RA’,’DEC’)

ksel: int

Number of sources to return, default 1 (if None return all sources sorted by distance)

maxdist: float

Maximum distance to source in arcsec, default None

**kwargs

Other arguments are passed to astropy.coordinates.match_coordinates_sky.

Returns:
astropy.table.Table

The corresponding catalog of matched sources with the additional Distance column (arcsec).

plot_symb(self, ax, wcs, label=False, esize=0.8, lsize=None, etype='o', ltype=None, ra=None, dec=None, id=None, ecol='k', lcol=None, alpha=1.0, fill=False, fontsize=8, expand=1.7, ledgecol=None, lfacecol=None, npolygon=3, **kwargs)[source]

This function plots the sources location from the catalog.

Parameters:
ax : matplotlib.axes.Axes

Matplotlib axis instance (eg ax = fig.add_subplot(2,3,1)).

wcs : mpdaf.obj.WCS

Image WCS.

label: bool

If True catalog ID are displayed.

esize : float

symbol size in arcsec (used only if lsize is not set).

lsize : str

Column name containing the size in arcsec.

etype : str

Type of symbol: o (circle, size=diameter), s (square, size=length), p (polygon, size=diameter) used only if ltype is not set.

ltype : str

Name of column that contain the symbol to use.

ra : str

Name of the column that contains RA values (in degrees).

dec : str

Name of the column that contains DEC values (in degrees).

id : str

Name of the column that contains ID.

lcol: str

Name of the column that contains Color.

ecol : str

Symbol color (only used if lcol is not set).

alpha : float

Symbol transparency.

fill: bool

If True filled symbol are used.

expand: float

Expand factor to write label.

ledgecol: str

Name of the column that contains the edge color.

lfacecol: str

Name of the column that contains the fqce color.

**kwargs

kwargs can be used to set additional plotting properties.

select(self, wcs, ra=None, dec=None, margin=0, mask=None)[source]

Select all sources from catalog which are inside the given WCS and return a new catalog.

Parameters:
wcs : WCS

Image WCS

ra : str

Name of the column that contains RA values in degrees.

dec : str

Name of the column that contains DEC values in degrees.

margin : int

Margin from the edges (pixels).

mask : array_like

Mask used to filter sources (1 to mask).

Returns:
mpdaf.sdetect.Catalog

The catalog with selected rows.

to_ds9_regions(self, outfile, ra=None, dec=None, radius=1, frame='fk5', unit_pos='deg', unit_radius='arcsec')[source]

Return an astropy.coordinates.SkyCoord object.

to_skycoord(self, ra=None, dec=None, frame='fk5', unit='deg')[source]

Return an astropy.coordinates.SkyCoord object.

write(self, *args, **kwargs)[source]

Write this Table object out in the specified format.

This function provides the Table interface to the astropy unified I/O layer. This allows easily writing a file in many supported data formats using syntax such as:

>>> from astropy.table import Table
>>> dat = Table([[1, 2], [3, 4]], names=('a', 'b'))
>>> dat.write('table.dat', format='ascii')  

The arguments and keywords (other than format) provided to this function are passed through to the underlying data reader (e.g. write).