Displaying Tables and Catalogs#
This notebook shows how to display tables in Firefly and how to modify the table display (filtering/sorting). Catalog tables are overlaid on images by default if Firefly recognizes celestial coordinates in the table.
Setup#
First, we create a FireflyClient instance and open a Firefly viewer. See Initializing a FireflyClient instance for more details. Then, we display a FITS image from a URL so that we have an image for catalog overlays. See Displaying a FITS Image for more details.
[1]:
from firefly_client import FireflyClient
# Following imports are just for example data fetching and processing (not needed always)
from astropy.utils.data import download_file
from astropy.table import Table
import io
# Initialize a FireflyClient instance
fc = FireflyClient.make_client(url="https://irsa.ipac.caltech.edu/irsaviewer")
# Display a FITS image (from URL of WISE W2 cutout of M51 galaxy)
cutout_image_url = 'https://irsa.ipac.caltech.edu/ibe/data/wise/allsky/4band_p1bm_frm/9a/05379a/141/05379a141-w2-int-1b.fits?center=202.4841667,47.23055556&size=400pix'
plot_id = 'wise-cutout'
fc.show_fits_image(file_input=cutout_image_url, plot_id=plot_id, title='WISE Cutout')
[1]:
{'success': True}
Display a Table#
Use show_table method of the FireflyClient object to display a table. Similar to show_fits_image, it can take a URL, a local file path, or a file-like object as input via the file_input parameter.
From a local file#
You can specify path of any local table file. Here we download the Gaia DR3 catalog for 300” cone around M51 and use its file path:
[2]:
tbl_url_gaia = "https://gea.esac.esa.int/tap-server/tap/sync?LANG=ADQL&QUERY=SELECT+*+FROM+gaiadr3.gaia_source+WHERE+CONTAINS(POINT('ICRS',ra,dec),CIRCLE('ICRS',202.4841667,47.23055556,0.083333))=1"
tbl_fpath_gaia = download_file(tbl_url_gaia, cache=True, timeout=120)
tbl_fpath_gaia
[2]:
'/Users/jsinghal/.astropy/cache/download/url/55fa7a5603170b3f0b7f826748efe73a/contents'
[3]:
tbl_id_gaia = 'gaia-catalog'
fc.show_table(file_input=tbl_fpath_gaia,
tbl_id=tbl_id_gaia,
title='Gaia Catalog')
[3]:
{'success': True}
From an in-memory file-like object#
You can also use a file-like object (e.g. StringIO or BytesIO stream) instead of a local file path or URL. This is useful when you are working with a Table file in memory (for e.g. as an Astropy Table) and don’t want to write it to disk.
[4]:
gaia_tbl = Table.read(tbl_fpath_gaia)
gaia_galaxy_tbl = gaia_tbl[gaia_tbl['classprob_dsc_combmod_galaxy'] >= 0.95]
gaia_galaxy_tbl[:5]
[4]:
| solution_id | DESIGNATION | SOURCE_ID | random_index | ref_epoch | ra | ra_error | dec | dec_error | parallax | parallax_error | parallax_over_error | pm | pmra | pmra_error | pmdec | pmdec_error | ra_dec_corr | ra_parallax_corr | ra_pmra_corr | ra_pmdec_corr | dec_parallax_corr | dec_pmra_corr | dec_pmdec_corr | parallax_pmra_corr | parallax_pmdec_corr | pmra_pmdec_corr | astrometric_n_obs_al | astrometric_n_obs_ac | astrometric_n_good_obs_al | astrometric_n_bad_obs_al | astrometric_gof_al | astrometric_chi2_al | astrometric_excess_noise | astrometric_excess_noise_sig | astrometric_params_solved | astrometric_primary_flag | nu_eff_used_in_astrometry | pseudocolour | pseudocolour_error | ra_pseudocolour_corr | dec_pseudocolour_corr | parallax_pseudocolour_corr | pmra_pseudocolour_corr | pmdec_pseudocolour_corr | astrometric_matched_transits | visibility_periods_used | astrometric_sigma5d_max | matched_transits | new_matched_transits | matched_transits_removed | ipd_gof_harmonic_amplitude | ipd_gof_harmonic_phase | ipd_frac_multi_peak | ipd_frac_odd_win | ruwe | scan_direction_strength_k1 | scan_direction_strength_k2 | scan_direction_strength_k3 | scan_direction_strength_k4 | scan_direction_mean_k1 | scan_direction_mean_k2 | scan_direction_mean_k3 | scan_direction_mean_k4 | duplicated_source | phot_g_n_obs | phot_g_mean_flux | phot_g_mean_flux_error | phot_g_mean_flux_over_error | phot_g_mean_mag | phot_bp_n_obs | phot_bp_mean_flux | phot_bp_mean_flux_error | phot_bp_mean_flux_over_error | phot_bp_mean_mag | phot_rp_n_obs | phot_rp_mean_flux | phot_rp_mean_flux_error | phot_rp_mean_flux_over_error | phot_rp_mean_mag | phot_bp_rp_excess_factor | phot_bp_n_contaminated_transits | phot_bp_n_blended_transits | phot_rp_n_contaminated_transits | phot_rp_n_blended_transits | phot_proc_mode | bp_rp | bp_g | g_rp | radial_velocity | radial_velocity_error | rv_method_used | rv_nb_transits | rv_nb_deblended_transits | rv_visibility_periods_used | rv_expected_sig_to_noise | rv_renormalised_gof | rv_chisq_pvalue | rv_time_duration | rv_amplitude_robust | rv_template_teff | rv_template_logg | rv_template_fe_h | rv_atm_param_origin | vbroad | vbroad_error | vbroad_nb_transits | grvs_mag | grvs_mag_error | grvs_mag_nb_transits | rvs_spec_sig_to_noise | phot_variable_flag | l | b | ecl_lon | ecl_lat | in_qso_candidates | in_galaxy_candidates | non_single_star | has_xp_continuous | has_xp_sampled | has_rvs | has_epoch_photometry | has_epoch_rv | has_mcmc_gspphot | has_mcmc_msc | in_andromeda_survey | classprob_dsc_combmod_quasar | classprob_dsc_combmod_galaxy | classprob_dsc_combmod_star | teff_gspphot | teff_gspphot_lower | teff_gspphot_upper | logg_gspphot | logg_gspphot_lower | logg_gspphot_upper | mh_gspphot | mh_gspphot_lower | mh_gspphot_upper | distance_gspphot | distance_gspphot_lower | distance_gspphot_upper | azero_gspphot | azero_gspphot_lower | azero_gspphot_upper | ag_gspphot | ag_gspphot_lower | ag_gspphot_upper | ebpminrp_gspphot | ebpminrp_gspphot_lower | ebpminrp_gspphot_upper | libname_gspphot |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yr | deg | mas | deg | mas | mas | mas | mas / yr | mas / yr | mas / yr | mas / yr | mas / yr | mas | 1 / um | 1 / um | 1 / um | mas | deg | deg | deg | deg | deg | electron / s | electron / s | mag | electron / s | electron / s | mag | electron / s | electron / s | mag | mag | mag | mag | km / s | km / s | d | km / s | K | log(cm.s**-2) | dex | km / s | km / s | mag | mag | deg | deg | deg | deg | K | K | K | log(cm.s**-2) | log(cm.s**-2) | log(cm.s**-2) | dex | dex | dex | pc | pc | pc | mag | mag | mag | mag | mag | mag | mag | mag | mag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int64 | object | int64 | int64 | float64 | float64 | float32 | float64 | float32 | float64 | float32 | float32 | float32 | float64 | float32 | float64 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | int16 | int16 | int16 | int16 | float32 | float32 | float32 | float32 | int16 | bool | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | int16 | int16 | float32 | int16 | int16 | int16 | float32 | float32 | int16 | int16 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | bool | int16 | float64 | float32 | float32 | float32 | int16 | float64 | float32 | float32 | float32 | int16 | float64 | float32 | float32 | float32 | float32 | int16 | int16 | int16 | int16 | int16 | float32 | float32 | float32 | float32 | float32 | int16 | int16 | int16 | int16 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | int16 | float32 | float32 | int16 | float32 | float32 | int16 | float32 | object | float64 | float64 | float64 | float64 | bool | bool | int16 | bool | bool | bool | bool | bool | bool | bool | bool | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | object |
| 1636148068921376768 | Gaia DR3 1551988292131549568 | 1551988292131549568 | 890082052 | 2016.0 | 202.4762183571381 | 0.7483232 | 47.15197277622812 | 0.90635014 | -1.5528816967619312 | 1.2272083 | -1.2653774 | 2.435153 | -2.433067669781294 | 0.99403685 | 0.10075750370665146 | 1.2699696 | 0.37464455 | -0.18958016 | 0.164549 | 0.16169423 | -0.26797423 | 0.14067373 | 0.170917 | -0.16200161 | -0.37716597 | 0.27786323 | 258 | 0 | 256 | 2 | 2.6322927 | 328.286 | 2.3207922 | 1.0567786 | 95 | False | -- | 1.342268 | 0.26838365 | -0.06818995 | -0.02599792 | 0.19759205 | -0.068285316 | -0.1404691 | 31 | 24 | 1.8951416 | 38 | 17 | 0 | 0.045262143 | 96.571175 | 0 | 2 | 1.1186156 | 0.18424867 | 0.37325877 | 0.17451991 | 0.3911204 | -74.23466 | -63.911423 | 37.652275 | 21.430153 | True | 293 | 95.72243039693318 | 0.97902095 | 97.77363 | 20.734833 | 26 | 181.22854756223984 | 17.16168 | 10.56007 | 19.692976 | 25 | 139.126248916666 | 14.404385 | 9.658604 | 19.389372 | 3.3467057 | 0 | 26 | 0 | 25 | 0 | 0.30360413 | -1.0418568 | 1.3454609 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 104.79205498866989 | 68.59840109705154 | 175.16975597229666 | 50.90282916020732 | False | True | 0 | False | False | False | False | False | False | False | False | 0.00061333785 | 0.99851996 | 0.0008667134 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1636148068921376768 | Gaia DR3 1551988463929387648 | 1551988463929387648 | 1636149772 | 2016.0 | 202.43602355290994 | 0.4442286 | 47.166535222632824 | 0.597321 | -0.21015205310363805 | 0.7318001 | -0.28717142 | 4.1304617 | 0.8822386227805766 | 0.5614789 | 4.035141522879581 | 0.7525941 | 0.27231008 | -0.1558327 | 0.049065713 | 0.08984825 | -0.21483701 | 0.024377363 | 0.3666216 | -0.06945767 | -0.37318176 | 0.20351215 | 446 | 0 | 437 | 9 | 7.8904915 | 884.0793 | 4.6238 | 20.217863 | 95 | False | -- | 1.0923414 | 0.15020418 | 0.0075074336 | 0.10797731 | 0.036282983 | -0.04886637 | 0.032524027 | 52 | 27 | 1.1143742 | 70 | 39 | 8 | 0.09647766 | 111.126526 | 1 | 4 | 1.2796121 | 0.21149713 | 0.306924 | 0.11864363 | 0.28504333 | -56.36863 | -64.56285 | 45.921818 | 16.223856 | False | 519 | 200.25315292528146 | 1.3851699 | 144.56938 | 19.933418 | 22 | 1406.2116398881642 | 54.931282 | 25.599468 | 17.468416 | 23 | 1191.5846132957317 | 32.58693 | 36.566338 | 17.057583 | 12.972561 | 0 | 22 | 0 | 23 | 0 | 0.41083336 | -2.465002 | 2.8758354 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 104.87670575355821 | 68.59620898462525 | 175.12108344537904 | 50.898730580732106 | False | True | 0 | False | False | False | False | False | False | False | False | 5.039107e-11 | 0.9999963 | 3.7102905e-06 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1636148068921376768 | Gaia DR3 1551988773167190784 | 1551988773167190784 | 1019354550 | 2016.0 | 202.47320377987734 | 0.3855256 | 47.18964498571504 | 0.4566394 | 1.5211452385500648 | 0.6175824 | 2.4630647 | 1.2724876 | -0.46393810497919563 | 0.48734134 | -1.1848992038985076 | 0.585832 | 0.21224469 | -0.11296499 | 0.039310772 | 0.08014045 | -0.056877375 | 0.05055111 | 0.26251525 | -0.10948872 | -0.3380506 | 0.2342358 | 445 | 9 | 438 | 7 | 3.5123873 | 574.4533 | 2.7437994 | 3.9494662 | 95 | False | -- | 1.7705681 | 0.12830798 | -0.046022233 | -0.03372772 | -0.015914414 | 0.0326091 | 0.012305762 | 52 | 26 | 0.87323254 | 65 | 19 | 3 | 0.048416786 | 80.55671 | 3 | 0 | 1.1210413 | -- | -- | -- | -- | -- | -- | -- | -- | False | 535 | 196.27222764519266 | 1.3947663 | 140.72052 | 19.95522 | 51 | 945.7075037412388 | 39.506973 | 23.937737 | 17.89915 | 50 | 1248.8159333647193 | 67.423676 | 18.52192 | 17.006649 | 11.181019 | 0 | 51 | 0 | 50 | 0 | 0.89250183 | -2.0560684 | 2.9485703 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 104.83917605475946 | 68.56482582796096 | 175.13227558279567 | 50.93224110096643 | False | True | 0 | False | False | False | False | False | False | False | False | 1.2306821e-10 | 1.0 | 1.5448892e-08 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1636148068921376768 | Gaia DR3 1551988807529534208 | 1551988807529534208 | 1580103035 | 2016.0 | 202.47636031469165 | 0.27819628 | 47.20181446050358 | 0.31006017 | -1.2936895789793474 | 0.41817343 | -3.0936677 | 4.0442266 | 1.6662771292169811 | 0.3470907 | 3.6850090171600574 | 0.40181306 | 0.14083208 | -0.17493783 | -0.0022352762 | 0.1443171 | -0.085471846 | 0.100037746 | 0.25123927 | -0.058198392 | -0.268136 | 0.107605435 | 494 | 0 | 490 | 4 | 8.797426 | 856.9983 | 2.523579 | 8.443419 | 95 | False | -- | 1.7690873 | 0.08837092 | -0.00955923 | 0.011110091 | 0.06710235 | 0.020670226 | -0.018311834 | 58 | 30 | 0.58091736 | 74 | 74 | 0 | 0.07512684 | 42.541615 | 6 | 1 | 1.2949432 | 0.14410761 | 0.18137343 | 0.08337384 | 0.31451 | -95.37658 | -61.87112 | 42.66108 | 14.672581 | False | 596 | 297.46864926800265 | 1.9929224 | 149.26254 | 19.503763 | 31 | 988.5444026077391 | 43.8885 | 22.523996 | 17.851051 | 31 | 891.1620161050269 | 44.442825 | 20.051876 | 17.373003 | 6.319007 | 0 | 25 | 0 | 25 | 0 | 0.47804832 | -1.6527119 | 2.1307602 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 104.84735418313173 | 68.55283585204637 | 175.12377607884164 | 50.94337703119712 | False | True | 0 | False | False | False | False | False | False | False | False | 4.911622e-10 | 0.9990501 | 0.0009499131 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1636148068921376768 | Gaia DR3 1551990422436538112 | 1551990422436538112 | 203118792 | 2016.0 | 202.50463745972854 | 0.58571744 | 47.22914100135316 | 0.7143791 | -1.2775890828687113 | 0.8813056 | -1.449655 | 2.8226283 | -2.747593544517516 | 0.7255988 | -0.6464981781462955 | 0.8764862 | 0.23443323 | -0.11217248 | 0.13822456 | 0.115287475 | -0.034732208 | 0.093300864 | 0.38000315 | -0.032184172 | -0.22637571 | 0.22365719 | 464 | 0 | 458 | 6 | 38.162697 | 2947.4468 | 7.549794 | 47.098263 | 95 | False | -- | 1.6162161 | 0.18061645 | -0.014007429 | -0.06825928 | 0.024061043 | -0.018459056 | 0.07899852 | 56 | 29 | 1.3104724 | 70 | 21 | 0 | 0.19378218 | 153.90639 | 2 | 0 | 2.5074837 | 0.21887751 | 0.24703863 | 0.09563878 | 0.3500768 | -93.71961 | -64.65714 | 47.037 | 15.638713 | False | 554 | 231.60530583396545 | 1.702601 | 136.03029 | 19.775496 | 60 | 669.7124008113333 | 19.927288 | 33.607803 | 18.27382 | 60 | 515.7529888597848 | 21.506039 | 23.981775 | 17.966791 | 5.1184726 | 0 | 60 | 0 | 60 | 0 | 0.30702972 | -1.5016747 | 1.8087044 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 104.8297949161545 | 68.52005828530262 | 175.1232256964299 | 50.97677659075816 | False | True | 0 | False | False | False | False | False | False | False | False | 1.2920486e-08 | 0.9989277 | 0.0010722713 | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
[5]:
tbl_stream = io.BytesIO()
gaia_galaxy_tbl.write(tbl_stream, format='votable')
WARNING: W50: ?:?:?: W50: Invalid unit string 'log(cm.s**-2)' [astropy.io.votable.tree]
[6]:
fc.show_table(file_input=tbl_stream,
tbl_id=tbl_id_gaia+'-galaxy',
title='Gaia Galaxy Catalog')
[6]:
{'success': True}
From a URL#
You can specify URL of any table. Here we use an IRSA TAP query to retrieve a 2MASS catalog for 0.125 degree cone at M51.
[7]:
tbl_url_2mass = "http://irsa.ipac.caltech.edu/TAP/sync?FORMAT=IPAC_TABLE&QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT('J2000',ra,dec),CIRCLE('J2000',202.4841667,47.23055556,0.125))=1"
[8]:
tbl_id_2mass = '2mass-catalog'
fc.show_table(file_input=tbl_url_2mass,
tbl_id=tbl_id_2mass,
title='2MASS Catalog')
[8]:
{'success': True}
Note
Displaying a catalog table also caused Firefly to overlay the image with markers for each row of the table by default. Also we see the active chart and coverage tab as bonus! If we have more than one images displayed, the catalog overlay will appear to all images that cover the catalog area.
Modify the displayed table#
After displaying a table in Firefly, you can apply filters and sorting by tbl_id.
Sorting by a column#
You can sort the table by a column in ascending (ASC) or descending (DESC) order:
[9]:
fc.sort_table_column(tbl_id=tbl_id_2mass, # note: we use the table id we defined above
column_name='j_m', sort_direction='ASC')
[9]:
{'success': True}
Filtering the rows#
Filters can be specified as an SQL WHERE clause-like string with column names quoted:
[10]:
fc.apply_table_filters(tbl_id=tbl_id_2mass,
filters='"j_m"<15 and "j_cmsig"<0.05')
[10]:
{'success': True}
Note
You can see these filters in the table display. The catalog markers on the image also reduce in number as well as the active chart updates too.
To remove the filters:
[11]:
fc.apply_table_filters(tbl_id=tbl_id_2mass, filters='')
[11]:
{'success': True}
Tweaking the table display parameters#
show_table method offers several parameters other than the ones we used above, to control how to display the table.
Load table without displaying it#
By default, show_table loads the provided table and displays it in a table viewer. If it is desired to overlay the table on an image, or to make plots from it without showing the table in the viewer, you can set the visible parameter to False.
Tip
This is especially useful for loading a MOC file (a single-column table) since you only want to overlay the MOC map on the HiPS image without displaying the table. See Overlay MOC on HiPS
[12]:
tbl_url_spitzer = "https://irsa.ipac.caltech.edu/cgi-bin/Gator/nph-query?outfmt=1&catalog=slphotdr4&objstr=202.484167d+47.230556d+eq+j2000&spatial=Cone&radius=240"
fc.show_table(file_input=tbl_url_spitzer,
title='Spitzer catalog',
visible=False)
[12]:
{'success': True}
Note
It may take some time to load this catalog table, and since there’s no feedback from the table display, look for the spinner on the top left of the image display.
Display table without catalog overlay#
If the table contains celestial coordinates recognized by Firefly, the catalog overlay will appear by default on the displayed image. But if you specifically do not want the table overlaid on the image, you can set the is_catalog parameter to False
[13]:
fc.show_table(file_input=tbl_url_spitzer,
title='Spitzer: no overlay',
is_catalog=False
)
[13]:
{'success': True}