fjebaker / SpectralFitting.jl

✨🛰 Fast and flexible spectral fitting in Julia.
https://fjebaker.github.io/SpectralFitting.jl
GNU General Public License v3.0
9 stars 5 forks source link

Adding Optxagnf model #127

Closed GloriaRAH closed 2 months ago

GloriaRAH commented 2 months ago

Adding a draft for the Optxagnf model. Not yet tested if it is working.

fjebaker commented 2 months ago

Not necessarily for you, but I wanted to write this up to eventually put in the documentation:

Here's a short guide on how to test / develop, just for reference in case it's needed

mkdir temp-jl && cd temp-jl      # use a temporary environment
julia --project=.
# then in package manager mode
(temp-jl) pkg> dev --local SpectralFitting

# back on the command line
cd dev/SpectralFitting
git fetch origin pull/127/head:gloria
git switch gloria
cd ../..

Now you have your version of the code loaded in development mode. So you can use code . or whatever to open the temp-jl directory in VSCode.

fjebaker commented 2 months ago

Fixing that typo fixes everything :) The following works fine:

using SpectralFitting

model = XS_Optxagnf() 
energies = collect(range(0.01, 10.0, 100))
invokemodel(energies, model)
fjebaker commented 2 months ago
using SpectralFitting, UnicodePlots

function plotmodel(energy, model)
    flux = invokemodel(energy, model)
    lineplot(
        energy[1:end-1],
        flux,
        title=String(Base.typename(typeof(model)).name),
        xlabel="E (keV)",
        canvas=DotCanvas
    )
end

# e.g. for XS_PowerLaw()
energy = collect(range(0.1, 20.0, 100))
plotmodel(energy, XS_Optxagnf())

The resulting plot might need log axes or some different parameters, but I'll leave that choice to you