-
Notifications
You must be signed in to change notification settings - Fork 77
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
weighting MC gamma to MAGIC log-parabola spectrum #302
weighting MC gamma to MAGIC log-parabola spectrum #302
Conversation
|
||
return rate | ||
|
||
|
||
def weight(emin, emax, sim_sp_idx, rate, nev, w_param): | ||
def weight(shape, emin, emax, sim_sp_idx, rate, nev, w_param): |
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.
Same as above, explain w_param, especially signs.
lstchain/mc/sensitivity.py
Outdated
elif(shape == "LogParabola"): | ||
dFdE, crab_par = crab_magic(energy) | ||
|
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.
General comment: for differential sensitivity calculations, using the HEGRA power-law spectrum, or a more accurate log-parabola parametrization, will make no difference. The effect would just go through the difference in hardness within each energy bin , and hence is very small for the usually narrow (5 bins/dex) bins we use.
The log-parabola weighting is instead crucial for comparisons of Crab data with MC gammas, for example to obtain parameter distributions, because in that case the energy range spanned by events entering one such comparison may be arbitrarily wide.
Thanks for the comments @moralejo ! I see, then here I'd like to implement the change for only 'rate', 'weight' function, not sensitivity codes. (If needed in the future, I'll pull request again). |
Hi @SeiyaNozaki, I agree with @moralejo that the log-parabola will not make a big difference for the differential sensitivity calculations, but this will be useful for other calculations, thanks for implementing it! |
This reverts commit 99cb79e.
Hi @rlopezcoto Sorry I forgot to answer your message.
For now, no. Just I wanted to implement this function for anyone to use log-parabola weighting. |
param should include 'f0','e0','alpha' | ||
dFdE = f0 * np.power(E / e0, alpha) | ||
|
||
if shape is 'LogParabola': |
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.
Hi @SeiyaNozaki, I'm happy with the changes and would propose this to be accepted if @moralejo approves, just one additional question: if the shape
given is LogParabola
and no beta
parameter is given, will the call throw an error or is there any default value?
Also, what if shape == PowerLaw
and I introduce a beta
parameter in the call?
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.
Hi @rlopezcoto ,
For the first case(LogParabola
without beta
), we will get error.
But the second case(PowerLaw
with beta
), no error and just other parameters are used for the calcurlation.
Would it be better to add the function to check if the param
match the shape
?
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.
what kind of error in the first case? (a generic python one I guess).
It would be great if you could check that we are giving the correct parameters depending on the function introduced.
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.
what kind of error in the first case? (a generic python one I guess).
Yes, just a KeyError.
>>> crab_par_hegra
{'f0': <Quantity 2.83e-11 1 / (cm2 s TeV)>, 'alpha': -2.62, 'e0': <Quantity 1. TeV>}
>>> rate_ = rate("LogParabola", 0.1 * u.TeV, 100 * u.TeV, crab_par_hegra, 0, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/cta/Work/Install/anaconda3/envs/cta-dev/lib/python3.7/site-packages/lstchain-0.4.5.post9+git66dd663-py3.7.egg/lstchain/mc/mc.py", line 107, in rate
log_parabola = LogParabolaSpectralModel.from_log10(amplitude=param['f0'], reference=param['e0'], alpha=-1*param['alpha'], beta=-1*param['beta'])
KeyError: 'beta'
It would be great if you could check that we are giving the correct parameters depending on the function introduced.
I'll introduce such a function in a few days.
I added the function to check if the input parameters correspond to the expected function. |
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.
Thanks a lot @SeiyaNozaki!
If @moralejo approves, I'll merge
Sorry, I got an unit error with Log Parabola function, let me check a little... |
I fixed the unit error, sorry. |
Here I'd like to implement the code for weighting MC gamma to LogParabola spectrum.
Main difference is:
Any comments are welcome.