def lock_parameter(self, name, par, lock=True):
        """Set parameter to locked/unlocked state.  A locked parameter
        will be ignored when running methods that free/fix sources or
        parameters.

        Parameters
        ----------
        name : str
            Source name.

        par : str
            Parameter name.

        lock : bool       
            Set parameter to locked (True) or unlocked (False) state.
        """
        name = self.roi.get_source_by_name(name).name
        lck_params = self._lck_params.setdefault(name, [])

        if lock:
            self.free_parameter(name, par, False)
            if not par in lck_params:
                lck_params += [par]
        else:
            if par in lck_params:
                lck_params.remove(par)