Writing to a Parameter File¶
The desired theoretical model parameterization must be written out to
the parameter file that will be passed to the rsdfit
executable. The
easiest way to do this is to use the
to_file()
function
of the default parameter object.
The recommended workflow to configure the theory is:
1. Generate the default parameter set via the GalaxySpectrum.default_params()
function.
- Make the desired changes to the parametrization, i.e., changing priors, etc
- Write to an exisiting file using the
to_file()
function.
For example, assuming we have an existing parameter file entitled params.dat
,
we can write out our parameters as
In [1]: from pyRSD.rsd import GalaxySpectrum
# get the default parameters from an existing model
In [2]: model = GalaxySpectrum()
In [3]: params = model.default_params()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-20168f551e3a> in <module>()
----> 1 params = model.default_params()
~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsd/power/gal/power_gal.py in default_params(self)
128 """
129 from pyRSD.rsdfit.theory import GalaxyPowerParameters
--> 130 return GalaxyPowerParameters.from_defaults(model=self)
131
132 #---------------------------------------------------------------------------
~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsdfit/theory/base.py in from_defaults(cls, model, extra_params)
155 """
156 # initialize an empty class
--> 157 params = cls()
158
159 # add extra parameters
~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsdfit/parameters/parameterset.py in __init__(self, *args, **kwargs)
35 def __init__(self, *args, **kwargs):
36
---> 37 kwargs['asteval'] = lmfit.asteval.Interpreter(symtable=SmartSymTable(self))
38 super(ParameterSet, self).__init__(*args, **kwargs)
39 self._prepared = False
AttributeError: module 'lmfit' has no attribute 'asteval'
# make any desired changes
# ....
# write out to file
In [4]: params.to_file('params.dat', mode='a') # append to this file