Closed mireianievas closed 2 years ago
Dear Mireia, thanks a lot for using jeteset. Before going into the details may I ask you which version you are using? I suggest you to install the release candidate of the new version: https://github.com/andreatramacere/jetset/releases/tag/1.2.0rc10 You can directly use the installer https://github.com/andreatramacere/jetset-installer, passing to the command line the argument 1.2.0rc10. The documentation for the pre-release is here: https://andreatramacere.github.io/jetsetdoc/html/index.html Now, coming to your issue. I should have a look at the code that you use to plot in matplotlib to understand what is going on. The other problem might be solved with the version that I am suggesting you to install. Please, let me know how things evolve and how I can help you. Cheers Andrea
I am using 1.1.2, the last stable I guess. I will try the pre-release you mention. Any big compatibility issue I need to know in advance?
One, maybe relevant bit, is that I have my own electron distribution defined. It is basically a broken power law, but defined in a way that it is always concave (i.e. redefining p_1 so that p_1' = abs(p_1 - p). Maybe (I'm not saying it is the reason) jetset 'forgets' at some point it is a custom distribution and uses a standard broken power law?
from jetset.jet_emitters import EmittersDistribution
def distr_func_bkn(gamma_break,gamma,p,p_1):
return np.power(gamma,-np.abs(p))*(1.+(gamma/gamma_break))**(-np.abs(p_1))
bkn2=EmittersDistribution('bkn')
bkn2.add_par('gamma_break',par_type='turn-over-energy',val=1E3,vmin=1., vmax=None, unit='lorentz-factor')
bkn2.add_par('p',par_type='LE_spectral_slope',val=2.5,vmin=0., vmax=10, unit='')
bkn2.add_par('p_1',par_type='HE_spectral_slope',val=3.2,vmin=0., vmax=10, unit='')
bkn2.set_distr_func(distr_func_bkn)
bkn2.parameters.show_pars()
bkn2.parameters.p.val=2
bkn2.parameters.p_1.val=0.5
p=bkn2.plot3p()
p.fig
At least that would perhaps explain this non-sense SED
So I found what happens, you called the distribution with the same name of the custom model, 'bkn'. Once you save the model, and you load it, the constructor is getting the custom one. In version 1.1.2 I have not implemented the serialization of the custom electron distribution. This is done with the version that I have suggested before, anyhow I found the solution for your problem, still using version 1.1.2. Use the code attached, and remember, once you load the model and then you update it with the saved custom distribution, run .eval()
to update
custom_emitters_ditribution_serialization.ipynb.gz
I have also pushed the notebook with the solution to the git repo that you share before. Please, let me know if this solved your problem
Thank you Andrea, I will try it !
El jue., 4 nov. 2021 23:01, andrea tramacere @.***> escribió:
I have also pushed the notebook with the solution to the git repo that you share before. Please, let me know if this solved your problem
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/andreatramacere/jetset/issues/52#issuecomment-961495757, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAT4VEHMKLOHYEL75CVOH2TUKMGDZANCNFSM5HL7FUKA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Regarding compatibility, there might be minor changes. Just in case, share with me a piece of code with all the jetset steps that you are using, I will check if it is OK
I have done a couple of fits:
I want to make the plot a bit nicer, so I explore each model component and plot it with matplotlib. I get:
I really don't understand this. I have all these Jet instances stored in a dict and I'm doing exactly the same eval() thing for all of them, and using the same plotting code. It is not a bug in the code because the weird output happens only sometimes, other times it is plot correctly. I have been dealing with this issue for months and I have found no logical pattern, maybe you can bring some light to it ??
PS. I also have other issues with jetset, like how the fit is done (e.g. why if I set a maximum of calls to 300 it does whatever it wants, being it 20 calls or 500?, or why if I set the starting parameters to a reasonable solution the minimizer goes crazy exploring a random part of the space parameter that is super far away from the initial parameter values) or why if I store the Jet models then recovering them brings me wrong parameters?. But for now let's concentrate on the plotting thing I presented before :P