Changeset 41474
- Timestamp:
- Jan 24, 2021, 3:37:52 PM (5 years ago)
- Location:
- trunk/Ohana/src/libfits
- Files:
-
- 10 edited
-
include/gfitsio.h (modified) (1 diff)
-
matrix/F_compress_M.c (modified) (4 diffs)
-
matrix/F_compress_data.c (modified) (1 diff)
-
matrix/F_compress_utils.c (modified) (7 diffs)
-
matrix/F_uncompress_M.c (modified) (12 diffs)
-
matrix/F_uncompress_data.c (modified) (1 diff)
-
table/F_get_column.c (modified) (1 diff)
-
table/F_table_format.c (modified) (3 diffs)
-
test/compress.sh (modified) (8 diffs)
-
test/imagecomp.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/include/gfitsio.h
r41433 r41474 214 214 int gfits_byteswap_zdata PROTO((char *zdata, off_t Nzdata, int pixsize)); 215 215 int gfits_compressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions)); 216 int gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions ));217 int gfits_uncompressed_data_bitpix PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions ));216 int gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions, int rice_use_bitpix)); 217 int gfits_uncompressed_data_bitpix PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions, int rice_use_bitpix)); 218 218 int gfits_vartable_heap_pixsize PROTO((char format)); 219 219 int gfits_cmptype_valid PROTO((char *cmptype)); -
trunk/Ohana/src/libfits/matrix/F_compress_M.c
r39457 r41474 76 76 if (!gfits_modify (theader, "ZCMPTYPE", "%s", 1, zcmptype)) ESCAPE; 77 77 78 // define compression-specific keywords, update header as needed.79 if (!strcasecmp(zcmptype, "GZIP_1") || !strcasecmp(zcmptype, "GZIP_2")) {80 if ((header[0].bitpix == -32) || (header[0].bitpix == -64)) {81 if (!gfits_modify (theader, "ZQUANTIZ", "%s", 1, "NONE")) ESCAPE;82 }83 }84 85 78 if (!gfits_modify_alt (theader, "ZSIMPLE", "%t", 1, TRUE)) ESCAPE; 86 79 // gfits_modify (header, "ZTENSION", "%s", 1, exttype); … … 124 117 int oblank = 32767; 125 118 // gfits_modify (header, "BLANK", "%d", 1, oblank); 119 120 // define compression-specific keywords, update header as needed. 121 if (!strcasecmp(zcmptype, "GZIP_1") || !strcasecmp(zcmptype, "GZIP_2")) { 122 if ((header[0].bitpix == -32) || (header[0].bitpix == -64)) { 123 if (!gfits_modify (theader, "ZQUANTIZ", "%s", 1, "NONE")) ESCAPE; 124 } 125 } 126 126 127 127 # if (0) … … 159 159 unsigned long int max_tile_size = gfits_imtile_maxsize (matrix, ztile); 160 160 161 // size of a pixel in the raw pixel buffer (before compression) 162 int raw_pixsize = gfits_uncompressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0); 163 int raw_bitpix = gfits_uncompressed_data_bitpix (zcmptype, header[0].bitpix, NULL, NULL, 0); 161 // size of a pixel in the compressed data (cmp_pixsize), used for byteswap below 164 162 int cmp_pixsize = gfits_compressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0); 163 164 // size of a pixel in the raw pixel buffer (before compression) (last option says RICE uses header.bitpix) 165 int raw_pixsize = gfits_uncompressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0, TRUE); 166 167 // we also need the bitpix value for the raw uncompressed buffer to distinguish int and floats 168 int raw_bitpix = gfits_uncompressed_data_bitpix (zcmptype, header[0].bitpix, NULL, NULL, 0, TRUE); 165 169 166 170 // define compression-specific keywords, update header as needed. … … 237 241 } 238 242 239 // GZIP_1 is swapped before compression; GZIP_2 implies swapping. All other 240 // compression modes require swapping after compression (compresssion & decompression 241 // operate on native ENDIAN) 242 if (strcasecmp(zcmptype, "NONE_2") && // strcasecmp(zcmptype, "NONE") && 243 strcasecmp(zcmptype, "GZIP_1") && 244 strcasecmp(zcmptype, "GZIP_2") && 245 strcasecmp(zcmptype, "RICE_1") && 246 strcasecmp(zcmptype, "RICE_ONE")) { 247 // Nzdata is number of bytes 248 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; 249 } 243 // BYTESWAP the compressed data after compressing. Compression algorithms which do 244 // not need to byteswap here return 1 for cmp_pixsize. GZIP_1 is swapped before 245 // compression; GZIP_2 implies swapping. All other compression modes require swapping 246 // after compression (the compresssion & decompression functions operate on native 247 // ENDIAN data values). 248 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; 250 249 251 250 if (VERBOSE_DUMP && (i == 0)) { -
trunk/Ohana/src/libfits/matrix/F_compress_data.c
r39457 r41474 120 120 121 121 if (status) { 122 fprintf (stderr, "error in h decompress\n");122 fprintf (stderr, "error in hcompress\n"); 123 123 return (FALSE); 124 124 } -
trunk/Ohana/src/libfits/matrix/F_compress_utils.c
r39457 r41474 104 104 // fprintf (stderr, "swapping %d bytes in pix of size %d bytes...\n", Nzdata, pixsize); 105 105 switch (pixsize) { 106 case 0: 106 107 case 1: 107 108 break; … … 186 187 } 187 188 188 int gfits_uncompressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 189 // the size of the compressed data pixels, needed to perform swaps 190 int gfits_compressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 191 192 // NONE should be swapped to mimic swapping types 193 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_1")) { 194 if (out_bitpix == 8) return (1); 195 if (out_bitpix == 16) return (2); 196 if (out_bitpix == 32) return (4); 197 if (out_bitpix == -32) return (4); 198 if (out_bitpix == -64) return (8); 199 return (1); 200 } 201 202 // GZIP_1, GZIP_2 should not be swapped after compression / before decompression 203 if (!strcasecmp(cmptype, "GZIP_1") || 204 !strcasecmp(cmptype, "GZIP_2") || 205 !strcasecmp(cmptype, "NONE_2")) { 206 if (out_bitpix == 8) return (1); 207 if (out_bitpix == 16) return (1); 208 if (out_bitpix == 32) return (1); 209 if (out_bitpix == -32) return (1); 210 if (out_bitpix == -64) return (1); 211 return (1); 212 } 213 214 // RICE_1 should not be swapped after compression / before decompression 215 if (!strcasecmp(cmptype, "RICE_1") || 216 !strcasecmp(cmptype, "RICE_ONE")) { 217 return (1); 218 } 219 220 // PLIO_1 always results in 4-byte ints (not 2 byte ints?) 221 if (!strcasecmp(cmptype, "PLIO_1")) { 222 return (4); 223 } 224 225 if (!strcasecmp(cmptype, "HCOMPRESS_1")) { 226 if (out_bitpix == 8) return (4); 227 if (out_bitpix == 16) return (4); 228 return (8); 229 } 230 return (0); 231 } 232 233 int gfits_uncompressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions, int rice_use_bitpix) { 189 234 190 235 int i, Nbyte; … … 207 252 if (!strcasecmp(cmptype, "RICE_1") || 208 253 !strcasecmp(cmptype, "RICE_ONE")) { 254 // on compression, user may set BYTEPIX based on header.bitpix: 255 if (rice_use_bitpix) { 256 if (out_bitpix == 8) return (1); 257 if (out_bitpix == 16) return (2); 258 if (out_bitpix == 32) return (4); 259 } 209 260 // if BYTEPIX option is specified, use that for Nbyte 210 261 for (i = 0; i < Noptions; i++) { … … 214 265 } 215 266 } 216 if (out_bitpix == 8) return (1); 217 if (out_bitpix == 16) return (2); 218 if (out_bitpix == 32) return (4); 219 return (4); 267 return (4); // RICE_1 default is 4 byte int if BYTEPIX undefined (White et al 6.2) 220 268 } 221 269 … … 233 281 } 234 282 235 int gfits_compressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 236 237 int i, Nbyte; 238 239 // NONE should be swapped to mimic swapping types 240 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_1")) { 241 if (out_bitpix == 8) return (1); 242 if (out_bitpix == 16) return (2); 243 if (out_bitpix == 32) return (4); 244 if (out_bitpix == -32) return (4); 245 if (out_bitpix == -64) return (8); 246 return (1); 247 } 248 249 // GZIP_1, GZIP_2 should not be swapped after compression 250 if (!strcasecmp(cmptype, "GZIP_1") || 251 !strcasecmp(cmptype, "GZIP_2") || 252 !strcasecmp(cmptype, "NONE_2")) { 253 if (out_bitpix == 8) return (1); 254 if (out_bitpix == 16) return (1); 255 if (out_bitpix == 32) return (1); 256 if (out_bitpix == -32) return (1); 257 if (out_bitpix == -64) return (1); 258 return (1); 259 } 260 261 // RICE_1 must operate on integer pixels 262 if (!strcasecmp(cmptype, "RICE_1") || 263 !strcasecmp(cmptype, "RICE_ONE")) { 264 // if BYTEPIX option is specified, use that for Nbyte 265 for (i = 0; i < Noptions; i++) { 266 if (!strcmp(optname[i], "BYTEPIX")) { 267 Nbyte = atoi (optvalue[i]); 268 return (Nbyte); 269 } 270 } 271 if (out_bitpix == 8) return (1); 272 if (out_bitpix == 16) return (2); 273 if (out_bitpix == 32) return (4); 274 return (4); 275 } 276 277 // PLIO_1 always results in 4-byte ints (not 2 byte ints?) 278 if (!strcasecmp(cmptype, "PLIO_1")) { 279 return (4); 280 } 281 282 if (!strcasecmp(cmptype, "HCOMPRESS_1")) { 283 if (out_bitpix == 8) return (4); 284 if (out_bitpix == 16) return (4); 285 return (8); 286 } 287 return (0); 288 } 289 290 int gfits_uncompressed_data_bitpix (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 283 int gfits_uncompressed_data_bitpix (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions, int rice_use_bitpix) { 291 284 292 285 int i, Nbyte; … … 304 297 if (!strcasecmp(cmptype, "RICE_1") || 305 298 !strcasecmp(cmptype, "RICE_ONE")) { 299 if (rice_use_bitpix) { 300 if (out_bitpix == 8) return (out_bitpix); 301 if (out_bitpix == 16) return (out_bitpix); 302 if (out_bitpix == 32) return (out_bitpix); 303 } 306 304 // if BYTEPIX option is specified, use that for Nbyte 307 305 for (i = 0; i < Noptions; i++) { … … 311 309 } 312 310 } 313 if (out_bitpix == 8) return (out_bitpix);314 if (out_bitpix == 16) return (out_bitpix);315 if (out_bitpix == 32) return (out_bitpix);316 311 return (32); 317 312 } -
trunk/Ohana/src/libfits/matrix/F_uncompress_M.c
r40549 r41474 40 40 gfits_modify (header, NAME, TYPE, 1, OUT); } 41 41 42 # define DUMP_ROWBYTES(BUF, INFO) \ 43 if (VERBOSE_DUMP && (row == 0)) { \ 44 int k; \ 45 fprintf (stderr, "%s: ", INFO); \ 46 for (k = 0; k < 64; k++) { \ 47 fprintf (stderr, "%02hhx", BUF[k]); \ 48 if (k % 4 == 3) fprintf (stderr, " "); \ 49 } fprintf (stderr, "\n"); } 50 42 51 int gfits_uncompress_image (Header *header, Matrix *matrix, FTable *ftable) { 43 52 … … 97 106 } else { 98 107 gfits_delete (header, "ZTILE1", 1); 108 // if ZTILE1 exists, all ZTILEn must exist: 99 109 for (axis = 1; axis < header->Naxes; axis++) { 100 110 snprintf (key, 10, "ZTILE%d", axis + 1); … … 127 137 } 128 138 129 // XXX get ZMASKCMP 130 int zsimple, have_zsimple; 131 int have_ztension; 139 // check for ZMASKCMP (not yet supported 2021.01.23) 140 char zmaskcmp[81]; 141 int have_zmaskcmp = gfits_scan (header, "ZMASKCMP", "%s", 1, zmaskcmp); 142 if (have_zmaskcmp) { 143 fprintf (stderr, "null pixels were compressed with %s, not implemented in Ohana\n", zmaskcmp); 144 ESCAPE; 145 } 132 146 133 147 // NOTE target of %t must be int length 134 have_zsimple = gfits_scan_alt (header, "ZSIMPLE", "%t", 1, &zsimple); 135 have_ztension = gfits_scan (header, "ZTENSION", "%s", 1, exttype); 136 137 // this is a very bogus case: we cannot have both keywords 148 int zsimple; 149 int have_zsimple = gfits_scan_alt (header, "ZSIMPLE", "%t", 1, &zsimple); 150 int have_ztension = gfits_scan (header, "ZTENSION", "%s", 1, exttype); 151 152 // this is a bogus case: we cannot have both keywords 138 153 if (have_zsimple && have_ztension) ESCAPE; 139 154 … … 179 194 } 180 195 } else { 196 // if this is a PHU (whether or not ZSIMPLE is present), PCOUNT & GCOUNT must be basic (0,1) 181 197 header->pcount = 0; 182 198 header->gcount = 1; … … 188 204 MOD_KEYWORD ("ZDATASUM", "DATASUM", "%s", datasum, datasum); 189 205 190 zscale = 1; 191 gfits_scan (header, "ZSCALE", "%f", 1, &zscale); 192 193 zblank = 32767; 194 gfits_scan (header, "ZBLANK", "%d", 1, &zblank); 195 196 oblank = 32767; 197 gfits_scan (header, "BLANK", "%d", 1, &oblank); 198 199 zzero = 0; 200 gfits_scan (header, "ZZERO", "%f", 1, &zzero); 206 // get other basic keywords (default values supplied) 207 zscale = 1; gfits_scan (header, "ZSCALE", "%f", 1, &zscale); 208 zblank = 32767; gfits_scan (header, "ZBLANK", "%d", 1, &zblank); 209 oblank = 32767; gfits_scan (header, "BLANK", "%d", 1, &oblank); 210 zzero = 0; gfits_scan (header, "ZZERO", "%f", 1, &zzero); 201 211 202 212 // find the COMPRESSED_DATA column (format should be 1PB, 1PI, 1PJ) 203 // is it required that this be the only column?213 // XXX is it required that this be the only column? -- not if ZMASKCMP exists (not yet supported) 204 214 int colnum; 205 215 for (colnum = 1; TRUE; colnum++) { … … 242 252 243 253 // heapdata.pixsize : zdef.format 244 // zdata.pixsize : depends on compression 245 // odata.pixsize : depends on compression 246 // idata.pixsize : header.bitpix254 // zdata.pixsize : depends on compression method (cmp_pixsize below) 255 // odata.pixsize : depends on compression method (raw_pixsize below) 256 // idata.pixsize : depends on header.bitpix 247 257 248 258 // size of an element in the vartable heap section 249 259 // zdata_pixsize = gfits_vartable_heap_pixsize (zdef.format); XXX 250 260 251 // size of a pixel in the output from the decompression routine 261 // depending on the compression method, the data may need to be byteswapped either before 262 // or after uncompression: 263 264 // size of a pixel in the compressed data (cmp_pixsize), used for byteswap below 252 265 int cmp_pixsize = gfits_compressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions); 253 int raw_bitpix = gfits_uncompressed_data_bitpix (cmptype, header[0].bitpix, optname, optvalue, Noptions); 254 int raw_pixsize = gfits_uncompressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions); 266 267 // size of a pixel in the raw uncomprssed buffer (raw_pixsize) after uncompression (last option says RICE ignores bitpix) 268 int raw_pixsize = gfits_uncompressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions, FALSE); 269 270 // we also need the bitpix value for the raw uncompressed buffer to distinguish int and floats 271 int raw_bitpix = gfits_uncompressed_data_bitpix (cmptype, header[0].bitpix, optname, optvalue, Noptions, FALSE); 255 272 256 273 // size of a pixel in the final image (not needed) … … 261 278 ALLOCATE (out, char, Nout_alloc); 262 279 263 off_t row;264 265 if (VERBOSE_DUMP) {266 int k;267 fprintf (stderr, "unc tbl: ");268 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", ftable->buffer[k]); if (k % 4 == 3) fprintf (stderr, " "); }269 fprintf (stderr, "\n");270 }271 272 280 // uncompress the data 273 281 Nzrows = ftable->header->Naxis[1]; 274 for (row = 0; row < Nzrows; row++) { 282 for (off_t row = 0; row < Nzrows; row++) { 283 284 DUMP_ROWBYTES (ftable->buffer, "tbl dat"); 275 285 276 286 // expected output size for this tile … … 280 290 if (!zdata) ESCAPE; 281 291 282 if (VERBOSE_DUMP && (row == 0)) { 283 int k; 284 fprintf (stderr, "unc dat: "); 285 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); } 286 fprintf (stderr, "\n"); 287 } 288 289 if (strcasecmp(cmptype, "NONE_2") && // strcasecmp(cmptype, "NONE") && 290 strcasecmp(cmptype, "GZIP_1") && 291 strcasecmp(cmptype, "GZIP_2") && 292 strcasecmp(cmptype, "RICE_1") && 293 strcasecmp(cmptype, "RICE_ONE")) { 294 // Nzdata is number of bytes 295 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; 296 } 297 298 if (VERBOSE_DUMP && (row == 0)) { 299 int k; 300 fprintf (stderr, "unc SWP: "); 301 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); } 302 fprintf (stderr, "\n"); 303 fprintf (stderr, "Nout : %lu -> ", Nout); 304 } 292 DUMP_ROWBYTES (zdata, "cmp dat"); 293 294 // byteswap the compressed data before uncompressing. 295 // compression algorithms which do not need to byteswap here return 1 for cmp_pixsize 296 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; 297 298 DUMP_ROWBYTES (zdata, "cmp swp"); 305 299 306 300 // gfits_uncompress_data uncompresses from zdata to the temporary output buffer which must be allocated 307 // XXXthe tile must not be > 2GB308 // Nout going in is number of bytes301 // Note: the tile must not be > 2GB 302 // Nout going in is the expected number of bytes 309 303 if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, Nout_alloc, raw_pixsize)) ESCAPE; 310 304 311 if (VERBOSE_DUMP && (row == 0)) { 312 int k; 313 fprintf (stderr, "%lu\n", Nout); 314 fprintf (stderr, "unc swp: "); 315 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); } 316 fprintf (stderr, "\n"); 317 } 305 DUMP_ROWBYTES (out, "unc swp"); 318 306 319 307 if (!strcasecmp(cmptype, "GZIP_1")) { … … 322 310 } 323 311 324 if (VERBOSE_DUMP && (row == 0)) { 325 int k; 326 fprintf (stderr, "unc raw: "); 327 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); } 328 fprintf (stderr, "\n"); 329 } 312 DUMP_ROWBYTES (out, "unc raw"); 330 313 331 314 // copy the uncompressed pixels into their correct locations … … 336 319 } 337 320 338 if (VERBOSE_DUMP && (row == 0)) { 339 int k; 340 fprintf (stderr, "unc mat: "); 341 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", matrix->buffer[k]); if (k % 4 == 3) fprintf (stderr, " "); } 342 fprintf (stderr, "\n"); 343 } 321 DUMP_ROWBYTES (matrix->buffer, "out raw"); 344 322 345 323 // update the tile counters, carrying to the next dimension if needed … … 370 348 } 371 349 372 // bitpix is the input data size/type 350 // raw_bitpix is the data size/type for the temporary buffer of uncompressed data 351 // matrix->bitpix is the data size/type of the output image data 373 352 int gfits_distribute_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) { 374 353 … … 514 493 } 515 494 516 // bitpix is the input data size/type 495 // raw_bitpix is the data size/type for the temporary buffer of uncompressed data 496 // matrix->bitpix is the data size/type of the output image data 497 // The gzip2 algorithm organizes the compressed data in groups by significant byte sequence (most significant byte of all pixels first, etc). 498 // gfits_distribute_gzp2 needs to shuffle the bytes back into the correct location in the tile. 517 499 int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) { 500 // unused parameters are supplied to make this function have the same API as gfits_distribute_data() 518 501 OHANA_UNUSED_PARAM(oblank); 519 502 OHANA_UNUSED_PARAM(zblank); -
trunk/Ohana/src/libfits/matrix/F_uncompress_data.c
r39457 r41474 5 5 6 6 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); } 7 8 /* This function uncompresses the data in 'zdata' into the pre-allocated output buffer 'outdata'. 9 The compression algorithm is chosen based on 'cmptype', with options specified by 'optname, optvalue, Nopt' 10 zdata : input compressed data, Nzdata : number of compressed BYTES 11 outdata : output buffer, Nout : number of actual output PIXELS, Nout_alloc : number of allocated bytes in the buffer, out_pixsize : bytes per output pixel 12 */ 7 13 8 14 int gfits_uncompress_data (char *zdata, unsigned long Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize) { -
trunk/Ohana/src/libfits/table/F_get_column.c
r41433 r41474 403 403 if (!strcmp (type, "int")) { 404 404 ALLOCATE (array, char, Ny*4); 405 Pout =array;406 for (i = 0; i < Ny; i++, Pin+=Nx, Pout+=4) {405 int *tmpPtr = (int *)array; 406 for (i = 0; i < Ny; i++, Pin+=Nx, tmpPtr ++) { 407 407 memcpy (line, Pin, Nval*Nbytes); 408 sscanf (line, cformat, (int *)Pout); 408 sscanf (line, "%d", tmpPtr); 409 // fprintf (stderr, "test: %d %d\n", Nscan, tmpValue); 409 410 } 410 411 } 411 412 if (!strcmp (type, "int64_t")) { 412 413 ALLOCATE (array, char, Ny*8); 413 Pout =array;414 for (i = 0; i < Ny; i++, Pin+=Nx, Pout+=8) {414 int64_t *tmpPtr = (int64_t *)array; 415 for (i = 0; i < Ny; i++, Pin+=Nx, tmpPtr ++) { 415 416 memcpy (line, Pin, Nval*Nbytes); 416 sscanf (line, "%" PRId64, (int64_t *)Pout);417 sscanf (line, "%" PRId64, tmpPtr); 417 418 } 418 419 } 419 420 if (!strcmp (type, "float")) { 420 421 ALLOCATE (array, char, Ny*4); 421 Pout =array;422 for (i = 0; i < Ny; i++, Pin+=Nx, Pout+=4) {422 float *tmpPtr = (float *) array; 423 for (i = 0; i < Ny; i++, Pin+=Nx, tmpPtr ++) { 423 424 memcpy (line, Pin, Nval*Nbytes); 424 sscanf (line, cformat, (float *)Pout); 425 sscanf (line, "%e", tmpPtr); 426 } 427 } 428 if (!strcmp (type, "double")) { 429 ALLOCATE (array, char, Ny*8); 430 double *tmpPtr = (double *) array; 431 for (i = 0; i < Ny; i++, Pin+=Nx, tmpPtr++) { 432 memcpy (line, Pin, Nval*Nbytes); 433 sscanf (line, "%le", tmpPtr); 425 434 } 426 435 } -
trunk/Ohana/src/libfits/table/F_table_format.c
r41433 r41474 92 92 int gfits_table_format (char *format, char *type, int *Nval, int *Nbytes) { 93 93 94 char Fchar, Size[80] , Type;94 char Fchar, Size[80]; 95 95 int Nv; 96 96 … … 107 107 } 108 108 109 Type = 'x'; 110 if (Fchar == 'D') { *Nbytes = 1; strcpy (type, "double"); Type = 'e'; *Nval = Nv; } 109 int isLong = FALSE; 110 char Type = 'x'; 111 if (Fchar == 'D') { *Nbytes = 1; strcpy (type, "double"); Type = 'e'; *Nval = Nv; isLong = TRUE; } 111 112 if (Fchar == 'E') { *Nbytes = 1; strcpy (type, "float"); Type = 'e'; *Nval = Nv; } 112 113 if (Fchar == 'F') { *Nbytes = 1; strcpy (type, "float"); Type = 'f'; *Nval = Nv; } … … 115 116 if (!*Nbytes) { return (FALSE); } 116 117 117 sprintf (format, "%%-%s%c", Size, Type); // NOTE: this line is not used 118 if (0) { 119 // this format is appropriate for scanning, but not printing 120 if (isLong) { 121 sprintf (format, "%%%sl%c", Size, Type); 122 } else { 123 sprintf (format, "%%%s%c", Size, Type); 124 } 125 } 126 127 // this format is appropriate for printing, but not scanning 128 sprintf (format, "%%-%s%c", Size, Type); 118 129 119 130 return (TRUE); -
trunk/Ohana/src/libfits/test/compress.sh
r38425 r41474 1 1 input tap.dvo 2 3 ## NOTE: in order to run this test suite, you must have a modern version of fpack / funpack. 4 ## The IPP version included in the build tree (3100-p5) does not have support for gzip2 in fpack. 5 6 ## Acceptable versions can be obtained by downloading a current copy 7 ## of CFITSIO (https://heasarc.gsfc.nasa.gov/fitsio/). 8 9 ## To avoid installing the library or funpack/fpack in your psconfig 10 ## tree, only build the code locally and do NOT install. 11 12 ## in the cfitsio directory, edit the Makefile with the following changes: 13 14 ## LDFLAGS_BIN = -g -O2 -Wl,-rpath,${CFITSIO_LIB} -static 15 ## CFLAGS = -g -Dg77Fortran -fPIC 16 ## (comment out the old versions) 17 18 ## run psconfigure, make, make fpack funpack 19 20 ## after building these (static) binaries, link them into this test directory 2 21 3 22 macro tests … … 5 24 test_table_all_rnd 6 25 end 26 27 $FPACK = ./fpack 28 $FUNPACK = ./funpack 7 29 8 30 macro test_image_all … … 53 75 54 76 if ($cmpmode == GZIP_1) 55 exec fpack -q 0 -g -S test.raw.fits > test.fpk.fits 77 ## mana does not (yet) handle non-zero quantization 78 exec $FPACK -q 0 -g -S test.raw.fits > test.fpk.fits 56 79 end 57 80 if ($cmpmode == GZIP_2) 58 exec fpack-q 0 -g2 -S test.raw.fits > test.fpk.fits81 exec $FPACK -q 0 -g2 -S test.raw.fits > test.fpk.fits 59 82 end 60 83 if ($cmpmode == RICE_1) 61 exec fpack-r -S test.raw.fits > test.fpk.fits84 exec $FPACK -r -S test.raw.fits > test.fpk.fits 62 85 end 63 86 # echo "load fpack version" … … 68 91 tapOK {$SIGMA < 0.001} "read fpack $cmpmode $bitpix (SIGMA = $SIGMA)" 69 92 70 if ($cmpmode == RICE_1_0)71 echo "*** funpack fails on RICE_1 ****"72 return73 end93 # if ($cmpmode == RICE_1_0) 94 # echo "*** funpack fails on RICE_1 ****" 95 # return 96 # end 74 97 75 98 # echo "run funpack on our version" 76 exec funpack-S test.cmp.fits > test.fun.fits99 exec $FUNPACK -S test.cmp.fits > test.fun.fits 77 100 rd e test.fun.fits 78 101 set d = x - e … … 213 236 if (1) 214 237 tapEXEC /bin/cp -f test.raw.tbl test.fpk.tbl 215 tapEXEC fpack-table -F test.fpk.tbl238 tapEXEC $FPACK -table -F test.fpk.tbl 216 239 217 240 data test.fpk.tbl … … 236 259 # try to run fpack on ours 237 260 tapEXEC /bin/cp -f test.cmp.tbl test.fun.tbl 238 tapEXEC funpack-F test.fun.tbl261 tapEXEC $FUNPACK -F test.fun.tbl 239 262 240 263 data test.fun.tbl … … 403 426 if (1) 404 427 tapEXEC /bin/cp -f test.raw.tbl test.fpk.tbl 405 tapEXEC fpack-table -F test.fpk.tbl428 tapEXEC $FPACK -table -F test.fpk.tbl 406 429 407 430 data test.fpk.tbl … … 431 454 # try to run fpack on ours 432 455 tapEXEC /bin/cp -f test.cmp.tbl test.fun.tbl 433 tapEXEC funpack-F test.fun.tbl456 tapEXEC $FUNPACK -F test.fun.tbl 434 457 435 458 data test.fun.tbl -
trunk/Ohana/src/libfits/test/imagecomp.c
r39457 r41474 3 3 # include "tap_ohana.h" 4 4 5 # define MEM_VERBOSE FALSE 6 5 7 int test_compress (int bitpix, char *zcmptype); 6 8 int test_compress_fullrange (int bitpix, char *zcmptype); 7 9 int test_compress_fulltile (int bitpix, char *zcmptype); 8 10 9 // char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL};11 // XXX FULL SET : char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL}; 10 12 char *cmptype[] = {"NONE", "NONE_1", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", NULL}; 13 // XXX NOT WORKING: char *cmptype[] = {"HCOMPRESS_1", NULL}; 11 14 int bitpix[] = {8, 16, 32, -32, -64, 0}; 12 15 … … 31 34 test_compress_fulltile (bitpix[j], cmptype[i]); 32 35 test_compress_fullrange (bitpix[j], cmptype[i]); 33 ok (ohana_memcheck ( TRUE), "no memory corruption");36 ok (ohana_memcheck (MEM_VERBOSE), "no memory corruption"); 34 37 } 35 38 } … … 43 46 test_compress_fulltile (bitpix[j], cmptype[i]); 44 47 test_compress_fullrange (bitpix[j], cmptype[i]); 45 ok (ohana_memcheck ( TRUE), "no memory corruption");48 ok (ohana_memcheck (MEM_VERBOSE), "no memory corruption"); 46 49 } 47 50 } … … 55 58 test_compress_fulltile (bitpix[j], cmptype[i]); 56 59 test_compress_fullrange (bitpix[j], cmptype[i]); 57 ok (ohana_memcheck ( TRUE), "no memory corruption");60 ok (ohana_memcheck (MEM_VERBOSE), "no memory corruption"); 58 61 } 59 62 } … … 138 141 } 139 142 143 // diag ("--- Image has a total of %d pixels of which %d are bad ---", NX*NY, Nbad); 140 144 ok (!Nbad, "all image pixels match"); 141 145
Note:
See TracChangeset
for help on using the changeset viewer.
