In [1]:
%matplotlib inline
from __future__ import division
import om10,os
import numpy as np
import matplotlib.pyplot as plt
import triangle

In [2]:
# redshift sigma g/Reff r   i   z     g mag   r mag    i mag  z    w1     w2       w3      w4
lrgs = np.loadtxt(os.path.expandvars('$OM10_DIR/data/LRGo.txt'))

#kill photometric outliers in r and i bands
lrgs = lrgs[np.logical_and(lrgs[:,8]<24,lrgs[:,9]<22)] 
#color outliers:
lrgs = lrgs[(lrgs[:,6] - lrgs[:,7]) < 3] 
lrgs = lrgs[(lrgs[:,7] - lrgs[:,8]) > 0]
lrgs = lrgs[(lrgs[:,8] - lrgs[:,9]) > 0]

#redshift       g    r    i    z     w1      w2       w3     w4
qsos = np.loadtxt(os.path.expandvars('$OM10_DIR/data/QSOo.txt'))
qsos = qsos[np.logical_and(qsos[:,3]>0,qsos[:,1]>0)] #require g and i band > 0 to kill -10,000 outliers

In [3]:
_ = plt.hist(lrgs[:,0].flatten(),bins=100)
plt.xlabel('z')


Out[3]:
<matplotlib.text.Text at 0x10ab54c10>

Well, we don't have that great a handle on redshifts past .8, but hopefully ok...

PS1QLS Forecast


In [3]:
#load and decorate OM10 catalog
db = om10.DB(catalog='$OM10_DIR/data/qso_mock.fits')
#PS1-like sample!
db.select_random(maglim=21.4,area=100000.0,IQ=1.0)
print 'Total number of sims: ', len(db.sample)
db.get_sky_positions(input_cat='$OM10_DIR/data/CFHTLS_LRGs.txt')
#db.assign_sky_positions()
db.paint(lrg_input_cat='$OM10_DIR/data/LRGo.txt',qso_input_cat='$OM10_DIR/data/QSOo.txt')

#which objects got correctly colored in our desired parameter range?
matched = db.sample[db.sample['ZLENS'] < 3]
#matched = matched[matched['ZLENS'] < 3]
matched = matched[np.logical_and(matched['SDSS_FLAG_SRC'] == 0,matched['SDSS_FLAG_LENS'] == 0)]
matched = matched[matched['ZSRC'] < 4.5]
matched = matched[np.logical_and(matched['VELDISP'] > 200,matched['VELDISP'] < 300)]
print 'Fraction remaining after bad color matching: ', len(matched)/len(db.sample)

#more restrictive range that improves color matching
matched = matched[matched['ZLENS'] < .98]
print 'Fraction remaining after good color matching: ', len(matched)/len(db.sample)

#which objects got assigned a position?
#matched = db.sample[np.logical_and(db.sample['RA']> 0,db.sample['DEC'] > -20)]
#matched = matched[np.logical_and(matched['RA']> 0,matched['DEC'] > -20)]
print 'Fraction remaining after position-matching: ', len(matched)/len(db.sample)


om10.DB: selection yields  3317  lenses
Total number of sims:  3317
om10.DB: read in LRG sky position data from  /Users/mbaumer/pybin/OM10/data/CFHTLS_LRGs.txt
Mean LRG RA,DEC,z =  34.3807307408 -7.09643979181 0.612498 21.63331883
Mean LRG i,(g-r) =  34.3807307408 -7.09643979181 0.612498 21.63331883
om10.DB: number of LRGs stored =  10000
Fraction remaining after bad color matching:  0.639433222792
Fraction remaining after good color matching:  0.462767561049
Fraction remaining after position-matching:  0.462767561049

Going from ZLENS < 3 to ZLENS < 1 costs us 9% of our training set, but I think will greatly improve our ability to apply XD to this problem, because otherwise, there will be massive color peaks in the lens color distributions. The fixes Adri suggested are good, but I propose we save them for pass 2...

So the final prediction is that there would be 379 lenses that we could hope to find in our PS1QLS sample!


In [40]:
len(matched) #total number of systems in input cat!


Out[40]:
1186

In [34]:
db.sample = matched
out_cat = db.make_sim_input_catalog()

In [35]:
out_cat


Out[35]:
LENSIDRADEC...IZ
5810316.034.64855907-7.843399404...19.7167819.24147
5810316.034.6483635464-7.84380984844...19.053644623118.8341046231
5810316.034.6486285253-7.84323284844...19.252315685819.0327756858
22039442.034.43273733-5.827326791...18.1047517.63566
22039442.034.4327503696-5.82756665211...17.339553097817.4058530978
22039442.034.4325370171-5.82731473544...17.42812656217.494426562
22039442.034.4329389553-5.82727356878...17.349667660217.4159676602
22039442.034.4327466839-5.82709956878...17.042503021117.1088030211
26594724.034.1184052-5.921554115...19.4325518.65366
26594724.034.1183392928-5.92165592056...17.455084601117.4802646011
26594724.034.1184751008-5.921597365...18.149745406718.1749254067
..................
3927786.034.6002388397-9.10930629433...17.349057111617.3489171116
3927786.034.6004915827-9.10903873878...17.689726700217.6895867002
15280613.034.84433207-5.846780364...19.4629519.01755
15280613.034.8439439956-5.84692369733...17.132694784416.9926447844
15280613.034.8443633159-5.84651375289...17.672815932317.5327659323
17966953.034.10953809-7.60819296...19.0771718.53848
17966953.034.1095119992-7.60835390444...17.000329613117.0475096131
17966953.034.1095616866-7.60810054333...18.159983275518.2071632755
9346277.034.09309537-6.555716868...19.3823218.59626
9346277.034.0932177815-6.55585022911...16.845174104716.5694741047
9346277.034.0928517493-6.55566128467...16.91654344216.640843442

In [38]:
out_cat.write('input_cat_for_eric.fits',format='fits',overwrite=True)

In [4]:
to_plot = np.array([lrgs[:,0], lrgs[:,1], lrgs[:,8], lrgs[:,6]-lrgs[:,7], lrgs[:,7]-lrgs[:,8],\
                    lrgs[:,8]-lrgs[:,9], lrgs[:,9]-lrgs[:,10], lrgs[:,10]-lrgs[:,11]]).transpose()
painted_lenses = np.array([matched['ZLENS'],matched['VELDISP'], matched['MAGI_LENS'], matched['MAGG_LENS']-matched['MAGR_LENS'], \
                    matched['MAGR_LENS']-matched['MAGI_LENS'],matched['MAGI_LENS']-matched['MAGZ_LENS'], \
                    matched['MAGZ_LENS']-matched['MAGW1_LENS'],matched['MAGW1_LENS']-matched['MAGW2_LENS']]).transpose()
fig = triangle.corner(to_plot,labels=['z','sigma','i mag','g-r','r-i','i-z','z-w1','w1-w2'],color='Blue')
_ = triangle.corner(painted_lenses,labels=['z','sigma','i mag','g-r','r-i','i-z','z-w1','w1-w2'],color='Green',fig=fig)
plt.suptitle('SDSS Lenses')


Out[4]:
<matplotlib.text.Text at 0x10c6f1c90>

In [10]:
to_plot = np.array([qsos[:,0], qsos[:,3], qsos[:,1]-qsos[:,2], qsos[:,2]-qsos[:,3], qsos[:,3]-qsos[:,4],\
                   qsos[:,4]-qsos[:,5],qsos[:,5]-qsos[:,6]]).transpose()
painted_qsos = np.array([matched['ZSRC'],matched['MAGI'],matched['MAGG_SRC']-matched['MAGR_SRC'], \
                    matched['MAGR_SRC']-matched['MAGI_SRC'],matched['MAGI_SRC']-matched['MAGZ_SRC'], \
                    matched['MAGZ_SRC']-matched['MAGW1_SRC'],matched['MAGW1_SRC']-matched['MAGW2_SRC']]).transpose()
fig = triangle.corner(to_plot,labels=['z','magi','g-r','r-i','i-z','z-w1','w1-w2'],color='Blue')
_ = triangle.corner(painted_qsos,labels=['z','magi','g-r','r-i','i-z','z-w1','w1-w2'],color='Green',fig=fig)
plt.suptitle('SDSS Quasars')


Out[10]:
<matplotlib.text.Text at 0x119ea1f90>

In [ ]: