# 安装astroquery
# !pip install --pre astroquery
import numpy as np
from matplotlib import cm, colors, pyplot as plt
import astropy.units as u
from astroquery import gaia
from astroquery.gaia import Gaia as g
%%time
# 使用SQL(ADQL)查询:按视差降序排序,前100条数据
tab = g.launch_job_async('''
select top 100
*
from gaiadr3.gaia_source_lite
where parallax > 0
order by parallax desc
''').get_results()
print(len(tab))
INFO: Query finished. [astroquery.utils.tap.core] 100 CPU times: user 64.9 ms, sys: 4.94 ms, total: 69.8 ms Wall time: 3.8 s
# 把周年视差转换成距离:
# 1.距离(distance)= 1/周年视差(parallax)
tab['distance'] = 1 / tab['parallax']
tab['distance'].unit = 'kpc'
# 2.距离单位转换:千秒差距 -> 光年
tab['distance'] = tab['distance'].to(u.lightyear)
# 距离分布
plt.hist(tab['distance'], bins=(100))
plt.show()
# 打印表格
print('距离我们最近的100颗恒星')
display(tab)
距离我们最近的100颗恒星
source_id | random_index | ra | dec | parallax | parallax_error | parallax_over_error | pmra | pmra_error | pmdec | pmdec_error | astrometric_params_solved | pseudocolour | pseudocolour_error | ipd_frac_multi_peak | ipd_frac_odd_win | ruwe | phot_g_mean_flux_over_error | phot_g_mean_mag | phot_bp_mean_flux_over_error | phot_bp_mean_mag | phot_rp_mean_flux_over_error | phot_rp_mean_mag | phot_bp_rp_excess_factor | bp_rp | radial_velocity | radial_velocity_error | rv_nb_transits | rv_expected_sig_to_noise | rv_renormalised_gof | rv_chisq_pvalue | phot_variable_flag | l | b | in_qso_candidates | in_galaxy_candidates | non_single_star | has_xp_continuous | has_xp_sampled | has_rvs | has_epoch_photometry | has_epoch_rv | has_mcmc_gspphot | has_mcmc_msc | in_andromeda_survey | teff_gspphot | logg_gspphot | mh_gspphot | distance_gspphot | ag_gspphot | ebpminrp_gspphot | distance |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | mas | mas | mas / yr | mas / yr | mas / yr | mas / yr | 1 / um | 1 / um | mag | mag | mag | mag | km / s | km / s | deg | deg | K | log(cm.s**-2) | dex | pc | mag | mag | lyr | |||||||||||||||||||||||||||
int64 | int64 | float64 | float64 | float64 | float32 | float32 | float64 | float32 | float64 | float32 | int16 | float32 | float32 | int16 | int16 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 | int16 | float32 | float32 | float32 | object | float64 | float64 | bool | bool | int16 | bool | bool | bool | bool | bool | bool | bool | bool | float32 | float32 | float32 | float32 | float32 | float32 | float64 |
5853498713190525696 | 1320081859 | 217.39232147200883 | -62.67607511676666 | 768.0665391873573 | 0.049872905 | 15400.477 | -3781.741008265163 | 0.031386077 | 769.4650146478623 | 0.050524533 | 95 | 1.1408331 | 0.007456389 | 11 | 0 | 0.97145325 | 1527.8928 | 8.984749 | 420.41574 | 11.373116 | 618.5337 | 7.5685353 | 1.6316793 | 3.8045802 | -21.942726 | 0.21612652 | 7 | 222.26839 | -3.3928843 | 0.8895482 | NOT_AVAILABLE | 313.92549558326704 | -1.9177544232946377 | False | False | 0 | True | True | False | False | False | True | False | False | 2829.3542 | 5.1373 | -0.1806 | 1.3011 | 0.0 | 0.0 | 4.246459923404928 |
4472832130942575872 | 1329945144 | 269.44850252543836 | 4.739420051112412 | 546.975939730948 | 0.040116355 | 13634.737 | -801.5509783684709 | 0.031820867 | 10362.394206546573 | 0.036070455 | 31 | -- | -- | 0 | 0 | 1.0848505 | 1553.9851 | 8.1939745 | 951.9071 | 9.791788 | 1518.3344 | 6.9580913 | 1.4803807 | 2.8336968 | -110.46822 | 0.13125522 | 12 | 381.34583 | -4.171129 | 0.5895669 | NOT_AVAILABLE | 31.049417957939717 | 14.08660366802383 | False | False | 0 | True | True | False | False | False | True | False | False | 3099.6335 | 4.764 | -0.9072 | 1.8275 | 0.0 | 0.0 | 5.962901729775837 |
3864972938605115520 | 766292388 | 164.10319030755974 | 7.002726940984864 | 415.17941567802137 | 0.06837086 | 6072.462 | -3866.3382751436793 | 0.08130645 | -2699.214987679166 | 0.06910815 | 95 | 1.0886071 | 0.015429774 | 3 | 0 | 0.8353354 | 722.8211 | 11.038391 | 232.04747 | 13.770287 | 504.92255 | 9.58545 | 1.6632524 | 4.1848364 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 244.05115057496633 | 56.09885280026159 | False | False | 0 | True | True | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 7.8557935533509955 |
762815470562110464 | 970765473 | 165.83095967577933 | 35.948653032660104 | 392.75294543876464 | 0.03206665 | 12248.019 | -580.0570872139048 | 0.025565954 | -4776.588719443488 | 0.030034095 | 95 | 1.2979331 | 0.0075547816 | 0 | 0 | 0.9638494 | 2079.2886 | 6.551172 | 974.18225 | 7.6911216 | 1037.6364 | 5.475513 | 1.3874384 | 2.2156086 | -85.11064 | 0.13100341 | 11 | 709.08905 | -- | 0.49117628 | NOT_AVAILABLE | 185.1695098360815 | 65.4339878357637 | False | False | 0 | True | True | False | False | False | True | False | False | 3511.045 | 4.8322 | -0.1783 | 2.5453 | 0.0 | 0.0 | 8.304364906859634 |
2947050466531873024 | 52974825 | 101.28662552099249 | -16.720932526023173 | 374.48958852876103 | 0.2313347 | 1618.8214 | -461.570505530133 | 0.2779457 | -914.5196209016666 | 0.33150372 | 31 | -- | -- | 18 | 0 | 2.4190555 | 621.3722 | 8.524133 | 23.208166 | 8.120362 | 27.79296 | 8.398789 | 1.5243522 | -0.27842712 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 227.2344521579568 | -8.892834154293482 | False | False | 0 | True | True | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 8.7093576886369 |
5140693571158946048 | 575090658 | 24.771674208211856 | -17.947682860008488 | 373.8443122683992 | 0.50087124 | 746.38806 | 3178.6942575748953 | 0.42692018 | 584.0613350385156 | 0.30229247 | 95 | 1.7280899 | 0.07499732 | 10 | 0 | 10.453167 | 538.3399 | 10.817838 | 108.16757 | 13.252207 | 70.54292 | 9.423653 | 1.5971872 | 3.8285542 | 10.249533 | 3.2381904 | 4 | 59.103638 | -- | -- | NOT_AVAILABLE | 175.5190466595442 | -75.6864408461554 | False | False | 0 | False | False | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 8.724390528712428 |
5140693571158739840 | 633518913 | 24.771554293454546 | -17.948299887129313 | 367.71189618147696 | 0.74180114 | 495.70142 | 3385.315810465071 | 0.67216444 | 544.3863845619521 | 0.3787539 | 31 | -- | -- | 9 | 0 | 12.367461 | 1439.128 | 10.507542 | 194.82921 | 12.820644 | 86.96797 | 9.067688 | 1.6715958 | 3.7529564 | 21.458223 | 0.7900771 | 7 | 83.45942 | -- | -- | NOT_AVAILABLE | 175.52059241295885 | -75.6869385406657 | False | False | 0 | True | True | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 8.869889201402808 |
4075141768785646848 | 249919922 | 282.4587890175222 | -23.83709744872712 | 336.0266016683708 | 0.031666122 | 10611.549 | 639.367850335873 | 0.03683873 | -193.95792507116096 | 0.031829588 | 31 | -- | -- | 0 | 0 | 0.98801184 | 1233.3462 | 9.126414 | 341.96747 | 10.732183 | 798.3095 | 7.898147 | 1.4699805 | 2.8340364 | -11.11644 | 0.5655069 | 11 | 241.3441 | -2.5438895 | 0.0017242172 | NOT_AVAILABLE | 11.307625151239241 | -10.287475752633519 | False | False | 0 | False | False | True | False | False | False | False | False | 3117.376 | 4.776 | -0.84 | 2.9762 | 1e-04 | 1e-04 | 9.70626659012644 |
1926461164913660160 | 1195011327 | 355.4800152581559 | 44.170375700747755 | 316.48118678226916 | 0.044448785 | 7120.1313 | 112.52746493350043 | 0.036434025 | -1591.6497618145506 | 0.026793785 | 31 | -- | -- | 8 | 0 | 1.0273284 | 1519.5181 | 10.379277 | 527.5998 | 12.546428 | 1637.9124 | 9.017014 | 1.5746436 | 3.5294142 | -77.289825 | 0.18532437 | 12 | 142.50458 | -2.7386127 | 0.09257997 | VARIABLE | 109.98933805855953 | -16.947350494260327 | False | False | 0 | True | True | False | True | False | False | False | False | -- | -- | -- | -- | -- | -- | 10.305711408404521 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4847957293278177024 | 108944108 | 50.00034361894219 | -43.06655252783423 | 165.5242095575573 | 0.07836173 | 2112.3093 | 3035.01731561514 | 0.0812309 | 726.9644815849239 | 0.101254486 | 95 | 1.48711 | 0.020080015 | 0 | 0 | 1.976701 | 1044.884 | 4.063915 | 535.3128 | 4.440891 | 337.56985 | 3.5082927 | 1.2146823 | 0.9325981 | 87.75779 | 0.12703782 | 18 | 1827.109 | -- | 0.016656557 | NOT_AVAILABLE | 250.73404566404008 | -56.06475866970972 | False | False | 0 | True | True | False | False | False | True | False | False | 5427.3184 | 4.4433 | 0.0247 | 6.0327 | 0.0 | 0.0 | 19.704451607928075 |
946632924007399936 | 91728796 | 107.50514340448903 | 38.52526941964586 | 165.2146994337292 | 0.06364261 | 2595.976 | -439.4204467281696 | 0.065588385 | -944.7934896029223 | 0.058826566 | 95 | 1.1692526 | 0.01691827 | 3 | 0 | 1.1360852 | 1072.4795 | 9.934659 | 458.038 | 11.747847 | 1013.1161 | 8.641891 | 1.5211012 | 3.105956 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 178.9577895000976 | 19.901669191941114 | False | False | 0 | True | True | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 19.74136555855134 |
6427464123776727168 | 82124097 | 302.19503988923026 | -66.18709128441725 | 163.9544145383167 | 0.12218077 | 1341.9004 | 1211.7606270999615 | 0.07212469 | -1130.2369049548956 | 0.10327922 | 95 | 1.490049 | 0.01786107 | 0 | 0 | 2.8562405 | 1219.4386 | 3.3641381 | 106.95936 | 3.8463583 | 346.84515 | 2.8270798 | 1.1554333 | 1.0192785 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 329.76078020612954 | -32.42131089268436 | False | False | 0 | True | True | False | False | False | True | False | False | 5437.5474 | 4.3012 | 0.0321 | 6.099 | 0.0 | 0.0 | 19.89311349957701 |
2572901021957789568 | 296063152 | 24.24124978791965 | 9.563070454755835 | 163.44784569658697 | 0.4628947 | 353.0994 | 1238.2439374026383 | 0.5540863 | -16.155571796869925 | 0.32792777 | 95 | 0.7173792 | 0.08122052 | 0 | 0 | 1.1058807 | 167.75575 | 19.461197 | 5.497416 | 21.107285 | 75.279015 | 17.640982 | 2.4098299 | 3.4663029 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 141.2250759328284 | -51.68433605805002 | False | False | 0 | False | False | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 19.954767609613956 |
6673000841376349696 | 1493486120 | 303.4773905559996 | -45.16473054247641 | 162.2171000791857 | 0.022484917 | 7214.4854 | 778.3309821152101 | 0.02004672 | -159.9388249728239 | 0.017635535 | 31 | -- | -- | 0 | 0 | 1.0053535 | 2765.9475 | 7.2426615 | 1211.0605 | 8.190446 | 1238.8899 | 6.278736 | 1.3257185 | 1.9117098 | -33.51682 | 0.11843188 | 11 | 468.1204 | -2.4713318 | 0.985096 | NOT_AVAILABLE | 354.8063478610685 | -32.97826039920067 | False | False | 0 | True | True | False | False | False | True | False | False | 3588.5205 | 4.0644 | -1.4065 | 6.1659 | 0.0003 | 0.0002 | 20.10616498245445 |
1638979384378696704 | 1624596075 | 267.01612290514834 | 70.88157381434476 | 160.99524492008814 | 0.011894624 | 13535.128 | -1266.3871707976418 | 0.015870238 | 1108.8007104699252 | 0.016470628 | 31 | -- | -- | 0 | 0 | 1.0637181 | 3653.4583 | 13.778201 | 980.8214 | 14.179064 | 2145.4294 | 13.176234 | 1.2341527 | 1.0028296 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 101.43804084104781 | 30.691322551716652 | False | False | 0 | True | True | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 20.258758442128823 |
6324325225803432320 | 1416906431 | 218.56843175696892 | -12.516923853592898 | 159.9225477824956 | 0.054619387 | 2927.9448 | -355.1381150377546 | 0.052832775 | 593.0401507540619 | 0.043415446 | 31 | -- | -- | 0 | 0 | 1.4434574 | 1008.93677 | 9.894982 | 627.9283 | 11.569429 | 780.0093 | 8.646179 | 1.4847639 | 2.9232502 | -1.359221 | 0.19820952 | 8 | 132.83919 | -2.105764 | 0.092563055 | NOT_AVAILABLE | 338.4202515815191 | 43.1573140452653 | False | False | 0 | True | True | False | False | False | True | False | False | 3000.055 | 4.3516 | -0.5936 | 6.2554 | 0.0 | 0.0 | 20.394646173367363 |
2824770686019004032 | 541819637 | 352.9716753030632 | 19.937313746866927 | 159.90846046252173 | 0.051349618 | 3114.112 | 552.3494119624912 | 0.055147033 | 20.27460819805265 | 0.036104545 | 31 | -- | -- | 6 | 0 | 1.5881655 | 1491.2142 | 10.828941 | 145.96365 | 12.704212 | 748.20654 | 9.530133 | 1.5212379 | 3.174079 | -- | -- | -- | -- | -- | -- | NOT_AVAILABLE | 98.58054051342569 | -39.14342615324564 | False | False | 0 | False | False | False | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 20.396442863208335 |
2824770686019003904 | 770267785 | 352.97012375450475 | 19.93699282660293 | 159.66339203721853 | 0.03412789 | 4678.3843 | 578.0086593589436 | 0.035451487 | -59.768604898823476 | 0.02324439 | 31 | -- | -- | 1 | 0 | 1.3173962 | 1476.4573 | 9.043998 | 284.76175 | 10.507311 | 765.9866 | 7.8463645 | 1.4568522 | 2.6609464 | -0.20729986 | 0.8243951 | 14 | 267.29807 | -1.4795082 | 0.3191088 | NOT_AVAILABLE | 98.5786475699206 | -39.14315221697577 | False | False | 0 | True | True | True | False | False | False | False | False | -- | -- | -- | -- | -- | -- | 20.427749501946835 |
6322070093095493504 | 1320391257 | 229.85630133329227 | -7.722707024157902 | 158.71827296463243 | 0.030101538 | 5272.763 | -1221.2776289653712 | 0.03665181 | -97.22923861858034 | 0.026740635 | 31 | -- | -- | 0 | 0 | 1.3033525 | 1622.9315 | 9.421787 | 619.3337 | 10.813405 | 2136.1707 | 8.251837 | 1.4377834 | 2.5615683 | -9.745852 | 0.15540636 | 12 | 195.53186 | -3.1428182 | 0.12624983 | NOT_AVAILABLE | 354.07215955069114 | 40.02218731174595 | False | False | 0 | False | False | False | False | False | True | False | False | 3110.4065 | 4.2666 | -0.849 | 6.2984 | 0.0 | 0.0 | 20.549390541152214 |