Lv2_create_time_res_spec.py
def niextract_gti(eventfile,gap,gtifile,min_exp):
    """
    Using niextract-events to get segmented data based on the individual GTIs created with
    GTI_bunching in Lv1_data_gtis. (Very similar to that in Lv2_presto_subroutines,
    except I create a list of paths to the event files.)

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    gap - maximum separation between end time of 1st GTI and start time of 2nd GTI allowed
    gtifile - name of GTI file
    min_exp - minimum exposure to be used for the spectra
    """
    parent_folder = str(pathlib.Path(eventfile).parent)
    Lv1_data_gtis.GTI_bunching(eventfile,gap,gtifile)

    gtis = list(fits.open(parent_folder+'/'+gtifile)[1].data)
    niextract_folder = parent_folder + '/accelsearch_GTIs/'
    Lv2_mkdir.makedir(niextract_folder)
    for i in tqdm(range(len(gtis))):
        gti_start = gtis[i][0]
        gti_end = gtis[i][1]
        if gti_end - gti_start >= min_exp:
            subprocess.run(['mkgti.py','--gtiname',niextract_folder+'GTI'+str(i+1)+'.gti',str(gti_start),str(gti_end)])
            subprocess.run(['niextract-events',eventfile,niextract_folder+str(pathlib.Path(eventfile).name)[:-4]+'_GTI'+str(i+1).zfill(4)+'.evt','timefile='+niextract_folder+'GTI'+str(i+1)+'.gti'])

    return

    Using niextract-events to get segmented data based on the individual GTIs created with
    GTI_bunching in Lv1_data_gtis. (Very similar to that in Lv2_presto_subroutines,
    except I create a list of paths to the event files.)

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    gap - maximum separation between end time of 1st GTI and start time of 2nd GTI allowed
    gtifile - name of GTI file
    min_exp - minimum exposure to be used for the spectra
    
Using niextract-events to get segmented data based on the individual GTIs created with
GTI_bunching in Lv1_data_gtis. (Very similar to that in Lv2_presto_subroutines,
except I create a list of paths to the event files.)

path to the event file. Will extract ObsID from this for the NICER files.
gap - maximum separation between end time of 1st GTI and start time of 2nd GTI allowed
gtifile - name of GTI file
min_exp - minimum exposure to be used for the spectra
Using niextract - events to get segmented data based on the individual GTIs created with GTI_bunching in Lv1_data_gtis . ( Very similar to that in Lv2_presto_subroutines except I create a list of paths to the event files . ) path to the event file . Will extract ObsID from this for the NICER files . gap - maximum separation between end time of 1st GTI and start time of 2nd GTI allowed gtifile - name of GTI file min_exp - minimum exposure to be used for the spectra
def niextract_gti(eventfile,gap,gtifile,min_exp):
    parent_folder = str(pathlib.Path(eventfile).parent)
    Lv1_data_gtis.GTI_bunching(eventfile,gap,gtifile)
    gtis = list(fits.open(parent_folder+'/'+gtifile)[1].data)
    niextract_folder = parent_folder + '/accelsearch_GTIs/'
    Lv2_mkdir.makedir(niextract_folder)
    for i in tqdm(range(len(gtis))):
        gti_start = gtis[i][0]
        gti_end = gtis[i][1]
        if gti_end - gti_start >= min_exp:
            subprocess.run(['mkgti.py','--gtiname',niextract_folder+'GTI'+str(i+1)+'.gti',str(gti_start),str(gti_end)])
            subprocess.run(['niextract-events',eventfile,niextract_folder+str(pathlib.Path(eventfile).name)[:-4]+'_GTI'+str(i+1).zfill(4)+'.evt','timefile='+niextract_folder+'GTI'+str(i+1)+'.gti'])
    return
def niextract_gti ( eventfile , gap , gtifile , min_exp ) : parent_folder = str ( pathlib . Path ( eventfile ) . parent ) Lv1_data_gtis . GTI_bunching ( eventfile , gap , gtifile ) gtis = list ( fits . open ( parent_folder + '/' + gtifile ) [ 1 ] . data ) niextract_folder = parent_folder + '/accelsearch_GTIs/' Lv2_mkdir . makedir ( niextract_folder ) for i in tqdm ( range ( len ( gtis ) ) ) : gti_start = gtis [ i ] [ 0 ] gti_end = gtis [ i ] [ 1 ] if gti_end - gti_start >= min_exp : subprocess . run ( [ 'mkgti.py' , '--gtiname' , niextract_folder + 'GTI' + str ( i + 1 ) + '.gti' , str ( gti_start ) , str ( gti_end ) ] ) subprocess . run ( [ 'niextract-events' , eventfile , niextract_folder + str ( pathlib . Path ( eventfile ) . name ) [ : - 4 ] + '_GTI' + str ( i + 1 ) . zfill ( 4 ) + '.evt' , 'timefile=' + niextract_folder + 'GTI' + str ( i + 1 ) + '.gti' ] ) return
Using niextract-events to get segmented data based on the individual GTIs created with
GTI_bunching in Lv1_data_gtis.
Using niextract - events to get segmented data based on the individual GTIs created with GTI_bunching in Lv1_data_gtis .
"""
    Using niextract-events to get segmented data based on the individual GTIs created with
    GTI_bunching in Lv1_data_gtis. (Very similar to that in Lv2_presto_subroutines,
    except I create a list of paths to the event files.)

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    gap - maximum separation between end time of 1st GTI and start time of 2nd GTI allowed
    gtifile - name of GTI file
    min_exp - minimum exposure to be used for the spectra
    """
eventfile
gap
gtifile
min_exp