skip to main content

@tonyfast s notebooks

site navigation
notebook summary
title
astropy tables as semantic tables
description
astropy tables carry a lot of information. the default representation violates html standards. we reuse our accessible table repr on the pandas version of the table. with this installed, astropy tables are accessible.
cells
6 total
4 code
state
executed in order
kernel
mast_nb
language
python
name
mast_nb
lines of code
27
outputs
3
table of contents
{"kernelspec": {"display_name": "mast_nb", "language": "python", "name": "mast_nb"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2"}, "widgets": {"application/vnd.jupyter.widget-state+json": {"state": {}, "version_major": 2, "version_minor": 0}}, "title": "astropy tables as semantic tables", "description": "astropy tables carry a lot of information. the default representation violates html standards.\nwe reuse our accessible table repr on the pandas version of the table. with this installed, astropy tables are accessible."}
notebook toolbar
Activate
cell ordering
1

astropy tables as semantic tables

astropy tables carry a lot of information. the default representation violates html standards. we reuse our accessible table repr on the pandas version of the table. with this installed, astropy tables are accessible.

image.png

2
%matplotlib inline
import astropy
from astropy.coordinates import SkyCoord
from astroquery.mast import Observations

from nbconvert_a11y.tables import *
from nbconvert_a11y.outputs import BeautifulSoup
%reload_ext nbconvert_a11y.outputs
1 outputs.
3

Below are the helper functions we will call for plotting purposes later in the notebook.

4
# We will pass in the coordinates as a Sky Coord object
coordinates = SkyCoord(289.0979, -29.3370, unit="deg")

obs = Observations.query_criteria(coordinates=coordinates,
                                  target_name='TICA FFI',
                                  dataproduct_type='image',
                                  sequence_number=27)

obs
1 outputs.
Table masked=True length=1
intentType obs_collection provenance_name instrument_name project filters wavelength_region target_name target_classification obs_id s_ra s_dec dataproduct_type proposal_pi calib_level t_min t_max t_exptime em_min em_max obs_title t_obs_release proposal_id proposal_type sequence_number s_region jpegURL dataURL dataRights mtFlag srcDen obsid objID objID1 distance
str7 str4 str4 str10 str4 str4 str7 str8 str1 str25 float64 float64 str5 str17 int64 float64 float64 float64 float64 float64 str1 float64 str3 str1 int64 str117 str1 str1 str6 bool float64 str8 str9 str9 float64
science HLSP TICA Photometer TESS TESS Optical TICA FFI -- hlsp_tica_s0027-cam1-ccd4 292.5180823224232 -33.62274382166828 image Michael Fausnaugh 3 59035.77807636512 59060.13917620387 475.2 600.0 1000.0 -- 59246.0 N/A -- 27 POLYGON 298.489297 -26.919235 301.396094 -38.579035 285.694884 -40.219585 285.275975 -28.732615 298.489297 -26.919235 -- -- PUBLIC False nan 96814766 185636258 185636258 0.0
5
import astropy.table
from nbconvert_a11y.outputs import BeautifulSoup
from nbconvert_a11y.tables import repr_semantic, get_table, SHOW_INDEX, repr_semantic_update
@repr_semantic.register(astropy.table.Table)
def repr_astropy_table(table, *args, **kwargs):
    return get_table(obs.to_pandas(), BeautifulSoup(obs._base_repr_(True)).i.text, type_=type(table), ROW_INDEX=SHOW_INDEX.hide)

repr_semantic_update()
6
    obs
1 outputs.
Table masked=True length=1
rows
1
columns
35
indexes
rows
0
columns
1
intentType obs_collection provenance_name instrument_name project filters wavelength_region target_name target_classification obs_id hidden s_region jpegURL dataURL dataRights mtFlag srcDen obsid objID objID1 distance
science HLSP TICA Photometer TESS TESS Optical TICA FFI nan hlsp_tica_s0027-cam1-ccd4 hidden POLYGON 298.489297 -26.919235 301.396094 -38.579035 285.694884 -40.219585 285.275975 -28.732615 298.489297 -26.919235 nan nan PUBLIC False nan 96814766 185636258 185636258 0.0