Perform all of the cuts and save the new table to output the final candidates list

This way, I dont have to do all of the cuts in topcat every time...


In [6]:
import os
import warnings
import numpy as np
from sklearn.neighbors import BallTree
from astropy.io import fits as pf
import matplotlib.pyplot as plt

In [ ]:


In [33]:
#Triton path to the data and random files
#file1='../Data_Sets/Candidates_photoz_SpSh_shenzrange_tocluster.fits'
file1 = '/Users/johntimlin/Catalogs/QSO_candidates/Final_S82_candidates_full/New_Training_VVDS_M13_DR12Q_photoz.fits'

#Open the data with fits

data=pf.open(file1)[1].data
Ag = data.extinctu/4.239 * 3.303
fdx = ((data.ra>=344.1) | (data.ra < 330)) &  (Ag<=0.21) & (data.zphotNW>=2.9) & (data.zphotNW<=5.4)
classification = (data.ypredBAG+data.ypredSVM+data.ypredRFC)

imag = -2.5/np.log(10)*(np.arcsinh(data.iflux/1.0e9/(2*1.8e-10))+np.log(1.8e-10))-1.698*data.extinctu/4.239
print data.iflux
print imag

dx = ((data.zphotNW>=2.9) & (data.zphotNW<=5.4) & (data.dec >=-1.2) & (data.dec<=1.2)) &  ((fdx) |(classification <2))
ra = data.ra[dx]
dec= data.dec[dx]

tbhdu=pf.BinTableHDU.from_columns([pf.Column(name='RA',format='D',array=ra),
pf.Column(name='DEC',format='D',array=dec),pf.Column(name='imag',format='D',array=imag)])

prihdr=pf.Header()
prihdr['COMMENT']="Catalog of high redshift quasars in the SpIES field with all cuts"
prihdu=pf.PrimaryHDU(header=prihdr)
hdulist = pf.HDUList([prihdu,tbhdu])
#hdulist=pf.HDUList(data[dx])
#hdulist.writeto('/Users/johntimlin/Catalogs/QSO_candidates/Final_S82_candidates_full/Candidates_with_cuts_S82_imag.fits')


[  9.42772  36.2621   13.49613 ...,   1.44174   2.0414    1.92255]
[-25.13839914 -26.47909811 -25.38499399 ..., -22.97172148 -23.39491923
 -23.29794685]
/Users/johntimlin/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:9: RuntimeWarning: invalid value encountered in greater_equal
/Users/johntimlin/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:9: RuntimeWarning: invalid value encountered in less_equal
/Users/johntimlin/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:16: RuntimeWarning: invalid value encountered in greater_equal
/Users/johntimlin/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:16: RuntimeWarning: invalid value encountered in less_equal

In [41]:
imag = -2.5/np.log(10)*(np.arcsinh(data.iflux/1.0e-9/(2*1.8e-10))+np.log(1.8e-10))-1.698*data.extinctu/4.239

print data.iflux/1.0e-9/(2*1.8e-10)
print (np.arcsinh(data.iflux/1.0e9/(2*1.8e-10))+np.log(1.8e-10))*(-2.5/np.log(10))-1.698*data.extinctu/4.239


[  2.61881111e+19   1.00728056e+20   3.74892500e+19 ...,   4.00483333e+18
   5.67055556e+18   5.34041667e+18]
[ 19.86120529  18.52087514  19.61481293 ...,  22.01173734  21.59673618
  21.6926586 ]

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: