How to use the hendrics.lcurve.lcurve_from_fits function in hendrics

To help you get started, we’ve selected a few hendrics 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
logging.warn("RATE, RATE1 or COUNTS ambiguous columns found in " + str(hduname) + " HDU, found columns: " + str(hdulist[hduname].data.names))
        return None

    ratecolumn = list(intersection_columns)[0]
    if len(hdulist[hduname].data[ratecolumn].shape) != 1 \
        or not (isinstance(hdulist[hduname].data[ratecolumn][0], int) \
        or isinstance(hdulist[hduname].data[ratecolumn][0], np.integer) \
        or isinstance(hdulist[hduname].data[ratecolumn][0], float) \
        or isinstance(hdulist[hduname].data[ratecolumn][0], np.floating)):
        logging.warn("Wrong data type found for column: " + str(ratecolumn) + " in " + str(hduname) + " HDU, expected Integer or Float.")
        return None

    header, header_comments = get_header(hdulist, hduname)

    # Reads the lightcurve with HENDRICS
    outfile = lcurve_from_fits(destination, gtistring=get_hdu_string_from_hdulist(gtistring, hdulist),
                             timecolumn=column, ratecolumn=ratecolumn, ratehdu=1,
                             fracexp_limit=CONFIG.FRACEXP_LIMIT)[0]

    lcurve, events_start_time = substract_tstart_from_lcurve(load_data(outfile), time_offset)

    dataset = DataSet.get_lightcurve_dataset_from_stingray_lcurve(lcurve, header, header_comments,
                                                                    hduname, column)

    # Stores the events_start_time in time column extra
    dataset.tables[hduname].columns[column].set_extra("TSTART", events_start_time)

    logging.debug("Read Lightcurve fits with stingray file successfully: " + str(destination) + ", tstart: " + str(events_start_time) + ", rate: " + str(len(lcurve["counts"])))

    return dataset
github StingraySoftware / dave / src / main / python / utils / dave_reader.py View on Github external
# Opening Fits
        hdulist = fits.open(destination, memmap=True)

        if 'EVENTS' in hdulist:
            # If EVENTS extension found, consider the Fits as EVENTS Fits
            fits_data = load_events_and_gtis(destination,
                                             additional_columns=['PI', "PHA"],
                                             gtistring=CONFIG.GTI_STRING,
                                             hduname='EVENTS', column=CONFIG.TIME_COLUMN)
            return substract_tstart_from_events(fits_data, time_offset)

        elif 'RATE' in hdulist:
            # If RATE extension found, consider the Fits as LIGHTCURVE Fits
            # Reads the lightcurve with hendrics
            outfile = lcurve_from_fits(destination, gtistring=get_hdu_string_from_hdulist(CONFIG.GTI_STRING, hdulist),
                                     timecolumn=CONFIG.TIME_COLUMN, ratecolumn=None, ratehdu=1,
                                     fracexp_limit=CONFIG.FRACEXP_LIMIT)[0]
            return substract_tstart_from_lcurve(load_lcurve(outfile), time_offset)

        else:
            logging.error("Unsupported FITS type!")

    else:
        logging.error("Unknown file extension: %s" % file_extension)
        return None

hendrics

High ENergy Data Reduction Interface from the Command Shell

BSD-2-Clause
Latest version published 20 days ago

Package Health Score

69 / 100
Full package analysis