code: def calc_counts(skydir, ltc, event_class, event_types,
                  egy_bins, cth_bins, fn, npts=1):
      
      #npts = int(np.ceil(32. / bins_per_dec(egy_bins)))
      egy_bins = np.exp(utils.split_bin_edges(np.log(egy_bins), npts))
      exp = calc_exp(skydir, ltc, event_class, event_types,
                     egy_bins, cth_bins)
      dnde = fn.dnde(egy_bins)
      cnts = loglog_quad(egy_bins, exp * dnde[:, None], 0)
      cnts = sum_bins(cnts, 0, npts)
      return cnts
docs: Calculate the expected counts vs. true energy and incidence angle
      for a source with spectral parameterization ``fn``.
  
      Parameters
      ----------
      skydir : `~astropy.coordinate.SkyCoord`
  
      ltc : `~fermipy.irfs.LTCube`
  
      egy_bins : `~numpy.ndarray`
          Bin edges in observed energy in MeV.
  
      cth_bins : `~numpy.ndarray`
          Bin edges in cosine of the true incidence angle.
  
      npts : int
          Number of points by which to oversample each energy bin.