host_model
- class zdm.optical.host_model(opstate=None, verbose=False)[source]
Bases:
objectA class to hold information about the intrinsic properties of FRB host galaxies. Eventually, this should be expanded to be a meta-class with different internal models. But for now, it’s just a simple one
- Ingredients are:
- A model for describing the intrinsic distribution
of host galaxies. This model must be described by some set of parameters, and be able to return a prior as a function of intrinsic host galaxy magnitude. This model is initialised via opstate.AbsModelID
- A model for converting absolute to apparent host magnitudes.
This is by defult an apparent r-band magnitude, though in theory a user can work in whatever band they wish.
- Internally, this class initialises:
An array of absolute magnitudes, which get weighted according to the host model. Internal variables associated with this are prefaced “Model”
An array of apparent magnitudes, which is used to compare with host galaxy candidates Internal variables associated with this are prefaced “App”
Arrays mapping intrinsic to absolute magnitude as a function of redshift, to allow quick estimation of p(apparent_mag | DM) for a given FRB survey with many FRBs Internal variables associated with this are prefaced “Abs”
Note that while this class describes the intrinsic “magnitudes”, really magnitude here is a proxy for whatever parameter is used to intrinsically describe FRBs. However, only 1D descriptions are currently implemented. Future descriptions will include redshift evolution, and 2D descriptions (e.g. mass, SFR) at any given redshift.
Methods Summary
calc_magnitude_priors(zlist, pzlist)Calculates priors as a function of magnitude for a given redshift distribution.
estimate_unseen_prior(mag_limit)Calculates PU, the prior that an FRB host galaxy of a particular DM is unseen in the optical image
get_posterior(grid, DM)Returns posterior redshift distributiuon for a given grid, and DM magnitude distribution, for FRBs of DM given a grid object. Note: this calculates a prior for PATH, but is a posterior from zDM's point of view.
Initialises internal array of absolute magnitudes This is a simple set of uniformly log-spaced bins in terms of absolute magnitude, which the absolute magnitude model gets projected onto
Assigns a weight to each of the absolute magnitudes in the internal array (which generally is very large) in terms of the absolute magnitude parameterisation (generally, only a few parameters)
Initialises prior on absolute magnitude of galaxies according to the method.
Initialises bins in apparent magnitude It uses these to calculate priors for any given host galaxy magnitude.
Initialises the array mapping redshifts and absolute magnitudes to redshift and apparent magnitude
Initialises bins for the simple model of an absolute magnitude prior.
init_path_raw_prior_Oi(DM, grid)Initialises the priors for a particlar DM.
init_zmapping(zvals)For a set of redshifts, initialise mapping between intrinsic magnitudes and apparent magnitudes
path_raw_prior_Oi(mags, ang_sizes, Sigma_ms)Function to pass to astropath module for calculating a raw FRB prior.
Re-initialises all internal info which depends on the optical param model.
Methods Documentation
- calc_magnitude_priors(zlist: ndarray, pzlist: ndarray)[source]
Calculates priors as a function of magnitude for a given redshift distribution.
- Parameters:
# returns probability-weighted magnitude distribution, as a function of # self.AppBins
- estimate_unseen_prior(mag_limit)[source]
Calculates PU, the prior that an FRB host galaxy of a particular DM is unseen in the optical image
This requires initialisation of init_path_raw_prior_Oi
- NOTE: The total normalisation of priors in the magnitude range
may be less than unity. This is because some probability may fall outside of the magnitude range being examined. Hence, the correct normalisation is found by summing the visible magnitudes, and subtracting them from unity.
- get_posterior(grid, DM)[source]
Returns posterior redshift distributiuon for a given grid, and DM magnitude distribution, for FRBs of DM given a grid object. Note: this calculates a prior for PATH, but is a posterior
from zDM’s point of view.
- Parameters:
grid (class grid object) – grid object defining p(z,DM)
DM (float, np.ndarray OR scalar) – FRB DM(s)
- Returns:
probability distribution of apparent magnitudes given DM pz (np.ndarray, floats): probability distribution of redshift given DM
- Return type:
papps (np.ndarray, floats)
- init_abs_bins()[source]
Initialises internal array of absolute magnitudes This is a simple set of uniformly log-spaced bins in terms of absolute magnitude, which the absolute magnitude model gets projected onto
- init_abs_mag_weights()[source]
Assigns a weight to each of the absolute magnitudes in the internal array (which generally is very large) in terms of the absolute magnitude parameterisation (generally, only a few parameters)
- init_abs_prior()[source]
Initialises prior on absolute magnitude of galaxies according to the method.
- init_app_bins()[source]
Initialises bins in apparent magnitude It uses these to calculate priors for any given host galaxy magnitude. This is a very simple set of uniformly log-spaced bins in magnitude space, and linear interpolation is used between them.
- init_maghist()[source]
Initialises the array mapping redshifts and absolute magnitudes to redshift and apparent magnitude
Calculates the internal maghist array, of size self.NAppBins X self.NZ
No return value.
- init_model_bins()[source]
Initialises bins for the simple model of an absolute magnitude prior. This is much sparser than the app or abs bins, since these model bins correspond to parameters which may get adjusted by e.g. an MCMC
The base unit here is assumed to be absolute r-band magnitude M, but in principle this works for whatever absolute unit is being used by the model.
- init_path_raw_prior_Oi(DM, grid)[source]
Initialises the priors for a particlar DM. This performs a function very similar to “get_posterior” except that it expicitly only operates on a single DM, and saves the information internally so that path_raw_prior_Oi can be called for numerous host galaxy candidates.
It returns the priors distribution.
- Parameters:
[float] (DM) – dispersion measure of an FRB (pc cm-3)
grid (class grid) – initialised grid object from which to calculate priors
- Returns:
vector of priors on host galaxy apparent magnitude
- Return type:
priors (float)
- init_zmapping(zvals)[source]
For a set of redshifts, initialise mapping between intrinsic magnitudes and apparent magnitudes
This routine only needs to be called once, since the model to convert absolute to apparent magnitudes is fixed
It is not set automatically however, and needs to be called with a set of z values. This is all for speedup purposes.
- Parameters:
zvals (np.ndarray, float) – array of redshifts over which to map absolute to apparent magnitudes.
- path_raw_prior_Oi(mags, ang_sizes, Sigma_ms)[source]
Function to pass to astropath module for calculating a raw FRB prior.
- NOTE: as of all recent PATH iterations, the galaxy angular
size should NOT be included in the calculation, since this gets integrated over in estimating the offset error. Nonetheless, this function must accept an ang_size argument.
- NOTE2: Before using this function, the call “init_path_raw_prior_Oi”
must be called. This is because the full prior requires a zDM grid and an FRB DM, yet this cannot be passed to raw_prior_Oi within PATH.
- reinit_model()[source]
Re-initialises all internal info which depends on the optical param model. It assumes that the changes have been implemented in self.AbsPrior
- __init__(opstate=None, verbose=False)[source]
Class constructor
- Parameters:
(class (opstate) – Hosts, optional): class defining parameters of optical state model
verbose (bool, optional) – to be verbose y/n
- init_abs_prior()[source]
Initialises prior on absolute magnitude of galaxies according to the method.
- init_app_bins()[source]
Initialises bins in apparent magnitude It uses these to calculate priors for any given host galaxy magnitude. This is a very simple set of uniformly log-spaced bins in magnitude space, and linear interpolation is used between them.
- init_abs_bins()[source]
Initialises internal array of absolute magnitudes This is a simple set of uniformly log-spaced bins in terms of absolute magnitude, which the absolute magnitude model gets projected onto
- init_model_bins()[source]
Initialises bins for the simple model of an absolute magnitude prior. This is much sparser than the app or abs bins, since these model bins correspond to parameters which may get adjusted by e.g. an MCMC
The base unit here is assumed to be absolute r-band magnitude M, but in principle this works for whatever absolute unit is being used by the model.
- init_zmapping(zvals)[source]
For a set of redshifts, initialise mapping between intrinsic magnitudes and apparent magnitudes
This routine only needs to be called once, since the model to convert absolute to apparent magnitudes is fixed
It is not set automatically however, and needs to be called with a set of z values. This is all for speedup purposes.
- Parameters:
zvals (np.ndarray, float) – array of redshifts over which to map absolute to apparent magnitudes.
- init_maghist()[source]
Initialises the array mapping redshifts and absolute magnitudes to redshift and apparent magnitude
Calculates the internal maghist array, of size self.NAppBins X self.NZ
No return value.
- reinit_model()[source]
Re-initialises all internal info which depends on the optical param model. It assumes that the changes have been implemented in self.AbsPrior
- init_abs_mag_weights()[source]
Assigns a weight to each of the absolute magnitudes in the internal array (which generally is very large) in terms of the absolute magnitude parameterisation (generally, only a few parameters)
- estimate_unseen_prior(mag_limit)[source]
Calculates PU, the prior that an FRB host galaxy of a particular DM is unseen in the optical image
This requires initialisation of init_path_raw_prior_Oi
- NOTE: The total normalisation of priors in the magnitude range
may be less than unity. This is because some probability may fall outside of the magnitude range being examined. Hence, the correct normalisation is found by summing the visible magnitudes, and subtracting them from unity.
- path_raw_prior_Oi(mags, ang_sizes, Sigma_ms)[source]
Function to pass to astropath module for calculating a raw FRB prior.
- NOTE: as of all recent PATH iterations, the galaxy angular
size should NOT be included in the calculation, since this gets integrated over in estimating the offset error. Nonetheless, this function must accept an ang_size argument.
- NOTE2: Before using this function, the call “init_path_raw_prior_Oi”
must be called. This is because the full prior requires a zDM grid and an FRB DM, yet this cannot be passed to raw_prior_Oi within PATH.
- init_path_raw_prior_Oi(DM, grid)[source]
Initialises the priors for a particlar DM. This performs a function very similar to “get_posterior” except that it expicitly only operates on a single DM, and saves the information internally so that path_raw_prior_Oi can be called for numerous host galaxy candidates.
It returns the priors distribution.
- Parameters:
[float] (DM) – dispersion measure of an FRB (pc cm-3)
grid (class grid) – initialised grid object from which to calculate priors
- Returns:
vector of priors on host galaxy apparent magnitude
- Return type:
priors (float)
- calc_magnitude_priors(zlist: ndarray, pzlist: ndarray)[source]
Calculates priors as a function of magnitude for a given redshift distribution.
- Parameters:
# returns probability-weighted magnitude distribution, as a function of # self.AppBins
- get_posterior(grid, DM)[source]
Returns posterior redshift distributiuon for a given grid, and DM magnitude distribution, for FRBs of DM given a grid object. Note: this calculates a prior for PATH, but is a posterior
from zDM’s point of view.
- Parameters:
grid (class grid object) – grid object defining p(z,DM)
DM (float, np.ndarray OR scalar) – FRB DM(s)
- Returns:
probability distribution of apparent magnitudes given DM pz (np.ndarray, floats): probability distribution of redshift given DM
- Return type:
papps (np.ndarray, floats)