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, ...])

x_column = 'X_IMAGE' y_column = 'Y_IMAGE' mag_column = 'MAG_AUTO' pixel_index=1 pad=100

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

fov : fov in degrees size : size of DIVs (w, h) in pixels (w, h)

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.

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]

x_column = ‘X_IMAGE’ y_column = ‘Y_IMAGE’ mag_column = ‘MAG_AUTO’ pixel_index=1 pad=100

auto_keep=3 maxKeep=10 auto_limit=3 ba_max = 0.99

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)[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.

filter_columnslist

Add option to limit min/max values of column data

buttonslist

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

togglebool

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

use_jsonbool

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.

etc

Additional parameters passed through to write.