Quick Start
Contents
Quick Start#
When first time import LOTUS
#
[1]:
import lotus_nlte
lotus_nlte.utils.docs_setup()
print(f"lotus_nlte.__version__ = '{lotus_nlte.__version__}'")
lotus_nlte.__version__ = '0.1.1rc3.dev4+g68c6449.d20211211'
When you first import lotus_nlte
, it will download interpolated models for each line in our “golden linelist” with their calculated precision at certain grid points. Once they have been downloaded in your disk, it will be no longer downloaded again for your next run. docs_setup()
mainly collect some warnings created by theano and set up our matplotlib style. This process always costs around 5 mins. You can access the directory of your interpolated models at lotus_nlte.config.GCOGDIR
and the directory of calculated precision files at lotus_nlte.config.EWDIFFDIR
:
[2]:
print(f"Interpolated General Curve of Growth direcory:'{lotus_nlte.config.GCOG_DIR}'")
print(f"Interpolated EW precision direcory:'{lotus_nlte.config.EWDIFF_DIR}'")
Interpolated General Curve of Growth direcory:'/media/yangyangli/OS/yangyangli_private/Code/NLTE/LOTUSdev/src/lotus_nlte/package_data/gcoglib/'
Interpolated EW precision direcory:'/media/yangyangli/OS/yangyangli_private/Code/NLTE/LOTUSdev/src/lotus_nlte/package_data/ewdiff/'
We also provide a line list from Jofre et al. (2014) and Heiter et al. (2015). You can check which lines are included in this linelist:
[3]:
import pandas as pd
import os
fp = os.path.dirname(os.path.realpath(lotus_nlte.__file__))
obs_path = fp + "/package_data/linelist/final.linelist"
linelist = pd.read_csv(obs_path)
linelist.head()#showing first 5 lines
[3]:
Line  lambda  Ex.P  

0  FeI  3440.61  0.00 
1  FeI  3440.99  0.05 
2  FeI  3447.28  2.20 
3  FeI  3450.33  2.22 
4  FeI  3451.91  2.22 
Interpolate stellar metalicity [Fe/H]#
You must specify your line information, which region you want to interpolate the abundance via stellar_type
and the type of calculation assumption via cal
. Notice that you must set interpolated=True
in SingleGCOG
. stellar_type="whole grid"
uses the whole grid: \(4000 K \leqslant \mathrm{T}_\mathrm{eff} \leqslant 6850 K\), \(0.0 \leqslant \mathrm{log}\mathit{g} \leqslant 5.0\) and \(0.5 km\cdot s^{1} \leqslant \xi_t \leqslant 3.0 km\cdot s^{1}\). Other options
for this argument can be in the following format: spectral type/mass type/metalicity type
. For example, if your star is a metal rich G dwarf, you can set stellar_type="G/dwarf/metal_rich"
. We provide categories of each stellar type and their corresponding ranges of stellar parameters in the following chart:
Categories 
Options 
Parameter ranges 

Spectral Type(Teff) 
K 
[4000, 5200) 
G 
[5200, 6000) 

F 
[6000, 6850] 

Mass Type(logg) 
supergiant 
[0.0, 0.5) 
giant 
[0.5, 3.0) 

subgiant 
[3.0, 4.0) 

dwarf 
[4.0, 5.0] 

Metalicity Type([Fe/H]) 
very_metal_poor 
[3.5, 2.0) 
metal_poor 
[2.0, 0.5) 

metal_rich 
[0.5, 0.5) 
If you have estimated the ranges of your stellar parameters, you can pick any options in the above chart and combine them as the final value of stellar_type
.
[4]:
from lotus_nlte.gcogs.gcog import SingleGCOG
wavelength = 5307.36
excitation_potential = 1.61
element = "FeI"
sg_nlte = SingleGCOG(wavelength, excitation_potential, element, stellar_type="whole_grid", cal="nlte", interpolated=True)
model_nlte = sg_nlte.load_model()
[5]:
teff = 5200
logg = 2.5
vt = 1.5
ew = 80
#predict the interpolated metalicity, the reference solar [Fe/H] is 7.46
model_nlte.predict([[teff, logg, vt, ew]])
[5]:
array([0.82065384])
You can also obtain NonLTE correction of metalicity by call another model using cal="lte"
:
[6]:
sg_lte = SingleGCOG(wavelength, excitation_potential, element, stellar_type="whole_grid", cal="lte", interpolated=True)
model_lte = sg_lte.load_model()
correction = model_nlte.predict([[teff, logg, vt, ew]])  model_lte.predict([[teff, logg, vt, ew]])
correction
[6]:
array([0.14367426])
Plot interpolated specific Curve of Growth (COG) fixing \(\mathrm{T}_\mathrm{eff}\), \(\mathrm{log}\mathit{g}\) and \(\xi_t\)#
This can be done by fixing \(\mathrm{T}_\mathrm{eff}\), \(\mathrm{log}\mathit{g}\) and \(\xi_t\) in the GCOG, the default range of EWs is from 1 \(m\overset{\circ}A\) to 100\(m\overset{\circ}A\). You can define your EWs via ews
in method function plot_interpolated_cog
:
[7]:
%matplotlib notebook
fig = sg_nlte.plot_interpolated_cog(teff, logg, vt)
Derive stellar parameters via minimization of ionization and exciation balance#
We choose observed EWs from Sun to illustrate how LOTUS
obtain the optimal stellar parameters. Calculation assumption is LTE:
[8]:
import os
fp = os.path.dirname(os.path.realpath(lotus_nlte.__file__))
obs_path = fp + "/test/data/Sun.csv"
The format of your observed EW list should contain the following columns at least, you can check our sample data from the above Sun.csv
as a reference:
obs_wavelength 
element 
obs_ew 
obs_ep 

PolyMultiGCOG
include all lines into the class and access their corresponding interpolated genenral curve of growth (GCOG) according the stellar_type stellar_type
, adopted excitation potential cutoff exp_cutoff
, calculation assumption cal
and estimation precision which is homogeous for every lines (you can set it via ew_error
, default value is 5\(m\overset{\circ}A\)). Method pipelines
determines which lines are trustful for later determination of stellar parameters.
Excitation potential cutoff has been adopted by Bergemann et al. (2012) and Roederer et al. (2018) to obtain consisten stellar parameters from EW method and achieve ioinisaztion equilibria and excitation equilibria under the optimal stellar parameters. We recommend users to set this argument when not reaching best optimization. For metal_rich
star,
we recommend exp_cutoff=0
; For metal_poor
star, recommended exp_cutoff
is 1.2; For very_metal_poor
star, we recommend exp_cutoff
as 2.0 or 2.7.
[9]:
from lotus_nlte.gcogs.multigcogs import PolyMultiGCOG
star = "Sun"
stellar_type = "G/dwarf/metal_rich"
exp_cutoff = 0 #excitation potential cutoff, here for metal rich star we don't need to add any cutoff
cal = "lte"
mgcog = PolyMultiGCOG(star=star, stellar_type=stellar_type, exp_cutoff=exp_cutoff,
obs_path=obs_path,cal=cal)
mgcog.pipelines()
All optimizations are based on exist interpolated models and you don't need to interpolate them!
Hypersurface of line 4787.83A with ep=3.00ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4788.76A with ep=3.24ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4789.65A with ep=3.55ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4793.96A with ep=3.05ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4794.35A with ep=2.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4802.88A with ep=3.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4808.15A with ep=3.25ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4869.46A with ep=3.55ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4875.88A with ep=3.33ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4877.60A with ep=3.00ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4882.14A with ep=3.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4885.43A with ep=3.88ev of element FeI exists but doesn't pass test of interpolation
Hypersurface of line 4905.13A with ep=3.93ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4907.73A with ep=3.43ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4924.77A with ep=2.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4939.69A with ep=0.86ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4946.39A with ep=3.37ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4950.11A with ep=3.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4962.57A with ep=4.18ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4969.92A with ep=4.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4994.13A with ep=0.92ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4999.11A with ep=4.19ev of element FeI exists but doesn't pass test of interpolation
Hypersurface of line 5002.79A with ep=3.40ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5022.24A with ep=3.98ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5023.19A with ep=4.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5028.13A with ep=3.57ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5044.21A with ep=2.85ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5048.44A with ep=3.96ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5054.64A with ep=3.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5079.22A with ep=2.20ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5079.74A with ep=0.99ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5088.15A with ep=4.15ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5107.45A with ep=0.99ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5127.36A with ep=0.92ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5131.47A with ep=2.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5150.84A with ep=0.99ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5151.91A with ep=1.01ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5197.94A with ep=4.30ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5225.53A with ep=0.11ev of element FeI doesn't have enough points for interpolation
Hypersurface of line 5228.38A with ep=4.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5242.49A with ep=3.63ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5243.78A with ep=4.26ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5247.05A with ep=0.09ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5250.65A with ep=2.20ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5253.02A with ep=2.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5285.13A with ep=4.43ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5288.52A with ep=3.69ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5293.96A with ep=4.14ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5294.55A with ep=3.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5295.31A with ep=4.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5307.36A with ep=1.61ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5322.04A with ep=2.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5373.71A with ep=4.47ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5379.57A with ep=3.69ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5386.33A with ep=4.15ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5398.28A with ep=4.45ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5417.03A with ep=4.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5441.34A with ep=4.31ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5466.40A with ep=4.37ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5470.09A with ep=4.45ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5473.90A with ep=4.15ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5483.10A with ep=4.15ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5487.15A with ep=4.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5491.83A with ep=4.19ev of element FeI exists but doesn't pass test of interpolation
Hypersurface of line 5494.46A with ep=4.08ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5501.46A with ep=0.96ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5522.45A with ep=4.21ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5539.28A with ep=3.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5543.94A with ep=4.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5546.51A with ep=4.37ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5554.89A with ep=4.55ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5560.21A with ep=4.43ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5618.63A with ep=4.21ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5619.60A with ep=4.39ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5633.95A with ep=4.99ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5636.70A with ep=3.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5638.26A with ep=4.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5641.43A with ep=4.26ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5649.99A with ep=5.10ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5651.47A with ep=4.47ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5652.32A with ep=4.26ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5653.87A with ep=4.39ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5655.18A with ep=5.06ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5661.34A with ep=4.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5679.02A with ep=4.65ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5691.50A with ep=4.30ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5701.54A with ep=2.56ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5705.46A with ep=4.30ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5731.76A with ep=4.26ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5732.30A with ep=4.99ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5741.85A with ep=4.26ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5742.96A with ep=4.18ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5760.34A with ep=3.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5855.08A with ep=4.61ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5858.78A with ep=4.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5927.79A with ep=4.65ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5929.68A with ep=4.55ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 5934.65A with ep=3.93ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6003.01A with ep=3.88ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6008.56A with ep=3.88ev of element FeI doesn't have enough points for interpolation
Hypersurface of line 6024.06A with ep=4.55ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6027.05A with ep=4.08ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6056.00A with ep=4.73ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6065.48A with ep=2.61ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6079.01A with ep=4.65ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6082.71A with ep=2.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6093.64A with ep=4.61ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6096.66A with ep=3.98ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6127.91A with ep=4.14ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6151.62A with ep=2.18ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6165.36A with ep=4.14ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6173.33A with ep=2.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6187.99A with ep=3.94ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6200.31A with ep=2.61ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6213.43A with ep=2.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6219.28A with ep=2.20ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6226.73A with ep=3.88ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6229.23A with ep=2.85ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6232.64A with ep=3.65ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6240.65A with ep=2.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6265.13A with ep=2.18ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6270.22A with ep=2.86ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6271.28A with ep=3.33ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6297.79A with ep=2.22ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6315.81A with ep=4.08ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6322.69A with ep=2.59ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6338.88A with ep=4.80ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6364.36A with ep=4.80ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6380.74A with ep=4.19ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6408.02A with ep=3.69ev of element FeI doesn't have enough points for interpolation
Hypersurface of line 6421.35A with ep=2.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6481.87A with ep=2.28ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6496.47A with ep=4.80ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6498.94A with ep=0.96ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6518.37A with ep=2.83ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6569.21A with ep=4.73ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6574.23A with ep=0.99ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6593.87A with ep=2.43ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6597.56A with ep=4.80ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6609.11A with ep=2.56ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6627.54A with ep=4.55ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6703.57A with ep=2.76ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6713.74A with ep=4.80ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6733.15A with ep=4.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6739.52A with ep=1.56ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6750.15A with ep=2.42ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6752.71A with ep=4.64ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6786.86A with ep=4.19ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6804.27A with ep=4.58ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 6810.26A with ep=4.61ev of element FeI has already existed and passes test of interpolation
Hypersurface of line 4993.35A with ep=2.81ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5256.93A with ep=2.89ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5264.80A with ep=3.23ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5325.55A with ep=3.22ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5414.07A with ep=3.22ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5425.25A with ep=3.20ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5534.84A with ep=3.25ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 5991.37A with ep=3.15ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 6149.25A with ep=3.89ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 6247.56A with ep=3.89ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 6369.46A with ep=2.89ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 6432.68A with ep=2.89ev of element FeII has already existed and passes test of interpolation
Hypersurface of line 6456.38A with ep=3.90ev of element FeII has already existed and passes test of interpolation
Start optimization using differential evolution algorithm, a required parameter is bound
, which is the constraints of \(\mathrm{T}_\mathrm{eff}\), \(\mathrm{log}\mathit{g}\) and \(\xi_t\) during optimization. You can either use our tools from utils
to access this according to your stellar type or define this yourself. Notice that the bound should be within the boundary of current grid: \(4000 K \leqslant \mathrm{T}_\mathrm{eff} \leqslant 6850 K\),
\(0.0 \leqslant \mathrm{log}\mathit{g} \leqslant 5.0\) and \(0.5 km\cdot s^{1} \leqslant \xi_t \leqslant 3.0 km\cdot s^{1}\):
[10]:
from lotus_nlte.optimize import DiffEvoStellarOptimization
from lotus_nlte.utils import generate_ranges
physicaltol
array contains the convergence conditions for the absolute values of the slope of fitted line given by the derived abundances and exicitation potential of all lines, the slope from the derived abundances and reduced equivalent widths of all lines and the difference of the average abundance from FeI and FeII lines; disp
, popsize
, recombination
, mutation
are parameters from scipy.optimize.differential_evolution
, details can be check in
differential_evolution. We suggest users to use values belows for good performance:
[11]:
bounds = [tuple(r) for r in generate_ranges(stellar_type)[:2]]
bounds.append((0.5, 3.0))
de = DiffEvoStellarOptimization(mgcog, bounds, physicaltol=[1e5,2e5,5e5])
result = de.optimize(disp=True, popsize=100, recombination=0.3, mutation=(0.8,1.2))
differential_evolution step 1: f(x)= 9.38766
differential_evolution step 2: f(x)= 7.7971
differential_evolution step 3: f(x)= 7.7971
differential_evolution step 4: f(x)= 5.67808
differential_evolution step 5: f(x)= 4.28423
differential_evolution step 6: f(x)= 4.28423
differential_evolution step 7: f(x)= 1.29133
differential_evolution step 8: f(x)= 1.29133
differential_evolution step 9: f(x)= 1.29133
differential_evolution step 10: f(x)= 1.29133
differential_evolution step 11: f(x)= 1.29133
differential_evolution step 12: f(x)= 1.29133
differential_evolution step 13: f(x)= 0.395751
differential_evolution step 14: f(x)= 0.395751
differential_evolution step 15: f(x)= 0.395751
differential_evolution step 16: f(x)= 0.395751
differential_evolution step 17: f(x)= 0.395751
differential_evolution step 18: f(x)= 0.395751
differential_evolution step 19: f(x)= 0.301614
differential_evolution step 20: f(x)= 0.301614
differential_evolution step 21: f(x)= 0.301614
differential_evolution step 22: f(x)= 0.301614
differential_evolution step 23: f(x)= 0.301614
differential_evolution step 24: f(x)= 0.301614
differential_evolution step 25: f(x)= 0.301614
differential_evolution step 26: f(x)= 0.194259
differential_evolution step 27: f(x)= 0.194259
differential_evolution step 28: f(x)= 0.194259
differential_evolution step 29: f(x)= 0.194259
differential_evolution step 30: f(x)= 0.194259
differential_evolution step 31: f(x)= 0.194259
differential_evolution step 32: f(x)= 0.194259
differential_evolution step 33: f(x)= 0.194259
differential_evolution step 34: f(x)= 0.194259
differential_evolution step 35: f(x)= 0.194259
differential_evolution step 36: f(x)= 0.194259
differential_evolution step 37: f(x)= 0.194259
differential_evolution step 38: f(x)= 0.194259
differential_evolution step 39: f(x)= 0.194259
differential_evolution step 40: f(x)= 0.194259
differential_evolution step 41: f(x)= 0.194259
differential_evolution step 42: f(x)= 0.194259
differential_evolution step 43: f(x)= 0.0741986
differential_evolution step 44: f(x)= 0.0741986
differential_evolution step 45: f(x)= 0.0741986
differential_evolution step 46: f(x)= 0.0741986
differential_evolution step 47: f(x)= 0.0741986
differential_evolution step 48: f(x)= 0.0741986
differential_evolution step 49: f(x)= 0.0741986
differential_evolution step 50: f(x)= 0.0184822
differential_evolution step 51: f(x)= 0.0184822
differential_evolution step 52: f(x)= 0.0184822
differential_evolution step 53: f(x)= 0.0184822
differential_evolution step 54: f(x)= 0.0184822
differential_evolution step 55: f(x)= 0.0184822
differential_evolution step 56: f(x)= 0.0184822
differential_evolution step 57: f(x)= 0.0184822
differential_evolution step 58: f(x)= 0.0184822
differential_evolution step 59: f(x)= 0.0184822
differential_evolution step 60: f(x)= 0.0184822
differential_evolution step 61: f(x)= 0.0184822
differential_evolution step 62: f(x)= 0.00660313
differential_evolution step 63: f(x)= 0.00660313
differential_evolution step 64: f(x)= 0.00660313
differential_evolution step 65: f(x)= 0.00660313
differential_evolution step 66: f(x)= 0.00660313
differential_evolution step 67: f(x)= 0.00660313
differential_evolution step 68: f(x)= 0.00660313
differential_evolution step 69: f(x)= 0.00660313
differential_evolution step 70: f(x)= 0.00660313
differential_evolution step 71: f(x)= 0.00660313
differential_evolution step 72: f(x)= 0.00660313
differential_evolution step 73: f(x)= 0.00660313
differential_evolution step 74: f(x)= 0.00660313
differential_evolution step 75: f(x)= 0.00250189
differential_evolution step 76: f(x)= 0.00250189
differential_evolution step 77: f(x)= 0.00250189
differential_evolution step 78: f(x)= 0.00250189
differential_evolution step 79: f(x)= 0.00250189
differential_evolution step 80: f(x)= 0.00250189
differential_evolution step 81: f(x)= 0.00250189
differential_evolution step 82: f(x)= 0.00250189
differential_evolution step 83: f(x)= 0.00250189
differential_evolution step 84: f(x)= 0.00160934
differential_evolution step 85: f(x)= 0.000614101
differential_evolution step 86: f(x)= 0.000614101
differential_evolution step 87: f(x)= 0.000614101
differential_evolution step 88: f(x)= 0.000614101
differential_evolution step 89: f(x)= 0.000614101
differential_evolution step 90: f(x)= 0.000614101
differential_evolution step 91: f(x)= 0.000614101
differential_evolution step 92: f(x)= 0.000614101
differential_evolution step 93: f(x)= 0.000614101
differential_evolution step 94: f(x)= 0.000614101
differential_evolution step 95: f(x)= 0.000614101
differential_evolution step 96: f(x)= 0.000495143
differential_evolution step 97: f(x)= 0.000100499
differential_evolution step 98: f(x)= 0.000100499
differential_evolution step 99: f(x)= 0.000100499
differential_evolution step 100: f(x)= 0.000100499
differential_evolution step 101: f(x)= 0.000100499
differential_evolution step 102: f(x)= 0.000100499
differential_evolution step 103: f(x)= 0.000100499
differential_evolution step 104: f(x)= 0.000100499
differential_evolution step 105: f(x)= 0.000100499
differential_evolution step 106: f(x)= 0.000100499
differential_evolution step 107: f(x)= 0.000100499
differential_evolution step 108: f(x)= 0.000100499
differential_evolution step 109: f(x)= 0.000100499
differential_evolution step 110: f(x)= 0.000100499
differential_evolution step 111: f(x)= 0.000100499
differential_evolution step 112: f(x)= 0.000100499
differential_evolution step 113: f(x)= 0.000100499
differential_evolution step 114: f(x)= 0.000100499
differential_evolution step 115: f(x)= 0.000100499
differential_evolution step 116: f(x)= 0.000100499
differential_evolution step 117: f(x)= 0.000100499
differential_evolution step 118: f(x)= 0.000100499
differential_evolution step 119: f(x)= 0.000100499
differential_evolution step 120: f(x)= 1.41301e05
differential_evolution step 121: f(x)= 1.41301e05
differential_evolution step 122: f(x)= 1.41301e05
differential_evolution step 123: f(x)= 1.41301e05
differential_evolution step 124: f(x)= 1.41301e05
differential_evolution step 125: f(x)= 1.41301e05
differential_evolution step 126: f(x)= 1.41301e05
differential_evolution step 127: f(x)= 1.41301e05
differential_evolution step 128: f(x)= 1.41301e05
differential_evolution step 129: f(x)= 1.41301e05
differential_evolution step 130: f(x)= 1.41301e05
differential_evolution step 131: f(x)= 1.41301e05
differential_evolution step 132: f(x)= 1.41301e05
differential_evolution step 133: f(x)= 1.41301e05
differential_evolution step 134: f(x)= 1.41301e05
differential_evolution step 135: f(x)= 1.41301e05
differential_evolution step 136: f(x)= 1.41301e05
differential_evolution step 137: f(x)= 1.41301e05
differential_evolution step 138: f(x)= 1.41301e05
differential_evolution step 139: f(x)= 8.09162e06
Final optimal results can be check with the output from optimize()
, a dictionary named stellarpars
contains your stellar parameters and their roughly estimated uncertainty:
[12]:
result['stellarpars']
[12]:
{'Teff': [5712.097257814576, 28.295096855057864],
'logg': [4.3461948165328925, 0.05148673428035967],
'feh': [0.13347877062286426, 0.10335153537220176],
'Vmic': [0.7769916663894697, 0.030948064231603387]}
We can plot the final equilibria fixed at such stellar parameter combination by plot_optimized_equilibrium
:
[13]:
%matplotlib notebook
from lotus_nlte.plot import plot_optimized_equilibrium
import numpy as np
idx_fei = np.where(np.array(mgcog.obs_ele) =="FeI")
idx_feii = np.where(np.array(mgcog.obs_ele) =="FeII")
REWs = np.log10(1e3*np.array(mgcog.obs_ew)/np.array(mgcog.obs_wavelength))
chis = np.array(mgcog.obs_ep)
fit_pars = [result['dAdREW'], result['dAdchi']]
abunds = de.abunds
fig = plot_optimized_equilibrium("Sun", result['stellarpars'], fit_pars, REWs1=REWs[idx_fei], REWs2=REWs[idx_feii],
chis1=chis[idx_fei], chis2=chis[idx_feii], abunds1=abunds[idx_fei],
abunds2=abunds[idx_feii])
If you want to conduct a thorough analysis of your star and perform MCMC to obtain wellcontrained uncertainty of each derived stellar parameters, please go to Example and get an example fitting a star in ‘real’ observations.