get_dm_mask

zdm.pcosmic.get_dm_mask(dmvals, params, zvals=None, plot=False)[source]

Generate a convolution kernel for host galaxy DM contribution.

Creates a probability distribution p(DM_host) following a lognormal distribution. This kernel can be convolved with p(DM_cosmic|z) to obtain the full p(DM_extragalactic|z) = p(DM_cosmic + DM_host|z).

The host DM contribution is redshift-corrected: observed DM_host is reduced by (1+z) relative to the rest-frame value.

Parameters:
  • dmvals (ndarray) – DM grid values (bin centers) in pc/cm^3.

  • params (array_like) – [log10_mean, log10_sigma] - lognormal parameters for host DM distribution in log10 space.

  • zvals (ndarray, optional) – If provided, compute a redshift-dependent mask where host DM is scaled by 1/(1+z). If None, return a single z-independent mask.

  • plot (bool, optional) – If True, generate diagnostic plots. Default is False.

Returns:

If zvals is None: 1D array of shape (len(dmvals),) containing p(DM_host). If zvals is provided: 2D array of shape (len(zvals), len(dmvals)). Each row/vector is normalized to sum to 1.

Return type:

ndarray

Notes

The mask is designed for discrete convolution: p(DM_EG)[i] = sum_j p(DM_cosmic)[i-j] * mask[j]