ast2000tools.star_population.StarPopulation

class ast2000tools.star_population.StarPopulation(number_of_stars=50000, giant_star_fraction=0.01, supergiant_star_fraction=0.001, white_dwarf_star_fraction=0.01, temperature_variance_offset=0, temperature_variance_scale=0.08, luminosity_variance_offset=0, luminosity_variance_scale=0.4, seed=None)

Bases: object

Represents a population of stars of different types.

An instance of this class contains all information required to plot a detailed Hertzsprung–Russell diagram.

Parameters
  • number_of_stars (int, optional) – The total number of stars in the star population. Default is 50000.

  • giant_star_fraction (float, optional) – The proportion of giants in the star population. Default is 1/100.

  • supergiant_star_fraction (float, optional) – The proportion of supergiants in the star population. Default is 1/1000.

  • white_dwarf_star_fraction (float, optional) – The proportion of white dwarfs in the star population. Default is 1/100.

  • temperature_variance_offset (float, optional) – The component of the variance in temperature that is the same for all stars. Larger values increases horizontal spread uniformly in the HR diagram. Default is 0.

  • temperature_variance_scale (float, optional) – The component of the variance in temperature that is proportional to the mean. Larger values increases horizontal spread more for larger temperatures in the HR diagram. Default is 0.08.

  • luminosity_variance_offset (float, optional) – The component of the variance in luminosity that is the same for all stars. Larger values increases vertical spread uniformly in the HR diagram. Default is 0.

  • luminosity_variance_scale (float, optional) – The component of the variance in luminosity that is proportional to the mean. Larger values increases vertical spread more for larger luminosities in the HR diagram. Default is 0.4.

  • seed (int) – The seed to use when generating the mass distribution of stars in the population. By default a different seed is used each time.

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from ast2000tools.star_population import StarPopulation
...
>>> stars = StarPopulation()
>>> T = stars.temperatures # [K]
>>> L = stars.luminosities # [L_sun]
>>> r = stars.radii        # [R_sun]
...
>>> c = stars.colors
>>> s = np.maximum(1e3*(r - r.min())/(r.max() - r.min()), 1.0) # Make point areas proportional to star radii
...
>>> fig, ax = plt.subplots()
>>> ax.scatter(T, L, c=c, s=s, alpha=0.8, edgecolor='k', linewidth=0.05)
...
>>> ax.set_xlabel('Temperature [K]')
>>> ax.invert_xaxis()
>>> ax.set_xscale('log')
>>> ax.set_xticks([35000, 18000, 10000, 6000, 4000, 3000])
>>> ax.set_xticklabels(list(map(str, ax.get_xticks())))
>>> ax.set_xlim(40000, 2000)
>>> ax.minorticks_off()
...
>>> ax.set_ylabel(r'Luminosity [$L_\odot$]')
>>> ax.set_yscale('log')
>>> ax.set_ylim(1e-4, 1e6)
...
>>> plt.savefig('HR_diagram.png')

HR diagram

../_images/HR_diagram.png

Attributes

colors

Array of shape (number_of_stars, 3) containing the colors of all the stars as RGB floats.

giant_star_colors

Array of shape (number_of_giant_stars, 3) containing the colors of the giant stars as RGB floats.

giant_star_fraction

The proportion of giants in the star population.

giant_star_luminosities

Array of shape (number_of_giant_stars,) containing the luminosities of the giant stars in solar luminosities.

giant_star_masses

Array of shape (number_of_giant_stars,) containing the masses of the giant stars in solar masses.

giant_star_radii

Array of shape (number_of_giant_stars,) containing the radii of the giant stars in solar radii.

giant_star_temperatures

Array of shape (number_of_giant_stars,) containing the temperatures of the giant stars in kelvin.

luminosities

Array of shape (number_of_stars,) containing the luminosities of all the stars in solar luminosities.

luminosity_variance_offset

The component of the variance in luminosity that is the same for all stars.

luminosity_variance_scale

The component of the variance in luminosity that is proportional to the mean.

main_sequence_star_colors

Array of shape (number_of_main_sequence_stars, 3) containing the colors of the main sequence stars as RGB floats.

main_sequence_star_fraction

The proportion of main sequence stars in the star population.

main_sequence_star_luminosities

Array of shape (number_of_main_sequence_stars,) containing the luminosities of the main sequence stars in solar luminosities.

main_sequence_star_masses

Array of shape (number_of_main_sequence_stars,) containing the masses of the main sequence stars in solar masses.

main_sequence_star_radii

Array of shape (number_of_main_sequence_stars,) containing the radii of the main sequence stars in solar radii.

main_sequence_star_temperatures

Array of shape (number_of_main_sequence_stars,) containing the temperatures of the main sequence stars in kelvin.

masses

Array of shape (number_of_stars,) containing the masses of all the stars in solar masses.

number_of_giant_stars

The number of giants in the star population.

number_of_main_sequence_stars

The number of main sequence stars in the star population.

number_of_stars

The total number of stars in the star population.

number_of_supergiant_stars

The number of supergiants in the star population.

number_of_white_dwarf_stars

The number of white dwarfs in the star population.

radii

Array of shape (number_of_stars,) containing the radii of all the stars in solar radii.

supergiant_star_colors

Array of shape (number_of_supergiant_stars, 3) containing the colors of the supergiant stars as RGB floats.

supergiant_star_fraction

The proportion of supergiants in the star population.

supergiant_star_luminosities

Array of shape (number_of_supergiant_stars,) containing the luminosities of the supergiant stars in solar luminosities.

supergiant_star_masses

Array of shape (number_of_supergiant_stars,) containing the masses of the supergiant stars in solar masses.

supergiant_star_radii

Array of shape (number_of_supergiant_stars,) containing the radii of the supergiant stars in solar radii.

supergiant_star_temperatures

Array of shape (number_of_supergiant_stars,) containing the temperatures of the supergiant stars in kelvin.

temperature_variance_offset

The component of the variance in temperature that is the same for all stars.

temperature_variance_scale

The component of the variance in temperature that is proportional to the mean.

temperatures

Array of shape (number_of_stars,) containing the temperatures of all the stars in kelvin.

white_dwarf_star_colors

Array of shape (number_of_white_dwarf_stars, 3) containing the colors of the white dwarf stars as RGB floats.

white_dwarf_star_fraction

The proportion of white dwarfs in the star population.

white_dwarf_star_luminosities

Array of shape (number_of_white_dwarf_stars,) containing the luminosities of the white dwarf stars in solar luminosities.

white_dwarf_star_masses

Array of shape (number_of_white_dwarf_stars,) containing the masses of the white dwarf stars in solar masses.

white_dwarf_star_radii

Array of shape (number_of_white_dwarf_stars,) containing the radii of the white dwarf stars in solar radii.

white_dwarf_star_temperatures

Array of shape (number_of_white_dwarf_stars,) containing the temperatures of the white dwarf stars in kelvin.

property number_of_stars

The total number of stars in the star population.

Type

int

property main_sequence_star_fraction

The proportion of main sequence stars in the star population.

Type

float

property giant_star_fraction

The proportion of giants in the star population.

Type

float

property supergiant_star_fraction

The proportion of supergiants in the star population.

Type

float

property white_dwarf_star_fraction

The proportion of white dwarfs in the star population.

Type

float

property number_of_main_sequence_stars

The number of main sequence stars in the star population.

Type

int

property number_of_giant_stars

The number of giants in the star population.

Type

int

property number_of_supergiant_stars

The number of supergiants in the star population.

Type

int

property number_of_white_dwarf_stars

The number of white dwarfs in the star population.

Type

int

property temperature_variance_offset

The component of the variance in temperature that is the same for all stars.

Type

float

property temperature_variance_scale

The component of the variance in temperature that is proportional to the mean.

Type

float

property luminosity_variance_offset

The component of the variance in luminosity that is the same for all stars.

Type

float

property luminosity_variance_scale

The component of the variance in luminosity that is proportional to the mean.

Type

float

property masses

Array of shape (number_of_stars,) containing the masses of all the stars in solar masses.

Type

1-D numpy.ndarray

property main_sequence_star_masses

Array of shape (number_of_main_sequence_stars,) containing the masses of the main sequence stars in solar masses.

Type

1-D numpy.ndarray

property giant_star_masses

Array of shape (number_of_giant_stars,) containing the masses of the giant stars in solar masses.

Type

1-D numpy.ndarray

property supergiant_star_masses

Array of shape (number_of_supergiant_stars,) containing the masses of the supergiant stars in solar masses.

Type

1-D numpy.ndarray

property white_dwarf_star_masses

Array of shape (number_of_white_dwarf_stars,) containing the masses of the white dwarf stars in solar masses.

Type

1-D numpy.ndarray

property radii

Array of shape (number_of_stars,) containing the radii of all the stars in solar radii.

Type

1-D numpy.ndarray

property main_sequence_star_radii

Array of shape (number_of_main_sequence_stars,) containing the radii of the main sequence stars in solar radii.

Type

1-D numpy.ndarray

property giant_star_radii

Array of shape (number_of_giant_stars,) containing the radii of the giant stars in solar radii.

Type

1-D numpy.ndarray

property supergiant_star_radii

Array of shape (number_of_supergiant_stars,) containing the radii of the supergiant stars in solar radii.

Type

1-D numpy.ndarray

property white_dwarf_star_radii

Array of shape (number_of_white_dwarf_stars,) containing the radii of the white dwarf stars in solar radii.

Type

1-D numpy.ndarray

property temperatures

Array of shape (number_of_stars,) containing the temperatures of all the stars in kelvin.

Type

1-D numpy.ndarray

property main_sequence_star_temperatures

Array of shape (number_of_main_sequence_stars,) containing the temperatures of the main sequence stars in kelvin.

Type

1-D numpy.ndarray

property giant_star_temperatures

Array of shape (number_of_giant_stars,) containing the temperatures of the giant stars in kelvin.

Type

1-D numpy.ndarray

property supergiant_star_temperatures

Array of shape (number_of_supergiant_stars,) containing the temperatures of the supergiant stars in kelvin.

Type

1-D numpy.ndarray

property white_dwarf_star_temperatures

Array of shape (number_of_white_dwarf_stars,) containing the temperatures of the white dwarf stars in kelvin.

Type

1-D numpy.ndarray

property luminosities

Array of shape (number_of_stars,) containing the luminosities of all the stars in solar luminosities.

Type

1-D numpy.ndarray

property main_sequence_star_luminosities

Array of shape (number_of_main_sequence_stars,) containing the luminosities of the main sequence stars in solar luminosities.

Type

1-D numpy.ndarray

property giant_star_luminosities

Array of shape (number_of_giant_stars,) containing the luminosities of the giant stars in solar luminosities.

Type

1-D numpy.ndarray

property supergiant_star_luminosities

Array of shape (number_of_supergiant_stars,) containing the luminosities of the supergiant stars in solar luminosities.

Type

1-D numpy.ndarray

property white_dwarf_star_luminosities

Array of shape (number_of_white_dwarf_stars,) containing the luminosities of the white dwarf stars in solar luminosities.

Type

1-D numpy.ndarray

property colors

Array of shape (number_of_stars, 3) containing the colors of all the stars as RGB floats.

Type

2-D numpy.ndarray

property main_sequence_star_colors

Array of shape (number_of_main_sequence_stars, 3) containing the colors of the main sequence stars as RGB floats.

Type

2-D numpy.ndarray

property giant_star_colors

Array of shape (number_of_giant_stars, 3) containing the colors of the giant stars as RGB floats.

Type

2-D numpy.ndarray

property supergiant_star_colors

Array of shape (number_of_supergiant_stars, 3) containing the colors of the supergiant stars as RGB floats.

Type

2-D numpy.ndarray

property white_dwarf_star_colors

Array of shape (number_of_white_dwarf_stars, 3) containing the colors of the white dwarf stars as RGB floats.

Type

2-D numpy.ndarray