funcs module

zELDA es a phantastic code!!

funcs.Analytic_f_esc_Thin_Shell(V_Arr, logNH_Arr, ta_Arr)[source]

Return the escape fraction computed analytically for the Thin Shell (Gurung-lopez et al. 2019a)

Input:

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Arr1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Output:

fesc1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.Analytic_f_esc_Wind(V_Arr, logNH_Arr, ta_Arr)[source]

Return the escape fraction computed analytically for the Galactic Wind (Gurung-lopez et al. 2019a)

Input:

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Output:

fesc1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.Check_if_DATA_files_are_found()[source]

This function checks if all the data files are in the set directory.

Input:

None : None

Output:

Bool_1Bool

1 if found. 0 if not found.

funcs.Compute_Inflow_From_Outflow(w_Arr, f_out_Arr)[source]

Computes the line profile of an inflow from the line profiles of an outflow

Input:

w_Arr1-D sequence of floats

wavelength where the line profile is evaluated.

f_out_Arrfloat

Outflow flux density (line profile)

Output:

f_in_Arr1-D sequence of bool

Inflow flux density (line profile)

funcs.Define_wavelength_for_NN(Delta_min=- 18.5, Delta_max=18.5, Nbins_tot=1000, Denser_Center=True)[source]

This function defines the wavelength used in for the neural netwroks.

Input

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -18.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +18.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 1000

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

Output

rest_w_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the rest frame.

funcs.Generate_a_line_for_training(z_t, V_t, log_N_t, t_t, F_t, log_EW_t, W_t, PNR_t, FWHM_t, PIX_t, DATA_LyaRT, Geometry, normed=False, scaled=True, Delta_min=- 18.5, Delta_max=18.5, Denser_Center=True, Nbins_tot=1000, T_IGM_Arr=None, w_IGM_Arr=None, RETURN_ALL=False)[source]

Creates a mock line profile at the desired redshift and returns all the NN products.

Input

z_tfloat

Redshift

V_tfloat

Outflow expansion velocity [km/s]

log_N_tfloat

logarithmic of the neutral hydrogen column density in cm**-2

t_tfloat

Dust optical depth

F_tfloat

Total flux of the line. You can pass 1.

log_EW_toptional, float

Logarithmic of the rest frame intrisic equivalent width of the line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

W_toptional, float

Rest frame intrisic width of the Lyman-alpha line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

PNR_tfloat

Signal to noise ratio of the global maximum of the line profile.

FWHM_tfloat

Full width half maximum [A] of the experiment. This dilutes the line profile.

PIX_tfloat

Pixel size in wavelgnth [A] of the experiment. This binnes the line profile.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -18.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +18.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 1000

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Output

rest_w_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the rest frame.

train_line1-D sequence of float

Line profile.

z_max_ifloat

Redshift of the source if the global maximum of the spectrum is the Lyman-alpha wavelegth.

INPUT: 1-D secuence of float

The actuall input to use in the Neural networks.

funcs.Generate_a_line_for_training_II(z_t, V_t, log_N_t, t_t, F_t, log_EW_t, W_t, PNR_t, FWHM_t, PIX_t, DATA_LyaRT, Geometry, normed=False, scaled=True, Delta_min=- 10.0, Delta_max=10.0, Denser_Center=True, Nbins_tot=500, T_IGM_Arr=None, w_IGM_Arr=None)[source]

Creates a mock line profile at the desired redshift and returns all the NN products.

Input

z_tfloat

Redshift

V_tfloat

Outflow expansion velocity [km/s]

log_N_tfloat

logarithmic of the neutral hydrogen column density in cm**-2

t_tfloat

Dust optical depth

F_tfloat

Total flux of the line. You can pass 1.

log_EW_toptional, float

Logarithmic of the rest frame intrisic equivalent width of the line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

W_toptional, float

Rest frame intrisic width of the Lyman-alpha line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

PNR_tfloat

Signal to noise ratio of the global maximum of the line profile.

FWHM_tfloat

Full width half maximum [A] of the experiment. This dilutes the line profile.

PIX_tfloat

Pixel size in wavelgnth [A] of the experiment. This binnes the line profile.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -12.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +12.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 800

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Output

rest_w_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the rest frame.

train_line1-D sequence of float

Line profile.

z_max_ifloat

Redshift of the source if the global maximum of the spectrum is the Lyman-alpha wavelegth.

INPUT: 1-D secuence of float

The actuall input to use in the Neural networks.

funcs.Generate_a_real_line(z_t, V_t, log_N_t, t_t, F_t, log_EW_t, W_t, PNR_t, FWHM_t, PIX_t, DATA_LyaRT, Geometry, T_IGM_Arr=None, w_IGM_Arr=None, RETURN_ALL=False)[source]

Makes a mock line profile for the Thin_Shell_Cont geometry.

Input

z_tfloat

Redshift

V_tfloat

Outflow expansion velocity [km/s]

log_N_tfloat

logarithmic of the neutral hydrogen column density in cm**-2

t_tfloat

Dust optical depth

F_tfloat

Total flux of the line. You can pass 1.

log_EW_toptional, float

Logarithmic of the rest frame intrisic equivalent width of the line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

W_toptional, float

Rest frame intrisic width of the Lyman-alpha line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

PNR_tfloat

Signal to noise ratio of the global maximum of the line profile.

FWHM_tfloat

Full width half maximum [A] of the experiment. This dilutes the line profile.

PIX_tfloat

Pixel size in wavelgnth [A] of the experiment. This binnes the line profile.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Output

w_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the observed frame.

f_Arr1-D sequence of float

Line profile flux density in arbitrary units.

noise_Amplitude_Arr1-D sequence of float

1-sigma level of the applyed noise.

funcs.Interpolate_Lines_Arrays_3D_grid(V_Arr, logNH_Arr, logta_Arr, x_Arr, Grid_Dictionary)[source]

Computes the escape fraction using the line profiles grids for many configurations

Input:

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

Logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

x_Arr1-D sequence of floats

Frequency in Doppler units where the line prfile will be evaluated.

Grid_Dictionarypython dictionary

All the necessary information for the interpoation. Loaded with load_Grid_Line().

Output:

line_Arr2-D sequence of floats

Flux density in arbitrary units. The first dimension matches the dimension of the input configurations (e.g. V_Arr). The second dimension matches x_Arr.

funcs.Interpolate_Lines_Arrays_3D_grid_MCMC(V_Value, logNH_Value, logta_Value, x_Arr, Grid_Dictionary)[source]

Computes the escape fraction using the line profiles grids for one configuration. This is usefull for the Thin_Shell, Galactic_Wind and Bicones configurations.

Input:

V_Valuefloat

Outflow bulk velocity [km/s]

logNH_Valuefloat

Logarithm of the neutral hydrogen column density [cm**-2]

ta_Valuefloat

Dust optical depth [no dimensions]

x_Arr1-D sequence of floats

Frequency in Doppler units where the line prfile will be evaluated.

Grid_Dictionarypython dictionary

All the necessary information for the interpoation. Loaded with load_Grid_Line().

Output:

axu_line_11-D sequence of floats

Flux density in arbitrary units.

funcs.Interpolate_Lines_Arrays_5D_grid(V_Arr, logNH_Arr, logta_Arr, logEW_Arr, Wi_Arr, x_Arr, Grid_Dictionary)[source]

Computes the escape fraction using the line profiles grids for many configurations. This is usefull for the Thin_Shell_Cont

Input:

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

Logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

logEW_Arr1-D sequence of floats

Logarithm of the rest frame equivalent width [A]

Wi_Arr1-D sequence of floats

Rest frame instrinc line width [A]

x_Arr1-D sequence of floats

Frequency in Doppler units where the line prfile will be evaluated.

Grid_Dictionarypython dictionary

All the necessary information for the interpoation. Loaded with load_Grid_Line().

Output:

linew_Arr2-D sequence of floats

Flux density in arbitrary units. The first dimension matches the dimension of the input configurations (e.g. V_Arr). The second dimension matches x_Arr. Flux density in arbitrary units.

funcs.Interpolate_Lines_Arrays_5D_grid_MCMC(V_Value, logNH_Value, logta_Value, logEW_Value, Wi_Value, x_Arr, Grid_Dictionary)[source]

Computes the escape fraction using the line profiles grids for many configurations. This is usefull for the Thin_Shell_Cont

Input:

V_Valuefloat

Outflow bulk velocity [km/s]

logNH_Valuefloat

Logarithm of the neutral hydrogen column density [cm**-2]

ta_Valuefloat

Dust optical depth [no dimensions]

logEW_Valuefloat

Logarithm of the rest frame equivalent width [A]

Wi_Valuefloat

Rest frame instrinc line width [A]

x_Arr1-D sequence of floats

Frequency in Doppler units where the line prfile will be evaluated.

Grid_Dictionarypython dictionary

All the necessary information for the interpoation. Loaded with load_Grid_Line().

Output:

axu_line_11-D sequence of floats

Flux density in arbitrary units.

funcs.Interpolate_f_esc_Arrays_2D_grid(V_Arr, logNH_Arr, ta_Arr, Grid_Dictionary, Geometry)[source]

Computes the escape fraction using the escape fraction grids of parameters

Input:

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Grid_Dictionarypython dictionary

Constains the grid to compute the escape fraction. Loaded with load_Grid_fesc().

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

Output:

f_esc_Arr1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.Interpolate_fesc_Arrays_3D_grid(V_Arr, logNH_Arr, ta_Arr, Grid_Dictionary)[source]

Computes the escape fraction using the escape fraction grids of parameters

Input:

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Grid_Dictionarypython dictionary

Constains the grid to compute the escape fraction. Loaded with load_Grid_fesc().

Output:

f_esc_Arr_evaluated1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.Linear_ND_interpolator(N_dim, Coor_props_Matrix, Coor_grid_list, Field_in_grid_Matrix)[source]

Interpolates in an arbitrary dimension space

N_dimint

Number of dimensions.

Coor_props_MatrixList of N_dim float values

Coordenates in the N_dim space to evaluate. For example [ X , Y , Z ]

Coor_grid_listList of N_dim 1-D sequence of floats

For example, if there is a field evaluated in X_Arr, Y_Arr, Z_Arr [ X_Arr , Y_Arr , Z_Arr ]

Field_in_grid_Matrix : numpy array with the field to interpolate

Field_at_the_prob_point :

funcs.Load_NN_model(Mode, iteration=1)[source]

Loads the saved parameters of the deep neural networks

Input

Modestring

‘Inflow’ or ‘Outflow’

iterationoptional int

Number of the iteration. Currently only 1 Default 1

Output

machine_datapython dictionaty

Contains all the info for the DNN

funcs.MCMC_Analysis_sampler_5(w_target_Arr, f_target_Arr, s_target_Arr, FWHM, N_walkers, N_burn, N_steps, Geometry, DATA_LyaRT, log_V_in=None, log_N_in=None, log_t_in=None, z_in=None, log_E_in=None, W_in=None, progress=True, FORCE_z=False, Inflow=False)[source]

Full MCMC anaylsis for the Thin_Shell_Cont

Input

w_tar_Arr1-D sequence of floats

wavelength where the densit flux is evaluated

f_tar_Arr1-D sequence of floats

Densit flux is evaluated

s_tar_Arr1-D sequence of floats

Uncertainty of the densit flux is evaluated

FWHMfloat

Full width half maximum [A] of the experiment.

N_walkersint

Number of walkers

N_dimint

Number of dimensions (6)

N_burnint

Number of steps in the burnin-in phase

N_stepsint

Number of steps

Geometrystring

Outflow geometry to use.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometry_Modeoptinal string

Changes from inflow (‘Inflow’) to outflow (‘Outflow’) Default: ‘Outflow’

log_V_inoptional 1-D sequence of floats.

Range of the logarithm of the bulk velocity log_V_in[0] is the minimum log_V_in[1] is the maximum

log_N_inoptional 1-D sequence of floats.

Range of the logarithm of the neutral hydrogen column density log_N_in[0] is the minimum log_N_in[1] is the maximum

log_t_inoptional 1-D sequence of floats.

Range of the logarithm of the dust optical depth log_t_in[0] is the minimum log_t_in[1] is the maximum

z_inoptional 1-D sequence of floats.

Redshift range to be considered. z_in[0] is the minimum redshift z_in[1] is the maximum redshift

log_E_inoptional 1-D sequence of floats.

Range of the logarithm of the intrinsic equivalent width log_E_in[0] is the minimum log_E_in[1] is the maximum

W_inoptional 1-D sequence of floats.

Instrinsic line width range to be considered. W_in[0] is the minimum redshift W_in[1] is the maximum redshift

progressoptional bool

If True shows the MCMC progress. Default True

FORCE_zoptional bool

If True, force the redshift to be inside z_in

Inflowoptional bool

If True, fits and inflow instead of an outflow. Default False. So by default, it fits outflows.

Output

samplesemcee python packge object.

Contains the information of the MCMC.

funcs.MCMC_get_region_6D(MODE, w_tar_Arr, f_tar_Arr, s_tar_Arr, FWHM, PIX, DATA_LyaRT, Geometry, Geometry_Mode='Outflow')[source]

Computes the region of where the walkers are initialize

Input

MODEstring

Method, DNN or PSO

w_tar_Arr1-D sequence of floats

wavelength where the densit flux is evaluated

f_tar_Arr1-D sequence of floats

Densit flux is evaluated

s_tar_Arr1-D sequence of floats

Uncertainty of the densit flux is evaluated

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

w_minfloat

minimum wavelength in the observed frame [A] to use. This matches the minimum wavelgnth of wave_pix_Arr (see below).

w_maxfloat

maximum wavelength in the observed frame [A] to use. This might not be exactly the maximum wavelgnth of wave_pix_Arr (see below) due to pixelization.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Geometry_Modeoptinal string

Changes from inflow (‘Inflow’) to outflow (‘Outflow’) Default: ‘Outflow’

Output

log_V_in1-D sequence of floats.

Range of the logarithm of the bulk velocity log_V_in[0] is the minimum log_V_in[1] is the maximum

log_N_in1-D sequence of floats.

Range of the logarithm of the neutral hydrogen column density log_N_in[0] is the minimum log_N_in[1] is the maximum

log_t_in1-D sequence of floats.

Range of the logarithm of the dust optical depth log_t_in[0] is the minimum log_t_in[1] is the maximum

z_in1-D sequence of floats.

Redshift range to be considered. z_in[0] is the minimum redshift z_in[1] is the maximum redshift

log_E_in1-D sequence of floats.

Range of the logarithm of the intrinsic equivalent width log_E_in[0] is the minimum log_E_in[1] is the maximum

W_in1-D sequence of floats.

Instrinsic line width range to be considered. W_in[0] is the minimum redshift W_in[1] is the maximum redshift

funcs.NN_convert_Obs_Line_to_proxy_rest_line(w_obs_Arr, f_obs_Arr, s_obs_Arr=None, normed=False, scaled=True)[source]

Converts an observed line profile to the rest frame of the maximum of the line profile.

Input

w_obs_Arr1-D sequence of floats

wavelength where the line profile is evaluated.

f_obs_Arr1-D sequence of floats

Flux density of the observed line profile.

s_obs_Arroptional 1-D sequence of floats

Uncertainty in the flux density of the observed line profile.

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Output

w_rest_Arr1-D sequence of floats

wavelength where the line profile is evaluated in the rest frame of the global maximum

Delta_rest_Arr1-D sequence of floats

w_rest_Arr - Lyman-alpha.

f_rest_Arr1-D sequence of floats

Flux density in the rest frame of the global maximum

z_maxfloat

Redshift if the global maximum is the Lyaman-alpha wavelength

if s_obs_Arr is not None it also returns: s_rest_Arr : 1-D sequence of floats

Uncertainty of the flux density in the rest frame of the global maximum

funcs.NN_generate_random_outflow_props(N_walkers, log_V_in, log_N_in, log_t_in, Allow_Inflows=True)[source]

Generates random poperties for the Thin_Shell, Galactic_Wind, etc. (Not for Thin_Shell_Cont)

Input

N_walkersint

Number of walkers

log_V_inoptional 1-D sequence of floats.

Range of the logarithm of the bulk velocity log_V_in[0] is the minimum log_V_in[1] is the maximum

log_N_inoptional 1-D sequence of floats.

Range of the logarithm of the neutral hydrogen column density log_N_in[0] is the minimum log_N_in[1] is the maximum

log_t_inoptional 1-D sequence of floats.

Range of the logarithm of the dust optical depth log_t_in[0] is the minimum log_t_in[1] is the maximum

Allow_Inflowsoptional Bool

If True it also return negative values of V in the same range. Default True

Output

init_V_Arr1-D sequence of floats

Expansion velocity

init_log_N_Arr1-D sequence of floats

Logarithms of the column density

init_log_t_Arr1-D sequence of floats

Logarithms of the dust optical depth

funcs.NN_generate_random_outflow_props_5D(N_walkers, log_V_in, log_N_in, log_t_in, log_E_in, log_W_in, MODE='Outflow')[source]

Generates random poperties for the Thin_Shell_Cont

Input

N_walkersint

Number of walkers

log_V_inoptional 1-D sequence of floats.

Range of the logarithm of the bulk velocity log_V_in[0] is the minimum log_V_in[1] is the maximum

log_N_inoptional 1-D sequence of floats.

Range of the logarithm of the neutral hydrogen column density log_N_in[0] is the minimum log_N_in[1] is the maximum

log_t_inoptional 1-D sequence of floats.

Range of the logarithm of the dust optical depth log_t_in[0] is the minimum log_t_in[1] is the maximum

log_E_inoptional 1-D sequence of floats.

Range of the logarithm of the instrinsic equivalent width log_E_in[0] is the minimum log_E_in[1] is the maximum

log_W_inoptional 1-D sequence of floats.

Range of the logarithm of the intrinsic width of the line log_W_in[0] is the minimum log_W_in[1] is the maximum

MODEoptional string

‘Outflow’ for outflows ‘Inflow’ for inflows

Output

init_V_Arr1-D sequence of floats

Expansion velocity

init_log_N_Arr1-D sequence of floats

Logarithms of the column density

init_log_t_Arr1-D sequence of floats

Logarithms of the dust optical depth

init_log_E_Arr1-D sequence of floats

Logarithms of the instrinsic equivalent width

init_log_W_Arr1-D sequence of floats

Logarithms of the intrinsic width of the line

funcs.NN_measure(w_tar_Arr, f_tar_Arr, s_tar_Arr, FWHM_tar, PIX_tar, loaded_model, w_rest_Machine_Arr, N_iter=None, normed=False, scaled=True, Delta_min=- 18.5, Delta_max=18.5, Nbins_tot=1000, Denser_Center=True, Random_z_in=None)[source]

Generates random poperties for the Thin_Shell_Cont

Input

w_tar_Arr1-D sequence of floats

wavelength where the densit flux is evaluated

f_tar_Arr1-D sequence of floats

Densit flux is evaluated

s_tar_Arr1-D sequence of floats

Uncertainty of the densit flux is evaluated

FWHMfloat

Full width half maximum [A] of the experiment.

PIX_tarfloat

Pixelization of the line profiles due to the experiment [A]

loaded_modelpython dictionaty

Contains all the info for the DNN form Load_NN_model()

w_rest_Machine_Arr1-D sequence of floats

wavelength used by the INPUT of the DNN

N_iteroptional int

Number of Monte Carlo iterations of the observed espectrum. If None, no iteration is done. Default None

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -18.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +18.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 1000

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Random_z_inoptinal list of legnth=2

List with the minimum and maximum redshift for doing Feature importance analysis. For example [0.01,4.0]. This variable will input a random redshift with in the interval as a proxy redshift. This variable should only be used when doing a feature importance analysis. If you are not doing it, leave it as None. Otherwide you will get, probably, bad results. For example [0.01,4.0].

Output

if N_iter is None:
Sol1-D sequence of float

Array with the solution of the observed spectrum. No Monte Carlo perturbation.

z_Solfloat

Best resdhift

if N_iter is a float:

Sol and z_sol and

log_V_sol_2_Arr1-D sequence

Logarithm of the expasion velocity

log_N_sol_2_Arr1-D sequence

Logarithm of the neutral hydrogen column density

log_t_sol_2_Arr1-D sequence

Logarithm of the dust optical depth

z_sol_2_Arr1-D sequence

redshift

log_E_sol_2_Arr1-D sequence

Logarithm of the intrinsic equivalent width

log_W_sol_2_Arr1-D sequence

Logarithm of the instrinsic width of the line

funcs.NN_measure_II(w_tar_Arr, f_tar_Arr, s_tar_Arr, FWHM_tar, PIX_tar, loaded_model, w_rest_Machine_Arr, N_iter=None, normed=False, scaled=True, Delta_min=- 10.0, Delta_max=10.0, Nbins_tot=500, Denser_Center=True, Random_z_in=None)[source]

Generates random poperties for the Thin_Shell_Cont

Input

w_tar_Arr1-D sequence of floats

wavelength where the densit flux is evaluated

f_tar_Arr1-D sequence of floats

Densit flux is evaluated

s_tar_Arr1-D sequence of floats

Uncertainty of the densit flux is evaluated

FWHMfloat

Full width half maximum [A] of the experiment.

PIX_tarfloat

Pixelization of the line profiles due to the experiment [A]

loaded_modelpython dictionaty

Contains all the info for the DNN form Load_NN_model()

w_rest_Machine_Arr1-D sequence of floats

wavelength used by the INPUT of the DNN

N_iteroptional int

Number of Monte Carlo iterations of the observed espectrum. If None, no iteration is done. Default None

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -18.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +18.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 1000

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Random_z_inoptinal list of legnth=2

List with the minimum and maximum redshift for doing Feature importance analysis. For example [0.01,4.0]. This variable will input a random redshift with in the interval as a proxy redshift. This variable should only be used when doing a feature importance analysis. If you are not doing it, leave it as None. Otherwide you will get, probably, bad results. For example [0.01,4.0].

Output

if N_iter is None:
Sol1-D sequence of float

Array with the solution of the observed spectrum. No Monte Carlo perturbation.

z_Solfloat

Best resdhift

if N_iter is a float:

Sol and z_sol and

log_V_sol_2_Arr1-D sequence

Logarithm of the expasion velocity

log_N_sol_2_Arr1-D sequence

Logarithm of the neutral hydrogen column density

log_t_sol_2_Arr1-D sequence

Logarithm of the dust optical depth

z_sol_2_Arr1-D sequence

redshift

log_E_sol_2_Arr1-D sequence

Logarithm of the intrinsic equivalent width

log_W_sol_2_Arr1-D sequence

Logarithm of the instrinsic width of the line

funcs.PSO_Analysis(w_tar_Arr, f_tar_Arr, FWHM, PIX, DATA_LyaRT, Geometry, n_particles, n_iters)[source]

Does a PSO analysis to find in a fast way a close good fit

Input

w_tar_Arr1-D sequence of float

wavelength where the observed density flux is evaluated.

f_tar_Arr1-D sequence of float

Observed flux density

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

n_particlesint

Number of particles in the PSO

n_itersint

Number of steps in the PSO

Output

costfloat

Cost of the best configuration

pos1-D sequence of floats

Position of the best configuration

funcs.PSO_compute_xi_2_MANY(X, w_tar_Arr, f_tar_Arr, FWHM, PIX, DATA_LyaRT, Geometry)[source]

Compute the chi esquare for the PSO analysis for many configurations

Input

x: 1-D sequence of float
Contains the parameters of the mode:

x[0] = logarithim of the expansion velocity x[1] = logarithim of the neutral hydrogen column density x[2] = logarithim of the dust optical depth x[3] = redshift x[4] = logarithm of the intrinsic equivalent width x[5] = intrinsic width

w_tar_Arr1-D sequence of float

wavelength where the observed density flux is evaluated.

f_tar_Arr1-D sequence of float

Observed flux density

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Output

xi_2_Arr1-D sequence of float

Chi square of the configurations

funcs.PSO_compute_xi_2_ONE_6D(x, w_tar_Arr, f_tar_Arr, FWHM, PIX, DATA_LyaRT, Geometry, T_IGM_Arr=None, w_IGM_Arr=None)[source]

Compute the chi esquare for the PSO analysis

Input

x: 1-D sequence of float
Contains the parameters of the mode:

x[0] = logarithim of the expansion velocity x[1] = logarithim of the neutral hydrogen column density x[2] = logarithim of the dust optical depth x[3] = redshift x[4] = logarithm of the intrinsic equivalent width x[5] = intrinsic width

w_tar_Arr1-D sequence of float

wavelength where the observed density flux is evaluated.

f_tar_Arr1-D sequence of float

Observed flux density

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Output

xi_2float

Chi square of the configuration

w_pso_Arr1-D sequence of floats

Wavelgnth of the line profile computed by the PSO

my_f_pso_Arr1-D sequence of floats

Flux density of the line profile computed by the PSO

funcs.Prior_f(theta)[source]

Decides when a walker from the MCMC is out for the Thin_Shell, Galactic wind and bicones.

Input

theta1-D sequence of float
Contains the parameters of the mode:

theta[0] = logarithim of the expansion velocity theta[1] = logarithim of the neutral hydrogen column density theta[2] = logarithim of the dust optical depth

Output

True if the walker is inside False if the walker is outside

funcs.Prior_f_5(theta)[source]

Decides when a walker from the MCMC is out for the Thin_Shell_Cont,

Input

theta1-D sequence of float
Contains the parameters of the mode:

theta[0] = logarithim of the expansion velocity theta[1] = logarithim of the neutral hydrogen column density theta[2] = logarithim of the dust optical depth theta[3] = redshift theta[4] = logarithm of the intrinsic equivalent width theta[5] = intrinsic width

Output

True if the walker is inside False if the walker is outside

funcs.RT_Line_Profile(Geometry, wavelength_Arr, V_Arr, logNH_Arr, ta_Arr, logEW_Arr=None, Wi_Arr=None, MODE_CONT='FULL')[source]

Return the Lyman alpha line profile for a given outflow properties.

Input:

Geometrystring

The outflow geometry to use: Options: ‘Thins_Shell’, ‘Galactic_Wind’ , ‘Bicone_X_Slab’, ‘Thin_Shell_Cont’

wavelength_Arr1-D sequence of floats

Array with the wavelength vales where the line profile is computed. The units are meters, i.e., amstrongs * 1.e-10.

V_Arr1-D sequence of float

Array with the expansion velocity of the outflow. The unit are km/s.

logNH_Arr1-D sequence of float

Array with the logarithim of the outflow neutral hydrogen column density. The units of the colum density are in c.g.s, i.e, cm**-2.

ta_Arr1-D sequence of float

Array with the dust optic depth of the outflow.

ta_Value1-D sequence of bool

Dust optical depth [no dimensions]

logEW_ValueOptional 1-D sequence of bool

Logarithm of rest frame equiavlent width [A] Default = None

Wi_ValueOptional 1-D sequence of bool

Intrinsic width line in the rest frame [A] Default = None

MODEoptinal string.

For the ‘Thin_Shell_Cont’ ONLY. Defines the grid to be loaded. MODE_CONT=’FULL’ loads a very dense grid. ~12GB of RAM. MODE_CONT=’LIGHT’ loads a more sparse grid. ~ 2GB of RAM.

Output:

lines_Arr2-D sequence of float

The Lyman alpha line profiles. lines_Arr[i] is the line profile computed at the wavelengths wavelength_Arr for wich V_Arr[i] , logNH_Arr[i] , ta_Arr[i] , Inside_Bicone_Arr[i].

funcs.RT_Line_Profile_MCMC(Geometry, wavelength_Arr, V_Value, logNH_Value, ta_Value, DATA_LyaRT, logEW_Value=None, Wi_Value=None)[source]

Return one and only one Lyman alpha line profile for a given outflow properties. This function is especial to run MCMCs or PSO.

Input:

Geometrystring

The outflow geometry to use: Options: ‘Thins_Shell’, ‘Galactic_Wind’ , ‘Bicone_X_Slab’, ‘Thin_Shell_Cont’

wavelength_Arr1-D sequence of floats

Array with the wavelength vales where the line profile is computed. The units are meters, i.e., amstrongs * 1.e-10.

V_Valuefloat

Value of the expansion velocity of the outflow. The unit are km/s.

logNH_Valuefloat

Value of the logarithim of the outflow neutral hydrogen column density. The units of the colum density are in c.g.s, i.e, cm**-2.

ta_Valuefloat

Value of the dust optic depth of the outflow.

DATA_LyaRTDictionay

This dictonary have all the information of the grid. This dictionary can be loaded with the function : load_Grid_Line, for example:

DATA_LyaRT = load_Grid_Line( ‘Thin_Shell’ )

Output:

lines_Arr1-D sequence of float

The Lyman alpha line profile.

funcs.RT_f_esc(Geometry, V_Arr, logNH_Arr, ta_Arr, MODE='Parametrization', Algorithm='Intrepolation', Machine_Learning_Algorithm='Tree')[source]

Return the Lyman alpha escape fraction for a given outflow properties.

Input

Geometrystring

The outflow geometry to use: Options: ‘Thins_Shell’, ‘Galactic_Wind’ , ‘Bicone_X_Slab’.

V_Arr1-D sequence of float

Array with the expansion velocity of the outflow. The unit are km/s.

logNH_Arr1-D sequence of float

Array with the logarithim of the outflow neutral hydrogen column density. The units of the colum density are in c.g.s, i.e, cm**-2.

ta_Arr1-D sequence of float

Array with the dust optic depth of the outflow.

MODEoptional string
Set the mode in which the escape fraction is computed. It can be:

Analytic : it uses an analytic equation fitted to the output of the RT MC code. Parametrization : it computes the escape fraction using a function that depends on the

dust optical depts as in Neufeld et al. 1990.

Raw : it uses directly the output of the RT MC code.

Default = ‘Parametrization’

Algorithmoptional string
Set how the escape fraction is computed. If MODE=’Analytic’ then this varialbe is useless.

Intrepolation : Direct lineal interpolation. Machine_Learning : uses machine learning algorithms

Default = ‘Intrepolation’

Machine_Learning_Algorithmoptial string
Set the machine learning algorith used. Available:

Tree : decision tree Forest : random forest KN : KN

Default = ‘Tree’

Output

lines_Arr1-D sequence of float

The Lyman alpha escape fraction for V_Arr[i] , logNH_Arr[i] , ta_Arr[i] , Inside_Bicone_Arr[i].

funcs.RT_f_esc_Analytic(Geometry, V_Arr, logNH_Arr, ta_Arr)[source]

Return the escape fraction computed analytically (Gurung-lopez et al. 2019a, 2019b)

Input: Geometry : String

Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Arr1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Output:

fesc1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.RT_f_esc_Interpolation_Parameters(Geometry, V_Arr, logNH_Arr, ta_Arr, Machine_Learning_Algorithm=None)[source]

Computes the escape fraction using the escape fraction grids of parameters

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Machine_Learning_AlgorithmString

Kind of algorithm: ‘KN’, ‘Grad’, ‘Tree’ or ‘Forest’

Output:

f_esc_Arr1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.RT_f_esc_Interpolation_Values(Geometry, V_Arr, logNH_Arr, ta_Arr, Machine_Learning_Algorithm=None)[source]

Computes the escape fraction using the escape fraction grids of values

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Machine_Learning_AlgorithmString

Kind of algorithm: ‘KN’, ‘Grad’, ‘Tree’ or ‘Forest’

Output:

f_esc_Arr1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.RT_f_esc_Machine_Parameter(Geometry, V_Arr, logNH_Arr, ta_Arr, Machine_Learning_Algorithm='Tree')[source]

Anallytic expression of the escape fraction as a function of the dust optical depth (Gurung-lopez et al. 2019b). This uses the parametric expression of the escape fraction.

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Machine_Learning_Algorithmstring

Machine learning algorithm: ‘KN’, ‘Grad’, ‘Tree’ or ‘Forest’

Output:

f_esc_Arr1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.RT_f_esc_Machine_Values(Geometry, V_Arr, logNH_Arr, ta_Arr, Machine_Learning_Algorithm='Tree')[source]

Anallytic expression of the escape fraction as a function of the dust optical depth (Gurung-lopez et al. 2019b). This uses the directly the escape fraction.

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

Machine_Learning_Algorithmstring

Machine learning algorithm: ‘KN’, ‘Grad’, ‘Tree’ or ‘Forest’

Output:

f_esc_Arr1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.Signal_to_noise_estimator(w_Arr, Line_Arr, w_line)[source]

Estimates the signal to noise of a line profile

Input

w_Arr1-D sequence of float

wavelgnth array

Line_Arr1-D sequence float

Flux density of the line profile.

w_linefloat

wavelgnth of the line

Output

SNRfloat

Signal to noise ratio.

funcs.Test_1()[source]

Script to test if everything is working fine.

funcs.Test_2()[source]

Script to test if everything looks fine.

funcs.Treat_A_Line_To_NN_Input(w_Arr, f_Arr, PIX, FWHM, Delta_min=- 18.5, Delta_max=18.5, Nbins_tot=1000, Denser_Center=True, normed=False, scaled=True)[source]

Convert a line profile and the usefull information into the INPUT of the NN.

Input

w_Arr1-D sequence of floats

Wavelgnth of the line profile in the observed frame. [A]

f_Arr1-D sequence of floats

Flux density of the observed line profile in arbitrary units.

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -18.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +18.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 1000

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Output

rest_w_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the rest frame.

NN_line1-D sequence of float

Line profile evaluated in rest_w_Arr after normalization or scaling.

z_max_ifloat

Redshift of the source if the global maximum of the spectrum is the Lyman-alpha wavelegth.

INPUT: 1-D secuence of float

The actuall input to use in the Neural networks.

funcs.Treat_A_Line_To_NN_Input_II(w_Arr, f_Arr, PIX, FWHM, Delta_min=- 10.0, Delta_max=10.0, Nbins_tot=500, Denser_Center=True, normed=False, scaled=True)[source]

Convert a line profile and the usefull information into the INPUT of the NN.

Input

w_Arr1-D sequence of floats

Wavelgnth of the line profile in the observed frame. [A]

f_Arr1-D sequence of floats

Flux density of the observed line profile in arbitrary units.

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

Delta_minoptional float

Defines the minimum rest frame wavelegnth with respecto to Lyman-alpha.

Default = -18.5

Delta_minoptional float

Defines the maximum rest frame wavelegnth with respecto to Lyman-alpha.

Default = +18.5

Nbins_totoptional int

Total number of wvelgnths bins.

Default = 1000

Denser_Centeroptional bool

Populates denser the regions close to Lyman-alpha

Default = True

normedoptional bool

If True, nomalizes the line profile.

scaledoptinal bool

If True, divides the line profile by its maximum.

Output

rest_w_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the rest frame.

NN_line1-D sequence of float

Line profile evaluated in rest_w_Arr after normalization or scaling.

z_max_ifloat

Redshift of the source if the global maximum of the spectrum is the Lyman-alpha wavelegth.

INPUT: 1-D secuence of float

The actuall input to use in the Neural networks.

funcs.bin_one_line(wave_Arr_line, Line_Prob_Arr, new_wave_Arr, Bin, same_norm=False)[source]

This functions bins the line profile mimicking the pixelization in a CCD.

Input

wave_Arr_line1-D sequence of float

Array with the Wavelength where the spectrum is evaluated. Same units as Bin. This has to be sorted.

Line_Prob_Arr1-D sequence of float

Arrays with the flux of the spectrum.

new_wave_Arr1-D sequence of float

Array with the nex wavelgnth where the fline profile will be interpolated

Binfloat

Bin size.

same_normoptional bool.

If true return a line with the same normalization as the input

Output

binned_line1-D sequence of float

Spectrum after the convolution

funcs.convert_gaussian_FWHM_to_sigma(FWHM_Arr)[source]

This function computes the sigma of a gaussian from its FWHM.

Input

FWHM_Arr1-D sequence of float

Array with the Full Width Half Maximum that you want to convert

Output

sigma_Arr1-D sequence of float

The width of the FWHM_Arr

funcs.convert_lamda_into_x(lamda, T4=None)[source]

This function converts from frequency in Doppler units to wavelength

Input:

lamda1-D sequence of float

wavelength

T4optional float

Temperature in units of 10**4 K: T4 = T[k] / 10**4

Output:

x_Arr1-D sequence of float

Frequency in Doppler units.

funcs.convert_x_into_lamda(x, T4=None)[source]

This function converts from frequency in Doppler units to wavelength

Input:

x1-D sequence of float

Frequency in Doppler units.

T4optional float

Temperature in units of 10**4 K: T4 = T[k] / 10**4

Output:

w_Arr1-D sequence of float

wavelength.

funcs.define_RT_parameters(T4=None)[source]

This function gives the parameters use to compute useful variables when working with radiative transfer.

Input:

T4optional float

Temperature in units of 10**4 K: T4 = T[k] / 10**4

Output:

nu0float

Lyaman-alpha frequency.

Dv : float

funcs.dilute_line(wave_Arr, Spec_Arr, FWHM)[source]

This functions dilutes a given spectrum by convolving with a gaussian filter.

Input

wave_Arr1-D sequence of float

Array with the Wavelength where the spectrum is evaluated. Same units as FWHM_Arr. This has to be sorted.

Spec_Arr1-D sequence of float

Arrays with the flux of the spectrum.

FWHM_Arr1-D sequence of float

Array with the Full width half maximuum of of the gaussian to convolve. If FWHM_Arr is a single value, it uses the same value across the x_Arr range. If FWHM is a 1-D sequence, a different value of width of the gaussian is used. In this case, the length of this array has to be the same as wave_Arr and Spec_Arr.

same_normoptional bool.

If true return a line with the same normalization as the input

Output

new_Line1-D sequence of float

Spectrum after the convolution

funcs.dilute_line_changing_FWHM(wave_Arr, Spec_Arr, FWHM_Arr, same_norm=False)[source]

This functions dilutes a given spectrum by convolving with a gaussian filter.

Input

wave_Arr1-D sequence of float

Array with the Wavelength where the spectrum is evaluated. Same units as FWHM_Arr. This has to be sorted.

Spec_Arr1-D sequence of float

Arrays with the flux of the spectrum.

FWHM_Arr1-D sequence of float

Array with the Full width half maximuum of of the gaussian to convolve. If FWHM_Arr is a single value, it uses the same value across the x_Arr range. If FWHM is a 1-D sequence, a different value of width of the gaussian is used. In this case, the length of this array has to be the same as wave_Arr and Spec_Arr.

same_normoptional bool.

If true return a line with the same normalization as the input

Output

new_Line1-D sequence of float

Spectrum after the convolution

funcs.fesc_of_ta_Bicone(ta, CCC, KKK, LLL)[source]

Anallytic expression of the escape fraction as a function of the dust optical depth (Gurung-lopez et al. 2019b)

Input:

ta1-D sequence of floats

Dust optical depth [no dimensions]

CCCfloat

CCC parameter

KKKfloat

KKK parameter

LLLfloat

LLL parameter

Output:

fesc1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.fesc_of_ta_Thin_and_Wind(ta, CCC, KKK)[source]

Anallytic expression of the escape fraction as a function of the dust optical depth (Gurung-lopez et al. 2019a)

Input:

ta1-D sequence of floats

Dust optical depth [no dimensions]

CCCfloat

CCC parameter

KKKfloat

KKK parameter

Output:

fesc1-D sequence of floats

Escape fractions for the input configurations [no dimensions]

funcs.gaus(x_Arr, A, mu, sigma)[source]

Retruns a gaussian evaluated in x_Arr.

Input

x_Arr1-D sequence of float

Where the gaussian has to be evaluated.

Afloat

Amplitude

mufloat

Mean

sigmafloat

width

Output

gauss_Arr1-D sequence of float

Gaussian

funcs.generate_a_REAL_line_Noise_w(z_f, V_f, logNH_f, ta_f, F_line_f, logEW_f, Wi_f, Noise_w_Arr, Noise_Arr, FWHM_f, PIX_f, w_min, w_max, DATA_LyaRT, Geometry, T_IGM_Arr=None, w_IGM_Arr=None)[source]

Makes a mock line profile for the Thin_Shell_Cont geometry.

Input

z_ffloat

Redshift

V_ffloat

Outflow expansion velocity [km/s]

logNH_ffloat

logarithmic of the neutral hydrogen column density in cm**-2

ta_ffloat

Dust optical depth

logEW_foptional, float

Logarithmic of the rest frame intrisic equivalent width of the line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

Wi_foptional, float

Rest frame intrisic width of the Lyman-alpha line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

Noise_w_Arr1-D sequence of float

wavelength array where the noise pattern is evaluated.

Noise_Arr1-D sequence of float

Noise pattern. Evolution of the noise as a function of wavelength (Noise_w_Arr)

FWHM_ffloat

Full width half maximum [A] of the experiment. This dilutes the line profile.

PIX_ffloat

Pixel size in wavelgnth [A] of the experiment. This binnes the line profile.

w_minfloat

minimum wavelength in the observed frame [A] to use. This matches the minimum wavelgnth of wave_pix_Arr (see below).

w_maxfloat

maximum wavelength in the observed frame [A] to use. This might not be exactly the maximum wavelgnth of wave_pix_Arr (see below) due to pixelization.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

Output

wave_pix_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the observed frame.

noisy_Line_Arr1-D sequence of float

Line profile flux density in arbitrary units.

dicpython dictionaty.
Contains all the meta data used to get the line profiles:

‘w_rest’ : restframe wavelength of line before reducing quality ‘w_obs’ : wavelength of line before reducing quality ‘Intrinsic’ : line profile before quality reduction ‘Diluted’ : Line profile after the FWHM has been applyed. ‘Pixelated’ : Line profile after the FWHM and PIX have been applyed ‘Noise’ : Particular noise patern used.

funcs.generate_a_obs_line(z_f, V_f, logNH_f, ta_f, DATA_LyaRT, Geometry, logEW_f=None, Wi_f=None, T_IGM_Arr=None, w_IGM_Arr=None, RETURN_ALL=False)[source]

Moves in redshift a line profile.

Input

z_ffloat

Redshift

V_ffloat

Outflow expansion velocity [km/s]

logNH_ffloat

logarithmic of the neutral hydrogen column density in cm**-2

ta_ffloat

Dust optical depth

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

logEW_foptional, float

Logarithmic of the rest frame intrisic equivalent width of the line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

Wi_foptional, float

Rest frame intrisic width of the Lyman-alpha line [A] Requiered if Geometry == ‘Thin_Shell_Cont’

Output

w_rest_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the rest frame.

wavelength_Arr1-D sequence of float

Wavelgnth array where the line is evaluated in the observed frame.

line_Arr1-D sequence of float

Line profile flux density in arbitrary units.

funcs.get_solutions_from_flat_chain(flat_chains, Q_Arr)[source]

function to get the solution from the emcee sampler sin some given percentiles.

Input

flat_samples2-D sequence of floats

The MCMC chains but flat.

Q_Arr1-D list of floats

List of the percentiles that will be computed, for example [ 16.0 , 50.0 , 84.0 ]

Output

matrix_sol: 2-D sequence of floats

The percentiles of each of the 6 properties.

funcs.get_solutions_from_sampler(sampler, N_walkers, N_burn, N_steps, Q_Arr)[source]

function to get the solution from the emcee sampler sin some given percentiles.

Input

sampleremcee python packge object.

Contains the information of the MCMC.

N_walkersint

Number of walkers

N_burnint

Number of steps in the burnin-in phase

N_stepsint

Number of steps

Q_Arr1-D list of floats

List of the percentiles that will be computed, for example [ 16.0 , 50.0 , 84.0 ]

Output

matrix_sol: 2-D sequence of floats

The percentiles of each of the 6 properties.

flat_samples2-D sequence of floats

The MCMC chains but flat.

funcs.get_solutions_from_sampler_mean(sampler, N_walkers, N_burn, N_steps)[source]

function to get the solution from the emcee sampler as the mean.

Input

sampleremcee python packge object.

Contains the information of the MCMC.

N_walkersint

Number of walkers

N_burnint

Number of steps in the burnin-in phase

N_stepsint

Number of steps

Output

matrix_sol: 1-D sequence of floats

Mean of each of the 6 properties.

flat_samples2-D sequence of floats

The MCMC chains but flat.

funcs.get_solutions_from_sampler_peak(sampler, N_walkers, N_burn, N_steps, N_hist_steps)[source]

function to get the solution from the emcee sampler as the global maximum of the distribution of the posteriors.

Input

sampleremcee python packge object.

Contains the information of the MCMC.

N_walkersint

Number of walkers

N_burnint

Number of steps in the burnin-in phase

N_stepsint

Number of steps

N_hist_stepsint

Number of bins to sample the PDF of all properties

Output

matrix_sol: 1-D sequence of floats

Mean of each of the 6 properties.

flat_samples2-D sequence of floats

The MCMC chains but flat.

funcs.init_walkers_5(N_walkers, N_dim, log_V_in, log_N_in, log_t_in, z_in, log_E_in, W_in)[source]

Creates the initial position for the walkers

Input

N_walkersint

Number of walkers

N_dimint

Number of dimensions (6)

log_V_in1-D sequence of floats.

Range of the logarithm of the bulk velocity log_V_in[0] is the minimum log_V_in[1] is the maximum

log_N_in1-D sequence of floats.

Range of the logarithm of the neutral hydrogen column density log_N_in[0] is the minimum log_N_in[1] is the maximum

log_t_in1-D sequence of floats.

Range of the logarithm of the dust optical depth log_t_in[0] is the minimum log_t_in[1] is the maximum

z_in1-D sequence of floats.

Redshift range to be considered. z_in[0] is the minimum redshift z_in[1] is the maximum redshift

log_E_in1-D sequence of floats.

Range of the logarithm of the intrinsic equivalent width log_E_in[0] is the minimum log_E_in[1] is the maximum

W_in1-D sequence of floats.

Instrinsic line width range to be considered. W_in[0] is the minimum redshift W_in[1] is the maximum redshift

Output

theta_01-D sequence of float
Contains the parameters of the mode:

theta_0[:,0] = logarithim of the expansion velocity theta_0[:,1] = logarithim of the neutral hydrogen column density theta_0[:,2] = logarithim of the dust optical depth theta_0[:,3] = redshift theta_0[:,4] = logarithm of the intrinsic equivalent width theta_0[:,5] = intrinsic width

funcs.load_Grid_Line(Geometry, MODE='FULL')[source]

Return the dictionary with all the properties of the grid where the lines were run.

Input

Geometrystring

The outflow geometry to use: Options: ‘Thins_Shell’, ‘Galactic_Wind’ , ‘Bicone_X_Slab_In’, ‘Bicone_X_Slab_Out’, ‘Thin_Shell_Cont’.

MODEoptinal string.

For the ‘Thin_Shell_Cont’ ONLY. Defines the grid to be loaded. MODE=’FULL’ loads a very dense grid. ~12GB of RAM. MODE=’LIGHT’ loads a more sparse grid. ~ 2GB of RAM.

Output

loaded_modelDictionary

This dictonary have all the information of the grid. Entries:

‘V_Arr’ : Array of velocity expansions used.[km/s] ‘logNH_Arr’ : Array of logarithm of the column density. [c.g.s.] ‘logta_Arr’ : Array of logarithm of the dust optical depth. ‘x_Arr’ : Array of frequency in Doppler units. ‘Grid’ : Array with the output of the RT MC code LyaRT:

loaded_model[‘Grid’][i,j,k,:] has the line profile evaluated in loaded_model[‘x_Arr’] with outflow velocity loaded_model[‘V_Arr’][i] , logarithm of the neutral hydrogen column density loaded_model[‘logNH_Arr’][j] and logarithm of dust optical depth loaded_model[‘logta_Arr’][k]

funcs.load_Grid_fesc(Geometry, MODE)[source]

This functions gives you grids of the escape fraction

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

MODEString

Parametrization of the escape fraction. ‘Parameters’ or ‘values’

Output:

loaded_model : file the grid of f_esc parameters/values.

funcs.load_machine_fesc(Machine, property_name, Geometry)[source]

This functions gives you the trained model that you want to use.

Input:

MachineString

Kind of algorithm: ‘KN’, ‘Grad’, ‘Tree’ or ‘Forest’

property_nameString

The variable to import: ‘KKK’ , ‘CCC’ , ‘LLL’ or ‘f_esc’

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

Output:

loaded_model : file with all the necesary to do machine learning

funcs.log_likeliehood_of_model_5(theta, w_obs_Arr, f_obs_Arr, s_obs_Arr, FWHM, PIX, w_min, w_max, DATA_LyaRT, Geometry, z_in, FORCE_z=False, Inflow=False, T_IGM_Arr=None, w_IGM_Arr=None)[source]

Logarithm of the likelihood between an observed spectrum and a model configuration defined in theta

Input

theta1-D sequence of float
Contains the parameters of the mode:

theta[0] = logarithim of the expansion velocity theta[1] = logarithim of the neutral hydrogen column density theta[2] = logarithim of the dust optical depth theta[3] = redshift theta[4] = logarithm of the intrinsic equivalent width theta[5] = intrinsic width

w_obs_Arr1-D sequence of float

wavelength where the observed density flux is evaluated.

f_obs_Arr1-D sequence of float

Observed flux density

s_obs_Arr1-D sequence of float

Uncertanty in the observed flux density.

FWHMfloat

Full width half maximum [A] of the experiment.

PIXfloat

Pixel size in wavelgnth [A] of the experiment.

w_minfloat

minimum wavelength in the observed frame [A] to use. This matches the minimum wavelgnth of wave_pix_Arr (see below).

w_maxfloat

maximum wavelength in the observed frame [A] to use. This might not be exactly the maximum wavelgnth of wave_pix_Arr (see below) due to pixelization.

DATA_LyaRTpython dictionary

Contains the grid information.

Geometrystring

Outflow geometry to use.

z_in1-D sequence of floats.

Redshift range to be considered. In principle the redshift can be outside z_in[0] is the minimum redshift z_in[1] is the maximum redshift

FORCE_zoptional bool

If True, force the redshift to be inside z_in

Inflowoptional bool

If True, fits and inflow instead of an outflow. Default False. So by default, it fits outflows.

Output

log_likefloat

Logarithm of the likelihood

funcs.log_likelihood(w_obs_Arr, f_obs_Arr, s_obs_Arr, w_model_Arr, f_model_Arr)[source]

Logarithm of the likelihood between an observed spectrum and a model spectrum.

Input

w_obs_Arr1-D sequence of float

wavelength where the observed density flux is evaluated.

f_obs_Arr1-D sequence of float

Observed flux density

s_obs_Arr1-D sequence of float

Uncertanty in the observed flux density.

w_model_Arr1-D sequence of float

wavelength where the model density flux is evaluated

f_model_Arr1-D sequence of float

Model flux density

Output

log_likefloat

Logarithm of the likelihood

funcs.plot_a_rebinned_line(new_wave_Arr, binned_line, Bin)[source]

This functions is used to plot line profiles. It transforms the line line in a histogram.

Input

new_wave_Arr1-D sequence of float

Array with the Wavelength where the spectrum is evaluated.

binned_line1-D sequence of float

Arrays with the flux of the spectrum.

Binfloat

Bin size.

Output

XX_Arr1-D sequence of float

Wavelength where the new line is evaluated

YY_Arr1-D sequence of float

Flux density array

funcs.pre_treatment_Line_profile(Geometry, V_Arr, logNH_Arr, ta_Arr, logEW_Arr=None, Wi_Arr=None)[source]

Checks the inflow/outflow parameters before doing the proper computation.

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’
, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’,

‘Thin_Shell_Cont’

V_Value1-D sequence of bool

Outflow bulk velocity [km/s]

logNH_Value1-D sequence of bool

logarithm of the neutral hydrogen column density [cm**-2]

ta_Value1-D sequence of bool

Dust optical depth [no dimensions]

logEW_ValueOptional 1-D sequence of bool

Logarithm of rest frame equiavlent width [A] Default = None

Wi_ValueOptional 1-D sequence of bool

Intrinsic width line in the rest frame [A] Default = None

Output:

Bool_good1-D sequence of bool

1 if the parameters are good, 0 if they are bad.

funcs.pre_treatment_Line_profile_MCMC(Geometry, V_Value, logNH_Value, ta_Value, logEW_Value=None, Wi_Value=None)[source]

Checks the inflow/outflow parameters before doing the proper computation.

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’
, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

‘Thin_Shell_Cont’

V_Valuefloat

Outflow bulk velocity [km/s]

logNH_Valuefloat

logarithm of the neutral hydrogen column density [cm**-2]

ta_Valuefloat

Dust optical depth [no dimensions]

logEW_ValueOptinal float

Logarithm of rest frame equiavlent width [A] Default = None

Wi_ValueOptinal float

Intrinsic width line in the rest frame [A] Default = None

Output:

Bool_good1-D sequence of bool

1 if the parameters are good, 0 if they are bad.

funcs.pre_treatment_f_esc(Geometry, V_Arr, logNH_Arr, ta_Arr, MODE)[source]

Checks the inflow/outflow parameters before doing the proper computation.

Input:

GeometryString
Outflow configuration to use: ‘Thin_Shell’ , ‘Galactic_Wind’

, ‘Bicone_X_Slab_In’ , ‘Bicone_X_Slab_Out’

V_Arr1-D sequence of floats

Outflow bulk velocity [km/s]

logNH_Ar1-D sequence of floats

logarithm of the neutral hydrogen column density [cm**-2]

ta_Arr1-D sequence of floats

Dust optical depth [no dimensions]

MODEoptional string
Set the mode in which the escape fraction is computed. It can be:

Analytic : it uses an analytic equation fitted to the output of the RT MC code. Parametrization : it computes the escape fraction using a function that depends on the

dust optical depts as in Neufeld et al. 1990.

Raw : it uses directly the output of the RT MC code.

Default = ‘Parametrization’

Kind of algorithm: ‘KN’, ‘Grad’, ‘Tree’ or ‘Forest’

Output:

mask_good1-D sequence of bool

1 if the parameters are good, 0 if they are bad.