Korg.jl
Korg is a package for computing stellar spectra from 1D model atmospheres and linelists assuming local thermodynamic equilibrium. It can be used with Julia or Python. Here's some things it can do:
- Computing spectra from Teff, logg, abundances, etc.
- Fitting whole spectra or individual lines via synthesis or equivalent widths
- Excitation-ionization balance from equivalent width data
- Model atmosphere interpolation, parsing and using atmosphere files (MARCS)
- Parsing and using linelists in VALD, Kurucz, MOOG, ExoMol, and Turbospectrum formats, with several defaults built-in.
- Automatic differentiaion (via ForwardDiff.jl)
- Synthesis with arbitrary abundances/solar abundance scales, with several defaults built-in.
After installing Korg, get started by looking at the top-level functions or the tutorial notebooks.
Example
(Python version below)
using Korg, PyPlot
wls, flux, continuum = synth(
Teff=5000, # effective temperature of 5000 Kelvin
logg=4.32, # surface gravity of 10^(4.32) cm/s²
m_H=-1.1, # metallicity, [m/H]. Overridden for individual elements by alpha_H and individual abundances
C=-0.5, # The Carbon abundance, [C/H]. Works for anything from He to U.
linelist=Korg.get_GALAH_DR3_linelist(),
wavelengths=(5850, 5900)
)
# plot
figure(figsize=(12, 4))
plot(wls, flux, "k-")
xlabel(L"$\lambda$ [Å]")
ylabel(L"$F_\lambda/R_\mathrm{star}^2$ [erg s$^{-1}$ cm$^{-5}$]");
<img src="https://github.com/ajwheeler/Korg.jl/assets/711963/70a13b45-4db2-472c-9121-fdd818a47105" />
See the documentation for synth
, or the documentation for synthesize
for advanced usage.
Code papers (please cite these if you use Korg):
- Korg: A Modern 1D LTE Spectral Synthesis Package. This is also a good overview of how spectral synthesis works, the inputs and outputs, etc.
- Korg: fitting, model atmosphere interpolation, and Brackett lines
Tutorials:
Getting help
If you are having trouble using or installing Korg, please get in touch by opening a GitHub issue (preferred), or sending Adam an email.
You can also call Korg from python
See the documentation for setup instructions.
from juliacall import Main as jl
jl.seval("using Korg"); Korg = jl.Korg
# calling Korg.synth is exactly the same as in Julia.
wls, flux, continuum = Korg.synth(
Teff=5000,
logg=4.32,
m_H=-1.1,
C=-0.5,
linelist=Korg.get_GALAH_DR3_linelist(),
wavelengths=(5850, 5900)
)
Multithreading
Korg can use multithreading to speed up line opacity calculation, the most expensive step for syntheses. To use it launch Julia with more than one thread, using the -t
command-line argument, or by setting the $JULIA_NUM_THREADS
environment variable.