Lv3_analyze_xspec_pars.py
def lumin_plus_par(model,MJDs,E1,E2):
    """
    Plot luminosity against a spectral parameter
    11/17: Need to be able to generalize such that I can use this function for >1 model!

    model - name of the model used
    MJDs - list of MJDs used
    E1 - lower bound for energy (4-digit PI string)
    E2 - upper bound for energy (4-digit PI string)
    """
    input_file = Lv0_dirs.NGC300 + 'spectral_fit_'+E1+'-'+E2+'/'+model+'_lumin.txt'
    contents = open(input_file).read().split('\n')
    lumin_lines = [float(contents[i].split(' ')[2]) for i in range(2,len(contents),3)]

    xspec_fits = xspec_par(model,E1,E2)

    fig = plt.figure(figsize=(16,9))
    fig.suptitle('Parameters from ' + model + ' against luminosity')
    gs = GridSpec(2,1,hspace=0) #that '1' is for the overall spectra

    singular_model = model.split('-')[-1] #PLACEHOLDER FOR NOW
    for k in range(len(model_par(singular_model))):
        var = model_par(singular_model)[k]
        ax = fig.add_subplot(gs[k,0])
        ax.errorbar(x=np.array(lumin_lines)/1e39,y=xspec_fits[singular_model+'-'+var],yerr=xspec_fits[singular_model+'-'+var+'_unc'],fmt='x')#,label=MJDs[j])
        #datacursor(formatter='{label}'.format,bbox=None)
        ax.set_ylim([0.8*np.min(xspec_fits[singular_model+'-'+var]),1.2*np.max(xspec_fits[singular_model+'-'+var])])
        ax.set_ylabel(singular_model + '\n' + var)
        ax.set_xlabel('Luminosity in 10^(39) erg/s',fontsize=12)

    plt.show()

    Plot luminosity against a spectral parameter
    11/17: Need to be able to generalize such that I can use this function for >1 model!

    model - name of the model used
    MJDs - list of MJDs used
    E1 - lower bound for energy (4-digit PI string)
    E2 - upper bound for energy (4-digit PI string)
    
Plot luminosity against a spectral parameter
11/17: Need to be able to generalize such that I can use this function for >1 model!


Plot luminosity against a spectral parameter 11 / 17 : Need to be able to generalize such that I can use this function for > 1 model!
def lumin_plus_par(model,MJDs,E1,E2):
    input_file = Lv0_dirs.NGC300 + 'spectral_fit_'+E1+'-'+E2+'/'+model+'_lumin.txt'
    contents = open(input_file).read().split('\n')
    lumin_lines = [float(contents[i].split(' ')[2]) for i in range(2,len(contents),3)]
    xspec_fits = xspec_par(model,E1,E2)
    fig = plt.figure(figsize=(16,9))
    fig.suptitle('Parameters from ' + model + ' against luminosity')
    gs = GridSpec(2,1,hspace=0) 
    singular_model = model.split('-')[-1] 
    for k in range(len(model_par(singular_model))):
        var = model_par(singular_model)[k]
        ax = fig.add_subplot(gs[k,0])
        ax.errorbar(x=np.array(lumin_lines)/1e39,y=xspec_fits[singular_model+'-'+var],yerr=xspec_fits[singular_model+'-'+var+'_unc'],fmt='x')
        ax.set_ylim([0.8*np.min(xspec_fits[singular_model+'-'+var]),1.2*np.max(xspec_fits[singular_model+'-'+var])])
        ax.set_ylabel(singular_model + '\n' + var)
        ax.set_xlabel('Luminosity in 10^(39) erg/s',fontsize=12)
    plt.show()
def lumin_plus_par ( model , MJDs , E1 , E2 ) : input_file = Lv0_dirs . NGC300 + 'spectral_fit_' + E1 + '-' + E2 + '/' + model + '_lumin.txt' contents = open ( input_file ) . read ( ) . split ( '\n' ) lumin_lines = [ float ( contents [ i ] . split ( ' ' ) [ 2 ] ) for i in range ( 2 , len ( contents ) , 3 ) ] xspec_fits = xspec_par ( model , E1 , E2 ) fig = plt . figure ( figsize = ( 16 , 9 ) ) fig . suptitle ( 'Parameters from ' + model + ' against luminosity' ) gs = GridSpec ( 2 , 1 , hspace = 0 ) singular_model = model . split ( '-' ) [ - 1 ] for k in range ( len ( model_par ( singular_model ) ) ) : var = model_par ( singular_model ) [ k ] ax = fig . add_subplot ( gs [ k , 0 ] ) ax . errorbar ( x = np . array ( lumin_lines ) / 1e39 , y = xspec_fits [ singular_model + '-' + var ] , yerr = xspec_fits [ singular_model + '-' + var + '_unc' ] , fmt = 'x' ) ax . set_ylim ( [ 0.8 * np . min ( xspec_fits [ singular_model + '-' + var ] ) , 1.2 * np . max ( xspec_fits [ singular_model + '-' + var ] ) ] ) ax . set_ylabel ( singular_model + '\n' + var ) ax . set_xlabel ( 'Luminosity in 10^(39) erg/s' , fontsize = 12 ) plt . show ( )
Plot luminosity against a spectral parameter
11/17: Need to be able to generalize such that I can use this function for >1 model!
Plot luminosity against a spectral parameter 11 / 17 : Need to be able to generalize such that I can use this function for > 1 model!
"""
    Plot luminosity against a spectral parameter
    11/17: Need to be able to generalize such that I can use this function for >1 model!

    model - name of the model used
    MJDs - list of MJDs used
    E1 - lower bound for energy (4-digit PI string)
    E2 - upper bound for energy (4-digit PI string)
    """ #that '1' is for the overall spectra #PLACEHOLDER FOR NOW #,label=MJDs[j]) #datacursor(formatter='{label}'.format,bbox=None)
model
MJDs
E1
E2