In [4]:
import os
import numpy as np
import fitsio
from astropy.table import Table
import matplotlib.pyplot as plt
In [1]:
def read_data():
topdir = os.path.join(os.getenv('DESI_ROOT'), 'datachallenge', 'PR427-spectra-onepixel')
targets = Table(fitsio.read(os.path.join(topdir, 'targets.fits')))
iqso = np.where(targets['DESI_TARGET'] & desi_mask.QSO != 0)[0] # QSO targets
iqso = np.argsort(iqso)
targets = targets[iqso]
info = fitsio.FITS(os.path.join(topdir, 'truth.fits'))
truth = Table(info['TRUTH'].read(rows=iqso))
truth_qso = Table(info['TRUTH_QSO'].read()) # Tracer+Lya QSO targets
# Pull out the extragalactic and stellar QSO contaminants.
truth_bgs = Table(info['TRUTH_BGS'].read()) # Includes extragalactic contaminants
truth_bgs = truth_bgs[np.isin(truth_bgs['TARGETID'], targets['TARGETID'])]
truth_star = Table(info['TRUTH_STAR'].read()) # Includes stellar contaminants
truth_star = truth_star[np.isin(truth_star['TARGETID'], targets['TARGETID'])]
return targets, truth, truth_qso, truth_bgs, truth_star
In [2]:
targets, truth, truth_qso, truth_bgs, truth_star = read_data()
In [3]:
topdir = os.path.join(os.getenv('DESI_ROOT'), 'datachallenge', 'PR427-spectra-onepixel')
targets = Table(fitsio.read(os.path.join(topdir, 'targets.fits')))
ff = fitsio.FITS(os.path.join(topdir, 'truth.fits'))
truth = Table(ff['TRUTH'].read())
truth_qso = Table(ff['TRUTH_QSO'].read()) # Tracer+Lya QSO targets
In [ ]:
iqso = np.where(targets['DESI_TARGET'] & desi_mask.QSO != 0)[0] # QSO targets