Lv2_swift_lc.py
def xselect_script(eventlist,regfile,binsize,mjd1,mjd2):
    """
    Writes a script so that XSELECT can take in the events, bins them, and
    outputs them into a light curve (.lc) form

    eventlist - a list of event files
    binsize - desired bin size for the light curve
    """
    parent_folder = str(pathlib.Path(eventlist[0]).parent)
    script_name = parent_folder + '/xselect_earlier_ulx1_instructions.txt'

    writing = open(script_name,'w')
    writing.write('set mission swift' + '\n')
    writing.write('set inst xrt' + '\n')
    for i in range(len(eventlist)):
        if (fits.open(eventlist[i])[1].header['MJD-OBS'] >= mjd1) and (fits.open(eventlist[i])[1].header['MJD-OBS'] <= mjd2):
            eventfile = str(pathlib.Path(eventlist[i]).name)
            obsid = eventfile[:13]
            writing.write('set datadir ' + parent_folder + '\n')
            writing.write('read events ' + eventfile + '\n')
            writing.write('filter region ' + regfile + '\n')
            writing.write('extract curve binsize=' + str(binsize) + '\n')
            writing.write('save curve ' + obsid + '_ulx1.lc' + '\n')
            writing.write('clear data' + '\n')
            writing.write('clear region' + '\n')
            writing.write(' ' + '\n')
    writing.close()

    Writes a script so that XSELECT can take in the events, bins them, and
    outputs them into a light curve (.lc) form

    eventlist - a list of event files
    binsize - desired bin size for the light curve
    
Writes a script so that XSELECT can take in the events, bins them, and
outputs them into a light curve (.lc) form

a list of event files
binsize - desired bin size for the light curve
Writes a script so that XSELECT can take in the events bins them and outputs them into a light curve ( . lc ) form a list of event files binsize - desired bin size for the light curve
def xselect_script(eventlist,regfile,binsize,mjd1,mjd2):
    parent_folder = str(pathlib.Path(eventlist[0]).parent)
    script_name = parent_folder + '/xselect_earlier_ulx1_instructions.txt'
    writing = open(script_name,'w')
    writing.write('set mission swift' + '\n')
    writing.write('set inst xrt' + '\n')
    for i in range(len(eventlist)):
        if (fits.open(eventlist[i])[1].header['MJD-OBS'] >= mjd1) and (fits.open(eventlist[i])[1].header['MJD-OBS'] <= mjd2):
            eventfile = str(pathlib.Path(eventlist[i]).name)
            obsid = eventfile[:13]
            writing.write('set datadir ' + parent_folder + '\n')
            writing.write('read events ' + eventfile + '\n')
            writing.write('filter region ' + regfile + '\n')
            writing.write('extract curve binsize=' + str(binsize) + '\n')
            writing.write('save curve ' + obsid + '_ulx1.lc' + '\n')
            writing.write('clear data' + '\n')
            writing.write('clear region' + '\n')
            writing.write(' ' + '\n')
    writing.close()
def xselect_script ( eventlist , regfile , binsize , mjd1 , mjd2 ) : parent_folder = str ( pathlib . Path ( eventlist [ 0 ] ) . parent ) script_name = parent_folder + '/xselect_earlier_ulx1_instructions.txt' writing = open ( script_name , 'w' ) writing . write ( 'set mission swift' + '\n' ) writing . write ( 'set inst xrt' + '\n' ) for i in range ( len ( eventlist ) ) : if ( fits . open ( eventlist [ i ] ) [ 1 ] . header [ 'MJD-OBS' ] >= mjd1 ) and ( fits . open ( eventlist [ i ] ) [ 1 ] . header [ 'MJD-OBS' ] <= mjd2 ) : eventfile = str ( pathlib . Path ( eventlist [ i ] ) . name ) obsid = eventfile [ : 13 ] writing . write ( 'set datadir ' + parent_folder + '\n' ) writing . write ( 'read events ' + eventfile + '\n' ) writing . write ( 'filter region ' + regfile + '\n' ) writing . write ( 'extract curve binsize=' + str ( binsize ) + '\n' ) writing . write ( 'save curve ' + obsid + '_ulx1.lc' + '\n' ) writing . write ( 'clear data' + '\n' ) writing . write ( 'clear region' + '\n' ) writing . write ( ' ' + '\n' ) writing . close ( )
Writes a script so that XSELECT can take in the events, bins them, and
outputs them into a light curve (.lc) form
Writes a script so that XSELECT can take in the events bins them and outputs them into a light curve ( . lc ) form
"""
    Writes a script so that XSELECT can take in the events, bins them, and
    outputs them into a light curve (.lc) form

    eventlist - a list of event files
    binsize - desired bin size for the light curve
    """
eventlist
regfile
binsize
mjd1
mjd2