Playing around with the dummy Gaia archive

gully

Sept 2, 2016

Attempt 1: 100000 sources in Taurus, $1^{\circ}$ radius

SELECT TOP 100000 * FROM public.gaia_source  WHERE CONTAINS(POINT('ICRS',public.gaia_source.ra,public.gaia_source.dec),CIRCLE('ICRS',64.1171208,28.1266139,1.0))=1

In [1]:
import pandas as pd
import numpy as np
import seaborn as sns
%config InlineBackend.figure_format = 'retina'
%matplotlib inline

In [2]:
import matplotlib.pyplot as plt

In [3]:
from astropy.io import votable

In [4]:
out = votable.parse_single_table('../data/result.vot_01.gz')


WARNING: W50: ../data/result.vot_01.gz:15:0: W50: Invalid unit string 'Angle[mas]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:51:0: W50: Invalid unit string 'Angle[mas^-2]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:54:0: W50: Invalid unit string 'Angle[mas^-2]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:57:0: W50: Invalid unit string 'Angle[deg]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:60:0: W50: Invalid unit string 'Angle[mas]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:63:0: W50: Invalid unit string 'Dimensionless[see description]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:66:0: W50: Invalid unit string 'Dimensionless[see description]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:69:0: W50: Invalid unit string 'Dimensionless[see description]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:75:0: W50: Invalid unit string 'Angle[mas]' [astropy.io.votable.tree]
WARNING: W50: ../data/result.vot_01.gz:78:0: W50: Invalid unit string 'Angle[mas]' (suppressing further warnings of this type...) [astropy.io.votable.tree]

In [5]:
out2 = out.to_table()

In [6]:
out3 = out2.to_pandas()

In [7]:
out2[0:5]


Out[7]:
<Table masked=True length=5>
astrometric_chi2_acastrometric_chi2_alastrometric_delta_qastrometric_excess_noiseastrometric_excess_noise_sigastrometric_go_fastrometric_n_obs_acastrometric_n_obs_alastrometric_n_outliers_acastrometric_n_outliers_alastrometric_params_solvedastrometric_primary_flagastrometric_priors_usedastrometric_rank_defectastrometric_relegation_factorastrometric_weight_acastrometric_weight_aldecdec_errordec_parallax_corrdec_pmdec_corrdec_pmra_corrmatched_observationsparallaxparallax_errorparallax_pmdec_corrparallax_pmra_corrphot_g_mean_fluxphot_g_mean_flux_errorphot_g_mean_magphot_g_n_obsphot_variable_flagpmdecpmdec_errorpmrapmra_errorpmra_pmdec_corrrara_dec_corrra_errorrandom_indexra_parallax_corrra_pmdec_corrra_pmra_corrref_epochscan_direction_mean_k1scan_direction_mean_k2scan_direction_mean_k3scan_direction_mean_k4scan_direction_strength_k1scan_direction_strength_k2scan_direction_strength_k3scan_direction_strength_k4source_id
Angle[mas]Angle[mas^-2]Angle[mas^-2]Angle[deg]Angle[mas]Dimensionless[see description]Dimensionless[see description]Dimensionless[see description]Angle[mas]Angle[mas]Dimensionless[see description]Dimensionless[see description]Flux[e-/s]Flux[e-/s]Magnitude[mag]Dimensionless[see description]Angular Velocity[mas/year]Angular Velocity[mas/year]Angular Velocity[mas/year]Angular Velocity[mas/year]Dimensionless[see description]Angle[deg]Dimensionless[see description]Angle[mas]Dimensionless[see description]Dimensionless[see description]Dimensionless[see description]Time[Julian Years]Angle[deg]Angle[deg]Angle[deg]Angle[deg]
float32float32float32float64float64float32int32int32int32int32int16boolint32int32float32float32float32float64float64float32float32float32int16float64float64float32float32float64float64float64int32objectfloat64float64float64float64float32float64float32float64int64float32float32float32float64float32float32float32float32float32float32float32float32int64
----0.00.00.00.0--------0False--00.0----27.2501136482745712.9999999355286926------0--------2669.7276411877683197.8467881934238917.0534326049804680------------64.66043817587564--2.9999999355286926--------2000.0----------------150870415718325888
----0.00.00.00.0--------0False--00.0----27.261580778401648.0000003166097127------0--------548.2766674921098242.33720903344455918.7721005889892570------------64.669052686381264--9.0000001729859775--------2000.0----------------150870518797541248
----0.00.00.00.0--------0False--00.0----27.26278416666665215.000000044043363------0--------243.6711004643320819.3842559974467919.6525899383544920------------64.67942749999996--21.999999771477011--------2000.0----------------150870518800285440
----0.00.00.00.0--------0False--00.0----27.2709305400933815.0000000146811203------0--------1946.9282805744538149.5350396382869717.3962251159667960------------64.681303252625014--5.0000000146811203--------2000.0----------------150870553157279744
----0.00.00.00.0--------0False--00.0----27.273506388888876324.99999362627483------0--------509.30110439028897187.6334637262738718.8521634552001950------------64.685003611111071--229.99999188173396--------2000.0----------------150870553158746240

In [10]:
plt.plot(out3.ra, out3.dec, '.', alpha=0.1)


Out[10]:
[<matplotlib.lines.Line2D at 0x118e44438>]

In [29]:
gaia = out3

In [30]:
gpos = SkyCoord(gaia.ra*u.deg, gaia.dec*u.deg, frame='icrs')

Let's make some postage stamps


In [11]:
from astropy.nddata import Cutout2D
from astropy import units as u
from astropy.io import fits
from astropy.coordinates import SkyCoord
from astropy.wcs import WCS
sns.set_style('ticks')

In [13]:
fn = '../data/LkCa4_DSS.fits'
hdu_list = fits.open(fn)
hdu_list.info()


Filename: ../data/LkCa4_DSS.fits
No.    Name         Type      Cards   Dimensions   Format
0    PRIMARY     PrimaryHDU     168   (300, 300)   float32   

In [14]:
image_data = hdu_list[0].data

hdu_list.close()
wcs = WCS('../data/LkCa4_DSS.fits')

In [15]:
position = SkyCoord('04h16m28.109s +28d07m35.81s', frame='icrs')

In [25]:
cutout = Cutout2D(image_data, position, 50.0*u.arcsecond, wcs=wcs)
cutout2 = Cutout2D(image_data, position, 150.0*u.arcsecond, wcs=wcs)

In [26]:
plt.imshow(image_data, origin='lower', interpolation='none')
cutout.plot_on_original(color='red', lw=2)


Out[26]:
<matplotlib.axes._subplots.AxesSubplot at 0x1200c3588>

In [27]:
from matplotlib.patches import Rectangle

In [52]:
ra_vec = np.arange(-5, 5)*u.arcsecond
d_ra = ra_vec.to(u.degree).value
mult_ra = position.ra.value + d_ra

dec_vec = np.arange(-5, 5)*u.arcsecond
d_dec = dec_vec.to(u.degree).value
mult_dec = position.dec.value + d_dec

fig = plt.figure(figsize=(10, 5))
ax1 = fig.add_subplot(131, projection=wcs)
plt.imshow(image_data.data, origin='lower', cmap='cubehelix_r', interpolation='none')
plt.xlabel('RA')
plt.ylabel('Dec')

cutout.plot_on_original(color='red', lw=2)

lon1 = ax1.coords[0]
lon1.set_major_formatter('hh:mm:ss')
#lon1.set_separator((':', ":"))

ax1.set_title('DSS overview')

xlims, ylims = ax1.get_xlim(), ax1.get_ylim()
ax1.set_xlim(xlims)
ax1.set_ylim(ylims)

ax1.scatter([gpos.ra.value], [gpos.dec.value], transform=ax1.get_transform('icrs'), s=20, c='g', marker='o', lw=1)

ax2 = fig.add_subplot(132, projection=cutout.wcs)
plt.imshow(cutout.data, origin='lower', cmap='Greys', interpolation='none')

lon = ax2.coords[0]
lat = ax2.coords[1]

lon.set_ticklabel_visible(False)
lat.set_ticklabel_visible(False)
lon.set_ticks(mult_ra * u.degree)
lat.set_ticks(mult_dec * u.degree)
ax2.scatter([position.ra.value], [position.dec.value], transform=ax2.get_transform('icrs'), s=60, c='r', marker='+', lw=2)

ra1 = position.ra.value + (12.0*u.arcsecond).to(u.degree).value
dec1 = position.dec.value + (10.0*u.arcsecond).to(u.degree).value
rect_post = (ra1, dec1)
ras, decs = (7.8*u.arcsecond).to(u.degree).value, (7.8*u.arcsecond).to(u.degree).value

r = Rectangle(rect_post, ras, decs, edgecolor='blue', facecolor='none', lw=2,
              transform=ax2.get_transform('icrs'))
#ax2.add_patch(r)
ax2.set_title(r"DSS 50''$\times$50'' ")

xlims, ylims = ax2.get_xlim(), ax2.get_ylim()
ax2.set_xlim(xlims)
ax2.set_ylim(ylims)

ax2.scatter([gpos.ra.value], [gpos.dec.value], transform=ax2.get_transform('icrs'), s=20, c='g', marker='o', lw=1)



ax3 = fig.add_subplot(133, projection=cutout2.wcs)
plt.imshow(cutout2.data, origin='lower', cmap='Greys', interpolation='none')


lon3 = ax3.coords[0]
lat3 = ax3.coords[1]

lon3.set_ticklabel_visible(False)
lat3.set_ticklabel_visible(False)
lon3.set_ticks(mult_ra * u.degree)
lat3.set_ticks(mult_dec * u.degree)
ax3.scatter([position.ra.value], [position.dec.value], transform=ax3.get_transform('icrs'), s=60, c='r', marker='+', lw=2)



xlims, ylims = ax3.get_xlim(), ax3.get_ylim()
ax3.set_xlim(xlims)
ax3.set_ylim(ylims)

ax3.scatter([gpos.ra.value], [gpos.dec.value], transform=ax3.get_transform('icrs'), s=20, c='g', marker='o', lw=1)


ax3.set_title(r"DSS 150''$\times$150'' ")
plt.savefig('../results/LkCa4_DSS_gaia.png', dpi=300)



In [51]:
!mkdir ../results

In [53]:
ra_vec = np.arange(-5, 5)*u.arcsecond
d_ra = ra_vec.to(u.degree).value
mult_ra = position.ra.value + d_ra

dec_vec = np.arange(-5, 5)*u.arcsecond
d_dec = dec_vec.to(u.degree).value
mult_dec = position.dec.value + d_dec

fig = plt.figure(figsize=(10, 5))
ax1 = fig.add_subplot(131, projection=wcs)
plt.imshow(image_data.data, origin='lower', cmap='cubehelix_r', interpolation='none')
plt.xlabel('RA')
plt.ylabel('Dec')

cutout.plot_on_original(color='red', lw=2)

lon1 = ax1.coords[0]
lon1.set_major_formatter('hh:mm:ss')
#lon1.set_separator((':', ":"))

ax1.set_title('DSS overview')

xlims, ylims = ax1.get_xlim(), ax1.get_ylim()
ax1.set_xlim(xlims)
ax1.set_ylim(ylims)

#ax1.scatter([gpos.ra.value], [gpos.dec.value], transform=ax1.get_transform('icrs'), s=20, c='g', marker='o', lw=1)



ax2 = fig.add_subplot(132, projection=cutout.wcs)
plt.imshow(cutout.data, origin='lower', cmap='Greys', interpolation='none')

lon = ax2.coords[0]
lat = ax2.coords[1]

lon.set_ticklabel_visible(False)
lat.set_ticklabel_visible(False)
lon.set_ticks(mult_ra * u.degree)
lat.set_ticks(mult_dec * u.degree)
ax2.scatter([position.ra.value], [position.dec.value], transform=ax2.get_transform('icrs'), s=60, c='r', marker='+', lw=2)

ra1 = position.ra.value + (12.0*u.arcsecond).to(u.degree).value
dec1 = position.dec.value + (10.0*u.arcsecond).to(u.degree).value
rect_post = (ra1, dec1)
ras, decs = (7.8*u.arcsecond).to(u.degree).value, (7.8*u.arcsecond).to(u.degree).value

r = Rectangle(rect_post, ras, decs, edgecolor='blue', facecolor='none', lw=2,
              transform=ax2.get_transform('icrs'))
#ax2.add_patch(r)
ax2.set_title(r"DSS 50''$\times$50'' ")

xlims, ylims = ax2.get_xlim(), ax2.get_ylim()
ax2.set_xlim(xlims)
ax2.set_ylim(ylims)

#ax2.scatter([gpos.ra.value], [gpos.dec.value], transform=ax2.get_transform('icrs'), s=20, c='g', marker='o', lw=1)



ax3 = fig.add_subplot(133, projection=cutout2.wcs)
plt.imshow(cutout2.data, origin='lower', cmap='Greys', interpolation='none')


lon3 = ax3.coords[0]
lat3 = ax3.coords[1]

lon3.set_ticklabel_visible(False)
lat3.set_ticklabel_visible(False)
lon3.set_ticks(mult_ra * u.degree)
lat3.set_ticks(mult_dec * u.degree)
ax3.scatter([position.ra.value], [position.dec.value], transform=ax3.get_transform('icrs'), s=60, c='r', marker='+', lw=2)



xlims, ylims = ax3.get_xlim(), ax3.get_ylim()
ax3.set_xlim(xlims)
ax3.set_ylim(ylims)

ax3.scatter([gpos.ra.value[vec]], [gpos.dec.value[vec]], transform=ax3.get_transform('icrs'), s=50, c='r', marker='o', lw=1)


ax3.set_title(r"DSS 150''$\times$150'' ")
plt.savefig('../results/LkCa4_DSS_reg.png', dpi=300)


//anaconda/lib/python3.4/site-packages/ipykernel/__main__.py:80: FutureWarning: in the future, boolean array-likes will be handled as a boolean array index

In [47]:
vec = out3.parallax == out3.parallax
vec.sum(), len(vec)


Out[47]:
(5, 31602)

In [ ]:


In [ ]: