How to use the getdist.paramnames.ParamInfo function in getdist

To help you get started, we’ve selected a few getdist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cmbant / getdist / getdist / types.py View on Github external
name = [s.strip() for s in name.split(':', 1)]
                            if len(name) > 1:
                                (kind, name) = name
                            else:
                                kind = ''
                            chi2 = LikelihoodChi2()
                            if '=' in name:
                                chi2.tag, chi2.name = [s.strip() for s in name.split('=')]
                            else:
                                chi2.tag, chi2.name = None, name
                            chi2.chisq = float(chisq)
                            self.chiSquareds.append((kind, chi2))
                    break
                continue
            if not isFixed or want_fixed:
                param = paramnames.ParamInfo()
                param.isFixed = isFixed
                param.isDerived = isDerived
                (param.number, param.best_fit, param.name, param.label) = [s.strip() for s in line.split(None, 3)]
                param.number = int(param.number)
                param.best_fit = float(param.best_fit)
                self.names.append(param)
github cmbant / getdist / getdist / paramnames.py View on Github external
loads from fileName, a plain text .paramnames file or a "full" yaml file
        """

        self.filenameLoadedFrom = os.path.split(fileName)[1]
        extension = os.path.splitext(fileName)[-1]
        if extension == '.paramnames':
            with open(fileName) as f:
                self.names = [ParamInfo(line) for line in [s.strip() for s in f] if line != '']
        elif extension.lower() in ('.yaml', '.yml'):
            from getdist.yaml_tools import yaml_load_file
            from getdist.cobaya_interface import get_info_params, is_sampled_param
            from getdist.cobaya_interface import is_derived_param, _p_label, _p_renames
            self.info_dict = yaml_load_file(fileName)
            info_params = get_info_params(self.info_dict)
            # first sampled, then derived
            self.names = [ParamInfo(name=param, label=(info or {}).get(_p_label, param),
                                    renames=(info or {}).get(_p_renames))
                          for param, info in info_params.items() if is_sampled_param(info)]
            self.names += [ParamInfo(name=param, label=(info or {}).get(_p_label, param),
                                     renames=(info or {}).get(_p_renames), derived=True)
                           for param, info in info_params.items() if is_derived_param(info)]
github cmbant / getdist / getdist / types.py View on Github external
def texValues(self, formatter, p, limit=2, refResults=None, shiftSigma_indep=False, shiftSigma_subset=False):
        if not isinstance(p, paramnames.ParamInfo):
            param = self.parWithName(p)
        else:
            param = self.parWithName(p.name)
        if param is not None:
            lim = param.limits[limit - 1]
            sf = 3
            if param.name.startswith('chi2'):
                # Chi2 for low dof are very skewed, always want mean and sigma or limit
                res, sigma, _ = formatter.numberFormatter.namesigFigs(param.mean, param.err, param.err, wantSign=False,
                                                                      sci=False)
                if limit == 1:
                    res += r'\pm ' + sigma
                else:
                    # in this case give mean and effective dof
                    res += r'\,({\nu\rm{:}\,%.1f})' % (param.err ** 2 / 2)
                    # res, plus_str, minus_str = formatter.numberFormatter.namesigFigs(param.mean, lim.upper - param.mean, lim.lower, sci=False)
github cmbant / getdist / getdist / chains.py View on Github external
def _makeParamvec(self, par):
        if self.needs_update:
            self.updateBaseStatistics()
        if isinstance(par, ParamInfo):
            par = par.name
        if isinstance(par, six.string_types):
            return self.samples[:, self.index[par]]
        return WeightedSamples._makeParamvec(self, par)
github cmbant / getdist / getdist / paramnames.py View on Github external
def setWithNames(self, names):
        self.names = [ParamInfo(name) for name in names]
        return self
github cmbant / getdist / getdist / paramnames.py View on Github external
def addDerived(self, name, **kwargs):
        """
        adds a new parameter

        :param name: name tag for the new parameter
        :param kwargs: other arguments for constructing the new :class:`ParamInfo`
        """
        if kwargs.get('derived') is None: kwargs['derived'] = True
        kwargs['name'] = name
        self.names.append(ParamInfo(**kwargs))
        return self.names[-1]
github cmbant / getdist / getdist / paramnames.py View on Github external
def loadFromKeyWords(self, keywordProvider):
        num_params_used = keywordProvider.keyWord_int('num_params_used')
        num_derived_params = keywordProvider.keyWord_int('num_derived_params')
        nparam = num_params_used + num_derived_params
        for i in range(nparam):
            info = ParamInfo()
            info.setFromStringWithComment(keywordProvider.keyWordAndComment('param_' + str(i + 1)))
            self.names.append(info)
        return nparam
github cmbant / getdist / getdist / chains.py View on Github external
def _parAndNumber(self, name):
        """
        Get index and ParamInfo for a name or index

        :param name: name or parameter index
        :return: index, ParamInfo instance
        """
        if isinstance(name, ParamInfo):
            name = name.name
        if isinstance(name, six.string_types):
            name = self.index.get(name, None)
            if name is None:
                return None, None
        if isinstance(name, _int_types):
            return name, self.paramNames.names[name]
        raise ParamError("Unknown parameter type %s" % name)
github cmbant / getdist / getdist / paramnames.py View on Github external
def setDefault(self, n):
        self.names = [ParamInfo(name='param' + str(i + 1), label='p_{' + str(i + 1) + '}') for i in range(n)]
        return self