bundles / astropy latest / astropy / io / fits / convenience / setval
function
astropy.io.fits.convenience:setval
source: /astropy/io/fits/convenience.py :301
Signature
def setval ( filename , keyword , * args , value = None , comment = None , before = None , after = None , savecomment = False , ** kwargs ) Summary
Set a keyword's value from a header in a FITS file.
Extended Summary
If the keyword already exists, it's value/comment will be updated. If it does not exist, a new card will be created and it will be placed before or after the specified location. If no before or after is specified, it will be appended at the end.
When updating more than one keyword in a file, this convenience function is a much less efficient approach compared with opening the file for update, modifying the header, and closing the file.
Parameters
filename: path-like or file-likeName of the FITS file, or file object If opened, mode must be update (rb+). An opened file object or GzipFile object will be closed upon return.
keyword: strKeyword name
value: str, int, float, optionalKeyword value (default:
None, meaning don't modify)comment: str, optionalKeyword comment, (default:
None, meaning don't modify)before: str, int, optionalName of the keyword, or index of the card before which the new card will be placed. The argument
beforetakes precedence overafterif both are specified (default:None).after: str, int, optionalName of the keyword, or index of the card after which the new card will be placed. (default:
None).savecomment: bool, optionalWhen
True, preserve the current comment for an existing keyword. The argumentsavecommenttakes precedence overcommentif both specified. Ifcommentis not specified then the current comment will automatically be preserved (default:False).ext, extname, extverThe rest of the arguments are for HDU specification. See getdata for explanations/examples.
**kwargsAny additional keyword arguments to be passed to astropy.io.fits.open. Note: This function automatically specifies
do_not_scale_image_data = Truewhen opening the file so that values can be retrieved from the unmodified header.
Aliases
-
astropy.io.fits.setval