The notebook is available here: https://github.com/starkit/starkit/tree/master/docs/io/reading_phoenix.ipynb


Preparing a raw Phoenix Grid installation

This is needed for making custom StarKit grids - not suitable for most users.

You first need to navigate to the Phoenix folder that contains the grid (‘PHOENIX-ACES-AGSS-COND-2011’)

[1]:
cd ~/data/skgrid/phoenix2016
/scigarfs/home/wkerzend/data/skgrid/phoenix2016
[2]:
from starkit.gridkit.io.phoenix import make_grid_info
from starkit.gridkit.io.phoenix import PhoenixProcessGrid
from starkit.gridkit import load_grid
import pandas as pd
from astropy import units as u, constants as const
from astropy.io import fits
import numpy as np
import uuid
[4]:
meta = pd.read_hdf('phoenix_grid_info.h5', 'meta')
raw_index = pd.read_hdf('phoenix_grid_info.h5', 'index')
wavelength = pd.read_hdf('phoenix_grid_info.h5', 'wavelength')[0].values * u.Unit(meta['wavelength_unit'])
[6]:
sun_flux = fits.getdata(raw_index.loc[487]['filename']) * u.erg/u.s/u.cm**2/u.cm
sun_header = fits.getheader(raw_index.loc[487]['filename'])
sun_lum_dens = sun_flux * (4 * np.pi * (sun_header['PHXREFF'] * u.cm)**2)

[47]:
(np.trapz(sun_lum_dens, wavelength).to('W') / const.L_sun).to(1)
[47]:
$0.87787727 \; \mathrm{}$
[ ]:
index_filter = (raw_index.teff.between(2000, 20000) &
 raw_index.logg.between(-1, 5) &
 raw_index.mh.between(-1.5, 0.5) &
 (raw_index.alpha == 0.0))
[7]:
index_filter = (raw_index.teff.between(2000, 20000) &
 raw_index.logg.between(-1, 5) &
 raw_index.mh.between(-1.5, 0.5) &
 (raw_index.alpha == 0.0))

new_index = raw_index.loc[index_filter]
[8]:
pgrid = PhoenixProcessGrid(new_index, wavelength, meta,
                           wavelength_start=2000*u.angstrom,
                           wavelength_stop=9000*u.angstrom, R=10000,
                          R_sampling=4)
[ ]:
pgrid.to_hdf('phoenix_working_v1_fixed_units.h5', overwrite=True)
 46% (1801 of 3833) |#########            | Elapsed Time: 3:43:20 ETA:  3:28:26
[15]:
phoenix_grid = load_grid('phoenix_working_v1_fixed_units.h5')
starkit.gridkit.base - INFO - Reading index
starkit.gridkit.base - INFO - Discovered columns teff, logg, mh
starkit.gridkit.base - INFO - Reading Fluxes
starkit.gridkit.base - INFO - Fluxes shape (3833, 60164)
starkit.gridkit.base - INFO - Initializing spec grid
starkit.gridkit.base - INFO - Setting grid extent
[12]:
%pylab notebook

w, f = phoenix_grid()

plot(w, f)
Populating the interactive namespace from numpy and matplotlib
[12]:
[<matplotlib.lines.Line2D at 0x7fb557b6c410>]