import numpy as np
from lib.inferenceModel import SpectraSynthesizer

# Declare synthesizer object
specS = SpectraSynthesizer()

# Object data to prepare a synthetic observation
synth_data = {
    'spectra_components': ['emission', 'nebular', 'stellar'],
    'wavelengh_limits': [4000, 6900],
    'resample_inc': 1,
    'norm_interval': [5100, 5150],
    'output_folder':
    '/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/testing_output/',
    'obs_name': 'ObsHIIgalaxySynth',
    'obj_lines_file':
    '/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_objlines.txt',
    'obj_properties_file':
    '/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_objProperties.txt',
    'ssp_lib_type': 'starlight',  # TODO In here we will add "test" for the pip
    'data_folder': '/home/vital/Starlight/Bases/',
    'data_file': '/home/vital/Starlight/Bases/Dani_Bases_Extra_short.txt',
    'obj_ssp_coeffs_file':
    '/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_stellarPop.txt',
    'error_stellarContinuum': 0.01,
    'error_lines': 0.02
}
#
# # Generate the synthetic data
specS.gen_synth_obs(**synth_data)
Exemplo n.º 2
0
import numpy as np
from collections import OrderedDict
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer
from lib.Astro_Libraries.spectrum_fitting.import_functions import make_folder

# Import functions
dz = Dazer()
specS = SpectraSynthesizer()

# Declare data location
root_folder = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\bayesianModel\\'
whtSpreadSheet = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\WHT_Galaxies_properties.xlsx'

# Import data
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)

default_lines = [
    'H1_4341A', 'H1_6563A', 'He1_4471A', 'He1_5876A', 'He1_6678A', 'He2_4686A',
    'O2_7319A', 'O2_7319A_b', 'O2_7330A', 'O3_4363A', 'O3_4959A', 'O3_5007A',
    'N2_6548A', 'N2_6584A', 'S2_6716A', 'S2_6731A', 'S3_6312A', 'S3_9069A',
    'S3_9531A', 'Ar3_7136A', 'Ar4_4740A'
]

# Quick indexing
dz.quick_indexing(catalogue_df)

# Sample objects
excludeObjects = [
    'SHOC579', 'SHOC575_n2', '11', 'SHOC588', 'SDSS3', 'SDSS1', 'SHOC36'
Exemplo n.º 3
0
# headers_dic['n_e'] = r'$n_{e}[SII](cm^{-3})$'
# headers_dic['T_low'] = r'$T_{e}[SIII](K)$'
# headers_dic['T_high'] = r'$T_{e}[OIII](K)$'
# headers_dic['cHbeta'] = r'$c(H\beta)$'
headers_dic['n_e'] = r'$n_{e}[SII]$'
headers_dic['T_low'] = r'$T_{e}[SIII]$'
headers_dic['T_high'] = r'$T_{e}[OIII]$'
headers_dic['cHbeta'] = ''

# headers_dic['tau'] = r'$\tau$'
varsNum = len(headers_dic)
headers_format = [''] + headers_dic.values()

# Import functions
dz = Dazer()
specS = SpectraSynthesizer()

# Declare data location
root_folder = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\bayesianModel\\'  # root_folder = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/bayesianModel/'
article_folder = 'E:\\Dropbox\\Astrophysics\\Papers\\Yp_BayesianMethodology\\source files\\tables\\'
whtSpreadSheet = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\WHT_Galaxies_properties.xlsx'  # whtSpreadSheet = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx'

# Import data
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)

# Quick indexing
dz.quick_indexing(catalogue_df)

# Sample objects
excludeObjects = [
Exemplo n.º 4
0
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer
from lib.Astro_Libraries.spectrum_fitting.import_functions import make_folder
import shutil

# Import functions
dz = Dazer()
specS = SpectraSynthesizer()

# Declare data location
root_folder = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\bayesianModel\\'  # root_folder = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/bayesianModel/'
whtSpreadSheet = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\WHT_Galaxies_properties.xlsx'  # whtSpreadSheet = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx'
article_supplementary_folder = 'E:\\Dropbox\\Astrophysics\\Papers\\Yp_BayesianMethodology\\supplementary material online\\'
fluxes_folder = article_supplementary_folder + 'emission_line_fluxes\\'
results_folder = article_supplementary_folder + 'model_parameters\\'

# Make new folder
make_folder(fluxes_folder)
make_folder(results_folder)

# Import data
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)

default_lines = [
    'H1_4341A', 'H1_6563A', 'He1_4471A', 'He1_5876A', 'He1_6678A', 'He2_4686A',
    'O2_7319A', 'O2_7319A_b', 'O2_7330A', 'O3_4363A', 'O3_4959A', 'O3_5007A',
    'N2_6548A', 'N2_6584A', 'S2_6716A', 'S2_6731A', 'S3_6312A', 'S3_9069A',
    'S3_9531A', 'Ar3_7136A', 'Ar4_4740A'
]
import numpy as np
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer
import matplotlib.pyplot as plt

# Declare synthesizer object
specS = SpectraSynthesizer()

#Import library object
dz = Dazer()

# Object database
dataFolder = '/home/vital/SpecSynthesizer_data/'
whtSpreadSheet = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx'
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)
dz.quick_indexing(catalogue_df)

# Data root folder
root_folder = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/bayesianModel/'

# Import stellar library data
starlight_ssp = {
    'ssp_lib_type': 'starlight',
    'data_folder': '/home/vital/Starlight/Bases/',
    'data_file': '/home/vital/Starlight/Bases/Dani_Bases_Extra.txt',
    'wavelengh_limits': [3600, 6900],
    'resample_inc': 1,
    'norm_interval': [5100, 5150]
}
Exemplo n.º 6
0
            stats_dict[parameter]['mean'] = np.mean(trace_i)
            stats_dict[parameter]['median'] = np.median(trace_i)
            stats_dict[parameter]['standard deviation'] = np.std(trace_i)
            stats_dict[parameter]['n'] = trace_i.size
            stats_dict[parameter]['16th_p'] = np.percentile(trace_i, 16)
            stats_dict[parameter]['84th_p'] = np.percentile(trace_i, 84)
            stats_dict[parameter]['95% HPD interval'] = (
            stats_dict[parameter]['16th_p'], stats_dict[parameter]['84th_p'])
            stats_dict[parameter]['trace'] = trace_i

    return stats_dict


# Declare synthesizer object
specS = SpectraSynthesizer()

specS.synth_coefs = dict(He1_3889A = np.array([0.904, 1.5e-6, -0.173, -0.00054]),
                   He1_4026A = np.array([-8.12509670e-02, 1.78807195e-04, 4.31012092e+00, -1.95511656e-04]),
                   He1_4471A = np.array([-1.19176501e-01, 2.67353941e-04, 2.04665573e+00, -1.37697881e-04]),
                   He1_5876A = np.array([-2.07460883e-01, 6.03088917e-04, 7.37037512e-01, -1.13466418e-04]),
                   He1_6678A = np.array([-2.18639788e-01, 6.40026064e-04, 2.59194623e+00, -4.07583592e-04]),
                   He1_7065A = np.array([4.329, -0.0024, -0.368, -0.0017]),
                   H1_6563A = np.array([10.35,  -3.254, 0.3457]),
                   H1_4341A = np.array([0.0254, 0.1922, -0.0204]),
                   He2_4686A = np.array([12.309698048256134, -0.06407094]))

def H1_linesEmis(xy_space, a, b, c):
    temp_range, den_range = xy_space
    return a + b * np.log10(temp_range) + c * np.log10(temp_range) * np.log10(temp_range)
import numpy as np
import pandas as pd
import ConfigParser
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer
from lib.Astro_Libraries.spectrum_fitting.import_functions import parseObjData

# Declare synthesizer object
specS = SpectraSynthesizer()

#Import library object
dz = Dazer()

# Object database
dataFolder = '/home/vital/SpecSynthesizer_data/'
whtSpreadSheet = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx'
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)
dz.quick_indexing(catalogue_df)

# Data root folder
root_folder = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/bayesianModel/'

# Import stellar library data
starlight_ssp = {
    'ssp_lib_type': 'starlight',  # TODO In here we will add "test" for the pip
    'data_folder': '/home/vital/Starlight/Bases/',
    'data_file': '/home/vital/Starlight/Bases/Dani_Bases_Extra.txt',
    'wavelengh_limits': [3600, 6900],
    'resample_inc': 1,
    'norm_interval': [5100, 5150]
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer
from lib.Astro_Libraries.spectrum_fitting.import_functions import make_folder

# Import functions
dz = Dazer()
specS = SpectraSynthesizer()

# Declare data location
root_folder = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\bayesianModel\\'
whtSpreadSheet = 'E:\\Dropbox\\Astrophysics\\Data\\WHT_observations\\WHT_Galaxies_properties.xlsx'

# Import data
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)

default_lines = ['H1_4341A', 'H1_6563A', 'He1_4471A', 'He1_5876A', 'He1_6678A',
       'He2_4686A', 'O2_7319A', 'O2_7319A_b', 'O2_7330A', 'O3_4363A', 'O3_4959A',
       'O3_5007A', 'N2_6548A', 'N2_6584A', 'S2_6716A', 'S2_6731A',
       'S3_6312A', 'S3_9069A', 'S3_9531A', 'Ar3_7136A', 'Ar4_4740A']

# Quick indexing
dz.quick_indexing(catalogue_df)

# Sample objects
excludeObjects = ['SHOC579', 'SHOC575_n2', '11', 'SHOC588', 'SDSS3', 'SDSS1', 'SHOC36']  # SHOC579, SHOC575, SHOC220, SHOC588, SHOC592, SHOC036
sampleObjects = catalogue_df.loc[dz.idx_include & ~catalogue_df.index.isin(excludeObjects)].index.values

# Failing objects
listFails = []
from os import environ

environ["MKL_THREADING_LAYER"] = "GNU"
import theano
import theano.tensor as tt
import pymc3 as pm
import numpy as np
import matplotlib.pyplot as plt
from lib.inferenceModel import SpectraSynthesizer
import pymc as pm2

specS = SpectraSynthesizer()

# synth_data = {'spectra_components'      :['emission', 'nebular', 'stellar'],
#               'wavelengh_limits'        :[4200,6900],
#               'resample_inc'            :1,
#               'norm_interval'           :[5100,5150],
#               'input_ions'              :['H1r','He1r','He2r','O2','O3','Ar3','Ar4','S2','S3','N2'],
#               'output_folder'           :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/testing_output/',
#               'obs_name'                :'ObsHIIgalaxySynth',
#               'obj_lines_file'          :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_objlines.txt',
#               'obj_properties_file'     :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_objProperties.txt',
#               'ssp_lib_type'            :'starlight',  # TODO In here we will add "test" for the pip
#               'data_folder'             :'/home/vital/Starlight/Bases/',
#               'data_file'               :'/home/vital/Starlight/Bases/Dani_Bases_Extra_short.txt',
#               'obj_ssp_coeffs_file'     :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_stellarPop.txt',
#               'error_stellarContinuum'  :0.01,
#               'error_lines'             :0.02}
#
# specS.gen_synth_obs(**synth_data)
import numpy as np
from lib.inferenceModel import SpectraSynthesizer

# Declare synthesizer object
specS = SpectraSynthesizer()

# Object data to prepare a synthetic observation
synth_data = {
    'obs_name': 'synthTestHIIgalaxy',
    'output_folder':
    'E:\\Research\\article_YpBayesian\\',  #'/home/vital/article_YpBayesian/',#
    'obj_properties_file':
    'C:\\Users\\Vital\\PycharmProjects\\thesis_pipeline\\article2_material\\synth_TestObjProperties.txt',  #'/home/vital/PycharmProjects/thesis_pipeline/article2_material/synth_TestObjProperties.txt',
    'obj_lines_file':
    'C:\\Users\\Vital\\PycharmProjects\\thesis_pipeline\\article2_material\\synth_TestObjLines.txt',  #'/home/vital/PycharmProjects/thesis_pipeline/article2_material/synth_TestObjLines.txt',
    'wavelengh_limits': [4000, 6900],
    'resample_inc': 1,
    'norm_interval': [5100, 5150],
    'ssp_lib_type': 'starlight',
    'ssp_folder':
    'E:\\Research\\Starlight\\Bases\\',  #'/home/vital/Starlight/Bases/', #
    'ssp_file':
    'E:\\Research\\Starlight\\Bases\\Dani_Bases_Extra_short.txt',  #'/home/vital/Starlight/Bases/Dani_Bases_Extra_short.txt',
    'obj_ssp_coeffs_file':
    'C:\\Users\\Vital\\PycharmProjects\\thesis_pipeline\\article2_material\\synth_StellarPop.txt',  #'/home/vital/PycharmProjects/thesis_pipeline/article2_material/synth_StellarPop.txt', # ,
    'error_stellarContinuum': 0.01,
    'error_lines': 0.02,
    'atomic_data': None,
    'ftau_coeffs': None
}
Exemplo n.º 11
0
import numpy as np
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer
import matplotlib.pyplot as plt

# Import library object
dz = Dazer()
specS = SpectraSynthesizer()

# Data root folder
specS.normContants = {'He1r': 0.1, 'He2r': 0.001}
root_folder = '/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/'

# HII galaxy
model_name = 'testSimu'
outputFolder = root_folder + 'testing_output/'
specS.objName = 'ObsHIIgalaxySynth_objParams'
specS.configFile = '{}/{}_objParams.txt'.format(outputFolder, specS.objName)

# # Load the results
db_address = outputFolder + model_name + '.db'  #
inferenceTrace, db_dict = specS.load_pymc_database_manual(db_address,
                                                          sampler='pymc3')
params_list = np.array(db_dict.keys())
params_list = np.array(['T_low', 'n_e', 'He1r', 'S2'])

# Corner plot
print '--Scatter plot matrix'
trueValues = {'T_low': 12500.0, 'n_e': 125.0, 'He1r': 0.869, 'S2': 5.48}

specS.corner_plot(params_list,
from os import environ
environ["MKL_THREADING_LAYER"] = "GNU"
import theano
import theano.tensor as tt
import pymc3 as pm
import numpy as np
import matplotlib.pyplot as plt
from lib.inferenceModel import SpectraSynthesizer
import pymc as pm2

specS = SpectraSynthesizer()

# synth_data = {'spectra_components'      :['emission', 'nebular', 'stellar'],
#               'wavelengh_limits'        :[4200,6900],
#               'resample_inc'            :1,
#               'norm_interval'           :[5100,5150],
#               'input_ions'              :['H1r','He1r','He2r','O2','O3','Ar3','Ar4','S2','S3','N2'],
#               'output_folder'           :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/testing_output/',
#               'obs_name'                :'ObsHIIgalaxySynth',
#               'obj_lines_file'          :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_objlines.txt',
#               'obj_properties_file'     :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_objProperties.txt',
#               'ssp_lib_type'            :'starlight',  # TODO In here we will add "test" for the pip
#               'data_folder'             :'/home/vital/Starlight/Bases/',
#               'data_file'               :'/home/vital/Starlight/Bases/Dani_Bases_Extra_short.txt',
#               'obj_ssp_coeffs_file'     :'/home/vital/PycharmProjects/thesis_pipeline/spectrum_fitting/synth_stellarPop.txt',
#               'error_stellarContinuum'  :0.01,
#               'error_lines'             :0.02}
#
# specS.gen_synth_obs(**synth_data)

# Import observation
    return


# Ar vs S ionisation fractions relation
m_SIV_correction = un.ufloat(1.1628, 0.00559)
n_SIV_correction = un.ufloat(0.0470, 0.0097)

# Ohrs 2016 relation for the OI_SI gradient
logSI_OI_Gradient = un.ufloat(-1.53, 0.05)
OI_SI_un = umath_pow(10, -logSI_OI_Gradient)

# Constants
normContants = {'He1r': 0.1, 'He2r': 0.001}

# Declare synthesizer object
specS = SpectraSynthesizer()

#Import library object
dz = Dazer()

# Object database
dataFolder = '/home/vital/SpecSynthesizer_data/'
whtSpreadSheet = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx'
catalogue_dict = dz.import_catalogue()
catalogue_df = dz.load_excel_DF(whtSpreadSheet)
dz.quick_indexing(catalogue_df)

# Data root folder
root_folder = '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/bayesianModel/'

rawData = OrderedDict([
Exemplo n.º 14
0
import numpy as np
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer

#Generate dazer object
dz = Dazer()
specS = SpectraSynthesizer()

#Define plot frame and colors
size_dict = {
    'axes.labelsize': 28,
    'legend.fontsize': 24,
    'font.family': 'Times New Roman',
    'mathtext.default': 'regular',
    'xtick.labelsize': 24,
    'ytick.labelsize': 24
}
dz.FigConf(plotSize=size_dict)

Te = 10000.0
wave = np.arange(600, 10000, 1)
HeII_HII = 0.1
HeIII_HII = 0.001

H_He_frac = 1 + HeII_HII * 4 + HeIII_HII * 4

# Bound bound continuum
gamma_2q = specS.twoPhotonGammaCont(wave, Te)

# Free-Free continuum
gamma_ff = H_He_frac * specS.freefreeGammaCont(wave, Te, Z_ion=1.0)
from dazer_methods import Dazer
from lib.inferenceModel import SpectraSynthesizer

# Import functions
dz = Dazer()
specS = SpectraSynthesizer()

# Object data to prepare a synthetic observation
synth_data = {
    'obs_name': 'synthTestHIIgalaxy',
    'output_folder':
    'E:\\Research\\article_YpBayesian\\',  #'/home/vital/article_YpBayesian/',#
    'obj_properties_file':
    'C:\\Users\\Vital\\PycharmProjects\\thesis_pipeline\\article2_material\\synth_TestObjProperties.txt',  #'/home/vital/PycharmProjects/thesis_pipeline/article2_material/synth_TestObjProperties.txt',
    'obj_lines_file':
    'C:\\Users\\Vital\\PycharmProjects\\thesis_pipeline\\article2_material\\synth_TestObjLines.txt',  #'/home/vital/PycharmProjects/thesis_pipeline/article2_material/synth_TestObjLines.txt',
    'wavelengh_limits': [4000, 6900],
    'resample_inc': 1,
    'norm_interval': [5100, 5150],
    'ssp_lib_type': 'starlight',
    'ssp_folder':
    'E:\\Research\\Starlight\\Bases\\',  #'/home/vital/Starlight/Bases/', #
    'ssp_file':
    'E:\\Research\\Starlight\\Bases\\Dani_Bases_Extra_short.txt',  #'/home/vital/Starlight/Bases/Dani_Bases_Extra_short.txt',
    'obj_ssp_coeffs_file':
    'C:\\Users\\Vital\\PycharmProjects\\thesis_pipeline\\article2_material\\synth_StellarPop.txt',  #'/home/vital/PycharmProjects/thesis_pipeline/article2_material/synth_StellarPop.txt', # ,
    'error_stellarContinuum': 0.01,
    'error_lines': 0.02,
    'atomic_data': None,
    'ftau_coeffs': None
}