Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying a gain correction #147

Open
KriSun95 opened this issue Jun 12, 2024 · 1 comment
Open

Applying a gain correction #147

KriSun95 opened this issue Jun 12, 2024 · 1 comment

Comments

@KriSun95
Copy link
Collaborator

Provide a general description of the issue or problem.

It turns out that the gain correction (if applied) being performed in fitting_legacy is not being done in the same way as XSPEC, it was doing it more like another package (see gainshift in here).

XSPEC will gain shift the photon energy grid of the spectral response. This is done by defining a new energy grid with the equation $E_{new}=E_{old}/G_{slope} - G_{offset}$ for the photon axis of the SRM then evaluating the photon model at these new energies and interpolating the effective areas (if present) to the $E_{new}$.

The way fitting_legacy does it at the minute is by defining a new energy grid with the same equation but on the output count axis grid. The output model is then interpolated to the $E_{new}$ and compared to the data.

One thing to figure out is which way is the correct way to gain shift.

At the minute, this only affects fitting_legacy but has implications on how things may need to be implemented/made available during the refactor.

I expect this to turn into a discussion and more should be added, but this is maybe a good start! (although it seemed to have started a while ago elsewhere)

@KriSun95 KriSun95 mentioned this issue Jun 12, 2024
@settwi
Copy link
Contributor

settwi commented Nov 8, 2024

"gain" is the conversion from ADC to count energy, generally linear which i guess NuSTAR assumes across its valid range

for a diagonal matrix i reckon it wouldn't make a difference. for non-diagonal matrices (as things tend to be at higher energies like >100 keV) i would be surprised if interpolating the photon axis is the way to go.

fundamentally if the gain is changing then interpolating either photons or counts doesn't make much sense. what should be modified is the response matrix, so that the count bin edges shift and map different incident photon energies to different count energies. this requires that the matrix be re-interpolated. for XSPEC i reckon they couldn't be bothered to code that into the 30 year old package so instead went with the photon interpolation approximation (which might work for fine enough energy bins)

...

just some thoughts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants