def read_header(filename, ext=<NUM_LIT:0>, extver=None, case_sensitive=False, **keys):
dont_create = <NUM_LIT:0><EOL>try:<EOL><INDENT>hdunum = ext+<NUM_LIT:1><EOL><DEDENT>except TypeError:<EOL><INDENT>hdunum = None<EOL><DEDENT>_fits = _fitsio_wrap.FITS(filename, READONLY, dont_create)<EOL>if hdunum is None:<EOL><INDENT>extname = mks(ext)<EOL>if extver is None:<EOL><INDENT>extver_num = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>extver_num = extver<EOL><DEDENT>if not case_sensitive:<EOL><INDENT>hdunum = _fits.movnam_hdu(ANY_HDU, extname, extver_num)<EOL><DEDENT>else:<EOL><INDENT>found = False<EOL>current_ext = <NUM_LIT:0><EOL>while True:<EOL><INDENT>hdunum = current_ext+<NUM_LIT:1><EOL>try:<EOL><INDENT>hdu_type = _fits.movabs_hdu(hdunum)  <EOL>name, vers = _fits.get_hdu_name_version(hdunum)<EOL>if name == extname:<EOL><INDENT>if extver is None:<EOL><INDENT>found = True<EOL>break<EOL><DEDENT>else:<EOL><INDENT>if extver_num == vers:<EOL><INDENT>found = True<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except OSError:<EOL><INDENT>break<EOL><DEDENT>current_ext += <NUM_LIT:1><EOL><DEDENT>if not found:<EOL><INDENT>raise IOError(<EOL>'<STR_LIT>' % (extname, extver))<EOL><DEDENT><DEDENT><DEDENT>return FITSHDR(_fits.read_header(hdunum))<EOL>
Convenience function to read the header from the specified FITS HDU

The FITSHDR allows access to the values and comments by name and
number.

parameters
----------
filename: string
    A filename.
ext: number or string, optional
    The extension.  Either the numerical extension from zero
    or a string extension name. Default read primary header.
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 select a particular version.  If extver is not
    sent, the first one will be selected.  If ext is an integer, the extver
    is ignored.
case_sensitive: bool, optional
    Match extension names with case-sensitivity.  Default is False.