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
from IPython.display import clear_output
    
In [2]:
    
from mltier1 import Field, Q_0, parallel_process, describe
    
In [3]:
    
%load_ext autoreload
    
In [4]:
    
%autoreload
    
In [5]:
    
from IPython.display import clear_output
    
In [6]:
    
%pylab inline
    
    
In [7]:
    
# Busy week Hatfield 2017
ra_down = 170.
ra_up = 190.
dec_down = 46.8
dec_up = 55.9
    
In [8]:
    
field = Field(170.0, 190.0, 46.8, 55.9)
    
In [9]:
    
combined = Table.read("pw.fits")
    
In [10]:
    
#lofar_all = Table.read("data/LOFAR_HBA_T1_DR1_catalog_v0.9.srl.fits")
lofar_all = Table.read("data/LOFAR_HBA_T1_DR1_merge_ID_optical_v0.8.fits")
    
In [11]:
    
np.array(combined.colnames)
    
    Out[11]:
In [12]:
    
np.array(lofar_all.colnames)
    
    Out[12]:
In [13]:
    
lofar_aux = lofar_all[~np.isnan(lofar_all['Maj'])]
    
In [14]:
    
lofar = field.filter_catalogue(lofar_aux[(lofar_aux['Maj'] < 30.) &
                                         (lofar_aux['ID_flag'] == 1)], 
                               colnames=("RA", "DEC"))
    
In [15]:
    
coords_combined = SkyCoord(combined['ra'], 
                           combined['dec'], 
                           unit=(u.deg, u.deg), 
                           frame='icrs')
    
In [16]:
    
coords_lofar = SkyCoord(lofar['RA'], 
                       lofar['DEC'], 
                       unit=(u.deg, u.deg), 
                       frame='icrs')
    
In [17]:
    
combined_matched = (~np.isnan(combined["i"]) & 
                    ~np.isnan(combined["W1mag"]))
np.sum(combined_matched) # Matches
    
    Out[17]:
In [18]:
    
combined_panstarrs = (~np.isnan(combined["i"]) & 
                      np.isnan(combined["W1mag"]))
np.sum(combined_panstarrs) # Only PanSTARSS
    
    Out[18]:
In [19]:
    
combined_wise =(np.isnan(combined["i"]) & 
                ~np.isnan(combined["W1mag"]))
np.sum(combined_wise) # Only WISE
    
    Out[19]:
In [20]:
    
combined_i = combined_matched | combined_panstarrs
combined_w1 = combined_matched | combined_wise
    
In [21]:
    
n_iter = 10
    
In [22]:
    
rads = list(range(1,26))
    
In [23]:
    
q_0_comp_i = Q_0(coords_lofar, coords_combined[combined_i], field)
    
In [24]:
    
q_0_rad_i = []
for radius in rads:
    q_0_rad_aux = []
    for i in range(n_iter):
        out = q_0_comp_i(radius=radius)
        q_0_rad_aux.append(out)
    q_0_rad_i.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 [25]:
    
plt.rcParams["figure.figsize"] = (5,5)
plot(rads, q_0_rad_i)
xlabel("Radius (arcsecs)")
ylabel("$Q_0 i-band$")
ylim([0, 1]);
    
    
In [26]:
    
q_0_comp_w1 = Q_0(coords_lofar, coords_combined[combined_w1], field)
    
In [27]:
    
q_0_rad_w1 = []
for radius in rads:
    q_0_rad_aux = []
    for i in range(n_iter):
        out = q_0_comp_w1(radius=radius)
        q_0_rad_aux.append(out)
    q_0_rad_w1.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 [28]:
    
plt.rcParams["figure.figsize"] = (5,5)
plot(rads, q_0_rad_w1)
xlabel("Radius (arcsecs)")
ylabel("$Q_0 W1-band$")
ylim([0, 1]);
    
    
In [ ]: