def create_image_hdu(self,<EOL>img=None,<EOL>dims=None,<EOL>dtype=None,<EOL>extname=None,<EOL>extver=None,<EOL>compress=None,<EOL>tile_dims=None,<EOL>header=None):
if (img is not None) or (img is None and dims is None):<EOL><INDENT>from_image = True<EOL><DEDENT>elif dims is not None:<EOL><INDENT>from_image = False<EOL><DEDENT>if from_image:<EOL><INDENT>img2send = img<EOL>if img is not None:<EOL><INDENT>dims = img.shape<EOL>dtstr = img.dtype.descr[<NUM_LIT:0>][<NUM_LIT:1>][<NUM_LIT:1>:]<EOL>if img.size == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if not img.flags['<STR_LIT>']:<EOL><INDENT>img2send = numpy.ascontiguousarray(img)<EOL>array_to_native(img2send, inplace=True)<EOL><DEDENT>else:<EOL><INDENT>img2send = array_to_native(img, inplace=False)<EOL><DEDENT>if IS_PY3 and img2send.dtype.char == '<STR_LIT>':<EOL><INDENT>img2send = img2send.astype('<STR_LIT:S>', copy=False)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._ensure_empty_image_ok()<EOL>compress = None<EOL>tile_dims = None<EOL><DEDENT>dims2send = None<EOL><DEDENT>else:<EOL><INDENT>if dtype is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>dtype = numpy.dtype(dtype)<EOL>dtstr = dtype.descr[<NUM_LIT:0>][<NUM_LIT:1>][<NUM_LIT:1>:]<EOL>img2send = numpy.zeros(<NUM_LIT:1>, dtype=dtype)<EOL>dims2send = numpy.array(dims, dtype='<STR_LIT>', ndmin=<NUM_LIT:1>)<EOL><DEDENT>if img2send is not None:<EOL><INDENT>if img2send.dtype.fields is not None:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>if extname is None:<EOL><INDENT>extname = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>if not isstring(extname):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>extname = mks(extname)<EOL><DEDENT>if extname is not None and extver is not None:<EOL><INDENT>extver = check_extver(extver)<EOL><DEDENT>if extver is None:<EOL><INDENT>extver = <NUM_LIT:0><EOL><DEDENT>comptype = get_compress_type(compress)<EOL>tile_dims = get_tile_dims(tile_dims, dims)<EOL>if img2send is not None:<EOL><INDENT>check_comptype_img(comptype, dtstr)<EOL><DEDENT>if header is not None:<EOL><INDENT>nkeys = len(header)<EOL><DEDENT>else:<EOL><INDENT>nkeys = <NUM_LIT:0><EOL><DEDENT>self._FITS.create_image_hdu(img2send,<EOL>nkeys,<EOL>dims=dims2send,<EOL>comptype=comptype,<EOL>tile_dims=tile_dims,<EOL>extname=extname,<EOL>extver=extver)<EOL>self.update_hdu_list(rebuild=False)<EOL>
Create a new, empty image HDU and reload the hdu list.  Either
create from an input image or from input dims and dtype

    fits.create_image_hdu(image, ...)
    fits.create_image_hdu(dims=dims, dtype=dtype)

If an image is sent, the data are also written.

You can write data into the new extension using
    fits[extension].write(image)

Alternatively you can skip calling this function and instead just use

    fits.write(image)
    or
    fits.write_image(image)

which will create the new image extension for you with the appropriate
structure, and write the data.

parameters
----------
img: ndarray, optional
    An image with which to determine the properties of the HDU. The
    data will be written.
dims: sequence, optional
    A sequence describing the dimensions of the image to be created
    on disk.  You must also send a dtype=
dtype: numpy data type
    When sending dims= also send the data type.  Can be of the
    various numpy data type declaration styles, e.g. 'f8',
    numpy.float64.
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.
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.

header: FITSHDR, list, dict, optional
    This is only used to determine how many slots to reserve for
    header keywords

restrictions
------------
The File must be opened READWRITE