Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/src/examples/xrism-simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ begin
erange = 10 .^ collect(range(log10(4), log10(20.0), 100))
model2 = GaussianLine() + GaussianLine(μ = FitParam(10.0))
plot(
erange[1:(end-1)],
erange[1:(end - 1)],
@time(invokemodel(erange, model)),
marker = :o,
markersize = 4,
label = "XS",
)
plot!(
erange[1:(end-1)],
erange[1:(end - 1)],
@time(invokemodel(erange, model2)),
marker = :o,
markersize = 4,
Expand All @@ -40,14 +40,14 @@ model = XS_PowerLaw(a = FitParam(2.0), K = FitParam(1.0))
emids = push!(copy(resp.channel_bins_low), last(resp.channel_bins_high))
evald = push!(copy(resp.bins_low), last(resp.bins_high))
out = resp.matrix * invokemodel(evald, model)
plot(emids[1:(end-1)], out)
plot(emids[1:(end - 1)], out)


sims = @time simulate(model, resp, anc; exposure_time = 1e3, seed = 42)
plot(sims, xscale = :log10, yscale = :log10, xlims = (1.0, 30.0), ylims = (1e-6, 100.0))
sims = @time simulate(model, resp, anc; exposure_time = 1.0e3, seed = 42)
plot(sims, xscale = :log10, yscale = :log10, xlims = (1.0, 30.0), ylims = (1.0e-6, 100.0))

begin
sims = @time simulate(model, resp, nothing; exposure_time = 1e5, seed = 42)
sims = @time simulate(model, resp, nothing; exposure_time = 1.0e5, seed = 42)
normalize!(faked)
plot(
faked,
Expand All @@ -58,7 +58,7 @@ begin
)
plot!(sims)
plot!(
emids[1:(end-1)] .+ diff(emids) ./ 2,
emids[1:(end - 1)] .+ diff(emids) ./ 2,
out .* 1.4,
xscale = :log10,
label = "Hand folded",
Expand All @@ -71,18 +71,18 @@ result = @time fit(prob, LevenbergMarquadt())
plot!(faked, result)


sims = @time simulate(model, resp, anc; exposure_time = 1e3, seed = 42)
sims = @time simulate(model, resp, anc; exposure_time = 1.0e3, seed = 42)
plot(
sims,
xscale = :log10,
# yscale = :log10,
xlims = (1.0, 10.0),
ylims = (1e-6, 40.0),
ylims = (1.0e-6, 40.0),
)

model = GaussianLine(μ = FitParam(7.0)) + PowerLaw(a = FitParam(0.2))

sims = @time simulate(model, resp, nothing; exposure_time = 1e5, seed = 42)
sims = @time simulate(model, resp, nothing; exposure_time = 1.0e5, seed = 42)

plot(
sims,
Expand Down
2 changes: 2 additions & 0 deletions lib/XSPECModels/src/XSPECModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function register_xspec_data()
register_model_data(XS_Kerrconv, "kerrtable.fits"; root = LIBXSPEC_STORAGE_PATH)
register_model_data(XS_KyrLine, "KBHline01.fits"; root = LIBXSPEC_STORAGE_PATH)
register_model_data(XS_Laor, "ari.mod"; root = LIBXSPEC_STORAGE_PATH)
return
end


Expand All @@ -32,6 +33,7 @@ function __init__()
# set an environment variable so we don't accidentally init again
ENV["SPECTRAL_FITTING_XSPEC_INIT"] = "true"
end
return
end

end # module XSPECModels
Loading
Loading