galapy.CompositeStellarPopulation
GalaPy module for combining Simple Stellar Populations (SSP) into a Composite Stellar Population (CSP).
Functions
|
Given an input SSP table returns a version with the formatting internally required by the library. |
|
Return a list of the available SSP libraries. |
|
Load a SSP library corresponding to a given name. |
Print on screen a list of the available SSP libraries. |
|
|
Reshapes a flattened SSP table to the original 3-dimensional shape. |
|
Save a new SSP table |
Classes
|
The Composite Stellar Population object handles and manipulates SSP libraries. |
- galapy.CompositeStellarPopulation.print_ssp_libs()
Print on screen a list of the available SSP libraries.
This has the only purpose of listing the possible choices.
Naming convention: author.method[.imf.filling_schema]
author: An achronym for the authors of the SSP library
method: if present, shows which method was used to compute the SSP
imf: if present shows the initial mass function used to compute the SSP
filling_schema: all the SSPs’ wavelength domain has been extended to span from \(1\ \mathring{A}\) to \(10^{10}\ \mathring{A}\). This code provides the strategy used (plain = filled with zeros,
extrap= extrapolated linearly in the logarithm,refined= thinner lambda grid obtained by linearly-interpolating the plain equivalent)
- galapy.CompositeStellarPopulation.list_ssp_libs(return_path=False)
Return a list of the available SSP libraries.
- Parameters:
return_path (bool) – (default = False) if True, also return a list with absolute paths to each of the available SSP libs.
- Returns:
list – available SSP libraries
list – available SPP libraries as a list of absolute paths.
- galapy.CompositeStellarPopulation.load_SSP_table(which)
Load a SSP library corresponding to a given name.
- galapy.CompositeStellarPopulation.format_SSP_table(L, lidx, tidx, Zidx, lsize, tsize, Zsize, flat=True)
Given an input SSP table returns a version with the formatting internally required by the library.
- Parameters:
L (array-like) – input SSP table. It can be either a continuous array indexed on 3 coordinates (i.e. wavelength, age and metallicity) in whatever ordering, or a 3-dimensional matrix for which the 3 dimensions run over the wavelength, age and metallicity (also in this case the order is not important).
lidx (integer) – axis number in the array L corresponding to the wavelength dimension
tidx (integer) – axis number in the array L corresponding to the age dimension
Zidx (integer) – axis number in the array L corresponding to the metallicity dimension
lsize (integer) – dimension of the wavelength grid
tsize (integer) – dimension of the age grid
Zsize (integer) – dimension of the metallicity grid
flat (bool) – if True, the input array is assumed to be flattened, if False it should instead be a 3D matrix with axes corresponding to the 3 grids in wavelength, age and metallicity
- Returns:
newL – output SSP table in the correct format
- Return type:
1d contiguous array
- galapy.CompositeStellarPopulation.store_SSP_table(outfile, l, t, Z, L, endianism='little', force=False)
Save a new SSP table
- Parameters:
outfile (string) – path to output file name.
l (array-like) – wavelength grid
t (array-like) – age grid
Z (array-like) – metallicity grid
L (array-like) – flattened SSP table in the correct format accepted by the library (check function
format_SSP_table())endianism (string) – endianism of your machine, you can check this by calling
import sys; print(sys.byteorder)force (bool) – whether to overwrite an already existing
outfile
- galapy.CompositeStellarPopulation.reshape_SSP_table(L, shape)
Reshapes a flattened SSP table to the original 3-dimensional shape.
The 3D matrix has the dimensions of the 3 grids over which it varies: wavelength (l_grid), age (t_grid) and metallicity (Z_grid).
- Parameters:
L (1d numpy array) – Input flattened SSP table with length l_grid*t_grid*Z_grid
shape (tuple) –
Tuple of 3 integers with the sizes of
wavelength grid
age grid
metallicity grid
The above ordering is mandatory
- Returns:
3D copy of the original array with shape (l_grid, t_grid, Z_grid).
- Return type:
3-d numpy array
- class galapy.CompositeStellarPopulation.CSP(ssp_lib='parsec22.NT', CCSN=False)
The Composite Stellar Population object handles and manipulates SSP libraries.
It provides convenient functions for reading the SSPs from the provided formatted binary files. SSPs can be extracted for given age/wavelength/metallicity. Providing an object of type galapy.StarFormationHistory the self.emission function computes the luminosity of the resulting Composite Stellar Population.
- Parameters:
ssp_lib (string) – which SSP library to load. The default is
parsec22.NT- To see the list of available libraries rungalapy.CompositeStellarPopulation.print_ssp_libs()CCSN (bool) – whether to allow for Core-Collapse Supernova support (default=False).
- set_parameters(age, sfh)
Function for setting the internal quantities required for combining SSPs into CSPs.
- Parameters:
age (float) – The age in years of the CSP.
sfh (object of type SFH()) – The chosen star formation history. This has to be (or inherit from) the instance of an object of type galapy.StarFormationHistory.SFH().
- SSP(il, it, iz)
Indexes the SSP library.
- Parameters:
il (uint or array-like of uints) – index in the wavelength-grid of pre-computed SSPs
it (uint or array-like of uints) – index in the time-grid of pre-computed SSPs
iz (uint or array-like of uints) – index in the metallicity-grid of pre-computed SSPs
- Returns:
SSP[il,it,iz] – Element (il,it,iz) of the SSP table.
- Return type:
float or array of floats
- emission(age, sfh, il=None, ftau=None)
Computes the CSP emission at given index in the wavelength-grid.
It approximates the integral:
\[L_\lambda^\text{CSP}(\tau') = \int_0^{\tau'}\text{d}\tau F(\lambda,\tau)\cdot L_\lambda^\text{SSP}\bigl[\tau, Z_\ast(\tau'-\tau)\bigr]\psi(\tau'-\tau)\]where \(\tau'\) is the age of the CSP, \(L_\lambda^\text{SSP}[\tau, Z\ast]\) is the luminosity of the Simple Stellar Population at given time \(\tau\) and at given stellar metallicity \(Z_\ast\), \(\psi(\tau)\) is the Star Formation History and \(F(\lambda, \tau)\) is aa attenuating function of choice. The latter is passed as the keyword argument
ftauand should be a matrix with dimension \((N_\lambda, N_\tau)\), where \(N_\lambda\) is the size of the wavelength grid (chosen through the keyword argumentil) and \(N_\tau\) is the size of the time grid of the SSP (self.shape[1]).ftaudefaults toNone, in which case no attenuation is applied.- Parameters:
age (float) – The age in years of the CSP.
sfh (object of type SFH()) – The chosen star formation history. This has to be (or inherit from) the instance of an object of type galapy.StarFormationHistory.SFH().
il (array of int) – array of indexes of the positions in the wavelength-grid for which to compute the emission. The default value is
None, for which the function will return the emission all over the wavelength grid.Ftau (array) – array containing a function of time to convolve the integrand with (must have same dimension of the il array size times the SSP’s time-grid size)
- Returns:
L_CSP – the emission of the galaxy’s CSP filtered by the function of time \(F(\tau)\)
- Return type:
array or scalar float
- RCCSN(age, sfh)
- Parameters:
age (float) – The age in years of the CSP.
sfh (object of type SFH()) – The chosen star formation history. This has to be (or inherit from) the instance of an object of type galapy.StarFormationHistory.SFH().
- Returns:
RCCSN – The Core-Collapse Supernova rate at given age for a given SFH.
- Return type:
scalar float
- Raises:
Warning – if the object has been built without CCSN support.