Lv2_presto_subroutines.py
def ps2pdf(eventfile,segment_length,mode):
    """
    Converting from .ps to .pdf
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    mode - "all", "t", "gtis", or "E" ; basically to tell the function where to access files to run ps2pdf for
    """
    parent_folder = str(pathlib.Path(eventfile).parent)

    if mode == "all":
        ps_files = sorted(glob.glob(parent_folder+'/*ps'))
    elif mode == "t":
        ps_files = sorted(glob.glob(parent_folder+'/accelsearch_'+str(segment_length)+'s/*ps'))
    elif mode == "E":
        ps_files = sorted(glob.glob(parent_folder+'/accelsearch_E/*ps'))
    elif mode == "gtis":
        ps_files = sorted(glob.glob(parent_folder+'/accelsearch_GTIs/*ps'))
    else:
        raise ValueError("mode should either of 'all', 't', 'gtis', or 'E'!")

    print('Running ps2pdf now!')
    for i in tqdm(range(len(ps_files))):
        pdf_file = ps_files[i][:-2]+'pdf' #replacing .ps to .pdf
        ps2pdf_command = ['ps2pdf',ps_files[i],pdf_file]
        subprocess.run(ps2pdf_command) #using ps2pdf to convert from ps to pdf ; not just a simple change in extension

    return

    Converting from .ps to .pdf
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    mode - "all", "t", "gtis", or "E" ; basically to tell the function where to access files to run ps2pdf for
    
Converting from .ps to .pdf
eventfile - path to the event file. Will extract ObsID from this for the NICER files.
Converting from . ps to . pdf eventfile - path to the event file . Will extract ObsID from this for the NICER files .
def ps2pdf(eventfile,segment_length,mode):
    parent_folder = str(pathlib.Path(eventfile).parent)
    if mode == "all":
        ps_files = sorted(glob.glob(parent_folder+'/*ps'))
    elif mode == "t":
        ps_files = sorted(glob.glob(parent_folder+'/accelsearch_'+str(segment_length)+'s/*ps'))
    elif mode == "E":
        ps_files = sorted(glob.glob(parent_folder+'/accelsearch_E/*ps'))
    elif mode == "gtis":
        ps_files = sorted(glob.glob(parent_folder+'/accelsearch_GTIs/*ps'))
    else:
        raise ValueError("mode should either of 'all', 't', 'gtis', or 'E'!")
    print('Running ps2pdf now!')
    for i in tqdm(range(len(ps_files))):
        pdf_file = ps_files[i][:-2]+'pdf' 
        ps2pdf_command = ['ps2pdf',ps_files[i],pdf_file]
        subprocess.run(ps2pdf_command) 
    return
def ps2pdf ( eventfile , segment_length , mode ) : parent_folder = str ( pathlib . Path ( eventfile ) . parent ) if mode == "all" : ps_files = sorted ( glob . glob ( parent_folder + '/*ps' ) ) elif mode == "t" : ps_files = sorted ( glob . glob ( parent_folder + '/accelsearch_' + str ( segment_length ) + 's/*ps' ) ) elif mode == "E" : ps_files = sorted ( glob . glob ( parent_folder + '/accelsearch_E/*ps' ) ) elif mode == "gtis" : ps_files = sorted ( glob . glob ( parent_folder + '/accelsearch_GTIs/*ps' ) ) else : raise ValueError ( "mode should either of 'all', 't', 'gtis', or 'E'!" ) print ( 'Running ps2pdf now!' ) for i in tqdm ( range ( len ( ps_files ) ) ) : pdf_file = ps_files [ i ] [ : - 2 ] + 'pdf' ps2pdf_command = [ 'ps2pdf' , ps_files [ i ] , pdf_file ] subprocess . run ( ps2pdf_command ) return
Converting from .ps to .pdf
eventfile - path to the event file.
Converting from . ps to . pdf eventfile - path to the event file .
"""
    Converting from .ps to .pdf
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    mode - "all", "t", "gtis", or "E" ; basically to tell the function where to access files to run ps2pdf for
    """ #replacing .ps to .pdf #using ps2pdf to convert from ps to pdf ; not just a simple change in extension
eventfile
segment_length
mode