ALMA archive data mining with ECOGAL

imaging ALMA catalog release demo

(This page is auto-generated from the Jupyter notebook ecogal-dja-showcase.ipynb.)

Short description of the project:

ECOGAL (ECOology for Galaxies using ALMA archive and Legacy surveys) is an ALMA data-mining effort that uniformly reduces archival data, creates science-ready ALMA images, and links them to JWST/HST legacy datasets in well-studied survey fields.

This notebook provides an introduction to the ECOGAL catalogue, including how to query sources by position and retrieve the summary plots available for ALMA-detected galaxies with DJA spectra. The catalogue released with this post covers galaxies in the three ALMA-accessible CANDELS fields: COSMOS, GOODS-S, and UDS.

  • This notebook was tested on python 3.12 version
  • Some functions that are used in this notebook can be installed from : https://github.com/mjastro/ecogal
    • or on terminal:

    python -m pip install git+https://github.com/mjastro/ecogal.git

Additional documentation will be released soon. A complete description of the ALMA data reduction and catalogue construction is provided in Lee et al. (2025) [arXiv:2511.20751], and should be cited when using the ECOGAL data products. Users should also cite the appropriate survey references (including ALMA project IDs) when making use of the DJA data products.

%matplotlib inline
# libraries to install
if 0:
    !python -m pip install git+https://github.com/mjastro/ecogal.git
    !pip install tabulate
    !pip install git+https://github.com/karllark/dust_attenuation.git
# setting the libraries

import ecogal

import numpy as np
import astropy
import os,sys
from astropy.coordinates import SkyCoord
from astropy import units as u
from astropy.table import Table
from astropy.utils.data import download_file
import astropy.constants as const

import matplotlib as mpl
import cmasher as cmr
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from astropy.coordinates import Angle


import shapely
from shapely import Point, Polygon


import warnings
from astropy.io import fits
from astropy.wcs import WCS
warnings.filterwarnings('ignore')

import pandas as pd


# cosmology
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Tcmb0=2.725)


CACHE_DOWNLOADS = True


print(f'astropy version: {astropy.__version__}')
astropy version: 7.1.1
# Set plotting style
mpl.rcParams['axes.linewidth'] = 2
mpl.rcParams['axes.labelsize'] = 20
mpl.rcParams.update({'font.family':'serif'})
mpl.rcParams.update({'xtick.major.pad': '7.0'})
mpl.rcParams.update({'xtick.major.size': '7.5'})
mpl.rcParams.update({'xtick.major.width': '1.5'})
mpl.rcParams.update({'xtick.minor.pad': '7.0'})
mpl.rcParams.update({'xtick.minor.size': '3.5'})
mpl.rcParams.update({'xtick.minor.width': '1.0'})
mpl.rcParams.update({'ytick.major.pad': '7.0'})
mpl.rcParams.update({'ytick.major.size': '7.5'})
mpl.rcParams.update({'ytick.major.width': '1.5'})
mpl.rcParams.update({'ytick.minor.pad': '7.0'})
mpl.rcParams.update({'ytick.minor.size': '3.5'})
mpl.rcParams.update({'ytick.minor.width': '1.0'})
mpl.rcParams.update({'xtick.labelsize':14})
mpl.rcParams.update({'ytick.labelsize':14})

mpl.rcParams.update({'xtick.direction':'in'})
mpl.rcParams.update({'ytick.direction':'in'})

mpl.rcParams.update({'axes.labelsize' :18})
# to get DJA spectra information

from urllib import request

####Needed to load spectra
import msaexp
import msaexp.spectrum

#to get DJA slit information

import grizli
from grizli import utils


print(f'grizli version: {grizli.__version__}')

grizli version: 1.13.2

Catalogue data exploration

Read the table

# prior catalogue which includes all sources with flux constraints (including non-detection) based on the source positions determined by JWST/HST detection

version ='v1' #initial data release

URL_PREFIX = "https://s3.amazonaws.com/alma-ecogal/dr1"
file_cat = "ecogal_all_priors_"+version+".csv"

if 0:
    # the latest zenodo (frozen) catalogue is available here (TBD)
    # this include blind catalogue, and detection catalogue
    URL_PREFIX = "https://zenodo.org/records/XXX"

table_url = f"{URL_PREFIX}/catalogue/{file_cat}"

tab = utils.read_catalog(download_file(table_url, cache=CACHE_DOWNLOADS), format='csv')

Column descriptions

columns_url = f"{URL_PREFIX}/catalogue/ecogal_{version}.columns.csv"
tab_columns = utils.read_catalog(download_file(columns_url, cache=CACHE_DOWNLOADS), format='csv')

# Set column metadata
for row in tab_columns:
    col = row['column']
    if row['unit'] != '--':
        tab[col].unit = row['unit']
    if row['description'] != '--':
        tab[col].description = row['description']

tab.info()
<GTable length=258455>
       name         dtype      unit                                                                                                     description                                                                                                     class     n_bad 
------------------ ------- ------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------ ------
         projectID   str14                                                                                                                                                                                                           ALMA project ID       Column      0
       target_alma   str23                                                                                           ALMA target names without space;if original ALMA program has a space for the target name this column does not include the space       Column      0
  small_mosaic_idx   int64                                                                                                                                                                   mosaic identifier if it was obtained in the mosaic mode       Column      0
             field    str6                                                                                                                                                                                                        legacy field names       Column      0
         id_ecogal   int64                                                                                                                                                                                                          ecogal parant ID       Column      0
            id_new   str13                                                                                                                                                                            ecogal parent full ID including the field name       Column      0
         frequency float64          GHz                                                                                                                                                                                           observed frequency       Column      0
              band    str2                                                                                                                                                                                                        observed ALMA band       Column      0
          beam_maj float64       arcsec                                                                                                                                                                        synthesized beam major axis in arcsec       Column      0
             frame    str4                                                                                                                                                                                                               image frame       Column      0
         RA_parent float64          deg                                                                                                                                                                  prior position from JWST/HST (RA) in degree       Column      0
        Dec_parent float64          deg                                                                                                                                                                 prior position from JWST/HST (DEC) in degree       Column      0
      RA_peak_alma float64          deg                                                                                                                                                                            ALMA peak position (RA) in degree       Column      0
     Dec_peak_alma float64          deg                                                                                                                                                                            ALMA pak position (DEC) in degree       Column      0
  separation_prior float64       arcsec                                                                                                                                                     position offset between ALMA peak and the prior position       Column      0
         flux_peak float64           Jy                                                                                                                                                                                         peak ALMA flux in Jy       Column      0
             noise float64           Jy                                                                                                                                         1-sigma noise level (after correcting for the primary beam response)       Column      0
                sn float64                                                                                                                                                                                                                  peak SNR       Column      0
         flux_aper float64           Jy                                                                                                                                                                            flux from the aperture photometry MaskedColumn   1707
        eflux_aper float64           Jy                                                                                                                                                                      flux error from the aperture photometry       Column      0
   flux_peak_imfit float64           Jy                                                                                                                                                           peak flux from the 2D Gaussian fitting using imfit       Column      0
        flux_imfit float64           Jy                                                                                                                                                                flux from the 2D Gaussian fitting using imfit       Column      0
       eflux_imfit float64           Jy                                                                                                                                                          flux error from the 2D Gaussian fitting using imfit       Column      0
         fac_pbcor float64                                                                                                                                                              primary beam response at the position of the source;1=center       Column      0
       id_3dhst_v4 float64                                                                                                                                                                                3D-HST(ver4.0) catalogue id when available MaskedColumn 142476
        ecogal_ver    str4                                                                                                                                                                                                            ecogal version       Column      0
    zsp_best_avail float64                                                                                                                                                                                     best available spectroscopic redshift       Column      0
   zsp_best_survey    str9                                                                                                                                                                                        selected spectroscopic survey name       Column      0
             z_ver    str4                                                                                                                                                                                                           DJA MSA version       Column      0
             objid float64                                                                                                                                                                                                  Unique source identifier MaskedColumn 248862
             srcid float64                                                                                                                                                                                                   Source ID from APT plan MaskedColumn 248862
              file   str55                                                                                                                                                                                                              DJA filename MaskedColumn 248862
           grating    str5                                                                                                                                                                                                           NIRSpec grating MaskedColumn 248862
         file_phot   str44                                                                                                                                                                                   Filename of the DJA photometric catalog MaskedColumn 249835
           id_phot float64                                                                                                                                                                                 ID number in the DJA photometric cadtalog MaskedColumn 249835
             valid    str5                                                                                                                                                                            Redshift matches best z from visual inspection       Column      0
       z_phot_eazy float64                                                                                                                                                          photometric redshift from eazypy combining 3D-HST+DJA photometry       Column      0
             restU float64                                                                                                                                                        flux density of the rest-frame U band from the photoz (eazypy) fit       Column      0
         restU_err float64                                                                                                                                                  flux density error of the rest-frame U band from the photoz (eazypy) fit       Column      0
             restV float64                                                                                                                                                        flux density of the rest-frame V band from the photoz (eazypy) fit       Column      0
         restV_err float64                                                                                                                                                        flux density of the rest-frame V band from the photoz (eazypy) fit       Column      0
             restJ float64                                                                                                                                                        flux density of the rest-frame J band from the photoz (eazypy) fit       Column      0
         restJ_err float64                                                                                                                                                        flux density of the rest-frame J band from the photoz (eazypy) fit       Column      0
           mass_ez float64      solMass                                                                                                                                                                    stellar mass from the photoz (eazypy) fit       Column      0
            sfr_ez float64 solMass / yr                                                                                                                                                             star-formation rate from the photoz (eazypy) fit       Column      0
             Av_ez float64          mag                                                                                                                                                                                   Av the photoz (eazypy) fit       Column      0
             lmass float64      solMass                                                                                                                                                     stellar mass in log from FAST++ fit (spec-z source only) MaskedColumn      8
         l68_lmass float64      solMass                                                                                                                               68% lower boundary of stellar mass in log from FAST++ run (spec-z source only) MaskedColumn      8
         u68_lmass float64      solMass                                                                                                                               68% upper boundary of stellar mass in log from FAST++ run (spec-z source only) MaskedColumn      8
              lsfr float64 solMass / yr                                                                                                                                              star-formation rate in log from FAST++ fit (spec-z source only) MaskedColumn      8
          l68_lsfr float64 solMass / yr                                                                                                                        68% lower boundary of star-formation rate in log from FAST++ fit (spec-z source only) MaskedColumn      8
          u68_lsfr float64 solMass / yr                                                                                                                        68% upper boundary of star-formation rate in log from FAST++ fit (spec-z source only) MaskedColumn      8
         file_alma  str137                                                                                                                                                                       ECOGAL ALMA fits file name (primary beam corrected)       Column      0
           RA_bdsf float64          deg                                                                                                                                                                        ALMA position(RA) based on PYBDSF fit MaskedColumn 255029
          DEC_bdsf float64          deg                                                                                                                                                                       ALMA position(Dec) based on PYBDSF fit MaskedColumn 255029
  Total_flux_pbcor float64           Jy                                                                                                                                     Total flux based on PYBDSF fit (corrected for the primary beam response) MaskedColumn 255029
E_Total_flux_pbcor float64           Jy                                                                                                                               Total flux error based on PYBDSF fit (corrected for the primary beam response) MaskedColumn 255029
             pbfac float64                                                                                                                                          ALMA primary beam response at the position of the detected source;1=phase center MaskedColumn 255029
         Peak_flux float64           Jy                                                                                                                                                 Peak flux from PYBDSF fit (before the primary beam response) MaskedColumn 255029
       E_Peak_flux float64           Jy                                                                                                                                           Peak flux error from PYBDSF fit (before the primary beam response) MaskedColumn 255029
               Maj float64          deg                                                                                                                                                                     the FWHM of the major axis of the source MaskedColumn 255029
             E_Maj float64          deg                                                                                                                                                the 1-sigma error on the FWHM of the major axis of the source MaskedColumn 255029
               Min float64          deg                                                                                                                                                                     the FWHM of the minor axis of the source MaskedColumn 255029
             E_Min float64          deg                                                                                                                                                the 1-sigma error on the FWHM of the minor axis of the source MaskedColumn 255029
                PA float64          deg                                                                                                                                    the position angle of the major axis of the source measured east of north MaskedColumn 255029
              E_PA float64          deg                                                                                                                                      the 1-sigma error on the position angle of the major axis of the source MaskedColumn 255029
     Maj_img_plane float64          deg                                                                                                                                                  the FWHM of the major axis of the source in the image plane MaskedColumn 255029
   E_Maj_img_plane float64          deg                                                                                                                                         the 1-sigma error of the major axis of the source in the image plane MaskedColumn 255029
     Min_img_plane float64          deg                                                                                                                                                  the FWHM of the minor axis of the source in the image plane MaskedColumn 255029
   E_Min_img_plane float64          deg                                                                                                                                         the 1-sigma error of the minor axis of the source in the image plane MaskedColumn 255029
      PA_img_plane float64          deg                                                                                                                 the position angle in the image plane of the major axis of the source measured east of north MaskedColumn 255029
    E_PA_img_plane float64          deg                                                                                                                  the 1-sigma error of the image plane of the major axis of the source measured east of north MaskedColumn 255029
    Isl_Total_flux float64           Jy                                                                                         the total integrated Stokes I flux density of the island in which the source is located (not primary beam corrected) MaskedColumn 255029
  E_Isl_Total_flux float64           Jy                                                                                                                     the 1-sigma error on the total flux density of the island in which the source is located MaskedColumn 255029
           Isl_rms float64    Jy / beam                                                                                                                                    the average background rms value of the island (derived from the rms map) MaskedColumn 255029
            S_Code    str1              a code that defines the source structure; ‘S’ = a single-Gaussian source that is the only source in the island; ‘C’ = a single-Gaussian source in an island with other sources;'M’ = a multi-Gaussian source MaskedColumn 255029
   Separation_bdsf float64       arcsec                                                                                                                                           offset between the optical counterpart (matched within 0.8 arcsec) MaskedColumn 255029

zphot-zspec

### -- getting the unique source and spec-z sources
con_dup = np.array(tab.to_pandas()['id_new'].duplicated())
tab0 = tab[~con_dup]
len(tab0)
128125
con_z = tab0['zsp_best_avail']>0
con_z &= tab0['z_phot_eazy']>0

con_dja = tab0['zsp_best_survey']=='dja'
con_dja_z = np.logical_and(con_dja,con_z)

plt.scatter(tab0[con_z]['zsp_best_avail'], tab0[con_z]['z_phot_eazy'], s=1, zorder=100, label='All spec-z')
plt.scatter(tab0[con_dja_z]['zsp_best_avail'], tab0[con_dja_z]['z_phot_eazy'], marker='s',facecolor='None',edgecolor='grey',alpha=0.5, label='DJA spec-z')

plt.xlabel(r'$z_{\rm spec}$')
plt.ylabel(r'$z_{\rm phot}$')
plt.legend()
<matplotlib.legend.Legend at 0x331825df0>

png

Query if there is any ALMA coverage given the position

  • ALMA/ECOGAL metadata includes information of individual ALMA images such as regions, pixel scales, phase center position, etc.

  • This will allow you to check the ALMA/ECOGAL coverage for your source of interest.

# A complete version of the metadata

version='v1'
meta_file = "ecogal_"+version+"_metadata.fits"

table_url = f"{URL_PREFIX}/ancillary/{meta_file}"
meta = utils.read_catalog(download_file(table_url, cache=CACHE_DOWNLOADS), format='fits')
meta[:3]
GTable length=3
file_almaversionsimplebitpixnaxisnaxis1naxis2naxis3extendbscalebzerobmajbminbpabtypeobjectbunitequinoxradesyslonpolelatpolepc1_1pc2_1pc3_1pc1_2pc2_2pc3_2pc1_3pc2_3pc3_3ctype1crval1cdelt1crpix1cunit1ctype2crval2cdelt2crpix2cunit2ctype3crval3cdelt3crpix3cunit3pv2_1pv2_2restfrqspecsysaltrvalaltrpixvelreftelescopobserverdate-obstimesysobsraobsdecobsgeo-xobsgeo-yobsgeo-zinstrumedistancempiprocschnchnksmemreqmemavailuseweighdateoriginalmaidis_mosaicbandfootprintreleaseis_availablera_centerdec_centernoise_fitnoise_totFoV_sigma
bytes137bytes4boolint64int64int64int64int64boolfloat64float64float64float64float64bytes9bytes26bytes7float64bytes4float64float64float64float64float64float64float64float64float64float64float64bytes8float64float64float64bytes3bytes8float64float64float64bytes3bytes4float64float64float64bytes2float64float64float64bytes4float64float64int64bytes4bytes15bytes26bytes3float64float64float64float64float64bytes4float64int64int64float64float64boolbytes26bytes30bytes14boolint64bytes461bytes3boolfloat64float64float64float64float64
2011.0.00064.S___concat_all_6_AzTEC-3_0_b7_cont_noninter2sig.image.pbcor.fitsv1.0True-323160016001True1.00.00.00020058131880230.0001579564147525-53.50122070312IntensityAzTEC-3Jy/beam2000.0FK5180.02.5868333363111.00.00.00.01.00.00.00.01.0RA---SIN150.0890000048-2.777777777778e-05801.0degDEC--SIN2.5868333363112.777777777778e-05801.0degFREQ296763686486.815646751913.561.0Hz0.00.0296763686486.8LSRK-0.01.0257ALMAriechers2012-04-11T01:22:13.632000UTC150.08900000482.5868333363112225142.180269-5440307.370349-2481029.851874ALMA0.0110.12359619150.23436False2023-11-14T12:19:42.442402CASA 6.5.6-22 CASAtools:v1.0.02011.0.00064.SFalse7((150.088583,2.582778),(150.085914,2.584167),(150.084940,2.587250),(150.086331,2.589917),(150.089417,2.590889),(150.092086,2.589500),(150.093060,2.586417),(150.091669,2.583750),(150.088583,2.582778))N/ATrue150.08900000482.58683333631100254.46259777172499e-055.5606829846510664e-058.332485222950787
2011.0.00064.S___concat_all_6_AzTEC-3_1_b7_cont_noninter2sig.image.pbcor.fitsv1.0True-323160016001True1.00.00.00020078808069230.0001580240825812-53.53054428101IntensityAzTEC-3Jy/beam2000.0FK5180.02.5885277779321.00.00.00.01.00.00.00.01.0RA---SIN150.0868750002-2.777777777778e-05801.0degDEC--SIN2.5885277779322.777777777778e-05801.0degFREQ296763687761.715646752334.741.0Hz0.00.0296763687761.7LSRK-0.01.0257ALMAriechers2012-04-11T01:22:54.720000UTC150.08687500022.5885277779322225142.180269-5440307.370349-2481029.851874ALMA0.0110.12359619150.1451False2023-11-14T13:30:14.601414CASA 6.5.6-22 CASAtools:v1.0.02011.0.00064.SFalse7((150.086458,2.584472),(150.083789,2.585861),(150.082815,2.588944),(150.084206,2.591611),(150.087292,2.592583),(150.089961,2.591194),(150.090935,2.588111),(150.089544,2.585444),(150.086458,2.584472))N/ATrue150.08687500022.58852777793200066.49289000021855e-050.000117142153612803678.33248518715434
2011.0.00097.S___concat_all_10_COSMOSLowz_64_29_b7_cont_noninter2sig.image.pbcor.fitsv1.0True-323184418441True1.00.00.00014458558625650.000138595170444932.57455062866IntensityCOSMOSLowz_64Jy/beam2000.0FK5180.02.1937788888891.00.00.00.01.00.00.00.01.0RA---SIN150.0951-2.777777777778e-05923.0degDEC--SIN2.1937788888892.777777777778e-05923.0degFREQ341959206917.115956638554.121.0Hz0.00.0341959206917.1LSRK-0.01.0257ALMAnscoville2012-04-22T02:13:22.032000UTC150.09512.1937788888892225142.180269-5440307.370349-2481029.851874ALMA0.0--------False2022-01-18T10:06:48.750999CASA 5.6.1-82011.0.00097.STrue7((150.094822,2.190251),(150.092487,2.191390),(150.091570,2.194057),(150.092709,2.196390),(150.095378,2.197307),(150.097713,2.196168),(150.098630,2.193501),(150.097491,2.191168),(150.094822,2.190251))dr1True150.09512.19377888888899970.000139687380281118630.000141854310641065247.231210572315804

Use ecogal function : query metata data based on the coordinates

Use visualcheck.get_footprint function.

import ecogal.visualcheck as visualcheck
# get the metadata via DJA
ra, dec = 34.41887, -5.21965
fp,_ = visualcheck.get_footprint(ra,dec)
There are #15 ALMA projects overlapping
fp['file_alma','almaid','object','band']
GTable length=15
file_almaalmaidobjectband
bytes137bytes14bytes26int64
2012.1.00245.S__all_SXDF-NB2315-2_b7_cont_noninter2sig.image.pbcor.fits2012.1.00245.SSXDF-NB2315-27
2012.1.00245.S__all_SXDF-NB2315-3_b7_cont_noninter2sig.image.pbcor.fits2012.1.00245.SSXDF-NB2315-37
2013.1.00742.S__all_SXDF-B3-NB2315-FoV1_b3_cont_noninter2sig.image.pbcor.fits2013.1.00742.SSXDF-B3-NB2315-FoV13
2013.1.00781.S__all_SXDS-AzTEC23_b6_cont_noninter2sig.image.pbcor.fits2013.1.00781.SSXDS-AzTEC236
2015.1.00442.S__all_SXDS-AzTEC28_b6_cont_noninter2sig.image.pbcor.fits2015.1.00442.SSXDS-AzTEC286
2015.1.01074.S__all_UDSp_17_b7_cont_noninter2sig.image.pbcor.fits2015.1.01074.SUDSp_177
2015.1.01528.S__all_UDS.0113_b7_cont_noninter2sig.image.pbcor.fits2015.1.01528.SUDS.01137
2016.1.00434.S__all_UDS.0113_b7_cont_noninter2sig.image.pbcor.fits2016.1.00434.SUDS.01137
2017.1.00562.S__all_NB2315_b3_cont_noninter2sig.image.pbcor.fits2017.1.00562.SNB23153
2017.1.00562.S__all_NB2315_b6_cont_noninter2sig.image.pbcor.fits2017.1.00562.SNB23156
2017.1.00562.S__all_U4-16795_b9_cont_noninter2sig.image.pbcor.fits2017.1.00562.SU4-167959
2017.1.01027.S__all_U4-16504_b7_cont_noninter2sig.image.pbcor.fits2017.1.01027.SU4-165047
2017.1.01027.S__all_U4-16795_b7_cont_noninter2sig.image.pbcor.fits2017.1.01027.SU4-167957
2019.1.00337.S__all_AS2UDS0113.1_b3_cont_noninter2sig.image.pbcor.fits2019.1.00337.SAS2UDS0113.13
2021.1.00705.S__all_UDS.0113_b4_cont_noninter2sig.image.pbcor.fits2021.1.00705.SUDS.01134

Get ALMA/ECOGAL cutouts

Method 1. Using ecogal

Use ecogal.pbcor.show_all_cutouts function.

import ecogal.pbcor as ecogal_plot

[1] JWST RGB + ALMA cutout

# an example of many ALMA coverage
ra, dec = 34.41887, -5.21965
# this example can take a while because it downloads a lot of fits files
summary_cutouts = ecogal_plot.show_all_cutouts(ra,dec)
N=15
2013.1.00742.S__all_SXDF-B3-NB2315-FoV1_b3       b3   157x 157  0.04  dx=7.57"
2017.1.00562.S__all_NB2315_b3                    b3   313x 313  0.02  dx=7.57"
2019.1.00337.S__all_AS2UDS0113.1_b3              b3    63x  63  0.10  dx=9.84"
2021.1.00705.S__all_UDS.0113_b4                  b4    33x  33  0.20  dx=6.65"
2015.1.00442.S__all_SXDS-AzTEC28_b6              b6   157x 157  0.04  dx=8.32"
2013.1.00781.S__all_SXDS-AzTEC23_b6              b6   313x 313  0.02  dx=8.33"
2017.1.00562.S__all_NB2315_b6                    b6   313x 313  0.02  dx=4.83"
2016.1.00434.S__all_UDS.0113_b7                  b7   157x 157  0.04  dx=6.65"
2012.1.00245.S__all_SXDF-NB2315-3_b7             b7   313x 313  0.02  dx=9.65"
2015.1.01074.S__all_UDSp_17_b7                   b7   313x 313  0.02  dx=9.75"
2015.1.01528.S__all_UDS.0113_b7                  b7   313x 313  0.02  dx=6.66"
2012.1.00245.S__all_SXDF-NB2315-2_b7             b7   313x 313  0.02  dx=0.15"
2017.1.01027.S__all_U4-16504_b7                  b7    63x  63  0.10  dx=9.77"
2017.1.01027.S__all_U4-16795_b7                  b7    63x  63  0.10  dx=0.42"
2017.1.00562.S__all_U4-16795_b9                  b9   313x 313  0.02  dx=0.06"

png

[2] Ready-made summary file

There are some summary png files in the repository made for sources with ALMA detection and DJA spectra (~120 unique sources in total with the first data release), which can be queried by the source position.

  • the default searching area is 0.4 arcsec, that you can change with r_search
ra, dec = 150.14325, 2.35599	
_ = visualcheck.get_summary(ra,dec, r_search=0.5)
There are #10 ALMA projects overlapping
There are 9 ECOGAL+DJA cross-match!
https://s3.amazonaws.com/alma-ecogal/dr1/pngs/ecogal__0_all_filters_COSMOS.60520.png
A source found at a distance of = 0.13 arcsec

ra, dec = 34.27751, -5.22819
_ = visualcheck.get_summary(ra,dec)
There are #1 ALMA projects overlapping
There are 1 ECOGAL+DJA cross-match!
https://s3.amazonaws.com/alma-ecogal/dr1/pngs/ecogal__0_all_filters_UDS.104633.png
A source found at a distance of = 0.13 arcsec

Method 2: Getting cutouts and footprint via DJA API

There are three different output modes:

  • output=footprint : footprint for ALMA coverage
  • output=csv : metadata
  • output=cutout : making a cutout image
    • for cutout module: specify ALMA file names. The file name is available in the ECOGAL catalogue or from the metadata, and the column name is file_alma

footprint mode

https://grizli-cutout.herokuapp.com/ecogal?output=footprint&ra=34.48016&dec=-5.11252

cutout mode

Given the ALMA file name of 2015.1.01528.S__all_UDS.0424_b7_cont_noninter2sig.image.pbcor.fits

https://grizli-cutout.herokuapp.com/ecogal?output=cutout&sx=3.&cutout_size=2.0&ra=34.48016&dec=-5.11252&file_alma=2015.1.01528.S__all_UDS.0424_b7_cont_noninter2sig.image.pbcor.fits

from IPython.display import display, Markdown, Latex
# getting the summary of the footprint for a given ra, dec
ra, dec = 34.48016,-5.11252
cord = SkyCoord(ra,dec, unit=(u.degree, u.degree))
ara = tab['RA_peak_alma']
adec = tab['Dec_peak_alma']
acord = SkyCoord(ara, adec, unit=(u.degree, u.degree))
#search for the matching source within 0.1 arcsec
con_pos = acord.separation(cord).arcsec<0.15
ecotb=tab[con_pos]

#  see also the description in the https://dawn-cph.github.io/dja/blog/2025/05/01/nirspec-merged-table-v4/
#  
cutout_URL = f"https://grizli-cutout.herokuapp.com/ecogal?output=footprint&ra={ra}&dec={dec}"

ecotb['Thumb'] = [
    "<img src=\"{0}\" height=200px>".format(
        cutout_URL.format(ra,dec)
    )
    for row in ecotb
]

df = ecotb['projectID','target_alma','id_new','band','beam_maj','sn','separation_prior','zsp_best_avail','z_phot_eazy','Thumb','file_alma'].to_pandas()

display(Markdown(df.to_markdown()))
  projectID target_alma id_new band beam_maj sn separation_prior zsp_best_avail z_phot_eazy Thumb file_alma
0 2023.1.01520.S 0424.0 UDS.105062 b4 0.69 7.08 0.09 3.5433 3.47313 2023.1.01520.S__all_0424.0_b4_cont_noninter2sig.image.pbcor.fits
1 2015.1.01528.S UDS.0424 UDS.105062 b7 0.21 19.15 0.05 3.5433 3.47313 2015.1.01528.S__all_UDS.0424_b7_cont_noninter2sig.image.pbcor.fits
2 2013.1.00781.S SXDS-AzTEC28 UDS.105062 b6 0.32 18.72 0.06 3.5433 3.47313 2013.1.00781.S__all_SXDS-AzTEC28_b6_cont_noninter2sig.image.pbcor.fits

Access the ALMA/ECOGAL image fits files

  • All fits files (primary beam corrected) are available from the DJA repository (on AWS server) and a frozen version will be available on Zenodo.
#getting the corresponding file name from the catalogue
#some times the file name includes special string like "+", which should be parsed to download the fits file

idx = 2
file_alma = ecotb['file_alma'][idx]
encoded_filename = file_alma.replace("+", "%2B")
fits_URL = "https://s3.amazonaws.com/alma-ecogal/dr1/pbcor/"

almafits = fits.open(
    download_file(str(os.path.join(fits_URL, encoded_filename)), cache=True)
                    )
img = almafits[0].data[0]
hdr = almafits[0].header
wcs_alma = WCS(hdr)

gid = tab[con_pos]['id_new'][idx]
band = tab[con_pos]['band'][idx]
zgal = tab[con_pos]['zsp_best_avail'][idx]
lmass = np.log10(tab[con_pos]['mass_ez'][idx])
sfr = tab[con_pos]['sfr_ez'][idx]

#get the noise of the map (after pb-correction)
noise = tab[con_pos]['noise'][idx]
##################
## plotting; think about adding a function
##################

x,y,_= wcs_alma.wcs_world2pix(ra,dec,0,0)
pixsz = np.abs(hdr['CDELT1']*3600)
imsz = 1/pixsz

noise_array = noise*np.arange(4,30,3)
cutout = img[int(y-imsz):int(y+imsz),int(x-imsz):int(x+imsz)]

fig=plt.figure(1,figsize=(5,5))
ax=plt.subplot(111)

ax.imshow(cutout, origin='lower')
ax.contour(cutout, levels = noise_array, colors='white')
ax.set_title(f'{gid},{band}')
ax.text(0.55,0.95, f'z={zgal}', transform=ax.transAxes, c='white')
ax.text(0.55,0.90, f'log(Mstar/Msun)={lmass:.2f}', transform=ax.transAxes, c='white')
ax.text(0.55,0.85, f'sfr={sfr:.2f} Msun/yr', transform=ax.transAxes, c='white')



#get beam size 
bmaj = hdr['BMAJ']*3600
bmin = hdr['BMIN']*3600
pa = hdr['BPA']
theta = Angle(90+pa,'deg') 
be=mpatches.Ellipse((imsz/6.,imsz/6.),bmaj/pixsz,bmin/pixsz,angle=theta.degree,lw=1,facecolor='grey',edgecolor='black',hatch='//')
ax.add_patch(be)

<matplotlib.patches.Ellipse at 0x346f95010>

png

Access the DJA files from the information available in the catalogue

## consider peak SNR>15 and DJA spectra at z>5

con_sn = tab0['sn']>15
con_sn &= tab0['zsp_best_survey']=='dja'
con_sn &= tab0['zsp_best_avail']>5

tab1 = tab0[con_sn]
filename = tab1['file'][0]
zgal = tab1['zsp_best_avail'][0]
filename, zgal
('capers-cos01-v4_prism-clear_6368_52597.spec.fits', 5.8351)
# prepare a line detectionary
# ** line dictionary -- for plot purpose (you can add more)
# ** lines in AA to overplot the emission lines

lam_file = Table.read("""line, wavelength_nm
H-alpha,656.46
H-beta,486.271
H-delta,410.1734
H-gamma,434.0472
Ly-alpha,121.567
[OII],372.71
[OII],372.986
[OII],733.1
[OII],732.0
[NeIII],386.986
[OIII],496.03
[OIII],500.824
[NII],654.986
[NII],658.527
[SII],671.827
[SII],673.267
Pa-alpha,1875
Pa-beta,1282
Pa-gamma,1093.8
Br-beta,2626
HeI,1083.0
[SIII],906.9
[SIII],953.0
[CI],985.0
[PII],1188
[FeII],1257
[FeII],1640      
""", format="csv")

#lam_file = Table.read('opt_emission_lines.csv')

lines_dic = {'Ly-alpha':r'Ly$\alpha$', 'H-beta':r'H$\beta$', 'H-alpha': r'H$\alpha$ + [NII]', 
             'H-delta':r'H$\delta$','H-gamma':r'H$\gamma$', 'Na1D':'NaID',
             'Pa-alpha':r'Pa$\alpha$','Pa-beta':r'Pa$\beta$','Pa-gamma':r'Pa$\gamma$','CaIIK':'Ca II K',
             '[SiVI]':'[SiVI]','H2':r'H$_2$',
             'Br-beta':r'Br$\gamma$','MgI':'MgI','NaI':'NaI','SiI':'SiI','HI':'[FeII]+HI+FeII',#'HI':'HI'-- for grating
             'HeI':'HeI','FeII':'FeII','[FeII]':'[FeII]','[CI]':'[CI]','[PII]':'[PII]',
             '[OII]': '[OII]', '[NII]':'[NII]', '[SII]':'[SII]', '[OIII]':'[OIII]','[NeIII]':'[NeIII]',
             '[SIII]':'[SIII]'}
lam_file
Table length=27
linewavelength_nm
str8float64
H-alpha656.46
H-beta486.271
H-delta410.1734
H-gamma434.0472
Ly-alpha121.567
[OII]372.71
[OII]372.986
[OII]733.1
[OII]732.0
......
Pa-beta1282.0
Pa-gamma1093.8
Br-beta2626.0
HeI1083.0
[SIII]906.9
[SIII]953.0
[CI]985.0
[PII]1188.0
[FeII]1257.0
[FeII]1640.0

set some functions to get DJA spectra

########################################
### Load the DJA spectra information:
########################################

def loadDJAspec(file_fullpath):
    sh = msaexp.spectrum.SpectrumSampler(file_fullpath, err_median_filter=None)
    wave = np.array(sh.spec["wave"])*1e4 ###in AA
    fnu = sh.spec["flux"] ##uJy
    fnu_err = sh.spec["full_err"] ##uJy

    spec_flambda = np.array((fnu*u.uJy/(wave*u.AA)**2*const.c).to(u.erg/u.s/u.cm**2/u.AA)/(u.erg/u.s/u.cm**2/u.AA))
    spec_flambda_err = np.array((fnu_err/(wave*u.AA)**2*const.c).to(u.erg/u.s/u.cm**2/u.AA)/(u.erg/u.s/u.cm**2/u.AA))
    return(sh,wave,spec_flambda,spec_flambda_err)

#################################################
### settting up the DJA spectra information
#################################################

def get_dja_spectra(file, zsp, restframe=False):
    #plotting in the restframe
    
    root = file.split('_')[0]+'/'
    basename = 'https://s3.amazonaws.com/msaexp-nirspec/extractions/'
    fullname = basename+root+file

    print(f'A galaxy at z={zsp}')
    sampled,lam,galaxy,noise = loadDJAspec(fullname)

    #deredshift
    lam0 = lam/(1 + zsp)
    if restframe:
        lam /=(1 + zsp) # Compute approximate restframe wavelength
    

    ####mask areas
    con_mask = noise==0 
    con_mask |= noise>galaxy[lam > 1100].max()
    galaxy_masked = np.ma.masked_where(con_mask, galaxy)


    galaxy0=galaxy_masked
    noise0=noise
    lam0=lam #in AA
    return lam0, galaxy0, noise0



        
lam0, galaxy0, noise0 = get_dja_spectra(filename, zgal, restframe=True)
plt.plot(lam0[lam0>1300],galaxy0[lam0>1300])
plt.xlabel(f'Rest-Wavelength ($\AA$)')
plt.ylabel(f'Flux (erg/s/cm$^2$/$\AA$)')

##adding line identifiers
lines_plotted=[]
ticker_max = galaxy0.max()
text_hi = ticker_max+1e-20
for kk in range(len(lam_file)):
    lam_idx = np.argmin(np.abs(lam_file['wavelength_nm'][kk]*10-lam0))
    
    if lam_file['wavelength_nm'][kk]*10> lam0.min() and lam_file['wavelength_nm'][kk]*10<lam0.max() and noise0[lam_idx]>0:
        plt.axvline(lam_file['wavelength_nm'][kk]*10, linestyle=':', color='darkgrey')
        if lam_file['line'][kk] not in lines_plotted:
            #lines_plotted.append(lam_file['line'][kk])
            if lam_file['line'][kk] not in ['[NII]']:#if PRISM #'[FeII]','FeII'
                plt.text(lam_file['wavelength_nm'][kk]*10+0.01, text_hi*(0.9-0.1*np.mod(kk,3)), lines_dic[lam_file['line'][kk]], rotation='vertical', fontsize=9)

A galaxy at z=5.8351

png

get source information with multiple DJA spectra

# Full DJA table

table_url = "https://s3.amazonaws.com/msaexp-nirspec/extractions/dja_msaexp_emission_lines_v4.4.csv.gz"
tab00 = utils.read_catalog(download_file(table_url, cache=True), format='csv')


con_sn = tab0['sn']>10
con_sn &= tab0['zsp_best_survey']=='dja'
con_sn &= tab0['zsp_best_avail']>4

tab0[con_sn]['file','objid']
GTable length=6
fileobjid
str55float64
gto-wide-uds13-v4_prism-clear_1215_1951.spec.fits172449.0
capers-cos01-v4_prism-clear_6368_52597.spec.fits141884.0
rubies-uds23-v4_prism-clear_4233_166691.spec.fits149974.0
capers-cos04-v4_prism-clear_6368_36571.spec.fits143258.0
rubies-uds1-v4_prism-clear_4233_37108.spec.fits151060.0
gto-wide-uds13-v4_prism-clear_1215_1472.spec.fits162424.0
## check the alternative spectra information

dja_uniq_id = 172449
print(dja_uniq_id)

#search for other dja spectra
msa = tab00[tab00['objid'] == dja_uniq_id]
msa
172449
GTable length=4
filesrcidradecgratingfiltereffexptmnfilesdatasetmsametmsaidmsacnfdithnslitidrootnpixndetwminwmaxwmaxsnsn10flux10err10sn50flux50err50sn90flux90err90xstartystartxsizeysizeslit_papa_v3srcypixprofcenprofsigctimeversionexptimecontchi2doffullchi2line_ariii_7138line_ariii_7138_errline_ariii_7753line_ariii_7753_errline_braline_bra_errline_brbline_brb_errline_brdline_brd_errline_brgline_brg_errline_hbline_hb_errline_hdline_hd_errline_hei_1083line_hei_1083_errline_hei_3889line_hei_3889_errline_hei_5877line_hei_5877_errline_hei_7065line_hei_7065_errline_hei_8446line_hei_8446_errline_heii_4687line_heii_4687_errline_hgline_hg_errline_lyaline_lya_errline_mgiiline_mgii_errline_neiii_3867line_neiii_3867_errline_neiii_3968line_neiii_3968_errline_nev_3346line_nev_3346_errline_nevi_3426line_nevi_3426_errline_niii_1750line_niii_1750_errline_oi_6302line_oi_6302_errline_oiiline_oii_7325line_oii_7325_errline_oii_errline_oiiiline_oiii_1663line_oiii_1663_errline_oiii_4363line_oiii_4363_errline_oiii_4959line_oiii_4959_errline_oiii_5007line_oiii_5007_errline_oiii_errline_pa10line_pa10_errline_pa8line_pa8_errline_pa9line_pa9_errline_paaline_paa_errline_pabline_pab_errline_padline_pad_errline_pagline_pag_errline_pfbline_pfb_errline_pfdline_pfd_errline_pfeline_pfe_errline_pfgline_pfg_errline_siiline_sii_errline_siii_9068line_siii_9068_errline_siii_9531line_siii_9531_errspl_0spl_0_errspl_1spl_10spl_10_errspl_11spl_11_errspl_12spl_12_errspl_13spl_13_errspl_14spl_14_errspl_15spl_15_errspl_16spl_16_errspl_17spl_17_errspl_18spl_18_errspl_19spl_19_errspl_1_errspl_2spl_20spl_20_errspl_21spl_21_errspl_22spl_22_errspl_2_errspl_3spl_3_errspl_4spl_4_errspl_5spl_5_errspl_6spl_6_errspl_7spl_7_errspl_8spl_8_errspl_9spl_9_errzlineline_civ_1549line_civ_1549_errline_h10line_h10_errline_h11line_h11_errline_h12line_h12_errline_h7line_h7_errline_h8line_h8_errline_h9line_h9_errline_haline_ha_errline_hei_6680line_hei_6680_errline_heii_1640line_heii_1640_errline_nii_6549line_nii_6549_errline_nii_6584line_nii_6584_errline_oii_7323line_oii_7323_errline_oii_7332line_oii_7332_errline_sii_6717line_sii_6717_errline_sii_6731line_sii_6731_errline_siii_6314line_siii_6314_errescale0escale1line_ciii_1906line_ciii_1906_errline_niv_1487line_niv_1487_errline_pah_3p29line_pah_3p29_errline_pah_3p40line_pah_3p40_erreqw_ariii_7138eqw_ariii_7753eqw_braeqw_brbeqw_brdeqw_brgeqw_ciii_1906eqw_civ_1549eqw_ha_niieqw_hbeqw_hdeqw_hei_1083eqw_hei_3889eqw_hei_5877eqw_hei_7065eqw_hei_8446eqw_heii_1640eqw_heii_4687eqw_hgeqw_lyaeqw_mgiieqw_neiii_3867eqw_neiii_3968eqw_nev_3346eqw_nevi_3426eqw_niii_1750eqw_niv_1487eqw_oi_6302eqw_oiieqw_oii_7325eqw_oiiieqw_oiii_1663eqw_oiii_4363eqw_oiii_4959eqw_oiii_5007eqw_pa10eqw_pa8eqw_pa9eqw_paaeqw_pabeqw_padeqw_pageqw_pfbeqw_pfdeqw_pfeeqw_pfgeqw_siieqw_siii_9068eqw_siii_9531line_ha_niiline_ha_nii_erreqw_h10eqw_h11eqw_h12eqw_h7eqw_h8eqw_h9eqw_haeqw_hei_6680eqw_nii_6549eqw_nii_6584eqw_oii_7323eqw_oii_7332eqw_sii_6717eqw_sii_6731eqw_siii_6314sn_lineztimeline_ci_9850line_ci_9850_errline_feii_11128line_feii_11128_errline_pii_11886line_pii_11886_errline_feii_12570line_feii_12570_erreqw_ci_9850eqw_feii_11128eqw_pii_11886eqw_feii_12570line_feii_16440line_feii_16440_errline_feii_16877line_feii_16877_errline_brfline_brf_errline_feii_17418line_feii_17418_errline_breline_bre_errline_feii_18362line_feii_18362_erreqw_feii_16440eqw_feii_16877eqw_brfeqw_feii_17418eqw_breeqw_feii_18362validobjidz_bestztypez_prismz_gratingphot_correctionphot_flux_radiusphot_drfile_photid_photphot_mag_autophot_f090w_tot_1phot_f090w_etot_1phot_f115w_tot_1phot_f115w_etot_1phot_f150w_tot_1phot_f150w_etot_1phot_f200w_tot_1phot_f200w_etot_1phot_f277w_tot_1phot_f277w_etot_1phot_f356w_tot_1phot_f356w_etot_1phot_f410m_tot_1phot_f410m_etot_1phot_f444w_tot_1phot_f444w_etot_1phot_Avphot_massphot_restUphot_restVphot_restJz_photphot_LHaphot_LOIIIphot_LOIIgradezgradereviewercommentzrfescaleobs_239_validobs_239_fracobs_239_fluxobs_239_errobs_239_full_errobs_205_validobs_205_fracobs_205_fluxobs_205_errobs_205_full_errobs_362_validobs_362_fracobs_362_fluxobs_362_errobs_362_full_errobs_363_validobs_363_fracobs_363_fluxobs_363_errobs_363_full_errobs_364_validobs_364_fracobs_364_fluxobs_364_errobs_364_full_errobs_365_validobs_365_fracobs_365_fluxobs_365_errobs_365_full_errobs_366_validobs_366_fracobs_366_fluxobs_366_errobs_366_full_errobs_370_validobs_370_fracobs_370_fluxobs_370_errobs_370_full_errobs_371_validobs_371_fracobs_371_fluxobs_371_errobs_371_full_errobs_375_validobs_375_fracobs_375_fluxobs_375_errobs_375_full_errobs_376_validobs_376_fracobs_376_fluxobs_376_errobs_376_full_errobs_377_validobs_377_fracobs_377_fluxobs_377_errobs_377_full_errobs_379_validobs_379_fracobs_379_fluxobs_379_errobs_379_full_errobs_380_validobs_380_fracobs_380_fluxobs_380_errobs_380_full_errobs_381_validobs_381_fracobs_381_fluxobs_381_errobs_381_full_errobs_382_validobs_382_fracobs_382_fluxobs_382_errobs_382_full_errobs_383_validobs_383_fracobs_383_fluxobs_383_errobs_383_full_errobs_384_validobs_384_fracobs_384_fluxobs_384_errobs_384_full_errobs_385_validobs_385_fracobs_385_fluxobs_385_errobs_385_full_errobs_386_validobs_386_fracobs_386_fluxobs_386_errobs_386_full_errrest_120_validrest_120_fracrest_120_fluxrest_120_errrest_120_full_errrest_121_validrest_121_fracrest_121_fluxrest_121_errrest_121_full_errrest_218_validrest_218_fracrest_218_fluxrest_218_errrest_218_full_errrest_219_validrest_219_fracrest_219_fluxrest_219_errrest_219_full_errrest_270_validrest_270_fracrest_270_fluxrest_270_errrest_270_full_errrest_271_validrest_271_fracrest_271_fluxrest_271_errrest_271_full_errrest_272_validrest_272_fracrest_272_fluxrest_272_errrest_272_full_errrest_274_validrest_274_fracrest_274_fluxrest_274_errrest_274_full_errrest_153_validrest_153_fracrest_153_fluxrest_153_errrest_153_full_errrest_154_validrest_154_fracrest_154_fluxrest_154_errrest_154_full_errrest_155_validrest_155_fracrest_155_fluxrest_155_errrest_155_full_errrest_156_validrest_156_fracrest_156_fluxrest_156_errrest_156_full_errrest_157_validrest_157_fracrest_157_fluxrest_157_errrest_157_full_errrest_158_validrest_158_fracrest_158_fluxrest_158_errrest_158_full_errrest_159_validrest_159_fracrest_159_fluxrest_159_errrest_159_full_errrest_160_validrest_160_fracrest_160_fluxrest_160_errrest_160_full_errrest_161_validrest_161_fracrest_161_fluxrest_161_errrest_161_full_errrest_162_validrest_162_fracrest_162_fluxrest_162_errrest_162_full_errrest_163_validrest_163_fracrest_163_fluxrest_163_errrest_163_full_errrest_414_validrest_414_fracrest_414_fluxrest_414_errrest_414_full_errrest_415_validrest_415_fracrest_415_fluxrest_415_errrest_415_full_errrest_416_validrest_416_fracrest_416_fluxrest_416_errrest_416_full_errbetabeta_ref_fluxbeta_npixbeta_wlobeta_whibeta_nmaddla_npixdla_valuedla_uncbeta_cov_00beta_cov_01beta_cov_10beta_cov_11
str57int64float64float64str5str6float64int64str72str25int64int64int64int64str24int64int64float64float64float64float64float64float64float64float64float64float64float64float64int64int64int64int64float64float64float64float64float64float64str30float64float64int64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64str5int64float64str1float64float64float64float64float64str44int64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64int64float64str4str93float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64int64float64float64float64float64float64float64int64float64float64float64float64float64float64float64float64float64float64
excels-uds01-v4_g235m-f170lp_3543_109269.spec.fits10926934.35062413-5.14987821G235MF170LP6565.06jw03543001001_05101_00002_nrs1_f170lp_g235m_raw.113.3543_109269.fitsjw03543001001_02_msa.fits6121113excels-uds01-v4277511.60523814.57525732.81565710.66378920.186908350.1052767562.24394820.426148150.179134134.08941030.88038350.5585832650514341544340.056.9097370.00.0010.74323141737361758.03376650.9.4.dev7+g92b1aa639390.021056.3827754609.642638.1352113.53396.2305715.9514675----------------421.7884512.25353940.83299.549703--------77.9442211.366782-18.49447814.979722----10.2970218.836235160.588789.798167--------99.2030511.217545533.6721913.3871485.1325214.60536-8.73928312.896657----45.19025416.34102760.06665----17.633625------31.5436158.97263475.6516412.4923011478.719520.716312----------------------------------------------------------2.69166351.02926061.76236941.20841380.159368230.77346180.1092582641.5076850.097979590.941813950.096818451.17772080.1016513850.778270240.11489711.01618060.150892060.772057830.29294607-0.368061961.5045673-4700.3892830.57180.38631132.51916310.00.00.00.00.00.00.220102411.95523730.12842322.3575760.102184562.20457650.0804555341.8396890.072078581.95908140.0716446641.71625420.077689741.45217620.082387544.622439-----23.88004110.763638-4.21606810.945385-10.38003910.46370334.73071312.58505763.8607211.191996-11.49343810.9105421681.471822.707413-3.884336713.712671----92.76910413.244619303.342214.01827732.4074314.73695416.25057615.096581101.7147913.087306102.2770512.364596-1.530984611.467584-0.009823302-0.121039405----------------33.23996.5497913--------------224.4988918.628468----48.388504-15.68925----5.406689680.58066----43.5218914.8675652.3390548-4.0933743----30.003298341.56543------15.96317259.9941822.1586---------------------------------10.549018-1.8727355-4.63383915.34104628.01381-5.0520831117.2476-2.832585861.117584204.4885632.1279116.23694277.4847179.08182-1.00996474.01737501800.0------------------------------------------------------------True1724494.6228543G4.6215824.62285431.425.580.07257426primer-uds-north-grizli-v7.2-fix_phot.fits3978723.860.29176659943328620.00745835209426020350.3758223233385980.0074742586318044410.44621158445568650.0064404276493320010.57397989446778470.00551312306007662250.84356759235092180.0047415835913716241.00948827352212470.00471437536860440550.88930533721385170.0073197983988069980.93248024707031170.0064055659448006261.769778101145008432809883821.6441650.509837750.85152031.71898964.39068841693531123.12067562439001724.140659491718980.061100734.62244GBr--4.6224387590076680.74656688392377727750.00.0-1.0-1.027750.257349463347073260.10740292183922340.136369441103519170.1087719337910259827750.00013941477819138190.0-1.0-1.027757.565232436087342e-050.0-1.0-1.027753.422394938541863e-050.0-1.0-1.027750.183654826621415270.082098529788242750.167339419530450230.1334748319585305827750.99998559485371210.31932196326641320.0050462637331229960.00399020087175682427750.99999418430693290.25377922569408760.0073931426867225950.005859048616848037427750.99999978345780570.380335100717340950.0071669744241209750.00566243893578468727751.04458118603856030.51740153314432490.0053261519901072520.00412305361033587827750.95927286840844840.6745018550004720.0105662957176877980.00789007851842686627750.68647664612952060.57922019424957570.0202251259584320140.01465446647866136927750.99992020459972510.429097519374822430.0081240195359323830.00630806092881876227751.13398071359042230.395991407145957150.0091809659750243540.00697904475897215427750.91557593491247120.43441440496799260.0120061508619827320.00898695027133847127751.00037081021005840.92539139255793290.015876403163767970.01194562966864433427750.99996294443725140.60121304103825950.0209542296791421050.01528744591322381327750.9999523827689610.58475513434910330.0345968029849937140.02506850515324459527750.2717429488887240.3857865717627310.090411929514558330.0648628356886288427750.0008707652505335630.0-1.0-1.027750.00.0-1.0-1.027750.00423352556868361250.0-1.0-1.027750.00.0-1.0-1.027750.302974384383537470.07291371261998590.178755729743772570.142580822211009527750.00.0-1.0-1.027750.00.0-1.0-1.027750.00.0-1.0-1.027750.2211925775581921-0.105630516229403840.41362965779374120.329924593560386627751.00003370853336440.337386684000136660.0049501997133148840.00391512068109804227751.00011810691057980.45486659530942920.00437500333353669450.003411465472288634227751.0016996161901920.45049446997083050.0070855186844952330.00539840179414354427751.00000889894961120.325475925964423260.0054078435536040750.00427637038243981127751.00043913190193520.53305394955182110.0049041240905993880.003821276538650555327750.96756559461569060.67158570979165740.0105537958802706280.0079432480903028727750.95874680932730360.58336247608236220.0194153538647165760.01409035663350078327750.0106346762416460130.0-1.0-1.027750.00.0-1.0-1.027750.00.0-1.0-1.027750.00.0-1.0-1.027750.59465321859305130.143785609883504060.080656306506196570.0643317625525549327750.99917000009262020.436132376755631770.0075827461978066630.005882422201278385427750.99934847778788480.59722171450157180.0221660013538589050.016079926523872485----0--------------------
gto-wide-uds13-v4_g235h-f170lp_1215_1951.spec.fits195134.35065901-5.14988767G235HF170LP802.3894jw01215013001_04101_00001_nrs2_f170lp_g235h_raw.70.1215_1951.fitsjw01215013001_01_msa.fits2051170gto-wide-uds13-v4224311.662.56891422.0963542-0.4861431-0.76567411.25939890.493435320.82248261.58585581.53045342.4590352.1690035113672048400.0253.849960.0-0.0010.49176791738073094.40703850.9.5.dev2+g80b81b41604.7782913.674822432811.6072----------------------------139.0327984.556435------------------------153.8161261.984585--------4.036922578.6098345.68170580.60967-50.98967787.7149273.970177.34231--------853.96075----94.13828-------30.71053161.72949-------------------------------------------------------------------1.07939352.657897716.8558966.0944111.05317835.00594471.09056543.18874671.25973054.45998572.4125624-0.02466108812.6989640.00.00.00.00.00.00.00.00.00.03.1934314-15.3881870.00.00.00.00.00.04.4179719.6017792.19342238.9636851.65063677.1661411.33674758.3720351.21251074.26637741.23175954.64916231.15570223.88286881.08954664.6232686----47.930361.00501-43.6645273.04057-52.86496769.194349.7313574.62461-10.00257282.228905-74.39123564.71364----------------------------------------0.008058175-0.11264437------------------------------------27.334742--------------35.321674----0.901568310.652017-5.75122649.181498------154.39067-------7.458391------------------------------------10.362592-9.0206-10.35602611.604869-2.242879-16.51436------------------9.11737732200.0------------------------------------------------------------True1724494.6228543G4.6215824.62285431.855.580.07257426primer-uds-north-grizli-v7.2-fix_phot.fits3978723.860.29176659943328620.00745835209426020350.3758223233385980.0074742586318044410.44621158445568650.0064404276493320010.57397989446778470.00551312306007662250.84356759235092180.0047415835913716241.00948827352212470.00471437536860440550.88930533721385170.0073197983988069980.93248024707031170.0064055659448006261.769778101145008432809883821.6441650.509837750.85152031.71898964.39068841693531123.12067562439001724.140659491718980.061100734.62327AutoRedshift matches gto-wide-uds13-v3_g395h-f290lp_1215_1951 z=4.62004.6232685499098020.709456638881514622430.00.0-1.0-1.022430.083691590145044890.0-1.0-1.022430.000134752121311073870.0-1.0-1.022437.249783264163463e-050.0-1.0-1.022433.2292668859647866e-050.0-1.0-1.022430.0282562457731430070.0-1.0-1.022431.03306078109461890.7518296714297640.049730139772867070.03505414077391367422430.95240845068388980.62077772864057670.07365738401822490.05182535164970092422430.99999325117785880.89085270895061190.071847633338447870.0507420817880656822430.233106790855914180.81777576499431350.085669650468178290.0608689089796093322435.297289023649329e-060.0-1.0-1.022438.489538935327642e-050.0-1.0-1.022430.86066067963849080.81788035777383830.087375034796877010.06207465732495831622438.430932664970874e-060.0-1.0-1.022436.407891996424609e-060.0-1.0-1.022435.218707652222712e-060.0-1.0-1.022432.556004809596254e-060.0-1.0-1.022434.739559277072582e-060.0-1.0-1.022435.993161422598339e-050.0-1.0-1.022430.000148670000814431580.0-1.0-1.022430.00.0-1.0-1.022430.00135848498352280.0-1.0-1.022430.00.0-1.0-1.022430.0290870783938803680.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022431.00465456271059830.79272402927996470.049087290061522040.0346340389621928322430.73806431842625480.85028849649057750.05570173491176360.03949338160150437522430.00.0-1.0-1.022431.00472001852256040.90226537416446920.053949736303127480.0380545011590011422430.3978842869223480.86323279992577970.059183548378377830.0420075875027193922430.00.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022430.00.0-1.0-1.022430.319745270180893050.3072443703164660.087453013573204090.0613896897903287622430.68030230237934080.81331012677239940.090389079338019910.0642163815758274322430.00.0-1.0-1.0----0--------------------
gto-wide-uds13-v4_g395h-f290lp_1215_1951.spec.fits195134.35065901-5.14988767G395HF290LP875.3334jw01215013001_07101_00001_nrs1_f290lp_g395h_raw.70.1215_1951.fitsjw01215013001_01_msa.fits2071170gto-wide-uds13-v4218112.834.3332573.0323372-0.78633463-15.71353912.1728050.0238156060.373342618.1839220.8675502516.77023729.42786416131366436240.0253.84990.00.00099999980.49176791738073098.92303820.9.5.dev2+g80b81b41750.6662725.717321812691.675523.426165412.58319.938076307.09857--------------------------------1451.3488428.447899.84564273.67517----------------------------------------845.74225630.42847-------------------------------------------------------------------------------------14.73979216.29617312.9411331.02383393.397932-3.89114953.70977527.11492163.9599311-7.77667146.36292737.8243421.133274-1564.3295707.89160.00.00.00.00.00.00.00.020.1023549.972840.00.00.00.00.00.016.226713-5.6475356.898581519.8417325.6790743-17.2085844.401540812.0064473.8504024-5.29018263.576970310.4832843.5806997-0.0448386453.35363154.5170674-----------------------------6.600751413.0291735.67981398.38538----261.49884355.15863129.73485455.60483-77.98808304.731051188.4515320.5895-734.2784440.50098-461.14597403.66617-347.5903561.14636-0.05869624-0.35027233-----------------53.5106547.888203----------------------486.24625435.344------------------------213.96024-----------------------------------------------------------1.97491235.720995494.40948531.44778370.47738-1292.1211-123.25613-80.68548-96.065163.71737732200.0------------------------------------------------------------False1724494.6228543G4.6215824.62285431.855.580.07257426primer-uds-north-grizli-v7.2-fix_phot.fits3978723.860.29176659943328620.00745835209426020350.3758223233385980.0074742586318044410.44621158445568650.0064404276493320010.57397989446778470.00551312306007662250.84356759235092180.0047415835913716241.00948827352212470.00471437536860440550.88930533721385170.0073197983988069980.93248024707031170.0064055659448006261.769778101145008432809883821.6441650.509837750.85152031.71898964.39068841693531123.12067562439001724.140659491718980.0611007--------4.5170672327779310.564860788478507821810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.378372806033187350.30073378877350320.74446020128737310.490704770112601121810.99997725815630871.0849590560588270.53790136814100730.3258501599646858621810.46571906088239290.316456122429764450.90230311614666590.502937109961654621810.000103458983994215680.0-1.0-1.021810.97137510203228260.457418632290097940.68870623543304750.452032368299819321810.99997883684430160.63063891826112220.83783928458635390.521586851955781621810.99991777977921651.56958255509102430.73398784084696040.439270433698185521810.98992885070480440.33781143559150890.87274104008912750.488844949655945121810.72624105927876840.72878325700327311.62514510261262380.889636331857754621810.00020465581692088940.0-1.0-1.021818.095252757928491e-050.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.0254781012251645250.0-1.0-1.021810.82917427996905710.464369903428483330.5853868721160590.3825571880849472621810.00.0-1.0-1.021810.15580905088338265-0.122382824001332341.18902953049758420.79528513113441721811.0007955356758030.94723197765313770.59816004549351360.3701599690609964621810.7884540479681250.48609976891580190.79507711314552080.446923297492038321813.0335519041963066e-050.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.00.0-1.0-1.021810.86201012639976390.327003048833010730.88946548014562950.4967532214376828----0--------------------
gto-wide-uds13-v4_prism-clear_1215_1951.spec.fits195134.35065901-5.14988767PRISMCLEAR802.3893jw01215013001_03101_00002_nrs2_clear_prism_raw.70.1215_1951.fitsjw01215013001_01_msa.fits11170gto-wide-uds13-v446810.549125975.50183343.68473222.32431390.254639330.026172359.3024950.525888860.05672894815.8331740.813775360.2462121411359506280.0253.850.00.0010.49176791738073090.45903830.9.5.dev2+g80b81b42407.1675617.831468613.400448.81281322.620071-2.43898720.292538----------------560.3777546.5238871.5108562.164665-----209.0797133.749680.51485428.13365440.7857123.21867660.54590223.91554396.5061643.993908291.3935275.85304-716.07837280.8714657.39623118.88307514.75586138.25935124.9183669.4759116.87719589.80219-47.7029494.66547447.62188198.2818999.0163832.63919733.2995652.6719621.67851383.931694--202.1944241.93048-169.2497372.94585932.392551.2134742339.160470.73323---12.02763730.294546260.6562245.92269-66.2230432.629578--------------------------------241.5833727.795877126.8822133.298237228.2963342.90715840.98921224.23347313.5295441.53098260.0668413861.2147470.0654479861.2784380.068561481.10275630.0708167851.02494170.0630152150.890603240.066679060.863898460.071084390.6518140.082727430.892115350.0982066540.7999550.13572117.265528722.441030.55887010.202403320.8701770.26910640.256994630.492328142.70035514.0981360.9542901510.1803530.39419785.2171680.220239363.39105840.157952492.85738090.128474272.12954570.0949365351.66466440.068344154.621582-649.9793196.06087---------------------------------323.86383244.54553-----------------------------0.020892859-0.019805139164.59029193.0386363.44467219.52042--------43.720543-2.5788078--------17.805237-53.110912274.049278.2447525.7951---70.5157155.21557235.79257680.42899-28.52515644.31549115.00771-52.4203312.157452172.5845643.145094.735929-13.8351314.56473328.05231377.97484235.5395449.396652--18.168468-67.426506482.791441235.6241-14.254797377.87656-86.09008----------------195.16728151.96198334.706822837.588958.07976------------------------------48.91737732200.0------------------------------------------------------------True1724494.6228543G4.6215824.62285431.855.580.07257426primer-uds-north-grizli-v7.2-fix_phot.fits3978723.860.29176659943328620.00745835209426020350.3758223233385980.0074742586318044410.44621158445568650.0064404276493320010.57397989446778470.00551312306007662250.84356759235092180.0047415835913716241.00948827352212470.00471437536860440550.88930533721385170.0073197983988069980.93248024707031170.0064055659448006261.769778101145008432809883821.6441650.509837750.85152031.71898964.39068841693531123.12067562439001724.140659491718980.061100734.62158AutoRedshift matches gto-wide-uds13-v3_g395h-f290lp_1215_1951 z=4.62004.6215818223666230.97108918291320174680.99931187732236240.297345287368543040.0050725100880407350.0057671776762988734681.00499205547901840.393580777257697360.0067549192465975960.0075320346582501854680.99941215890904590.21051690707795250.0057406637807352140.0065002766154227234681.00483313872040240.31427745786778980.00569726255184620.0064755896321601454681.00578029542423250.36338551756438990.0055521402602133170.00632323308909434754680.99693787404460780.3900864612676870.0060319484282636830.0067404626344621284680.99955453896318470.474286999296680940.0060872528641253720.0066447087825195584680.99495833584639190.42216954786398170.0081933610346360960.0089540260979210974680.99663989150137570.53306877351952390.009209356172428410.0100744247050554624681.0001357431027050.65857271863069610.005403493880405120.0058763149914546994681.00013774560664180.73941494232403860.0063236972216453260.00657843647415761254681.0000135670620850.61663115284743460.0086959886832214480.0081208343963060634680.99739993435266640.51232150540810250.0095293157240517770.0101622162892088694680.99984093274026230.56265092498234650.0077732873586725840.0080419472496916694680.99953296666652480.53961413625242080.0081871839437407510.0082207090806280894680.99996587108445710.93435327855731410.0096785913263813280.0104726755672192384681.00001430394332270.61987059973792210.0105207143709352780.0100782244938471634680.99975442088574470.60463180932711350.0165839680306032330.0156686152139237964681.00044031382300380.61046818523429650.0206204812996903760.019065157769290854680.99975862164716910.61814436271827080.021076738530111410.0192613525788099644681.00056859887945460.30693433388927470.0055832518962781260.0063499448216635274681.00031046197706440.37617507728276210.0043129069829441250.0048818839758859834680.99041317083763460.318022419512767330.0060280626749118580.0068531235549381714681.01077843200428190.3896902934395620.0084034197504122640.0093420994158070054681.00652327683654640.296512597002468460.0069429862854918340.0079033900375131494680.98475649795752220.323206051845095540.0084701502530873330.0096144903341584164681.01571880805442260.359585871572219050.008705281222085330.0098802075696683044681.00886704295383730.39768709001436640.0106500060761624950.0118693498336187074680.99961701065201320.4906474263814740.0061741410105441290.0067498642919289564681.0001847524600220.56868094419133870.0052804875016632250.0056844996408233984681.00014711645800110.6178241197762920.0058993189105843390.006161023266307294681.00012791665653360.47702550757606390.00664227086801747350.007255405697753864680.99999698654922990.65482369503652180.0051249022700812130.0056172700972459554680.99999985151259550.75759543608605350.0068382874970659630.0072371383068888764680.99973554347417370.61947142879174430.0090745227272573030.0086168951713262984680.92147085716483560.6683456535239440.020388971554850260.018301673408882314680.00.0-1.0-1.04680.00.0-1.0-1.04680.00.0-1.0-1.04681.0271026874464680.39105166136900730.0079455096610144010.0087881830194002684680.99843097463695710.52304355412673430.008875569807922510.0094629194318379484681.00437793572066080.61768136609355050.0106988285627730890.010147776185419594-1.45652064793650850.3061252990650476440.1403621198618130.25671459195207271.19540543417518315.018.5631673665753035.1446091370229970.0021474377023419544-0.0001561310838130919-0.000156131083813091881.803142058546427e-05

#  see the description in the https://dawn-cph.github.io/dja/blog/2025/05/01/nirspec-merged-table-v4/
#  
RGB_URL = "https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord={ra}%2C{dec}"
msa['metafile'] = [m.split('_')[0] for m in msa['msamet']]
SLIT_URL = "https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord={ra}%2C{dec}&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile={metafile}"
FITS_URL = "https://s3.amazonaws.com/msaexp-nirspec/extractions/{root}/{file}"

msa['Thumb'] = [
    "<img src=\"{0}\" height=200px>".format(
        RGB_URL.format(**row['ra','dec'])
    )
    for row in msa
]

msa['Slit_Thumb'] = [
    "<img src=\"{0}\" height=200px>".format(
        SLIT_URL.format(**row['ra','dec','metafile'])
    )
    for row in msa
]

msa['Spectrum_fnu'] = [
    "<img src=\"{0}\" height=200px>".format(
        FITS_URL.format(**row['root','file']).replace('.spec.fits', '.fnu.png')
    )
    for row in msa
]

msa['Spectrum_flam'] = [
    "<img src=\"{0}\" height=200px>".format(
        FITS_URL.format(**row['root','file']).replace('.spec.fits', '.flam.png')
    )
    for row in msa
]

df = msa['root','file','z_best','phot_mass','eqw_ha_nii','Thumb','Slit_Thumb','Spectrum_fnu', 'Spectrum_flam'].to_pandas()

display(Markdown(df.to_markdown()))
  root file z_best phot_mass eqw_ha_nii Thumb Slit_Thumb Spectrum_fnu Spectrum_flam
0 excels-uds01-v4 excels-uds01-v4_g235m-f170lp_3543_109269.spec.fits 4.62285 3.28099e+10 nan
1 gto-wide-uds13-v4 gto-wide-uds13-v4_g235h-f170lp_1215_1951.spec.fits 4.62285 3.28099e+10 nan
2 gto-wide-uds13-v4 gto-wide-uds13-v4_g395h-f290lp_1215_1951.spec.fits 4.62285 3.28099e+10 nan
3 gto-wide-uds13-v4 gto-wide-uds13-v4_prism-clear_1215_1951.spec.fits 4.62285 3.28099e+10 2274.05
# Reading the spectrum

for i in range(len(df)):
    spec_file = df['file'][i]
    row = msa[msa['file'] == spec_file][0]
    spec = msaexp.spectrum.SpectrumSampler(FITS_URL.format(**row))

    ## 
    con_mask = spec['full_err']==0 
    con_mask |= spec['full_err']> spec['flux']

    galaxy_masked = np.ma.masked_where(con_mask, spec['flux'])
    plt.plot(spec['wave'], galaxy_masked,
         label="{file}\nz={z_best:.3f}".format(**row), alpha=0.5)


plt.xlim([0.8,6])
plt.ylim(top=galaxy_masked.max()*2)
plt.semilogx()
plt.legend(fontsize=7, ncol=1)
<matplotlib.legend.Legend at 0x3117895e0>

png