Giter VIP home page Giter VIP logo

Comments (2)

orionlee avatar orionlee commented on August 25, 2024

The problem is similar to #1422 . While the specific code paths are different, the nature of underlying issue is the same: implementation assumes lc.time is Time / TimeDelta, but for normalized FoldedLightCurve, lc.time is Quantity with unit u.dimensionless_unscaled (conceptually floats).

from lightkurve.

Nschanche avatar Nschanche commented on August 25, 2024

I've been looking into this, and it's a bit tricky as the astropy functions require 'time' to be Time or TimeDelta objects. One possible workaround is to re-define all of the functions that fail in the FoldedLightCurve object so that if they have been normalized, the are temporarily reverted back to the regular phase, the operation is performed, and then time is reassigned to the normalized value again at the end. For example:

class FoldedLightCurve(LightCurve):
        def bin(
        self,
        time_bin_size=None,
        time_bin_start=None,
        time_bin_end=None,
        n_bins=None,
        aggregate_func=None,
        bins=None,
        binsize=None,
    ):
        if (hasattr(self, 'normalize_phase')) & (self.normalize_phase == True):
            with self._delay_required_column_checks():
                normalized_phase = self.time.copy()
                phase = TimeDelta(normalized_phase * self.period)
                self.remove_column("time")
                self.add_column(phase, name="time", index=0)


        *Regular bin operation from LightCurve*


        # Reset at the end of the function
        if (hasattr(self, 'normalize_phase')) & (self.normalize_phase == True):
            
            # Reset the 'time' column of the folded object to be the normalized value
            with self._delay_required_column_checks():
                phase = self.time.copy()
                normalized_phase = phase / self.period
                self.remove_column("time")
                self.add_column(normalized_phase, name="time", index=0)
                self.sort("time")

            # Reset the 'time' column of the folded and binned object to be the normalized value
            with returned_object._delay_required_column_checks():
                phase = returned_object.time.copy()
                normalized_phase = phase / self.period #returned_object.normalized_phase.copy()
                returned_object.remove_column("time")
                returned_object.add_column(normalized_phase, name="time", index=0)
                returned_object.sort("time")

It's an ugly solution, but it works. I'd be happy to develop other suggestions, as this requires over-writing all of the broken functions in FoldedLightCurve.

from lightkurve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.