In [1]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys
if 'saga_base_dir' not in locals():
saga_base_dir = os.path.abspath('..')
if saga_base_dir not in sys.path:
os.chdir(saga_base_dir)
In [2]:
from __future__ import division, print_function
import numpy as np
from astropy import units as u
from astropy import table
from astropy.coordinates import SkyCoord
In [3]:
%matplotlib inline
from matplotlib import pyplot as plt
plt.rcParams['image.cmap'] = 'viridis'
plt.rcParams['figure.figsize'] = [10.0, 6.0]
Hosts are identified in the HSC overlap check notebook. For DR1 they are (in "300 kpc" circles):
In [4]:
import hosts
In [5]:
hostobjs = hosts.get_saga_hosts_from_google()
hosts.use_base_catalogs(hostobjs)
hschosts = tuple([h for h in hostobjs if h.name in ('Alice', 'Othello', 'Dune')])
assert len(hschosts) == 3
hschosts
Out[5]:
In [6]:
for h in hschosts:
h.hscfn = os.path.join('catalogs', 'hsc_pdr1_{}.csv.gz'.format(h.name))
These queries are meant for the HSC casjobs at https://hsc-release.mtk.nao.ac.jp/datasearch/ (which requires login)
In [7]:
hsc_qry_templ="""
SELECT {cols}
FROM {table}
WHERE coneSearch(coord, {hra}, {hdec}, {radius})
"""[1:-1]
bands = 'gri'
cols = 'object_id,ra,dec'.split(',')
for band in bands:
magcol_to_add = []
magcol_to_add.append('{}cmodel_mag'.format(band))
magcol_to_add.append('{}mag_psf'.format(band))
magcol_to_add.append('{}mag_kron'.format(band))
magcol_to_add.append('{}mag_aperture10'.format(band))
magcol_to_add.append('{}mag_aperture20'.format(band))
magcol_to_add.append('{}mag_aperture30'.format(band))
for magcol in magcol_to_add:
cols.append(magcol)
cols.append(magcol+'_err')
cols.append('{}flux_kron_radius'.format(band))
cols.append('a_{}'.format(band))
cols = ','.join(cols)
In [8]:
table_to_query='pdr1_wide.forced'
for h in hschosts:
print('Query for host', h.name, 'which should be saved to', h.hscfn)
qry = hsc_qry_templ.format(table=table_to_query, cols=cols,
hra=h.ra, hdec=h.dec,
radius=h.environsarcmin*u.arcmin.to(u.arcsec))
print(qry, '\n')
In [9]:
def compute_ap_sb(mags, aperturerad):
A = 2.5*np.log10(np.pi*(aperturerad.to(u.arcsec).value)**2)
return np.array(mags + A) * u.mag * u.arcsec**-2
In [10]:
alice = [h for h in hostobjs if h.name=='Alice']
assert len(alice)==1
alice = alice[0]
In [11]:
alice.hsc_cat = table.Table.read(alice.hscfn, format='ascii.csv')
alice.hsc_cat['# object_id'].name = 'object_id'
alice.hsc_cat
Out[11]:
In [12]:
alice.hsc_cat['coord'] = SkyCoord.guess_from_table(alice.hsc_cat, unit=u.deg)
In [14]:
alice.hsc_cat['r_sb10'] = compute_ap_sb(alice.hsc_cat['rmag_aperture10'], 0.5*u.arcsec)
alice.hsc_cat['r_sb20'] = compute_ap_sb(alice.hsc_cat['rmag_aperture20'], 1.0*u.arcsec)
alice.hsc_cat['r_sb_kron'] = compute_ap_sb(alice.hsc_cat['rmag_kron'], alice.hsc_cat['rflux_kron_radius']*u.arcsec)
In [15]:
fig, (ax1, ax2) = plt.subplots(2,1,figsize=(10, 8))
Ar = alice.hsc_cat['a_r']
ax1.scatter(alice.hsc_cat['r_sb_kron']-Ar, alice.hsc_cat['rflux_kron_radius'], alpha=.05, s=1, lw=0)
ax2.scatter(alice.hsc_cat['r_sb_kron']-Ar, alice.hsc_cat['rcmodel_mag']-Ar, alpha=.05, s=1, lw=0)
for ax in (ax1, ax2):
ax.set_xlim(20, 30)
ax.set_xlabel('r_sb_kron')
ax1.set_ylim(0, 5)
ax2.set_ylim(30, 20)
ax1.set_ylabel('rflux_kron_radius')
ax2.set_ylabel('rcmodel_mag')
Out[15]:
In [22]:
coo = alice.hsc_cat['coord']
del alice.hsc_cat['coord']
alice.hsc_cat.write('catalogs/Alice_HSC_reprocessed.fits', format='fits')
!gzip catalogs/Alice_HSC_reprocessed.fits
!ls -lh catalogs/Alice*
coo = alice.hsc_cat['coord'] = coo
In [24]:
sdsscat = alice.get_sdss_catalog()
idx, d2d, _ = sdsscat['coord'].match_to_catalog_sky(alice.hsc_cat['coord'])
In [25]:
plt.hist(d2d.arcsec, range=(0, 10), log=True, bins=100, histtype='step');
In [26]:
matched = d2d < 1*u.arcsec
plt.scatter(sdsscat['r'][matched], alice.hsc_cat['rcmodel_mag'][idx[matched]], alpha=.2, lw=0, s=2)
plt.plot([17, 24], [17, 24], c='k')
plt.xlim(17, 24)
plt.ylim(17, 24)
plt.xlabel('SDSS r')
plt.ylabel('HSC r')
Out[26]:
In [27]:
deccat = table.Table.read('catalogs/Alice_decals_dr3.fits')
In [28]:
deccat['coord'] = SkyCoord(deccat['ra'], deccat['dec'], unit=u.deg)
idx, d2d, _ = deccat['coord'].match_to_catalog_sky(alice.hsc_cat['coord'])
In [29]:
plt.hist(d2d.arcsec, range=(0, 10), log=True, bins=100, histtype='step');
In [30]:
matched = d2d < 1*u.arcsec
plt.scatter(deccat['mag_r'][matched], alice.hsc_cat['rcmodel_mag'][idx[matched]], alpha=.2, lw=0, s=2)
plt.plot([17, 24], [17, 24], c='k')
plt.xlim(17, 24)
plt.ylim(17, 24)
plt.xlabel('DECaLS r')
plt.ylabel('HSC r')
Out[30]: