In [1]:
import numpy as np
from astropy.table import Table
from astropy import units as u
from astropy.coordinates import SkyCoord, search_around_sky
In [2]:
from mltier1 import generate_random_catalogue, Field, Q_0
In [3]:
%load_ext autoreload
In [4]:
%pylab inline
In [5]:
field = Field(170.0, 190.0, 45.5, 56.5)
In [6]:
panstarrs_full = Table.read("panstarrs_u2.fits")
In [7]:
wise_full = Table.read("wise_u2.fits")
In [8]:
panstarrs = field.filter_catalogue(
panstarrs_full,
colnames=("raMean", "decMean"))
In [9]:
# Free memory
del panstarrs_full
In [10]:
wise = field.filter_catalogue(
wise_full,
colnames=("raWise", "decWise"))
In [11]:
# Free memory
del wise_full
In [12]:
coords_panstarrs = SkyCoord(panstarrs['raMean'], panstarrs['decMean'], unit=(u.deg, u.deg), frame='icrs')
In [13]:
coords_wise = SkyCoord(wise['raWise'], wise['decWise'], unit=(u.deg, u.deg), frame='icrs')
In [14]:
# Example function (not used, we use a class that contains this code)
def q_0_r(coords_wise, coords_panstarrs, field, radius=5):
"""Compute the Q_0 for a given radius"""
random_wise = field.random_catalogue(len(coords_wise))
idx_random_wise, idx_panstarrs, d2d, d3d = search_around_sky(
random_wise, coords_panstarrs, radius*u.arcsec)
nomatch_random = len(coords_wise) - len(np.unique(idx_random_wise))
idx_wise, idx_panstarrs, d2d, d3d = search_around_sky(
coords_wise, coords_panstarrs, radius*u.arcsec)
nomatch_wise = len(coords_wise) - len(np.unique(idx_wise))
return (1. - float(nomatch_wise)/float(nomatch_random))
In [15]:
q_0_comp = Q_0(coords_wise, coords_panstarrs, field)
In [16]:
q_0_comp(radius=5)
Out[16]:
In [17]:
n_iter = 10
The radius tested ranges from 1 to 25
In [18]:
rads = list(range(1,26))
In [19]:
q_0_rad = []
for radius in rads:
q_0_rad_aux = []
for i in range(n_iter):
out = q_0_comp(radius=radius)
q_0_rad_aux.append(out)
q_0_rad.append(np.mean(q_0_rad_aux))
print("{:2d} {:7.5f} +/- {:7.5f} [{:7.5f} {:7.5f}]".format(radius,
np.mean(q_0_rad_aux), np.std(q_0_rad_aux),
np.min(q_0_rad_aux), np.max(q_0_rad_aux)))
In [20]:
plt.rcParams["figure.figsize"] = (5,5)
plot(rads, q_0_rad)
xlabel("Radius (arcsecs)")
ylabel("$Q_0$")
ylim([0, 1]);
In [ ]: