{ "cells": [ { "cell_type": "markdown", "id": "9aacc247", "metadata": {}, "source": [ "# Interactively fit Brown Dwarf Spectra with the `gollum` dashboard\n", "\n", "In this tutorial we will see how the spectra of brown dwarfs vary as a function of their intrinsic properties. We will fit observed spectra of a particular brown dwarf with the gollum dashboard, a dashboard which fits models based on properties including [effective temperature](https://en.wikipedia.org/wiki/Effective_temperature), [surface gravity](https://en.wikipedia.org/wiki/Surface_gravity), [metallicity](https://en.wikipedia.org/wiki/Metallicity), [rotational broadening](https://phys.libretexts.org/Bookshelves/Astronomy__Cosmology/Stellar_Atmospheres_(Tatum)/10%3A_Line_Profiles/10.06%3A_Rotational_Broadening), and [radial velocity](https://en.wikipedia.org/wiki/Radial_velocity#:~:text=The%20radial%20velocity%20of%20an,the%20point%20and%20the%20object.). The fitting for this tutorial will be based on the Sonora-Bobcat 2021 models, which takes into account effective temperature, surface gravity, and metallicity as intrinsic values." ] }, { "cell_type": "code", "execution_count": null, "id": "9e54e2c6", "metadata": {}, "outputs": [], "source": [ "from gollum.sonora import SonoraGrid\n", "from specutils import Spectrum1D\n", "import pandas as pd\n", "import astropy.units as u" ] }, { "cell_type": "code", "execution_count": null, "id": "ff4fbe7a", "metadata": {}, "outputs": [], "source": [ "from IPython.display import HTML\n", "from IPython.display import Image" ] }, { "cell_type": "markdown", "id": "7276493f", "metadata": {}, "source": [ "First, we will read in an example spectrum of this [ultracool dwarf](https://en.wikipedia.org/wiki/Ultra-cool_dwarf): \n", "\n", "[2MASS J05591914-1404488](http://simbad.u-strasbg.fr/simbad/sim-id?Ident=2MASS+J05591914-1404488&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id)\n", "\n", "We got its data from the Keck Telescope's [NIRSPEC spectrograph](https://www2.keck.hawaii.edu/inst/nirspec/). A specific section of this data is displayed below." ] }, { "cell_type": "code", "execution_count": null, "id": "aaa230b5", "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv('../../data/2mass0559_59.dat', \n", " delim_whitespace=True, \n", " comment='#', \n", " names=['wave', 'flux'])" ] }, { "cell_type": "code", "execution_count": null, "id": "c0af6965", "metadata": {}, "outputs": [], "source": [ "df.head()" ] }, { "cell_type": "markdown", "id": "7689e1b6", "metadata": {}, "source": [ "The unit for wavelength here is [microns](https://en.wikipedia.org/wiki/Micrometre) and the unit for flux is \"counts\"." ] }, { "cell_type": "code", "execution_count": null, "id": "b0385025", "metadata": {}, "outputs": [], "source": [ "bdss_spectrum = Spectrum1D(spectral_axis=df.wave.values*u.micron, \n", " flux=df.flux.values*u.ct)" ] }, { "cell_type": "code", "execution_count": null, "id": "761b08e9", "metadata": {}, "outputs": [], "source": [ "wl_lo, wl_hi = (bdss_spectrum.wavelength.value.min(), \n", " bdss_spectrum.wavelength.value.max())" ] }, { "cell_type": "markdown", "id": "af70bb92", "metadata": {}, "source": [ "Next, we can read in the Sonora-Bobcat grid and show an interactive dashboard. " ] }, { "cell_type": "code", "execution_count": null, "id": "2d297a2a", "metadata": {}, "outputs": [], "source": [ "grid = SonoraGrid(wl_lo=wl_lo, wl_hi=wl_hi)" ] }, { "cell_type": "markdown", "id": "fb6d9cf1", "metadata": {}, "source": [ "Awesome! Now you can hand-in a data spectrum to overlay it onto the grid and begin fitting using the interactive sliders." ] }, { "cell_type": "code", "execution_count": null, "id": "d25f222c", "metadata": {}, "outputs": [], "source": [ "grid.show_dashboard(data=bdss_spectrum, show_telluric=False)" ] }, { "cell_type": "markdown", "id": "dc73cf85", "metadata": {}, "source": [ "![dashboard demo](https://user-images.githubusercontent.com/98151293/167173097-31427d83-f7fc-4146-a520-34e6b97b3b1b.gif)" ] }, { "cell_type": "markdown", "id": "a1f1bf1e", "metadata": {}, "source": [ "The dashboard looks great!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" } }, "nbformat": 4, "nbformat_minor": 5 }