How to use the stingray.lightcurve.Lightcurve function in stingray

To help you get started, we’ve selected a few stingray examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github StingraySoftware / dave / src / main / python / utils / dave_reader.py View on Github external
"""Save Stingray object to intermediate file."""

    from stingray.lightcurve import Lightcurve
    from stingray.events import EventList
    from stingray.crossspectrum import Crossspectrum
    from hendrics.io import get_file_type
    from stingray.io import _retrieve_pickle_object

    # This will return an EventList, a light curve, a Powerspectrum, ...
    # depending on the contents of the file
    try:
        ftype, contents = get_file_type(fname)
    except:
        contents = _retrieve_pickle_object(fname)

    if isinstance(contents, Lightcurve):
        return DataSet.get_lightcurve_dataset_from_stingray_Lightcurve(contents)

    elif isinstance(contents, EventList):
        return DataSet.get_eventlist_dataset_from_stingray_Eventlist(contents)

    # This also work for Powerspectrum and AveragedCrosspowerspectrum, clearly
    elif isinstance(contents, Crossspectrum):
        logging.error("Unsupported intermediate file type: Crossspectrum")

    else:
        logging.error("Unsupported intermediate file type: %s" % type(stingray_object).__name__)

    return None
github StingraySoftware / dave / src / main / python / utils / dave_engine.py View on Github external
if bck_ds:

                    #Gets the backscale keyword value
                    table = DsHelper.get_hdutable_from_dataset(bck_ds)
                    if table:
                        if "BACKSCAL" in table.header:
                            backscale_ratio = src_backscale / int(table.header["BACKSCAL"])
                    bck_ds = None
                    table = None

            if backscale_ratio != 1:
                # Applies the backscale_ratio to background lightcurve
                logging.debug("Applying backscale_ratio: " + str(backscale_ratio))
                bck_lc.counts *= backscale_ratio
                bck_lc.counts_err *= backscale_ratio
                bck_lc = Lightcurve(bck_lc.time, bck_lc.counts,
                                    err=bck_lc.counts_err, gti=bck_lc.gti,
                                    mjdref=bck_lc.mjdref)

            #Substracts background lightcurve from source lightcurve
            lc = lc - bck_lc
            bck_lc = None

        else:
            logging.warn("Wrong lightcurve for background data...")

    else:
        logging.warn("Wrong source lightcurve.")

    return lc