- Timestamp:
- May 30, 2015, 7:59:48 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c
r38335 r38340 3 3 # include "tap_ohana.h" 4 4 5 int test_compress ( char *zcmptype);5 int test_compress (int bitpix, char *zcmptype); 6 6 7 7 int main (int argc, char **argv) { … … 11 11 diag ("libfits imagecomp.c tests"); 12 12 13 test_compress ("NONE"); 14 test_compress ("GZIP_1"); 13 test_compress ( 8, "NONE"); 14 test_compress ( 16, "NONE"); 15 test_compress ( 32, "NONE"); 16 test_compress (-32, "NONE"); 17 test_compress (-64, "NONE"); 18 19 test_compress ( 8, "GZIP_1"); 20 test_compress ( 16, "GZIP_1"); 21 test_compress ( 32, "GZIP_1"); 22 test_compress (-32, "GZIP_1"); 23 test_compress (-64, "GZIP_1"); 15 24 16 25 exit (0); … … 20 29 # define NY 100 21 30 22 int test_compress ( char *zcmptype) { // make a table, compress, uncompress, compare : use compression zcmptype31 int test_compress (int bitpix, char *zcmptype) { // make a table, compress, uncompress, compare : use compression zcmptype 23 32 24 33 Header rawheader; … … 31 40 ftable.header = &theader; 32 41 33 diag ("--- starting test_compress with zcmptype %s ---", zcmptype);42 diag ("--- starting test_compress with bitpix %d, zcmptype %s ---", bitpix, zcmptype); 34 43 ok (gfits_init_header (&rawheader), "init'ed the raw header"); 35 44 ok (gfits_init_matrix (&rawmatrix), "init'ed the raw matrix"); … … 38 47 39 48 /* assign the necessary internal values */ 40 rawheader.bitpix = -32;49 rawheader.bitpix = bitpix; 41 50 rawheader.Naxes = 2; 42 51 rawheader.Naxis[0] = NX; … … 46 55 ok (gfits_create_header (&rawheader), "created header"); 47 56 ok (gfits_create_matrix (&rawheader, &rawmatrix), "created matrix"); 48 49 float *rawdata = (float *) rawmatrix.buffer; 57 58 char *rawdata_char = (char *) rawmatrix.buffer; 59 short *rawdata_short = (short *) rawmatrix.buffer; 60 int *rawdata_int = (int *) rawmatrix.buffer; 61 float *rawdata_float = (float *) rawmatrix.buffer; 62 double *rawdata_double = (double *) rawmatrix.buffer; 63 50 64 int ix, iy; 51 65 for (ix = 0; ix < NX; ix++) { 52 66 for (iy = 0; iy < NY; iy++) { 53 rawdata[ix + NX*iy] = ix * iy*iy; 67 switch (bitpix) { 68 case 8: rawdata_char [ix + NX*iy] = ix + iy*iy; break; 69 case 16: rawdata_short [ix + NX*iy] = ix + iy*iy; break; 70 case 32: rawdata_int [ix + NX*iy] = ix + iy*iy; break; 71 case -32: rawdata_float [ix + NX*iy] = ix + iy*iy; break; 72 case -64: rawdata_double[ix + NX*iy] = ix + iy*iy; break; 73 default: myAbort ("bad bitpix value"); 74 } 54 75 } 55 76 } … … 64 85 int Nbad = 0; 65 86 66 float *outdata = (float *) outmatrix.buffer; 87 char *outdata_char = (char *) outmatrix.buffer; 88 short *outdata_short = (short *) outmatrix.buffer; 89 int *outdata_int = (int *) outmatrix.buffer; 90 float *outdata_float = (float *) outmatrix.buffer; 91 double *outdata_double = (double *) outmatrix.buffer; 92 67 93 for (ix = 0; ix < NX; ix++) { 68 94 for (iy = 0; iy < NY; iy++) { 69 if (rawdata[ix + NX*iy] != outdata[ix + NX*iy]) Nbad ++; 95 switch (bitpix) { 96 case 8: if (rawdata_char [ix + NX*iy] != outdata_char [ix + NX*iy]) Nbad ++; break; 97 case 16: if (rawdata_short [ix + NX*iy] != outdata_short [ix + NX*iy]) Nbad ++; break; 98 case 32: if (rawdata_int [ix + NX*iy] != outdata_int [ix + NX*iy]) Nbad ++; break; 99 case -32: if (rawdata_float [ix + NX*iy] != outdata_float [ix + NX*iy]) Nbad ++; break; 100 case -64: if (rawdata_double[ix + NX*iy] != outdata_double[ix + NX*iy]) Nbad ++; break; 101 default: myAbort ("bad bitpix value"); 102 } 70 103 } 71 104 }
Note:
See TracChangeset
for help on using the changeset viewer.
