Lv2_merged_pulse_methods.py
def pulse_profile(merging,data_id,E_trunc,PI1,PI2,pulse_pars,no_phase_bins):
    """
    Extracts the time series from the demodulated merged event file, and creates
    the pulse profile from Lv2_phase.py!

    merging - True/False - whether to use merged data
    data_id - 10-digit ObsID or 6-digit ID for the merged event file
    E_trunc - True/False - whether to do energy truncation
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    pulse_pars - parameters corresponding to the pulse
    no_phase_bins - number of phase bins desired
    """
    if type(data_id) != str:
        raise TypeError("data_id should be a string!")
    if len(data_id) != 6 and len(data_id) != 10:
        raise ValueError("data_id should have 6 or 10 digits in the string!")
    if E_trunc != True and E_trunc != False:
        raise ValueError("E_trunc (energy truncation) should either be True or False!")
    if type(pulse_pars) != list and type(pulse_pars) != np.ndarray:
        raise TypeError("pulse_pars should either be a list or an array!")

    if merging == True:
        print("Making pulse profile, merging is True!")
        all_merged_dir = Lv0_dirs.NICERSOFT_DATADIR + 'merged_events/' #directory for the merged events
        merged_dir = all_merged_dir + 'merged' + data_id + '/'
        if E_trunc == True:
            demod_merged_file = merged_dir + 'merged' + data_id + '_nicersoft_bary_E' + str(PI1).zfill(4) + '-' + str(PI2).zfill(4) + '_demod.evt'
        else:
            demod_merged_file = merged_dir + 'merged' + data_id + '_nicersoft_bary_demod.evt'

    else:
        print("Making pulse profile, merging is False!")
        if E_trunc == True:
            demod_merged_file = Lv0_dirs.NICERSOFT_DATADIR + data_id + '_pipe/ni' + data_id + '_nicersoft_bary_E' + str(PI1).zfill(4) + '-' + str(PI2).zfill(4) + '_demod.evt'
        else:
            demod_merged_file = Lv0_dirs.NICERSOFT_DATADIR + data_id + '_pipe/ni' + data_id + '_nicersoft_bary_demod.evt'

    #demod_merged_file = demod_merged_file[:-10] + '.evt'
    print('Will be using ' + str(demod_merged_file))
    event = fits.open(demod_merged_file)
    times = event[1].data['TIME']

    gtis = event[2].data
    T = sum([ (gtis[i][1]-gtis[i][0]) for i in range(len(gtis)) ])
    print('Will be using ' + str(T/1000) + 'ks worth of data!')

    phase_bins,summed_profile = Lv2_phase.pulse_folding(times,T,times[0],pulse_pars[0],pulse_pars[1],pulse_pars[2],no_phase_bins)

    return phase_bins,summed_profile

    Extracts the time series from the demodulated merged event file, and creates
    the pulse profile from Lv2_phase.py!

    merging - True/False - whether to use merged data
    data_id - 10-digit ObsID or 6-digit ID for the merged event file
    E_trunc - True/False - whether to do energy truncation
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    pulse_pars - parameters corresponding to the pulse
    no_phase_bins - number of phase bins desired
    
Extracts the time series from the demodulated merged event file, and creates
the pulse profile from Lv2_phase.py!


Extracts the time series from the demodulated merged event file and creates the pulse profile from Lv2_phase . py!
def pulse_profile(merging,data_id,E_trunc,PI1,PI2,pulse_pars,no_phase_bins):
    if type(data_id) != str:
        raise TypeError("data_id should be a string!")
    if len(data_id) != 6 and len(data_id) != 10:
        raise ValueError("data_id should have 6 or 10 digits in the string!")
    if E_trunc != True and E_trunc != False:
        raise ValueError("E_trunc (energy truncation) should either be True or False!")
    if type(pulse_pars) != list and type(pulse_pars) != np.ndarray:
        raise TypeError("pulse_pars should either be a list or an array!")
    if merging == True:
        print("Making pulse profile, merging is True!")
        all_merged_dir = Lv0_dirs.NICERSOFT_DATADIR + 'merged_events/' 
        merged_dir = all_merged_dir + 'merged' + data_id + '/'
        if E_trunc == True:
            demod_merged_file = merged_dir + 'merged' + data_id + '_nicersoft_bary_E' + str(PI1).zfill(4) + '-' + str(PI2).zfill(4) + '_demod.evt'
        else:
            demod_merged_file = merged_dir + 'merged' + data_id + '_nicersoft_bary_demod.evt'
    else:
        print("Making pulse profile, merging is False!")
        if E_trunc == True:
            demod_merged_file = Lv0_dirs.NICERSOFT_DATADIR + data_id + '_pipe/ni' + data_id + '_nicersoft_bary_E' + str(PI1).zfill(4) + '-' + str(PI2).zfill(4) + '_demod.evt'
        else:
            demod_merged_file = Lv0_dirs.NICERSOFT_DATADIR + data_id + '_pipe/ni' + data_id + '_nicersoft_bary_demod.evt'
    print('Will be using ' + str(demod_merged_file))
    event = fits.open(demod_merged_file)
    times = event[1].data['TIME']
    gtis = event[2].data
    T = sum([ (gtis[i][1]-gtis[i][0]) for i in range(len(gtis)) ])
    print('Will be using ' + str(T/1000) + 'ks worth of data!')
    phase_bins,summed_profile = Lv2_phase.pulse_folding(times,T,times[0],pulse_pars[0],pulse_pars[1],pulse_pars[2],no_phase_bins)
    return phase_bins,summed_profile
def pulse_profile ( merging , data_id , E_trunc , PI1 , PI2 , pulse_pars , no_phase_bins ) : if type ( data_id ) != str : raise TypeError ( "data_id should be a string!" ) if len ( data_id ) != 6 and len ( data_id ) != 10 : raise ValueError ( "data_id should have 6 or 10 digits in the string!" ) if E_trunc != True and E_trunc != False : raise ValueError ( "E_trunc (energy truncation) should either be True or False!" ) if type ( pulse_pars ) != list and type ( pulse_pars ) != np . ndarray : raise TypeError ( "pulse_pars should either be a list or an array!" ) if merging == True : print ( "Making pulse profile, merging is True!" ) all_merged_dir = Lv0_dirs . NICERSOFT_DATADIR + 'merged_events/' merged_dir = all_merged_dir + 'merged' + data_id + '/' if E_trunc == True : demod_merged_file = merged_dir + 'merged' + data_id + '_nicersoft_bary_E' + str ( PI1 ) . zfill ( 4 ) + '-' + str ( PI2 ) . zfill ( 4 ) + '_demod.evt' else : demod_merged_file = merged_dir + 'merged' + data_id + '_nicersoft_bary_demod.evt' else : print ( "Making pulse profile, merging is False!" ) if E_trunc == True : demod_merged_file = Lv0_dirs . NICERSOFT_DATADIR + data_id + '_pipe/ni' + data_id + '_nicersoft_bary_E' + str ( PI1 ) . zfill ( 4 ) + '-' + str ( PI2 ) . zfill ( 4 ) + '_demod.evt' else : demod_merged_file = Lv0_dirs . NICERSOFT_DATADIR + data_id + '_pipe/ni' + data_id + '_nicersoft_bary_demod.evt' print ( 'Will be using ' + str ( demod_merged_file ) ) event = fits . open ( demod_merged_file ) times = event [ 1 ] . data [ 'TIME' ] gtis = event [ 2 ] . data T = sum ( [ ( gtis [ i ] [ 1 ] - gtis [ i ] [ 0 ] ) for i in range ( len ( gtis ) ) ] ) print ( 'Will be using ' + str ( T / 1000 ) + 'ks worth of data!' ) phase_bins , summed_profile = Lv2_phase . pulse_folding ( times , T , times [ 0 ] , pulse_pars [ 0 ] , pulse_pars [ 1 ] , pulse_pars [ 2 ] , no_phase_bins ) return phase_bins , summed_profile
Extracts the time series from the demodulated merged event file, and creates
the pulse profile from Lv2_phase.py!
Extracts the time series from the demodulated merged event file and creates the pulse profile from Lv2_phase . py!
"""
    Extracts the time series from the demodulated merged event file, and creates
    the pulse profile from Lv2_phase.py!

    merging - True/False - whether to use merged data
    data_id - 10-digit ObsID or 6-digit ID for the merged event file
    E_trunc - True/False - whether to do energy truncation
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    pulse_pars - parameters corresponding to the pulse
    no_phase_bins - number of phase bins desired
    """ #directory for the merged events #demod_merged_file = demod_merged_file[:-10] + '.evt'
merging
data_id
E_trunc
PI1
PI2
pulse_pars
no_phase_bins