code: def model_counts_spectrum(self, name, logemin=None, logemax=None,
                                summed=False, weighted=False):
          
  
          if logemin is None:
              logemin = self.log_energies[0]
          if logemax is None:
              logemax = self.log_energies[-1]
  
          if summed:
              cs = np.zeros(self.enumbins)
              imin = utils.val_to_bin_bounded(self.log_energies,
                                              logemin + 1E-7)[0]
              imax = utils.val_to_bin_bounded(self.log_energies,
                                              logemax - 1E-7)[0] + 1
  
              for c in self.components:
                  ecenter = 0.5 * (c.log_energies[:-1] + c.log_energies[1:])
                  counts = c.model_counts_spectrum(name, self.log_energies[0],
                                                   self.log_energies[-1], weighted)
                  cs += np.histogram(ecenter,
                                     weights=counts,
                                     bins=self.log_energies)[0]
  
              return cs[imin:imax]
          else:
              cs = []
              for c in self.components:
                  cs += [c.model_counts_spectrum(name, logemin,
                                                 logemax, weighted=weighted)]
              return cs
docs: Return the predicted number of model counts versus energy
          for a given source and energy range.  If summed=True return
          the counts spectrum summed over all components otherwise
          return a list of model spectra.   If weighted=True return 
          the weighted version of the counts spectrum