Skip to content

Commit

Permalink
interface tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ajwheeler committed Nov 7, 2024
1 parent d860e2c commit 403724f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/abundances.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function format_A_X(default_metals_H::R1=0.0, default_alpha_H::R2=default_metals
# make sure the keys of abundances are valid, and convert them to Z if they are strings
clean_abundances = Dict{UInt8,V}()
for (el, abund) in abundances
if el isa Symbol
el = string(el)

Check warning on line 53 in src/abundances.jl

View check run for this annotation

Codecov / codecov/patch

src/abundances.jl#L53

Added line #L53 was not covered by tests
end
if el isa AbstractString
if !(el in keys(Korg.atomic_numbers))
throw(ArgumentError("$el isn't a valid atomic symbol."))
Expand Down
12 changes: 5 additions & 7 deletions src/synth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ function synth(;
rectify=true,
R=Inf,
vsini=0,
kwargs...,)
# if a keyword argument is an atomic symbol, it is assumed to be an abundance
# otherwise, it is passed to synthesize
abunds_set = [k for k in keys(kwargs) if k in atomic_symbols]

A_X = format_A_X(metals_H, alpha_H, Dict(k => kwargs[k] for k in abunds_set))
synthesize_kwargs=Dict(),
abundances...,)
A_X = format_A_X(metals_H, alpha_H, abundances)
atm = interpolate_marcs(Teff, logg, A_X)

Check warning on line 14 in src/synth.jl

View check run for this annotation

Codecov / codecov/patch

src/synth.jl#L13-L14

Added lines #L13 - L14 were not covered by tests

synthesize_kwargs = [k => kwargs[k] for k in keys(kwargs) if !(k in abunds_set)]
# synthesize kwargs currently must be symbols, which is annoying
spectrum = synthesize(atm, linelist, A_X, wavelengths; synthesize_kwargs...)
flux = if rectify
spectrum.flux ./ spectrum.cntm

Check warning on line 19 in src/synth.jl

View check run for this annotation

Codecov / codecov/patch

src/synth.jl#L17-L19

Added lines #L17 - L19 were not covered by tests
else
spectrum.flux

Check warning on line 21 in src/synth.jl

View check run for this annotation

Codecov / codecov/patch

src/synth.jl#L21

Added line #L21 was not covered by tests
end
if isfinite(R)

Check warning on line 23 in src/synth.jl

View check run for this annotation

Codecov / codecov/patch

src/synth.jl#L23

Added line #L23 was not covered by tests
# TODO this induces edge effects
flux = apply_LSF(flux, spectrum.wavelengths, R)

Check warning on line 25 in src/synth.jl

View check run for this annotation

Codecov / codecov/patch

src/synth.jl#L25

Added line #L25 was not covered by tests
end
if vsini > 0
Expand Down

0 comments on commit 403724f

Please sign in to comment.