Commit 95878a66 authored by Ole Streicher's avatar Ole Streicher

New upstream version 4.17

parent 15469f05
......@@ -12,11 +12,14 @@ libcfitsio.a on unix systems).
fitsverify can be built on most unix machines with a command similar
to the following:
gcc -o fitsverify ftverify.c fvrf_data.c fvrf_file.c fvrf_head.c fvrf_key.c
fvrf_misc.c -DSTANDALONE -L. -lcfitsio -lm -lnsl -lsocket
gcc -o fitsverify ftverify.c fvrf_data.c fvrf_file.c fvrf_head.c
fvrf_key.c fvrf_misc.c -DSTANDALONE -I/path/to/my/cfitsio
-L/path/to/my/cfitsio -lcfitsio -lm -lnsl -lsocket
(The '-lm', '-lnsl' and '-lsocket' library directives may not be
required on all platforms.)
Where you should substitute "/path/to/my/cfitsio" with the location
of the cfitsio header files and library on your system. Note also
that the '-lm', '-lnsl' and '-lsocket' library directives may not be
required on all platforms.
Optionally, one may add the -DERR2OUT flag to force all the error
messages to go to stdout rather than stderr (usually only useful
......@@ -27,7 +30,10 @@ vcvars32.bat file that is distributed with vcc, unpack the fitverify
.zip file, then excute the following command:
cl /MD ftverify.c fvrf_data.c fvrf_file.c fvrf_head.c fvrf_key.c
fvrf_misc.c -DSTANDALONE cfitsio.lib
fvrf_misc.c -DSTANDALONE /link setargv.obj cfitsio.lib
(The "/link setargv.obj" is optional and just enables support
for wildcard characters (like *) in the input file names).
A help file describing the features of fitsverify can be produced
by entering the command 'fitsverify -h'. The help file
......@@ -50,17 +56,16 @@ USAGE: fitsverify filename ... - verify one or more FITS files
EXAMPLES:
fitsverify -l m101.fits - produce a detailed verificaton report of
a single file, including a keyword listing
fitsverify -q *.fits *.fit - verify all files with .fits or .fit
extensions, writing a 1-line pass/fail
fitsverify -q *.fits *.fit - verify all files with .fits or .fit
extensions, writing a 1-line pass/fail
message for each file
DESCRIPTION:
This task reads one or more input FITS files and verifies that the
files conform to the specifications of the FITS Standard document
(known as the NASA/Science Office of Standards and Technology 'Definition
of the Current FITS Standard', document number, NOST 100-2.0, available
online at http://fits.gsfc.nasa.gov/). The input filename template may
files conform to the specifications of the FITS Standard, Definition
of the Flexible Image Transport System (FITS), Version 3.0, available
online at http://fits.gsfc.nasa.gov/. The input filename template may
contain wildcard characters, in which case all matching files will be
tested. Alternatively, the name of an ASCII text file containing a list
of file names, one per line, may be entered preceded by an '@' character.
......@@ -86,18 +91,16 @@ DESCRIPTION:
- Value and comment fields not separated by a slash character
- END keyword not filled with blanks in columns 9 - 80
- Reserved keyword with wrong datatype or illegal value
- EXTEND not present in the primary array if there are extensions
- BLOCKED, if present, not among the first 36 keywords
- XTENSION keyword in the primary array
- Column related keyword (TFIELDS, TTYPEn,TFORMn, etc.) in an image
- SIMPLE, EXTEND, or BLOCKED keyword in any extension
- BSCALE, BZERO, BUNIT, BLANK, DATAMAX, DATAMIN keywords in a table
- Image WCS keywords (CTYPEn, CRPIXn, CRVALn, etc.) in a table
- Table WCS keywords (TCTYPn, TCRPXn, TCRVLn, etc.) in an image
- TDIMn or THEAP keyword in an ASCII table
- TBCOLn keyword in a Binary table
- THEAP keyword in a binary table that has PCOUNT = 0
- XTENSION, TFORMn, TDISPn or TDIMn value contains leading space(s)
- WCSAXES keyword appears after other WCS keywords
- Index of any WCS keyword (CRPIXn, CRVALn, etc.) greater than
value of WCSAXES
- Index of any table column descriptor keyword (TTYPEn, TFORMn,
......@@ -106,6 +109,8 @@ DESCRIPTION:
- TDISPn value is inconsistent with the column datatype
- Length of a variable length array greater than the maximum
length as given by the TFORMn keyword
- ASCII table floating-point column value does not have decimal point(*)
- ASCII table numeric column value has embedded space character
- Logical column contains illegal value not equal to 'T', 'F', or 0
- Character string column contains non-ASCII text character
- Header fill bytes not all blanks
......@@ -122,7 +127,7 @@ DESCRIPTION:
- BSCALE or TSCALn value = 0.
- BLANK OR TNULLn value exceeds the legal range
- TFORMn has 'rAw' format and r is not a multiple of w
- DATE = 'dd/mm/yy' and yy is less than 10 (Y2K problem??)
- DATE = 'dd/mm/yy' and yy is less than 10 (Y2K problem?)
- Index of any WCS keyword (CRPIXn, CRVALn, etc.) greater than
value of NAXIS, if the WCSAXES keyword is not present
- Duplicated keyword (except COMMENT, HISTORY, blank, etc.)
......
......@@ -49,7 +49,7 @@ printf("DESCRIPTION:\n");
printf(" \n");
printf(" This task reads one or more input FITS files and verifies that the\n");
printf(" files conform to the specifications of the FITS Standard, Definition\n");
printf(" of the Flexible Image Transport System (FITS), Version 3.0, available");
printf(" of the Flexible Image Transport System (FITS), Version 3.0, available\n");
printf(" online at http://fits.gsfc.nasa.gov/. The input filename template may\n");
printf(" contain wildcard characters, in which case all matching files will be \n");
printf(" tested. Alternatively, the name of an ASCII text file containing a list\n");
......
......@@ -87,8 +87,15 @@ HISTORY
* opening a nonexistent or non-FITS file.
* Also fixed elusive memory allocation error.
*
* 2009-06-08 W Pence updates to comply with V3.0 of the FITS Standard
* 2010-07-26 W Pence Updates to WCS keyword checks, plux other V3.0 issues
* 2009-06-08 W Pence v4.15
* updates to comply with V3.0 of the FITS Standard
* 2010-07-26 W Pence v4.16
* Updates to WCS keyword checks, plus other V3.0 issues.
* Also check for non-zero heap if binary table has no
* variable length array columns.
* 2013-08-12 W Pence v4.17
* Ignore blank keywords preceding the END keyword.
* Support (partially at least) files with PCOUNT > 2GB.
*/
#define TOOLSUB ftverify
......@@ -131,7 +138,7 @@ int ftverify (void)
char errreport[PIL_LINESIZE];
static char taskname[80] = "ftverify";
static char version[8] = "4.16";
static char version[8] = "4.17";
/* Register taskname and version. */
......
......@@ -91,7 +91,7 @@ typedef struct {
int isgroup; /* random group flag */
int istilecompressed; /* tile compressed image */
int gcount; /* gcount */
int pcount; /* pcount */
LONGLONG pcount; /* pcount */
int bitpix; /* pix number */
int naxis; /* number of the axis,used for image array*/
LONGLONG *naxes; /* dimension of each axis,used for image array*/
......
......@@ -70,9 +70,8 @@ void test_data(fitsfile *infits, /* input fits file */
long repeat;
long totalrows;
long heap_offset;
long length;
long toffset;
LONGLONG length;
LONGLONG toffset;
long *maxlen;
int icol;
char *cdata;
......@@ -288,7 +287,6 @@ void test_data(fitsfile *infits, /* input fits file */
perbyte = (int *) calloc(ndesc , sizeof(int));
fits_get_num_rows(infits,&totalrows,&status);
status = 0;
heap_offset = hduptr->heap - hduptr->naxes[0] * hduptr->naxes[1];
/* this routine now only reads and test BIT, LOGICAL, and STRING columns */
/* There is no point in reading the other columns because the other datatypes */
......@@ -354,7 +352,7 @@ void test_data(fitsfile *infits, /* input fits file */
icol = desclist[i];
/* read and check the descriptor length and offset values */
if(fits_read_descript(infits, icol ,jl,&length,
if(fits_read_descriptll(infits, icol ,jl,&length,
&toffset, &status)){
sprintf(errtmp,"Row #%ld Col.#%d: ",jl,icol);
......@@ -364,7 +362,7 @@ void test_data(fitsfile *infits, /* input fits file */
sprintf(errmes, "Descriptor of Column #%d at Row %ld: ",
icol, jl);
sprintf(errtmp,"nelem(%ld) > maxlen(%ld) given by TFORM%d.",
length,maxlen[i],icol);
(long) length,maxlen[i],icol);
strcat(errmes,errtmp);
wrterr(out,errmes,1);
}
......@@ -374,19 +372,19 @@ void test_data(fitsfile *infits, /* input fits file */
else
bytelength = length*perbyte[i];
if(heap_offset + toffset + bytelength > hduptr->pcount ) {
if(toffset + bytelength > hduptr->pcount ) {
sprintf(errmes, "Descriptor of Column #%d at Row %ld: ",
icol, jl);
sprintf(errtmp,
" offset of first element(%ld) + nelem(%ld)",
toffset,length);
(long) toffset, (long) length);
strcat(errmes,errtmp);
if(perbyte[i] < 0)
sprintf(errtmp, "/8 > total heap area = %ld.",
hduptr->pcount-heap_offset);
(long) hduptr->pcount);
else
sprintf(errtmp, "*%d > total heap area = %ld.",
perbyte[i],hduptr->pcount-heap_offset);
perbyte[i], (long) hduptr->pcount);
strcat(errmes,errtmp);
wrterr(out,errmes,2);
}
......@@ -450,8 +448,8 @@ void test_data(fitsfile *infits, /* input fits file */
for (k = 0; k < rlength; k++) {
if (cdata[k] > 2) {
sprintf(errmes,
"Logical value in row #%ld, and column #%d has illegal value = %d",
jl, icol, (int) cdata[k]);
"Logical value in row #%ld, column #%d not equal to 'T', 'F', or 0",
jl, icol);
wrterr(out,errmes,1);
strcpy(errmes,
" (This error is reported only once; other rows may have errors).");
......@@ -632,9 +630,9 @@ data_end:
for(j = 1; j <= nrows * repeat[i]; j++) {
if (ldata[j] > 2) {
sprintf(errmes,
"Logical value in row #%ld, column #%d has illegal value = %d",
"Logical value in row #%ld, column #%d not equal to 'T', 'F', or 0",
(firstn+j - 2)/repeat[i] +1,
fits_iter_get_colnum(&(iter_col[i])), (int) ldata[j]);
fits_iter_get_colnum(&(iter_col[i])));
wrterr(usrpt->out,errmes,1);
strcpy(errmes,
" (Other rows may have similar errors).");
......
......@@ -222,11 +222,20 @@ void init_hdu(fitsfile *infits, /* input fits file */
for (i=0; i < ncards; i++) {
cards[i] = (char *)malloc(sizeof(char )* FLEN_CARD );
}
for (i=1; i <= ncards; i++) {
if(fits_read_record(infits, i, cards[i-1], &status))
wrtferr(out,"",&status,1);
}
/* if there were blank cards prior to the END card, then
make a fake END card, because CFITSIO blocks us from reading
the real END card */
if (strncmp(cards[ncards-1], "END ", 8)) {
strcpy(cards[ncards-1],"END ");
}
/* Parse the XTENSION/SIMPLEX keyword */
fits_parse_card(out, 1, cards[0], tmpkey.kname,
&(tmpkey.ktype), tmpkey.kvalue,comm);
......@@ -452,7 +461,8 @@ void test_hdu(fitsfile *infits, /* input fits file */
int numusrkey;
int hdunum;
char *p, *p2, *pname = 0;
int i,j,k,m,n, wcsaxes = 0, taxes;
int i,j,k,m,n, wcsaxes = 0;
int taxes;
int wcsaxesExists = 0, wcsaxesvalue = 0, wcsaxespos = 0, wcskeypos = 1000000000;
FitsKey *pkey;
int crota2_exists = 0, matrix_exists[2] = {0,0};
......@@ -554,6 +564,12 @@ void test_hdu(fitsfile *infits, /* input fits file */
pkey = hduptr->kwds[j];
wcsaxesvalue = (int) strtol(pkey->kvalue,NULL,10);
nmax = wcsaxesvalue;
if (wcsaxesvalue > wcsaxes) wcsaxes = wcsaxesvalue;
wcsaxesExists = 1;
/* store index of the wcsaxes keyword */
/* (it must appear before other WCS keywords) */
if (pkey->kindex > wcsaxespos) wcsaxespos = pkey->kindex;
}
}
......@@ -562,6 +578,9 @@ void test_hdu(fitsfile *infits, /* input fits file */
/* This is a less rigorous test than if one were to test the range of the */
/* keywords for each of the alternate WCS systems (A - Z) against the */
/* corresponding WCSAXESa keyword. */
key_match(tmpkwds,numusrkey,&ptemp,0,&k,&n);
for (j = k; j< n + k ; j++){
......@@ -573,7 +592,17 @@ void test_hdu(fitsfile *infits, /* input fits file */
/* store highest index of any wcsaxes keyword */
/* (they must appear before other WCS keywords) */
if (pkey->kindex > wcsaxespos) wcsaxespos = pkey->kindex;
/* Removed this check on 6/28/2012. See discussion on FITSBITS related
to this requirement. The sense of this dicussion is that it is not required
that every WCSAXESa keyword appear before ANY OTHER WCS keyword. In principle,
each WCSAXESa keyword should appear before any other WCS keyword within the SAME
alternate system, but this does not really provide any benefit to software that
needs to parse the WCS keywords. Since it would be somewhat tedious to make
this test, we will not not worry about the placement of the WCSAXESa keywords.
*/
/* if (pkey->kindex > wcsaxespos) wcsaxespos = pkey->kindex; */
}
}
......@@ -1000,7 +1029,7 @@ void test_prm(fitsfile *infits, /* input fits file */
}
else {
if(check_int(pkey,out))
hduptr->pcount = (int) strtol(pkey->kvalue,NULL,10);
hduptr->pcount = (LONGLONG) atof(pkey->kvalue);
check_fixed_int(cards[pkey->kindex - 1], out);
}
......@@ -1196,7 +1225,7 @@ void test_ext(fitsfile *infits, /* input fits file */
else {
pkey = hduptr->kwds[k];
if(check_int(pkey,out))
hduptr->pcount = (int) strtol(pkey->kvalue,NULL,10);
hduptr->pcount = (LONGLONG) atof(pkey->kvalue);
if( pkey->kindex != 4 + hduptr->naxis ) {
sprintf(errmes,"PCOUNT is not in record %d of the header.",
hduptr->naxis + 4);
......@@ -1287,7 +1316,7 @@ void test_img_ext(fitsfile *infits, /* input fits file */
if(hduptr->pcount != 0 && hduptr->pcount != -99){
sprintf(errmes,
"Illegal pcount value %d for image ext.",hduptr->pcount);
"Illegal pcount value %ld for image ext.",(long) hduptr->pcount);
wrterr(out,errmes,1);
}
......
......@@ -57,7 +57,7 @@ int fits_parse_card(FILE *out, /* output file pointer */
(*p < '0' || *p > '9')&&
(*p != '-' && *p != '_') ) {
sprintf(errmes,
"Keyword #%d: Name \"%s\" contains char \"%c\" which is not letter, digit, \"-\", and \"_\".",kpos,kname,*p);
"Keyword #%d: Name \"%s\" contains char \"%c\" which is not upper case letter, digit, \"-\", or \"_\".",kpos,kname,*p);
wrterr(out,errmes,1);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment