phoebe-project / phoebe2

PHOEBE - Eclipsing Binary Star Modeling Software
http://phoebe-project.org
GNU General Public License v3.0
80 stars 30 forks source link

Detached System run_solver(LC Geometry Estimator) error: ValueError: All-NaN slice encountered #441

Closed aliyyanurr closed 3 years ago

aliyyanurr commented 3 years ago

I'm using some LC and RV datas (from several objects) from VizieR. I'm following the steps from this tutorials for this LC and RV data. I assigned the period of the system with b.set_value('period@binary@component', value) (I'm using the referenced value, not running periodogram estimator).

I could run RV geometry estimator, but when I want to run LC geometry estimators, there is an error:

Fri, 23 Apr 2021 23:07 SOLVER       WARNING binning input observations (len: 2478) with 500 bins (ignores sigmas)
/home/aliyya/anaconda3/lib/python3.7/site-packages/phoebe/solverbackends/lc_geometry.py:73: RuntimeWarning: invalid value encountered in greater
  ph_cross = phases[fluxes - np.nanmedian(fluxes) > 0]
/home/aliyya/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py:729: RuntimeWarning: divide by zero encountered in true_divide
  transform = 1.0 / sigma
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model C failed with error: Residuals are not finite in the initial point.
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model CE failed with error: Residuals are not finite in the initial point.
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model CG failed with error: Residuals are not finite in the initial point.
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model CGE failed with error: Residuals are not finite in the initial point.
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model CG12 failed with error: Residuals are not finite in the initial point.
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model CG12E1 failed with error: Residuals are not finite in the initial point.
Fri, 23 Apr 2021 23:07 SOLVER       WARNING 2G model CG12E2 failed with error: Residuals are not finite in the initial point.
/home/aliyya/anaconda3/lib/python3.7/site-packages/phoebe/solverbackends/lc_geometry.py:119: RuntimeWarning: divide by zero encountered in log
  return -np.sum(np.log((2*np.pi)**0.5*yerr)+(y-ymodel)**2/(2*yerr**2))

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-5d51ee214046> in <module>
----> 1 b.run_solver('lcgeom', solution='lcgeom_sol')

~/anaconda3/lib/python3.7/site-packages/phoebe/parameters/parameters.py in _send_if_client(self, *args, **kwargs)
    399 
    400         else:
--> 401             return fctn(self, *args, **kwargs)
    402 
    403     return _send_if_client

~/anaconda3/lib/python3.7/site-packages/phoebe/frontend/bundle.py in run_solver(self, solver, solution, detach, return_changes, **kwargs)
  11527 
  11528         solver_class = getattr(_solverbackends, '{}Backend'.format(solver_ps.kind.title()))
> 11529         params = solver_class().run(self, solver_ps.solver, compute, solution=solution, **{k:v for k,v in kwargs.items() if k not in ['compute']})
  11530         metawargs = {'context': 'solution',
  11531                      'solver': solver_ps.solver,

~/anaconda3/lib/python3.7/site-packages/phoebe/solverbackends/solverbackends.py in run(self, b, solver, compute, **kwargs)
    508 
    509         else:
--> 510             rpacketlists_per_worker = [self.run_worker(**packet)]
    511 
    512         logger.debug("rank:{}/{} calling _fill_solution".format(mpi.myrank, mpi.nprocs))

~/anaconda3/lib/python3.7/site-packages/phoebe/solverbackends/solverbackends.py in run_worker(self, b, solver, compute, **kwargs)
    586 
    587         diagnose = kwargs.get('diagnose', False)
--> 588         fit_result = lc_geometry.fit_lc(phases, fluxes, sigmas)
    589         eclipse_dict = lc_geometry.compute_eclipse_params(phases, fluxes, sigmas, fit_result=fit_result, diagnose=diagnose)
    590 

~/anaconda3/lib/python3.7/site-packages/phoebe/solverbackends/lc_geometry.py in fit_lc(phases, fluxes, sigmas)
    213             'CG12E2': ['C', 'mu1', 'd1', 'sigma1', 'mu2', 'd2', 'sigma2', 'Aell']}
    214 
--> 215     best_fit = list(models.keys())[np.nanargmax(list(bics.values()))]
    216     return {'fits':fits, 'models':models, 'bics':bics, 'best_fit':best_fit, 'model_parameters': params}
    217 

<__array_function__ internals> in nanargmax(*args, **kwargs)

~/anaconda3/lib/python3.7/site-packages/numpy/lib/nanfunctions.py in nanargmax(a, axis)
    548         mask = np.all(mask, axis=axis)
    549         if np.any(mask):
--> 550             raise ValueError("All-NaN slice encountered")
    551     return res
    552 

ValueError: All-NaN slice encountered

I thought it was the system which has very narrow LC eclipses that affects the estimator module, because it runs well when I'm using semidetached system (nicely gaussian-like curved). It still returns the same error for another detached systems (but not too narrow/more narrow eclipses) I got from VizieR. I didn't change much the parameters and constraints, I'm following the tutorial I wrote above. Is there anything that should be done to solve this error?

kecnry commented 3 years ago

Can you please let us know what version of PHOEBE you're running? A similar bug was fixed in 2.3.21 - so if you're running anything older than that, please update and let us know if that fixes the issue or not.

And if that isn't the case - can you please send a short script so that we can reproduce the error and see what's going on? The easiest way is probably to save the bundle and upload that along and then just show any arguments you're passing to run_solver.

Thanks!

aliyyanurr commented 3 years ago

Can you please let us know what version of PHOEBE you're running? A similar bug was fixed in 2.3.21 - so if you're running anything older than that, please update and let us know if that fixes the issue or not.

And if that isn't the case - can you please send a short script so that we can reproduce the error and see what's going on? The easiest way is probably to save the bundle and upload that along and then just show any arguments you're passing to run_solver.

Thanks!

I was using PHOEBE ver. 2.3.3 when I face this problem. I've updated it to v2.3.33 and it runs well for LC geometry estimator. Thank you!

But then there's another error when I want to adopt the EBAI estimator solution:

print(b.adopt_solution('ebai_sol', trial_run=True))`, with the error message:

Sat, 24 Apr 2021 12:37 BUNDLE       WARNING solution='ebai_sol' is not included in run_checks_solution@setting, so will not raise interactive warnings
Sat, 24 Apr 2021 12:37 BUNDLE       WARNING at least one parameter in adopt_parameters includes nan in fitted_values  If not addressed, this warning will continue to be raised and will throw an error at adopt_solution.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-45a57b3d7989> in <module>
----> 1 print(b.adopt_solution('ebai_sol', trial_run=True))

/opt/anaconda3/lib/python3.7/site-packages/phoebe/frontend/bundle.py in adopt_solution(self, solution, adopt_parameters, adopt_distributions, adopt_values, trial_run, remove_solution, return_changes, **kwargs)
  11916                                      adopt_values=adopt_values,
  11917                                      trial_run=trial_run,
> 11918                                      **kwargs)
  11919 
  11920         if adopt_values and not trial_run:

/opt/anaconda3/lib/python3.7/site-packages/phoebe/frontend/bundle.py in run_checks_solution(self, solution, compute, solver, figure, raise_logger_warning, raise_error, **kwargs)
   4537                                                 True, 'adopt_solution')
   4538 
-> 4539         self._run_checks_warning_error(report, raise_logger_warning, raise_error)
   4540 
   4541         return report

/opt/anaconda3/lib/python3.7/site-packages/phoebe/frontend/bundle.py in _run_checks_warning_error(self, report, raise_logger_warning, raise_error)
   2870         if raise_error:
   2871             if not report.passed:
-> 2872                 raise ValueError("failed to pass checks\n{}".format(report))
   2873 
   2874     def run_checks(self, raise_logger_warning=False, raise_error=False, **kwargs):

ValueError: failed to pass checks
Run Checks Report: FAIL
WARNING: solution='ebai_sol' is not included in run_checks_solution@setting, so will not raise interactive warnings (1 affected parameters, affecting )
ERROR: at least one parameter in adopt_parameters includes nan in fitted_values (2 affected parameters, affecting adopt_solution)

Is this the same issues?

I'll put the iPython Notebook file here. Thank you. inverse_paper_examples CV Boo.zip

kecnry commented 3 years ago

Ok, that's great to hear! No, this other error message really just says that ebai is failing for your system (which isn't uncommon - we're hoping to improve it to be more flexible in the future). I'll make a note to explain this better in the tutorials/docs... but in general, I would recommend just using the other two estimators for now anyways.

I'll close this issue for now - but feel free to start a new issue if you run into any other errors, or ask questions on the discussion board.

Thanks!