Skip to content

Commit

Permalink
fix: correct the domains when building the transformer function in si…
Browse files Browse the repository at this point in the history
…mulate
  • Loading branch information
fjebaker committed May 14, 2024
1 parent 18f8587 commit 119d88e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/datasets/spectraldata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ function objective_transformer(
end
R = R_folded[dataset.data_mask, :]
ΔE = bin_widths(dataset)
E = response_energy(dataset.response)
_fold_transformer(T, layout, R, ΔE, E)
model_domain = response_energy(dataset.response)
_fold_transformer(T, layout, R, ΔE, model_domain)
end


Expand Down
7 changes: 3 additions & 4 deletions src/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ function _make_simulation_fitting_config(
response.matrix
end

E = output_domain
ΔE = diff(E)
ΔE = diff(output_domain)

objective = zeros(eltype(E), length(E) - 1)
objective = zeros(eltype(output_domain), length(output_domain) - 1)
variance = ones(eltype(objective), size(objective))

cache = SpectralCache(
layout,
model,
input_domain,
objective,
_fold_transformer(T, layout, R, ΔE, E),
_fold_transformer(T, layout, R, ΔE, input_domain),
)

conf = FittingConfig(
Expand Down
20 changes: 20 additions & 0 deletions test/simulation/test-sample-data-sim.jl
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
using Test, SpectralFitting

# path to the data directory
data1 = SpectralFitting.XmmData(
SpectralFitting.XmmEPIC(),
joinpath(testdir, "xmm/pn_spec_grp.fits"),
)


# smoke test
model = GaussianLine() + PowerLaw(a = FitParam(0.2))
sim = simulate(
model,
data1.data.response,
data1.data.ancillary;
seed = 8,
exposure_time = 1e1,
)

# TODO: add a fit. can't do it at the moment as the simulated datasets don't
# support masking the model domain, so we have singular values at high energies

0 comments on commit 119d88e

Please sign in to comment.