In [1]:
import sys
print sys.executable
# Hack!, this avoids messing with NERSC's config file for jupyter hub
sys.path.append('/global/homes/k/kaylanb/repos')
sys.path.append('/global/homes/k/kaylanb/repos/astrometry.net')
sys.path.append('/global/homes/k/kaylanb/repos/tractor')
sys.path
print sys.path
In [2]:
# Easy if pip, conda installable
#!/anaconda2/bin/pip install ...
#!/anaconda2/bin/conda install ...
Run legacy-zeropoints-qa.py like this "python legacy-zeropoints-qa.py" to analyze everything.
See below to walk through it step by step.
In [2]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import numpy as np
import matplotlib.pyplot as plt
import fitsio
import glob
import os
import matplotlib.patches as mpatches
from matplotlib.collections import PatchCollection
from astropy import units
from astropy.coordinates import SkyCoord
from astrometry.util.fits import fits_table, merge_tables
from tractor.brightness import NanoMaggies
In [3]:
import theValidator.catalogues as cat
In [9]:
In [ ]:
import theValidator.catalogues as cat
def big_mem_stack(self,fn_list,textfile=False):
'''does self.stack() but for the case the Memory will be exceeded'''
assert(textfile == False)
In [36]:
mat=cat.Matcher()
imatch,imiss,d2d= mat.match_within(dp2,dr3) #,dist=1./3600)
#fits_funcs.set_extra_data(dr3)
In [37]:
dp2.cut(imatch['ref'])
dr3.cut(imatch['obs'])
In [42]:
fits_funcs= cat.CatalogueFuncs()
fits_funcs.set_extra_data(dr3)
In [19]:
import decals_sim_priors
kwargs=dict(DR=2,savefig=False,alpha=0.2,\
brick_primary=True,anymask=True,allmask=False,fracflux=True)
# Stars, pure sample is from DR2
star_obj= decals_sim_priors.STAR(DR=2,savefig=False)
stars= star_obj.get_purestars()
# QSOs, DR2 for now, still need build DR3 sample
kwargs.update(dict(rlimit=22.7+1.))
qso_obj= decals_sim_priors.QSO(**kwargs)
qsos= qso_obj.get_qsos()
# DR3 for ELG, LRG
kwargs.update(dict(DR=3))
kwargs.update(dict(rlimit=23.4+1.))
elg_obj= decals_sim_priors.ELG(**kwargs)
elg_mags={}
rz,gr,elg_mags['r_nodust'],elg_mags['r_wdust']= elg_obj.get_elgs_FDR_cuts()
kwargs.update(dict(zlimit=20.46+1.))
lrg_obj= decals_sim_priors.LRG(**kwargs)
lrg_mags={}
rz,rW1,lrg_mags['r_nodust'],lrg_mags['r_wdust'],lrg_mags['z_nodust'],lrg_mags['z_wdust']= lrg_obj.get_lrgs_FDR_cuts()
In [24]:
fig,axes = plt.subplots(2,2,figsize=(18,12))
ax=axes.flatten()
plt.subplots_adjust(wspace=0.2,hspace=0.2)
for whichmag,color,alpha in zip(['nodust','wdust'],\
['b','g'],[0.5,0.5]):
for cnt,typ in zip(range(4),['qso','stars','lrg','elg']):
if typ == 'qso':
rmag=qsos.get('decam_mag_%s' % whichmag)[:,2]
hiz=2.1
loz= qsos.get('z') <= hiz
cut= (loz) * (np.isfinite(rmag))
rmag=rmag[cut]
elif typ == 'stars':
rmag=stars.get('decam_mag_%s' % whichmag)[:,2]
elif typ == 'elg':
rmag= elg_mags['r_%s' % whichmag]['med2hiz_oiibright']
elif typ == 'lrg':
rmag= lrg_mags['r_%s' % whichmag]['red_galaxy_hiz']
ax[cnt].hist(rmag,color=color,label=whichmag,alpha=alpha)
for cnt,typ in zip(range(4),['qso','stars','lrg','elg']):
xlab=ax[cnt].set_xlabel('r AB',fontsize='large')
ti=ax[cnt].set_title('%s' % typ,fontsize='large')
ax[cnt].legend(loc='upper left',fontsize='medium')
# plt.savefig('rmag_dist.png', \
# bbox_extra_artists=[xlab,ti], bbox_inches='tight',dpi=150)
# LRG - z > 20.46
# ELG - r < 23.4
# QSO - redshift < 2.1
# STAR - r > 16
In [22]:
# LRG zmag
for whichmag,color in zip(['nodust','wdust'],\
['b','g']):
zmag= lrg_mags['z_%s' % whichmag]['red_galaxy_hiz']
plt.hist(zmag,color=color,label=whichmag,alpha=0.5)
plt.legend(loc='upper left',fontsize='medium')
plt.xlabel('z AB')
plt.title('LRG')
Out[22]:
In [4]:
from decals_sim_priors import QSO
kwargs=dict(DR=2,savefig=False,alpha=0.2,\
brick_primary=True,anymask=True,allmask=False,fracflux=True)
dr2= QSO(**kwargs)
dr2.plot()
# kwargs.update(dict(DR=3))
# dr2= QSO(**kwargs)
# dr2.plot()
In [18]:
from decals_sim_priors import ELG
kwargs=dict(DR=2,savefig=False,alpha=0.2,\
brick_primary=True,anymask=True,allmask=False,fracflux=True)
elg= ELG(**kwargs)
elg.plot()
kwargs.update(dict(DR=3))
elg= ELG(**kwargs)
elg.plot()
In [29]:
import decals_sim_priors
kwargs=dict(DR=2,savefig=False,alpha=0.2,\
brick_primary=True,anymask=True,allmask=False,fracflux=True)
lrg= decals_sim_priors.LRG(**kwargs)
lrg.plot()
kwargs.update(dict(DR=3))
lrg= decals_sim_priors.LRG(**kwargs)
lrg.plot()
In [20]:
import decals_sim_priors
kwargs=dict(DR=2,savefig=False,alpha=0.2,\
brick_primary=True,anymask=True,allmask=False,fracflux=True)
lrg= decals_sim_priors.LRG(**kwargs)
lrg.plot()
kwargs.update(dict(DR=3))
lrg= decals_sim_priors.LRG(**kwargs)
lrg.plot()
In [ ]:
import theValidator.catalogues as cat
tt= cat.TargetTruth()
tt.qso()