Skip to content

Commit 65f5dc5

Browse files
committed
Add replace_oiii4363 function
- Update flux_dict - Change indentation so detection is always defined with binned_data=True
1 parent 68936e5 commit 65f5dc5

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

Metallicity_Stack_Commons/analysis/error_prop.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
from .ratios import flux_ratios
1313
from .temp_metallicity_calc import temp_calculation, metallicity_calculation
1414
from .attenuation import compute_EBV
15-
from .. import line_name
15+
from .. import line_name, line_name_short
1616
from ..logging import log_stdout, log_verbose
17+
from .fitting import OIII4363_flux_limit
1718

1819

1920
def write_npz(path: str, npz_files: list, dict_list: list,
@@ -41,6 +42,18 @@ def write_npz(path: str, npz_files: list, dict_list: list,
4142
log_verbose(log, "finished.", verbose=verbose)
4243

4344

45+
def replace_oiii4363(flux_file: str, detection: np.ndarray,
46+
flux_dict: dict,
47+
log: Logger = log_stdout()):
48+
49+
flux_limit = OIII4363_flux_limit(flux_file, log=log)
50+
51+
non_det = np.where(detection == 0.5)[0]
52+
flux_dict[line_name_short['4363']][non_det] = flux_limit[non_det]
53+
54+
return flux_dict
55+
56+
4457
def fluxes_derived_prop(path: str, raw: bool = False,
4558
binned_data: bool = True, apply_dust: bool = False,
4659
revised: bool = True, verbose: bool = False,
@@ -97,15 +110,15 @@ def fluxes_derived_prop(path: str, raw: bool = False,
97110
flux_tab0 = asc.read(flux_file)
98111

99112
if binned_data:
100-
if not raw:
101-
log.info(f"Reading : {verify_file}")
102-
verify_tab = asc.read(verify_file)
103-
detection = verify_tab['Detection'].data
113+
log.info(f"Reading : {verify_file}")
114+
verify_tab = asc.read(verify_file)
115+
detection = verify_tab['Detection'].data
104116

105-
# For now we are only considering those with reliable detection and
106-
# excluding those with reliable non-detections (detect = 0.5)
107-
detect_idx = np.where((detection == 1))[0]
117+
# For now we are only considering those with reliable detection and
118+
# excluding those with reliable non-detections (detect = 0.5)
119+
detect_idx = np.where((detection == 1))[0]
108120

121+
if not raw:
109122
ID = verify_tab['bin_ID'].data
110123
ID_detect = ID[detect_idx]
111124
log.info(ID_detect)
@@ -130,6 +143,7 @@ def fluxes_derived_prop(path: str, raw: bool = False,
130143
# Fill in dictionary
131144
flux_dict[line_name[aa]] = flux_tab0[flux].data
132145

146+
flux_dict = replace_oiii4363(flux_file, detection, flux_dict)
133147
flux_ratios_dict = flux_ratios(flux_dict, binned_data=binned_data,
134148
verbose=verbose, log=log)
135149

0 commit comments

Comments
 (0)