loudas_model

class zdm.optical.loudas_model(OpticalState=None, fname='p_mr_distributions_dz0.01_z_in_0_1.2.h5', data_dir=None, verbose=False)[source]

Bases: object

This class initiates a model based on Nick Loudas’s model of galaxy magnitudes as a function of redshift. The underlying model is a description of galaxies as a function of stellar mass and star-formation rate as a function of redshift.

Methods Summary

get_pmr_gz(mrbins, z)

Return the apparent magnitude probability distribution p(m_r | z).

give_p_mr_mass(z)

Return p(m_r | z) for the stellar-mass-weighted host population.

give_p_mr_sfr(z)

Return p(m_r | z) for the star-formation-rate-weighted host population.

init_args(fSFR)

Set the SFR/mass mixing fraction for the Loudas model.

init_cubics()

initialises cubic splines that interpolate in mr.

init_pmr(fname, data_dir)

Loads p(mr|z) distributions from Nick Loudas.

init_priors(zlist)

Generates magniude prior distributions for a list of redshifts This allows faster interpolation later.

load_p_mr_distributions(data_dir[, fname])

This code originally written by Nick Loudas.

Methods Documentation

get_pmr_gz(mrbins, z)[source]

Return the apparent magnitude probability distribution p(m_r | z).

Interpolates between the two nearest tabulated redshift bins (in log-z space), applying a luminosity-distance shift to each tabulated p(m_r) before combining them. The mass- and SFR-weighted distributions are mixed according to self.fsfr (set via init_args).

The result is normalised so that the bin probabilities sum to unity over the full magnitude range, provided the distribution does not extend significantly beyond mrbins.

Parameters:
  • mrbins (array-like of float, length N+1) – Edges of the apparent magnitude bins. Output has length N.

  • z (float) – Redshift at which to evaluate the distribution. Values outside the tabulated range are extrapolated from the nearest edge bin.

Returns:

pmr – Probability in each apparent magnitude bin (sums to ≤ 1).

Return type:

np.ndarray, length N

give_p_mr_mass(z: float)[source]

Return p(m_r | z) for the stellar-mass-weighted host population.

Uses a nearest-bin lookup (no interpolation) in the tabulated redshift grid. For interpolated results with luminosity-distance shifting, use get_pmr_gz with fSFR=0 instead.

Parameters:

z (float) – Redshift value.

Returns:

p(m_r | z) values at the tabulated r-band magnitude

centres (self.rmags), normalised to sum to unity.

Return type:

np.ndarray

give_p_mr_sfr(z: float)[source]

Return p(m_r | z) for the star-formation-rate-weighted host population.

Uses a nearest-bin lookup (no interpolation) in the tabulated redshift grid. For interpolated results with luminosity-distance shifting, use get_pmr_gz with fSFR=1 instead.

Parameters:

z (float) – Redshift value.

Returns:

p(m_r | z) values at the tabulated r-band magnitude

centres (self.rmags), normalised to sum to unity.

Return type:

np.ndarray

init_args(fSFR)[source]

Set the SFR/mass mixing fraction for the Loudas model.

Parameters:

fSFR (float or array-like of length 1) – fraction of FRB hosts that trace star-formation rate. fSFR=0 gives a purely mass-weighted population; fSFR=1 gives a purely SFR-weighted population. Intermediate values linearly mix the two. If an array is passed, only the first element is used.

init_cubics()[source]

initialises cubic splines that interpolate in mr. For later use (speedup!)

init_pmr(fname, data_dir)[source]

Loads p(mr|z) distributions from Nick Loudas. Note - these are actually distributions in apparent magnitude mr.

Mostly, this wraps around Nick’s code “load_p_mr_distributions”. I’ve kept them separate to distinguish between his code and mine -CWJ.

init_priors(zlist)[source]

Generates magniude prior distributions for a list of redshifts This allows faster interpolation later.

Currently, this is not used!

load_p_mr_distributions(data_dir, fname: str = 'p_mr_distributions_dz0.01_z_in_0_1.2.h5') tuple[source]

This code originally written by Nick Loudas. Used with permission

Load the p(mr|z) distributions from an HDF5 file. :param fname: Input filename. :type fname: str :param output_dir: Directory where the file is stored. Optional (otherwise defaults as below) :type output_dir: str

Returns:

Redshift bin edges. rmag_centers (np.array): Centers of r-band magnitude bins. p_mr_sfr (np.array): p(mr|z) for SFR-weighted population. Shape: (len(zbins) - 1,

rmag_resolution). rmag_resolution(=len(rmag_centers)) is fixed across redshift bins.

p_mr_mass (np.array): p(mr|z) for Mass-weighted population. Shape: (len(zbins) - 1,

rmag_resolution). rmag_resolution(=len(rmag_centers)) is fixed across redshift bins.

Return type:

zbins (np.array)

Note

The PDF in m_r within a given redshift bin [z1,z2] has been computed at the right edge of the bin (z = z2).

__init__(OpticalState=None, fname='p_mr_distributions_dz0.01_z_in_0_1.2.h5', data_dir=None, verbose=False)[source]

Initialise the Loudas model, loading precomputed p(m_r | z) tables.

Parameters:
  • OpticalState (OpticalState, optional) – optical parameter state. A default OpticalState is created if not provided.

  • fname (str) – HDF5 filename containing the Loudas p(m_r | z) tables. Defaults to 'p_mr_distributions_dz0.01_z_in_0_1.2.h5'.

  • data_dir (str, optional) – directory containing fname. Defaults to the package data directory zdm/data/optical/.

  • verbose (bool) – if True, print progress messages. Defaults to False.

init_pmr(fname, data_dir)[source]

Loads p(mr|z) distributions from Nick Loudas. Note - these are actually distributions in apparent magnitude mr.

Mostly, this wraps around Nick’s code “load_p_mr_distributions”. I’ve kept them separate to distinguish between his code and mine -CWJ.

init_cubics()[source]

initialises cubic splines that interpolate in mr. For later use (speedup!)

get_pmr_gz(mrbins, z)[source]

Return the apparent magnitude probability distribution p(m_r | z).

Interpolates between the two nearest tabulated redshift bins (in log-z space), applying a luminosity-distance shift to each tabulated p(m_r) before combining them. The mass- and SFR-weighted distributions are mixed according to self.fsfr (set via init_args).

The result is normalised so that the bin probabilities sum to unity over the full magnitude range, provided the distribution does not extend significantly beyond mrbins.

Parameters:
  • mrbins (array-like of float, length N+1) – Edges of the apparent magnitude bins. Output has length N.

  • z (float) – Redshift at which to evaluate the distribution. Values outside the tabulated range are extrapolated from the nearest edge bin.

Returns:

pmr – Probability in each apparent magnitude bin (sums to ≤ 1).

Return type:

np.ndarray, length N

load_p_mr_distributions(data_dir, fname: str = 'p_mr_distributions_dz0.01_z_in_0_1.2.h5') tuple[source]

This code originally written by Nick Loudas. Used with permission

Load the p(mr|z) distributions from an HDF5 file. :param fname: Input filename. :type fname: str :param output_dir: Directory where the file is stored. Optional (otherwise defaults as below) :type output_dir: str

Returns:

Redshift bin edges. rmag_centers (np.array): Centers of r-band magnitude bins. p_mr_sfr (np.array): p(mr|z) for SFR-weighted population. Shape: (len(zbins) - 1,

rmag_resolution). rmag_resolution(=len(rmag_centers)) is fixed across redshift bins.

p_mr_mass (np.array): p(mr|z) for Mass-weighted population. Shape: (len(zbins) - 1,

rmag_resolution). rmag_resolution(=len(rmag_centers)) is fixed across redshift bins.

Return type:

zbins (np.array)

Note

The PDF in m_r within a given redshift bin [z1,z2] has been computed at the right edge of the bin (z = z2).

give_p_mr_mass(z: float)[source]

Return p(m_r | z) for the stellar-mass-weighted host population.

Uses a nearest-bin lookup (no interpolation) in the tabulated redshift grid. For interpolated results with luminosity-distance shifting, use get_pmr_gz with fSFR=0 instead.

Parameters:

z (float) – Redshift value.

Returns:

p(m_r | z) values at the tabulated r-band magnitude

centres (self.rmags), normalised to sum to unity.

Return type:

np.ndarray

give_p_mr_sfr(z: float)[source]

Return p(m_r | z) for the star-formation-rate-weighted host population.

Uses a nearest-bin lookup (no interpolation) in the tabulated redshift grid. For interpolated results with luminosity-distance shifting, use get_pmr_gz with fSFR=1 instead.

Parameters:

z (float) – Redshift value.

Returns:

p(m_r | z) values at the tabulated r-band magnitude

centres (self.rmags), normalised to sum to unity.

Return type:

np.ndarray

init_args(fSFR)[source]

Set the SFR/mass mixing fraction for the Loudas model.

Parameters:

fSFR (float or array-like of length 1) – fraction of FRB hosts that trace star-formation rate. fSFR=0 gives a purely mass-weighted population; fSFR=1 gives a purely SFR-weighted population. Intermediate values linearly mix the two. If an array is passed, only the first element is used.

init_priors(zlist)[source]

Generates magniude prior distributions for a list of redshifts This allows faster interpolation later.

Currently, this is not used!