In [1]:
import numpy as np
import pandas as pd
from astropy import coordinates
from astropy.coordinates import match_coordinates_sky
import astropy.units as u
import astroquery
from astroquery.irsa import Irsa
from astroquery.vizier import Vizier
from astropy.table import Table, join
Irsa.ROW_LIMIT = -1
Vizier.ROW_LIMIT = -1
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
obj = ["3C 454.3", 343.49062, 16.14821, 4./60.]
# name, ra, dec, radius of cone
obj_name = obj[0]
obj_ra = obj[1]
obj_dec = obj[2]
cone_radius = obj[3]
In [3]:
obj_coord = coordinates.SkyCoord(ra=obj_ra, dec=obj_dec, unit=(u.deg, u.deg), frame="icrs")
In [4]:
data_2mass = Irsa.query_region(obj_coord, catalog="fp_psc", radius=cone_radius * u.deg)
data_wise = Irsa.query_region(obj_coord, catalog="allwise_p3as_psd", radius=cone_radius * u.deg)
__data_galex = Vizier.query_region(obj_coord, catalog='II/335', radius=cone_radius * u.deg)
data_galex = __data_galex[0]
In [5]:
num_2mass = len(data_2mass)
num_wise = len(data_wise)
num_galex = len(data_galex)
print("Number of object in (2MASS, WISE, GALEX): ", num_2mass, num_wise, num_galex)
In [6]:
ra_2mass = data_2mass['ra']
dec_2mass = data_2mass['dec']
c_2mass = coordinates.SkyCoord(ra=ra_2mass, dec=dec_2mass, unit=(u.deg, u.deg), frame="icrs")
ra_wise = data_wise['ra']
dec_wise = data_wise['dec']
c_wise = coordinates.SkyCoord(ra=ra_wise, dec=dec_wise, unit=(u.deg, u.deg), frame="icrs")
ra_galex = data_galex['RAJ2000']
dec_galex = data_galex['DEJ2000']
c_galex = coordinates.SkyCoord(ra=ra_galex, dec=dec_galex, unit=(u.deg, u.deg), frame="icrs")
In [7]:
sep_min = 2.5 * u.arcsec # minimum separation in arcsec
In [8]:
idx_2mass, idx_wise, d2d, d3d = c_wise.search_around_sky(c_2mass, sep_min)
c_2mass_wise = c_2mass[idx_2mass]
___idx_2mass_wise_galex, idx_galex, d2d, d3d = c_galex.search_around_sky(c_2mass_wise, sep_min)
match_all_coord = c_galex[idx_galex]
print("Match all 3 cats: ", len(match_all_coord))
In [9]:
### GALEX data which match with 2MASS and WISE!
match_galex = data_galex[idx_galex]
match_galex
Out[9]:
In [10]:
idx_2mass, idx, d2d, d3d = match_all_coord.search_around_sky(c_2mass, sep_min)
match_2mass = data_2mass[idx_2mass]
match_2mass
Out[10]:
In [11]:
idx_wise, idx, d2d, d3d = match_all_coord.search_around_sky(c_wise, sep_min)
match_wise = data_wise[idx_wise]
match_wise
Out[11]:
In [12]:
# joindata = Table([match_2mass['j_m'],
# match_2mass['j_m']-match_2mass['h_m'],
# match_2mass['j_m']-match_2mass['k_m'],
# match_2mass['j_m']-match_wise['w1mpro'],
# match_2mass['j_m']-match_wise['w2mpro'],
# match_2mass['j_m']-match_wise['w3mpro'],
# match_2mass['j_m']-match_wise['w4mpro'],
# match_2mass['j_m']-match_galex['NUVmag']],
# names=('J', 'J-H', 'J-K', 'J-W1', 'J-W2', 'J-W3', 'J-W4', 'J-NUV'))
In [13]:
joindata = np.array([match_2mass['j_m'],
match_2mass['j_m']-match_2mass['h_m'],
match_2mass['j_m']-match_2mass['k_m'],
match_2mass['j_m']-match_wise['w1mpro'],
match_2mass['j_m']-match_wise['w2mpro'],
match_2mass['j_m']-match_wise['w3mpro'],
match_2mass['j_m']-match_wise['w4mpro'],
match_2mass['j_m']-match_galex['NUVmag']])
joindata = joindata.T
In [14]:
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.decomposition import PCA
from sklearn.preprocessing import scale
X = joindata
X = scale(X)
pca = PCA(n_components=2)
X_r = pca.fit(X).transform(X)
In [15]:
plt.scatter(X_r[:,0], X_r[:,1])
Out[15]:
In [ ]: