synthesizer.emissions.utils¶
A submodule containing utility functions for working with emissions.
This module contains functions for converting between different line identifiers, calculating attenuation and transmission, and flattening lists of lines. It also includes functions for working with spectral energy distributions (SEDs) and calculating attenuation at specific wavelengths.
Example usage:
# Example usage of the functions line_id = [“H 1 4861.32A”, “H 1 6562.80A”] composite_line_id = get_composite_line_id_from_list(line_id) print(composite_line_id) # Output: “H 1 4861.32A, H 1 6562.80A”
# Example usage of the get_line_label function line_label = get_line_label(line_id) print(line_label) # Output: “HII4861.32A+HII6562.80A”
# Example usage of the flatten_linelist function list_to_flatten = [[“H 1 4861.32A”], [“H 1 6562.80A”]] flattened_list = flatten_linelist(list_to_flatten) print(flattened_list) # Output: [“H 1 4861.32A”, “H 1 6562.80A”]
# Example usage of the get_transmission function intrinsic_sed = Sed(…) attenuated_sed = Sed(…) transmission = get_transmission(intrinsic_sed, attenuated_sed)
# Example usage of the get_attenuation function intrinsic_sed = Sed(…) attenuated_sed = Sed(…) attenuation = get_attenuation(intrinsic_sed, attenuated_sed)
# Example usage of the get_attenuation_at_lam function lam = 5500.0 * angstrom intrinsic_sed = Sed(…) attenuated_sed = Sed(…) attenuation_at_lam = get_attenuation_at_lam(
lam, intrinsic_sed, attenuated_sed
)
Functions
- synthesizer.emissions.utils.alias_to_line_id(alias)[source]¶
Convert a line alias to a line id.
- Parameters:
alias (str) – The line alias.
- Returns:
The line id.
- Return type:
line_id (str)
- synthesizer.emissions.utils.combine_list_of_seds(sed_list)[source]¶
Convert a list of Seds into a single Sed object.
Combines a list of Sed objects (length Ngal) into a single Sed object, with dimensions Ngal x Nlam. Each Sed object in the list should have an identical wavelength range.
- Parameters:
sed_list (list) – list of Sed objects
- synthesizer.emissions.utils.flatten_linelist(list_to_flatten)[source]¶
Flatten a mixed list of lists and strings and remove duplicates.
Used when converting a line list which may contain single lines and doublets.
- Parameters:
list_to_flatten (list) – list containing lists and/or strings and integers
- Returns:
flattened list
- Return type:
(list)
- synthesizer.emissions.utils.get_attenuation(intrinsic_sed, attenuated_sed)[source]¶
Calculate attenuation as a function of wavelength.
- synthesizer.emissions.utils.get_attenuation_at_1500(intrinsic_sed, attenuated_sed)[source]¶
Calculate rest-frame FUV attenuation at 1500 angstrom.
- synthesizer.emissions.utils.get_attenuation_at_5500(intrinsic_sed, attenuated_sed)[source]¶
Calculate rest-frame FUV attenuation at 5500 angstrom.
- synthesizer.emissions.utils.get_attenuation_at_lam(lam, intrinsic_sed, attenuated_sed)[source]¶
Calculate attenuation at a given wavelength.
- Parameters:
- Returns:
- float/np.ndarray of float
The attenuation at the passed wavelength/s in magnitudes.
- synthesizer.emissions.utils.get_composite_line_id_from_list(id)[source]¶
Convert a list of line ids to a string describing a composite line.
A composite line is a line that is made up of multiple lines, e.g. a doublet or triplet. This function takes a list of line ids and converts them to a single string.
e.g. [“H 1 4861.32A”, “H 1 6562.80A”] -> “H 1 4861.32A, H 1 6562.80A”
- Parameters:
id (list, tuple) – a str, list, or tuple containing the id(s) of the lines
- Returns:
string representation of the id
- Return type:
id (str)
- synthesizer.emissions.utils.get_line_label(line_id)[source]¶
Get a line label for a given line_id, ratio, or diagram.
Where the line_id is one of several predifined lines in line_labels this label is used, otherwise the label is constructed from the line_id.
- Argumnents
- line_id (str):
The line_id either as a list of individual lines or a string. If provided as a list this is automatically converted to a single string so it can be used as a key.
- Returns:
A nicely formatted line label.
- Return type:
line_label (str)
- synthesizer.emissions.utils.get_roman_numeral(number)[source]¶
Convert an integer into a roman numeral str.
Used for renaming emission lines from the cloudy defaults.
- Parameters:
number (int) – The number to convert into a roman numeral.
- Returns:
String reprensentation of the roman numeral.
- Return type:
number_representation (str)