GTable

class grizli.utils.GTable(data=None, masked=False, names=None, dtype=None, meta=None, copy=True, rows=None, copy_indices=True, units=None, descriptions=None, **kwargs)[source]

Bases: Table

Extend Table class with more automatic IO and other helper methods.

Methods Summary

add_aladdin([rd_cols, fov, size, default_view])

Add AladinLite DIV column to the table

gread(file[, sextractor, format])

Assume ascii.commented_header by default

gwrite(output[, format])

Assume a format for the output table

match_to_catalog_sky(other[, self_radec, ...])

Compute SkyCoord projected matches between two GTable tables.

match_triangles(other[, self_wcs, x_column, ...])

Match sources between two catalogs using triangles

parse_radec_columns(self[, rd_pairs])

Parse column names for RA/Dec and set to degree units if not already set

write_sortable_html(output[, ...])

Wrapper around write(format='jsviewer').

Methods Documentation

add_aladdin(rd_cols=['ra', 'dec'], fov=0.5, size=(400, 200), default_view='P/DSS2/color')[source]

Add AladinLite DIV column to the table

Parameters
rd_colslist, optional

The column names in self that contain the right ascension and declination coordinates of the sources. Default is [“ra”, “dec”].

fovfloat, optional

The field of view in degrees. Default is 0.5.

sizetuple, optional

The size of the DIVs in pixels (width, height). Default is (400, 200).

default_viewstr, optional

The default view of the AladinLite image. Default is “P/DSS2/color”.

classmethod gread(file, sextractor=False, format=None)[source]

Assume ascii.commented_header by default

Parameters
sextractorbool

Use format='ascii.sextractor'.

formatNone or str

Override format passed to read.

Returns
tabTable

Table object

gwrite(output, format='ascii.commented_header')[source]

Assume a format for the output table

Parameters
outputstr

Output filename

formatstr

Format string passed to write.

match_to_catalog_sky(other, self_radec=None, other_radec=None, nthneighbor=1, get_2d_offset=False)[source]

Compute SkyCoord projected matches between two GTable tables.

Parameters
otherTable, GTable, or list.

Other table to match positions from.

self_radec, other_radecNone or [str, str]

Column names for RA and Dec. If None, then try the following pairs (in this order):

>>> rd_pairs = OrderedDict()
>>> rd_pairs['ra'] = 'dec'
>>> rd_pairs['ALPHA_J2000'] = 'DELTA_J2000'
>>> rd_pairs['X_WORLD'] = 'Y_WORLD'
nthneighborint

See match_to_catalog_sky.

get_2d_offsetbool, optional

If True, compute the 2D offset between the matched coordinates.

Returns
idxint array

Indices of the matches as in

>>> matched = self[idx]
>>> len(matched) == len(other)
drfloat array

Projected separation of closest match.

Examples

>>> import astropy.units as u
>>> ref = GTable.gread('input.cat')
>>> gaia = GTable.gread('gaia.cat')
>>> idx, dr = ref.match_to_catalog_sky(gaia)
>>> close = dr < 1*u.arcsec
>>> ref_match = ref[idx][close]
>>> gaia_match = gaia[close]
match_triangles(other, self_wcs=None, x_column='X_IMAGE', y_column='Y_IMAGE', mag_column='MAG_AUTO', other_ra='X_WORLD', other_dec='Y_WORLD', pixel_index=1, match_kwargs={}, pad=100, show_diagnostic=False, auto_keep=3, maxKeep=10, auto_limit=3, ba_max=0.99, scale_density=10)[source]

Match sources between two catalogs using triangles

Parameters
selfGTable

The first catalog to match.

otherTable or GTable or list

The second catalog to match.

self_wcsWCS, optional

The WCS object associated with the first catalog. If provided, the positions in self will be transformed to pixel coordinates using this WCS before matching.

x_columnstr, optional

The column name in self that contains the x-coordinates of the sources. Default is “X_IMAGE”.

y_columnstr, optional

The column name in self that contains the y-coordinates of the sources. Default is “Y_IMAGE”.

mag_columnstr, optional

The column name in self that contains the magnitudes of the sources. Default is “MAG_AUTO”.

other_rastr, optional

The column name in other that contains the right ascension coordinates of the sources. Default is “X_WORLD”.

other_decstr, optional

The column name in other that contains the declination coordinates of the sources. Default is “Y_WORLD”.

pixel_indexint, optional

The pixel index convention to use when transforming the positions from world coordinates to pixel coordinates. Default is 1.

match_kwargsdict, optional

Additional keyword arguments to pass to the match_catalog_tri function.

padfloat, optional

The padding in pixels to apply to the bounding box of the second catalog. Default is 100.

show_diagnosticbool, optional

If True, a diagnostic plot showing the matched sources will be created. Default is False.

auto_keepint, optional

The number of matched sources to keep when performing the automatic matching. Default is 3.

maxKeepint, optional

The maximum number of matched sources to keep. Default is 10.

auto_limitint, optional

The maximum number of sources to use when performing the automatic matching. Default is 3.

ba_maxfloat, optional

The maximum axis ratio allowed when performing the automatic matching. Default is 0.99.

scale_densityfloat, optional

The scaling factor to apply to the number of sources in the second catalog when matching the surface densities of the two catalogs. Default is 10.

Returns
match_ixndarray

The indices of the matched sources in self and other.

tfndarray

The transformation matrix that maps the positions in self to the positions in other.

dxndarray

The residual offsets between the matched sources in self and other after applying the transformation.

rmsfloat

The root-mean-square residual of the matched sources.

figFigure, optional

The diagnostic plot showing the matched sources. Only returned if show_diagnostic is True.

static parse_radec_columns(self, rd_pairs=None)[source]

Parse column names for RA/Dec and set to degree units if not already set

Parameters
rd_pairsOrderedDict or None

Pairs of {ra:dec} names to search in the column list. If None, then uses the following by default.

>>> rd_pairs = OrderedDict()
>>> rd_pairs['ra'] = 'dec'
>>> rd_pairs['ALPHA_J2000'] = 'DELTA_J2000'
>>> rd_pairs['X_WORLD'] = 'Y_WORLD'

NB: search is performed in order of rd_pairs.keys() and stops if/when a match is found.

Returns
rd_pair[str, str]

Column names associated with RA/Dec. Returns False if no column pairs found based on rd_pairs.

write_sortable_html(output, replace_braces=True, localhost=True, max_lines=50, table_id=None, table_class='display compact', css=None, filter_columns=[], buttons=['csv'], toggle=True, use_json=False, with_dja_css=False, timestamp=True)[source]

Wrapper around write(format='jsviewer').

Parameters
outputstr

Output filename.

replace_bracesbool

Replace ‘&lt;’ and ‘&gt;’ characters that are converted automatically from “<>” by the write method. There are parameters for doing this automatically with write(format='html') but that don’t appear to be available with write(format='jsviewer').

localhostbool

Use local JS files. Otherwise use files hosted externally.

max_linesint, optional

Maximum number of lines to display in the table. Default is 50.

table_idstr, optional

ID attribute for the HTML table element.

table_classstr, optional

Class attribute for the HTML table element. Default is “display compact”.

cssstr, optional

Additional CSS styles to apply to the table.

filter_columnslist, optional

Add option to limit min/max values of column data.

buttonslist, optional

Add buttons for exporting data. Allowed options are ‘copy’, ‘csv’, ‘excel’, ‘pdf’, ‘print’.

togglebool, optional

Add links at top of page for toggling columns on/off.

use_jsonbool, optional

Write the data to a JSON file and strip out of the HTML header. Use this for large datasets or if columns include rendered images.

with_dja_cssbool, optional

Include additional CSS styles for Django admin interface.

timestampbool, optional

Add a timestamp to the output file.