mikecokina / elisa

GNU General Public License v2.0
15 stars 5 forks source link

Fitting LC with log/sqrt LD Law #11

Closed zihaowrez closed 2 years ago

zihaowrez commented 2 years ago

Hi,

I'm trying to fit a light curve with different LD laws. However, when I start fitting I get an error:

Screenshot 2022-02-06 225155

The program runs smoothly when I change to linear law. Below is the full error message:

---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "C:\Users\37419\anaconda3\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\37419\anaconda3\lib\site-packages\elisa\binary_system\curves\c_managed.py", line 57, in produce_circ_sync_curves_mp
    curves = curves_fn(curves, pos_idx, crv_labels, on_pos)
  File "C:\Users\37419\anaconda3\lib\site-packages\elisa\binary_system\curves\lc_point.py", line 33, in compute_lc_on_pos
    band_curves[band][pos_idx] = _calculate_lc_point(band, system)
  File "C:\Users\37419\anaconda3\lib\site-packages\elisa\binary_system\curves\lc_point.py", line 16, in _calculate_lc_point
    flux += crv_utils.flux_from_star_container(band, star)
  File "C:\Users\37419\anaconda3\lib\site-packages\elisa\base\curves\utils.py", line 51, in flux_from_star_container
    return up.sum(calculate_surface_element_fluxes(band, star))
  File "C:\Users\37419\anaconda3\lib\site-packages\elisa\base\curves\utils.py", line 35, in calculate_surface_element_fluxes
    ld_cors = ld.limb_darkening_factor(coefficients=ld_cfs,
  File "C:\Users\37419\anaconda3\lib\site-packages\elisa\ld.py", line 187, in limb_darkening_factor
    retval[negative_cos_theta_test] = 0.0
IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1
"""

The above exception was the direct cause of the following exception:

IndexError                                Traceback (most recent call last)
<ipython-input-19-249ae2ab9e90> in <module>
      1 lst_sqr_task.set_result(lc_initial)
      2 
----> 3 lst_sqr_task.plot.model(discretization=5, number_of_points=1000, start_phase=-0.6, stop_phase=0.6)

~\anaconda3\lib\site-packages\elisa\analytics\binary_fit\plot.py in model(self, start_phase, stop_phase, number_of_points, discretization, separation, data_frac_to_normalize, normalization_kind, plot_legend, loc, return_figure_instance, rasterize, **kwargs)
    289         observer._system_cls = BinarySystem
    290 
--> 291         lc_fit = synthetic_binary(synth_phases, discretization, observer, **kwargs_to_replot)
    292         lc_fit, _ = normalize_light_curve(lc_fit, kind=average_kind, top_fraction_to_average=0.001)
    293 

~\anaconda3\lib\site-packages\elisa\analytics\models\lc.py in synthetic_binary(phases, discretization, observer, **kwargs)
     47     observer._system = binary
     48 
---> 49     lc = observer.observe.lc(phases=phases, normalize=True)
     50     return lc[1]

~\anaconda3\lib\site-packages\elisa\observer\observer.py in lc(self, from_phase, to_phase, phase_step, phases, normalize)
     24 
     25     def lc(self, from_phase=None, to_phase=None, phase_step=None, phases=None, normalize=False):
---> 26         return self.observer.lc(from_phase, to_phase, phase_step, phases, normalize)
     27 
     28     def rv(self, from_phase=None, to_phase=None, phase_step=None, phases=None, normalize=False, method=None):

~\anaconda3\lib\site-packages\elisa\observer\observer.py in lc(self, from_phase, to_phase, phase_step, phases, normalize, from_time, to_time, time_step, times)
    179         )
    180 
--> 181         curves = self._system.compute_lightcurve(**lc_kwargs)
    182 
    183         # remap unique phases back to original phase interval

~\anaconda3\lib\site-packages\elisa\binary_system\system.py in compute_lightcurve(self, **kwargs)
   1219         """
   1220         curve_fn = c_router.resolve_curve_method(self, curve='lc')
-> 1221         return curve_fn(**kwargs)
   1222 
   1223     def _compute_circular_synchronous_lightcurve(self, **kwargs):

~\anaconda3\lib\site-packages\elisa\binary_system\system.py in _compute_circular_synchronous_lightcurve(self, **kwargs)
   1222 
   1223     def _compute_circular_synchronous_lightcurve(self, **kwargs):
-> 1224         return lc.compute_circular_synchronous_lightcurve(self, **kwargs)
   1225 
   1226     def _compute_circular_spotty_asynchronous_lightcurve(self, **kwargs):

~\anaconda3\lib\site-packages\elisa\binary_system\curves\lc.py in compute_circular_synchronous_lightcurve(binary, **kwargs)
     29 
     30     _args = (binary, initial_system, unique_phase_interval, lc_point.compute_lc_on_pos, band_labels)
---> 31     band_curves = c_router.produce_circular_sync_curves(*_args, **kwargs)
     32     band_curves = {band: band_curves[band][reverse_phase_map] for band in band_curves}
     33 

~\anaconda3\lib\site-packages\elisa\binary_system\curves\c_router.py in produce_circular_sync_curves(binary, initial_system, phases, curve_fn, crv_labels, **kwargs)
    115     fn = c_managed.produce_circ_sync_curves_mp
    116     fn_args = (binary, initial_system, crv_labels, curve_fn)
--> 117     return manage_observations(fn=fn, fn_args=fn_args, position=phases, **kwargs)
    118 
    119 

~\anaconda3\lib\site-packages\elisa\observer\mp_manager.py in manage_observations(fn, fn_args, position, **kwargs)
     28         pool.join()
     29         # this will return output in same order as was given on apply_async init
---> 30         result = [r.get() for r in result]
     31         band_curves = utils.renormalize_async_result(result)
     32         return band_curves

~\anaconda3\lib\site-packages\elisa\observer\mp_manager.py in <listcomp>(.0)
     28         pool.join()
     29         # this will return output in same order as was given on apply_async init
---> 30         result = [r.get() for r in result]
     31         band_curves = utils.renormalize_async_result(result)
     32         return band_curves

~\anaconda3\lib\multiprocessing\pool.py in get(self, timeout)
    769             return self._value
    770         else:
--> 771             raise self._value
    772 
    773     def _set(self, i, obj):

IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1

How should I solve this? Thank you!

mirofedurco commented 2 years ago

Hi,

unfortunately, I was unable to reproduce the error in neither the latest release 0.5.1 nor in the latest development version 0.6dev. I tested the different limb darkening laws on demo08 and some custom LC fitting scripts using code very similar to the code in your screenshot. Could you provide me with the minimal working example (jupyter notebook or python script) that is able to reproduce this issue? This would help immensely to locate and fix the suspected bug.

Sincerely, Miro

zihaowrez commented 2 years ago

Hi, here is a minimal example. My ELISa version is 0.5.0dev. Thanks!

mirofedurco commented 2 years ago

Hi,

the script that you provided me with works fine on my machine. I tested it on versions 0.5 and 0.5.1. The problem you mentioned seems to me as a problem with numpy where the dimensions of the mask array is mismatched for some reason. Such problem was supposed to be catched by the unittests. I would recommend you to try upgrade the elisa to the latest release version 0.5.1 starting with a clean uninstall of the old version using pip uninstall elisa and then installing the newer version forcing the current release version pip install elisa==0.5.1.

Sincerely, Miro

zihaowrez commented 2 years ago

Thank you, I'll try upgrading. I'll close the issue for now.