Lv2_lc.py
def partial_tE(eventfile,par_list,tbin_size,t1,t2,E1,E2,mode):
    """
    Plot the time series for a desired time interval and desired energy range.

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    par_list - A list of parameters we'd like to extract from the FITS file
    (e.g., from eventcl, PI_FAST, TIME, PI,)
    tbin_size - the size of the time bins (in seconds!)
    >> e.g., tbin_size = 2 means bin by 2s
    >> e.g., tbin_size = 0.05 means by in 0.05s
    t1 - lower time boundary
    t2 - upper time boundary
    E1 - lower energy boundary
    E2 - upper energy boundary
    """
    if type(eventfile) != str:
        raise TypeError("eventfile should be a string!")
    if 'TIME' not in par_list:
        raise ValueError("You should have 'TIME' in the parameter list!")
    if type(par_list) != list and type(par_list) != np.ndarray:
        raise TypeError("par_list should either be a list or an array!")
    if E2<E1:
        raise ValueError("E2 should be greater than E1!")
    if t2<t1:
        raise ValueError("t2 should be greater than t1!")
    if mode != 'show' and mode != 'save':
        raise ValueError("Mode should either be 'show' or 'save'!")

    truncated_t, truncated_t_counts, truncated_E, truncated_E_counts = Lv1_data_bin.binning_tE(eventfile,par_list,tbin_size,0.05,t1,t2,E1,E2)
    #put in Ebin_size of 0.05 keV; I'm plotting light curves in this script, so truncated_E and truncated_E_counts are not needed

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

    plt.figure()
    plt.plot(truncated_t[:-1], truncated_t_counts)
    plt.title('Light curve for ' + obj_name + ', ObsID ' + str(obsid)+ '\n Time interval: ' + str(t1) + 's - ' + str(t2) + 's'+ '\n Energy range: ' + str(E1) + 'keV - ' + str(E2) + 'keV',fontsize=12)
    plt.xlabel('Time (s)', fontsize=12)
    plt.ylabel('Count/' + str(tbin_size) + 's',fontsize=12)

    if mode == 'show':
        plt.show()
    elif mode == 'save':
        filename = 'lc_' + obsid + '_bin' + str(tbin_size) + 's_' + str(t1) + 's-' + str(t2) + 's_' + str(E1) + 'keV-' + str(E2) + 'keV.pdf'
        plt.savefig(parent_folder+'/'+filename,dpi=900)
        plt.close()

    Plot the time series for a desired time interval and desired energy range.

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    par_list - A list of parameters we'd like to extract from the FITS file
    (e.g., from eventcl, PI_FAST, TIME, PI,)
    tbin_size - the size of the time bins (in seconds!)
    >> e.g., tbin_size = 2 means bin by 2s
    >> e.g., tbin_size = 0.05 means by in 0.05s
    t1 - lower time boundary
    t2 - upper time boundary
    E1 - lower energy boundary
    E2 - upper energy boundary
    
Plot the time series for a desired time interval and desired energy range.
eventfile - path to the event file. Will extract ObsID from this for the NICER files.
Plot the time series for a desired time interval and desired energy range . eventfile - path to the event file . Will extract ObsID from this for the NICER files .
def partial_tE(eventfile,par_list,tbin_size,t1,t2,E1,E2,mode):
    if type(eventfile) != str:
        raise TypeError("eventfile should be a string!")
    if 'TIME' not in par_list:
        raise ValueError("You should have 'TIME' in the parameter list!")
    if type(par_list) != list and type(par_list) != np.ndarray:
        raise TypeError("par_list should either be a list or an array!")
    if E2<E1:
        raise ValueError("E2 should be greater than E1!")
    if t2<t1:
        raise ValueError("t2 should be greater than t1!")
    if mode != 'show' and mode != 'save':
        raise ValueError("Mode should either be 'show' or 'save'!")
    truncated_t, truncated_t_counts, truncated_E, truncated_E_counts = Lv1_data_bin.binning_tE(eventfile,par_list,tbin_size,0.05,t1,t2,E1,E2)
    event_header = fits.open(eventfile)[1].header
    obj_name = event_header['OBJECT']
    obsid = event_header['OBS_ID']
    plt.figure()
    plt.plot(truncated_t[:-1], truncated_t_counts)
    plt.title('Light curve for ' + obj_name + ', ObsID ' + str(obsid)+ '\n Time interval: ' + str(t1) + 's - ' + str(t2) + 's'+ '\n Energy range: ' + str(E1) + 'keV - ' + str(E2) + 'keV',fontsize=12)
    plt.xlabel('Time (s)', fontsize=12)
    plt.ylabel('Count/' + str(tbin_size) + 's',fontsize=12)
    if mode == 'show':
        plt.show()
    elif mode == 'save':
        filename = 'lc_' + obsid + '_bin' + str(tbin_size) + 's_' + str(t1) + 's-' + str(t2) + 's_' + str(E1) + 'keV-' + str(E2) + 'keV.pdf'
        plt.savefig(parent_folder+'/'+filename,dpi=900)
        plt.close()
def partial_tE ( eventfile , par_list , tbin_size , t1 , t2 , E1 , E2 , mode ) : if type ( eventfile ) != str : raise TypeError ( "eventfile should be a string!" ) if 'TIME' not in par_list : raise ValueError ( "You should have 'TIME' in the parameter list!" ) if type ( par_list ) != list and type ( par_list ) != np . ndarray : raise TypeError ( "par_list should either be a list or an array!" ) if E2 < E1 : raise ValueError ( "E2 should be greater than E1!" ) if t2 < t1 : raise ValueError ( "t2 should be greater than t1!" ) if mode != 'show' and mode != 'save' : raise ValueError ( "Mode should either be 'show' or 'save'!" ) truncated_t , truncated_t_counts , truncated_E , truncated_E_counts = Lv1_data_bin . binning_tE ( eventfile , par_list , tbin_size , 0.05 , t1 , t2 , E1 , E2 ) event_header = fits . open ( eventfile ) [ 1 ] . header obj_name = event_header [ 'OBJECT' ] obsid = event_header [ 'OBS_ID' ] plt . figure ( ) plt . plot ( truncated_t [ : - 1 ] , truncated_t_counts ) plt . title ( 'Light curve for ' + obj_name + ', ObsID ' + str ( obsid ) + '\n Time interval: ' + str ( t1 ) + 's - ' + str ( t2 ) + 's' + '\n Energy range: ' + str ( E1 ) + 'keV - ' + str ( E2 ) + 'keV' , fontsize = 12 ) plt . xlabel ( 'Time (s)' , fontsize = 12 ) plt . ylabel ( 'Count/' + str ( tbin_size ) + 's' , fontsize = 12 ) if mode == 'show' : plt . show ( ) elif mode == 'save' : filename = 'lc_' + obsid + '_bin' + str ( tbin_size ) + 's_' + str ( t1 ) + 's-' + str ( t2 ) + 's_' + str ( E1 ) + 'keV-' + str ( E2 ) + 'keV.pdf' plt . savefig ( parent_folder + '/' + filename , dpi = 900 ) plt . close ( )
Plot the time series for a desired time interval and desired energy range.
Plot the time series for a desired time interval and desired energy range .
"""
    Plot the time series for a desired time interval and desired energy range.

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    par_list - A list of parameters we'd like to extract from the FITS file
    (e.g., from eventcl, PI_FAST, TIME, PI,)
    tbin_size - the size of the time bins (in seconds!)
    >> e.g., tbin_size = 2 means bin by 2s
    >> e.g., tbin_size = 0.05 means by in 0.05s
    t1 - lower time boundary
    t2 - upper time boundary
    E1 - lower energy boundary
    E2 - upper energy boundary
    """ #put in Ebin_size of 0.05 keV; I'm plotting light curves in this script, so truncated_E and truncated_E_counts are not needed
eventfile
par_list
tbin_size
t1
t2
E1
E2
mode