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

Better default TPF stretch #117

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Conversation

bmorris3
Copy link
Contributor

This PR gives a better default colormap stretch on TPF files. It sets vmin/vmax to the 5/99 percentile limits from the cube:

from lightkurve import search_targetpixelfile, search_lightcurve
from lcviz import LCviz

target = 'TRAPPIST-1'
lc = search_lightcurve(target, mission="K2", cadence="long").download().normalize()
tpf = search_targetpixelfile(target, mission="K2", cadence="long").download()

# Load the light curve into LCviz:
lcviz = LCviz()
lcviz.load_data(lc)
lcviz.load_data(tpf)
lcviz.show()

viewer = lcviz.app.get_viewer('flux-vs-time')
viewer.state.y_min = 0.9
viewer.state.y_max = 1.2
Screen Shot 2024-04-26 at 12 45 46

I opted to put this stretch as a private method in PlotOptions, and call the method from the parser when a TPF is loaded. That keeps the diff small. Caveats: this approach won't work if we load more than one TPF into the image viewer.

Copy link

codecov bot commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.89%. Comparing base (7b78df5) to head (df51b0d).
Report is 18 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #117      +/-   ##
==========================================
- Coverage   93.92%   91.89%   -2.04%     
==========================================
  Files          37       41       +4     
  Lines        1598     2012     +414     
==========================================
+ Hits         1501     1849     +348     
- Misses         97      163      +66     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to put this stretch as a private method in PlotOptions, and call the method from the parser when a TPF is loaded. That keeps the diff small. Caveats: this approach won't work if we load more than one TPF into the image viewer.

What if we listened to adding new data or layers (either here or in the helper... but I would prefer in the plugin I think to keep the code in one place)?

lcviz/plugins/plot_options/plot_options.py Show resolved Hide resolved
@bmorris3 bmorris3 modified the milestones: 0.3.1, 0.4.0 Apr 26, 2024
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

@bmorris3 bmorris3 merged commit e5aadd8 into spacetelescope:main Apr 26, 2024
11 of 13 checks passed
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

Successfully merging this pull request may close these issues.

2 participants