rail.creation.engines.dsps_sed_modeler module

class rail.creation.engines.dsps_sed_modeler.DSPSPopulationSedModeler

Bases: Modeler

Derived class of Modeler for creating a population of galaxy rest-frame SED models using DSPS v3. (Hearin+21). SPS calculations are based on a set of template SEDs of simple stellar populations (SSPs). Supplying such templates is outside the planned scope of the DSPS package, and so they will need to be retrieved from some other library. For example, the FSPS library supplies such templates in a convenient form.

The input galaxy properties, such as star-formation histories and metallicities, need to be supplied via an hdf5 table.

The user-provided metallicity grid should be consistently defined with the metallicity of the templates SEDs. Users should be cautious in the use of the cosmic time grid. The time resolution strongly depends on the user scientific aim. jax serially execute the computations on CPU on single core, for CPU parallelization you need MPI. If GPU is used, jax natively and automatically parallelize the execution.

Parameters:
  • output_mode ([str] default=default) – What to do with the outputs. The options are ‘default’, where outputs will be written to files and some returned, and ‘return’, where outputs will only be returned and not written.

  • ssp_templates_file ([str] default=/home/docs/checkouts/readthedocs.org/user_builds/rail-hub/conda/latest/lib/python3.14/site-packages/rail/examples_data/creation_data/data/dsps_default_data/ssp_data_fsps_v3.2_lgmet_age.h5) – hdf5 file storing the SSP libraries used to create SEDs

  • redshift_key (str] (default=redshifts))

  • cosmic_time_grid_key ([str] default=cosmic_time_grid) – Cosmic time grid keyword name of the hdf5 dataset, this is the grid of Universe age over which the stellar mass build-up takes place in units of Gyr

  • star_formation_history_key ([str] default=star_formation_history) – Star-formation history keyword name of the hdf5 dataset, this is the star-formation history of the galaxy in units of Msun/yr

  • stellar_metallicity_key ([str] default=stellar_metallicity) – Stellar metallicity keyword name of the hdf5 dataset, this is the stellar metallicity in units of log10(Z)

  • stellar_metallicity_scatter_key ([str] default=stellar_metallicity_scatter) – Stellar metallicity scatter keyword name of the hdf5 dataset, this is lognormal scatter in the metallicity distribution function

  • restframe_sed_key ([str] default=restframe_seds) – Rest-frame SED keyword name of the output hdf5 dataset

  • default_cosmology ([bool] default=True) – True to use default DSPS cosmology. If False,Om0, w0, wa, h need to be supplied in the fit_model function

  • min_wavelength (float] (default=250.0))

  • max_wavelength (float] (default=12000.0))

  • input (Hdf5Handle (INPUT))

  • model (Hdf5Handle (OUTPUT))

__init__(args, **kwargs)

Initialize SedModeler class. If the SSP templates are not provided by the user, they are automatically downloaded from the public NERSC directory. These default templates are created with default FSPS values, with gas emission at fixed gas solar metallicity value. The _a tuple for jax is composed of None or 0, depending on whether you don’t or do want the array axis to map over for all arguments.

default_files_folder = '/home/docs/checkouts/readthedocs.org/user_builds/rail-hub/conda/latest/lib/python3.14/site-packages/rail/examples_data/creation_data/data/dsps_default_data'
entrypoint_function: str | None = 'fit_model'
fit_model(input_data='/home/docs/checkouts/readthedocs.org/user_builds/rail-hub/conda/latest/lib/python3.14/site-packages/rail/examples_data/creation_data/data/dsps_default_data/input_galaxy_properties_dsps.hdf5', Om0=0.3075, w0=-1.0, wa=0.0, h=0.6774, **kwargs)

This function generates the rest-frame SEDs and stores them into the Hdf5Handle.

Parameters:
  • input_data (str) – Filepath to the hdf5 table containing galaxy properties.

  • Om0 (float) – Omega matter: density of non-relativistic matter in units of the critical density at z=0.

  • w0 (float) – Dark energy equation of state at z=0 (a=1). This is pressure/density for dark energy in units where c=1.

  • wa (float) – Negative derivative of the dark energy equation of state with respect to the scale factor. A cosmological constant has w0=-1.0 and wa=0.0.

  • h (float) – dimensionless Hubble constant at z=0.

Returns:

Hdf5 table storing the rest-frame SED model

Return type:

Hdf5Handle

inputs = [('input', <class 'rail.core.data.Hdf5Handle'>)]
interactive_function: str | None = 'dsps_population_sed_modeler'
name = 'DSPSPopulationSedModeler'
outputs = [('model', <class 'rail.core.data.Hdf5Handle'>)]
run()

Run method. It Calls _get_rest_frame_seds from DSPS to create rest-frame SEDs for a population of galaxies. The load_ssp_templates function loads the SSP templates created with FSPS. The resulting NamedTuple has 4 entries:

ssp_lgmetndarray of shape (n_met, )
    Array of log10(Z) of the SSP templates where dimensionless Z is the mass fraction of elements heavier than He
ssp_lg_age_gyrndarray of shape (n_ages, )
    Array of log10(age/Gyr) of the SSP templates
ssp_wave : ndarray of shape (n_wave, )
ssp_fluxndarray of shape (n_met, n_ages, n_wave)
    SED of the SSP in units of Lsun/Hz/Msun

Notes

The initial stellar mass of the galaxy is 0. The definition of the stellar mass table as cumulative sum refers to the total stellar mass formed. DSPS conveniently provides IMF-dependent fitting functions to compute the surviving mass (see surviving_mstar.py). The units of the resulting rest-frame SED is solar luminosity per Hertz. The luminosity refers to that emitted by the formed mass at the time of observation.

class rail.creation.engines.dsps_sed_modeler.DSPSSingleSedModeler

Bases: Modeler

Derived class of Modeler for creating a single galaxy rest-frame SED model using DSPS v3. (Hearin+21). SPS calculations are based on a set of template SEDs of simple stellar populations (SSPs). Supplying such templates is outside the planned scope of the DSPS package, and so they will need to be retrieved from some other library. For example, the FSPS library supplies such templates in a convenient form.

The input galaxy properties, such as star-formation histories and metallicities, need to be supplied via an hdf5 table.

The user-provided metallicity grid should be consistently defined with the metallicity of the templates SEDs. Users should be cautious in the use of the cosmic time grid. The time resolution strongly depends on the user scientific aim.

Parameters:
  • output_mode ([str] default=default) – What to do with the outputs. The options are ‘default’, where outputs will be written to files and some returned, and ‘return’, where outputs will only be returned and not written.

  • ssp_templates_file ([str] default=/home/docs/checkouts/readthedocs.org/user_builds/rail-hub/conda/latest/lib/python3.14/site-packages/rail/examples_data/creation_data/data/dsps_default_data/ssp_data_fsps_v3.2_lgmet_age.h5) – hdf5 file storing the SSP libraries used to create SEDs

  • redshift_key (str] (default=redshifts))

  • cosmic_time_grid_key ([str] default=cosmic_time_grid) – Cosmic time grid keyword name of the hdf5 dataset, this is the grid of Universe age over which the stellar mass build-up takes place in units of Gyr

  • star_formation_history_key ([str] default=star_formation_history) – Star-formation history keyword name of the hdf5 dataset, this is the star-formation history of the galaxy in units of Msun/yr

  • stellar_metallicity_key ([str] default=stellar_metallicity) – Stellar metallicity keyword name of the hdf5 dataset, this is the stellar metallicity in units of log10(Z)

  • stellar_metallicity_scatter_key ([str] default=stellar_metallicity_scatter) – Stellar metallicity scatter keyword name of the hdf5 dataset, this is lognormal scatter in the metallicity distribution function

  • restframe_sed_key ([str] default=restframe_sed) – Rest-frame SED keyword name of the output hdf5 dataset

  • default_cosmology ([bool] default=True) – True to use default DSPS cosmology. If False,Om0, w0, wa, h need to be supplied in the fit_model function

  • min_wavelength (float] (default=250.0))

  • max_wavelength (float] (default=12000.0))

  • input (Hdf5Handle (INPUT))

  • model (Hdf5Handle (OUTPUT))

__init__(args, **kwargs)

Initialize SedModeler class. If the SSP templates are not provided by the user, they are automatically downloaded from the public NERSC directory. These default templates are created with default FSPS values, with gas emission at fixed gas solar metallicity value.

Parameters:
  • args

  • comm

default_files_folder = '/home/docs/checkouts/readthedocs.org/user_builds/rail-hub/conda/latest/lib/python3.14/site-packages/rail/examples_data/creation_data/data/dsps_default_data'
entrypoint_function: str | None = 'fit_model'
fit_model(input_data='/home/docs/checkouts/readthedocs.org/user_builds/rail-hub/conda/latest/lib/python3.14/site-packages/rail/examples_data/creation_data/data/dsps_default_data/input_galaxy_properties_dsps.hdf5', Om0=0.3075, w0=-1.0, wa=0.0, h=0.6774, **kwargs)

This function generates the rest-frame SEDs and stores them into the Hdf5Handle.

Parameters:
  • input_data (str) – Filepath to the hdf5 table containing galaxy properties.

  • Om0 (float) – Omega matter: density of non-relativistic matter in units of the critical density at z=0.

  • w0 (float) – Dark energy equation of state at z=0 (a=1). This is pressure/density for dark energy in units where c=1.

  • wa (float) – Negative derivative of the dark energy equation of state with respect to the scale factor. A cosmological constant has w0=-1.0 and wa=0.0.

  • h (float) – dimensionless Hubble constant at z=0.

Returns:

Hdf5 table storing the rest-frame SED model

Return type:

Hdf5Handle

inputs = [('input', <class 'rail.core.data.Hdf5Handle'>)]
interactive_function: str | None = 'dsps_single_sed_modeler'
name = 'DSPSSingleSedModeler'
outputs = [('model', <class 'rail.core.data.Hdf5Handle'>)]
run()

Run method. It Calls _get_rest_frame_seds from DSPS to create a galaxy rest-frame SED. The load_ssp_templates function loads the SSP templates created with FSPS. The resulting NamedTuple has 4 entries:

ssp_lgmetndarray of shape (n_met, )
    Array of log10(Z) of the SSP templates where dimensionless Z is the mass fraction of elements heavier than He
ssp_lg_age_gyrndarray of shape (n_ages, )
    Array of log10(age/Gyr) of the SSP templates
ssp_wave : ndarray of shape (n_wave, )
ssp_fluxndarray of shape (n_met, n_ages, n_wave)
    SED of the SSP in units of Lsun/Hz/Msun

Notes

The initial stellar mass of the galaxy is 0. The definition of the stellar mass table as cumulative sum refers to the total stellar mass formed. DSPS conveniently provides IMF-dependent fitting functions to compute the surviving mass (see surviving_mstar.py). The units of the resulting rest-frame SED is solar luminosity per Hertz. The luminosity refers to that emitted by the formed mass at the time of observation.