dstndstn / astrometry.net

Astrometry.net -- automatic recognition of astronomical images
http://astrometry.net
Other
662 stars 186 forks source link

Modify qfits to follow FITS standard #164

Open daniel-SG1 opened 5 years ago

daniel-SG1 commented 5 years ago

Modifying the 'qfits_card.c' source file

While using the solve-field program, I noticed that it complained about the presence of the "REGISTAR" keyword in my FITS images. This keyword is simply a comment keyword, but rather than using "COMMENT" it used "REGISTAR".

The FITS standard makes such keywords legal, and since they are put in the images automatically by the RegiStar software I think it would be best to modify the qfits library to use the standard.

The file 'qfits_card.c' requires the following lines to be inserted near the beginning of the 'qfits_getkey_r' function, immediately preceding the 'Special case: blank keyword' comment:

/* BEGIN CHANGE */
/* 2019 06 27 -- FITS standard defines keys as being exactly 8 characters
  It is also not necessary for an equal sign to follow a key
  http://archive.stsci.edu/fits/fits_standard/node29.html#SECTION00912100000000000000
  The purpose of this change is to eliminate the need to keep
  adding "special cases" where the keyword is not followed by an equal sign.
*/

memcpy(key, line, 8);
key[8] = '\0';
for (i = 0; i < 8; i++)
{
    if (' ' == key[i])
    {
        key[i] = '\0';
        break;
    }
}

return key;

/* END OF CHANGE */
dstndstn commented 5 years ago

What does solve-field say about it?

Also, if you have 'fitsverify', can you please run that on your image and see what it says.

Thanks.

daniel-SG1 commented 5 years ago

solve-field says: qfits_getkey: cannot find equal sign in line

I uploaded the image to the FITS verifier script on the NASA GSFC site, and it indicated no errors (although it did issue warning that the keyword was duplicated, but that is because it is a multi line comment, still valid).

rmathar commented 3 years ago

There is the HIERARCH FITS convention which does allow header keywords to contain blanks and to be longer than 8 characters. It's for example supported by cfitsio (written in C) and nom.tam.fits (in Java). These files are generated for example by ESO instruments. See https://fits.gsfc.nasa.gov/registry/hierarch_keyword.html . The proposal above would reduce all header keywords to the single "HIERARCH" keyword and basically disable that convention. So actually using this code snipped is a bad idea assuming that some of the FITS files may be using that HIERARCH convention.