synthesizer.base_galaxy¶
A module for common functionality in Parametric and Particle Galaxies.
The class described in this module should never be directly instantiated. It only contains common attributes and methods to reduce boilerplate.
Classes
- class synthesizer.base_galaxy.BaseGalaxy(stars, gas, black_holes, redshift, centre, **kwargs)[source]¶
The base galaxy class.
This should never be directly instantiated. It instead contains the common functionality and attributes needed for parametric and particle galaxies.
- spectra¶
The dictionary containing a Galaxy’s spectra. Each entry is an Sed object. This dictionary only contains combined spectra from All components that make up the Galaxy (Stars, Gas, BlackHoles).
- Type:
dict, Sed
- stars¶
The Stars object holding information about the stellar population.
- Type:
particle.Stars/parametric.Stars
- gas¶
The Gas object holding information about the gas distribution.
- Type:
particle.Gas/parametric.Gas
- black_holes¶
The BlackHole/s object holding information about the black hole/s.
- Type:
particle.BlackHoles/parametric.BlackHole
- redshift¶
The redshift of the galaxy.
- Type:
float
- photo_lnu¶
The dictionary containing the photometry luminosities in spectral luminosity density units for each spectrum in Galaxy.spectra.
- Type:
dict
- photo_fnu¶
The dictionary containing the photometry fluxes in spectral flux density units for each spectrum in Galaxy.spectra.
- Type:
dict
- images_lnu¶
The dictionary containing the images in spectral luminosity density units.
- Type:
dict
- images_fnu¶
The dictionary containing the images in spectral flux density units.
- Type:
dict
- images_psf_lnu¶
The dictionary containing the images in spectral luminosity density units with a PSF applied.
- Type:
dict
- model_param_cache¶
A cache for parameters calculated by emission models.
- Type:
dict
- apply_noise_to_images_fnu(instrument, limit_to=None, apply_to_psf=True)[source]¶
Apply instrument noise to this galaxy’s and its component’s images.
This method now acts as an orchestration wrapper around the instrument-owned imaging-noise path. It fetches the relevant image collections, passes them into the instrument, stores the returned noisy images, and then repeats the same orchestration for any attached components.
- Parameters:
instrument (Instrument) – The instrument with the noise to apply.
limit_to (str/list) – If not None, defines a specific model (or list of models) to limit the image generation to. Otherwise, all models with saved spectra will have images generated.
apply_to_psf (bool) – If True, apply the noise to the PSF images. Otherwise, apply it to the normal images.
- Returns:
dict The images with the noise applied.
- apply_noise_to_images_lnu(instrument, limit_to=None, apply_to_psf=True)[source]¶
Apply instrument noise to this galaxy’s and its component’s images.
This method now acts as an orchestration wrapper around the instrument-owned imaging-noise path. It fetches the relevant image collections, passes them into the instrument, stores the returned noisy images, and then repeats the same orchestration for any attached components.
- Parameters:
instrument (Instrument) – The instrument with the noise to apply.
limit_to (str/list) – If not None, defines a specific model (or list of models) to limit the image generation to. Otherwise, all models with saved spectra will have images generated.
apply_to_psf (bool) – If True, apply the noise to the PSF images. Otherwise, apply it to the normal images.
- Returns:
dict The images with the noise applied.
- apply_psf_to_images_fnu(instrument, limit_to=None)[source]¶
Apply instrument PSFs to this galaxy’s flux images.
This method now acts as an orchestration wrapper around the instrument-owned PSF application path. It fetches the relevant image collections, passes them into the instrument, stores the returned PSF-processed images, and then repeats the same orchestration for any attached components.
- Parameters:
instrument (Instrument) – The instrument with the PSF to apply.
limit_to (str/list) – If not None, defines a specific model (or list of models) to limit the image generation to. Otherwise, all models with saved spectra will have images generated.
- Returns:
dict The images with the PSF applied.
- apply_psf_to_images_lnu(instrument, limit_to=None)[source]¶
Apply instrument PSFs to this galaxy’s luminosity images.
This method now acts as an orchestration wrapper around the instrument-owned PSF application path. It fetches the relevant image collections, passes them into the instrument, stores the returned PSF-processed images, and then repeats the same orchestration for any attached components.
- Parameters:
instrument (Instrument) – The instrument with the PSF to apply.
limit_to (str/list) – If not None, defines a specific model (or list of models) to limit the image generation to. Otherwise, all models with saved spectra will have images generated.
- Returns:
dict The images with the PSF applied.
- clear_all_emissions()[source]¶
Clear all spectra, lines and photometry.
This method is a quick helper to clear all spectra, lines, and photometry from the galaxy object and its components. This will cover both integrated and per particle emission.
- clear_all_lines()[source]¶
Clear all lines.
This method is a quick helper to clear all lines from the galaxy object and its components. This will cover both integrated and per particle lines if present.
- clear_all_photometry()[source]¶
Clear all photometry.
This method is a quick helper to clear all photometry from the galaxy object and its components. This will cover both integrated and per particle photometry if present.
- clear_all_spectra()[source]¶
Clear all spectra.
This method is a quick helper to clear all spectra from the galaxy object and its components. This will cover both integrated and per particle spectra if present.
- clear_all_spectroscopy()[source]¶
Clear all spectroscopy.
This method is a quick helper to clear all spectroscopy from the galaxy object and its components. This will cover both integrated and per particle spectroscopy if present.
- clear_weights()[source]¶
Clear all cached grid weights.
This clears all grid weights calculated using different methods from this base galaxy, and resets the _grid_weights dictionary.
- get_angular_diameter_distance(cosmo)[source]¶
Get the angular diameter distance of the galaxy.
This requires the redshift to be set on the galaxy.
This will use the astropy cosmology module to calculate the angular diameter distance. If the redshift is 0, the distance will be set to 10 pc to avoid any issues with 0s.
- Parameters:
cosmo (astropy.cosmology) – The cosmology to use for the calculation.
- Returns:
The angular diameter distance of the galaxy in kpc.
- Return type:
unyt_quantity
- get_dust_curve_params_sommovigobartlett2026(sigma_sfr=None, inclination=None, z_gas=None, log10_mstar=None, ssfr=None, sfr_timescale=unyt_quantity(100, 'Myr'), dust_model='MW', add_noise=False)[source]¶
Get the dust curve parameters for Sommovigo & Bartlett 2026.
This method is a perquisite for using the SommovigoBartlett2026 dust curve model without fixing all the dust curve parameters to fixed values.
Running this function will compute the dust curve parameters based on this galaxies properties and attach them to the stars component ready for using the dust curve transformer in calls to get_spectra. This function will attach:
self.stars.tau_v (V-band optical depth)
self.stars.B_0 (uv bump amplitude)
self.stars.B_1s (linear slope term, scaled by 1e-3)
self.stars.B_2s (slope modulation)
self.stars.B_3 (Exponential/curvature parameter)
Based on (also computed in this function where necessary):
Star formation rate surface density (sigma_SFR)
inclination
Gas phase metallicity (Z_gas, averaged over the galaxy)
Log 10 of the stellar mass (log10(M_star))
Specific star formation rate (sSFR)
Each galaxy property can be provided directly, named by a string referring to an attribute on this galaxy, or left as None to calculate it from the attached particle data.
- Parameters:
sigma_sfr (unyt_quantity/float/str) – Star formation rate surface density. Unitless values are interpreted as Msun / yr / kpc**2.
inclination (unyt_quantity/float/str) – Inclination angle. Unitless values are interpreted as degrees. If None, an isotropically distributed inclination is drawn.
z_gas (float/str) – Gas mass-weighted metallicity as an absolute mass fraction.
log10_mstar (float/str) – Log10 of the stellar mass in Msun.
ssfr (unyt_quantity/float/str) – Specific star formation rate. Unitless values are interpreted as Gyr**-1.
sfr_timescale (unyt_quantity) – Timescale over which the star formation rate is averaged. Defaults to 100 Myr, matching the model calibration.
dust_model (str) – Dust mixture model. One of ‘MW’, ‘SMC’, or ‘stellar’. Selects the small-grain fraction and the B_0 prediction formula.
add_noise (bool) – If True, add Gaussian scatter matching the intrinsic dispersion of the calibration sample. Default is False.
- Returns:
Predicted attenuation parameters, including A_V and tau_v.
- Return type:
dict
- get_equivalent_width(feature, blue, red, spectra_type)[source]¶
Get all equivalent widths associated with a sed object.
- Parameters:
feature (str) – The feature to measure the equivalent width of. e.g. “Halpha”, “Hbeta”, “MgII”, etc.
blue (float) – The blue side of the feature to measure.
red (float) – The red side of the feature to measure.
spectra_type (str/list) – The spectra type to measure the equivalent width of. Either a single type (str): or a list of types.
- Returns:
The equivalent width of the feature in the spectra.
- Return type:
equivalent_width (float/dict of float)
- get_images_flux(*labels, fov, instrument, img_type='smoothed', kernel=None, kernel_threshold=1, nthreads=1, cosmo=None)[source]¶
Make an ImageCollection from fluxes.
For Parametric Galaxy objects, images can only be smoothed. An exception will be raised if a histogram is requested.
For Particle Galaxy objects, images can either be a simple histogram (“hist”) or an image with particles smoothed over their SPH kernel.
Which images are produced is defined by the labels passed. If any of the necessary photometry is missing for generating a particular image, an exception will be raised.
Note that black holes will never be smoothed and only produce a histogram due to the point source nature of black holes.
All images that are created will be stored on the emitter (Stars, BlackHole/s, or galaxy) under the images_fnu attribute.
- Parameters:
*labels (str) – The labels of the emission models to make images for. These must be present in the photometry dicts of the components or the galaxy. For particle components, these labels must be present in the particle photometry dicts.
fov (unyt_quantity of float) – The width of the image in image coordinates.
instrument (Instrument) – The instrument to use for the image.
img_type (str) – The type of image to be made, either “hist” -> a histogram, or “smoothed” -> particles smoothed over a kernel for a particle galaxy. Otherwise, only smoothed is applicable.
kernel (np.ndarray of float) – The values from one of the kernels from the kernel_functions module. Only used for smoothed images.
kernel_threshold (float) – The kernel’s impact parameter threshold (by default 1).
nthreads (int) – The number of threads to use in the tree search. Default is 1.
cosmo (astropy.cosmology) – The cosmology to use for the calculation of the luminosity distance. Only needed for internal conversions from cartesian to angular coordinates when an angular resolution is used.
- Returns:
- ImageCollection/dict
Either a single ImageCollection if only one label is passed, otherwise a dict of ImageCollections keyed by label.
- get_images_luminosity(*labels, fov, instrument, img_type='smoothed', kernel=None, kernel_threshold=1, nthreads=1, cosmo=None)[source]¶
Make an ImageCollection from luminosities.
For Parametric Galaxy objects, images can only be smoothed. An exception will be raised if a histogram is requested.
For Particle Galaxy objects, images can either be a simple histogram (“hist”) or an image with particles smoothed over their SPH kernel.
Which images are produced is defined by the labels passed. If any of the necessary photometry is missing for generating a particular image, an exception will be raised.
Note that black holes will never be smoothed and only produce a histogram due to the point source nature of black holes.
All images that are created will be stored on the emitter (Stars, BlackHole/s, or galaxy) under the images_lnu attribute.
- Parameters:
*labels (str) – The labels of the emission models to make images for. These must be present in the photometry dicts of the components or the galaxy. For particle components, these labels must be present in the particle photometry dicts.
fov (unyt_quantity of float) – The width of the image in image coordinates.
instrument (Instrument) – The instrument to use for the image.
img_type (str) – The type of image to be made, either “hist” -> a histogram, or “smoothed” -> particles smoothed over a kernel for a particle galaxy. Otherwise, only smoothed is applicable.
kernel (np.ndarray of float) – The values from one of the kernels from the kernel_functions module. Only used for smoothed images.
kernel_threshold (float) – The kernel’s impact parameter threshold (by default 1).
nthreads (int) – The number of threads to use in the tree search. Default is 1.
cosmo (astropy.cosmology) – The cosmology to use for the calculation of the luminosity distance. Only needed for internal conversions from cartesian to angular coordinates when an angular resolution is used.
- Returns:
- ImageCollection/dict
Either a single ImageCollection if only one label is passed, otherwise a dict of ImageCollections keyed by label.
- get_line_maps_flux(*labels, line_ids, fov, instrument, img_type='smoothed', kernel=None, kernel_threshold=1, nthreads=1, cosmo=None)[source]¶
Make emission line maps (ImageCollections) from fluxes.
For Parametric Galaxy objects, maps can only be smoothed. An exception will be raised if a histogram is requested.
For Particle Galaxy objects, maps can either be a simple histogram (“hist”) or an image with particles smoothed over their SPH kernel.
All maps that are created will be stored on the emitter (Stars, BlackHole/s, or galaxy) under the line_maps_fnu attribute.
- Parameters:
*labels (str) – The labels of the emission models to make line maps for. These must be present in the lines dicts of the components or the galaxy.
line_ids (list) – The line ids to make maps for. Blended lines (e.g. doublets) can be given as a comma separated string (e.g. “O 3 4958.91A, O 3 5006.84A”) or a nested list of line ids; these produce a single map of the summed lines keyed by the “, “ joined id.
fov (unyt_quantity of float) – The width of the map in image coordinates.
instrument (Instrument) – The instrument to use for the map (typically a LineImager).
img_type (str) – The type of map to be made, either “hist” -> a histogram, or “smoothed” -> particles smoothed over a kernel for a particle galaxy. Otherwise, only smoothed is applicable.
kernel (np.ndarray of float) – The values from one of the kernels from the kernel_functions module. Only used for smoothed maps.
kernel_threshold (float) – The kernel’s impact parameter threshold (by default 1).
nthreads (int) – The number of threads to use in the tree search. Default is 1.
cosmo (astropy.cosmology) – The cosmology to use for the calculation of the luminosity distance. Only needed for internal conversions from cartesian to angular coordinates when an angular resolution is used.
- Returns:
- ImageCollection/dict
Either a single ImageCollection if only one label is passed, otherwise a dict of ImageCollections keyed by label.
- get_line_maps_luminosity(*labels, line_ids, fov, instrument, img_type='smoothed', kernel=None, kernel_threshold=1, nthreads=1, cosmo=None)[source]¶
Make emission line maps (ImageCollections) from luminosities.
For Parametric Galaxy objects, maps can only be smoothed. An exception will be raised if a histogram is requested.
For Particle Galaxy objects, maps can either be a simple histogram (“hist”) or an image with particles smoothed over their SPH kernel.
All maps that are created will be stored on the emitter (Stars, BlackHole/s, or galaxy) under the line_maps_lnu attribute.
- Parameters:
*labels (str) – The labels of the emission models to make line maps for. These must be present in the lines dicts of the components or the galaxy.
line_ids (list) – The line ids to make maps for. Blended lines (e.g. doublets) can be given as a comma separated string (e.g. “O 3 4958.91A, O 3 5006.84A”) or a nested list of line ids; these produce a single map of the summed lines keyed by the “, “ joined id.
fov (unyt_quantity of float) – The width of the map in image coordinates.
instrument (Instrument) – The instrument to use for the map (typically a LineImager).
img_type (str) – The type of map to be made, either “hist” -> a histogram, or “smoothed” -> particles smoothed over a kernel for a particle galaxy. Otherwise, only smoothed is applicable.
kernel (np.ndarray of float) – The values from one of the kernels from the kernel_functions module. Only used for smoothed maps.
kernel_threshold (float) – The kernel’s impact parameter threshold (by default 1).
nthreads (int) – The number of threads to use in the tree search. Default is 1.
cosmo (astropy.cosmology) – The cosmology to use for the calculation of the luminosity distance. Only needed for internal conversions from cartesian to angular coordinates when an angular resolution is used.
- Returns:
- ImageCollection/dict
Either a single ImageCollection if only one label is passed, otherwise a dict of ImageCollections keyed by label.
- get_lines(line_ids, emission_model, dust_curves=None, tau_v=None, fesc=None, covering_fraction=None, mask=None, verbose=True, out_dtype=None, **kwargs)[source]¶
Generate lines as described by the emission model.
- Parameters:
line_ids (list) – A list of line ids to include in the spectra.
emission_model (EmissionModel) – The emission model to use.
dust_curves (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
tau_v (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
fesc (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
covering_fraction (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
mask (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
verbose (bool) – Are we talking?
out_dtype (np.dtype) – Requested floating-point dtype for extracted line arrays.
kwargs (dict) – Any additional keyword arguments to pass to EmissionModel._get_lines, which raises an error for any it doesn’t accept.
- Returns:
- dict
The combined lines for the galaxy.
- get_luminosity_distance(cosmo)[source]¶
Get the luminosity distance of the galaxy.
This requires the redshift to be set on the galaxy.
This will use the astropy cosmology module to calculate the luminosity distance. If the redshift is 0, the distance will be set to 10 pc to avoid any issues with 0s.
- Parameters:
cosmo (astropy.cosmology) – The cosmology to use for the calculation.
- Returns:
The luminosity distance of the galaxy in kpc.
- Return type:
unyt_quantity
- get_observed_lines(cosmo, igm=<class 'synthesizer.emission_models.transformers.igm.Inoue14'>, nthreads=1, out_dtype=None)[source]¶
Calculate the observed lines for all Line objects.
This will run Line.get_fnu(…) and populate Line.fnu (and Line.obslam and Line.obsnu) for all lines in: - Galaxy.lines - Galaxy.stars.lines - Galaxy.gas.lines (WIP) - Galaxy.black_holes.lines
And in the case of particle galaxies - Galaxy.stars.particle_lines - Galaxy.gas.particle_lines (WIP) - Galaxy.black_holes.particle_lines
- Parameters:
cosmo (astropy.cosmology.Cosmology) – The cosmology object containing the cosmological model used to calculate the luminosity distance.
igm (igm) – The object describing the intergalactic medium (defaults to Inoue14). Any IGM parameters set on the galaxy take precedence over those the IGM was initialised with. The galaxy is the emitter for all contained component and particle lines, so their IGM parameters are read from the galaxy, not from the stars or black holes.
nthreads (int) – The number of threads to use when scaling the fluxes. nthreads=-1 will use all available threads.
out_dtype (np.dtype, optional) – Requested floating-point dtype for the flux arrays. If None the fluxes inherit the line luminosity dtype.
- Raises:
MissingAttribute – If a galaxy has no redshift we can’t get the observed lines.
- get_observed_spectra(cosmo, igm=<class 'synthesizer.emission_models.transformers.igm.Inoue14'>, nthreads=1, out_dtype=None, peculiar_velocity=None)[source]¶
Calculate the observed spectra for all Seds within this galaxy.
This will run Sed.get_fnu(…) and populate Sed.fnu (and sed.obslam and sed.obsnu) for all spectra in: - Galaxy.spectra - Galaxy.stars.spectra - Galaxy.gas.spectra (WIP) - Galaxy.black_holes.spectra
And in the case of particle galaxies - Galaxy.stars.particle_spectra - Galaxy.gas.particle_spectra (WIP) - Galaxy.black_holes.particle_spectra
- Parameters:
cosmo (astropy.cosmology.Cosmology) – The cosmology object containing the cosmological model used to calculate the luminosity distance.
igm (igm) – The object describing the intergalactic medium (defaults to Inoue14). Any IGM parameters set on the galaxy take precedence over those the IGM was initialised with. The galaxy is the emitter for all contained component and particle spectra, so their IGM parameters are read from the galaxy, not from the stars or black holes.
nthreads (int) – The number of threads to use for observer-frame flux conversion.
out_dtype (np.dtype, optional) – Requested floating-point dtype for the flux arrays. If None the fluxes inherit the source spectra dtype.
peculiar_velocity (unyt_quantity) – Line-of-sight peculiar velocity passed to Sed.get_fnu. If None, a peculiar_velocity attribute on the galaxy is used if set. Defaults to None.
- Raises:
MissingAttribute – If a galaxy has no redshift we can’t get the observed spectra.
- get_photo_fnu(filters, verbose=True, nthreads=1, limit_to=None, out_dtype=None)[source]¶
Calculate flux photometry using a FilterCollection object.
Photometry is calculated in spectral flux density units.
- Parameters:
filters (FilterCollection) – A FilterCollection object.
verbose (bool) – Are we talking?
nthreads (int) – The number of threads to use for the integration. If -1, all threads will be used.
limit_to (str/list, optional) – If None, then photometry is calculated for all spectra in the galaxy. If a string or list of strings is provided, then photometry is only calculated for the specified spectra.
out_dtype (np.dtype) – Requested floating-point dtype for the returned photometry.
- Returns:
A PhotometryCollection object containing the flux photometry in each filter in filters.
- Return type:
- get_photo_lnu(filters, verbose=True, nthreads=1, limit_to=None, out_dtype=None)[source]¶
Calculate luminosity photometry using a FilterCollection object.
Photometry is calculated in spectral luminosity density units.
- Parameters:
filters (FilterCollection) – A FilterCollection object.
verbose (bool) – Are we talking?
nthreads (int) – The number of threads to use for the integration. If -1, all threads will be used.
limit_to (str/list, optional) – If None, then photometry is calculated for all spectra in the galaxy. If a string or list of strings is provided, then photometry is only calculated for the specified spectra.
out_dtype (np.dtype) – Requested floating-point dtype for the returned photometry.
- Returns:
A PhotometryCollection object containing the luminosity photometry in each filter in filters.
- Return type:
- get_spectra(emission_model, dust_curves=None, tau_v=None, fesc=None, covering_fraction=None, mask=None, vel_shift=None, verbose=True, out_dtype=None, **kwargs)[source]¶
Generate spectra as described by the emission model.
- Parameters:
emission_model (EmissionModel) – The emission model to use.
dust_curves (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
tau_v (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
fesc (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
covering_fraction (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
mask (dict) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
vel_shift (bool) – No longer supported, passing it raises an error. Modify the EmissionModel (or the emitter) instead.
verbose (bool) – Are we talking?
out_dtype (np.dtype) – Requested floating-point dtype for extracted spectra arrays.
kwargs (dict) – Any additional keyword arguments to pass to EmissionModel._get_spectra, which raises an error for any it doesn’t accept.
- Returns:
- dict
The combined spectra for the galaxy.
- get_spectra_combined()[source]¶
Combine all common spectra from components onto the galaxy.
- e.g.:
intrinsc = stellar_intrinsic + black_hole_intrinsic.
For any combined spectra all components with a valid spectra will be combined and stored in Galaxy.spectra under the same key, but only if there are instances of a spectra containing that name to combine.
- Possible combined spectra are:
“total”
“intrinsic”
“emergent”
Note that this process is only applicable to integrated spectra.
- get_spectroscopy(instrument, limit_to=None, out_dtype=None)[source]¶
Get spectroscopy for the galaxy based on a specific instrument.
Deprecated alias for get_spectroscopy_fnu, which treats the instrument wavelengths as observer frame wavelengths.
- Parameters:
instrument (Instrument) – The instrument to use for the spectroscopy.
limit_to (str/list, optional) – If None, then spectroscopy is calculated for all spectra in the galaxy. If a string or list of strings is provided, then spectroscopy is only calculated for the specified spectra.
out_dtype (np.dtype, optional) – Requested floating-point dtype for the resulting spectra. If None the spectroscopy inherits the source spectra dtype.
- Returns:
- dict
The observer frame spectroscopy for the galaxy.
- get_spectroscopy_fnu(instrument, limit_to=None, out_dtype=None)[source]¶
Get observer frame spectroscopy for the galaxy from an instrument.
The instrument wavelengths are interpreted as observer frame wavelengths (see SpectroscopicInstrument.apply_lam_array_fnu), so the spectra must already have their fluxes computed. The results are stored in spectroscopy_fnu on the galaxy and its components.
If the instrument has a line spread function (LSF), the spectroscopy with it applied is also stored (in spectroscopy_lsf_fnu) and is the one returned.
- Parameters:
instrument (Instrument) – The instrument to use for the spectroscopy.
limit_to (str/list, optional) – If None, then spectroscopy is calculated for all spectra in the galaxy. If a string or list of strings is provided, then spectroscopy is only calculated for the specified spectra.
out_dtype (np.dtype, optional) – Requested floating-point dtype for the resulting spectra. If None the spectroscopy inherits the source spectra dtype.
- Returns:
- dict
The observer frame spectroscopy for the galaxy.
- get_spectroscopy_lnu(instrument, limit_to=None, out_dtype=None)[source]¶
Get rest frame spectroscopy for the galaxy from an instrument.
The instrument wavelengths are interpreted as rest frame wavelengths (see SpectroscopicInstrument.apply_lam_array_lnu). The results are stored in spectroscopy_lnu on the galaxy and its components.
If the instrument has a line spread function (LSF), the spectroscopy with it applied is also stored (in spectroscopy_lsf_lnu) and is the one returned.
- Parameters:
instrument (Instrument) – The instrument to use for the spectroscopy.
limit_to (str/list, optional) – If None, then spectroscopy is calculated for all spectra in the galaxy. If a string or list of strings is provided, then spectroscopy is only calculated for the specified spectra.
out_dtype (np.dtype, optional) – Requested floating-point dtype for the resulting spectra. If None the spectroscopy inherits the source spectra dtype.
- Returns:
- dict
The rest frame spectroscopy for the galaxy.
- get_surviving_mass(grid, **kwargs)[source]¶
Calculate the surviving mass of the stellar population.
This is the total mass of stars that have survived to the present day given the star formation and metal enrichment history.
- Parameters:
grid (Grid) – The grid to use for calculating the surviving mass. This is used to get the stellar fraction at each SFZH bin.
**kwargs (dict) – Additional keyword arguments to pass to the stars calculate_surviving_mass method. Only keyword used is ‘grid_assignment_method’, which is only used for particle galaxies.
- Returns:
The total surviving mass of the stellar population in Msun.
- Return type:
unyt_quantity
- plot_observed_spectra(combined_spectra=True, stellar_spectra=False, gas_spectra=False, black_hole_spectra=False, show=False, ylimits=(), xlimits=(), figsize=(3.5, 5), filters=None, quantity_to_plot='fnu')[source]¶
Plot observed spectra on this galaxy.
Plots either specific observed spectra (specified via combined_spectra, stellar_spectra, gas_spectra, and/or black_hole_spectra) or all spectra for any of the spectra arguments that are True. If any are false that component is ignored.
- Parameters:
combined_spectra (bool/list, string/string) –
- The specific combined galaxy spectra to plot. (e.g “total”)
If True all spectra are plotted.
If a list of strings each specific spectra is plotted.
If a single string then only that spectra is plotted.
stellar_spectra (bool/list, string/string) –
- The specific stellar spectra to plot. (e.g. “incident”)
If True all spectra are plotted.
If a list of strings each specific spectra is plotted.
If a single string then only that spectra is plotted.
gas_spectra (bool/list, string/string) –
- The specific gas spectra to plot. (e.g. “total”)
If True all spectra are plotted.
If a list of strings each specific spectra is plotted.
If a single string then only that spectra is plotted.
black_hole_spectra (bool/list, string/string) –
- The specific black hole spectra to plot. (e.g “blr”)
If True all spectra are plotted.
If a list of strings each specific 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.
filters (FilterCollection) – If given then the photometry is computed and both the photometry and filter curves are plotted
quantity_to_plot (string) – The sed property to plot. Can be “lnu”, “luminosity” or “llam” for rest frame spectra or “fnu”, “flam” or “flux” for observed spectra. Defaults to “lnu”.
- Returns:
- fig (matplotlib.pyplot.figure)
The matplotlib figure object for the plot.
- ax (matplotlib.axes)
The matplotlib axes object containing the plotted data.
- plot_observed_spectroscopy(instrument_label, combined_spectra=True, stellar_spectra=False, gas_spectra=False, black_hole_spectra=False, show=False, ylimits=(), xlimits=(), figsize=(3.5, 5), quantity_to_plot='fnu', fig=None, ax=None)[source]¶
Plot an instrument’s observer frame spectroscopy.
This will plot the observer frame spectroscopy (spectroscopy_fnu) for the galaxy and its components using the instrument’s wavelength array. The spectra are plotted in the order they are stored in the spectroscopy dictionary.
If the instrument has a line spread function (LSF), the spectroscopy with it applied (spectroscopy_lsf_fnu) is plotted instead.
- Parameters:
instrument_label (str) – The label of the instrument whose spectroscopy to plot.
combined_spectra (bool/list, string/string) –
The specific combined galaxy spectroscopy to plot. (e.g “total”)
If True all spectra are plotted.
If a list of strings each specifc spectra is plotted.
If a single string then only that spectra is plotted.
stellar_spectra (bool/list, string/string) –
- The specific stellar spectroscopy to plot. (e.g. “incident”)
If True all spectra are plotted.
If a list of strings each specifc spectra is plotted.
If a single string then only that spectra is plotted.
gas_spectra (bool/list, string/string) –
- The specific gas spectroscopy to plot. (e.g. “total”)
If True all spectra are plotted.
If a list of strings each specifc spectra is plotted.
If a single string then only that spectra is plotted.
black_hole_spectra (bool/list, string/string) –
- The specific black hole spectroscopy to plot. (e.g “blr”)
If True 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.
quantity_to_plot (string) – The sed property to plot. Can be “lnu”, “luminosity” or “llam” for rest frame spectra or “fnu”, “flam” or “flux” for observed spectra. Defaults to “lnu”.
fig (matplotlib.pyplot.figure) – The matplotlib figure object to plot on. If None a new figure is created.
ax (matplotlib.axes) – The matplotlib axes object to plot on. If None a new axes is created.
- Returns:
- fig (matplotlib.pyplot.figure)
The matplotlib figure object for the plot.
- ax (matplotlib.axes)
The matplotlib axes object containing the plotted data.
- plot_spectra(combined_spectra=True, stellar_spectra=False, gas_spectra=False, black_hole_spectra=False, show=False, ylimits=(), xlimits=(), figsize=(3.5, 5), quantity_to_plot='lnu')[source]¶
Plot spectra on this galaxy.
Plots either specific observed spectra (specified via combined_spectra, stellar_spectra, gas_spectra, and/or black_hole_spectra) or all spectra for any of the spectra arguments that are True. If any are false that component is ignored.
- Parameters:
combined_spectra (bool/list, string/string) –
- The specific combined galaxy spectra to plot. (e.g “total”)
If True all spectra are plotted.
If a list of strings each specific spectra is plotted.
If a single string then only that spectra is plotted.
stellar_spectra (bool/list, string/string) –
- The specific stellar spectra to plot. (e.g. “incident”)
If True all spectra are plotted.
If a list of strings each specific spectra is plotted.
If a single string then only that spectra is plotted.
gas_spectra (bool/list, string/string) –
- The specific gas spectra to plot. (e.g. “total”)
If True all spectra are plotted.
If a list of strings each specific spectra is plotted.
If a single string then only that spectra is plotted.
black_hole_spectra (bool/list, string/string) –
- The specific black hole spectra to plot. (e.g “blr”)
If True all spectra are plotted.
If a list of strings each specific 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.
quantity_to_plot (string) – The sed property to plot. Can be “lnu”, “luminosity” or “llam” for rest frame spectra or “fnu”, “flam” or “flux” for observed spectra. Defaults to “lnu”.
- Returns:
- fig (matplotlib.pyplot.figure)
The matplotlib figure object for the plot.
- ax (matplotlib.axes)
The matplotlib axes object containing the plotted data.
- plot_spectroscopy(instrument_label, combined_spectra=True, stellar_spectra=False, gas_spectra=False, black_hole_spectra=False, show=False, ylimits=(), xlimits=(), figsize=(3.5, 5), quantity_to_plot='lnu', fig=None, ax=None)[source]¶
Plot an instrument’s rest frame spectroscopy.
This will plot the rest frame spectroscopy (spectroscopy_lnu) for the galaxy and its components using the instrument’s wavelength array. The spectra are plotted in the order they are stored in the spectroscopy dictionary.
If the instrument has a line spread function (LSF), the spectroscopy with it applied (spectroscopy_lsf_lnu) is plotted instead.
- Parameters:
instrument_label (str) – The label of the instrument whose spectroscopy to plot.
combined_spectra (bool/list, string/string) –
- The specific combined galaxy spectra to plot. (e.g “total”)
If True all spectra are plotted.
If a list of strings each specifc spectra is plotted.
If a single string then only that spectra is plotted.
stellar_spectra (bool/list, string/string) –
- The specific stellar spectra to plot. (e.g. “incident”)
If True all spectra are plotted.
If a list of strings each specifc spectra is plotted.
If a single string then only that spectra is plotted.
gas_spectra (bool/list, string/string) –
- The specific gas spectra to plot. (e.g. “total”)
If True all spectra are plotted.
If a list of strings each specifc spectra is plotted.
If a single string then only that spectra is plotted.
black_hole_spectra (bool/list, string/string) –
- The specific black hole spectra to plot. (e.g “blr”)
If True 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.
quantity_to_plot (string) – The sed property to plot. Can be “lnu”, “luminosity” or “llam” for rest frame spectra or “fnu”, “flam” or “flux” for observed spectra. Defaults to “lnu”.
fig (matplotlib.pyplot.figure) – The matplotlib figure object to plot on. If None a new figure is created.
ax (matplotlib.axes) – The matplotlib axes object to plot on. If None a new axes is created.
- Returns:
- fig (matplotlib.pyplot.figure)
The matplotlib figure object for the plot.
- ax (matplotlib.axes)
The matplotlib axes object containing the plotted data.
- print_used_parameters(*models)[source]¶
Print the parameters used by emission models in a formatted table.
This method displays all parameters that have been cached during emission model calculations, organized by model label. Each model’s parameters are shown with their computed values.
The output is formatted using TableFormatter to match the style of other print methods in synthesizer.
- Parameters:
*models (str) – Optional model labels to print. If provided, only the specified models will be printed. If not provided, all cached models will be printed from all components (stars, black holes, and galaxy).
- property spectroscopy¶
Return the observer frame spectroscopy (deprecated alias).
- Returns:
- dict
The spectroscopy_fnu dictionary.
Examples using synthesizer.base_galaxy.BaseGalaxy¶
Demonstrate the dense basis approach for describing the SFZH
Point LOS Column Densities With A Truncated Source Kernel
Compare smoothed and point-particle LOS column densities