grd349 / PBjam

A repo for our peak baggin code and tips on jam
MIT License
17 stars 6 forks source link

Issue with Example-Star-API-Kepler.ipynb #272

Closed Anohita1 closed 7 months ago

Anohita1 commented 8 months ago

There is an error while performing peakbagging when reproducing the example star given in the notebook

Starting KDE estimation Steps taken: 2000 Steps taken: 3000 Steps taken: 4000 Chains reached stationary state after 4000 iterations. No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument. Starting asymptotic peakbagging /home/pratip/.local/lib/python3.8/site-packages/pbjam/asy_peakbag.py:383: UserWarning: Method mcmc not found: Using method mcmc warnings.warn(f'Method {method} not found: Using method mcmc') Steps taken: 2000 Chains reached stationary state after 2000 iterations.

InvalidIndexError Traceback (most recent call last) File :1, in

File ~/.local/lib/python3.8/site-packages/pbjam/star.py:343, in star.call(self, bw_fac, norders, model_type, tune, nthreads, make_plots, store_chains, asy_sampling, developer_mode) 307 """ Perform all the PBjam steps 308 309 Starts by running KDE, followed by Asy_peakbag and then finally peakbag. (...) 338 science results!
339 """ 341 self.run_kde(bw_fac=bw_fac, make_plots=make_plots) --> 343 self.run_asy_peakbag(norders=norders, make_plots=make_plots, 344 store_chains=store_chains, asy_sampling=asy_sampling, 345 developer_mode=developer_mode) 347 self.run_peakbag(model_type=model_type, tune=tune, nthreads=nthreads, 348 make_plots=make_plots, store_chains=store_chains)

File ~/.local/lib/python3.8/site-packages/pbjam/star.py:243, in star.run_asy_peakbag(self, norders, make_plots, store_chains, asy_sampling, developer_mode) 240 asymptotic_fit(self, norders=norders) 242 # Call --> 243 self.asy_fit(asy_sampling, developer_mode) 245 # Store 246 self.asy_fit.summary.to_csv(self._outpath(f'asymptotic_fitsummary{self.ID}.csv'), 247 index=True, index_label='name')

File ~/.local/lib/python3.8/site-packages/pbjam/asy_peakbag.py:398, in asymptotic_fit.call(self, method, developer_mode) 395 self.fit = pb.nested(self.par_names, bounds, self.likelihood, self.prior, self.path) 396 self.fit() --> 398 self.modeID = self.get_modeIDs(self.fit, self.norders) 399 self.summary = self._get_summary_stats(self.fit)
400 self.samples = self.fit.flatchain

File ~/.local/lib/python3.8/site-packages/pbjam/asy_peakbag.py:555, in asymptotic_fit.get_modeIDs(self, fit, norders) 551 ells = np.array([2, 0]*norders) 553 modeID = pd.DataFrame({'ell': ells, 'nu_med': np.zeros(len(ells)), 'nu_mad': np.zeros(len(ells))}) --> 555 modeID.at[::2, 'nu_med'] = nus_med[1, :] 556 modeID.at[1::2, 'nu_med'] = nus_med[0, :] 558 modeID.at[::2, 'nu_mad'] = nus_mad[1, :]

File /usr/local/lib/python3.8/dist-packages/pandas/core/indexing.py:2281, in _AtIndexer.setitem(self, key, value) 2278 self.obj.loc[key] = value 2279 return -> 2281 return super().setitem(key, value)

File /usr/local/lib/python3.8/dist-packages/pandas/core/indexing.py:2236, in _ScalarAccessIndexer.setitem(self, key, value) 2233 if len(key) != self.ndim: 2234 raise ValueError("Not enough indexers for scalar access (setting)!") -> 2236 self.obj._set_value(*key, value=value, takeable=self._takeable)

File /usr/local/lib/python3.8/dist-packages/pandas/core/frame.py:3869, in DataFrame._set_value(self, index, col, value, takeable) 3867 else: 3868 series = self._get_item_cache(col) -> 3869 loc = self.index.get_loc(index) 3871 # setitem_inplace will do validation that may raise TypeError 3872 # or ValueError 3873 series._mgr.setitem_inplace(loc, value)

File /usr/local/lib/python3.8/dist-packages/pandas/core/indexes/range.py:388, in RangeIndex.get_loc(self, key, method, tolerance) 386 except ValueError as err: 387 raise KeyError(key) from err --> 388 self._check_indexing_error(key) 389 raise KeyError(key) 390 return super().get_loc(key, method=method, tolerance=tolerance)

File /usr/local/lib/python3.8/dist-packages/pandas/core/indexes/base.py:5637, in Index._check_indexing_error(self, key) 5633 def _check_indexing_error(self, key): 5634 if not is_scalar(key): 5635 # if key is not a scalar, directly raise an error (the code below 5636 # would convert to numpy arrays and raise later any way) - GH29926 -> 5637 raise InvalidIndexError(key)

InvalidIndexError: slice(None, None, 2)

1 2 3