Lv2_average_ps_methods.py
def do_nicerfits2presto(eventfile,tbin,segment_length):
    """
    Using nicerfits2presto.py to bin the data, and to convert into PRESTO-readable format.

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    tbin - size of the bins in time
    segment_length - length of the individual segments for combining power spectra
    """
    parent_folder = str(pathlib.Path(eventfile).parent)
    event_header = fits.open(eventfile)[1].header
    obj_name = event_header['OBJECT']
    obsid = event_header['OBS_ID']

    eventfiles = sorted(glob.glob(parent_folder + '/accelsearch_' + str(segment_length) + 's/*.evt')) #get absolute paths of all demodulated event FITS files
    print('Now converting NICER event FITS files into the PRESTO-readable binary format!')
    for i in tqdm(range(len(eventfiles))):
        if os.path.exists(eventfiles[i][:-3] + 'dat'):
            continue
        try:
            subprocess.run(['nicerfits2presto.py','--dt='+str(tbin),eventfiles[i]])
        except (ValueError,subprocess.CalledProcessError):
            pass

    presto_files = glob.glob('*'+obsid+'*')
    if 'merged' in eventfile:
        presto_files = glob.glob('merged*')
    for i in range(len(presto_files)):
        subprocess.run(['mv',presto_files[i],parent_folder+'/accelsearch_'+str(segment_length)+'s/'])

    Using nicerfits2presto.py to bin the data, and to convert into PRESTO-readable format.

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    tbin - size of the bins in time
    segment_length - length of the individual segments for combining power spectra
    
Using nicerfits2presto.py to bin the data, and to convert into PRESTO-readable format.
eventfile - path to the event file. Will extract ObsID from this for the NICER files.
tbin - size of the bins in time
segment_length - length of the individual segments for combining power spectra
Using nicerfits2presto . py to bin the data and to convert into PRESTO - readable format . eventfile - path to the event file . Will extract ObsID from this for the NICER files . tbin - size of the bins in time segment_length - length of the individual segments for combining power spectra
def do_nicerfits2presto(eventfile,tbin,segment_length):
    parent_folder = str(pathlib.Path(eventfile).parent)
    event_header = fits.open(eventfile)[1].header
    obj_name = event_header['OBJECT']
    obsid = event_header['OBS_ID']
    eventfiles = sorted(glob.glob(parent_folder + '/accelsearch_' + str(segment_length) + 's/*.evt')) 
    print('Now converting NICER event FITS files into the PRESTO-readable binary format!')
    for i in tqdm(range(len(eventfiles))):
        if os.path.exists(eventfiles[i][:-3] + 'dat'):
            continue
        try:
            subprocess.run(['nicerfits2presto.py','--dt='+str(tbin),eventfiles[i]])
        except (ValueError,subprocess.CalledProcessError):
            pass
    presto_files = glob.glob('*'+obsid+'*')
    if 'merged' in eventfile:
        presto_files = glob.glob('merged*')
    for i in range(len(presto_files)):
        subprocess.run(['mv',presto_files[i],parent_folder+'/accelsearch_'+str(segment_length)+'s/'])
def do_nicerfits2presto ( eventfile , tbin , segment_length ) : parent_folder = str ( pathlib . Path ( eventfile ) . parent ) event_header = fits . open ( eventfile ) [ 1 ] . header obj_name = event_header [ 'OBJECT' ] obsid = event_header [ 'OBS_ID' ] eventfiles = sorted ( glob . glob ( parent_folder + '/accelsearch_' + str ( segment_length ) + 's/*.evt' ) ) print ( 'Now converting NICER event FITS files into the PRESTO-readable binary format!' ) for i in tqdm ( range ( len ( eventfiles ) ) ) : if os . path . exists ( eventfiles [ i ] [ : - 3 ] + 'dat' ) : continue try : subprocess . run ( [ 'nicerfits2presto.py' , '--dt=' + str ( tbin ) , eventfiles [ i ] ] ) except ( ValueError , subprocess . CalledProcessError ) : pass presto_files = glob . glob ( '*' + obsid + '*' ) if 'merged' in eventfile : presto_files = glob . glob ( 'merged*' ) for i in range ( len ( presto_files ) ) : subprocess . run ( [ 'mv' , presto_files [ i ] , parent_folder + '/accelsearch_' + str ( segment_length ) + 's/' ] )
Using nicerfits2presto.py to bin the data, and to convert into PRESTO-readable format.
Using nicerfits2presto . py to bin the data and to convert into PRESTO - readable format .
"""
    Using nicerfits2presto.py to bin the data, and to convert into PRESTO-readable format.

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    tbin - size of the bins in time
    segment_length - length of the individual segments for combining power spectra
    """ #get absolute paths of all demodulated event FITS files
eventfile
tbin
segment_length