Spectra of an object are often recorded over long periods of time and collected in reduced form as 1d spectra in fits format. This can lead to inconsistent headers by changing the data reduction software, the data acquisition software, own decisions etc.: Header keywords can be different or missing and much more.
Then one wishes for a software with which one can unify all spectra of the object in one go with regard to their header.
It is useful to have all spectra in one folder as a copy of the original files and to give them names that are uniform and informative. An example is shown in Figure. This makes it easier to enter your name using wildcards and the order of time by simply sorting it alphabetically by name.
In the following we discuss a Python3 program named lookHeaderAndCorrection.py (download here), which reads such series, checks and completes their header or changes them and saves the fits-files changed in the header again (and overwrites the read files).
The script in the following fig. starts as usual with the definition of the Python environment in form of a magic line (line 1) and the definition of the character code (line 2). Then follows the description in triple apostrophe or apostrophe. The module glob and again fits from astropy.io are imported. Graphical tools (matplotlib) are not required this time.
In order to know which modules exist in Python and what they are capable of, it is important to keep going through the Python documentation. Especially the Python Package Index, which can be found at https://pypi.org/ .
From the path to the files (selected by wildcards) a list of the files is created, which is sorted alphabetically in line 22. As a check, the file names are displayed in the console and their number.
From line 29 the first file is opened and information and its entire header is displayed in the console. Here you can now check whether the header data is complete and correct for further evaluations of the time series.
From lines 39 to 58 a header read function is defined, which returns a selection of the header data. With the knowledge from the header of the first file the function can be adapted before a second program run concerning the header data to be returned.
After the function has been adapted, the read header data selection from line 62 is displayed in a table in the console. If entries do not meet the requirements, they can be changed. This happens from line 69. The user is asked if he wants to make changes. If so, the header data is changed and then the fits file is updated (line 76). The header objects in lines 74 and 75 have to be adapted accordingly, deleted (e.g. by commenting them out) or extended by more.
After the change, the header data are displayed again in tabular form in the console for checking purposes. The final state after running the program in Spyder is shown in next figure. Here the headers ‚Object‘ and ‚Observer‘ are changed.