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

Add albedo correction #128

Open
samaloney opened this issue Nov 9, 2023 · 14 comments · May be fixed by #161
Open

Add albedo correction #128

samaloney opened this issue Nov 9, 2023 · 14 comments · May be fixed by #161

Comments

@samaloney
Copy link
Collaborator

Describe the feature

A few people have been asking if we have implemented the albedo correction similar to OSPEX

Proposed solution

No response

@settwi
Copy link
Contributor

settwi commented Nov 9, 2023

I think that would be an excellent addition. I believe OSPEX implements it as a “pseudo-model” but it shouldn’t be too hard to add if we look up the proper equations.

@KriSun95
Copy link
Collaborator

This has been on my to-do list for a while, I've just never been able to get around to it properly.

I think OSPEX does it via altering the response matrix before the fit and I think the main files to look at are drm_albedo.pro and drm_correct_albedo.pro (found here with some description).

Instructions on how the user interacts with this in OSPEX and some history is here.

@samaloney
Copy link
Collaborator Author

Yea those sav files are nightmare fuel do we have any idea how they were generated? @KriSun95 I think you are correct about the current implementation/approach here's the relevant paper but not clear if that the best way or have a model chain physical-model->albedo-model->SRM

@KriSun95
Copy link
Collaborator

KriSun95 commented Dec 7, 2023

@samaloney, I think your idea of physical-model->albedo-model->SRM makes more sense to me. I don't like the idea of editing the response any more than we really need to while having the correction as a model will help keep things transparent and make it easier to apply to different data too, I'd imagine.

@samaloney
Copy link
Collaborator Author

For RHESSI the albedo correction is included as part of the DRM, the logic being that it's not the observed spectrum I_O you want to fit but the emitted I_E where I_0=I_E + I_A. At the GX_SIMULATOR meeting and found out Edward/Gelu have implemented the Albedo correction as an addition to the model spectrum so we should be able to use the same approach https://github.com/Gelu-Nita/GX_SIMULATOR/blob/d772a411705ceed9db2a5b6eadfa14cd5dda190f/userslib/xray/xray_tt_albedo.pro

@edkontar
Copy link

Green function matrices are now available in JSON format (also as IDL SAVE files) https://github.com/edkontar/albedo

@settwi
Copy link
Contributor

settwi commented Sep 11, 2024

@edkontar thanks, Eduard! this will be very useful for albedo corrections going forward.

would you like to help implement the corrections in Python?

@edkontar
Copy link

would you like to help implement the corrections in Python?

Yes, I would be happy to help

@samaloney
Copy link
Collaborator Author

I have a draft PR open which uses the sav files from SSW in #161

What we eventually need is the ability to generate the "green's matrices"

@samaloney samaloney linked a pull request Sep 12, 2024 that will close this issue
3 tasks
@natsat0919
Copy link
Contributor

I'm still a bit confused by the albedo correction method. If I understand correctly, in the OSPEX, the albedo correction directly modifies the SRM but in our case, we will generate the photon models -> fold it though the albedo correction matrix-> fold this through the SRM to get the count model. During the fitting process, this method is done to each photon model. That means that all our output best fit count models by default have albedo accounted for them during fitting. But OSPEX always outputs the albedo correction as a separate model component during plotting (with the other models e.g. thermal, non-thermal.. plotted as well). Does that mean that during fitting we are account for albedo within each photon model, but then during plotting we plot the count models without the albedo correction (so in our case just : get best-fit the photon models -> fold through SRM) and instead, we plot a composite albedo model? Or am I misunderstanding this?

@edkontar
Copy link

Prior to April 2010, the albedo correction was applied to the DRM once when the DRM file was read, and the modified DRM was stored for use during analysis (this is how it was handled in old SPEX). This proved to be a problem for two reasons. 1. When using the drm_mod function component, the albedo correction was lost when the DRM was recalculated in the drm_mod procedure. 2. In May 2010, albedo was added as a function component to allow you to fit the anisotropy parameter: pseudo function

Assuming isotropic X-rays: for a given photon spectrum I(eps), albedo corrected spectrum is I_corrected =(1+A)##I, and the count spectrum C_corrected=SRM#I_corrected

@edkontar
Copy link

After doing a simple thermal+thick+albedo fit, the results in photon space should look like this:
ekfokgjnddmmoleo

@edkontar
Copy link

I have found IDL code used in 2005 to generate Green Matrices for OSPEX and put it on github:

https://github.com/edkontar/albedo

@samaloney
Copy link
Collaborator Author

Yea I think the main concept as Eduard said is the we are interested in $I_{emmited}$ but what we model/fit is $I_{obs} = I_{emmited} + I_{albedo}$ so in OSPEX this is 'hidden' in the DRM. I think in our case we want to be explicit and show as model component, even if it is often with fixed parameters ($\theta$, anisotropy). If we want to extract some parameters e.g. from a warm_target model, they can just be extracted from that model components parameters unless I'm missing something?

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

Successfully merging a pull request may close this issue.

5 participants