[PYTHON] Easy way to plot HR diagram using astroquery

HR diagram and astroquery

Introducing a simple plot using the Hertzsprung-Russell diagram (commonly known as the HR diagram) using a space astronomical database called astroquery. To do. Even those who are not good at it may get familiar with plotting for the time being.

If you only need the code, please refer to the google Colab page.

install astroquery

python


pip install astroquery

Then, enter astroquery.

Get data using astroquery

Data is from a database called Vizier

Use the data from the Hipparcos satellite at.

python


from astroquery.vizier import Vizier
v = Vizier(catalog="I/239/hip_main",columns=['HIP',"Vmag","B-V","Plx"],row_limit=-1)
data = v.query_constraints()
vmag = data[0]["Vmag"]
bv = data[0]["B-V"]
plx = data[0]["Plx"]

All you need is three.

--Vmag: V-band brightness --BV: Ratio of brightness between B band and V band (Note that although it is written as B-V, the magnitude is a log, so it is a ratio.) --plx: Annual parallax. I just need distance information. Since the distance of nearby stars is measured by triangulation, convert from annual parallax to distance.

Is.

The meaning of the option is that catalog = "I / 239 / hip_main" specifies the catalog, columns = ['HIP', "Vmag", "BV", "Plx"] specifies the columns, and row_limit =- Get all the data by removing the upper limit with 1.

Create HR diagram

Plot a star with an annual parallax of 20 to 25 mili arcsec (that is, a distance of about 40-50 pc).

def to_parsec(marcsec):
    return 1./(1e-3*marcsec)  # pc
pmin=20 # m arcsec
pmax=25 # m arcsec
dmax = to_parsec(pmin)
dmin = to_parsec(pmax)
dlabel = str("%3.1f" % dmin) + " pc to " + str("%3.1f" % dmax) + " pc"
print (dlabel) 
vmag_cut = vmag[ (plx > pmin) & (plx < pmax)]
bv_cut = bv [ (plx > pmin) & (plx < pmax)]

from matplotlib import pyplot as plt
plt.title(dlabel)
plt.xlim(-0.1,2)
plt.ylim(-13,0)
plt.xlabel("B-V")
plt.ylabel("Vmag")
plt.scatter(bv_cut, -vmag_cut, s=1)

Then

スクリーンショット 2020-10-11 17.11.33.png

In this way, the HR diagram is applied. What if I don't cut at a distance? Please give it a try. B-V is

python



B-V \equiv log(B band brightness)-log(V-band brightness) = log(B band brightness/V-band brightness)

Because it means, let's pay attention to the ratio of brightness.

Related page

-Searching the space astronomical catalog using python's astroquery and simple plotting method using galaxies

Recommended Posts

Easy way to plot HR diagram using astroquery
Easy way to scrape with python using Google Colab
Easy way to rename files
Easy way to use Wikipedia in Python
Easy way to use Python 2.7 on Cent OS 6
Easy way to load CPU / memory on Linux
[Small story] Easy way to convert Jupyter to PDF
An easy way to call Java from Python
An easy way to create an import module with jupyter
I tried to draw a configuration diagram using Diagrams
Even beginners can do it! An easy way to write a Sankey Diagram on Plotly