hpparvi / MuSCAT2_transit_pipeline

MuSCAT2 transit analysis pipeline
GNU General Public License v3.0
5 stars 0 forks source link

ta.optimize says ValueError: could not broadcast input array from shape (200,0) into shape (200,239) #25

Open TakuNishiumi opened 3 years ago

TakuNishiumi commented 3 years ago

I analyzed data of TOI01634.01 observed on 210213.

#optimize the parameter set using differential evolution
ta.optimize(500)

fig, axs = ta.plot_fit('de');

returns

Optimizing the model: 0%
0/500 [00:00<?, ?it/s]

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-48-da8ec6d1d9c3> in <module>
      1 #optimize the parameter set using differential evolution
----> 2 ta.optimize(500)
      3 
      4 fig, axs = ta.plot_fit('de');

~/github/MuSCAT2_transit_pipeline/muscat2ta/transitanalysis.py in optimize(self, niter, pop, plot_convergence, plot_lc)
    207 
    208     def optimize(self, niter: int = 1000, pop: ndarray = None, plot_convergence: bool = True, plot_lc: bool = False):
--> 209         self.lpf.optimize_global(niter, self.npop, pop, label='Optimizing the model')
    210         self.pv = self.lpf.de.minimum_location
    211 

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/lpf/logposteriorfunction.py in optimize_global(self, niter, npop, population, label, leave, plot_convergence, use_tqdm, plot_parameters)
    142             else:
    143                 self.de._population[:, :] = population
--> 144         for _ in tqdm(self.de(niter), total=niter, desc=label, leave=leave, disable=(not use_tqdm)):
    145             pass
    146 

~/miniconda3/envs/py3/lib/python3.8/site-packages/tqdm/notebook.py in __iter__(self, *args, **kwargs)
    251     def __iter__(self, *args, **kwargs):
    252         try:
--> 253             for obj in super(tqdm_notebook, self).__iter__(*args, **kwargs):
    254                 # return super(tqdm...) will not catch exception
    255                 yield obj

~/miniconda3/envs/py3/lib/python3.8/site-packages/tqdm/std.py in __iter__(self)
   1164 
   1165         try:
-> 1166             for obj in iterable:
   1167                 yield obj
   1168                 # Update and possibly print the progressbar.

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/utils/de.py in _eval_vfun(self, ngen)
    221         popt, fitt = self._trial_pop, self._trial_fit
    222 
--> 223         fitc[:] = self.m * self.minfun(self._population)
    224 
    225         for igen in range(ngen):

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/utils/de.py in __call__(self, x)
    248 
    249     def __call__(self, x):
--> 250         return self.f(x, *self.args, **self.kwargs)

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/lpf/logposteriorfunction.py in lnposterior(self, pv)
    118 
    119     def lnposterior(self, pv):
--> 120         lnp = self.lnprior(pv) + self.lnlikelihood(pv)
    121         return where(isfinite(lnp), lnp, -inf)
    122 

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/lpf/lpf.py in lnlikelihood(self, pvp)
    444 
    445         for lnlikelihood in self._lnlikelihood_models:
--> 446             lnl += lnlikelihood(pvp, fmodel)
    447         return lnl
    448 

~/github/MuSCAT2_transit_pipeline/muscat2ta/m2lpf.py in __call__(self, pvp, model)
    206             return lnlike_logistic_v1d(self.lpf.ofluxa, flux_m, err, self.lpf.lcids)
    207         else:
--> 208             return lnlike_logistic_v(self.lpf.relative_flux(pvp), flux_m, err, self.lpf.lcids)
    209 
    210 class M2LPF(BaseLPF):

~/github/MuSCAT2_transit_pipeline/muscat2ta/m2lpf.py in relative_flux(self, pv)
    781             return self.ofluxa
    782         else:
--> 783             return self.target_flux(pv) / self.reference_flux(pv)
    784 
    785     def target_flux(self, pv):

~/github/MuSCAT2_transit_pipeline/muscat2ta/m2lpf.py in target_flux(self, pv)
    790         off = zeros((p.shape[0], self.timea.size))
    791         for i, sl in enumerate(self.lcslices):
--> 792             off[:, sl] = self.target_fluxes[i][:, p].T
    793         return squeeze(off)
    794 

ValueError: could not broadcast input array from shape (200,0) into shape (200,239)
hpparvi commented 3 years ago

Hi Taku,

I can't repeat this error, the optimization works ok for me. Can you send me your analysis notebook and I'll try to run it.

Cheers, Hannu