Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions mind_the_gaps/lightcurves/fermilightcurve.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# @Author: Andrés Gúrpide <agurpide>
# @Date: 05-02-2022
# @Email: agurpidelash@irap.omp.eu
# @Email: agl1f22@soton.ac.uk
# @Last modified by: agurpide
# @Last modified time: 28-02-2022
# @Last modified time: 08-01-2026
import numpy as np
import astropy.units as u
from mind_the_gaps.lightcurves.gappylightcurve import GappyLightcurve
Expand All @@ -12,33 +12,32 @@ class FermiLightcurve(GappyLightcurve):
"""
A class to create a GappyLightcurve based on a csv file containing only times, rates and errors.
"""

def __init__(self, input_file):
"""

Parameters
----------
input_file:str,
Path to a csv file containing time, rates and errors
skip_header: int
How many rows to skip
"""
time, y, yerr = self.readdata(input_file)

super().__init__(time.to(u.s).value, y, yerr)


def readdata(self, input_file):

data = np.genfromtxt("%s" % input_file, names=True, delimiter=",")
time_column = data.dtype.names[0]
rate_column = data.dtype.names[1]


if "MJD" in data:
if "MJD" in time_column.upper():
time = data[time_column] << u.d
else:
time = data[time_column] << u.s

y = data[rate_column]
yerr = (np.abs(data["%s_err_neg" % rate_column]) + data["%s_err_pos" % rate_column]) / 2
yerr = (
np.abs(data["%s_err_neg" % rate_column]) + data["%s_err_pos" % rate_column]
) / 2
return time, y, yerr