Note
This tutorial was generated from a Jupyter notebook that can be downloaded here.
Perceived color diagram
In this notebook we will demonstrate how to create one of the possible tulips
diagrams. The perceived color diagram is useful when you want to display a property that applies for the entire star, like radius and color. tulips
visualizes the star as a circle, where its radius represents the actual radius, or any other physical quantity that you’re interested in. This circle is filled with a color, which indicates the temperature of the star, according to how it would appear on the sky.
Therefore, the diagram is an approximation of how the star would be perceived by the human eye.
Load example model
Let’s plot a diagram of a \(11 M_{\odot}\) star at the beginning of its evolution. As explained in the Getting Started page, we first need to load in a MESA model with mesaPlot
and store it in an object called m11
.
[1]:
# Interactive matplotlib plotting for jupyter lab
%matplotlib inline
# If you use jupyter notebook
# %matplotlib notebook
import matplotlib.pyplot as plt
import mesaPlot as mp
import tulips
# Specify directory of MESA model
SINGLE_M11_DIR = "../../tulips/MESA_DIR_EXAMPLE/"
m11 = mp.MESA()
m11.loadHistory(filename_in=SINGLE_M11_DIR + "history.data")
Create perceived color plot
Now we are ready to create the perceived color diagram of this star. We can do this by passing the MESA object to the perceived_color
function. Let’s plot an instance of the star at time_ind=0
. (Have a look at the Getting Started page on how to specify this time parameter)
[3]:
tulips.perceived_color(m11, time_ind=0, fig_size=(8, 6))
plt.show()
The radius of the star is shown on the x and y axis. Its blue color shows how it would be perceived by the human eye, and indicates a relatively hot star.
Note
The color is determined using the colorpy
package, which approximates the spectrum of a star using its effective temperature. According to the 1931 color matching functions of the Commission Internationale de l’Eclairage, this spectrum is converted to the approximate RGB color the human eye will perceive.
Create an animation
To see the star evolving, and observe its changing radius and color, we can also create an animation. To do this, we need to modify the time_ind
property. Here, we want to plot from the first (0) to last (-1) time index, with steps of 10. For more information about the time_ind
property, look at the Getting Started page.
[4]:
tulips.perceived_color(m11, time_ind=(0, -1, 10), fps=30, output_fname="perceived_color", fig_size=(8, 6))
plt.show()
Creating animation
[5]:
from IPython.display import Video
Video("perceived_color.mp4", embed=True, width=700, height=600)
[5]:
Showing other properties
Next to showing the star’s size, we can use this diagram to visualize other properties. It is possible to specify which quantity the radius is representing. This can be done by changing the raxis
property to any other quantity that is stored in the MESA output file.
Tip
To access all the different properties, you can type m11.hist.
and press Tab
.
In the example below, we change this property to star_mass
, to show the mass instead of radius on the x and y axis. A larger circle now represents a more massive star and vice versa. The color still shows the perceived color.
[6]:
tulips.perceived_color(m11, time_ind=0, raxis='star_mass', fig_size=(8, 6))
plt.show()