HETDEX AGN Catalog 1

import os.path as op
import numpy as np
from astropy.io import ascii, fits
from astropy.io.fits import getdata
from astropy.table import Table, Column,join
# fill in the path to the HETDEX AGN Catalog 1 file

path_to_agn1 = "/home/jovyan/Hobby-Eberly-Public/HETDEX/catalogs/agn_catalog_v1.0/"

if op.exists(path_to_agn1):
    pass
else:
    path_to_agn1 = "/corral-repl/utexas/Hobby-Eberly-Telesco/public/HETDEX/catalogs/agn_catalog_v1.0/"

Check basic info of the fits file

There are six extensions, 1 & 4 are table extensions, 2,3 & 5,6 are image extensions for spectra and their errors.

There are three major differences between ext2&3 and ext5&6.

(1) We provide two types of spectra with their errors in ext 2&3 and ext5&6: As an IFU survey, some spacially extended AGNs can be spacially resolved with multiple detections in the hetdex catalog. We do flux weighted friend-of-friend grouping for all AGN detectids with linking length of delta_r=5 arcsec, and delta_redshift = 0.1 to make the unqiue AGN catalog (extension 1). For each AGN, we pick up the detectid closest to the fof center as detectid_best.

ext 2&3 are the spectra for the detectid_best in the hetdex catalog.
ext5&6 are extracted spectra at the flux weighted friend-of-friend center.

(2) Aonther difference between ext2&3 and ext5&6 is the number of rows are different.
ext2&3 have 5322 rows, one row for one agn, arranged in the same order with extension 1.
ext5&6 have 6004 rows. This is because there are some AGNs that have repeat observations (identified by “shotid” in the table of extension 4). We provide all the spectra for repeated observations in ext 5&6. In the table of extension 4, each observation has one row, and the row number of ext5&6 are arranged following extension4.

(3) A minor difference is:
ext2&3 spectra with errors are applied with universal extinction correction of E(B-V)=0.02.
ext5&6 are raw data with no extinction applied.
The extinction correction only makes a <10% difference.

fname = op.join( path_to_agn1, 'hetdex_agn.fits')
hdul = fits.open(fname)
hdul.info()
Filename: /corral-repl/utexas/Hobby-Eberly-Telesco/public/HETDEX/catalogs/agn_catalog_v1.0/hetdex_agn.fits
No.    Name      Ver    Type      Cards   Dimensions   Format
  0  PRIMARY       1 PrimaryHDU       4   ()      
  1  basic_info    1 BinTableHDU    735   5322R x 159C   [K, E, E, E, E, K, 10A, K, K, E, E, E, K, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, 38A, E, E, E, E, 16A, E, E, E, E, 16A, E, E, E, E, 16A, E, 15A, E, E, K, K, K, E, K, E]   
  2  flux_array    1 ImageHDU        11   (1036, 5322)   float32   
  3  error_array    1 ImageHDU        11   (1036, 5322)   float32   
  4  repeat_info    1 BinTableHDU     15   6004R x 3C   [K, K, K]   
  5  flux_array_repeat    1 ImageHDU        11   (1036, 6004)   float32   
  6  error_array_repeat    1 ImageHDU        11   (1036, 6004)   float32   

Read extension 1 as a table

extension 1 has the basic information for each unique AGN, one row per AGN.

agn = Table.read( fname, format = 'fits', hdu = 1 )
agn
Table length=5322
agnidradeczz_erzflagfieldnshotsdetectid_bestra_bestdec_bestroffnmemalphaalpha_erfpl0fpl0_erslopeslope_erinterceptintercept_erL1350L1350_erL1450L1450_erL3000L3000_erL5100L5100_erfwhm_LyAfwhm_LyA_erew_LyAew_LyA_erflux_LyAflux_LyA_ercont_LyAcont_LyA_ersnr_LyAsnr_LyA_erchi2_LyAchi2_LyA_erfwhm_NVfwhm_NV_erew_NVew_NV_erflux_NVflux_NV_ercont_NVcont_NV_erfwhm_SiOfwhm_SiO_erew_SiOew_SiO_erflux_SiOflux_SiO_ercont_SiOcont_SiO_ersnr_SiOsnr_SiO_erchi2_SiOchi2_SiO_erfwhm_CIVfwhm_CIV_erew_CIVew_CIV_erflux_CIVflux_CIV_ercont_CIVcont_CIV_ersnr_CIVsnr_CIV_erchi2_CIVchi2_CIV_erfwhm_HeIIfwhm_HeII_erew_HeIIew_HeII_erflux_HeIIflux_HeII_ercont_HeIIcont_HeII_ersnr_HeIIsnr_HeII_erchi2_HeIIchi2_HeII_erfwhm_CIIIfwhm_CIII_erew_CIIIew_CIII_erflux_CIIIflux_CIII_ercont_CIIIcont_CIII_ersnr_CIIIsnr_CIII_erchi2_CIIIchi2_CIII_erfwhm_MgIIfwhm_MgII_erew_MgIIew_MgII_erflux_MgIIflux_MgII_ercont_MgIIcont_MgII_ersnr_MgIIsnr_MgII_erchi2_MgIIchi2_MgII_erfwhm_OIIfwhm_OII_erew_OIIew_OII_erflux_OIIflux_OII_ercont_OIIcont_OII_ersnr_OIIsnr_OII_erchi2_OIIchi2_OII_erfwhm_OVIfwhm_OVI_erew_OVIew_OVI_erflux_OVIflux_OVI_ercont_OVIcont_OVI_ersnr_OVIsnr_OVI_erchi2_OVIchi2_OVI_erfiberidr_aperr_aper_err_radiusr_depthr_catg_aperg_aper_erg_radiusg_depthg_catu_aperu_aper_eru_radiusu_depthu_catrsep_dr14qid_dr14qz_dr14qrsep_dr16plate_dr16fiber_dr16mjd_dr16z_dr16sflagapcor
degdegdegdegarcsec1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / skm / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)magmagarcsecarcsecmagmagarcsecarcsecmagmagarcsecarcsecarcsecarcsec
int64float32float32float32float32int64bytes10int64int64float32float32float32int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32bytes38float32float32float32float32bytes16float32float32float32float32bytes16float32float32float32float32bytes16float32bytes15float32float32int64int64int64float32int64float32
112.274719-0.52619884.1650.001281dex-fall1210137014612.274748-0.5262090.110353.70.227269923.2810827e-120.5094230.02363970.0015818-19.98861.352628.652.60440.093.6211221.91111.714796.171368.549-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.023484.5547.7862292.5551.5641070.967.3410.470.04460.3210.3564.140.05320191006024_1_multi_323_043_040_LU_070-99.0-99.0-99.0-99.0?22.00720.02051.863924.7DECAM/SHELA-99.0-99.0-99.0-99.0?0.068781433590-55201-02224.1650.068781433590222552014.16518700.943
2210.399851.953244.1488e-051dex-spring12101001922210.3995751.9530560.83427-99.00.40755767-99.052674527000.0-0.00164230.00109591.3070.9362-20.67.385-26.119.506-182.0473.009-604.31315.057-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.024464.00.09999.01596.5711538.9616.232-0.390.12395.121.0018.590.06620190504027_3_multi_203_086_031_RL_02019.66380.00221.528626.0MegaPrime/CFHTLS21.21740.00381.365626.0MegaPrime/CFHTLS-99.0-99.0-99.0-99.0?1.38602046739-56393-04024.1481.17370281044192524684.150202800.952
3194.1683851.9946753.930.000471dex-spring12100842829194.1683251.9946940.16892-0.789240.33032688-9.9987696499248000.00.00148730.0011787-1.32311.0091-0.674.193-0.685.423-0.851.348-0.89399.417-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.010560.4446.5069999.038563.977908.6311.373-0.040.07964.971.2435.230.04220190403022_3_multi_326_082_034_LL_096-99.0-99.0-99.0-99.0?21.12240.02492.193524.7MOSAIC/KPNO-99.0-99.0-99.0-99.0?0.377944866673-56419-01583.930.377944866673158564193.942996710.93
4242.7811453.7022323.9290.000741dex-spring22102444492242.7811453.7022320.01-2.366640.500772953186625.0524702220000.0-0.00356770.00239443.422.05222.487.6862.259.9260.83106.9820.4995.467-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.01761.81993.6132853.961158259300000.0667.8623.0690.230.14815.9641.731.450.02620200527024_1_multi_326_082_034_LU_06220.91360.01221.849324.0DECaLS22.22780.02512.47824.0DECaLS-99.0-99.0-99.0-99.0?0.475644326312-56487-07213.9290.475644326312721564873.931665400.888
5165.805351.279563.9120.000771dex-spring22100958103165.805351.2795370.07686-2.797080.3029708373525080.0589500000000.0-0.00535730.00146615.05131.25982.543.3732.234.3090.6141.6810.23382.316-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.016104.86406.6052930.8271.181797.5810.9820.270.06961.4250.8573.470.04320190501017_1_multi_308_047_024_LU_08420.25650.00392.214226.2HSC-DEX-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?0.59499368161-57127-07503.9120.59499366706116563853.91201310.936
69.844550.44518063.8440.00021dex-fall121013925949.8445230.4451090.2753-99.00.55153126-99.0428311940000.00.001040.0017264-0.36051.473719.715.62823.287.331115.84137.866352.771685.902-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.014561.13606.1531492.25363000630000.01066.4717.860.710.11764.1731.524.470.03820191024024_1_multi_410_015_038_LU_043-99.0-99.0-99.0-99.0?21.84850.02771.811724.7DECAM/SHELA-99.0-99.0-99.0-99.0?0.53579034222-55444-06583.8440.53579033589528551863.839748600.961
711.8217-0.0149043.7670.000171dex-fall1210009484411.8217-0.0149040.011.356040.13302090.0001761439994.486620.0028580.0002763-0.78490.269655.722.28965.943.221365.6663.311276.53503.414-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.01078.34133.976172.068.45370.898.3642.160.0457.7130.1870.910.02420171115010_3_multi_027_085_001_RU_018-99.0-99.0-99.0-99.0?22.30220.01921.947624.7DECAM/SHELA-99.0-99.0-99.0-99.0?0.14565843590-55201-03143.7670.143896463589118551863.785464300.472
8176.6707552.1251373.7320.000171dex-spring12101918986176.670852.1250840.241843.72.479328e-101.931566e-111.8884091e-130.01275270.000208-10.29720.2112129.961.271181.831.7785542.6554.18867116.2656.166-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.03289.4766.819163.333.319449.185.7752.750.02728.7330.181.980.0320200325031_2_multi_329_088_029_RL_079-99.0-99.0-99.0-99.0?20.88980.01641.586424.7MOSAIC/KPNO-99.0-99.0-99.0-99.0?0.47452776683-56416-05583.7290.47452776683558564163.729386310.896
927.7042540.6910783.7060.000191dex-fall1210142880127.7042540.6910780.011.707690.0560826143.605734e-050.00098421820.00822250.0002657-3.37410.2586138.382.314167.923.361202.4168.0385058.67444.509-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.02029.5229.22848.22.481244.2110.7295.070.04115.6010.1352.430.03520191101016_3_multi_330_092_075_LU_036-99.0-99.0-99.0-99.0?20.52770.00352.924.7DECAM/SHELA-99.0-99.0-99.0-99.0?196.338440700-52199-03881.67733.2731654233556554493.70247410.856
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
5369220.1881151.258820.260.000171dex-spring12100296414220.1881751.2591441.170241.146080.0069716240.00054401513.547415e-050.00205671.31e-05-0.91990.04450.060.00.070.00.330.01.020.003-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0116.82159.97629.380.779142.653.7754.850.0084.3370.210.950.054449.785.156.040.07340.760.4816.750.00614.5430.1532.090.065-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020180511009_1_multi_032_094_028_LL_01018.59240.0022.602126.2HSC-DEX-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?0.855732261328-52786-03510.260.855732261328351527860.2600836820.631
537022.692274-0.13354060.2543e-051dex-fall1210064134222.69228-0.1335440.02393-2.534980.00334483315290446000.0445417800.0-0.01131781.33e-0556.39990.04754.720.0144.230.0121.390.0010.610.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.01164.7440.9633.470.20496.895.65727.940.0187.0680.1250.70.053410.210.6522.60.15235.062.0413.50.0085.7370.1430.620.038-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020190101013_1_multi_032_094_028_LU_10719.04050.00131.570526.4HSC-SSP19.32790.00141.697926.8HSC-SSP19.47980.0012.074325.7DECAM/SHELA48.310984229-55501-01172.8950.1862989400271518200.2538167820.904
53719.3478750.13679880.2521e-051dex-fall121005163159.3479020.1367830.115717-2.924350.0022384499859391600000.016009678000.0-0.03018682.25e-05145.67050.081415.740.03213.720.0263.390.0011.220.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.02048.3413.8333.740.3282409.8923.23371.430.03337.5810.1330.940.074573.7911.7028.240.093254.282.8330.850.00913.7410.1411.780.057-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020181106013_1_multi_318_026_078_RU_061-99.0-99.0-99.0-99.0?18.18150.00232.757724.7DECAM/SHELA-99.0-99.0-99.0-99.0?0.14577517868-57006-08160.25196680.14577517868816570060.2519666920.925
5372205.1474355.825290.2461e-051dex-spring12101986017205.1474255.8252870.03857-1.820850.002426017586809544.01790615.4-0.01558441.91e-0586.16090.06954.280.014.040.0092.220.0011.440.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.04128.832.17825.230.4121158.618.81245.930.0256.4010.0740.440.064516.837.7642.10.02557.320.67627.230.00912.3380.1271.050.043-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020200413019_2_multi_422_078_069_LU_10517.99460.00162.653726.2HSC-DEX-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?0.89788121322-52791-03890.24640.89788121322389527910.2466999420.861
537313.6922430.7011080.2345e-051dex-fall1210140227713.6922430.7011080.01-2.189950.0045590541375639000.050706564.0-0.01417522.79e-0574.4770.09984.240.0183.890.0151.640.0010.870.002-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0467.7618.4232.430.16450.323.38820.730.0135.0240.1470.570.044-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020191027016_1_multi_330_092_075_LL_006-99.0-99.0-99.0-99.0?19.14460.00422.460124.7DECAM/SHELA-99.0-99.0-99.0-99.0?60.3303154224-55481-07963.9950.4018406394616518120.2340315400.839
5374165.2126551.5839580.2143e-051dex-spring12100935227165.2125551.583950.20788-1.68220.00174396746059370.0662251.3-0.02348422.49e-05133.97550.08964.510.0074.290.0062.610.0011.820.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0407.229.4132.30.104104.024.68945.190.0124.3630.0941.390.053-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020190428024_2_multi_312_045_065_RL_059-99.0-99.0-99.0-99.0?17.35210.00332.812624.7MOSAIC/KPNO-99.0-99.0-99.0-99.0?0.15000758161-57127-06530.2140.148444226706220563850.213886900.925
537536.2723960.0946840.2131e-051dex-fall1210054122836.2723960.0946840.01-1.341810.003746944913636.729419.219-0.0058081.69e-0536.6670.06281.030.0041.00.0030.780.0010.650.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0506.274.1535.630.03982.90.56514.730.00822.0130.152.450.071-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020181114017_3_multi_323_043_040_LU_07118.82820.00122.206826.4HSC-SSP19.27810.00122.400126.8HSC-SSP-99.0-99.0-99.0-99.0?137.945286780-56605-06001.8220.33331427406118518170.213358800.936
5376183.517755.680130.2113e-051dex-spring12101989501183.517755.680130.01-3.372460.005346768512540706000000.0553263370000.0-0.01252741.93e-0559.08640.06966.080.035.140.0230.920.0010.260.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0492.387.622.560.03728.90.41411.30.0088.2110.1010.890.037-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020200414015_2_multi_311_053_025_RU_00118.06920.00422.747626.2HSC-DEX-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?301.88946833-56413-05040.9391.00245361018613526720.2113694800.658
537728.8674530.0685650.1862e-051dex-fall1210009455828.8674530.0685650.01-0.417910.008291629330.3690831.295057-0.001262.46e-0515.35870.08760.210.0020.220.0020.340.0010.460.002-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0787.010.92410.660.113113.241.16110.630.01215.1720.1122.460.062-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020171114010_1_multi_017_086_022_RL_08818.24310.00192.875626.4HSC-SSP19.03510.00242.862926.8HSC-SSP-99.0-99.0-99.0-99.0?159.619171505-52941-02311.56310.11709731403425518710.1860986400.931
5378165.0825551.66710.1811e-051dex-spring12100775690165.0825551.6671070.0354-1.780220.004894129542569388.01711833.9-0.0097642.46e-0555.64020.08711.410.0061.340.0060.760.0010.50.001-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0591.714.3265.120.04295.460.76518.650.01218.9150.13710.490.147-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020190301014_3_multi_013_103_019_LU_027-99.0-99.0-99.0-99.0?18.16920.00262.10424.7MOSAIC/KPNO-99.0-99.0-99.0-99.0?0.10483218165-57374-04600.18097090.10483218165460573740.1809417500.925

check the header of the table

agn.info
<Table length=5322>
     name      dtype              unit                               description                  
------------- ------- ---------------------------- -----------------------------------------------
        agnid   int64                                   artificial sequential numbers for each AGN
           ra float32                          deg    RA  of the AGN (center of flux weighted fof)
          dec float32                          deg    DEC of the AGN (center of flux weighted fof)
            z float32                                                                     redshift
         z_er float32                                                            error of redshift
        zflag   int64                                        zflag=0/1: 1 confirmed z; 0 guessed z
        field bytes10                                                   field in the HETDEX survey
       nshots   int64                                                number of repeat observations
detectid_best   int64                               ID in the hetdex catalog closest to fof center
      ra_best float32                          deg                            RA  of detectid_best
     dec_best float32                          deg                            DEC of detectid_best
         roff float32                       arcsec offsec between ra_best,dec_best with fof center
         nmem   int64                                                   number of member detectids
        alpha float32                               alpha_lambda of the power-law fitted continuum
     alpha_er float32                                                               error of alpha
         fpl0 float32                                   power-law continuum = fpl0 * lambda^alpha 
      fpl0_er float32                                                                error of fpl0
        slope float32                                         slope of the linear fitted continuum
     slope_er float32                                                               error of slope
    intercept float32                                     intercept of the linear fitted continuum
 intercept_er float32                                                           error of intercept
        L1350 float32                1e+44 erg / s  monochromatic luminosity at rest-frame 1350 AA
     L1350_er float32                1e+44 erg / s                                  error of L1350
        L1450 float32                1e+44 erg / s  monochromatic luminosity at rest-frame 1450 AA
     L1450_er float32                1e+44 erg / s                                  error of L1450
        L3000 float32                1e+44 erg / s  monochromatic luminosity at rest-frame 3000 AA
     L3000_er float32                1e+44 erg / s                                  error of L3000
        L5100 float32                1e+44 erg / s  monochromatic luminosity at rest-frame 5100 AA
     L5100_er float32                1e+44 erg / s                                  error of L5100
     fwhm_LyA float32                       km / s             rest-frame FWHM of the LyA emission
  fwhm_LyA_er float32                       km / s                               error of fwhm_LyA
       ew_LyA float32                     Angstrom               rest-frame EW of the LyA emission
    ew_LyA_er float32                     Angstrom                                 error of ew_LyA
     flux_LyA float32          1e-17 erg / (s cm2)             rest-frame flux of the LyA emission
  flux_LyA_er float32          1e-17 erg / (s cm2)                               error of flux_LyA
     cont_LyA float32 1e-17 erg / (Angstrom s cm2)        rest-frame continuum at the LyA emission
  cont_LyA_er float32 1e-17 erg / (Angstrom s cm2)                               error of cont_LyA
      snr_LyA float32                                                        S/N of the LyA region
   snr_LyA_er float32                                                             error of snr_LyA
     chi2_LyA float32                                                       chi2 of the LyA region
  chi2_LyA_er float32                                                            error of chi2_LyA
      fwhm_NV float32                       km / s              rest-frame FWHM of the NV emission
   fwhm_NV_er float32                       km / s                                error of fwhm_NV
        ew_NV float32                     Angstrom                rest-frame EW of the NV emission
     ew_NV_er float32                     Angstrom                                  error of ew_NV
      flux_NV float32          1e-17 erg / (s cm2)              rest-frame flux of the NV emission
   flux_NV_er float32          1e-17 erg / (s cm2)                                error of flux_NV
      cont_NV float32 1e-17 erg / (Angstrom s cm2)         rest-frame continuum at the NV emission
   cont_NV_er float32 1e-17 erg / (Angstrom s cm2)                                error of cont_NV
     fwhm_SiO float32                       km / s             rest-frame FWHM of the SiO emission
  fwhm_SiO_er float32                       km / s                               error of fwhm_SiO
       ew_SiO float32                     Angstrom               rest-frame EW of the SiO emission
    ew_SiO_er float32                     Angstrom                                 error of ew_SiO
     flux_SiO float32          1e-17 erg / (s cm2)             rest-frame flux of the SiO emission
  flux_SiO_er float32          1e-17 erg / (s cm2)                               error of flux_SiO
     cont_SiO float32 1e-17 erg / (Angstrom s cm2)        rest-frame continuum at the SiO emission
  cont_SiO_er float32 1e-17 erg / (Angstrom s cm2)                               error of cont_SiO
      snr_SiO float32                                                        S/N of the SiO region
   snr_SiO_er float32                                                             error of snr_SiO
     chi2_SiO float32                                                       chi2 of the SiO region
  chi2_SiO_er float32                                                            error of chi2_SiO
     fwhm_CIV float32                       km / s             rest-frame FWHM of the CIV emission
  fwhm_CIV_er float32                       km / s                               error of fwhm_CIV
       ew_CIV float32                     Angstrom               rest-frame EW of the CIV emission
    ew_CIV_er float32                     Angstrom                                 error of ew_CIV
     flux_CIV float32          1e-17 erg / (s cm2)             rest-frame flux of the CIV emission
  flux_CIV_er float32          1e-17 erg / (s cm2)                               error of flux_CIV
     cont_CIV float32 1e-17 erg / (Angstrom s cm2)        rest-frame continuum at the CIV emission
  cont_CIV_er float32 1e-17 erg / (Angstrom s cm2)                               error of cont_CIV
      snr_CIV float32                                                        S/N of the CIV region
   snr_CIV_er float32                                                             error of snr_CIV
     chi2_CIV float32                                                       chi2 of the CIV region
  chi2_CIV_er float32                                                            error of chi2_CIV
    fwhm_HeII float32                       km / s            rest-frame FWHM of the HeII emission
 fwhm_HeII_er float32                       km / s                              error of fwhm_HeII
      ew_HeII float32                     Angstrom              rest-frame EW of the HeII emission
   ew_HeII_er float32                     Angstrom                                error of ew_HeII
    flux_HeII float32          1e-17 erg / (s cm2)            rest-frame flux of the HeII emission
 flux_HeII_er float32          1e-17 erg / (s cm2)                              error of flux_HeII
    cont_HeII float32 1e-17 erg / (Angstrom s cm2)       rest-frame continuum at the HeII emission
 cont_HeII_er float32 1e-17 erg / (Angstrom s cm2)                              error of cont_HeII
     snr_HeII float32                                                       S/N of the HeII region
  snr_HeII_er float32                                                            error of snr_HeII
    chi2_HeII float32                                                      chi2 of the HeII region
 chi2_HeII_er float32                                                           error of chi2_HeII
    fwhm_CIII float32                       km / s            rest-frame FWHM of the CIII emission
 fwhm_CIII_er float32                       km / s                              error of fwhm_CIII
      ew_CIII float32                     Angstrom              rest-frame EW of the CIII emission
   ew_CIII_er float32                     Angstrom                                error of ew_CIII
    flux_CIII float32          1e-17 erg / (s cm2)            rest-frame flux of the CIII emission
 flux_CIII_er float32          1e-17 erg / (s cm2)                              error of flux_CIII
    cont_CIII float32 1e-17 erg / (Angstrom s cm2)       rest-frame continuum at the CIII emission
 cont_CIII_er float32 1e-17 erg / (Angstrom s cm2)                              error of cont_CIII
     snr_CIII float32                                                       S/N of the CIII region
  snr_CIII_er float32                                                            error of snr_CIII
    chi2_CIII float32                                                      chi2 of the CIII region
 chi2_CIII_er float32                                                           error of chi2_CIII
    fwhm_MgII float32                       km / s            rest-frame FWHM of the MgII emission
 fwhm_MgII_er float32                       km / s                              error of fwhm_MgII
      ew_MgII float32                     Angstrom              rest-frame EW of the MgII emission
   ew_MgII_er float32                     Angstrom                                error of ew_MgII
    flux_MgII float32          1e-17 erg / (s cm2)            rest-frame flux of the MgII emission
 flux_MgII_er float32          1e-17 erg / (s cm2)                              error of flux_MgII
    cont_MgII float32 1e-17 erg / (Angstrom s cm2)       rest-frame continuum at the MgII emission
 cont_MgII_er float32 1e-17 erg / (Angstrom s cm2)                              error of cont_MgII
     snr_MgII float32                                                       S/N of the MgII region
  snr_MgII_er float32                                                            error of snr_MgII
    chi2_MgII float32                                                      chi2 of the MgII region
 chi2_MgII_er float32                                                           error of chi2_MgII
     fwhm_OII float32                       km / s             rest-frame FWHM of the OII emission
  fwhm_OII_er float32                       km / s                               error of fwhm_OII
       ew_OII float32                     Angstrom               rest-frame EW of the OII emission
    ew_OII_er float32                     Angstrom                                 error of ew_OII
     flux_OII float32          1e-17 erg / (s cm2)             rest-frame flux of the OII emission
  flux_OII_er float32          1e-17 erg / (s cm2)                               error of flux_OII
     cont_OII float32 1e-17 erg / (Angstrom s cm2)        rest-frame continuum at the OII emission
  cont_OII_er float32 1e-17 erg / (Angstrom s cm2)                               error of cont_OII
      snr_OII float32                                                        S/N of the OII region
   snr_OII_er float32                                                             error of snr_OII
     chi2_OII float32                                                       chi2 of the OII region
  chi2_OII_er float32                                                            error of chi2_OII
     fwhm_OVI float32                       km / s             rest-frame FWHM of the OVI emission
  fwhm_OVI_er float32                       km / s                               error of fwhm_OVI
       ew_OVI float32                     Angstrom               rest-frame EW of the OVI emission
    ew_OVI_er float32                     Angstrom                                 error of ew_OVI
     flux_OVI float32          1e-17 erg / (s cm2)             rest-frame flux of the OVI emission
  flux_OVI_er float32          1e-17 erg / (s cm2)                               error of flux_OVI
     cont_OVI float32 1e-17 erg / (Angstrom s cm2)        rest-frame continuum at the OVI emission
  cont_OVI_er float32 1e-17 erg / (Angstrom s cm2)                               error of cont_OVI
      snr_OVI float32                                                        S/N of the OVI region
   snr_OVI_er float32                                                             error of snr_OVI
     chi2_OVI float32                                                       chi2 of the OVI region
  chi2_OVI_er float32                                                            error of chi2_OVI
      fiberid bytes38                                               fiberid in hetdex fiber design
       r_aper float32                          mag                       r-band aperture magnitude
    r_aper_er float32                          mag                                 error of r_aper
     r_radius float32                       arcsec                          r-band aperture radius
      r_depth float32                       arcsec                      r-band depth of this field
        r_cat bytes16                                                             survey of r_aper
       g_aper float32                          mag                       g-band aperture magnitude
    g_aper_er float32                          mag                                 error of g_aper
     g_radius float32                       arcsec                          g-band aperture radius
      g_depth float32                       arcsec                      g-band depth of this field
        g_cat bytes16                                                             survey of g_aper
       u_aper float32                          mag                       u-band aperture magnitude
    u_aper_er float32                          mag                                 error of u_aper
     u_radius float32                       arcsec                          u-band aperture radius
      u_depth float32                       arcsec                      u-band depth of this field
        u_cat bytes16                                                             survey of u_aper
   rsep_dr14q float32                       arcsec                    smallest separation to dr14q
     id_dr14q bytes15                                               ID of the closest AGN in dr14q
      z_dr14q float32                                                spectral redshift of id_dr14q
    rsep_dr16 float32                       arcsec                     smallest separation to dr16
   plate_dr16   int64                                             plate of the closest AGN in dr16
   fiber_dr16   int64                                             fiber of the closest AGN in dr16
     mjd_dr16   int64                                              mjd  of the closest AGN in dr16
       z_dr16 float32                                                 spectral redshift of id_dr16
        sflag   int64                                                2em=2, sBL=1, boss=0, else=-1
        apcor float32                                                          aperture correction

Read extension 2 in as a 2-d array

from astrowidgets import ImageWidget

#hdu2, hdr2 = getdata( fname, 2, header = True )
print(hdul[2].header)
im    = hdul[2].data # read spectra in from extension 2
im_er = hdul[3].data # read errors  in from extension 3 if needed

imw = ImageWidget()
imw.cuts = (-1, 25)
imw.load_array(im)
display(imw)
XTENSION= 'IMAGE   '           / Image extension                                BITPIX  =                  -32 / array data type                                NAXIS   =                    2 / number of array dimensions                     NAXIS1  =                 1036                                                  NAXIS2  =                 5322                                                  PCOUNT  =                    0 / number of parameters                           GCOUNT  =                    1 / number of groups                               EXTNAME = 'flux_array'                                                          HIERARCH wave_start = '3470.0 AA'                                               HIERARCH wave_step = '   2.0 AA'                                                HIERARCH flux_unit = '1.0e-17 * erg / (cm^2 * s * AA)'                          END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

the information of the wave_array corresponds to the flux_array in each row can be found in the header:

wave_start = 3470.0, wave_step = 2.0

hdul[2].header['wave_start'], hdul[2].header['wave_step'], hdul[2].header['flux_unit']
('3470.0 AA', '   2.0 AA', '1.0e-17 * erg / (cm^2 * s * AA)')
# prepare wavelength array for the spectra
wave_start = 3470.0
wave_step  = 2.0
n_elements = hdul[2].header['NAXIS1'] #1036
wave_arr = wave_start + wave_step * np.arange( 0, n_elements )
wave_arr
array([3470., 3472., 3474., ..., 5536., 5538., 5540.])
from IPython.display import Image
import matplotlib.pyplot as plt

# ............
w_CIIIa = 977.030
w_NIII  = 991.514
w_OVIa  = 1031.912
w_OVIb  = 1037.613
w_LyA   = 1215.24 
w_NV    = 1240.81
w_OI    = 1305.53
w_CIIa  = 1335.31
w_SiO   = 1399.8
w_CIV   = 1549.48
w_HeII  = 1640.40
w_OIII  = 1665.85
w_CIIIb = 1908.734
w_CIIb  = 2326.0
w_NeIV  = 2439.5
w_MgII  = 2799.117
w_OII   = 3729.875
w_NeVI  = 3426.85
w_NeIII = 3868.760
w_Hg    = 4341.68
# ............

fontsize = 15
xl, xh = 3450, 5550 

# plot some example spectra at the following redshifts
z_sel = np.array( [ 0.9, 1.3, 1.8, 2.2, 2.5, 3.9 ] )

for i in range(np.size(z_sel)):
    sel  = agn['z'] < z_sel[i]
    dtmp = im[sel]
    flux_arr = dtmp[0]
    
    fig, ax = plt.subplots( figsize = ( 10., 5.)  )
    
    plt.plot( wave_arr, flux_arr, 'k' )
    
    lines   = np.array( [  w_OVIa, w_OVIb, w_LyA,   w_NV,   w_SiO,  w_CIV, w_HeII,   w_CIIb, w_CIIIb,  w_MgII, w_OII, w_NeVI, w_NeIII  ] )
    labels  = np.array( [  ' ',     'OVI',  'LyA','    NV', 'Si+O',   'CIV', 'HeII',    'C2', 'C III]', 'MgII', 'OII', 'NeVI', 'NeIII' ] )    

    yl, yh = np.min(flux_arr), np.max(flux_arr)
    for i in range( np.size(lines) ):
        wline = lines[i] * ( 1 + agn[sel]['z'][0] )
        if( ( wline >= xl ) and (wline <= xh ) ):
            wline = np.full( 2, wline )     
            plt.text( wline[0]+10, 0.9 * yh, labels[i], color = 'blue', fontsize=14 )
            plt.plot( wline,  np.array([yl,yh]), color = 'blue', linestyle = '--', linewidth = 1.0 )
    
    plt.xlim( xl, xh )
    plt.tick_params( which = 'both', bottom=True, top=True, left=True, right=True )

    plt.xlabel('$\mathrm{\lambda_{obs}\ (\AA)}$',fontsize=fontsize)
    plt.ylabel('$\mathrm{f_{\lambda,obs}\ (10^{-17} ergs/s/cm^2/\AA)}$',fontsize=fontsize)
    plt.xticks(fontsize=fontsize)
    plt.yticks(fontsize=fontsize)

    stitle = 'agnid=%d, detectid_best=%d, z=%.2f' % (agn[sel]['agnid'][0], agn[sel]['detectid_best'][0], agn[sel]['z'][0])
    plt.title( stitle, fontsize=fontsize )
    plt.show()
    #plt.savefig( 'tmp.png', format='png')
    #Image('tmp.png')

read extension 4 in as a table of repeat observation info

There are some repeat observations for some agns. In this table, each observation has one entry with a unique “shotid”, nshots shows the number of repeat observations for each unique AGN.

tab = Table.read( fname, format = 'fits', hdu = 4 )
tab
Table length=6004
agnidnshotsshotid
int64int64int64
1120191006024
2120190504027
3120190403022
4220200414024
4220200527024
5220190501017
5220190429016
6120191024024
7120171115010
8120200325031
.........
5369120180511009
5370120190101013
5371120181106013
5372120200413019
5373120191027016
5374120190428024
5375120181114017
5376120200414015
5377120171114010
5378120190301014
sel = tab['nshots'] == 1
print("There are %d AGNs that are only observed once" % np.sum(sel))

sel = tab['nshots'] == 2
dtmp = np.unique( tab[sel]['agnid'] )
print("There are %d AGNs that are observed twice" % np.size(dtmp) )

sel = tab['nshots'] > 2
dtmp = np.unique( tab[sel]['agnid'] )
print("There are %d AGNs that are observed more than twice" % np.size(dtmp) )
There are 4799 AGNs that are only observed once
There are 437 AGNs that are observed twice
There are 74 AGNs that are observed more than twice

Find all spectra and their error of a certain AGN in extension 5 and 6

find some strong agns (big nmem) with secure redshifts (z!=0) with more than five repeat observations

sel1 = agn['nshots'] >= 5
sel2 = agn['zflag' ] != 0
sel = sel1 * sel2
dtmp = agn[sel]
sel = np.argsort(-dtmp['nmem'])
dtmp[sel]
Table length=10
agnidradeczz_erzflagfieldnshotsdetectid_bestra_bestdec_bestroffnmemalphaalpha_erfpl0fpl0_erslopeslope_erinterceptintercept_erL1350L1350_erL1450L1450_erL3000L3000_erL5100L5100_erfwhm_LyAfwhm_LyA_erew_LyAew_LyA_erflux_LyAflux_LyA_ercont_LyAcont_LyA_ersnr_LyAsnr_LyA_erchi2_LyAchi2_LyA_erfwhm_NVfwhm_NV_erew_NVew_NV_erflux_NVflux_NV_ercont_NVcont_NV_erfwhm_SiOfwhm_SiO_erew_SiOew_SiO_erflux_SiOflux_SiO_ercont_SiOcont_SiO_ersnr_SiOsnr_SiO_erchi2_SiOchi2_SiO_erfwhm_CIVfwhm_CIV_erew_CIVew_CIV_erflux_CIVflux_CIV_ercont_CIVcont_CIV_ersnr_CIVsnr_CIV_erchi2_CIVchi2_CIV_erfwhm_HeIIfwhm_HeII_erew_HeIIew_HeII_erflux_HeIIflux_HeII_ercont_HeIIcont_HeII_ersnr_HeIIsnr_HeII_erchi2_HeIIchi2_HeII_erfwhm_CIIIfwhm_CIII_erew_CIIIew_CIII_erflux_CIIIflux_CIII_ercont_CIIIcont_CIII_ersnr_CIIIsnr_CIII_erchi2_CIIIchi2_CIII_erfwhm_MgIIfwhm_MgII_erew_MgIIew_MgII_erflux_MgIIflux_MgII_ercont_MgIIcont_MgII_ersnr_MgIIsnr_MgII_erchi2_MgIIchi2_MgII_erfwhm_OIIfwhm_OII_erew_OIIew_OII_erflux_OIIflux_OII_ercont_OIIcont_OII_ersnr_OIIsnr_OII_erchi2_OIIchi2_OII_erfwhm_OVIfwhm_OVI_erew_OVIew_OVI_erflux_OVIflux_OVI_ercont_OVIcont_OVI_ersnr_OVIsnr_OVI_erchi2_OVIchi2_OVI_erfiberidr_aperr_aper_err_radiusr_depthr_catg_aperg_aper_erg_radiusg_depthg_catu_aperu_aper_eru_radiusu_depthu_catrsep_dr14qid_dr14qz_dr14qrsep_dr16plate_dr16fiber_dr16mjd_dr16z_dr16sflagapcor
degdegdegdegarcsec1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / s1e+44 erg / skm / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)km / skm / sAngstromAngstrom1e-17 erg / (s cm2)1e-17 erg / (s cm2)1e-17 erg / (Angstrom s cm2)1e-17 erg / (Angstrom s cm2)magmagarcsecarcsecmagmagarcsecarcsecmagmagarcsecarcsecarcsecarcsec
int64float32float32float32float32int64bytes10int64int64float32float32float32int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32bytes38float32float32float32float32bytes16float32float32float32float32bytes16float32float32float32float32bytes16float32bytes15float32float32int64int64int64float32int64float32
3194150.231742.36407661.9280.000141cosmos72100547486150.231722.364080.070125-2.13820.0370582848091710.0297371070000.0-0.0096587.74e-0522.56980.128534.750.66132.030.4714.00.2147.650.2023083.9459.36455.941.228682.4612.08912.20.32321.8950.3210.730.143717.99144.43440.891.506477.216.77811.670.2916514.95332.25316.740.48150.974.0859.020.15112.9030.3920.580.355072.2156.8858.091.23421.647.8067.260.08129.2230.3470.720.051710.33624.79418.020.621115.83.8036.430.0554.3370.3750.590.036-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020181119015_2_multi_302_036_041_RL_08221.01230.00431.341426.4HSC-SSP21.06780.0031.279926.8HSC-SSP21.26750.00371.842425.7DECAM/COSMOS279.984954737-55630-01563.7180.377421384737159556301.931491420.951
2832150.025422.08791662.0523e-051cosmos62100136927150.02542.0879550.156761.40640.235581651.209612e-0628.4671658.42e-057.74e-05-0.09820.12880.130.0630.150.0680.870.6743.117.1688.786.4834483.0547.833134.491.3080.030.01621.4130.291.240.0282418.87337.306764.0660.85922.922.6580.030.016375.8670.788174.61686.2375.611.2920.030.0151.9480.0980.670.021758.9719.635613.39649.74622.751.7950.040.0167.2240.1180.550.022182.2420.50379.06673.33.181.3410.040.0171.6070.0850.560.026-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020180209009_2_multi_319_083_023_RL_00524.63510.08370.969326.4HSC-SSP24.6010.06551.10526.8HSC-SSP23.78880.03821.634825.7DECAM/COSMOS282.667974737-55630-01902.288129.620943154160548210.0001425902220.724
2114189.347162.2605742.2411e-041goods-n52100326004189.3473862.260410.74544-1.067580.17699678728.232069148.29-0.00086390.00013641.53650.1941.710.0751.70.0771.621.3931.5614.291158.1250.79847.4916.18417.570.5810.370.0187.540.2180.710.025557.51388.7846.223.6072.240.430.360.0178.521250.0520.012.1390.01.2960.320.0140.00.110.680.02730.79168.9780.130.610.040.130.290.0150.0690.0680.680.0260.083.7380.00.7520.00.0870.270.0170.00.020.880.031-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020180516012_2_multi_041_084_015_LL_030-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?142.952767118-56686-09711.017136.67041711897056686-0.0006518130510.765
2209189.2681462.2460632.2163e-051goods-n62100034488189.26862.2460140.300843.699890.33385694-2.3763004e-1316.691307-0.00038287.39e-050.43340.1101-0.450.065-0.640.074-19.391.33-234.815.903766.697.7149999.0422.20698.620.65-0.060.01425.5620.1460.990.0281318.8870.2229999.0489.13927.861.354-0.070.01368.27675.8329999.0382.4244.580.851-0.10.0130.5180.1130.940.029697.1437.1419999.0365.58718.042.036-0.150.0166.4950.1240.730.0281012.17281.1879999.0380.7776.562.408-0.190.0182.3280.1810.710.027-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020170303012_3_multi_008_093_054_LL_067-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?137.659747118-56686-09711.01710.047142711897056686-0.0006518130520.916
2720150.235962.28904442.086860.000171cosmos52100545139150.23592.2891010.30642-0.614830.08710167102.401224166.9214-0.00055429.95e-051.9860.15695.270.1035.420.097.170.6498.82.355680.1389.993169.189.94219.947.661.30.03410.8070.2140.780.024270.3637.45212.668.37716.29.9471.280.0313307.07542.85642.983.73351.23.4351.190.0213.670.190.780.0265583.52355.54380.463.85690.053.3141.120.0177.0010.2060.640.0252380.44507.2364.061.2054.391.0541.080.0180.9680.1280.860.027-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020181116015_1_multi_304_044_045_LU_03921.58960.00611.293126.4HSC-SSP21.48260.00381.28926.8HSC-SSP21.60580.00421.767725.7DECAM/COSMOS249.203264737-55630-01502.61177.3234737146556300.1656648510.956
1273150.183072.2476642.4878e-051cosmos72100031956150.183072.2476640.01-2.299290.151411676345365.5532300500.0-0.00403060.00025325.90280.34492.670.1542.430.150.950.6120.486.822931.212.00889.71196.5645.750.740.510.02816.1920.1570.710.0281392.0152.6320.0198.1010.01.3020.490.027170.19510.48222.9198.3128.491.3190.370.0221.0130.1240.770.023605.949.05977.56197.57222.751.2040.290.026.7960.1170.770.025-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.055.55175.3633.78197.8432.810.6010.740.0420.0460.0391.210.03320170225007_3_multi_020_095_004_LL_04423.66810.03021.061726.4HSC-SSP23.62160.02711.148526.8HSC-SSP24.96280.08941.154725.7DECAM/COSMOS326.566134737-55630-01502.611150.0367500552519946.8515124e-05-10.913
2195150.17982.2471352.220.000151cosmos102100031966150.17982.2471350.011.280830.184539784.3440756e-0518.0153050.00049639.36e-05-0.23410.13792.230.0872.630.08313.812.0346.3218.3441050.44155.575140.41201.17754.762.2420.390.0236.290.1480.720.027826.88483.86516.25197.7216.50.9810.40.0220.0157.3630.00.1620.00.0620.470.0160.00.021.140.03808.4543.8768.460.924.480.3360.530.0171.8380.1340.990.04152.7318.4471.050.5660.60.1660.570.020.3580.081.250.034-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020170225007_3_multi_020_095_004_LU_02828.36481.11490.87526.4HSC-SSP26.83430.25160.351526.8HSC-SSP26.86510.16831.025.7DECAM/COSMOS337.80134737-55630-01502.611153.61548500552519946.8515124e-0510.908
2420189.0490762.2425232.1670.000111goods-n62100029182189.0490762.2425230.01-1.398910.199480155507.7104434297.2-0.00173440.00015032.78220.23051.090.1421.060.1480.791.0620.646.0231508.0886.066144.67451.85439.061.1390.270.0345.1390.1270.840.029666.1810.4040.0458.7770.02.2770.260.0338.546.5319.93763.5542.171.2720.220.0290.3970.0941.040.03583.8148.46638.841270.9447.372.1520.190.031.4210.150.780.026377.3181.9436.95483.0941.220.9310.180.0320.5080.0890.80.029-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020170221012_2_multi_027_085_001_RU_094-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?94.692297118-56686-09292.58794.585556781221523732.585951310.912
2970189.1942962.2461472.0040.000131goods-n62100034726189.1942962.2461470.01-1.327220.0323371075704.2582335.7236-0.00160865.63e-052.87240.09341.570.0621.530.061.210.051.010.0581068.1619.21895.936.42944.131.130.460.0199.3080.1630.920.0224866.02289.87359.477.95626.762.5050.450.01821260.411434.14621.566.8858.211.6790.380.0150.7620.1510.750.0240.0922.3680.04.6130.00.7690.330.0130.00.0820.940.0297796.97803.52814.386.1124.441.2630.310.0120.7880.1520.940.025-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020170303012_3_multi_041_084_015_LL_038-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?170.515787118-56686-09292.587126.9574711897056686-0.0006518130510.929
4611189.2672462.1320461.260.000331goods-n82190007845189.2672462.1320460.01-0.860020.030318093680.776247.198917-0.00052751.62e-052.06780.03541.730.0231.750.021.930.022.080.066-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.02751.3131.58593.282.763114.62.251.230.0128.5590.1670.440.0324584.18296.76921.11.34524.681.2471.170.014.5020.20.710.0265554.27276.59352.891.62254.31.411.030.0059.9450.1640.970.035-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.020180415016_1_multi_312_047_065_RU_059-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?-99.0-99.0-99.0-99.0?284.42890781-52373-02302.068555.133644711879566860.560591820.896

take agnid = 3194 as an example

agnid = 3194

im_arr    = hdul[5].data
im_er_arr = hdul[6].data

sel = np.where( tab['agnid'] == agnid )
shotid_arr  = tab[sel]['shotid']
flux_arr    = im_arr[sel]
flux_er_arr = im_er_arr[sel]

# arrange the repeat observations by time
sel = np.argsort( shotid_arr )
shotid_arr, flux_arr, flux_er_arr = shotid_arr[sel], flux_arr[sel], flux_er_arr[sel]

# prepare the wavelength array for the spectra
wave_start = 3470.0
wave_step  = 2.0
n_elements = hdul[5].header['NAXIS1'] #1036
wave_arr = wave_start + wave_step * np.arange( 0, n_elements )

# plot all repeat observations
fig, ax = plt.subplots( figsize = ( 10., 5.)  )

for i in range(np.size(shotid_arr)):
    
    plt.plot( wave_arr, flux_arr[i], label = '%d' % shotid_arr[i])
    #plt.errorbar( wave_arr, flux_arr[i], flux_er_arr[i] , capsize = 1.5, label = '%d' % shotid_arr[i] )

# overplot with the catalog spectrum for detectid_best in ext 2&3 as black and compare with ext 5&6
im_arr    = hdul[2].data
im_er_arr = hdul[3].data
sel = agn['agnid'] == agnid
flux_arr    = im_arr[sel][0]
flux_er_arr = im_er_arr[sel][0]
plt.errorbar( wave_arr, flux_arr, flux_er_arr, color = 'k',capsize = 1., \
              label = 'ext2&3 spectrum')
    
plt.xlim( xl, xh )
plt.tick_params( which = 'both', bottom=True, top=True, left=True, right=True )

plt.xlabel('$\mathrm{\lambda_{obs}\ (\AA)}$',fontsize=fontsize)
plt.ylabel('$\mathrm{f_{\lambda,obs}\ (10^{-17} ergs/s/cm^2/\AA)}$',fontsize=fontsize)
plt.xticks(fontsize=fontsize)
plt.yticks(fontsize=fontsize)
plt.legend(fontsize=fontsize)
stitle = 'agnid=%d' % (agnid)
plt.title( stitle, fontsize=fontsize )
plt.show()