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

Enhance TargetPixelFile.interact() to let user access the selected pixels mask directly in Jupyter notebooks #1386

Open
orionlee opened this issue Nov 11, 2023 · 0 comments · May be fixed by #1402

Comments

@orionlee
Copy link
Collaborator

orionlee commented Nov 11, 2023

Problem description

Currently, when an user selects custom pixels via tpf.interact(), the user cannot use the selected pixels (as an aperture mask) in subsequent work outside of interact()

The user can only indirectly access it by exporting the lightcurve and read it back.

Proposal: make tpf.interact() to optionally return the the selected pixels as an aperture mask, if users specify a new return_selection_mask parameter.

Example

# return_selection_mask is the new parameter
interact_mask = tpf.interact(return_selection_mask=True);

Here an user selects custom pixels to highlight a background spike due to SSO.
image

Users can then access the mask in subsequent cells in the notebook, creating a lightcurve, highlight the pixels in plot(), interact_sky(), plot_pixels(), etc.

# make a copy of the selection to avoid accidental pixel selection changes in the interact.
sso_mask = interact_mask.copy()
...

lc_sso = tpf.to_lightcurve(aperture_mask=sso_mask)
lc_sso.scatter();

tpf.plot_pixels(aperture_mask=sso_mask)

The returned result is a dict that contains the selected pixels mask in the key selection_mask .
It is a dict so as to accommodate possible future additions, e.g., returning x / y limits, etc.
(Update: return the mask array directly upon feedback.)

Environment

  • lightkurve version (e.g. 1.0b6): v2.4.2
@orionlee orionlee changed the title Enhance TargetPixelFile.interact() to return the selected pixels programmaticaly Enhance TargetPixelFile.interact() to let user access the selected pixels mask directly in Jupyter notebooks Nov 11, 2023
@orionlee orionlee linked a pull request Jan 30, 2024 that will close this issue
4 tasks
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 a pull request may close this issue.

1 participant