The hmpdf code computes one- and two-point PDFs, the covariance matrix of the one-point PDF, and the angular power spectrum/correlation function of cosmological fields.
The formalism is based on the halo model, thus, only fields that are mainly sourced by virialized matter make sense.
Currently, two fields are supported:
The code is interfaced both through C header files as well as through a convenient python wrapper.
Applications of the code can be found in
which we also request you cite if you use the code.
Dependencies:
Compilation should be straightforward. You may have to edit the following parts of the Makefile:
Then you can simply type make
.
Afterwards, if you intend to use the python wrapper, type make python
. This will run pip. It will also hardcode the location of libhmpdf.so into the python package, which has the advantage that you can recompile the C code without having to run pip again, and the disadvantage that you need to keep libhmpdf.so where it is.
It may also be convenient to copy libhmpdf.so into one of the default locations searched by the linker.
The C interface can be found in hmpdf.h. All exposed objects' names start with hmpdf_ to help you keep your name space clean.
Workflow is as follows:
There is also a Python wrapper (hmpdf.py), with analogous workflow and simpler syntax.
There is a number of optional arguments to hmpdf_init(), the most important ones to get you started are
See the documentation of hmpdf_configs_e for all options.
The following were found with default settings on a laptop. These functions scale as hmpdf_N_M x hmpdf_N_z, this is omitted in the following:
The simplified simulations (maps) scale as hmpdf_map_fsky / hmpdf_pixel_side^2.
Other functions are fast in comparison to hmpdf_init(). hmpdf_init(), hmpdf_get_cov(), hmpdf_get_map(), hmpdf_get_map_op() are parallelized in critical parts, while hmpdf_get_tp() does not get faster if hmpdf_N_threads is increased. The simplified simulations can easily become memory throughput-limited, in which case speed does not scale well with hmpdf_N_threads.
All functions [except hmpdf_new()] return a non-zero int if an error occured. A traceback will be printed to stderr. You can remove the definition of the macro DEBUG in the Makefile, in which case no error handling at all will be happening (could give a marginal speed-up in some cases, but not recommended).
All functions are not threadsafe: making two calls on the same hmpdf_obj concurrently results in undefined behaviour.
Some examples are collected in examples/example.c and examples/example.py. You can compile the C code with
A simple calculation of the weak lensing convergence one-point PDF with all settings at default would look like this:
The same thing using the python wrapper is really easy:
Including the effect of an ell-space filter would look like this:
Here, we defined the function example_ell_filter conforming to the typedef hmpdf_ell_filter_f:
We can also do this in python (note, however, that due to the overhead in calling the python lambda this will be slower than in C):
For a more involved example, in examples/WL_PDF_forecast/ you can find all ingredients to reproduce the Fisher forecast from the WL convergence PDF.