In [1]:
%matplotlib inline
import numpy as np, matplotlib.pyplot as plt, matplotlib.gridspec as gridspec
from mpl_toolkits.basemap import Basemap
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
In [2]:
[ra, dec, z], [ra_isol, dec_isol, z_isol], [ra_pair, dec_pair, z_pair], [ra_trip, dec_trip, z_trip] = [np.loadtxt(filename+'.txt', usecols = (0, 1, 2), unpack=True) for filename in ['SDSS_DR10_galaxy_local', 'table1', 'table2', 'table3']]
decstart, decrange, alpha0, raCen, raDelta = 0., 5., .2, 0., 180.
ra_tot, dec_tot, z_tot = [ra, ra_isol, ra_pair, ra_trip], [dec, dec_isol, dec_pair, dec_trip], [z, z_isol, z_pair, z_trip]
rad_tot = [np.radians(raval) for raval in ra_tot]
In [3]:
def plotSkymap(SDSS=True, Isolated=True, Pairs=False, Triplets=False, Opacity=alpha0, DecRange=decrange, Declination=decstart):
plt.figure(figsize=(15, 15))
gs = gridspec.GridSpec(1, 2)
ax1, ax2 = [plt.subplot(gs[i], polar=val, projection=pj) for i, val, pj in zip(range(0, 2), [True, False], [None, 'mollweide'])]
[ax.grid(True) for ax in [ax1, ax2]]
cond_dec = [((decval > Declination) & (decval < Declination + DecRange)) for decval in dec_tot]
xyplt = [ax1.plot(rad_tot[i][cond_dec[i]], z_tot[i][cond_dec[i]], krgb, ms=mval, alpha=alpval, visible=visi)[0]
for i, krgb, mval, alpval, visi in zip(range(0, 4), ['k.', 'ro', 'go', 'bo'], [1, 4, 4, 4],
[Opacity, .7, .7, .7], [SDSS, Isolated, Pairs, Triplets])]
x, y = [np.radians(val) for val in [-1*(ra - 180), dec]]
H, xedges, yedges = np.histogram2d(x.T, y.T, bins=50)
extent, levels = [xedges[0], xedges[-1], yedges[0], yedges[-1]], [100, 10000]
ax2.contourf(H.T, levels, origin='lower', colors='b', lw=1, extent=extent, alpha=.3)
[plt.setp(gtval, fontsize=fontval, alpha=.6) for gtval, fontval in zip([ax2.get_xticklabels(), ax2.get_yticklabels()], [8, 12])]
x_rect, y_rect = [np.radians(val) for val in [raCen + np.array([-1, -1, 1, 1, -1])*raDelta, Declination + np.array([0, 1, 1, 0, 0])*DecRange]]
ax2.fill(x_rect, y_rect, 'r', lw=0, alpha=.5)
plt.show()
In [4]:
interact(plotSkymap, SDSS=True, Isolated=True, Pairs=False, Triplets=False,
Declination=widgets.FloatSlider(min=-20.0, max=90.0, step=2.0, value=decstart),
DecRange=widgets.FloatSlider(min=0.0, max=90.0, step=1.0, value=decrange),
Opacity=widgets.FloatSlider(min=0.0, max=1.0, step=0.1, value=alpha0))
Out[4]:
In [ ]: