astropy 5.0

Parameters
set(self, keyword, value=None, comment=None, before=None, after=None)

If the keyword does not already exist in the header, a new keyword is created in the specified position, or appended to the end of the header if no position is specified.

This method is similar to Header.update prior to Astropy v0.1.

note

It should be noted that header.set(keyword, value) and header.set(keyword, value, comment) are equivalent to header[keyword] = value and header[keyword] = (value, comment) respectively.

New keywords can also be inserted relative to existing keywords using, for example:

>>> header.insert('NAXIS1', ('NAXIS', 2, 'Number of axes'))

to insert before an existing keyword, or:

>>> header.insert('NAXIS', ('NAXIS1', 4096), after=True)

to insert after an existing keyword.

The only advantage of using :None:meth:`Header.set` is that it easily replaces the old usage of :None:meth:`Header.update` both conceptually and in terms of function signature.

Parameters

keyword : str

A header keyword

value : str, optional

The value to set for the given keyword; if None the existing value is kept, but '' may be used to set a blank value

comment : str, optional

The comment to set for the given keyword; if None the existing comment is kept, but '' may be used to set a blank comment

before : str, int, optional

Name of the keyword, or index of the Card before which this card should be located in the header. The argument before takes precedence over after if both specified.

after : str, int, optional

Name of the keyword, or index of the Card after which this card should be located in the header.

Set the value and/or comment and/or position of a specified keyword.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /astropy/io/fits/header.py#908
type: <class 'function'>
Commit: