py21cmfast.wrapper.cfuncs ========================= .. py:module:: py21cmfast.wrapper.cfuncs .. autoapi-nested-parse:: Low-level python wrappers of C functions. .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: py21cmfast.wrapper.cfuncs.logger Functions --------- .. autoapisummary:: py21cmfast.wrapper.cfuncs.broadcast_input_struct py21cmfast.wrapper.cfuncs.broadcast_params py21cmfast.wrapper.cfuncs.compute_luminosity_function py21cmfast.wrapper.cfuncs.compute_tau py21cmfast.wrapper.cfuncs.construct_fftw_wisdoms py21cmfast.wrapper.cfuncs.convert_halo_properties py21cmfast.wrapper.cfuncs.evaluate_FgtrM_cond py21cmfast.wrapper.cfuncs.evaluate_Nion_cond py21cmfast.wrapper.cfuncs.evaluate_Nion_z py21cmfast.wrapper.cfuncs.evaluate_SFRD_cond py21cmfast.wrapper.cfuncs.evaluate_SFRD_z py21cmfast.wrapper.cfuncs.evaluate_Xray_cond py21cmfast.wrapper.cfuncs.evaluate_condition_integrals py21cmfast.wrapper.cfuncs.evaluate_inverse_table py21cmfast.wrapper.cfuncs.evaluate_sigma py21cmfast.wrapper.cfuncs.free_cosmo_tables py21cmfast.wrapper.cfuncs.get_condition_mass py21cmfast.wrapper.cfuncs.get_delta_crit py21cmfast.wrapper.cfuncs.get_delta_crit_nu py21cmfast.wrapper.cfuncs.get_expected_nhalo py21cmfast.wrapper.cfuncs.get_growth_factor py21cmfast.wrapper.cfuncs.get_halo_catalog_buffer_size py21cmfast.wrapper.cfuncs.get_matter_power_values py21cmfast.wrapper.cfuncs.init_backend_ps py21cmfast.wrapper.cfuncs.init_gl py21cmfast.wrapper.cfuncs.init_sigma_table py21cmfast.wrapper.cfuncs.integrate_chmf_interval py21cmfast.wrapper.cfuncs.return_chmf_value py21cmfast.wrapper.cfuncs.return_uhmf_value py21cmfast.wrapper.cfuncs.sample_halos_from_conditions Module Contents --------------- .. py:function:: broadcast_input_struct(inputs) Broadcast the parameters to the C library. .. !! processed by numpydoc !! .. py:function:: broadcast_params(func) Broadcast the parameters to the C library before calling the function. This should be added as a decorator to any function which accesses the 21cmFAST if it does not directly call `broadcast_input_struct`. .. !! processed by numpydoc !! .. py:function:: compute_luminosity_function(*, redshifts, inputs, nbins = 100, mturnovers = None, mturnovers_mini = None, component = 'both') Compute a the luminosity function over a given number of bins and redshifts. :Parameters: * **redshifts** (*array-like*) -- The redshifts at which to compute the luminosity function. * **inputs** (:class:`~InputParameters`) -- The input parameters defining the simulation run. * **nbins** (*int, optional*) -- The number of luminosity bins to produce for the luminosity function. * **mturnovers** (*array-like, optional*) -- The turnover mass at each redshift for massive halos (ACGs). Only required when USE_MINI_HALOS is True. * **mturnovers_mini** (*array-like, optional*) -- The turnover mass at each redshift for minihalos (MCGs). Only required when USE_MINI_HALOS is True. * **component** (*str, {'both', 'acg', 'mcg}*) -- The component of the LF to be calculated. :returns: * **Muvfunc** (*np.ndarray*) -- Magnitude array (i.e. brightness). Shape [nredshifts, nbins] * **Mhfunc** (*np.ndarray*) -- Halo mass array. Shape [nredshifts, nbins] * **lfunc** (*np.ndarray*) -- Number density of haloes corresponding to each bin defined by `Muvfunc`. Shape [nredshifts, nbins]. .. !! processed by numpydoc !! .. py:function:: compute_tau(*, redshifts, global_xHI, inputs, z_re_HeII = 3.0) Compute the optical depth to reionization under the given model. :Parameters: * **redshifts** (*array-like*) -- Redshifts defining an evolution of the neutral fraction. * **global_xHI** (*array-like*) -- The mean neutral fraction at `redshifts`. * **inputs** (:class:`~InputParameters`) -- Defines the input parameters of the run * **z_re_HeII** (*float, optional*) -- The redshift at which helium reionization occurs. :returns: **tau** (*float*) -- The optical depth to reionization :raises ValueError :: If `redshifts` and `global_xHI` have inconsistent length or if redshifts are not in ascending order. .. !! processed by numpydoc !! .. py:function:: construct_fftw_wisdoms(*, use_fftw_wisdom) Construct all necessary FFTW wisdoms. :Parameters: **USE_FFTW_WISDOM** (*bool*) -- Whether we are interested in having FFTW wisdoms. .. !! processed by numpydoc !! .. py:function:: convert_halo_properties(*, redshift, inputs, halo_masses, star_rng, sfr_rng, xray_rng, halo_coords = None, vcb_grid = None, J_21_LW_grid = None, z_re_grid = None, Gamma12_grid = None) Convert a halo catalogue's mass and RNG fields to halo properties. Assumes no feedback (Lyman-Werner, reionization). Returns a dict of 12 properties per halo: halo mass stellar mass (ACG) star formation rate (ACG) xray luminosity (combined) ionising emissivity (combined) escape-fraction weighted SFR (combined) stellar mass (MCG) star formation rate (MCG) ACG turnover mass MCG turnover mass Reionization turnover mass Metallicity .. !! processed by numpydoc !! .. py:function:: evaluate_FgtrM_cond(inputs, densities, redshift, R) Get the collapsed fraction from the backend, given a density and condition sigma. .. !! processed by numpydoc !! .. py:function:: evaluate_Nion_cond(*, inputs, redshift, radius, densities, l10mturns_acg, l10mturns_mcg) Evaluate the conditional ionising emissivity expected at a range of densities. .. !! processed by numpydoc !! .. py:function:: evaluate_Nion_z(*, inputs, redshifts, log10mturns) Evaluate the global ionising emissivity expected at a range of redshifts. .. !! processed by numpydoc !! .. py:function:: evaluate_SFRD_cond(*, inputs, redshift, radius, densities, log10mturns) Evaluate the conditional star formation rate density expected at a range of densities. .. !! processed by numpydoc !! .. py:function:: evaluate_SFRD_z(*, inputs, redshifts, log10mturns) Evaluate the global star formation rate density expected at a range of redshifts. .. !! processed by numpydoc !! .. py:function:: evaluate_Xray_cond(*, inputs, redshift, radius, densities, log10mturns) Evaluate the conditional star formation rate density expected at a range of densities. .. !! processed by numpydoc !! .. py:function:: evaluate_condition_integrals(inputs, cond_array, redshift, redshift_prev = None) Get the expected number and mass of halos given a condition. If USE_INTERPOLATION_TABLES is set to 'hmf-interpolation': Will crash if the table has not been initialised, only `cond_array` is used, and the rest of the arguments are taken from when the table was initialised. .. !! processed by numpydoc !! .. py:function:: evaluate_inverse_table(inputs, cond_array, probabilities, redshift, redshift_prev = None) Get the expected number and mass of halos given a condition. .. !! processed by numpydoc !! .. py:function:: evaluate_sigma(*, inputs, masses) Evaluate the variance of a mass scale. Uses the 21cmfast backend .. !! processed by numpydoc !! .. py:function:: free_cosmo_tables() Free the memory of cosmo_tables_global that was allocated at the C backend. .. !! processed by numpydoc !! .. py:function:: get_condition_mass(inputs, R) Determine condition masses for backend routines. Returns either mass contained within a radius, or mass of the Lagrangian cell on HII_DIM .. !! processed by numpydoc !! .. py:function:: get_delta_crit(*, inputs, mass, redshift) Get the critical collapse density given a mass, redshift and parameters. .. !! processed by numpydoc !! .. py:function:: get_delta_crit_nu(hmf_int_flag, sigma, growth) Get the critical density from sigma and growth factor. .. !! processed by numpydoc !! .. py:function:: get_expected_nhalo(*, redshift, inputs, **kwargs) Get the expected number of halos in a given box. :Parameters: * **redshift** (*float*) -- The redshift at which to calculate the halo list. * **inputs** (:class:`~InputParameters`) -- The input parameters of the run .. !! processed by numpydoc !! .. py:function:: get_growth_factor(*, inputs, redshift) Get the growth factor at a given redshift. .. !! processed by numpydoc !! .. py:function:: get_halo_catalog_buffer_size(*, redshift, inputs, min_size = 1000000, **kwargs) Compute the required size of the memory buffer to hold a halo list. :Parameters: * **redshift** (*float*) -- The redshift at which to calculate the halo list. * **inputs** (:class:`~InputParameters`) -- The input parameters of the run * **min_size** (*int, optional*) -- A minimum size to be used as the buffer. .. !! processed by numpydoc !! .. py:function:: get_matter_power_values(*, inputs, k_values) Evaluate the power at a certain scale from the 21cmFAST backend. .. !! processed by numpydoc !! .. py:function:: init_backend_ps(func) Initialise the backend power-spectrum before calling the function. This should be added as a decorator to any function which uses the cosmology from the 21cmFAST backend without passing through our regular functions. .. !! processed by numpydoc !! .. py:function:: init_gl(func) Initialise the Gauss-Legendre integration if required before calling the function. Calculates the abcissae weights and stores them as arrays in the backend when either of the HMF integrals is set to use Gauss-Legendre integration. This should be added as a decorator to any function which calls backend integrals directly. .. !! processed by numpydoc !! .. py:function:: init_sigma_table(func) Initialise the the sigma interpolation table before calling the function. This should be added as a decorator to any function which calls lib.EvaluateSigma or the sigma tables directly. .. !! processed by numpydoc !! .. py:function:: integrate_chmf_interval(inputs, redshift, lnm_lower, lnm_upper, cond_values, redshift_prev = None) Evaluate conditional mass function integrals at a range of mass intervals. .. !! processed by numpydoc !! .. py:function:: return_chmf_value(*, inputs, redshift, mass_values, delta_values, condmass_values) Return the value of the conditional halo mass function at given parameters. :Parameters: * **inputs** (*InputParameters*) -- The input parameters defining the simulation run. * **redshift** (*float*) -- The redshift at which to evaluate the halo mass function. * **mass_values** (*float*) -- The mass values at which to evaluate the halo mass function. * **delta** (*float*) -- The overdensity at which to evaluate the halo mass function. * **cond_mass** (*float*) -- The condition mass at which to evaluate the halo mass function. .. !! processed by numpydoc !! .. py:function:: return_uhmf_value(*, inputs, redshift, mass_values) Return the value of the unconditional halo mass function at given parameters. :Parameters: * **inputs** (*InputParameters*) -- The input parameters defining the simulation run. * **redshift** (*float*) -- The redshift at which to evaluate the halo mass function. * **mass_values** (*float*) -- The mass values at which to evaluate the halo mass function. .. !! processed by numpydoc !! .. py:function:: sample_halos_from_conditions(*, inputs, redshift, cond_array, redshift_prev = None, buffer_size = None) Construct a halo sample given a descendant catalogue and redshifts. .. !! processed by numpydoc !! .. py:data:: logger