synthesizer.emission_models.extractors.extractor

A submodule containing the Extractor class.

Classes

class synthesizer.emission_models.extractors.extractor.DopplerShiftedParticleExtractor(grid, extract)[source]

A class to extract the Doppler shifted emission from a particle.

This Extractor will produce a Doppler shifted spectra for each particle in a particle based component.

This is not applicable for line emission which is treated without Doppler shifting. Doppler broadened lines can be extracted from spectra where the width of the lines is accounted for in the spectra grid.

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

Doppler shifted line luminosities make no sense.

generate_lnu(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the per particle doppler shifted spectra from the grid.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object from which to extract the emission.

  • model (EmissionModel) – The emission model defining the emission to extract.

  • mask (np.array) – A mask to apply to the particles.

  • lam_mask (np.array) – A mask to apply to the spectra’s wavelength axis.

  • grid_assignment_method (str) – The method to assign particles to the grid. Either “cic” (Cloud-in-Cell) or “ngp” (Nearest Grid Point).

  • nthreads (int) – The number of threads to use in the extraction. If -1 then all available threads will be used.

  • do_grid_check (bool) – Whether to check how many particles lie outside the grid. This is a sanity check that can be used to check the consistency of your particles with the grid. It is False by default because the check is extreme expensive.

Returns:

Sed

The integrated spectra.

class synthesizer.emission_models.extractors.extractor.Extractor(grid, extract)[source]

An abstract base class defining the framework for extraction.

This class provides common methods and attributes for the extraction of emissions (sed and lines) from a grid for a given emitter. It also templates out what methods are needed by any child classes.

In short, this class provides the machinery to extract emitter attributes corresponding to grid axes and run the extraction code to compute the emission from the grid. This functionality enables extraction from complete arbitrary grids and emitters, as long as the emitter contains the necessary attributes.

_emitter_attributes

The attributes to extract from the emitter.

Type:

tuple

_grid_axes

The grid axes corresponding to the emitter attributes.

Type:

tuple

_axes_units

The units for each grid axis.

Type:

tuple

_weight_var

The weight variable to extract from the emitter and use to weight the emission grid. Note, this is set during grid generation and is stored on each grid object explictly from the grid file itself.

Type:

str

_grid_dims

The grid dimensions, the shape of the spectra grid.

Type:

np.array

_grid_naxes

The number of grid axes, i.e. the shape of the grid excluding the wavelength axis.

Type:

int

_grid_nlam

The number of spectra grid wavelength elements.

Type:

int

_log_emitter_attr

Whether to log the emitter data.

Type:

tuple

_grid

The grid from which to extract the emission.

Type:

Grid

_spectra_grid

The grid of spectra.

Type:

unyt_array

_line_lum_grid

The grid of line luminosities.

Type:

unyt_array

_line_cont_grid

The grid of line continua.

Type:

unyt_array

_line_lams

The line wavelengths.

Type:

unyt_array

check_emitter_attrs(emitter, extracted_attrs)[source]

Compute the fraction of emitter attributes outside the grid axes.

This is by default not run but can be invoked via the do_grid_check argument in the generate_lnu and generate_line methods.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter from which the attributes were extracted.

  • extracted_attrs (tuple) – The extracted attributes from the emitter.

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

Extract the line luminosities from the grid for the emitter.

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

Extract the spectra from the grid for the emitter.

get_emitter_attrs(emitter, model, do_grid_check)[source]

Get the attributes from the emitter.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object.

  • model (EmissionModel) – The emission model object.

  • do_grid_check (bool) – Whether to check how many particles lie outside the grid. This is a sanity check that can be used to check the consistency of your particles with the grid. It is False by default because the check is extreme expensive.

Returns:

tuple

The extracted attributes and the weight variable.

class synthesizer.emission_models.extractors.extractor.IntegratedDopplerShiftedParticleExtractor(grid, extract)[source]

A class to extract the Doppler shifted emission from a particle.

This Extractor will produce the integrated Doppler shifted spectra for a particle based component.

This is not applicable for line emission which is treated without Doppler shifting. Doppler broadened lines can be extracted from spectra where the width of the lines is accounted for in the spectra grid.

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

Doppler shifted line luminosities make no sense.

generate_lnu(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the integrated doppler shifted spectra from the grid.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object from which to extract the emission.

  • model (EmissionModel) – The emission model defining the emission to extract.

  • mask (np.array) – A mask to apply to the particles.

  • lam_mask (np.array) – A mask to apply to the spectra’s wavelength axis.

  • grid_assignment_method (str) – The method to assign particles to the grid. Either “cic” (Cloud-in-Cell) or “ngp” (Nearest Grid Point).

  • nthreads (int) – The number of threads to use in the extraction. If -1 then all available threads will be used.

  • do_grid_check (bool) – Whether to check how many particles lie outside the grid. This is a sanity check that can be used to check the consistency of your particles with the grid. It is False by default because the check is extreme expensive.

Returns:

Sed

The integrated spectra.

class synthesizer.emission_models.extractors.extractor.IntegratedParametricExtractor(grid, extract)[source]

A class to extract the integrated parametric emission from a particle.

This Extractor will produce integrated emission from parametric based components. This differs from particle based components only in that we can straight multiply the SFZH by the grid spectra to get the integrated emission.

generate_line(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the line luminosities from the grid for the emitter.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object.

  • model (EmissionModel) – The emission model object.

generate_lnu(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the integrated spectra from the grid for a parametric emitter.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object from which to extract the emission.

  • model (EmissionModel) – The emission model defining the emission to extract.

  • mask (np.array) – A mask to apply to the particles.

  • lam_mask (np.array) – A mask to apply to the spectra’s wavelength axis.

  • grid_assignment_method (str) – The method to assign particles to the grid. Either “cic” (Cloud-in-Cell) or “ngp” (Nearest Grid Point).

  • nthreads (int) – The number of threads to use in the extraction. If -1 then all available threads will be used.

  • do_grid_check (bool) – Whether to check how many particles lie outside the grid. This is a sanity check that can be used to check the consistency of your particles with the grid. It is False by default because the check is extreme expensive.

Returns:

Sed

The integrated spectra.

class synthesizer.emission_models.extractors.extractor.IntegratedParticleExtractor(grid, extract)[source]

A class to extract the integrated emission from a particle.

This Extractor will produce integrated emission from particle based components.

If no mask is being used it will attempt to reuse any stored grid weights to reduce the computation time.

generate_line(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the line luminosities from the grid for the emitter.

generate_lnu(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the spectra from the grid for the emitter.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object from which to extract the emission.

  • model (EmissionModel) – The emission model defining the emission to extract.

  • mask (np.array) – A mask to apply to the particles.

  • lam_mask (np.array) – A mask to apply to the spectra’s wavelength axis.

  • grid_assignment_method (str) – The method to assign particles to the grid. Either “cic” (Cloud-in-Cell) or “ngp” (Nearest Grid Point).

  • nthreads (int) – The number of threads to use in the extraction. If -1 then all available threads will be used.

  • do_grid_check (bool) – Whether to check how many particles lie outside the grid. This is a sanity check that can be used to check the consistency of your particles with the grid. It is False by default because the check is extreme expensive.

Returns:

Sed

The integrated spectra.

class synthesizer.emission_models.extractors.extractor.ParticleExtractor(grid, extract)[source]

A class to extract the emission from a particle.

This Extractor will produce a spectra for each particle in a particle based component.

generate_line(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the line luminosities from the grid for the emitter.

generate_lnu(emitter, model, mask, lam_mask, grid_assignment_method, nthreads, do_grid_check)[source]

Extract the per particle spectra from the grid.

Parameters:
  • emitter (Stars/BlackHoles/Gas) – The emitter object from which to extract the emission.

  • model (EmissionModel) – The emission model defining the emission to extract.

  • mask (np.array) – A mask to apply to the particles.

  • lam_mask (np.array) – A mask to apply to the spectra’s wavelength axis.

  • grid_assignment_method (str) – The method to assign particles to the grid. Either “cic” (Cloud-in-Cell) or “ngp” (Nearest Grid Point).

  • nthreads (int) – The number of threads to use in the extraction. If -1 then all available threads will be used.

  • do_grid_check (bool) – Whether to check how many particles lie outside the grid. This is a sanity check that can be used to check the consistency of your particles with the grid. It is False by default because the check is extreme expensive.

Returns:

Sed

The integrated spectra.