Lv2_swift_lc.py
def time_order(eventlist,mjd1,mjd2):
    """
    Takes as input, a list of event files, and outputs a subset of event files,
    which are ordered in time, and are contained within mjd1 and mj2

    eventlist - list of event files
    mjd1 - lower bound on MJD (i.e., earliest)
    mjd2 - upper bound on MJD (i.e., latest)
    """
    if type(eventlist) != np.ndarray and type(eventlist) != list:
        raise TypeError('eventfile should be an array or a list!')

    start_times = [fits.open(eventlist[i])[1].header['TSTART'] for i in range(len(eventlist))]
    time_ordered = np.argsort(start_times)
    ordered_eventlist = np.array(eventlist)[time_ordered]

    if mjd1 != 0 and mjd2 != 0:
        truncated_eventlist = []
        for i in range(len(ordered_eventlist)):
            obs_time = fits.open(ordered_eventlist[i])[1].header['MJD-OBS']
            if obs_time >= mjd1 and obs_time <= mjd2:
                truncated_eventlist.append(ordered_eventlist[i])

        return truncated_eventlist

    else:
        return ordered_eventlist

    Takes as input, a list of event files, and outputs a subset of event files,
    which are ordered in time, and are contained within mjd1 and mj2

    eventlist - list of event files
    mjd1 - lower bound on MJD (i.e., earliest)
    mjd2 - upper bound on MJD (i.e., latest)
    
Takes as input, a list of event files, and outputs a subset of event files,
which are ordered in time, and are contained within mjd1 and mj2

list of event files
mjd1 - lower bound on MJD
mjd2 - upper bound on MJD
Takes as input a list of event files and outputs a subset of event files which are ordered in time and are contained within mjd1 and mj2 list of event files mjd1 - lower bound on MJD mjd2 - upper bound on MJD
def time_order(eventlist,mjd1,mjd2):
    if type(eventlist) != np.ndarray and type(eventlist) != list:
        raise TypeError('eventfile should be an array or a list!')
    start_times = [fits.open(eventlist[i])[1].header['TSTART'] for i in range(len(eventlist))]
    time_ordered = np.argsort(start_times)
    ordered_eventlist = np.array(eventlist)[time_ordered]
    if mjd1 != 0 and mjd2 != 0:
        truncated_eventlist = []
        for i in range(len(ordered_eventlist)):
            obs_time = fits.open(ordered_eventlist[i])[1].header['MJD-OBS']
            if obs_time >= mjd1 and obs_time <= mjd2:
                truncated_eventlist.append(ordered_eventlist[i])
        return truncated_eventlist
    else:
        return ordered_eventlist
def time_order ( eventlist , mjd1 , mjd2 ) : if type ( eventlist ) != np . ndarray and type ( eventlist ) != list : raise TypeError ( 'eventfile should be an array or a list!' ) start_times = [ fits . open ( eventlist [ i ] ) [ 1 ] . header [ 'TSTART' ] for i in range ( len ( eventlist ) ) ] time_ordered = np . argsort ( start_times ) ordered_eventlist = np . array ( eventlist ) [ time_ordered ] if mjd1 != 0 and mjd2 != 0 : truncated_eventlist = [ ] for i in range ( len ( ordered_eventlist ) ) : obs_time = fits . open ( ordered_eventlist [ i ] ) [ 1 ] . header [ 'MJD-OBS' ] if obs_time >= mjd1 and obs_time <= mjd2 : truncated_eventlist . append ( ordered_eventlist [ i ] ) return truncated_eventlist else : return ordered_eventlist
Takes as input, a list of event files, and outputs a subset of event files,
which are ordered in time, and are contained within mjd1 and mj2
Takes as input a list of event files and outputs a subset of event files which are ordered in time and are contained within mjd1 and mj2
"""
    Takes as input, a list of event files, and outputs a subset of event files,
    which are ordered in time, and are contained within mjd1 and mj2

    eventlist - list of event files
    mjd1 - lower bound on MJD (i.e., earliest)
    mjd2 - upper bound on MJD (i.e., latest)
    """
eventlist
mjd1
mjd2