QA_Brick


In [1]:
# imports
from desispec import io
from desispec.io import zfind as io_zfind
from desispec.io.qa import load_qa_brick, write_qa_brick
from desispec.qa import qa_plots as qap


/Users/xavier/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:1350: UserWarning:  This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)

ZBest

Load


In [2]:
zb_file = '/Users/xavier/DESI/TST/dogwood/bricks/3587p000/zbest-3587p000.fits'

In [3]:
zbest = io_zfind.read_zbest(zb_file)
zbest.nspec


Out[3]:
172

In [4]:
# bricks
brick = {}
bb_file = '/Users/xavier/DESI/TST/dogwood/bricks/3587p000/brick-b-3587p000.fits'
br_file = '/Users/xavier/DESI/TST/dogwood/bricks/3587p000/brick-r-3587p000.fits'
bz_file = '/Users/xavier/DESI/TST/dogwood/bricks/3587p000/brick-z-3587p000.fits'
brick['b'] = io.Brick(bb_file)
brick['r'] = io.Brick(br_file)
brick['z'] = io.Brick(bz_file)


/Users/xavier/DESI/desispec/py/desispec/io/brick.py:29: UserWarning: Deriving channel and brickname from filename brick-b-3587p000.fits instead of contents
  warnings.warn('Deriving channel and brickname from filename {} instead of contents'.format(filename))
/Users/xavier/DESI/desispec/py/desispec/io/brick.py:29: UserWarning: Deriving channel and brickname from filename brick-r-3587p000.fits instead of contents
  warnings.warn('Deriving channel and brickname from filename {} instead of contents'.format(filename))
/Users/xavier/DESI/desispec/py/desispec/io/brick.py:29: UserWarning: Deriving channel and brickname from filename brick-z-3587p000.fits instead of contents
  warnings.warn('Deriving channel and brickname from filename {} instead of contents'.format(filename))

YAML


In [5]:
qafile = '/Users/xavier/DESI/TST/dogwood/bricks/3587p000/qa_3587p000.yaml'

In [6]:
qabrick = load_qa_brick(qafile)
qabrick


INFO:qa.py:98:load_qa_brick: Loaded QA file /Users/xavier/DESI/TST/dogwood/bricks/3587p000/qa_3587p000.yaml
INFO:DESI:Loaded QA file /Users/xavier/DESI/TST/dogwood/bricks/3587p000/qa_3587p000.yaml
Out[6]:
QA_Brick: name=None

In [7]:
qabrick.run_qa('ZBEST', (zbest,brick))


WARNING:zfind.py:93:qa_zbest: High number of failed redshifts 48
WARNING:DESI:High number of failed redshifts 48

In [8]:
qabrick.data


Out[8]:
{u'ZBEST': {u'PARAM': {'ELG_TYPES': [u'ssp_em_galaxy'],
   'LRG_TYPES': [u'LRG'],
   'MAX_NFAIL': 10,
   'QSO_TYPES': [u'QSO'],
   'STAR_TYPES': [u'spEigenStar']},
  u'QA': {'MEAN_Z': 1.2631667271401863,
   'MEDIAN_Z': 1.2417498717011353,
   'NFAIL': 48,
   'NTYPE': {'ELG': 144,
    'LRG': 0,
    'MATCH': 16,
    'QSO': 26,
    'STAR': 2,
    'UNKWN': 0},
   'RMS_Z': 0.498536172043196}},
 'name': u''}

In [9]:
# Write
write_qa_brick(qafile, qabrick)


Out[9]:
'/Users/xavier/DESI/TST/dogwood/bricks/3587p000/qa_3587p000.yaml'

Plot


In [10]:
qafig = '/Users/xavier/DESI/TST/dogwood/bricks/3587p000/qa-zbest_3587p000.pdf'

In [11]:
reload(qap)
qap.brick_zbest(qafig, zbest, qabrick)


Wrote QA ZBEST file: /Users/xavier/DESI/TST/dogwood/bricks/3587p000/qa-zbest_3587p000.pdf

In [ ]: