-
Notifications
You must be signed in to change notification settings - Fork 26
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 #161
base: main
Are you sure you want to change the base?
Conversation
I have found IDL code used in 2005 to generate Green Matrices for OSPEX and put it on github: |
I have added the changes we made to the albedo model during the workshop. For now we made the model "unitless" until we resolve the astropy model unit problems with SRM. All the units-related lines are commented so it can be easily updated. |
b9217db
to
6ee7756
Compare
A very minor edit to the evaluate step in the Albedo class which allows unit handling to work with Scipy fitting. This was previously not working at the point of calling get_albedo_matrix, simply adding in self.theta here solves the problem.
The model can now be applied to a spectrum which can be fit by the astropy fitting routines with units handled correctly. However there is still an issue with fitting theta as a free parameter, practically this isnt an issue, however should in principle work.
The code has been restrcutred such that Astropy fitting is now fully functional and all required funtionality is contained within the class rather than externally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the main reason to separate things is to make them testable with these change it will be harder to test so I wonder are they necessary?
In OSPEX/drm_correct_albedo.pro, the anisotropy parameter is “a coefficient showing the ratio of the flux in observer direction to the flux downwards." A smaller value means more of an effect from albedo. A value of 1000 means very little effect. if anisotropy=1 (default) the source is isotropic. However, in the paper, the coefficient α that accounts for anisotropy of the source in the Eddington approximation – that is, "distinct but constant specific intensities in the downward and in the upward hemispheres, in the ratio α” i.e. the anisotropy described as the reciprocal of the anisotropy parameter in the OSPEX. Should the description state the definition of "α" was assumed as in OSPEX? class Albedo(FittableModel): |
I have reverted the code back to its state before the previous commit with some small edits, the functions are now defined outside of the class and the class is used a wrapper, therefore the tests should now work, is it ok for me to push these changes? The albedo model is now functional with astropy fitters. |
Go for it, sounds good |
The functions have been moved out of the class which now functions as a wrapper. The lru_cache method is applied to both the _calculate_albedo_matrix and _get_green_matrix functions, the outputs when fitting are identical with or without the decorators, and the code runs much quicker this way.
Fixes errors in the test process. Co-authored-by: Shane Maloney <[email protected]>
Co-authored-by: Shane Maloney <[email protected]>
Ok so I think this is good to go, @natsat0919 and @jajmitchell could you review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this PR is ready to be merged. I am still trying to get the albedo model to work with a matrix model in astropy class format and with the thermal model in astropy format, which may require some fiddling with the unit handling, we could delay the merge here and get the unit handling all working together before merging, or merge and then deal with this in a differently titled pull request as the albedo model does function now as a stand alone and this is a wider problem. My instinct would be to merge, then open a "compound model unit handling" pull request or issue, but am easy either way.
@samaloney, just realised that the anisotropy parameter needs to have the "name" argument added in its definition, apologies that I spotted this after adding my review, are you happy for me to push this minor change then re-review? |
Co-authored-by: Shane Maloney <[email protected]>
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
PR Description
A a function to read in precomputed greens table and return spectrum with albedo correction, would close #128
spec | albedo
(still waiting on proper units support in astroy for this work Should the model composition operator,|
, support units changing astropy/astropy#17302)Recreated Fig 2 upper from the paper