def write(self, data, units=None, extname=None, extver=None,<EOL>compress=None, tile_dims=None,<EOL>header=None,<EOL>names=None,<EOL>table_type='<STR_LIT>', write_bitcols=False, **keys):
isimage = False<EOL>if data is None:<EOL><INDENT>isimage = True<EOL><DEDENT>elif isinstance(data, numpy.ndarray):<EOL><INDENT>if data.dtype.fields == None:  <EOL><INDENT>isimage = True<EOL><DEDENT><DEDENT>if isimage:<EOL><INDENT>self.write_image(data, extname=extname, extver=extver,<EOL>compress=compress, tile_dims=tile_dims,<EOL>header=header)<EOL><DEDENT>else:<EOL><INDENT>self.write_table(data, units=units,<EOL>extname=extname, extver=extver, header=header,<EOL>names=names,<EOL>table_type=table_type,<EOL>write_bitcols=write_bitcols)<EOL><DEDENT>
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