Lv2_presto_subroutines.py
def niextract_gti_energy(eventfile,PI1,PI2):
    """
    Using niextract-events to get segmented data based on the energy range
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    """
    parent_folder = str(pathlib.Path(eventfile).parent)
    gtis = fits.open(eventfile)[2].data

    event_header = fits.open(eventfile)[1].header
    obj_name = event_header['OBJECT']
    obsid = event_header['OBS_ID']

    niextract_folder = parent_folder + '/accelsearch_E/'
    Lv2_mkdir.makedir(niextract_folder)
    output_file = niextract_folder + eventfile.split('/')[-1][:-4] + '_E'+str(PI1).zfill(4)+'-'+str(PI2).zfill(4)+'.evt'

    if os.path.exists(output_file)==False:
        subprocess.run(['niextract-events',eventfile+'[PI='+str(PI1)+':'+str(PI2)+']',output_file])

    return

    Using niextract-events to get segmented data based on the energy range
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    
Using niextract-events to get segmented data based on the energy range
eventfile - path to the event file. Will extract ObsID from this for the NICER files.
PI1 - lower bound of PI (not energy in keV!) desired for the energy range
PI2 - upper bound of PI (not energy in keV!) desired for the energy range
Using niextract - events to get segmented data based on the energy range eventfile - path to the event file . Will extract ObsID from this for the NICER files . PI1 - lower bound of PI ( not energy in keV! ) desired for the energy range PI2 - upper bound of PI ( not energy in keV! ) desired for the energy range
def niextract_gti_energy(eventfile,PI1,PI2):
    parent_folder = str(pathlib.Path(eventfile).parent)
    gtis = fits.open(eventfile)[2].data
    event_header = fits.open(eventfile)[1].header
    obj_name = event_header['OBJECT']
    obsid = event_header['OBS_ID']
    niextract_folder = parent_folder + '/accelsearch_E/'
    Lv2_mkdir.makedir(niextract_folder)
    output_file = niextract_folder + eventfile.split('/')[-1][:-4] + '_E'+str(PI1).zfill(4)+'-'+str(PI2).zfill(4)+'.evt'
    if os.path.exists(output_file)==False:
        subprocess.run(['niextract-events',eventfile+'[PI='+str(PI1)+':'+str(PI2)+']',output_file])
    return
def niextract_gti_energy ( eventfile , PI1 , PI2 ) : parent_folder = str ( pathlib . Path ( eventfile ) . parent ) gtis = fits . open ( eventfile ) [ 2 ] . data event_header = fits . open ( eventfile ) [ 1 ] . header obj_name = event_header [ 'OBJECT' ] obsid = event_header [ 'OBS_ID' ] niextract_folder = parent_folder + '/accelsearch_E/' Lv2_mkdir . makedir ( niextract_folder ) output_file = niextract_folder + eventfile . split ( '/' ) [ - 1 ] [ : - 4 ] + '_E' + str ( PI1 ) . zfill ( 4 ) + '-' + str ( PI2 ) . zfill ( 4 ) + '.evt' if os . path . exists ( output_file ) == False : subprocess . run ( [ 'niextract-events' , eventfile + '[PI=' + str ( PI1 ) + ':' + str ( PI2 ) + ']' , output_file ] ) return
Using niextract-events to get segmented data based on the energy range
eventfile - path to the event file.
Using niextract - events to get segmented data based on the energy range eventfile - path to the event file .
"""
    Using niextract-events to get segmented data based on the energy range
    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    """
eventfile
PI1
PI2