{ "cells": [ { "cell_type": "raw", "id": "eaf29ef7", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. _cookbook-bcep:\n", "\n", "Line Profile Variations of a Be Star\n", "====================================\n", "\n", "This :ref:`cookbook` recipe demonstrates how to simulate the spectral line-profile variations (lpv) of a pulsating Be star, using the MSG Python interface. The same basic approach presented in the :ref:`cookbook-rot-broaden` recipe is applied here to synthesize irradiance spectra, but we must properly account for the varying photospheric parameters of the quadrature elements used in the disk integration. Calculating these parameters is beyond the scope of the recipe, and so we'll rely on the open-source :mad-star:`BRUCE code ` :ads_citep:`townsend:1997` to perform the task.\n", "\n", "Preparation\n", "-----------\n", "\n", "Download :download:`sg-HeI-6678.h5 <../downloads/sg-HeI-6678.h5>` and place it in your working directory (this is the same :f-schema:`specgrid` file as used in the :ref:`cookbook-rot-broaden` recipe). Also download :download:`be-star-lpv.tar.bz2 <../downloads/be-star-lpv.tar.bz2>` and unpack it into your working directory using the :command:`tar` utility. This archive contains the following items:\n", "\n", "* :file:`elements-*` --- quadrature element data produced by BRUCE\n", "* :file:`input.bdf` --- BRUCE input file used to create :file:`elements-*`\n", "\n", "Note that :file:`input.bdf` isn't needed for the recipe; it's included for those who wish to recreate the :file:`elements-*` files, or are curious about their provenance. The stellar parameters specified in :file:`input.bdf` are similar to those used in the :ref:`cookbook-rot-broaden` recipe, and the pulsation parameters are for a :math:`\\ell=m=2` mode.\n", "\n", "Initialization\n", "--------------\n", "\n", "To start, import modules and set other parameters:" ] }, { "cell_type": "code", "execution_count": 1, "id": "2eb4244c", "metadata": {}, "outputs": [], "source": [ "# Import other modules\n", "\n", "import numpy as np\n", "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import scipy.io as si\n", "import astropy.constants as con\n", "\n", "# Import pymsg\n", "\n", "import pymsg\n", "\n", "# Set constants\n", "\n", "C = con.c.cgs.value\n", "PC = con.pc.cgs.value\n", "\n", "# Set plot parameters\n", "\n", "plt.rcParams.update({'font.size': 12})" ] }, { "cell_type": "raw", "id": "1a08b07c", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Define a Synthesis Function\n", "---------------------------\n", "\n", "Now let's create a function that synthesizes an irradiance spectrum for a pulsating star. The :py:func:`synthesize_irradiance` function, defined below, takes the following arguments:\n", "\n", "* ``specgrid`` --- :py:class:`pymsg.SpecGrid` object\n", "* ``lam`` --- wavelength abscissa (Å)\n", "* ``bruce_file`` --- name of quadrature element file produced by BRUCE\n", "* ``d`` --- distance to star (pc)\n", "\n", "(There are significantly fewer arguments than the corresponding :py:func:`synthesize_irradiance` function in the :ref:`cookbook-rot-broaden` recipe, because most data are provided by the BRUCE file.)" ] }, { "cell_type": "code", "execution_count": 2, "id": "02d6f490", "metadata": {}, "outputs": [], "source": [ "def synthesize_irradiance(specgrid, lam, bruce_file, d):\n", " \n", " # Read the BRUCE file\n", "\n", " with si.FortranFile(bruce_file, 'r') as f:\n", " \n", " # Read header\n", " \n", " record = f.read_record('" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Plot the irradiance spectra\n", "\n", "plt.figure()\n", "\n", "cmap = mpl.colormaps['cool']\n", "\n", "offset=0.2*(np.max(F_lam_obs[0]) - np.min(F_lam_obs[0]))\n", "\n", "for i in range(n_time):\n", " \n", " plt.plot(lam_c, F_lam_obs[i]+i*offset, color=cmap(i/(n_time-1)))\n", "\n", "plt.xlim(6670, 6690)\n", "\n", "plt.xlabel(r'$\\lambda ({\\AA})$')\n", "plt.ylabel(r'$F^{\\mathrm{obs}}_{\\lambda}\\ ({\\rm erg\\,cm^{-2}\\,s^{-1}}\\,\\AA^{-1})$');" ] }, { "cell_type": "raw", "id": "e59af876", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The lpv in the figure take the form of dips of enhanced absorption that travel across the line profile from blue to red. This is similar to the variations observed in pulsating Be stars (see, e.g., :ads_citealt:`stefl:2003`)." ] } ], "metadata": { "celltoolbar": "Raw Cell Format", "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.12.2" } }, "nbformat": 4, "nbformat_minor": 5 }