This Python package enables estimation of cosmological quantities using photometric redshift probability distributions.
Simulation¶
chippr enables simulation of surveys of photo-z interim posteriors.
The discrete Class¶
-
class
discrete.
discrete
(bin_ends, weights)[source]¶ -
evaluate
(xs)[source]¶ Function to evaluate the discrete probability distribution at many points
Parameters: xs (ndarray, float) – values at which to evaluate discrete probability distribution Returns: ps – values of discrete probability distribution at xs Return type: ndarray, float
-
evaluate_one
(x)[source]¶ Function to evaluate the discrete probability distribution at one point
Parameters: x (float) – value at which to evaluate discrete probability distribution Returns: p – value of discrete probability distribution at x Return type: float
-
The gauss Class¶
-
class
gauss.
gauss
(mean, var, limits=(-4503599627370496.0, 4503599627370496.0))[source]¶ -
evaluate
(xs)[source]¶ Function to evaluate Gaussian probability distribution at multiple points
Parameters: xs (float or ndarray, float) – input values at which to evaluate probability Returns: ps – output probabilities Return type: float or ndarray, float
-
evaluate_one
(x)[source]¶ Function to evaluate Gaussian probability distribution once
Parameters: x (float) – value at which to evaluate Gaussian probability distribution Returns: p – probability associated with x Return type: float
-
The gmix Class¶
-
class
gmix.
gmix
(amps, means, sigmas, limits=(-4503599627370496.0, 4503599627370496.0))[source]¶ -
evaluate
(xs)[source]¶ Function to evaluate the Gaussian mixture probability distribution at many points
Parameters: xs (ndarray, float) – values at which to evaluate Gaussian mixture probability distribution Returns: ps – values of Gaussian mixture probability distribution at xs Return type: ndarray, float
-
evaluate_one
(x)[source]¶ Function to evaluate the Gaussian mixture probability distribution at one point
Parameters: x (float) – value at which to evaluate Gaussian mixture probability distribution Returns: p – value of Gaussian mixture probability distribution at x Return type: float
-
The catalog Class¶
Simulation Utilities¶
-
sim_utils.
choice
(weights)[source]¶ Function sampling discrete distribution
Parameters: weights (numpy.ndarray) – relative probabilities for each category Returns: index – chosen category Return type: int
-
sim_utils.
ingest
(in_info)[source]¶ Function reading in parameter file to define functions necessary for generation of posterior probability distributions
Parameters: in_info (string or dict) – string containing path to plaintext input file or dict containing likelihood input parameters Returns: in_dict – dict containing keys and values necessary for posterior probability distributions Return type: dict
Inference¶
chippr currently enables estimation of the redshift density function.
The log_z_dens Class¶
-
class
log_z_dens.
log_z_dens
(catalog, hyperprior, truth=None, vb=True)[source]¶ -
log_hyper_posterior
(log_nz)[source]¶ Function to evaluate log hyperposterior
Parameters: log_nz (numpy.ndarray, float) – vector of logged redshift density bin values at which to evaluate the full posterior Returns: log_prob – log posterior probability associated with parameters in log_nz Return type: float
-
mexp
()[source]¶ Calculates the marginalized expected value estimator of the redshift density function
Returns: mexp_dens – array of redshift density function bin values Return type: ndarray
-
mmap
()[source]¶ Calculates the marginalized maximum a posteriori estimator of the redshift density function
Returns: mmap_dens – array of redshift density function bin values Return type: ndarray
-
optimize
(start, vb=True)[source]¶ Calculates the marginalized maximum likelihood estimator of the redshift density function
Parameters: - start (numpy.ndarray) – array of log redshift density function bin values at which to begin optimization
- vb (boolean, optional) – True to print progress messages to stdout, False to suppress
Returns: mmle_dens – array of redshift density function bin values
Return type: numpy.ndarray
-
sample
(n_samps, vb=True)[source]¶ Calculates samples estimating the redshift density function
Parameters: - n_samps (int) – number of samples to accept before stopping
- vb (boolean, optional) – True to print progress messages to stdout, False to suppress
Returns: samp_dens – array of sampled redshift density function bin values
Return type: ndarray
-
Plotting Utilities¶
-
plot_utils.
plot_h
(sub_plot, bin_ends, plot, s='--', c='k', a=1, w=1, d=[(0, (1, 0.0001))], l=None, r=False)[source]¶ Helper function to plot horizontal lines of a step function
Parameters: - sub_plot (matplotlib.pyplot subplot object) – subplot into which step function is drawn
- bin_ends (list or ndarray) – list or array of endpoints of bins
- plot (list or ndarray) – list or array of values within each bin
- s (string, optional) – matplotlib.pyplot linestyle
- c (string, optional) – matplotlib.pyplot color
- a (int or float, [0., 1.], optional) – matplotlib.pyplot alpha (transparency)
- w (int or float, optional) – matplotlib.pyplot linewidth
- d (list of tuple, optional) – matplotlib.pyplot dash style, of form [(start_point, (points_on, points_off, ...))]
- l (string, optional) – label for function
- r (boolean, optional) – True for rasterized, False for vectorized
-
plot_utils.
plot_step
(sub_plot, bin_ends, plot, s='--', c='k', a=1, w=1, d=[(0, (1, 0.0001))], l=None, r=False)[source]¶ Plots a step function
Parameters: - sub_plot (matplotlib.pyplot subplot object) – subplot into which step function is drawn
- bin_ends (list or ndarray) – list or array of endpoints of bins
- plot (list or ndarray) – list or array of values within each bin
- s (string, optional) – matplotlib.pyplot linestyle
- c (string, optional) – matplotlib.pyplot color
- a (int or float, [0., 1.], optional) – matplotlib.pyplot alpha (transparency)
- w (int or float, optional) – matplotlib.pyplot linewidth
- d (list of tuple, optional) – matplotlib.pyplot dash style, of form [(start_point, (points_on, points_off, ...))]
- l (string, optional) – label for function
- r (boolean, optional) – True for rasterized, False for vectorized
-
plot_utils.
plot_v
(sub_plot, bin_ends, plot, s='--', c='k', a=1, w=1, d=[(0, (1, 0.0001))], r=False)[source]¶ Helper function to plot vertical lines of a step function
Parameters: - sub_plot (matplotlib.pyplot subplot object) – subplot into which step function is drawn
- bin_ends (list or ndarray) – list or array of endpoints of bins
- plot (list or ndarray) – list or array of values within each bin
- s (string, optional) – matplotlib.pyplot linestyle
- c (string, optional) – matplotlib.pyplot color
- a (int or float, [0., 1.], optional) – matplotlib.pyplot alpha (transparency)
- w (int or float, optional) – matplotlib.pyplot linewidth
- d (list of tuple, optional) – matplotlib.pyplot dash style, of form [(start_point, (points_on, points_off, ...))]
- r (boolean, optional) – True for rasterized, False for vectorized