The default filter width of 0.01 used by pg.flatten() (added to star.__init__() following Issue #197) sometimes subtracts the signal, requiring a larger filter width (see below). When you pass a custom SNR to star, this resets and uses the default filter width. A quick work-around is to set star.pg = custom_snr following initialisation. However, I feel that either subtracting the background within PBjam or having kwargs to pass to flatten would be more intuitive.
# Given some predefined lightkurve.Periodogram object `pg`
flattened = []
filter_widths = [0.005, 0.01, 0.1, 0.2]
for fw in filter_widths:
flattened.append(pg.flatten(filter_width=fw, return_trend=True))
ax = pg.plot(scale='log', alpha=0.3, label='No filter')
for (snr, bkd), fw in zip(flattened, filter_widths):
bkd.plot(scale='log', ax=ax, label=f'FW = {fw}')
ax.axvline(numax[0], ymax=2e4, c='r', ls='--', alpha=0.5, label=r'$\nu_\max$')
ax.set_xlim(8, 300)
ax.set_ylim(10, 2e4)
ax.legend()
fig2, axs = plt.subplots(2, 1, figsize=(12, 9))
snr = [pg.flatten(), pg.flatten(filter_width=0.2)]
for ax, s in zip(axs, snr):
ax.axvline(numax[0], ymax=100, c='r', ls='--', alpha=0.5, label=r'$\nu_\max$')
s.plot(ax=ax);
ax.set_xlim(0, 150)
plt.show()
The default filter width of 0.01 used by
pg.flatten()
(added tostar.__init__()
following Issue #197) sometimes subtracts the signal, requiring a larger filter width (see below). When you pass a custom SNR tostar
, this resets and uses the default filter width. A quick work-around is to setstar.pg = custom_snr
following initialisation. However, I feel that either subtracting the background within PBjam or having kwargs to pass to flatten would be more intuitive.