Catalog

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

Bases: Table

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

Initialize a Catalog instance

Parameters:
idnamestr, optional

Table column name containing object IDs

ranamestr, optional

Table column name containing object RA coords

decnamestr, optional

Table column name containing object DEC coords

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

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.

hstack(cat2, **kwargs)

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

join(cat2, **kwargs)

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

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 another (in RA, DEC).

match3Dline(cat2, linecolc1, linecolc2[, ...])

3D Match elements of the current catalog with another 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_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=None, dec=None)[source]

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

Parameters:
wcsWCS

Image WCS

rastr

Name of the column that contains RA values in degrees

decstr

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:
pathstr

Directory containing Source files

fmtstr ‘working’|’default’

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

patternstr

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:
sourceslist< mpdaf.sdetect.Source >

List of mpdaf.sdetect.Source objects

fmtstr ‘working’|’default’

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

hstack(cat2, **kwargs)[source]

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

Parameters:
cat2astropy.table.Table

Catalog to stack with.

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

New catalog containing the stacked data

join(cat2, **kwargs)[source]

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

Parameters:
cat2astropy.table.Table

Right catalog to join with.

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

New table containing the result of the join operation.

masked_invalid()[source]

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

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

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

Parameters:
cat2astropy.table.Table

Catalog to match.

radiusfloat

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:
outastropy.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=(None, None), colc2=(None, None), **kwargs)[source]

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

Parameters:
cat2astropy.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_radiusfloat

Matching radius size in arcsec (default 1).

spectral_windowfloat (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:
outastropy.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=(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(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, tcol='k', ledgecol=None, lfacecol=None, npolygon=3, extent=None, **kwargs)[source]

This function plots the sources location from the catalog.

Parameters:
axmatplotlib.axes.Axes

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

wcsmpdaf.obj.WCS

Image WCS.

label: bool

If True catalog ID are displayed.

esizefloat

symbol size in arcsec if extent=None (used only if lsize is not set). if extent is not None, the size unit is in the extent referential

lsizestr

Column name containing the size in arcsec.

etypestr

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

ltypestr

Name of column that contain the symbol to use.

rastr

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

decstr

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

idstr

Name of the column that contains ID.

lcol: str

Name of the column that contains Color.

ecolstr

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

tcol: str

Text label color

alphafloat

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.

npolygon: int

Number of polygone to use with etype=’p

extent: list of float

[x1,y1,x2,y2] axis limits used with image.plot(extent=extent), default None (use spaxels)

**kwargs

kwargs can be used to set additional plotting properties.

select(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:
wcsWCS

Image WCS

rastr

Name of the column that contains RA values in degrees.

decstr

Name of the column that contains DEC values in degrees.

marginint

Margin from the edges (pixels).

maskarray_like

Mask used to filter sources (1 to mask).

Returns:
mpdaf.sdetect.Catalog

The catalog with selected rows.

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

Return an astropy.coordinates.SkyCoord object.

to_skycoord(ra=None, dec=None, 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).