docs: def write(self, data, units=None, extname=None, extver=None,
                compress=None, tile_dims=None,
                header=None,
                names=None,
                table_type='binary', write_bitcols=False, **keys):
          """
          Write the data to a new HDU.
  
          This method is a wrapper.  If this is an IMAGE_HDU, write_image is
          called, otherwise write_table is called.
  
          parameters
          ----------
          data: ndarray
              An n-dimensional image or an array with fields.
          extname: string, optional
              An optional extension name.
          extver: integer, optional
              FITS allows multiple extensions to have the same name (extname).
              These extensions can optionally specify an EXTVER version number in
              the header.  Send extver= to set a particular version, which will
              be represented in the header with keyname EXTVER.  The extver must
              be an integer > 0.  If extver is not sent, the first one will be
              selected.  If ext is an integer, the extver is ignored.
          header: FITSHDR, list, dict, optional
              A set of header keys to write. Can be one of these:
                  - FITSHDR object
                  - list of dictionaries containing 'name','value' and optionally
                    a 'comment' field; the order is preserved.
                  - a dictionary of keyword-value pairs; no comments are written
                    in this case, and the order is arbitrary.
              Note required keywords such as NAXIS, XTENSION, etc are cleaed out.
  
          Image-only keywords:
              compress: string, optional
                  A string representing the compression algorithm for images,
                  default None.
                  Can be one of
                      'RICE'
                      'GZIP'
                      'GZIP_2'
                      'PLIO' (no unsigned or negative integers)
                      'HCOMPRESS'
                  (case-insensitive) See the cfitsio manual for details.
  
          Table-only keywords:
              units: list/dec, optional:
                  A list of strings with units for each column.
              table_type: string, optional
                  Either 'binary' or 'ascii', default 'binary'
                  Matching is case-insensitive
              write_bitcols: bool, optional
                  Write boolean arrays in the FITS bitcols format, default False
  
  
          restrictions
          ------------
          The File must be opened READWRITE
          """
  
          isimage = False
          if data is None:
              isimage = True
          elif isinstance(data, numpy.ndarray):
              if data.dtype.fields == None:  # noqa - probably should be is None
                  isimage = True
  
          if isimage:
              self.write_image(data, extname=extname, extver=extver,
                               compress=compress, tile_dims=tile_dims,
                               header=header)
          else:
              self.write_table(data, units=units,
                               extname=extname, extver=extver, header=header,
                               names=names,
                               table_type=table_type,
                               write_bitcols=write_bitcols)