andreatramacere / jetset

JetSeT a framework for self-consistent modeling and fitting of astrophysical relativistic jets
BSD 3-Clause "New" or "Revised" License
30 stars 15 forks source link

jetset 1.1.2 and minuit minimization #49

Closed mireianievas closed 2 years ago

mireianievas commented 3 years ago

Hi,

I'm stumping with this not-so-descriptive error when trying to minimize with minuit on jetset 1.1.2

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-322-f38f62ed22e3> in <module>
      8                                      1E29,
      9                                      fitname='SSC-best-fit-minuit',
---> 10                                      repeat=3)

~/Software/miniconda/envs/astro/lib/python3.7/site-packages/jetset-1.1.2-py3.7-macosx-10.7-x86_64.egg/jetset/minimizer.py in fit(self, fit_Model, sed_data, nu_fit_start, nu_fit_stop, fitname, fit_workplace, loglog, silent, get_conf_int, max_ev, use_facke_err, use_UL, skip_minimizer, repeat)
    393                     if silent is False:
    394                         print('fit run:',i)
--> 395                 self.minimizer.fit(self,max_ev=max_ev,silent=silent)
    396 
    397                 self.pout = self.minimizer.pout

~/Software/miniconda/envs/astro/lib/python3.7/site-packages/jetset-1.1.2-py3.7-macosx-10.7-x86_64.egg/jetset/minimizer.py in fit(self, model, max_ev, use_UL, silent)
    485         self.molde=model
    486         self.silent=silent
--> 487         self._fit(max_ev)
    488         self._fit_stats()
    489         self._set_fit_errors()

~/Software/miniconda/envs/astro/lib/python3.7/site-packages/jetset-1.1.2-py3.7-macosx-10.7-x86_64.egg/jetset/minimizer.py in _fit(self, max_ev)
    686     def _fit(self,max_ev=None):
    687         bounds = [(par.fit_range_min, par.fit_range_max) for par in self.model.fit_par_free]
--> 688         self._set_minuit_func(self.model.pinit, bounds)
    689         #print('=>,')
    690         if max_ev is None or max_ev==0:

~/Software/miniconda/envs/astro/lib/python3.7/site-packages/jetset-1.1.2-py3.7-macosx-10.7-x86_64.egg/jetset/minimizer.py in _set_minuit_func(self, p_init, bounds, p_error)
    732             pedantic=False,
    733             errordef=1,
--> 734             **kwdarg)
    735 
    736     def chisq_func(self, *p):

~/Software/miniconda/envs/astro/lib/python3.7/site-packages/iminuit/minuit.py in __init__(self, fcn, grad, name, *args, **kwds)
    583         )
    584 
--> 585         self._init_state = _make_init_state(self._pos2var, args, kwds)
    586         self._values = mutil.ValueView(self)
    587         self._errors = mutil.ErrorView(self)

~/Software/miniconda/envs/astro/lib/python3.7/site-packages/iminuit/minuit.py in _make_init_state(pos2var, args, kwds)
   1537             if kw not in pos2var:
   1538                 raise RuntimeError(
-> 1539                     f"{kw} is not one of the parameters [{' '.join(pos2var)}]"
   1540                 )
   1541         nargs = len(kwds)

RuntimeError: forced_parameters is not one of the parameters []

Reading here https://github.com/sncosmo/sncosmo/issues/291 it suggest a change in iminuit api. I'm using iminuit 2.4 .

andreatramacere commented 3 years ago

Hi, iminuit has changed api without retrocompatibility. In the next version of jetset (1.2.0) the requirements are forced to use iminuit<2. Whit older versions of jetset, the only solution is to build an environment with iminuit<2, because when those versions were released iminuit was still at version<2. Please let me know if you need further help, and if you want to install the prerelease of version 1.2.0. I can give you all the guidance you need. By the way in version 1.2.0 I have added pp hadronic models, temporal evolution and the plugin for Sherpa. Thanks for using JetSeT

paarmitap commented 2 years ago

Hello, I am facing the same error when I am trying to model the IC peak with minuit on jetset 1.1.2. I am still not able to understand the procedure explained above. Please let me know how to resolve this issue

andreatramacere commented 2 years ago

@paarmitap I will release 1.2.0 in a few days which will solve all of these issues and provide many more new features. In the meantime, you can use the pre-release 1.2.0rc14: https://github.com/andreatramacere/jetset/releases/tag/1.2.0rc14 To install the pre-release follow the instructions here: https://github.com/andreatramacere/jetset/wiki, or easier, use the script here: https://github.com/andreatramacere/jetset-installer The doc for the pre-release is here: https://andreatramacere.github.io/jetsetdoc/html/index.html There are a few changes, but everything is written in the doc. Please let me know if everything is OK. It is better if you create a new python environment Cheers Andrea

paarmitap commented 2 years ago

@andreatramacere Thank you so much for your reply. I installed the latest version of 1.2.0 and I no longer get this error.