def from_input_to_mcmc_parameters(self, dictionary): """ Converts dictionary of raw quantities into a meaningful one. At the end of this initialization, every field but one is filled for every parameter, be it fixed or varying. The missing field is the 'last_accepted' one, that will be filled in the module :mod:`mcmc`. The other fields are `initial`: initial array of input values defined in the parameter file. Contains (in this order) `mean`, `minimum`, `maximum`, `1-sigma`. If the min/max values (**TO CHECK** proposal density boundaries) are unimportant/unconstrained, use `None` or `-1` (without a period !) `scale`: 5th entry of the initial array in the parameter file. `role`: 6th entry of the initial array, can be `cosmo`, `nuisance` or `derived`. A `derived` parameter will not be considered as varying, but will be instead recovered from the cosmological code for each point in the parameter space. `tex_name`: A tentative tex version of the name, provided by the function :func:`io_mp.get_tex_name`. `status`: Depending on the `1-sigma` value in the initial array, it will be set to `fixed` or `varying` (resp. zero and non-zero) `current`: Stores the value at the current point in parameter space (`not allowed initially`) .. note:: The syntax of the parameter files is defined here - if one wants to change it, one should report the changes in there. :Parameters: - **dictionary** (`dict`) - raw dictionary containing the input from the parameter file. Its content will be transformed and processed into the final :attr:`mcmc_parameters` """ for key, value in dictionary.iteritems(): self.mcmc_parameters[key] = od() self.mcmc_parameters[key]['initial'] = value[0:4] self.mcmc_parameters[key]['scale'] = value[4] self.mcmc_parameters[key]['role'] = value[-1] self.mcmc_parameters[key]['tex_name'] = io_mp.get_tex_name(key) if value[3] == 0: self.mcmc_parameters[key]['status'] = 'fixed' self.mcmc_parameters[key]['current'] = value[0] else: self.mcmc_parameters[key]['status'] = 'varying'
def __init__(self, array, key): """ This class replaces the old function defined in the Data class, called `from_input_to_mcmc_parameters`. The traduction is now done inside the Parameter class, which interprets the array given as an input inside the parameter file, and returns a dictionary having all relevant fields initialized. .. warning:: This used to be an ordered dictionary, for no evident reason. It is now reverted back to an ordinary dictionary. If this broke anything, it will be reverted back At the end of this initialization, every field but one is filled for the specified parameter, be it fixed or varying. The missing field is the 'last_accepted' one, that will be filled in the module :mod:`mcmc`. .. note:: The syntax of the parameter files is defined here - if one wants to change it, one should report the changes in there. The other fields are Attributes ---------- initial : array Initial array of input values defined in the parameter file. Contains (in this order) `mean`, `minimum`, `maximum`, `1-sigma`. If the min/max values (**TO CHECK** proposal density boundaries) are unimportant/unconstrained, use `None` or `-1` (without a period !) scale : float 5th entry of the initial array in the parameter file, defines the factor with which to multiply the values defined in `initial` to give the real value. role : str 6th entry of the initial array, can be `cosmo`, `nuisance` or `derived`. A `derived` parameter will not be considered as varying, but will be instead recovered from the cosmological code for each point in the parameter space. prior : :class:`Prior <prior.Prior>` defined through the optional 7th entry of the initial array, can be ommited or set to `flat` (same), or set to `gaussian`. An instance of the :class:`prior` defined in :mod:`prior` will be initialized and set to this value. tex_name : str A tentative tex version of the name, provided by the function :func:`io_mp.get_tex_name`. status : str Depending on the `1-sigma` value in the initial array, it will be set to `fixed` or `varying` (resp. zero and non-zero) current : float Stores the value at the current point in parameter space (`not allowed initially`) Parameters ---------- value : list Array read from the parameter file key : str Name of the parameter """ # calling the parent method initialization dict.__init__(self) self['initial'] = array[0:4] self['scale'] = array[4] self['role'] = array[-1] self['tex_name'] = io_mp.get_tex_name(key) if array[3] == 0: self['status'] = 'fixed' self['current'] = array[0] else: self['status'] = 'varying' self['prior'] = prior.Prior(array)