{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "HR diagrams\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Download all the Jupyter notebooks from: https://github.com/HeloiseS/hoki/tree/master/tutorials\n", "\n", "# Initial imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from hoki import load\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "%matplotlib inline\n", "plt.style.use('tuto.mplstyle')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### In this tutorial you will:\n", "\n", "- Learn about the HR-diagram data structure of BPASS\n", "- Learn how to load them in using hoki\n", "- Use the tools in `hoki` to explore your HR diagram data and make science plots\n", "- Learn to customise the `hoki` plots\n", "\n", "\n", "# Loading in the data\n", "\n", "### About the tools you're about to use. \n", "HR diagram data can be loaded using the `hoki.load.model_output()` function. This function will automatically know that you are trying to load an HR diagram from the name of the text file.\n", "\n", "**Important**:\n", "You should note that when loading an HR diagram you need to specify what type of HR diagram you want to load form the file. The HR diagram files are large and quite complex - see left hand side of the diagam below - so we'll be loading in one type of HR diagram at a time. \n", "\n", "You can choose from 3 options:\n", "- `'TL'`: For a temperature/Luminosity HR diagram\n", "- `'Tg'`: For a temperature/surface gravity HR diagram\n", "- `'TTG'`: For a temperature/(temperature**4/surface gravity) HR diagram\n", "\n", "These options are there for 2 reasons: \n", "* 1.They tell the object which segment of the text file to load in \n", "* 2.They tell the plotting function what grid to create in order to plot the contours (also picks the right axis labels)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Loading the HR diagrams" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Loading the HR diagrams for signle stars and binary star populations \n", "sin_hr_diagram = load.model_output('./data/hrs-sin-imf135_300.z020.dat', hr_type = 'TL')\n", "bin_hr_diagram = load.model_output('./data/hrs-bin-imf135_300.z020.dat', hr_type = 'TL')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Loading some observational data\n", "\n", "We're going to want to plot some observational data to compare to our models. A nice way to do that is to use `pandas`." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Loading the observational data of Upper Scorpio\n", "usco = pd.read_csv('./data/USco.dat', sep='\\t', engine='python', names=['Temperature', 'Luminosity'])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Temperature | \n", "Luminosity | \n", "
---|---|---|
0 | \n", "3.756 | \n", "0.38 | \n", "
1 | \n", "3.742 | \n", "0.34 | \n", "
2 | \n", "3.742 | \n", "0.36 | \n", "
3 | \n", "3.750 | \n", "0.08 | \n", "
4 | \n", "3.728 | \n", "0.27 | \n", "