Public Functions
The public functions exported by FormationTemps.jl are documented on this page. The high-level convenience functions should meet the needs of most users. However, some potentially useful, slightly lower-level methods are exposed by FormationTemps.jl and documented below. A full index of all methods defined by FormationTemps.jl is available in the Full Index.
High-level Convenience Functions
FormationTemps.jl provides a few high-level convenience wrappers to produce flux spectra and formation temperatures.
FormationTemps.calc_formation_temp — Function
calc_formation_temp(star, linelist; use_gpu=GPU_DEFAULT, Δλ=0.01, convolve=false,
minλ=NaN, maxλ=NaN, u1=NaN, u2=NaN, Nϕ=128, kwargs...)Compute flux formation temperatures, normalized flux, and flux contribution function for a given star and linelist.
The wavelength grid is built from the line list (wl * 1e8) with padding and step Δλ. Use minλ/maxλ (Angstrom) to override the default bounds (first/last line ± 2 A).
Returns a FormTempResult with fields:
wavs: wavelength grid (Angstrom).flux: normalized flux (sum(cfunc_dt_flux) / sum(cfunc_dt_flux_cont)).form_temps: formation temperature defined at 50% of the cumulative flux contribution.cont_func: contribution function, shape(Natm - 1, Nλ).atmosphere: atmosphere structure used for the calculation.
If convolve=true, applies Hirano rotation + macroturbulent convolution using limb-darkening coefficients u1 and u2. Otherwise, performs numerical disk integration using Nϕ latitude bins. Set use_gpu=true to use the GPU implementation when available.
Examples
star = StellarProps(Teff=5777.0, logg=4.44, Fe_H=0.0, vsini=2100.0)
linelist = Korg.read_linelist(joinpath(FT.datdir, "Sun_VALD.lin"))[1:500]
result = calc_formation_temp(star, linelist; Δλ=0.01, convolve=true, u1=0.43, u2=0.31)FormationTemps.StellarProps — Type
StellarProps(; Teff=NaN, logg=NaN, Fe_H=NaN, vsini=0.0, v_macro=NaN, v_micro=NaN,
ρstar=1.0, istar=90.0)Container for stellar parameters and broadening properties used by FormationTemps.
Keyword arguments:
Teff: effective temperature (K).logg: log10 surface gravity (cgs).Fe_H: metallicity [Fe/H] (dex), used to buildA_X.vsini: projected rotation velocity (m/s).v_macro: macroturbulent velocity (m/s); ifNaN, usesvmac_fit(Teff, logg).v_micro: microturbulent velocity (m/s); ifNaN, usesvmic_fit(Teff).ρstar: stellar radius scale factor for disk integration (dimensionless).istar: inclination angle in degrees (90 = equator-on).
FormationTemps.FormTempResult — Type
FormTempResult(wavs, flux, form_temps, cont_func, atmosphere)Container for calc_formation_temp outputs.
Fields:
wavs: wavelength grid (Angstrom).flux: normalized flux across the grid.form_temps: formation temperature (K) at cumulative flux contribution of 0.5.cont_func: differential contribution function (dC/dtau), size(Natm - 1, Nλ).atmosphere: atmosphere structure used for the calculation.
Atmosphere Types
FormTempResult includes an atmosphere field which contains the model atmosphere used in the spectrum modeling.
FormationTemps.Atmosphere — Type
Atmosphere{T}Abstract atmosphere type used by formation temperature calculations.
FormationTemps.get_τs — Function
get_τs(atm)Return the optical depth grid as a standard Array.
FormationTemps.get_zs — Function
get_zs(atm)Return the height grid as a standard Array.
FormationTemps.get_Ts — Function
get_Ts(atm)Return the temperature grid as a standard Array.
Empirical Relations
A few works have reported empirical relationships between fundamental stellar parameters and the measured micro- and macroturbulent velocities. FormationTemps.jl implements these for cases where micro- and macroturbulence are not available.
FormationTemps.vmac_fit — Function
vmac_fit(teff, logg)
vmac_fit(teff)Empirical macroturbulent velocity fits.
vmac_fit(teff, logg) uses the Doyle et al. (2014) relation with teff in K and logg in cgs. vmac_fit(teff) uses the Bruntt et al. (2010) relation with teff in K. Both return the macroturbulent velocity in m/s.
FormationTemps.vmic_fit — Function
vmic_fit(teff)Empirical microturbulent velocity fit from Bruntt et al. (2010).
Input teff is in K; returns microturbulent velocity in m/s.
Resolution Degradation + LSF Modeling
Spectra are synthesized at infinite spectral resolving power (but finite sampling). Since instruments imprint some LSF on spectra, model spectra are generally convolved with model LSFs. Functions for performing these operations are documented here.
FormationTemps.convolve_instrument_gauss — Function
convolve_instrument_gauss(xs, ys; new_res=1.17e5, oversampling=2.0)Convolve a spectrum with a Gaussian LSF at resolving power new_res.
TODO: finish docs.
FormationTemps.rebin_spectrum — Function
rebin_spectrum(xs_old, ys_old, xs_new)
rebin_spectrum(xs_old, ys_old, σs_old, xs_new)Rebin a spectrum (and optional uncertainties) from xs_old to xs_new.
Based on the SpectRes spectral resampling implementation: https://github.com/ACCarnall/SpectRes/blob/master/spectres/spectral_resampling.py
Note: the algorithm may introduce small shifts if the wavelength grids are misaligned.
Convolutions & Kernels
Convolutions operations are often used in the modeling of spectra, even when explicit disk-integration is performed (e.g., for microturbulent broadening). FormationTemps.jl implements methods implements these convolutions.
FormationTemps.convolve_gray_rotation — Function
convolve_gray_rotation(xs, ys, vsini, u1)Convolve a spectrum with the Gray (2008) rotation kernel using linear limb darkening.
TODO: finish docs.
FormationTemps.convolve_hirano_rotmacro — Function
convolve_hirano_rotmacro(xs, ys, vsini, ζ_rt, u1, u2; intres=intres_glob)Convolve a spectrum with the Hirano et al. (2011) rotation+macroturbulence kernel.
TODO: finish docs.
FormationTemps.convolve_iso_rt_macro — Function
convolve_iso_rt_macro(xs, ys, ζ_rt)Convolve a spectrum with the isotropic radial-tangential macroturbulence kernel.
TODO: finish docs.
FormationTemps.convolve_rt_macro — Function
convolve_rt_macro(xs, ys, ζ_rt, μ)
convolve_rt_macro(xs, ys, ζ_r, ζ_t, μ)Convolve a spectrum with a radial-tangential macroturbulence kernel.
TODO: finish docs.
The broadening kernels (which are evaluated internally in the above convolution functions) can also be directly calculated.
FormationTemps.gray_rot_kernel — Function
Equation 18.14 from The Observation and Analysis of Stellar Photospheres (Gray 2008)
FormationTemps.hirano_rotmacro_ft_kernel — Function
Equation B12 from Hirano et al. (2011). NOTE: This is returns the Fourier Transform of the rotmacro convolution kernel, not the kernel itself!!
FormationTemps.gray_iso_rt_macro_kernel — Function
Equation 17.8 from Gray (2008), assuming AR = AT and ζR = ζT
FormationTemps.rt_macro_kernel — Function
Equation 17.6 from Gray (2008), assuming AR = AT and ξR = ξT
Equation 17.6 from Gray (2008), assuming AR = AT
Miscellaneous Utilities
FormationTemps.round_to_power — Function
round_to_power(x::Real)Round x to one significant digit based on its order of magnitude.
TODO: finish docs.
FormationTemps.elav — Function
elav(a::AbstractVector)
elav(a; dims)Compute midpoints between adjacent elements along dims.
TODO: finish docs.
FormationTemps.searchsortednearest — Function
searchsortednearest(a, x)
searchsortednearest(x, a)Return the index of the element in sorted vector a that is closest to x.
TODO: finish docs.