synthesizer.components.stellar

A module for particle and parametric stars.

This should never be directly instantiated. Instead it is the parent class for particle.Stars and parametric.Stars and contains attributes and methods common between them.

Classes

class synthesizer.components.stellar.StarsComponent(ages, metallicities)[source]

The parent class for stellar components of a galaxy.

This class contains the attributes and spectra creation methods which are common to both parametric and particle stellar components.

This should never be instantiated directly.

Attributes:

generate_line(*args, **kwargs)[source]

This method is a prototype for generating lines from SPS grids. It is redefined on the child classes.

generate_lnu(*args, **kwargs)[source]

This method is a prototype for generating spectra from SPS grids. It is redefined on the child classes.

get_line_attenuated(grid, line_ids, fesc=0.0, tau_v_nebular=None, tau_v_stellar=None, dust_curve_nebular=<synthesizer.dust.attenuation.PowerLaw object>, dust_curve_stellar=<synthesizer.dust.attenuation.PowerLaw object>, mask=None, method='cic')[source]

Get a LineCollection containing attenuated lines.

Calculates attenuated properties (luminosity, continuum, EW) for a set of lines. Allows the nebular and stellar attenuation to be set separately.

Parameters:
  • grid (Grid) – The Grid object.

  • line_ids (list/str) – A list of line_ids or a str denoting a single line. Doublets can be specified as a nested list or using a comma (e.g. ‘OIII4363,OIII4959’).

  • fesc (float) – The Lyman continuum escaped fraction, the fraction of ionising photons that entirely escaped.

  • tau_v_nebular (float) – V-band optical depth of the nebular emission.

  • tau_v_stellar (float) – V-band optical depth of the stellar emission.

  • dust_curve_nebular (dust_curve) – A dust_curve object specifying the dust curve. for the nebular emission

  • dust_curve_stellar (dust_curve) – A dust_curve object specifying the dust curve for the stellar emission.

  • mask (array) – A mask to apply to the particles (only applicable to particle)

  • method (str) – The method to use for the interpolation. Options are: ‘cic’ - Cloud in cell ‘ngp’ - Nearest grid point

Returns:

LineCollection

A dictionary like object containing line objects.

get_line_intrinsic(grid, line_ids, fesc=0.0, mask=None, method='cic')[source]

Get a LineCollection containing intrinsic lines.

Parameters:
  • grid (Grid) – A Grid object.

  • line_ids (list/str) – A list of line_ids or a str denoting a single line. Doublets can be specified as a nested list or using a comma (e.g. ‘OIII4363,OIII4959’).

  • fesc (float) – The Lyman continuum escaped fraction, the fraction of ionising photons that entirely escaped.

  • mask (array) – A mask to apply to the particles (only applicable to particle)

  • method (str) – The method to use for the interpolation. Options are: ‘cic’ - Cloud in cell ‘ngp’ - Nearest grid point

Returns:

LineCollection

A dictionary like object containing line objects.

get_line_screen(grid, line_ids, fesc=0.0, tau_v=None, dust_curve=<synthesizer.dust.attenuation.PowerLaw object>, mask=None, method='cic')[source]

Get a LineCollection containing lines attenuated by a simple screen.

Calculates attenuated properties (luminosity, continuum, EW) for a set of lines assuming a simple dust screen (i.e. both nebular and stellar emission feels the same dust attenuation). This is a wrapper around the more general method above.

Parameters:
  • grid (Grid) – The Grid object.

  • line_ids (list/str) – A list of line_ids or a str denoting a single line. Doublets can be specified as a nested list or using a comma (e.g. ‘OIII4363,OIII4959’).

  • fesc (float) – The Lyman continuum escaped fraction, the fraction of ionising photons that entirely escaped.

  • tau_v (float) – V-band optical depth.

  • dust_curve (dust_curve) – A dust_curve object specifying the dust curve.

  • mask (array) – A mask to apply to the particles (only applicable to particle)

  • method (str) – The method to use for the interpolation. Options are: ‘cic’ - Cloud in cell ‘ngp’ - Nearest grid point

Returns:

LineCollection

A dictionary like object containing line objects.

get_photo_fluxes(filters, verbose=True)[source]

Calculate flux photometry using a FilterCollection object.

Parameters:
  • filters (object) – A FilterCollection object.

  • verbose (bool) – Are we talking?

Returns:

(dict)

A dictionary of fluxes in each filter in filters.

get_photo_luminosities(filters, verbose=True)[source]

Calculate luminosity photometry using a FilterCollection object.

Parameters:
Returns:

photo_luminosities (dict)

A dictionary of rest frame broadband luminosities.

get_spectra_CharlotFall(grid, tau_v_ISM=1.0, tau_v_BC=1.0, alpha_ISM=None, alpha_BC=None, young_old_thresh=unyt_quantity(10, 'Myr'), **kwargs)[source]

Calculates dust attenuated spectra assuming the Charlot & Fall (2000) dust model. In this model young star particles are embedded in a dusty birth cloud and thus feel more dust attenuation. This is a wrapper around our more generic pacman method.

Parameters:
  • grid (Grid) – The spectral grid object.

  • tau_v_ISM (float) – The ISM optical depth in the V-band.

  • tau_v_BC (float) – The birth cloud optical depth in the V-band.

  • alpha_ISM (float) – The slope of the ISM dust curve, (defaults to dust_curve.slope=-1, Recommended: -0.7 from MAGPHYS)

  • alpha_BC (float) – The slope of the birth cloud dust curve, (defaults to dust_curve.slope=-1, Recommended: -1.3 from MAGPHYS)

  • young_old_thresh (unyt_quantity) – The threshold for young/old stellar populations with units.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

Sed

A Sed object containing the dust attenuated spectra.

get_spectra_incident(grid, young=None, old=None, label='', **kwargs)[source]

Generate the incident (equivalent to pure stellar for stars) spectra using the provided Grid.

Parameters:
  • grid (obj) – Spectral grid object.

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • label (string) – A modifier for the spectra dictionary key such that the key is label + “_incident”.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

Sed

An Sed object containing the stellar spectra.

get_spectra_linecont(grid, fesc=0.0, fesc_LyA=1.0, young=None, old=None, **kwargs)[source]

Generate the line contribution spectra. This is only invoked if fesc_LyA < 1.

Parameters:
  • grid (obj) – Spectral grid object.

  • fesc (float) – Fraction of stellar emission that escapeds unattenuated from the birth cloud (defaults to 0.0).

  • fesc_LyA (float) – Fraction of Lyman-alpha emission that can escape unimpeded by the ISM/IGM.

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

numpy.ndarray

The line contribution spectra.

get_spectra_nebular(grid, fesc=0.0, young=None, old=None, label='', **kwargs)[source]

Generate nebular spectra from a grid object and star particles. The grid object must contain a nebular component.

Parameters:
  • grid (obj) – Spectral grid object.

  • fesc (float) – Fraction of stellar emission that escapeds unattenuated from the birth cloud (defaults to 0.0).

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • label (string) – A modifier for the spectra dictionary key such that the key is label + “_nebular”.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

Sed

An Sed object containing the nebular spectra.

get_spectra_nebular_continuum(grid, fesc=0.0, fesc_LyA=1.0, young=None, old=None, **kwargs)[source]

Generate the nebular continuum spectra. This is only invoked if fesc_LyA < 1.

Parameters:
  • grid (obj) – Spectral grid object.

  • fesc (float) – Fraction of stellar emission that escapeds unattenuated from the birth cloud (defaults to 0.0).

  • fesc_LyA (float) – Fraction of Lyman-alpha emission that can escape unimpeded by the ISM/IGM.

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

numpy.ndarray

The line contribution spectra.

get_spectra_pacman(grid, tau_v=1.0, dust_curve=<synthesizer.dust.attenuation.PowerLaw object>, alpha=-1.0, young_old_thresh=None, fesc=0.0, fesc_LyA=1.0, dust_emission_model=None, label='', **kwargs)[source]

Calculates dust attenuated spectra assuming the PACMAN dust/fesc model including variable Lyman-alpha transmission. In this model some fraction (fesc) of the pure stellar emission is able to completely escaped the galaxy without reprocessing by gas or dust. The rest is assumed to be reprocessed by both gas and a screen of dust. If young_old_thresh is set then the individual and combined spectra will be generated for both young and old components. In this case it’s necessary to provide an array of tau_v and alphas dscribing the ISM birth cloud components respectively. The young component feels attenuation from both the ISM and birth cloud while the old component only feels attenuation from the ISM.

Parameters:
  • grid (object, Grid) – The spectral grid object.

  • tau_v (float) – The V-band optical depth.

  • dust_curve (object) – Instance of a dust_curve from synthesizer.dust.attenuation.

  • alpha (float) – The dust curve slope.

  • young_old_thresh (unyt_quantity) – The threshold for young/old stellar populations with units.

  • fesc – (float): Lyman continuum escaped fraction.

  • fesc_LyA (float) – Lyman-alpha escaped fraction.

  • label (string) – A modifier for the spectra dictionary key such that the key is label + “_transmitted”.

  • dust_emisison_model (object) – Instance of a dust_emission_model from synthesizer.dust.emission.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Raises:

InconsistentArguments – Errors when more than two values for tau_v and alpha is passed for CF00 dust screen. In case of single dust screen, raises error for multiple optical depths or dust curve slope.

Updates:

incident escaped transmitted nebular reprocessed intrinsic attenuated emergent

if dust_emission_model provided:

dust total

if CF00:

young_incident young_escaped young_transmitted young_nebular young_reprocessed young_intrinsic young_attenuated young_emergent old_incident old_escaped old_transmitted old_nebular old_reprocessed old_intrinsic old_attenuated old_emergent

if dust_emission_model provided:

young_dust young_total old_dust old_total

Returns:

Sed

A Sed object containing the emergent or total spectra depending on whether a dust_emission_model is provided.

get_spectra_reprocessed(grid, fesc=0.0, fesc_LyA=1.0, young=None, old=None, label='', verbose=False, **kwargs)[source]

Generates the intrinsic spectra, this is the sum of the escaping radiation (if fesc>0), the transmitted emission, and the nebular emission. The transmitted emission is the emission that is transmitted through the gas. In addition to returning the intrinsic spectra this saves the incident, nebular, and escaped spectra.

Note, if a grid that has not been post-processed through a photoionisation code is provided (i.e. grid.reprocessed=False) this will just call get_spectra_incident.

Parameters:
  • grid (obj) – Spectral grid object.

  • fesc (float) – Fraction of stellar emission that escapeds unattenuated from the birth cloud (defaults to 0.0).

  • fesc_LyA (float) – Fraction of Lyman-alpha emission that can escape unimpeded by the ISM/IGM.

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • label (string) – A modifier for the spectra dictionary key such that the key is label + “_transmitted”.

  • verbose (bool) – verbose output flag

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Updates:

incident: transmitted nebular reprocessed intrinsic

if fesc>0:

escaped

Returns:

Sed

An Sed object containing the intrinsic spectra.

get_spectra_screen(grid, tau_v, dust_curve=<synthesizer.dust.attenuation.PowerLaw object>, young=None, old=None, label='', **kwargs)[source]

Calculates dust attenuated spectra assuming a simple screen. This is disfavoured over using the pacman model but will be computationally faster. Note: this implicitly assumes fesc=0.0.

Parameters:
  • grid (object, Grid) – The spectral grid object.

  • tau_v (float) – The V-band optical depth.

  • dust_curve (object) – Instance of a dust_curve from synthesizer.dust.attenuation.

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • label (string) – A modifier for the spectra dictionary key such that the key is label + “_transmitted”.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

Sed

An Sed object containing the dust attenuated spectra.

get_spectra_transmitted(grid, fesc=0.0, young=None, old=None, label='', **kwargs)[source]

Generate the transmitted spectra using the provided Grid. This is the emission which is transmitted through the gas as calculated by the photoionisation code.

Parameters:
  • grid (obj) – Spectral grid object.

  • fesc (float) – Fraction of stellar emission that escapeds unattenuated from the birth cloud (defaults to 0.0).

  • young (unyt_quantity) – If not None, specifies age in Myr at which to filter for young star particles.

  • old (unyt_quantity) – If not None, specifies age in Myr at which to filter for old star particles.

  • label (string) – A modifier for the spectra dictionary key such that the key is label + “_transmitted”.

  • kwargs – Any keyword arguments which can be passed to generate_lnu.

Returns:

Sed

An Sed object containing the transmitted spectra.

plot_spectra(spectra_to_plot=None, show=False, ylimits=(), xlimits=(), figsize=(3.5, 5), **kwargs)[source]

Plots either specific spectra (specified via spectra_to_plot) or all spectra on the child Stars object.

Parameters:
  • spectra_to_plot (string/list, string) –

    The specific spectra to plot.
    • If None all spectra are plotted.

    • If a list of strings each specifc spectra is plotted.

    • If a single string then only that spectra is plotted.

  • show (bool) – Flag for whether to show the plot or just return the figure and axes.

  • ylimits (tuple) – The limits to apply to the y axis. If not provided the limits will be calculated with the lower limit set to 1000 (100) times less than the peak of the spectrum for rest_frame (observed) spectra.

  • xlimits (tuple) – The limits to apply to the x axis. If not provided the optimal limits are found based on the ylimits.

  • figsize (tuple) – Tuple with size 2 defining the figure size.

  • kwargs (dict) – Arguments to the sed.plot_spectra method called from this wrapper.

Returns:

fig (matplotlib.pyplot.figure)

The matplotlib figure object for the plot.

ax (matplotlib.axes)

The matplotlib axes object containing the plotted data.