Utilities

Spectra.blackbodyFunction
blackbody(wave::Vector{<:Quantity}, T::Quantity)
blackbody(wave::Vector{<:Real}, T::Real)

Create a blackbody spectrum using Planck's law. The curve follows the mathematical form

$B_λ(T) = \frac{2hc^2}{λ^5} \frac{1}{e^{hc/λ k_B T} - 1}$

If wave and T are not Unitful.Quantity, they are assumed to be in angstrom and Kelvin, and the returned flux will be in units W m^-2 Å^-1.

The physical constants are calculated using PhysicalConstants.jl, specifically the CODATA2018 measurement set.

References

Planck's Law

Examples

julia> using Spectra, Unitful, UnitfulAstro

julia> wave = range(1, 3, length=100)u"μm"
(1.0:0.020202020202020204:3.0) μm

julia> bb = blackbody(wave, 2000u"K")
SingleSpectrum(Quantity{Float64, 𝐋, Unitful.FreeUnits{(μm,), 𝐋, nothing}}, Quantity{Float64, 𝐌 𝐋^-1 𝐓^-3, Unitful.FreeUnits{(μm^-1, m^-2, W), 𝐌 𝐋^-1 𝐓^-3, nothing}})
  wave (100,): 1.0 μm .. 3.0 μm
  flux (100,): 89534.30930426194 W μm^-1 m^-2 .. 49010.54557924032 W μm^-1 m^-2
  meta: Dict{Symbol, Any}(:T => 2000 K, :name => "Blackbody")

julia> blackbody(ustrip.(u"angstrom", wave), 6000)
SingleSpectrum(Float64, Float64)
  wave (100,): 10000.0 .. 30000.0
  flux (100,): 1190.9562575755397 .. 40.04325690910415
  meta: Dict{Symbol, Any}(:T => 6000, :name => "Blackbody")

julia> bb.wave[argmax(bb)]
1.4444444444444444 μm

julia> 2898u"μm*K" / bb.T # See if it matches up with Wien's law
1.449 μm
source
blackbody(T::Quantity)

Returns a function for calculating blackbody curves.

source
Spectra.equivalent_widthFunction
equivalent_width(::AbstractSpectrum)

Calculate the equivalent width of the given continuum-normalized spectrum. Return value has units equal to wavelengths.

source
Spectra.line_fluxFunction
line_flux(::AbstractSpectrum)

Calculate the line flux of the given continuum-normalized spectrum. Return value has units equal to flux.

source