How to use the astromodels.Parameter function in astromodels

To help you get started, we’ve selected a few astromodels 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 threeML / threeML / threeML / plugins / FermiLATLike.py View on Github external
thisNamesV = pyLike.StringVector()
            thisSrc = self.like.logLike.getSource(srcName)
            thisSrc.spectrum().getFreeParamNames(thisNamesV)
            thisNames = map(lambda x: "%s_%s" % (srcName, x), thisNamesV)
            freeParamNames.extend(thisNames)
        pass

        nuisanceParameters = collections.OrderedDict()

        for name in freeParamNames:

            value = self.getNuisanceParameterValue(name)
            bounds = self.getNuisanceParameterBounds(name)
            delta = self.getNuisanceParameterDelta(name)

            nuisanceParameters["%s_%s" % (self.name, name)] = Parameter("%s_%s" % (self.name, name),
                                                                        value,
                                                                        min_value=bounds[0],
                                                                        max_value=bounds[1],
                                                                        delta=delta)

            nuisanceParameters["%s_%s" % (self.name, name)].free = self.innerMinimization

            # Prepare a callback which will set the parameter value in the pyLikelihood object if it gets
            # changed
            # def this_callback(parameter):
            #
            #     _, src, pname = parameter.name.split("_")
            #
            #     try:
            #
            #         self.like.model[src].funcs['Spectrum'].getParam(pname).setValue(parameter.value)
github threeML / threeML / threeML / plugins / HAWCLike.py View on Github external
# deactivate_CommonNorm()
        self._fit_commonNorm = False

        # This is to keep track of whether the user defined a ROI or not

        self._roi_ra = None
        self._roi_fits = None
        self._roi_galactic = False

        # Create the dictionary of nuisance parameters

        self._nuisance_parameters = collections.OrderedDict()

        param_name = "%s_ComNorm" % name

        self._nuisance_parameters[param_name] = Parameter(
            param_name, 1.0, min_value=0.5, max_value=1.5, delta=0.01
        )
        self._nuisance_parameters[param_name].fix = True

        super(HAWCLike, self).__init__(name, self._nuisance_parameters)
github threeML / threeML / threeML / plugins / FermiLATLike.py View on Github external
thisNamesV = pyLike.StringVector()
            thisSrc = self.like.logLike.getSource(srcName)
            thisSrc.spectrum().getFreeParamNames(thisNamesV)
            thisNames = ["%s_%s" % (srcName, x) for x in thisNamesV]
            freeParamNames.extend(thisNames)
        pass

        nuisanceParameters = collections.OrderedDict()

        for name in freeParamNames:

            value = self.getNuisanceParameterValue(name)
            bounds = self.getNuisanceParameterBounds(name)
            delta = self.getNuisanceParameterDelta(name)

            nuisanceParameters["%s_%s" % (self.name, name)] = Parameter(
                "%s_%s" % (self.name, name),
                value,
                min_value=bounds[0],
                max_value=bounds[1],
                delta=delta,
            )

            nuisanceParameters[
                "%s_%s" % (self.name, name)
            ].free = self.fit_nuisance_params

        return nuisanceParameters
github threeML / threeML / threeML / minimizer / grid_minimizer.py View on Github external
def add_parameter_to_grid(self, parameter, grid):
        """
        Add a parameter to the grid

        :param parameter: an instance of a parameter or a parameter path
        :param grid: a list (or a numpy.array) with the values the parameter is supposed to take during the grid search
        :return: None
        """

        if isinstance(parameter, Parameter):

            assert parameter in list(self.parameters.values()), (
                "Parameter %s is not part of the " "current model" % parameter.name
            )

        else:

            # Assume parameter is a path
            parameter_path = str(parameter)

            # Make a list of paths for the parameters
            v = list(self.parameters.values())
            parameters_paths = [x.path for x in v]

            try: