def create_from_stack(cls, shape, components, ylims, weights=None):
        """  Combine the log-likelihoods from a number of components.

        Parameters
        ----------
        shape    :  tuple
           The shape of the return array

        components : [~fermipy.castro.CastroData_Base]
           The components to be stacked

        weights : array-like

        Returns
        -------
        castro : `~fermipy.castro.CastroData`
        """
        if len(components) == 0:
            return None
        norm_vals, nll_vals, nll_offsets = CastroData_Base.stack_nll(shape,
                                                                     components,
                                                                     ylims,
                                                                     weights)
        return cls(norm_vals, nll_vals,
                   components[0].refSpec,
                   components[0].norm_type)