code: def _table_to_bintable(table):
      
      data = table.as_array()
      header = fits.Header()
      header.update(table.meta)
      name = table.meta.pop('name', None)
      return fits.BinTableHDU(data, header, name=name)
docs: Convert `~astropy.table.Table` to `astropy.io.fits.BinTable`.