CosmoFit.model_from_expression¶
- CosmoFit.model_from_expression(name, E, *, extra_params=None, label=None, w=None, dEdz=None, Omega_de=None, mu=None)[source]¶
Same as
define_model(), butE/w/dEdz/Omega_de/muare given as Python expression strings (e.g."sqrt(Omega_m*(1+z)**3 + (1-Omega_m)*(1+z)**(3*(1+w0)))") instead of callables – convenient for text-entry UIs (see the Streamlit app underapp/), where asking for a Python function isn’t practical.E/w/dEdz/Omega_deexpressions seezand every current parameter value (standard ones plus anyextra_params) as plain names;muinstead seesa(scale factor) andk(wavenumber [h/Mpc], orNoneif not supplied by the caller) – see_compile_expression()for exactly what else is available.Example
>>> MyModel = model_from_expression( ... "MyModel", ... E="sqrt(Omega_m*(1+z)**3 + (1-Omega_m)*(1+z)**(3*(1+w0))*(1+beta*z))", ... extra_params={"beta": {"default": 0.0, "bounds": (-2.0, 2.0)}}, ... )
A modified-gravity example (custom growth on top of an otherwise LCDM background, in the spirit of
FRTLinear):>>> MyMG = model_from_expression( ... "MyMG", ... E="sqrt(Omega_m*(1+z)**3 + (1-Omega_m))", ... mu="1 + 3*beta", ... extra_params={"beta": {"default": 0.0, "bounds": (-0.2, 0.2)}}, ... )