コード例 #1
0
    def model(value = y_data, x_values = x_data, m = m_coef, n = n_coef, sigma = sigma):
        value_theo      = m*x_values + n
        chi_sq          = np.sum( np.square(value - value_theo) / np.square(sigma))
        L_prob          = - chi_sq / 2.0
        return L_prob

#   #---Chi Square Moodel
    @pymc.deterministic()
    def Chi(value = y_data, x_values = x_data, m = m_coef, n = n_coef, sigma = sigma):
        value_theo      = m*x_values + n
        ChiSq             = np.sum( np.square(value - value_theo) / np.square(sigma))
        return ChiSq

    return locals()

dz = bayes_plotter()
Fig    = plt.figure(figsize = (16, 9))  
Axis1  = Fig.add_subplot(111)
dz.Import_FigConf(Fig, Axis1)



#Generating some data for the model_difference y = m * x + n
m_true, n_true  = 3, 2
sigma_true      = 2
x_true          = 25 * (np.random.random(50) - 0.5)
y_true          = m_true * x_true + n_true

#Adding some scatter
x_data, y_data  = x_true, y_true
# x_data, y_data  = np.random.normal(x_true, 2), np.random.normal(y_true, 2)
コード例 #2
0
        
        #Add the HeIII component if observed
        if HeIII_HII != None:
            HeI_HI = HeII_HII_Inference + HeIII_HII
        else:
            HeI_HI = HeII_HII_Inference
            
        Y_mass_InferenceS = (4 * HeI_HI * (1 - 20 * ch_an.OI_SI * SI_HI)) / (1 + 4 * HeI_HI)
    
    else:
        Y_mass_InferenceS = None    
        
    return Y_mass_InferenceO, Y_mass_InferenceS

pv                      = myPickle()
bp                      = bayes_plotter()
ch_an                   = Chemical_Analysis()

#Define data type and location
Catalogue_Dic           = DataToTreat()
Pattern                 = Catalogue_Dic['Datatype'] + '.fits'

#Databases format
AbundancesFileExtension = '_WHT_LinesLog_v3.txt'
database_extension      = '_extandar_30000_5000_10_Revision3'
globalfile_extension    = '_global_30000_5000_10_Revision3.csv'

#Variables to plot
Traces_code             = ['He_abud', 'T_e', 'n_e', 'c_Hbeta', 'Tau', 'Xi', 'ChiSq'] #['He_abud', 'T_e', 'n_e', 'abs_H', 'abs_He', 'c_Hbeta', 'Tau', 'Xi', 'ChiSq']
Traces_labels           = [r'$y^{+}$', r'$T_{e}$',  r'$n_{e}$', r'$c(H\beta)$', r'$\tau$', r'$\xi$', r'$\chi^{2}$'] #[r'$y^{+}$', r'$T_{e}$',  r'$n_{e}$', r'$a_{H}$', r'$a_{He}$' r'$c(H\beta)$',  r'$\tau$', r'$\xi$', r'$\chi^{2}$']
コード例 #3
0
import corner
from uncertainties import ufloat
from CodeTools.PlottingManager import myPickle
from ManageFlow import DataToTreat
from Plotting_Libraries.bayesian_data import bayes_plotter
from uncertainties.umath import log10 as uma_log10, pow as uma_pow
from Astro_Libraries.Abundances_Class import Chemical_Analysis
from numpy import array, mean, median, percentile, std
import matplotlib.pyplot as plt

pv = myPickle()
bp = bayes_plotter()
ch_an = Chemical_Analysis()

#Define data type and location
Pattern_low_ne = 'he_Abundance__30000_5000_10_NoNuissanceParameters_8_Model4_continuous'
Pattern_High_ne = 'he_Abundance__30000_5000_10_NoNuissanceParameters_EqwHbetaPrior5_Model3_VeryGood_4649sec'

Folder = '/home/vital/workspace/X_Data/'

#Variables to plot
# Traces_code             = ['He_abud', 'T_e', 'n_e', 'abs_H', 'abs_He', 'c_Hbeta', 'Tau', 'Xi'] #['He_abud', 'T_e', 'n_e', 'c_Hbeta', 'Tau', 'Xi', 'ChiSq'] #['He_abud', 'T_e', 'n_e', 'abs_H', 'abs_He', 'c_Hbeta', 'Tau', 'Xi', 'ChiSq']
# Traces_labels           = [r'$y^{+}$', r'$T_{e}\,(K)$',  r'$n_{e}\,(cm^{-3})$', r'$a_{H}$', r'$a_{He}$', r'$c(H\beta)$',  r'$\tau$', r'$\xi$']#[r'$y^{+}$', r'$T_{e}$',  r'$n_{e}$', r'$c(H\beta)$', r'$\tau$', r'$\xi$', r'$\chi^{2}$'] #[r'$y^{+}$', r'$T_{e}$',  r'$n_{e}$', r'$a_{H}$', r'$a_{He}$' r'$c(H\beta)$',  r'$\tau$', r'$\xi$', r'$\chi^{2}$']
# True_LowDen             = [0.08, 18000.0, 100.0, 1.0, 1.0, 0.1, 0.2, 1.0]
# True_HighDen            = [0.085, 16000.0, 500.0, 1.0, 0.5, 0.1, 1.0, 1.0]

# pattern         = Pattern_High_ne
# true_values     = True_HighDen
# Name            = 'Test_highDensity'
# article_folder  = '/home/vital/Dropbox/Astrophysics/Papers/Elemental_RegressionsSulfur/Images/'