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

Disabled datasets included in optimization when generic passband parameters are being adjusted #595

Open aprsa opened 2 years ago

aprsa commented 2 years ago

Say we add two datasets and disable one; then we add pblum@primary to be adjusted. This will adjust both the enabled and the disable dataset's pblum@primary. A simple workaround is to be explicit and add pblum@primary@enabled_dataset, but this should not be a requirement.

Minimal example:

import phoebe
import numpy as np

b = phoebe.default_binary()
b.add_dataset('lc', times=np.linspace(0, 1, 21), fluxes=np.ones(21), passband='Johnson:B', dataset='B')
b.add_dataset('lc', times=phoebe.linspace(0, 1, 21), fluxes=np.ones(21), passband='Johnson:V', dataset='V')
b.disable_dataset('B')

b.add_solver('optimizer.nelder_mead', solver='nms')
b['fit_parameters@nms'] = ['pblum@primary']

b.run_solver('nms', solution='problem')
print(b['problem'])
kecnry commented 2 years ago

This will require some (more) thought:

b['fit_parameters'].expand_value() (which is available to the user, but also is used internally to determine what parameters to pass to the optimizer) matches all visible parameters and is not aware of which compute options will be used, so will expand to include both pblums. Ideally, to avoid any confusion of the underlying behavior, this logic would be able to be extended to know about the referenced compute options and not include values from disabled datasets. But then this logic will need to also account for passing compute as a keyword argument to run_solver.

The other option would be to cover this in b.run_checks_solver to either raise a warning or an error. If just a warning, we could conceivably drop parameters from disabled datasets within the solver itself. The fitted parameters are available in the solution, so even if the warning isn't noticed, there will still be some indication of the "dropped" parameters when comparing to the expanded value of the input fit_parameters.