Lv3_orbitephem_visual.py
def folding(eventfile,Porb,nbins):
    """
    Folding the events by some orbital period
    """
    times = fits.open(eventfile)[1].data['TIME'] #getting array of times
    gtis_data = fits.open(eventfile)[2].data #getting GTIs
    T = sum([ gtis_data[i]['STOP']-gtis_data[i]['START'] for i in range(len(gtis_data)) ]) #exposure time

    gtis_conform = []
    for i in range(len(gtis_data)):
        gtis_conform.append([gtis_data[i][0],gtis_data[i][1]]) #conform to the input that Stingray uses

    phase_sr,prof_sr,err_sr = fold_events(times,1/Porb,gtis=np.array(gtis_conform),ref_time=times[0],nbin=nbins)
    phase_sr_expo,prof_sr_expo,err_sr_expo = fold_events(times,1/Porb,gtis=np.array(gtis_conform),ref_time=times[0],expocorr=True,nbin=nbins)

    total_phase_sr = list(phase_sr) + list(phase_sr+1)
    total_prof_sr = list(prof_sr)*2
    total_err_sr = list(err_sr)*2

    total_phase_sr_expo = list(phase_sr_expo) + list(phase_sr_expo+1)
    total_prof_sr_expo = list(prof_sr_expo)*2
    total_err_sr_expo = list(err_sr_expo)*2

    plt.figure()
    plt.errorbar(x=total_phase_sr,y=total_prof_sr/T,yerr=total_err_sr/T,color='r',drawstyle='steps-mid')
    plt.errorbar(x=total_phase_sr_expo,y=total_prof_sr_expo/T,yerr=total_err_sr_expo/T,color='b',drawstyle='steps-mid')
    plt.legend(('Folded profile','Exposure-corrected'),loc='best',fontsize=12)
    plt.title(str(pathlib.Path(eventfile).name) +', exposure-corrected (using Stingray fold_events)',fontsize=12)
    plt.xlabel('Phase',fontsize=12)
    plt.ylabel('Counts/s',fontsize=12)

    return total_phase_sr_expo,total_prof_sr_expo/T,total_err_sr_expo/T

    Folding the events by some orbital period
    
Folding the events by some orbital period
Folding the events by some orbital period
def folding(eventfile,Porb,nbins):
    times = fits.open(eventfile)[1].data['TIME'] 
    gtis_data = fits.open(eventfile)[2].data 
    T = sum([ gtis_data[i]['STOP']-gtis_data[i]['START'] for i in range(len(gtis_data)) ]) 
    gtis_conform = []
    for i in range(len(gtis_data)):
        gtis_conform.append([gtis_data[i][0],gtis_data[i][1]]) 
    phase_sr,prof_sr,err_sr = fold_events(times,1/Porb,gtis=np.array(gtis_conform),ref_time=times[0],nbin=nbins)
    phase_sr_expo,prof_sr_expo,err_sr_expo = fold_events(times,1/Porb,gtis=np.array(gtis_conform),ref_time=times[0],expocorr=True,nbin=nbins)
    total_phase_sr = list(phase_sr) + list(phase_sr+1)
    total_prof_sr = list(prof_sr)*2
    total_err_sr = list(err_sr)*2
    total_phase_sr_expo = list(phase_sr_expo) + list(phase_sr_expo+1)
    total_prof_sr_expo = list(prof_sr_expo)*2
    total_err_sr_expo = list(err_sr_expo)*2
    plt.figure()
    plt.errorbar(x=total_phase_sr,y=total_prof_sr/T,yerr=total_err_sr/T,color='r',drawstyle='steps-mid')
    plt.errorbar(x=total_phase_sr_expo,y=total_prof_sr_expo/T,yerr=total_err_sr_expo/T,color='b',drawstyle='steps-mid')
    plt.legend(('Folded profile','Exposure-corrected'),loc='best',fontsize=12)
    plt.title(str(pathlib.Path(eventfile).name) +', exposure-corrected (using Stingray fold_events)',fontsize=12)
    plt.xlabel('Phase',fontsize=12)
    plt.ylabel('Counts/s',fontsize=12)
    return total_phase_sr_expo,total_prof_sr_expo/T,total_err_sr_expo/T
def folding ( eventfile , Porb , nbins ) : times = fits . open ( eventfile ) [ 1 ] . data [ 'TIME' ] gtis_data = fits . open ( eventfile ) [ 2 ] . data T = sum ( [ gtis_data [ i ] [ 'STOP' ] - gtis_data [ i ] [ 'START' ] for i in range ( len ( gtis_data ) ) ] ) gtis_conform = [ ] for i in range ( len ( gtis_data ) ) : gtis_conform . append ( [ gtis_data [ i ] [ 0 ] , gtis_data [ i ] [ 1 ] ] ) phase_sr , prof_sr , err_sr = fold_events ( times , 1 / Porb , gtis = np . array ( gtis_conform ) , ref_time = times [ 0 ] , nbin = nbins ) phase_sr_expo , prof_sr_expo , err_sr_expo = fold_events ( times , 1 / Porb , gtis = np . array ( gtis_conform ) , ref_time = times [ 0 ] , expocorr = True , nbin = nbins ) total_phase_sr = list ( phase_sr ) + list ( phase_sr + 1 ) total_prof_sr = list ( prof_sr ) * 2 total_err_sr = list ( err_sr ) * 2 total_phase_sr_expo = list ( phase_sr_expo ) + list ( phase_sr_expo + 1 ) total_prof_sr_expo = list ( prof_sr_expo ) * 2 total_err_sr_expo = list ( err_sr_expo ) * 2 plt . figure ( ) plt . errorbar ( x = total_phase_sr , y = total_prof_sr / T , yerr = total_err_sr / T , color = 'r' , drawstyle = 'steps-mid' ) plt . errorbar ( x = total_phase_sr_expo , y = total_prof_sr_expo / T , yerr = total_err_sr_expo / T , color = 'b' , drawstyle = 'steps-mid' ) plt . legend ( ( 'Folded profile' , 'Exposure-corrected' ) , loc = 'best' , fontsize = 12 ) plt . title ( str ( pathlib . Path ( eventfile ) . name ) + ', exposure-corrected (using Stingray fold_events)' , fontsize = 12 ) plt . xlabel ( 'Phase' , fontsize = 12 ) plt . ylabel ( 'Counts/s' , fontsize = 12 ) return total_phase_sr_expo , total_prof_sr_expo / T , total_err_sr_expo / T
Folding the events by some orbital period
Folding the events by some orbital period
"""
    Folding the events by some orbital period
    """ #getting array of times #getting GTIs #exposure time #conform to the input that Stingray uses
eventfile
Porb
nbins