In [58]:
%autosave 20
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import astropy.units as u
from astropy.coordinates import SkyCoord
from astroquery.vizier import Vizier
from astroquery.simbad import Simbad
from astropy import table
Autosaving every 20 seconds
In [9]:
m67 = Simbad.query_object('M67')
display(m67)
# SkyCoord.guess_from_table(m67['RA', 'DEC'])
center = SkyCoord(ra=m67['RA'], dec=m67['DEC'],
                  unit=(u.hourangle, u.deg))
center
Table masked=True length=1
MAIN_IDRADECRA_PRECDEC_PRECCOO_ERR_MAJACOO_ERR_MINACOO_ERR_ANGLECOO_QUALCOO_WAVELENGTHCOO_BIBCODE
"h:m:s""d:m:s"masmasdeg
objectstr13str13int16int16float32float32int16str1str1object
NGC 268208 51 18+11 48.044----0E2005ApJ...619..824X
Out[9]:
<SkyCoord (ICRS): (ra, dec) in deg
    [(132.825, 11.8)]>
In [19]:
vizier = Vizier(
    column_filters={},
    row_limit=10000
)
twomass_table = vizier.query_region(
    center,
    radius=5*u.arcmin,
    catalog='2MASS'
)[0]
display(twomass_table)
# twomass = SkyCoord.guess_from_table(twomass_table)
twomass = SkyCoord(
    ra=twomass_table['RAJ2000'],
    dec=twomass_table['DEJ2000'],
    unit=(u.deg, u.deg),
)
sdss_table = vizier.query_region(
    center,
    radius=5*u.arcmin,
    catalog='SDSS7'
)[0]
display(sdss_table)
# sdss = SkyCoord.guess_from_table(sdss_table)
sdss = SkyCoord(
    ra=sdss_table['RA_ICRS'],
    dec=sdss_table['DE_ICRS'],
    unit=(u.deg, u.deg),
)
Table masked=True length=271
_qRAJ2000DEJ2000_2MASSJmage_JmagHmage_HmagKmage_KmagQflgRflgBflgCflgXflgAflg
degdegmagmagmagmagmagmag
int32float64float64bytes17float32float32float32float32float32float32bytes3bytes3bytes3bytes3uint8uint8
1132.81028511.74350108511446+114436613.8590.03613.4790.04113.3340.044AAA222222ccc00
1132.81027911.74469608511446+114440914.1760.02813.6500.02313.5980.036AAA222222ccc00
1132.79305411.73046208511033+114349616.2860.10415.5530.12115.4630.172ABC22211100000
1132.80617111.74037308511348+114425316.5060.12316.310--15.894--BUU20010000000
1132.78622511.73324308510869+114359616.5390.12616.2550.22915.621--BDU22011000000
1132.81785411.74246208511628+114432812.3080.02112.0210.02011.9540.020AAA22211100000
1132.83918011.73357508512140+114400814.8210.03714.3250.04914.0820.052AAA222111cc000
1132.84098911.72158108512183+114317613.2740.02313.0030.02312.9520.025AAA22211100000
1132.84891711.73617208512374+114410216.6690.14216.0110.19215.7900.229BCD22211100000
................................................
1132.89281711.82884108513427+114943811.8040.02211.5690.02211.5220.020AAA22211100000
1132.89272511.84845808513425+115054412.5850.02312.3410.02312.2570.023AAA22211100000
1132.88614511.84192008513267+115030914.1640.03013.6790.03213.6140.039AAA22211100000
1132.88395211.83433708513214+115003611.5140.02211.2260.02011.1980.020AAA22211100000
1132.88580111.81446408513259+114852010.6450.02210.5410.02010.5260.018AAA22211100000
1132.88573111.84461208513257+115040611.7300.02211.6570.02011.6170.020AAA22211100000
1132.80290411.87843608511269+11524238.6500.0188.1220.0187.9760.018AAA11111100000
1132.83399311.87998708512015+115247912.7720.02212.5450.02012.4570.021AAA22211100000
1132.85633411.87744908512552+115238812.1500.02211.8970.02011.8100.021AAA22211100000
1132.84064611.87717208512175+115237810.1050.0239.8160.0229.7600.018AAA22211100000
Table masked=True length=1401
_qmodeclSDSSm_SDSSzspumage_umaggmage_gmagrmage_rmagimage_imagzmage_zmagRA_ICRSDE_ICRSObsDateQ
magmagmagmagmagmagmagmagmagmagdegdegyr
int32uint8uint8bytes19bytes1float64float32float32float32float32float32float32float32float32float32float32float64float64float64uint8
123J085116.77+114829.2--20.8410.43122.4410.80424.6816.83224.2708.11418.3900.166132.81988611.8081152006.08443
116J085116.78+115038.8--14.9670.00615.0490.01314.2430.00913.3690.00913.2020.005132.81992011.8441352005.93143
126J085116.78+115038.9--15.0470.00614.5350.00914.1960.00915.1870.01113.2490.004132.81992611.8441512006.01613
116J085116.81+114541.6--15.8730.00514.4390.00313.9210.00313.7350.00313.7260.004132.82005311.7615612005.93143
113J085116.81+114807.4--17.6250.07419.8370.14116.1030.01314.9470.01616.5340.113132.82006311.8020672005.93143
126J085116.81+114541.6*--16.4320.00814.9110.00515.8220.01414.1560.00514.2140.007132.82006911.7615662006.08443
116J085116.85+114938.6--19.2660.03016.8060.00415.7330.00415.3670.00415.1670.005132.82023411.8274052005.93143
126J085116.85+114938.6*--19.1930.02716.7910.00415.7360.00315.3560.00315.1520.005132.82023911.8274122006.01613
116J085116.97+115009.3--14.8850.00414.5390.01114.9190.01115.2250.01413.2450.005132.82072611.8359242005.93143
............................................................
126J085116.32+114711.3--24.3980.71621.9910.06920.4500.02919.0810.01518.3080.020132.81801611.7864762006.08443
126J085116.43+114834.3--25.5920.81121.9660.07821.7770.10420.2210.04220.4050.131132.81847111.8095272006.01613
116J085116.46+114607.3--23.5830.84420.8070.03319.2310.01318.2220.00917.6520.017132.81860811.7687192005.93143
116J085116.47+114900.1--21.3810.13918.7400.00917.3610.00516.7980.00516.4710.008132.81862811.8166932005.93143
126J085116.47+114900.1*--21.1170.10718.7190.00817.3690.00516.7950.00516.5030.008132.81863011.8167012006.01613
126J085116.50+114723.9--22.3930.21822.0690.07722.2710.13722.2610.18923.0570.419132.81876911.7899832006.08443
123J085116.61+114529.3--24.6319.99917.0000.02016.1280.01516.1880.01914.3330.017132.81924111.7581382006.08443
113J085116.65+114528.9--24.3583.65216.0210.01516.6230.02416.4730.02422.8239.999132.81941211.7580522005.93143
116J085116.68+114529.3--14.8460.00514.8860.01114.7480.01114.6360.01212.4900.004132.81953711.7581442005.93143
126J085116.69+114529.3--14.5710.00615.4030.01215.7980.01414.6510.01313.4140.014132.81956411.7581642006.08443
In [36]:
plt.figure(figsize=(6,6))
plt.plot(twomass.ra.to_value(u.deg),
         twomass.dec.to_value(u.deg),
        'x', color='blue')
plt.plot(sdss.ra.to_value(u.deg),
         sdss.dec.to_value(u.deg),
        '.', color='green')
plt.scatter(center.ra.to_value(u.deg),
            center.dec.to_value(u.deg),
            marker='*', color='red')
Out[36]:
<matplotlib.collections.PathCollection at 0x7f22e4809940>
In [39]:
idx_close_to_center = center.separation(twomass) < 1 * u.arcmin
twomass_table[idx_close_to_center]
Out[39]:
Table masked=True length=13
_qRAJ2000DEJ2000_2MASSJmage_JmagHmage_HmagKmage_KmagQflgRflgBflgCflgXflgAflg
degdegmagmagmagmagmagmag
int32float64float64bytes17float32float32float32float32float32float32bytes3bytes3bytes3bytes3uint8uint8
1132.81150511.78997108511476+114723811.7470.02111.4950.02211.4300.018AAA22211100000
1132.81540611.80434308511569+114815613.2440.02412.9650.02712.9550.026AAA222111ddd00
1132.82786911.78406208511868+114702611.0170.02110.6190.02010.5290.018AAA22211100000
1132.82918911.78918708511900+114721015.8190.07415.0920.08915.0420.116AAB222111sss00
1132.82992711.79850608511918+114754612.5660.02112.2470.02012.1820.020AAA22211100000
1132.82125711.80446008511710+11481608.1400.0277.5260.0187.3850.021AAA11111100000
1132.83006911.80747508511921+114826915.1510.04214.6000.05414.3120.060AAA22211100000
1132.82334111.80454008511760+114816314.6160.02311.767--11.455--AUU200100c0000
1132.81796611.78654808511631+114711516.7620.16415.665--15.393--CUU266200c0000
1132.83627511.80873708512070+114831415.4680.04814.8430.06614.5620.074AAA22211100000
1132.81436311.79204908511544+114731311.7080.02111.4750.02011.4300.018AAA22211100000
1132.83287511.81045108511989+114837615.0840.04314.5080.04814.4450.067AAA22211100000
1132.81702711.78732608511608+114714315.9470.08615.164--14.736--AUU266200c0000
In [43]:
idx_twomass, idx_sdss, d2d, d3d = sdss.search_around_sky(
    twomass, 2*u.arcsec
)
twomass_table[idx_twomass]
Out[43]:
Table masked=True length=556
_qRAJ2000DEJ2000_2MASSJmage_JmagHmage_HmagKmage_KmagQflgRflgBflgCflgXflgAflg
degdegmagmagmagmagmagmag
int32float64float64bytes17float32float32float32float32float32float32bytes3bytes3bytes3bytes3uint8uint8
1132.81028511.74350108511446+114436613.8590.03613.4790.04113.3340.044AAA222222ccc00
1132.81028511.74350108511446+114436613.8590.03613.4790.04113.3340.044AAA222222ccc00
1132.81027911.74469608511446+114440914.1760.02813.6500.02313.5980.036AAA222222ccc00
1132.81027911.74469608511446+114440914.1760.02813.6500.02313.5980.036AAA222222ccc00
1132.79305411.73046208511033+114349616.2860.10415.5530.12115.4630.172ABC22211100000
1132.79305411.73046208511033+114349616.2860.10415.5530.12115.4630.172ABC22211100000
1132.80617111.74037308511348+114425316.5060.12316.310--15.894--BUU20010000000
1132.80617111.74037308511348+114425316.5060.12316.310--15.894--BUU20010000000
1132.78622511.73324308510869+114359616.5390.12616.2550.22915.621--BDU22011000000
................................................
1132.88573111.84461208513257+115040611.7300.02211.6570.02011.6170.020AAA22211100000
1132.88573111.84461208513257+115040611.7300.02211.6570.02011.6170.020AAA22211100000
1132.80290411.87843608511269+11524238.6500.0188.1220.0187.9760.018AAA11111100000
1132.80290411.87843608511269+11524238.6500.0188.1220.0187.9760.018AAA11111100000
1132.83399311.87998708512015+115247912.7720.02212.5450.02012.4570.021AAA22211100000
1132.83399311.87998708512015+115247912.7720.02212.5450.02012.4570.021AAA22211100000
1132.85633411.87744908512552+115238812.1500.02211.8970.02011.8100.021AAA22211100000
1132.85633411.87744908512552+115238812.1500.02211.8970.02011.8100.021AAA22211100000
1132.84064611.87717208512175+115237810.1050.0239.8160.0229.7600.018AAA22211100000
1132.84064611.87717208512175+115237810.1050.0239.8160.0229.7600.018AAA22211100000
In [59]:
idx_sdss, d2d, d3d = twomass.match_to_catalog_sky(sdss)
t = table.hstack((twomass_table, sdss_table[idx_sdss]))
t['sep'] = d2d
t
/opt/conda/lib/python3.6/site-packages/astropy/utils/metadata.py:360: MergeConflictWarning: Cannot merge meta key 'ID' types <class 'str'> and <class 'str'>, choosing ID='II_294_sdss7'
  MergeConflictWarning)
/opt/conda/lib/python3.6/site-packages/astropy/utils/metadata.py:360: MergeConflictWarning: Cannot merge meta key 'name' types <class 'str'> and <class 'str'>, choosing name='II/294/sdss7'
  MergeConflictWarning)
/opt/conda/lib/python3.6/site-packages/astropy/utils/metadata.py:360: MergeConflictWarning: Cannot merge meta key 'description' types <class 'str'> and <class 'str'>, choosing description='* output of the SDSS photometric catalog'
  MergeConflictWarning)
Out[59]:
Table masked=True length=271
_q_1RAJ2000DEJ2000_2MASSJmage_JmagHmage_HmagKmage_KmagQflgRflgBflgCflgXflgAflg_q_2modeclSDSSm_SDSSzspumage_umaggmage_gmagrmage_rmagimage_imagzmage_zmagRA_ICRSDE_ICRSObsDateQsep
degdegmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagdegdegyrdeg
int32float64float64bytes17float32float32float32float32float32float32bytes3bytes3bytes3bytes3uint8uint8int32uint8uint8bytes19bytes1float64float32float32float32float32float32float32float32float32float32float32float64float64float64uint8float64
1132.81028511.74350108511446+114436613.8590.03613.4790.04113.3340.044AAA222222ccc00116J085114.46+114436.5--17.2550.00915.6530.00415.0710.00314.8920.00414.7840.005132.81025311.7434962006.084433.17266619626919e-05
1132.81027911.74469608511446+114440914.1760.02813.6500.02313.5980.036AAA222222ccc00116J085114.45+114440.9--17.9810.01316.2100.00415.3990.00315.2030.00415.3410.005132.81024611.7446972006.084433.232459429986805e-05
1132.79305411.73046208511033+114349616.2860.10415.5530.12115.4630.172ABC22211100000116J085110.32+114349.5--22.8520.28020.0670.01718.6610.00918.0010.00817.6140.014132.79302811.7304412006.084433.300088183610788e-05
1132.80617111.74037308511348+114425316.5060.12316.310--15.894--BUU20010000000126J085113.48+114425.6*--25.3001.04021.8100.07120.3920.03018.9750.01318.2260.025132.80619611.7404562005.931438.65339410341914e-05
1132.78622511.73324308510869+114359616.5390.12616.2550.22915.621--BDU22011000000116J085108.61+114359.3--20.9280.06519.0750.01018.3510.00818.1360.00918.0190.017132.78591411.7331642006.084430.00031458271139627445
1132.81785411.74246208511628+114432812.3080.02112.0210.02011.9540.020AAA22211100000116J085116.28+114432.8--16.1570.01116.0070.01915.6070.01215.0570.01814.4510.012132.81783311.7424452006.084432.6678360157593366e-05
1132.83918011.73357508512140+114400814.8210.03714.3250.04914.0820.052AAA222111cc000116J085121.39+114400.8--20.1720.04017.7010.00616.5790.00416.2100.00515.9800.007132.83913911.7335632006.084434.189846167827402e-05
1132.84098911.72158108512183+114317613.2740.02313.0030.02312.9520.025AAA22211100000116J085121.83+114317.6--16.3070.00715.0820.00515.5960.01214.3900.00514.2920.006132.84097511.7215812006.084431.3708049052631302e-05
1132.84891711.73617208512374+114410216.6690.14216.0110.19215.7900.229BCD22211100000126J085123.71+114410.6--25.2701.03821.1710.04219.6610.01818.6130.01117.9670.021132.84882411.7362952005.931430.00015303644818535168
...............................................................................................................
1132.89281711.82884108513427+114943811.8040.02211.5690.02211.5220.020AAA22211100000126J085134.27+114943.8*--14.8760.00513.3220.00314.1910.00912.7810.00113.0410.004132.89280711.8288322006.016131.3296539552404174e-05
1132.89272511.84845808513425+115054412.5850.02312.3410.02312.2570.023AAA22211100000116J085134.25+115054.4--15.2990.00514.2070.00314.4820.01113.9890.01213.6080.004132.89271111.8484532005.931431.458550850287712e-05
1132.88614511.84192008513267+115030914.1640.03013.6790.03213.6140.039AAA22211100000116J085132.67+115030.8--18.0880.01616.1760.00315.4600.00415.2410.00415.1080.005132.88614311.8419082005.931431.2158599918403357e-05
1132.88395211.83433708513214+115003611.5140.02211.2260.02011.1980.020AAA22211100000126J085132.14+115003.5--14.7400.00514.9540.01014.7230.00914.5940.01013.2740.005132.88393811.8343242006.016131.8887997936612012e-05
1132.88580111.81446408513259+114852010.6450.02210.5410.02010.5260.018AAA22211100000116J085132.59+114851.9--14.4170.00714.0000.00811.5890.00113.2020.00813.2500.012132.88579811.8144362005.931432.815355613377517e-05
1132.88573111.84461208513257+115040611.7300.02211.6570.02011.6170.020AAA22211100000116J085132.57+115040.5--14.5580.00614.6010.00914.9230.01114.1860.01013.4410.007132.88571411.8446032005.931431.8916241033416936e-05
1132.80290411.87843608511269+11524238.6500.0188.1220.0187.9760.018AAA11111100000126J085112.68+115242.3--15.1550.00811.0210.00110.1730.00112.1340.00310.4110.001132.80285911.8784272006.016134.49466797568373e-05
1132.83399311.87998708512015+115247912.7720.02212.5450.02012.4570.021AAA22211100000126J085120.15+115247.9*--15.2960.00414.0710.00313.6990.00314.9880.01213.6000.003132.83397611.8799812006.016131.7684806515114607e-05
1132.85633411.87744908512552+115238812.1500.02211.8970.02011.8100.021AAA22211100000126J085125.51+115238.7--14.9700.00414.3460.01113.9560.01015.0900.01113.2230.004132.85632711.8774342006.016131.649012706041507e-05
1132.84064611.87717208512175+115237810.1050.0239.8160.0229.7600.018AAA22211100000116J085121.74+115237.8--14.5880.00714.4760.00810.4680.00110.3940.00111.4800.002132.84062311.8771712005.931432.252979828595256e-05