In [1]:
__author__ = 'Stephanie Juneau, NOAO Data Lab Team'
__version__ = '20170602' # yyyymmdd

DECaLS and SDSS/BOSS Large Scale Structure

by Stephanie Juneau and the NOAO Data Lab Team

This short notebook illustrates an example joint query between the DECaLS DR3 photometry Tractor table, and the SDSS/BOSS DR13 specObj spectroscopy table. It takes advantage of the fact that there is a version of the DECaLS DR3 tractor table that was pre-matched to SDSS/BOSS DR13 so we can join on a common column called specobjid.

The columns from the DECaLS table used (Tractor, pre-matched to specObj DR13) can be seen here: http://datalab.noao.edu/tutdev/query.php?name=ls_dr3.dr3_specobj_dr13

The columns from the SDSS/BOSS DR13 table can be seen here: http://datalab.noao.edu/tutdev/query.php?name=sdss_dr13.specobj

Import

Import packages including some Data Lab (dl) specific ones.

In [2]:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

from cStringIO import StringIO  #C script to handle string format
from astropy.table import Table

from dl import authClient as ac, queryClient as qc
print 'Done importing'
Done importing

Authenticate

In [3]:
# To save to virtual space, need to log in your account (not anonymous)
token = ac.login('anonymous')
print 'Done getting token'
Done getting token

Joint Query on SDSS specObj and DECaLS Photometry

In this section, we use a version of the DECaLS DR3 tractor table which was pre-matched with specObj table from SDSS/BOSS DR13.

In [4]:
# ls_dr3.dr3_specobj_dr13           #DECaLS matched to SDSS DR13 specobj
# sdss_dr13.specobj                 #SDSS DR13 specobj

# Write query statement (adql)
query = ("""SELECT 
           L.ra,L.dec,L.type,
           S.z,S.plug_ra,S.plug_dec,S.class, 
           S.vdisp,S.vdisp_err 
         FROM ls_dr3.dr3_specobj_dr13 as L JOIN sdss_dr13.specobj as S 
         ON L.specObjId = S.specobjid 
         WHERE L.ra BETWEEN %s and %s and L.dec BETWEEN %s and %s and (L.ra_ivar > 0) 
         limit 100000""") %(126,131,7.,12.)  #small region

# L.ra, L.dec      = RA, Dec from Legacy Survey (LS) table    
# L.type           = object type (PSF, SIMP, EXP, DEV, COMP)
# S.z              = redshift (z) from SDSS specObj table
# S.plug_ra,dec    = RA, Dec of SDSS fiber from specObj table
# S.class          = Source class (Star, Galaxy, QSO) from SDSS
# S.vdisp,vdisp_err= velocity dispersion (and error) from SDSS specObj table
#
# WHERE: requirement that RA & Dec coordinates are within a rectangular region


print query
SELECT 
           L.ra,L.dec,L.type,
           S.z,S.plug_ra,S.plug_dec,S.class, 
           S.vdisp,S.vdisp_err 
         FROM ls_dr3.dr3_specobj_dr13 as L JOIN sdss_dr13.specobj as S 
         ON L.specObjId = S.specobjid 
         WHERE L.ra BETWEEN 126 and 131 and L.dec BETWEEN 7.0 and 12.0 and (L.ra_ivar > 0) 
         limit 100000
In [5]:
%%time
# Call query manager
response = qc.query(token, adql=query, fmt='csv')

print 'Time'
Time
CPU times: user 28 ms, sys: 9 ms, total: 37 ms
Wall time: 1.63 s
In [6]:
# Reformat output into a table
result = Table.read(StringIO(response), format='csv')  #dictionary

result[:3]
Out[6]:
<Table length=3>
radectypezplug_raplug_decclassvdispvdisp_err
float64float64str4float64float64float64str6float64float64
126.0000791677.03495434515DEV0.212844126.000087.0349361GALAXY284.4305115.617004
126.0149385117.00774970052DEV0.24385899126.014957.0077364GALAXY229.5399523.60804
126.0266249657.04572519908DEV0.25915501126.026637.0457033GALAXY221.3285512.791714

Sanity check: RA, Dec positions from both tables

In [7]:
chgsign = np.where(result['ra'] > 180)
result['ra'][chgsign] = result['ra'][chgsign]-360.
result['plug_ra'][chgsign] = result['plug_ra'][chgsign]-360.

plt.figure(figsize=(9,8))

plt.scatter(result['ra'],result['dec'],s=7,color='r',marker='o')
plt.scatter(result['plug_ra'],result['plug_dec'],s=2,color='b')

# Extent of RA, Dec (in degrees) to plot
xmin = 126.
xmax = 131.
ymin = 7.
ymax = 12.

plt.axis([xmin, xmax, ymin, ymax])
plt.xlim(reversed(plt.xlim())) # flip the x-axis
plt.xlabel("RA (degrees)", fontsize=20)
plt.ylabel("Dec (degrees)", fontsize=20)
plt.show()

Visual Inspection of Large-Scale Structures

Plot the positions of a broad range of redshift, and overplot a thin slice in redshift to show possible structures within that slice.

In [16]:
# Select redshift slice
rz = np.where((result['z'] >0.105) & (result['z']<0.125))

plt.figure(figsize=(9,8))

# plot all points in red (all redshifts)
plt.scatter(result['plug_ra'],result['plug_dec'],s=3,color='r',marker='o',alpha=0.25)

# overplot in blue objects in narrow redshift slice
plt.scatter(result['plug_ra'][rz],result['plug_dec'][rz],s=5,color='b')

# Extent of RA, Dec (in degrees) to plot
xmin = 126.
xmax = 131.
ymin = 7.
ymax = 12.

plt.axis([xmin, xmax, ymin, ymax])
plt.xlim(reversed(plt.xlim())) # flip the x-axis
plt.xlabel("RA (degrees)", fontsize=20)
plt.ylabel("Dec (degrees)", fontsize=20)
plt.show()

Possible extension

One could plot again with symbols coded with object type (from LS) and/or class (from SDSS) and/or velocity dispersion (from SDSS).