hmf.helpers.functional.get_hmf

hmf.helpers.functional.get_hmf(req_qauntities, get_label=True, framework=<class 'hmf.mass_function.hmf.MassFunction'>, fast_kwargs={'Mmax': 11.5, 'Mmin': 10, 'dlnk': 1, 'dlog10m': 0.5, 'lnk_max': 1, 'lnk_min': -1, 'transfer_model': 'BBKS'}, label_kind='display', label_kwargs=None, **kwargs)[source]

Yield framework instances for all combinations of parameters supplied.

The underlying idea here is that typically modifying say the redshift has a smaller number of re-computations than modifying the base cosmological parameters. Thus, in a nested loop, the redshift should be the inner loop.

It is not always obvious which order the loops should be, but this function internally determines the order, and calculates the requisite quantities in a series of framework instances.

Parameters
  • req_qauntities (str or list of str) – A string defining the quantities that should be pre-cached in the output instances. It is advisable that any required quantities for a given application be provided here, to ensure proper optimization.

  • get_label (bool, optional) – Whether to return a list of string labels designating each combination of parameters.

  • framework (hmf._framework.Framework class, optional) – A framework for which to perform the optimization.

  • fast_kwargs (dict, optional) – Parameters to be used in the initial run to determine optimal order. These should be set to provide very quick calculation, and do not affect the final result. This will need to be over-ridden for frameworks other than hmf.MassFunction.

  • kwargs (unpacked-dict) – Any of the parameters to the initialiser of framework which should be calculated. These may be scalar or lists. The total number of calculations will be the total combination of all parameters.

Yields
  • quantities (list) – A list of quantities, specified by the req_quantities arguments

  • x (Framework instance) – An instance of framework, with the requisite quantities pre-cached.

  • label (optional) – If get_label is True, also returns a string label uniquely specifying the current parameter combination.

Examples

The following operation will run 12 iterations, yielding the desired quantities, an instance containing those and other quantities, and a unique label at every iteration.

>>> for quants, mf, label in get_hmf(['dndm','ngtm'],z=range(3),hmf_model=["ST","PS"],sigma_8=[0.7,0.8]):
>>>     print label
sigma.8: 0.7, ST, z: 0
sigma.8: 0.7, PS, z: 0
sigma.8: 0.7, ST, z: 1
sigma.8: 0.7, PS, z: 1
sigma.8: 0.7, ST, z: 2
sigma.8: 0.7, PS, z: 2
sigma.8: 0.8, ST, z: 0
sigma.8: 0.8, PS, z: 0
sigma.8: 0.8, ST, z: 1
sigma.8: 0.8, PS, z: 1
sigma.8: 0.8, ST, z: 2
sigma.8: 0.8, PS, z: 2

To calculate all of them and keep the results as a list:

>>> big_list = list(get_hmf('mean_density',z=range(8)))
>>> print [x[0][0]/1e10 for x in big_list]
[8.531878308131338, 68.2550264650507, 230.36071431954613, 546.0402117204056, 1066.4847885164174, 1842.885714556369, 2926.434259689049, 4368.321693763245]