In [2]:
import os
import numpy as np
import numpy.ma as ma
from astropy.io import ascii
import matplotlib.pyplot as plt
from astroML.stats import binned_statistic_2d
import seaborn as sns
#from scipy.stats import gaussian_kde
%matplotlib inline
sns.set(style='white', font_scale=1.6, palette='deep')
In [4]:
# Read the full catalog
dat = ascii.read(os.path.join(os.getenv('HOME'),'dr2-grz.txt'),
format='fixed_width', delimiter='|', data_start=2)#, data_end=10000)
dat
Out[4]:
In [3]:
# Do some juggling to deal with masked values and then define the g-r and r-z colors.
rcut = 20.0
dat['gflux'].fill_value = -99
dat['rflux'].fill_value = -99
dat['zflux'].fill_value = -99
good = np.where((dat['gflux']>0)*(dat['rflux']>0)*(dat['zflux']>0)*(dat['rflux']>10**(0.4*(22.5-rcut)))*1)[0]
gr = -2.5*np.log10(np.array(dat['gflux'][good]/dat['rflux'][good]))
rz = -2.5*np.log10(np.array(dat['rflux'][good]/dat['zflux'][good]))
print(len(gr))
In [1]:
# Make a fancy histogram - http://www.astroml.org/examples/datasets/plot_SDSS_SSPP.html
xlim = (-0.7, 2.0)
ylim = (-0.7, 2.0)
N, xedges, yedges = binned_statistic_2d(rz, gr, gr, 'count',
bins=100, range=[xlim, ylim])
N[N<10] = 0
print(np.log10(N).max())
# Define custom colormaps: Set pixels with no sources to white
cmap = plt.cm.jet
cmap.set_bad('w', 1.)
cmap_multicolor = plt.cm.jet
cmap_multicolor.set_bad('w', 1.)
In [35]:
# Create figure and subplots
fig = plt.figure(figsize=(10, 6))
fig.subplots_adjust(wspace=0.25, left=0.1, right=0.95,
bottom=0.07, top=0.95)
#ax.scatter(rz, gr, c=nn, s=50, edgecolor='', cmap=cm.Blues)
#sns.kdeplot(rz, gr, clip=(xlim, ylim), ax=ax, gridsize=40,
# cmap="Reds", shade=True, cut=0, shade_lowest=False)
#ax.scatter(gr[:100], rz[:100], marker='s')
plt.subplot(111, xticks=[4000, 5000, 6000, 7000, 8000])
plt.imshow(np.log10(N.T), origin='lower',
extent=[xedges[0], xedges[-1], yedges[0], yedges[-1]],
aspect='auto', interpolation='nearest', cmap=cmap)
levels = np.linspace(0, np.log10(N.max()), 7)[2:]
plt.contour(np.log10(N.T), levels, colors='k', linewidths=1,
extent=[xedges[0], xedges[-1], yedges[0], yedges[-1]])
plt.xlim(xedges[0], xedges[-1])
plt.ylim(yedges[0], yedges[-1])
plt.xlabel('r - z')
plt.ylabel('g - r')
plt.colorbar()
#cb = plt.colorbar(ticks=[0, 1, 2, 3], format=r'$10^{%i}$')
#cb.set_label(r'$\mathrm{Number\ of\ objects}$')
#plt.clim(0, 3)
#plt.tight_layout()
plt.show()
In [ ]: