code: def gtlike_spectrum_to_dict(spectrum):
      
      parameters = pyLike.ParameterVector()
      spectrum.getParams(parameters)
      d = dict(spectrum_type=spectrum.genericName())
      for p in parameters:
  
          pname = p.getName()
          pval = p.getTrueValue()
          perr = abs(p.error() * p.getScale()) if p.isFree() else np.nan
          d[pname] = np.array([pval, perr])
  
          if d['spectrum_type'] == 'FileFunction':
              ff = pyLike.FileFunction_cast(spectrum)
              d['file'] = ff.filename()
      return d
docs: Convert a pyLikelihood object to a python dictionary which can
          be easily saved to a file.