コード例 #1
0
 
fig = plt.figure()
ax  = fig.add_subplot(111, projection = '3d')
O_range = linspace(0.0, max(nominal_values(O_values)) * 1.10, 20)
S_range = linspace(0.0, max(nominal_values(S_values)) * 1.10, 20)
linear_regresion = Yp_mean + mO_mean * O_range + mS_mean * S_range
  
ax.plot(O_range, S_range, linear_regresion, label='O - S regression')
ax.scatter(nominal_values(O_values), nominal_values(S_values), nominal_values(Y_S), marker='o', label='Observed abundances')
ax.scatter(0.0, 0.0, WMAP_coordinates[1].nominal_value, marker='o', label='WMAP prediction')
ax.legend(loc='lower left')
ax.set_xlabel('Oxygen abundance')
ax.set_ylabel('Sulfur abundance')
ax.set_zlabel('Y')
plotTitle = r'{title}: $Y_{{P}} = {n}_{{-{lowerlimit}}}^{{+{upperlimit}}}$'.format(
title = 'Oxygen and Sulfur regression', n = round_sig(n_Median,4, scien_notation=False), lowerlimit = round_sig(n_Median-n_16th,4, scien_notation=False), upperlimit = round_sig(n_84th-n_Median,4, scien_notation=False))

ax.set_title(plotTitle, fontsize = 16)

plt.show()



# #Run the fits
# for k in range(MC_iterations):
#     O_i = O_matrix[:,k]
#     S_i = S_values[:,k]
#     y_i = Y_S[:,k]
# 
#     m, n, r_value, p_value, std_err = stats.linregress(x_i, y_i)
#     m_vector[k], n_vector[k] = m, n
コード例 #2
0
    #Bootstrap BCES
    m, n, m_err, n_err, cov = bcesboot(nominal_values(x), std_devs(x), nominal_values(y), std_devs(y), cerr=zeros(len(x)), nsim=10000)
    print element
    print 'New methods'
    print m[0], m[1], m[2], m[3]
    print m_err[0], m_err[1], m_err[2], m_err[3]
    print n[0], n[1], n[2], n[3]
    print n_err[0], n_err[1], n_err[2], n_err[3]

    #Get fit mean values
    n_Median, n_16th, n_84th = median(n_vector), percentile(n_vector,16), percentile(n_vector,84)
    m_Median, m_16th, m_84th = median(m_vector), percentile(m_vector,16), percentile(m_vector,84)

    print 'Classical'
    print n_Median, round_sig(n_Median-n_16th,2, scien_notation=False), round_sig(n_84th-n_Median,2, scien_notation=False)
    
    #Linear data
    x_regression_range = linspace(0.0, max(nominal_values(x)) * 1.10, 20)
    y_regression_range = m_Median * x_regression_range + n_Median      
    
    #Plotting the data, 
    dz.data_plot(nominal_values(x), nominal_values(y), color = Regresions_dict['Colors'][i], label=regression, markerstyle='o', x_error=std_devs(x), y_error=std_devs(y))
    dz.data_plot(WMAP_coordinates[0].nominal_value, WMAP_coordinates[1].nominal_value, color = dz.colorVector['pink'], label=r'WMAP prediction: $Y = 0.24709\pm0.00025$', markerstyle='o', x_error=WMAP_coordinates[0].std_dev, y_error=WMAP_coordinates[1].std_dev)    
    dz.data_plot(x_regression_range, y_regression_range, label = 'Linear regression', color = Regresions_dict['Colors'][i], linestyle = '--')
    dz.plot_text(nominal_values(x), nominal_values(y), objects)
    
    plotTitle = r'{title}: $Y_{{P}} = {n}_{{-{lowerlimit}}}^{{+{upperlimit}}}$'.format(title = Regresions_dict['title'][i], n = round_sig(n_Median,4, scien_notation=False), lowerlimit = round_sig(n_Median-n_16th,2, scien_notation=False), upperlimit = round_sig(n_84th-n_Median,2, scien_notation=False))
    dz.FigWording(Regresions_dict['x label'][i], Regresions_dict['y label'][i], plotTitle, loc='lower right')

    output_pickle = '{objFolder}{element}_regression'.format(objFolder=catalogue_dict['Data_Folder'], element = element)
コード例 #3
0
    
    #Run the fits
    for k in range(MC_iterations):
        x_i = metal_matrix[:,k]
        y_i = Y_matrix[:,k]

        m, n, r_value, p_value, std_err = stats.linregress(x_i, y_i)
        m_vector[k], n_vector[k] = m, n
    
    #Get fit mean values
    n_Median, n_16th, n_84th = median(n_vector), percentile(n_vector,16), percentile(n_vector,84)
    m_Median, m_16th, m_84th = median(m_vector), percentile(m_vector,16), percentile(m_vector,84)
    
    #Linear data
    x_regression_range = linspace(0.0, max(nominal_values(x)) * 1.10, 20)
    y_regression_range = m_Median * x_regression_range + n_Median      
    
    #Plotting the data
    dz.data_plot(nominal_values(x), nominal_values(y), color = Regresions_dict['Colors'][i], label=regression, markerstyle='o', x_error=std_devs(x), y_error=std_devs(y))
    dz.data_plot(WMAP_coordinates[0].nominal_value, WMAP_coordinates[1].nominal_value, color = dz.colorVector['pink'], label='WMAP prediction', markerstyle='o', x_error=WMAP_coordinates[0].std_dev, y_error=WMAP_coordinates[1].std_dev)    
    dz.data_plot(x_regression_range, y_regression_range, label = 'Linear regression', color = Regresions_dict['Colors'][i], linestyle = '--')
    dz.plot_text(nominal_values(x), nominal_values(y), objects)

    plotTitle = r'{title}: $Y_{{P}} = {n}_{{-{lowerlimit}}}^{{+{upperlimit}}}$'.format(title = regression, n = round_sig(n_Median,4, scien_notation=False), lowerlimit = round_sig(n_Median-n_16th,4, scien_notation=False), upperlimit = round_sig(n_84th-n_Median,4, scien_notation=False))
    dz.FigWording(Regresions_dict['x label'][i], Regresions_dict['y label'][i], plotTitle, loc='lower right')

    output_pickle = '{objFolder}{element}_regression'.format(objFolder=catalogue_dict['Data_Folder'], element = element)
    dz.save_manager(output_pickle, save_pickle = True)


コード例 #4
0
                                       cerr=zeros(len(x)),
                                       nsim=10000)

    #--Objects summary
    print '--- Using {}:'.format(len(objects)), ', '.join(list(objects))
    print '--- Rejecting {}:'.format(len(reject_objs)), ', '.join(
        list(reject_objs))

    print 'BCES Bootstrap'
    print m[0], m[1], m[2], m[3]
    print m_err[0], m_err[1], m_err[2], m_err[3]
    print n[0], n[1], n[2], n[3]
    print n_err[0], n_err[1], n_err[2], n_err[3]

    print 'My bootstrap'
    print n_Median, round_sig(n_Median - n_16th, 2,
                              scien_notation=False), round_sig(
                                  n_84th - n_Median, 2, scien_notation=False)

    #Linear data
    x_regression_range = linspace(0.0, max(nominal_values(x)) * 1.10, 20)
    y_regression_range = m_Median * x_regression_range + n_Median
    label_regr = 'SCIPY bootstrap: $Y_{{P}} = {n}_{{-{lowerlimit}}}^{{+{upperlimit}}}$'.format(
        title=Regresions_dict['title'][i],
        n=round_sig(n_Median, 4, scien_notation=False),
        lowerlimit=round_sig(n_Median - n_16th, 2, scien_notation=False),
        upperlimit=round_sig(n_84th - n_Median, 2, scien_notation=False))

    #Plotting the data,
    dz.data_plot(nominal_values(x),
                 nominal_values(y),
                 color=Regresions_dict['Colors'][i],
コード例 #5
0
dz.argon_abundance_scheme(dz.abunData['TeOIII'], dz.abunData['TeSIII'],
                          dz.abunData['neSII'])
dz.sulfur_abundance_scheme(dz.abunData['TeSIII'],
                           dz.abunData['neSII'],
                           SIII_lines_to_use=Data_TestObject.SIII_lines)
dz.oxygen_abundance_scheme(dz.abunData['TeOIII'], dz.abunData['TeSIII'],
                           dz.abunData['neSII'])
dz.nitrogen_abundance_scheme(dz.abunData['TeOIII'], dz.abunData['neSII'])

for parameter in dz.abunData.index:
    mean_value, std_value = mean(dz.abunData[parameter]), std(
        dz.abunData[parameter])
    scientfici_not = True if (mean_value < 1e-4) or (
        mean_value > 1e-5) else False
    print '--', parameter, '\t\t', round_sig(
        mean_value, 5,
        scientfici_not), ' +/- ', round_sig(std_value, 5, scientfici_not)

# dz = Dazer()
# dz.load_elements()
#
# param_dict = {}
# param_dict['ne_true']   = 150.0
# param_dict['Te_low']    = 12000.0
# param_dict['Te_high']   = 14000.0
# param_dict['Ar3_abund']  = 2.4e-6
# param_dict['Ar4_abund']  = 4.8e-6
#
# Emis_Hbeta_Tlow = dz.H1_atom.getEmissivity(tem=param_dict['Te_low'], den=param_dict['ne_true'], label = '4_2', product = False)
# Emis_Hbeta_Thigh = dz.H1_atom.getEmissivity(tem=param_dict['Te_high'], den=param_dict['ne_true'], label = '4_2', product = False)
#