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]:
Table length=5
solution_idDESIGNATIONSOURCE_IDrandom_indexref_epochrara_errordecdec_errorparallaxparallax_errorparallax_over_errorpmpmrapmra_errorpmdecpmdec_errorra_dec_corrra_parallax_corrra_pmra_corrra_pmdec_corrdec_parallax_corrdec_pmra_corrdec_pmdec_corrparallax_pmra_corrparallax_pmdec_corrpmra_pmdec_corrastrometric_n_obs_alastrometric_n_obs_acastrometric_n_good_obs_alastrometric_n_bad_obs_alastrometric_gof_alastrometric_chi2_alastrometric_excess_noiseastrometric_excess_noise_sigastrometric_params_solvedastrometric_primary_flagnu_eff_used_in_astrometrypseudocolourpseudocolour_errorra_pseudocolour_corrdec_pseudocolour_corrparallax_pseudocolour_corrpmra_pseudocolour_corrpmdec_pseudocolour_corrastrometric_matched_transitsvisibility_periods_usedastrometric_sigma5d_maxmatched_transitsnew_matched_transitsmatched_transits_removedipd_gof_harmonic_amplitudeipd_gof_harmonic_phaseipd_frac_multi_peakipd_frac_odd_winruwescan_direction_strength_k1scan_direction_strength_k2scan_direction_strength_k3scan_direction_strength_k4scan_direction_mean_k1scan_direction_mean_k2scan_direction_mean_k3scan_direction_mean_k4duplicated_sourcephot_g_n_obsphot_g_mean_fluxphot_g_mean_flux_errorphot_g_mean_flux_over_errorphot_g_mean_magphot_bp_n_obsphot_bp_mean_fluxphot_bp_mean_flux_errorphot_bp_mean_flux_over_errorphot_bp_mean_magphot_rp_n_obsphot_rp_mean_fluxphot_rp_mean_flux_errorphot_rp_mean_flux_over_errorphot_rp_mean_magphot_bp_rp_excess_factorphot_bp_n_contaminated_transitsphot_bp_n_blended_transitsphot_rp_n_contaminated_transitsphot_rp_n_blended_transitsphot_proc_modebp_rpbp_gg_rpradial_velocityradial_velocity_errorrv_method_usedrv_nb_transitsrv_nb_deblended_transitsrv_visibility_periods_usedrv_expected_sig_to_noiserv_renormalised_gofrv_chisq_pvaluerv_time_durationrv_amplitude_robustrv_template_teffrv_template_loggrv_template_fe_hrv_atm_param_originvbroadvbroad_errorvbroad_nb_transitsgrvs_maggrvs_mag_errorgrvs_mag_nb_transitsrvs_spec_sig_to_noisephot_variable_flaglbecl_lonecl_latin_qso_candidatesin_galaxy_candidatesnon_single_starhas_xp_continuoushas_xp_sampledhas_rvshas_epoch_photometryhas_epoch_rvhas_mcmc_gspphothas_mcmc_mscin_andromeda_surveyclassprob_dsc_combmod_quasarclassprob_dsc_combmod_galaxyclassprob_dsc_combmod_starteff_gspphotteff_gspphot_lowerteff_gspphot_upperlogg_gspphotlogg_gspphot_lowerlogg_gspphot_uppermh_gspphotmh_gspphot_lowermh_gspphot_upperdistance_gspphotdistance_gspphot_lowerdistance_gspphot_upperazero_gspphotazero_gspphot_lowerazero_gspphot_upperag_gspphotag_gspphot_lowerag_gspphot_upperebpminrp_gspphotebpminrp_gspphot_lowerebpminrp_gspphot_upperlibname_gspphot
yrdegmasdegmasmasmasmas / yrmas / yrmas / yrmas / yrmas / yrmas1 / um1 / um1 / ummasdegdegdegdegdegelectron / selectron / smagelectron / selectron / smagelectron / selectron / smagmagmagmagkm / skm / sdkm / sKlog(cm.s**-2)dexkm / skm / smagmagdegdegdegdegKKKlog(cm.s**-2)log(cm.s**-2)log(cm.s**-2)dexdexdexpcpcpcmagmagmagmagmagmagmagmagmag
int64objectint64int64float64float64float32float64float32float64float32float32float32float64float32float64float32float32float32float32float32float32float32float32float32float32float32int16int16int16int16float32float32float32float32int16boolfloat32float32float32float32float32float32float32float32int16int16float32int16int16int16float32float32int16int16float32float32float32float32float32float32float32float32float32boolint16float64float32float32float32int16float64float32float32float32int16float64float32float32float32float32int16int16int16int16int16float32float32float32float32float32int16int16int16int16float32float32float32float32float32float32float32float32int16float32float32int16float32float32int16float32objectfloat64float64float64float64boolboolint16boolboolboolboolboolboolboolboolfloat32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32object
1636148068921376768Gaia DR3 155198829213154956815519882921315495688900820522016.0202.47621835713810.748323247.151972776228120.90635014-1.55288169676193121.2272083-1.26537742.435153-2.4330676697812940.994036850.100757503706651461.26996960.37464455-0.189580160.1645490.16169423-0.267974230.140673730.170917-0.16200161-0.377165970.27786323258025622.6322927328.2862.32079221.056778695False--1.3422680.26838365-0.06818995-0.025997920.19759205-0.068285316-0.140469131241.8951416381700.04526214396.571175021.11861560.184248670.373258770.174519910.3911204-74.23466-63.91142337.65227521.430153True29395.722430396933180.9790209597.7736320.73483326181.2285475622398417.1616810.5600719.69297625139.12624891666614.4043859.65860419.3893723.346705702602500.30360413-1.04185681.3454609--------------------------------------------NOT_AVAILABLE104.7920549886698968.59840109705154175.1697559722966650.90282916020732FalseTrue0FalseFalseFalseFalseFalseFalseFalseFalse0.000613337850.998519960.0008667134------------------------------------------
1636148068921376768Gaia DR3 1551988463929387648155198846392938764816361497722016.0202.436023552909940.444228647.1665352226328240.597321-0.210152053103638050.7318001-0.287171424.13046170.88223862278057660.56147894.0351415228795810.75259410.27231008-0.15583270.0490657130.08984825-0.214837010.0243773630.3666216-0.06945767-0.373181760.20351215446043797.8904915884.07934.623820.21786395False--1.09234140.150204180.00750743360.107977310.036282983-0.048866370.03252402752271.1143742703980.09647766111.126526141.27961210.211497130.3069240.118643630.28504333-56.36863-64.5628545.92181816.223856False519200.253152925281461.3851699144.5693819.933418221406.211639888164254.93128225.59946817.468416231191.584613295731732.5869336.56633817.05758312.97256102202300.41083336-2.4650022.8758354--------------------------------------------NOT_AVAILABLE104.8767057535582168.59620898462525175.1210834453790450.898730580732106FalseTrue0FalseFalseFalseFalseFalseFalseFalseFalse5.039107e-110.99999633.7102905e-06------------------------------------------
1636148068921376768Gaia DR3 1551988773167190784155198877316719078410193545502016.0202.473203779877340.385525647.189644985715040.45663941.52114523855006480.61758242.46306471.2724876-0.463938104979195630.48734134-1.18489920389850760.5858320.21224469-0.112964990.0393107720.08014045-0.0568773750.050551110.26251525-0.10948872-0.33805060.2342358445943873.5123873574.45332.74379943.949466295False--1.77056810.12830798-0.046022233-0.03372772-0.0159144140.03260910.01230576252260.87323254651930.04841678680.55671301.1210413----------------False535196.272227645192661.3947663140.7205219.9552251945.707503741238839.50697323.93773717.89915501248.815933364719367.42367618.5219217.00664911.18101905105000.89250183-2.05606842.9485703--------------------------------------------NOT_AVAILABLE104.8391760547594668.56482582796096175.1322755827956750.93224110096643FalseTrue0FalseFalseFalseFalseFalseFalseFalseFalse1.2306821e-101.01.5448892e-08------------------------------------------
1636148068921376768Gaia DR3 1551988807529534208155198880752953420815801030352016.0202.476360314691650.2781962847.201814460503580.31006017-1.29368957897934740.41817343-3.09366774.04422661.66627712921698110.34709073.68500901716005740.401813060.14083208-0.17493783-0.00223527620.1443171-0.0854718460.1000377460.25123927-0.058198392-0.2681360.107605435494049048.797426856.99832.5235798.44341995False--1.76908730.08837092-0.009559230.0111100910.067102350.020670226-0.01831183458300.58091736747400.0751268442.541615611.29494320.144107610.181373430.083373840.31451-95.37658-61.8711242.6610814.672581False596297.468649268002651.9929224149.2625419.50376331988.544402607739143.888522.52399617.85105131891.162016105026944.44282520.05187617.3730036.31900702502500.47804832-1.65271192.1307602--------------------------------------------NOT_AVAILABLE104.8473541831317368.55283585204637175.1237760788416450.94337703119712FalseTrue0FalseFalseFalseFalseFalseFalseFalseFalse4.911622e-100.99905010.0009499131------------------------------------------
1636148068921376768Gaia DR3 155199042243653811215519904224365381122031187922016.0202.504637459728540.5857174447.229141001353160.7143791-1.27758908286871130.8813056-1.4496552.8226283-2.7475935445175160.7255988-0.64649817814629550.87648620.23443323-0.112172480.138224560.115287475-0.0347322080.0933008640.38000315-0.032184172-0.226375710.223657194640458638.1626972947.44687.54979447.09826395False--1.61621610.18061645-0.014007429-0.068259280.024061043-0.0184590560.0789985256291.3104724702100.19378218153.90639202.50748370.218877510.247038630.095638780.3500768-93.71961-64.6571447.03715.638713False554231.605305833965451.702601136.0302919.77549660669.712400811333319.92728833.60780318.2738260515.752988859784821.50603923.98177517.9667915.118472606006000.30702972-1.50167471.8087044--------------------------------------------NOT_AVAILABLE104.829794916154568.52005828530262175.123225696429950.97677659075816FalseTrue0FalseFalseFalseFalseFalseFalseFalseFalse1.2920486e-080.99892770.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}