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
adding G10 and C11 intrinsic scattering models #378
base: master
Are you sure you want to change the base?
Conversation
I would like to comment, that I like that very much. |
Hi @MickaelRigault, I also have the C11 but need some extra-test before push I think |
I modfied the PR, I've added the
I followed the SNANA implementation also described in arxiv:1209.2482. The implementation of C11 works as follows:
As for G10 the Gaussian drawing is done each time propagate is called, giving different results at each call. |
Any update on this ? Could that be accepted or you think it should not be made like that ? |
Sorry. I started a new job and am slowly getting settled in. I'll work on this soon. |
After a quick review, sncosmo/sncosmo/tests/test_models.py Lines 342 to 369 in 9037060
|
|
||
def propagate(self, wave, flux): | ||
"""Propagate the effect to the flux.""" | ||
lam_nodes, siglam_values = self.compute_sigma_nodes() |
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.
Would moving this to __init__
make this SALTwithG10.bandflux
the same on repeated calls?
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.
Yes it should works since the random part is in self.compute_sigma_nodes()
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.
Moving this part in __init__
leads to a non-functional Model.set()
since the updates on self._parameters
will not be taken into account. I set a self._seed
parameter in the __init__
to fix the randomness when init the model.
sncosmo/models.py
Outdated
|
||
inf_mask = wave <= self._lam_nodes[0] | ||
sup_mask = wave >= self._lam_nodes[-1] | ||
|
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 these first three statements could be moved to __init__
. Am I missing something?
Remove random variability between call
With respect to @benjaminrose comments, I moved all random variables in |
I'va added tests for G10 and C11 in |
minor change in parameters names
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.
Sorry this is taking a long time. This is a fairly major change in functionality and I want to use it as a template for future additions. I think we are really close to something extremely useful.
There are two issues found in the tests. 1) the tests don't work on python 3.7 and we should discuss what to do to fix that. and 2) there are some code style issues. |
I've corrected the code style. For python 3.7 I think the problem comes from |
Python 3.7 is also end of life, https://devguide.python.org/versions/, maybe we should just bump our minimum dependancies? |
I've re-corrected style. Yes Python 3.7 is end of life and not supported by numpy since 1.22 so changing minimum dependencies is a good solution ! |
Let me drop 3.7 support, then we should be able to merge this in. |
Hi, I propose this implementation for the G10 scattering model, it's a cleaner implementation of one I use in snsim. It follows the implementation used in SNANA as described in arxiv:1209.2482.
I create the
G10
class inmodels.py
that inherit fromPropagationEffect
. To be initialized the class need aSALTsource
:The
compute_sigma_nodes
class function compute a sigma value fromsource.minwave()
tosource.maxwave()
each 800 A, then for each sigma an intrinsic scattering is drawn with gaussian pdf. The result is two arrays : the wavelength at valueslam_nodes
and the scattering value for each wavelengthsiglam_values
.In
propagate
class function the wavelengths are interpolated by a sinus function on (lam_nodes
,siglam_values
).Possible problem: The Gaussian drawing is done each time
propagate
is called, resulting in different results for different calls ofSALTwithG10.bandflux
.