fedithead
Richard J. Mathar
Fitsheaderkeywordbatcheditor
|
The class edits header keywords FITS headers. More...
#include <FEditHead.h>
Inherits FITS.
Public Member Functions | |
FEditHead (char *fitsname, char *fitstpl) | |
Constructor given a FITS file and a template ASCII file. | |
FEditHead (char *fitsname, const vector< string > fitstpl) | |
Constructor given a FITS file and a list of template ASCII files. | |
FEditHead (const char *gstream, int glines, int bitpix, int naxis, long *naxes, char fitstpl[], const char *fname) | |
FEditHead (const char *gstream, int glines, int bitpix, int naxis, long *naxes, const vector< string > fitstpl, const char *fname) | |
Constructor given an old-fashioned GEIRS header stream and template ASCII files. | |
FEditHead (const char *gstream, char *fname, int glines=-1) | |
Constructor given an old-fashioned GEIRS header stream. | |
~FEditHead () | |
Destructor. | |
void | exec (const bool verbose) |
Execute the modifications of the template file in the header. | |
char * | allLines (int maxLines) |
Public Attributes | |
String | cfgFil |
Name of the configuration file with header template keywords. | |
char * | buffer |
The concatenation of all input lines, trimed/expanded to a multiple of 80 characters per line, one final \0. | |
Protected Member Functions | |
vector< string > | scanTpl (const char *fitstpl, const bool raw80=false) const |
Scan the template file. | |
vector< string > | scanTpl (const string fitstpl, const bool raw80=false) const |
Scan the template file. | |
vector< string > | scanTpl (const vector< string >fitstpl, const bool raw80=false) const |
Scan a list of template files. | |
void | readStream (const char *gstream, int glines, const bool restr=false) |
Static Protected Member Functions | |
static string | trimws (const string &instring) |
Strip leading and trailing white space from a string. | |
static char * | parse_template (const string &instring) |
Reformat an input string into a standard FITS header line. | |
static int | templateAnal (char *card, char keyname[], char keyval[], char cmt[], char dtyp[]) |
Analyse a header card. | |
static vector< string > | splitColon (const string &instring) |
Split a string using colons or exclamaion marks as delimiters. | |
static vector< string > | splitColon (const string &instring, const string &delim) |
Split a string using a specific delimiting string. | |
static bool | addHduCard (HDU &hdu, char *card, const bool verbose=false) |
Protected Attributes | |
vector< string > | tplLins |
The assembly of all template keyword ASCII lines. | |
The class edits header keywords FITS headers.
The object is created specifying the name of an existing FITS file and the name of a template file which contains instructions to add, delete or modify keywords. A method then allows to run through these instructions and apply them to a specified primary or extension header.
The main intend of this program is to eliminate the limitations known for the fmodhead, fthedit and eso2fits programs. The program fedithead
does work with hierarchical keywords, and and it even allows to replace hierarchical keywords by simple keywords and vice versa. Groups of keywords that are pareseable by a regex(7) specification may also be removed or replaced with a syntax known from the sed(1), calculated with the aid of the boost::regex
package. Moving keywords between HDU's or re-calculation of keywords as with ESO's FTU is not supported.
FEditHead::FEditHead | ( | char * | fitsname, |
char * | fitstpl | ||
) |
Constructor given a FITS file and a template ASCII file.
It attempts to open the FITS file and to scan the template file. Applying the template modifications to the FITS file is left to a subsequent call to FEditHead::exec .
[in] | fitsname | The name of the FITS file to be modified. |
[in] | fitstpl | The name of the ASCII file with the header template lines. |
FEditHead::FEditHead | ( | char * | fitsname, |
const vector< string > | fitstpl | ||
) |
Constructor given a FITS file and a list of template ASCII files.
It attempts to open the FITS file and to scan all template files. Applying the template modifications to the FITS file is left to a subsequent call to FEditHead::exec .
[in] | fitsname | The name of the FITS file to be modified. |
[in] | fitstpl | The name of the ASCII files with the header template lines. |
FEditHead::FEditHead | ( | const char * | gstream, |
int | glines, | ||
int | bitpix, | ||
int | naxis, | ||
long * | naxes, | ||
char | fitstpl[], | ||
const char * | fname | ||
) |
FEditHead::FEditHead | ( | const char * | gstream, |
int | glines, | ||
int | bitpix, | ||
int | naxis, | ||
long * | naxes, | ||
const vector< string > | fitstpl, | ||
const char * | fnam | ||
) |
Constructor given an old-fashioned GEIRS header stream and template ASCII files.
It attempts to split the header stream in 80 bytes pieces and to scan all template files. Applying the template modifications to the FITS file is left to a subsequent call to FEditHead::exec .
[in] | gStream | The bytes in the GEIRS header. These are characterized by having the shape of non-terminated 80-byte lines. |
[in] | glines | The number of 80-byte lines in gstream. |
[in] | fitstpl | The names of the ASCII files with the header template lines. |
[in] | fnam | The name of the temporary FITS file to be created. |
FEditHead::FEditHead | ( | const char * | gstream, |
char * | fnam, | ||
int | glines = -1 |
||
) |
Constructor given an old-fashioned GEIRS header stream.
It attempts to split the header stream in 80 bytes pieces. Applying the template modifications to the FITS file is left to a subsequent call to FEditHead::exec .
[in] | gStream | The bytes in the GEIRS header. These are characterized by having the shape of non-terminated 80-byte lines. |
[in] | fnam | The name of the temporary FITS file to be created. |
FEditHead::~FEditHead | ( | ) |
Destructor.
De-allocates the buffer with the sequential concatenation of all the 80-bytes header lines. Removes the FITS file if the flag keepDtor was set to false.
void FEditHead::exec | ( | const bool | verbose | ) |
Execute the modifications of the template file in the header.
Request of adding or modifying keywords are executed in the order of request (in the order of the template file) and the new keywords are appended in that order. This basically means that header cards are not sorted in any particular way to be 'nice.'
[in] | verbose | If true, comment on each substitution, deletion etc. |
Do nothing if the requested list of keywords is empty.
Consider in the outer loop each applicable template line.
char * FEditHead::allLines | ( | int | maxLines | ) |
[in] | maxLines | A cutoff for the number of lines to be returned. A negative number is interpreted as that no upper limit is set. |
|
protected |
Scan the template file.
[in] | fitstpl | The name of the template ASCII file. The file contains six types of lines:
|
[in] | raw80 | If true, the file fitstpl contains lines of 80 bytes without line feeds |
|
protected |
Scan the template file.
[in] | fitstpl | The name of the template ASCII file. The contents is the same as documented in the signature with the character pointer. |
[in] | raw80 | If true, the file fitstpl contains lines of 80 bytes without line feeds |
|
protected |
Scan a list of template files.
The function implies a loop of scans over the template files in the order of the vector. This means files later (with higher index) in the vector may override the specs of lines in files earlier in the vector.
[in] | raw80 | If true, the file fitstpl contains lines of 80 bytes without line feeds |
|
staticprotected |
Strip leading and trailing white space from a string.
[in] | instring | The initial string from which nonprintable leading and trailing characters or white space (tabs, blanks) ought to be removed. |
|
staticprotected |
Reformat an input string into a standard FITS header line.
This is an intermediate invocation of the fits_parse_template() functionality of cfitsio.
[in] | instring |
|
staticprotected |
Analyse a header card.
The header card is decomposed into name, value, comment and type.
[in] | card | The card to be analysed, typically up to 80 characters. |
[out] | keyname | Keyword name in the card. |
[out] | keyval | Keyword value in the card. |
[out] | cmt | Comment after the slash in the card. |
[out] | dtyp | Rough type (string, integer, float, boolean or complex) |
|
staticprotected |
Split a string using colons or exclamaion marks as delimiters.
[in] | instring | This input has the sequential format :....:.....:.... or !...!...!... Either the colon or the exclamation mark are the local delimiters. This means the first, second and third mark delimit the two strings to be defined. The third mark is optional. If missing, the entire residual part of the input defines the 2nd string. |
|
staticprotected |
Split a string using a specific delimiting string.
[in] | instring | This input has the sequential format <delimit>....<delimit>.....<delimit>... This means the first, second and third mark delimit the two strings to be defined. The third mark is optional. If missing, the entire residual part of the input defines the 2nd string. |
[in] | delim | The delimiting string. |
|
protected |
gstream | The characters to be fed into the primary header. This stream contains neither line feeds nor 0-bytes. | |
[in] | glines | The number of 80-byte blocks in gstream |
[in] | restr | Restrict the lines such that NAXIS keywords are blocked |
|
staticprotected |
hdu | The header-data unit to be checked for the card. |
card | The (first 80 bytes of) the new header card. |
verbose |
String FEditHead::cfgFil |
Name of the configuration file with header template keywords.
char* FEditHead::buffer |
The concatenation of all input lines, trimed/expanded to a multiple of 80 characters per line, one final \0.
|
protected |
The assembly of all template keyword ASCII lines.
These are all lines with the exception of empty or comment lines. They are kept in the order of the configuration file, which may be important if the same keyword may be targeted at more than one place (in case of which the templates are enacted from the top to the bottom of the configuation file.)