Lv2_phase.py
def pulse_folding(t,T,T0,f,fdot,fdotdot,no_phase_bins,mission):
    """
    Calculating the pulse profile by also incorporating \dot{f} corrections!
    Goes from 0 to 2.

    t - array of time values
    T - sum of all the GTIs
    T0 - reference epoch in MJD
    f - pulse/folding Frequency
    fdot - frequency derivative
    fdotdot - second derivative of frequency
    no_phase_bins - number of phase bins desired (recommended 20!)
    mission - "NICER", "XMM", or "SWIFT" for now

    Returns the pulse profile in counts/s/phase bin vs phase. The number of counts
    is divided by the exposure time (calculated through total sum of the GTIs)

    Also added a "TIMEZERO" manually in the script since it'd be inconvenient to call the eventfile here.
    """
    if mission == "NICER":
        ##### NICER
        MJDREFI = 56658.0
        MJDREFF = 0.000777592592592593
        TIMEZERO = -1
        t_MJDs =  MJDREFI + MJDREFF + (TIMEZERO+t)/86400 #Swift or NICER

    if mission == "SWIFT":
        ##### SWIFT
        MJDREFI = 51910.0
        MJDREFF = 7.428703700000000E-04
        TIMEZERO = 0
        t_MJDs =  MJDREFI + MJDREFF + (TIMEZERO+t)/86400 #Swift or NICER

    if mission == "XMM":
        ##### XMM-NEWTON
        MJDREF = 50814.0
        t_MJDs = MJDREF + t/86400.0

    tau = (t_MJDs-T0)*86400.0
    #print(tau[:10])
    #print(f*tau[:10])
    phase = (f*tau + fdot/2 *tau**2 + fdotdot/6*tau**3)%1
    #print(phase[:10])

    counts = np.ones(len(phase))
    phase_bins = np.linspace(0,1,no_phase_bins+1)

    summed_profile,bin_edges,binnumber = stats.binned_statistic(phase,counts,statistic='sum',bins=phase_bins)

    phase_bins_total = np.array(list(phase_bins[:-1]) + list(phase_bins+1))
    summed_profile_total = np.array(list(summed_profile)*2)
    error = np.sqrt(summed_profile_total)

    return phase_bins_total, summed_profile_total/T, error/T

    Calculating the pulse profile by also incorporating \dot{f} corrections!
    Goes from 0 to 2.

    t - array of time values
    T - sum of all the GTIs
    T0 - reference epoch in MJD
    f - pulse/folding Frequency
    fdot - frequency derivative
    fdotdot - second derivative of frequency
    no_phase_bins - number of phase bins desired (recommended 20!)
    mission - "NICER", "XMM", or "SWIFT" for now

    Returns the pulse profile in counts/s/phase bin vs phase. The number of counts
    is divided by the exposure time (calculated through total sum of the GTIs)

    Also added a "TIMEZERO" manually in the script since it'd be inconvenient to call the eventfile here.
    
Calculating the pulse profile by also incorporating \dot{f} corrections.
Goes from 0 to 2.



Returns the pulse profile in counts/s/phase bin vs phase. The number of counts
is divided by the exposure time (calculated through total sum of the GTIs)

Also added a "TIMEZERO" manually in the script since it'd be inconvenient to call the eventfile here.
Calculating the pulse profile by also incorporating \ dot { f } corrections . Goes from 0 to 2 . Returns the pulse profile in counts / s / phase bin vs phase . The number of counts is divided by the exposure time ( calculated through total sum of the GTIs ) Also added a " TIMEZERO " manually in the script since it ' d be inconvenient to call the eventfile here .
def pulse_folding(t,T,T0,f,fdot,fdotdot,no_phase_bins,mission):
    if mission == "NICER":
        MJDREFI = 56658.0
        MJDREFF = 0.000777592592592593
        TIMEZERO = -1
        t_MJDs =  MJDREFI + MJDREFF + (TIMEZERO+t)/86400 
    if mission == "SWIFT":
        MJDREFI = 51910.0
        MJDREFF = 7.428703700000000E-04
        TIMEZERO = 0
        t_MJDs =  MJDREFI + MJDREFF + (TIMEZERO+t)/86400 
    if mission == "XMM":
        MJDREF = 50814.0
        t_MJDs = MJDREF + t/86400.0
    tau = (t_MJDs-T0)*86400.0
    phase = (f*tau + fdot/2 *tau**2 + fdotdot/6*tau**3)%1
    counts = np.ones(len(phase))
    phase_bins = np.linspace(0,1,no_phase_bins+1)
    summed_profile,bin_edges,binnumber = stats.binned_statistic(phase,counts,statistic='sum',bins=phase_bins)
    phase_bins_total = np.array(list(phase_bins[:-1]) + list(phase_bins+1))
    summed_profile_total = np.array(list(summed_profile)*2)
    error = np.sqrt(summed_profile_total)
    return phase_bins_total, summed_profile_total/T, error/T
def pulse_folding ( t , T , T0 , f , fdot , fdotdot , no_phase_bins , mission ) : if mission == "NICER" : MJDREFI = 56658.0 MJDREFF = 0.000777592592592593 TIMEZERO = - 1 t_MJDs = MJDREFI + MJDREFF + ( TIMEZERO + t ) / 86400 if mission == "SWIFT" : MJDREFI = 51910.0 MJDREFF = 7.428703700000000E-04 TIMEZERO = 0 t_MJDs = MJDREFI + MJDREFF + ( TIMEZERO + t ) / 86400 if mission == "XMM" : MJDREF = 50814.0 t_MJDs = MJDREF + t / 86400.0 tau = ( t_MJDs - T0 ) * 86400.0 phase = ( f * tau + fdot / 2 * tau ** 2 + fdotdot / 6 * tau ** 3 ) % 1 counts = np . ones ( len ( phase ) ) phase_bins = np . linspace ( 0 , 1 , no_phase_bins + 1 ) summed_profile , bin_edges , binnumber = stats . binned_statistic ( phase , counts , statistic = 'sum' , bins = phase_bins ) phase_bins_total = np . array ( list ( phase_bins [ : - 1 ] ) + list ( phase_bins + 1 ) ) summed_profile_total = np . array ( list ( summed_profile ) * 2 ) error = np . sqrt ( summed_profile_total ) return phase_bins_total , summed_profile_total / T , error / T
Calculating the pulse profile by also incorporating \dot{f} corrections!
Calculating the pulse profile by also incorporating \ dot { f } corrections!
"""
    Calculating the pulse profile by also incorporating \dot{f} corrections!
    Goes from 0 to 2.

    t - array of time values
    T - sum of all the GTIs
    T0 - reference epoch in MJD
    f - pulse/folding Frequency
    fdot - frequency derivative
    fdotdot - second derivative of frequency
    no_phase_bins - number of phase bins desired (recommended 20!)
    mission - "NICER", "XMM", or "SWIFT" for now

    Returns the pulse profile in counts/s/phase bin vs phase. The number of counts
    is divided by the exposure time (calculated through total sum of the GTIs)

    Also added a "TIMEZERO" manually in the script since it'd be inconvenient to call the eventfile here.
    """ ##### NICER #Swift or NICER ##### SWIFT #Swift or NICER ##### XMM-NEWTON #print(tau[:10]) #print(f*tau[:10]) #print(phase[:10])
t
T
T0
f
fdot
fdotdot
no_phase_bins
mission