HRDiagram is a R package used to produce the Hertzsprung-Russell (H-R) diagram for plotting stellar data. Specifically, it can plot either an observational H-R diagram, which is based on absolute magnitude and stellar color (B-V index) or a theoretical H-R diagram, which is based on absolute magnitude and stellar temperature (degrees Kelvin).
The theoretical H-R diagram is based on a small dataset (n=55) from the McDonald Observatory. The plot is interactive and includes a listing of stellar positions with the intent that someone may actually wish to view some of the objects listed through a small telescope.
The observational H-R diagram is based on on a dataset from the Yale Trigonometric Parallax Dataset (n=6220). The dataset is part of the R package GDAdata.
The following R packages are used:
library(HRDiagram) library(ggplot2) library(dplyr) library(readxl) library(GDAdata)
McDonald Observatory Dataset (theoretical H-R diagram)
The theoretical H-R diagram is based on a dataset obtained from McDonald Observatory including a selection of hypervelocity star. The dataset is part of an exercise developed by Mary Kay Hemenway and Brad Armosky which can be found at https://mcdonaldobservatory.org/sites/default/files/pdfs/teachers/hrd.pdf. A list of hypervelocity stars can be found in the December 2018 issue of Sky&Telescope.
Data was input into an Excel format from Tables B, C and D from the above educational guide. Additional annotations to the McDonald dataset include right ascension and declination positional data of select stars with some notes of interest from Wikipedia.
The dataset resides as an Excel file on https://github.com/cowboy2718/Hertzsprung-Russell/ under Inst/Data/Extdata.
The Excel data set must be downloaded to the working directory. The following codes converts the Excel file to a R data frame.
library(readxl) df<-import_mcdonald_data("mcdonaldstars.xlsx")
Note: Errors associated with the Excel file belong with the author of this package since they were input manually from the McDonald Obsevatory pdf file.
Yale Trigonometric Parallax Dataset (observational H-R diagram)
The Yale Trigonometric Parallax Dataset is found in the R package GDAdata under the data HRstars. The dataset can be accessed with the following code chunk.
install.packages("GDAdata") data(HRstars, package="GDAdata")
Spectral types based on stellar temperature in degrees Kelvin may be added to the McDonald Observatory data set or any data set in which stellar temperatures are provided in a column. The following code will perform the operation on a dataframe in R.
library(dplyr) spectral(filename)
The following code will plot the interactive theoretical H-R diagram based on n = 57 stellar data points obtained from the McDonald Observatory data set and a selection of hypervelocity stars from Sky & Telescope, December 2018 issue. The graph plots absolute magnitude by degrees Kelvin.
library(dplyr) library(ggplot2) library(plotly) interactiveHR(filename) #Filename will be the imported McDonald Observatory dataset
Note: The interactive plot also provides a tooltip that can be used to hover over individual stars to show additional information such as apparent magnitude, spectral type, constellation, right ascension and declination.
The following code will plot a non-interactive observational H-R diagram based on n = 6220 stellar data points obtained from the Yale Trigonometric Parallax Dataset. The graph plots absolute magnitude by color type.
library(dplyr) library(ggplot2) library(plotly) install.packages("GDAdata") data(HRstars, package="GDAdata") yale_hr_diagram
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.