Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg.flatten() in star __init__ uses default filter width #213

Open
alexlyttle opened this issue Jan 31, 2020 · 1 comment
Open

pg.flatten() in star __init__ uses default filter width #213

alexlyttle opened this issue Jan 31, 2020 · 1 comment

Comments

@alexlyttle
Copy link
Collaborator

alexlyttle commented Jan 31, 2020

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()

image
image

@alexlyttle alexlyttle changed the title pg.flatten() in star __init__ causes pg.flatten() in star __init__ uses default filter width Jan 31, 2020
@grd349
Copy link
Owner

grd349 commented Jul 1, 2020

Related but different to #225 - we should fix both at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants