Skip to content

Commit

Permalink
Merge branch 'release/0.4.0' (PR #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed Mar 1, 2020
2 parents 736f975 + ca5d3d7 commit 9c42b94
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 2 deletions.
136 changes: 136 additions & 0 deletions Metallicity_Stack_Commons/column_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
from . import line_name, line_type


# Need to define here
def line_fit_suffix_add(line_name0, line_type0):
"""
Purpose:
Simple list comprehension combining emission line fit suffixes with
the emission line. This works for individual lines
:param line_name0: str containing the line name
:param line_type0: str containing the emisison-line type (e.g., 'Balmer')
:return: gauss_lines_names: list with str formatted as [LINE]_[SUFFIX]
"""

gauss_lines_names = ['{}_{}'.format(line_name0, suffix) for suffix in gauss_names0]
if line_type0 == 'Balmer':
gauss_lines_names += ['{}_{}'.format(line_name0, suffix) for suffix in balmer_names0]

return gauss_lines_names


# These are common/general column names

# Column names for bin information
bin_names0 = ['bin_ID', 'N_stack', 'Detection']

# Column names for individual galaxies/spectra
indv_names0 = ['ID', 'logR23', 'logO32', 'logM', 'logLHb', 'two_beta', 'three_beta']

# Dust attenuation
dust0 = ['E(B-V)', 'HgHb', 'HdHb']

# Column names for bin information in stellar mass and H-beta luminosity
bin_mzevolve_names0 = ['logM_min', 'logM_max', 'logM_avg', 'logM_median',
'logLHb_min', 'logLHb_max', 'logLHb_avg', 'logLHb_median']

# Column names for bin information in R23 and O32 line ratios
bin_zcalbase_names0 = ['logR23_min', 'logR23_max', 'logR23_avg', 'logR23_median',
'logO32_min', 'logO32_max', 'logO32_avg', 'logO32_median']

# Column names for composite line ratios
bin_ratios0 = ['logR23_composite', 'logO32_composite',
'two_beta_composite', 'three_beta_composite']

# Column names for Gaussian fitting
# This is just the suffix
gauss_names0 = ['Flux_Gaussian', 'Flux_Observed', 'S/N', 'Center', 'Norm',
'Median', 'Sigma']
balmer_names0 = ['Abs_Norm', 'Abs_Sigma']

# Emission-line fit column names with [LINE] prefix
gauss_lines_names0 = []
for line0, type0 in zip(line_name, line_type):
gauss_lines_names0 += line_fit_suffix_add(line0, type0)


# Temperature and metallicity properties
temp_metal_names0 = ['T_e', '12+log(O/H)', 'log(O+/H)', 'log(O++/H)', 'O+/H', 'O++/H']

# Dictionary containing filenames
filename_dict = dict()

# Bin-related files
filename_dict['bin_info'] = 'bin_info.tbl'
filename_dict['bin_valid'] = 'bin_validation.tbl'
filename_dict['bin_fit'] = 'bin_emission_line_fit.tbl'
filename_dict['bin_fit_rev'] = filename_dict['bin_fit'].replace('.tbl', '.revised.tbl')
filename_dict['bin_derived_prop'] = 'bin_derived_properties.tbl'
filename_dict['bin_derived_prop_rev'] = filename_dict['bin_derived_prop'].replace('.tbl', '.revised.tbl')

# Individual galaxy/spectra-related files
filename_dict['indv_prop'] = 'individual_properties.tbl'
filename_dict['indv_bin_info'] = 'individual_bin_info.tbl'
filename_dict['indv_derived_prop'] = 'individual_derived_properties.tbl'


def merge_column_names(*args):
"""
Purpose:
Merges multiple lists containing column names.
Usage:
column_names = merge_column_names(bin_names0, indv_names0)
:param args: An undefined number of lists
:return merge_list:
"""

merge_list = list()

arg_count = len(args)
if arg_count > 0:
for elem in args:
merge_list += elem

return merge_list


def remove_from_list(list0, remove_entries):
"""
Purpose:
Remove entries from list
:param list0: list of column names
:param remove_entries: list of column names to remove
"""

dup_list0 = list0.copy()

for entry in remove_entries:
dup_list0.remove(entry)

return dup_list0


def indv_R23_O32():
"""
Purpose:
Use remove_from_list() to provide simplified list that contains ID, logR23 and logO32
:return: list containing just ID, logR23, logO32
"""

return remove_from_list(indv_names0, ['logM', 'logLHb'])


def indv_M_LHb():
"""
Purpose:
Use remove_from_list() to provide simplified list that contains ID, logM and logLHb
:return: list containing just ID, logM, logLHb
"""

return remove_from_list(indv_names0, ['logR23', 'logO32'])
7 changes: 5 additions & 2 deletions Metallicity_Stack_Commons/temp_metallicity_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from . import k_dict

from .column_names import temp_metal_names0, remove_from_list

k_4363 = k_dict['OIII_4363']
k_5007 = k_dict['OIII_5007']

Expand Down Expand Up @@ -73,7 +75,8 @@ def metallicity_calculation(T_e, TWO_BETA, THREE_BETA):
com_O = O_s_ion + O_d_ion
com_O_log = np.log10(com_O) + 12

metal_dict = dict(O_s_ion=O_s_ion, O_d_ion=O_d_ion,
O_s_ion_log=O_s_ion_log, O_d_ion_log=O_d_ion_log)
key_dict = remove_from_list(temp_metal_names0, ['T_e', '12+log(O/H)'])
key_values = [O_s_ion_log, O_d_ion_log, O_s_ion, O_d_ion] # Order matters here
metal_dict = dict(zip(key_dict, key_values))

return com_O_log, metal_dict

0 comments on commit 9c42b94

Please sign in to comment.