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

New feature request with pull request coming: lc.remove_data(start=start,end=end,col='str') #1353

Closed
mwood7 opened this issue Aug 5, 2023 · 3 comments
Labels
➕ enhancement New feature or request

Comments

@mwood7
Copy link

mwood7 commented Aug 5, 2023

Problem description

For my work it is useful to remove small sections of data. E.g., just before the mid-sector gap the star is in eclipse ingress, but hasn't reached eclipse midpoint. In this case it is better to simply remove those ingress points.

So I'm wanting functionality that is similar to the 'truncate' method, but able to remove data points by time within a light curve object.

I've followed the developer instructions and have tested the code below (inserted just after 'truncate'), and it appears to work. Of course the core developers may want to change the name, argument names, etc.

I did think it should be required that both 'start' and 'end' be passed, and I think this does that.

Example

def remove_data(self, start: float = None, end: float = None, column: str = "time"):
    """remove eata from the light curve between two values.

    Parameters
    ----------
    start : float
        Clip all rows between start and end
    end: float
        Clip all rows between start and end
    column : str, optional
        The name of the column on which the clipping is based. Defaults to 'time'.

    Returns
    -------
    clipped_lc : LightCurve
        The clipped light curve.
    """
    def _to_unitless(data):
        return np.asarray(getattr(data, "value", data))

    mask = np.ones(len(self), dtype=bool)

    if end and start:
        mask &= (_to_unitless(getattr(self, column)) >= end) | (_to_unitless(getattr(self, column)) <= start)
    return self[mask]

Expected behavior

N/A

Environment

MacOS
LK 2.4.0

  • platform (e.g. Linux, OSX, Windows):
  • lightkurve version (e.g. 1.0b6):
  • installation method (e.g. pip, conda, source):
@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Hi there! 👋 Thank you for opening your first Lightkurve issue! 🙏 One of our maintainers will get back to you as soon as possible. 👩‍🚀 You can expect a response within 7 days. 📅 If you haven’t heard anything by then, feel free to ping this thread. 🛎️ We love that you are using Lightkurve and appreciate your feedback. 👍

@rebekah9969 rebekah9969 added the ➕ enhancement New feature or request label Aug 7, 2023
@rebekah9969
Copy link
Collaborator

Dear @astromattwood,

Thank you very much for posting this issue.
While your code is indeed useful, there are already ways to create boolean masks to block out specific time series data using python and lightkurve e.g.,

lc_n = lc[(lc.time.value < start) | (lc.time.value > end)]

There are also specific ways to mask out data which might contain transits or other phenomena as shown here (https://docs.lightkurve.org/tutorials/3-science-examples/exoplanets-identifying-transiting-planet-signals.html)
As such adding in this function, while useful, would be an unnecessary step and might not represent all functionality that a user may desire.

We however sincerely think you for your interest and will keep this in mind if we ever do move in this direction.

We will close this issue now, but please feel free to post again to open it back up.

@mwood7
Copy link
Author

mwood7 commented Aug 9, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
➕ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants