Lv2_presto_subroutines.py
def realfft(eventfile,segment_length,mode):
    """
    Performing PRESTO's realfft on the binned data (.dat)
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    segment_length - length of the individual segments
    mode - "all", "t", "gtis", or "E" ; basically to tell the function where to access files to run realfft for
    """
    parent_folder = str(pathlib.Path(eventfile).parent)

    if mode == "all":
        dat_files = sorted(glob.glob(parent_folder+'/*.dat'))
        logfile = parent_folder + '/realfft_all.log'
    elif mode == "t":
        dat_files = sorted(glob.glob(parent_folder+'/accelsearch_'+str(segment_length)+'s/*.dat'))
        logfile = parent_folder + '/accelsearch_' + str(segment_length) + 's/realfft_t.log'
    elif mode == "E":
        dat_files = sorted(glob.glob(parent_folder+'/accelsearch_E/*.dat'))
        logfile = parent_folder + '/accelsearch_E/realfft_E.log'
    elif mode == "gtis":
        dat_files = sorted(glob.glob(parent_folder+'/accelsearch_GTIs/*.dat'))
        logfile = parent_folder + '/accelsearch_GTIs/realfft_gtis.log'
    else:
        raise ValueError("mode should either of 'all', 't', 'gtis', or 'E'!")

    print("Running realfft now:")
    with open(logfile,'w') as logtextfile:
        for i in tqdm(range(len(dat_files))):
            if os.path.exists(dat_files[i][:-3] + 'fft')==False:
                output = subprocess.run(['realfft',dat_files[i]],capture_output=True,text=True)
                logtextfile.write(output.stdout)
                logtextfile.write('*------------------------------* \n')
                logtextfile.write(output.stderr)
        logtextfile.close()

    return

    Performing PRESTO's realfft on the binned data (.dat)
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    segment_length - length of the individual segments
    mode - "all", "t", "gtis", or "E" ; basically to tell the function where to access files to run realfft for
    
Performing PRESTO's realfft on the binned data (.dat)
eventfile - path to the event file. Will extract ObsID from this for the NICER files.
Performing PRESTO ' s realfft on the binned data ( . dat ) eventfile - path to the event file . Will extract ObsID from this for the NICER files .
def realfft(eventfile,segment_length,mode):
    parent_folder = str(pathlib.Path(eventfile).parent)
    if mode == "all":
        dat_files = sorted(glob.glob(parent_folder+'/*.dat'))
        logfile = parent_folder + '/realfft_all.log'
    elif mode == "t":
        dat_files = sorted(glob.glob(parent_folder+'/accelsearch_'+str(segment_length)+'s/*.dat'))
        logfile = parent_folder + '/accelsearch_' + str(segment_length) + 's/realfft_t.log'
    elif mode == "E":
        dat_files = sorted(glob.glob(parent_folder+'/accelsearch_E/*.dat'))
        logfile = parent_folder + '/accelsearch_E/realfft_E.log'
    elif mode == "gtis":
        dat_files = sorted(glob.glob(parent_folder+'/accelsearch_GTIs/*.dat'))
        logfile = parent_folder + '/accelsearch_GTIs/realfft_gtis.log'
    else:
        raise ValueError("mode should either of 'all', 't', 'gtis', or 'E'!")
    print("Running realfft now:")
    with open(logfile,'w') as logtextfile:
        for i in tqdm(range(len(dat_files))):
            if os.path.exists(dat_files[i][:-3] + 'fft')==False:
                output = subprocess.run(['realfft',dat_files[i]],capture_output=True,text=True)
                logtextfile.write(output.stdout)
                logtextfile.write('*------------------------------* \n')
                logtextfile.write(output.stderr)
        logtextfile.close()
    return
def realfft ( eventfile , segment_length , mode ) : parent_folder = str ( pathlib . Path ( eventfile ) . parent ) if mode == "all" : dat_files = sorted ( glob . glob ( parent_folder + '/*.dat' ) ) logfile = parent_folder + '/realfft_all.log' elif mode == "t" : dat_files = sorted ( glob . glob ( parent_folder + '/accelsearch_' + str ( segment_length ) + 's/*.dat' ) ) logfile = parent_folder + '/accelsearch_' + str ( segment_length ) + 's/realfft_t.log' elif mode == "E" : dat_files = sorted ( glob . glob ( parent_folder + '/accelsearch_E/*.dat' ) ) logfile = parent_folder + '/accelsearch_E/realfft_E.log' elif mode == "gtis" : dat_files = sorted ( glob . glob ( parent_folder + '/accelsearch_GTIs/*.dat' ) ) logfile = parent_folder + '/accelsearch_GTIs/realfft_gtis.log' else : raise ValueError ( "mode should either of 'all', 't', 'gtis', or 'E'!" ) print ( "Running realfft now:" ) with open ( logfile , 'w' ) as logtextfile : for i in tqdm ( range ( len ( dat_files ) ) ) : if os . path . exists ( dat_files [ i ] [ : - 3 ] + 'fft' ) == False : output = subprocess . run ( [ 'realfft' , dat_files [ i ] ] , capture_output = True , text = True ) logtextfile . write ( output . stdout ) logtextfile . write ( '*------------------------------* \n' ) logtextfile . write ( output . stderr ) logtextfile . close ( ) return
Performing PRESTO's realfft on the binned data (.dat)
eventfile - path to the event file.
Performing PRESTO ' s realfft on the binned data ( . dat ) eventfile - path to the event file .
"""
    Performing PRESTO's realfft on the binned data (.dat)
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    segment_length - length of the individual segments
    mode - "all", "t", "gtis", or "E" ; basically to tell the function where to access files to run realfft for
    """
eventfile
segment_length
mode