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.

Parameters:
  • intrinsic_sed (Sed) – The intrinsic spectra object.

  • attenuated_sed (Sed) – The attenuated spectra object.

Returns:

np.ndarray of float

The attenuation array in magnitudes.

synthesizer.emissions.utils.get_attenuation_at_1500(intrinsic_sed, attenuated_sed)[source]

Calculate rest-frame FUV attenuation at 1500 angstrom.

Parameters:
  • intrinsic_sed (Sed) – The intrinsic spectra object.

  • attenuated_sed (Sed) – The attenuated spectra object.

Returns:

float

The attenuation at rest-frame 1500 angstrom in magnitudes.

synthesizer.emissions.utils.get_attenuation_at_5500(intrinsic_sed, attenuated_sed)[source]

Calculate rest-frame FUV attenuation at 5500 angstrom.

Parameters:
  • intrinsic_sed (Sed) – The intrinsic spectra object.

  • attenuated_sed (Sed) – The attenuated spectra object.

Returns:

float

The attenuation at rest-frame 5500 angstrom in magnitudes.

synthesizer.emissions.utils.get_attenuation_at_lam(lam, intrinsic_sed, attenuated_sed)[source]

Calculate attenuation at a given wavelength.

Parameters:
  • lam (float/np.ndarray of float) – The wavelength/s at which to evaluate the attenuation in the same units as sed.lam (by default angstrom).

  • intrinsic_sed (Sed) – The intrinsic spectra object.

  • attenuated_sed (Sed) – The attenuated spectra object.

Returns:

float/np.ndarray of float

The attenuation at the passed wavelength/s in magnitudes.

synthesizer.emissions.utils.get_available_diagram_ids(signature)[source]

Get the cached diagram ids for a line-id signature.

Parameters:

signature (tuple) – The ordered tuple of line ids describing the collection.

Returns:

The tuple of predefined diagram ids available for these lines.

Return type:

tuple

synthesizer.emissions.utils.get_available_ratio_ids(signature)[source]

Get the cached ratio ids for a line-id signature.

Parameters:

signature (tuple) – The ordered tuple of line ids describing the collection.

Returns:

The tuple of predefined ratio ids available for these lines.

Return type:

tuple

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_diagram_requirements()[source]

Precompute required line ids for each diagram definition.

Returns:

A mapping from diagram id to the frozen set of required line ids.

Return type:

dict

synthesizer.emissions.utils.get_line2index(signature)[source]

Get a cached line-id to index mapping.

Parameters:

signature (tuple) – The ordered tuple of line ids describing the collection.

Returns:

A mapping from each stored line id to its array index.

Return type:

MappingProxyType

synthesizer.emissions.utils.get_line_id_signature(line_ids)[source]

Return the canonical cache key for a line-id sequence.

Parameters:

line_ids (array-like) – The ordered sequence of line ids describing the collection.

Returns:

The ordered line ids converted into a hashable cache key.

Return type:

tuple

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_ratio_requirements()[source]

Precompute required line ids for each ratio definition.

Returns:

A mapping from ratio id to the frozen set of required line ids.

Return type:

dict

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)

synthesizer.emissions.utils.get_transmission(intrinsic_sed, attenuated_sed)[source]

Calculate transmission as a function of wavelength.

The transmission is defined as the ratio between an attenuated and an intrinsic sed.

Parameters:
  • intrinsic_sed (Sed) – The intrinsic spectra object.

  • attenuated_sed (Sed) – The attenuated spectra object.

Returns:

The transmission array.

Return type:

np.ndarray of float