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.

Methods Summary

edgedist(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.
masked_invalid() Mask where invalid values occur (NaNs or infs or -9999 or ‘’).
match(cat2[, radius, colc1, colc2, full_output]) Match elements of the current catalog with an other (in RA, DEC).
match3Dline(cat2, linecolc1, linecolc2[, …]) 3D Match elements of the current catalog with an other using spatial (RA, DEC) and list of spectral lines location.
nearest(coord[, colcoord, ksel, maxdist]) Return the nearest sources with respect to the given coordinate.
plot_id(**kwargs) This function displays the id of the catalog.
plot_symb(ax, wcs[, label, esize, lsize, …]) This function plots the sources location from the catalog.
select(wcs[, ra, dec, margin, mask]) Select all sources from catalog which are inside the given WCS and return a new catalog.
to_ds9_regions(outfile[, ra, dec, radius, …]) Return an astropy.coordinates.SkyCoord object.
to_skycoord([ra, dec, frame, unit]) Return an astropy.coordinates.SkyCoord object.
write(*args, **kwargs) Write this Table object out in the specified format.

Methods Documentation

edgedist(wcs, ra='RA', dec='DEC')[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.

masked_invalid()[source]

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

match(cat2, radius=1, colc1=('RA', 'DEC'), colc2=('RA', 'DEC'), 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

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

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 (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(cat2, linecolc1, linecolc2, spatial_radius=1, spectral_window=5, suffix=('_1', '_2'), full_output=True, colc1=('RA', 'DEC'), colc2=('RA', 'DEC'), **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

other arguments are passed to astropy match_to_catalog_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(coord, colcoord=('RA', 'DEC'), 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_id(**kwargs)[source]

This function displays the id of the catalog.

Parameters:

ax : matplotlib.axes.Axes

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

wcs : mpdaf.obj.WCS

Image WCS

iden : str

Name of the column that contains ID values

ra : str

Name of the column that contains RA values

dec : str

Name of the column that contains DEC values

symb : float

Size of the circle in arcsec

col : str

Symbol color.

alpha : float

Symbol transparency

ellipse_kwargs : dict

Additional properties for matplotlib.patches.Ellipse.

**kwargs

Additional properties for ax.text.

plot_symb(ax, wcs, label=False, esize=0.8, lsize=None, etype='o', ltype=None, ra='RA', dec='DEC', id='ID', ecol='k', lcol=None, alpha=1.0, fill=False, fontsize=8, expand=1.7, **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) 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.

**kwargs

kwargs can be used to set additional plotting properties.

select(wcs, ra='RA', dec='DEC', 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(outfile, ra='RA', dec='DEC', radius=1, frame='fk5', unit_pos='deg', unit_radius='arcsec')[source]

Return an astropy.coordinates.SkyCoord object.

to_skycoord(ra='RA', dec='DEC', frame='fk5', unit='deg')[source]

Return an astropy.coordinates.SkyCoord object.

write(*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).