#NEWLINE# def setval( filename , keyword , * args , **kwargs ) : #NEWLINE# #INDENT# "\n    Set a keyword's value from a header in a FITS file.\n\n    If the keyword already exists, it's value/comment will be updated.\n    If it does not exist, a new card will be created and it will be\n    placed before or after the specified location.  If no ``before`` or\n    ``after`` is specified, it will be appended at the end.\n\n    When updating more than one keyword in a file, this convenience\n    function is a much less efficient approach compared with opening\n    the file for update, modifying the header, and closing the file.\n\n    Parameters\n    ----------\n    filename : file path, file object, or file like object\n        Name of the FITS file, or file object If opened, mode must be update\n        (rb+).  An opened file object or `~gzip.GzipFile` object will be closed\n        upon return.\n\n    keyword : str\n        Keyword name\n\n    value : str, int, float, optional\n        Keyword value (default: `None`, meaning don't modify)\n\n    comment : str, optional\n        Keyword comment, (default: `None`, meaning don't modify)\n\n    before : str, int, optional\n        Name of the keyword, or index of the card before which the new card\n        will be placed.  The argument ``before`` takes precedence over\n        ``after`` if both are specified (default: `None`).\n\n    after : str, int, optional\n        Name of the keyword, or index of the card after which the new card will\n        be placed. (default: `None`).\n\n    savecomment : bool, optional\n        When `True`, preserve the current comment for an existing keyword.  The\n        argument ``savecomment`` takes precedence over ``comment`` if both\n        specified.  If ``comment`` is not specified then the current comment\n        will automatically be preserved  (default: `False`).\n\n    ext, extname, extver\n        The rest of the arguments are for extension specification.\n        See `getdata` for explanations/examples.\n\n    kwargs\n        Any additional keyword arguments to be passed to `pyfits.open`.\n        *Note:* This function automatically specifies ``do_not_scale_image_data\n        = True`` when opening the file so that values can be retrieved from the\n        unmodified header.\n    " #NEWLINE# if ( 'do_not_scale_image_data' not in kwargs ) : #NEWLINE# #INDENT# kwargs [ 'do_not_scale_image_data' ] = True #NEWLINE# #UNINDENT# value = kwargs . pop ( 'value' , None ) #NEWLINE# comment = kwargs . pop ( 'comment' , None ) #NEWLINE# before = kwargs . pop ( 'before' , None ) #NEWLINE# after = kwargs . pop ( 'after' , None ) #NEWLINE# savecomment = kwargs . pop ( 'savecomment' , False ) #NEWLINE# ( hdulist , extidx ) = _getext ( filename , 'update' , * args , ** kwargs ) #NEWLINE# if ( ( keyword in hdulist [ extidx ] . header ) and savecomment ) : #NEWLINE# #INDENT# comment = None #NEWLINE# #UNINDENT# hdulist [ extidx ] . header . set ( keyword , value , comment , before , after ) #NEWLINE# hdulist . close ( )