Changeset 38366
- Timestamp:
- Jun 4, 2015, 5:42:47 PM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libfits
- Files:
-
- 1 added
- 13 edited
-
include/gfitsio.h (modified) (3 diffs)
-
matrix/F_compress_M.c (modified) (3 diffs)
-
matrix/F_compress_data.c (modified) (3 diffs)
-
matrix/F_compress_utils.c (modified) (4 diffs)
-
matrix/F_uncompress_M.c (modified) (4 diffs)
-
matrix/F_uncompress_data.c (modified) (3 diffs)
-
table/F_compress_T.c (modified) (8 diffs)
-
table/F_get_column.c (modified) (8 diffs)
-
table/F_set_column.c (modified) (36 diffs)
-
table/F_uncompress_T.c (modified) (6 diffs)
-
test/compress.sh (modified) (9 diffs)
-
test/imagecomp.c (modified) (2 diffs)
-
test/tablecomp.c (modified) (11 diffs)
-
test/tap.dvo (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h
r38356 r38366 191 191 192 192 int gfits_uncompress_image PROTO((Header *header, Matrix *matrix, FTable *ftable)); 193 int gfits_uncompress_data PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize));193 int gfits_uncompress_data PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize)); 194 194 int gfits_distribute_data PROTO((Matrix *matrix, char *data, int Ndata, int bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero)); 195 195 … … 244 244 int gfits_fwrite_ftable_range PROTO((FILE *f, FTable *table, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal)); 245 245 int gfits_get_bintable_column PROTO((Header *header, FTable *table, char *label, void **data)); 246 int gfits_get_bintable_column_raw PROTO((Header *header, FTable *table, char *label, void **data, char nativeOrder)); 246 247 int gfits_get_bintable_column_type PROTO((Header *header, char *label, char *type, int *Nval)); 248 void *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol)); 247 249 int gfits_get_bintable_column_type_by_N PROTO((Header *header, int N, char *type, int *Nval)); 248 void *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol));250 void *gfits_get_bintable_column_data_raw PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder)); 249 251 int gfits_get_table_column PROTO((Header *header, FTable *table, char *label, void **data)); 250 252 int gfits_get_table_column_type PROTO((Header *header, char *label, char *type)); … … 252 254 int gfits_read_table PROTO((char *filename, FTable *ftable)); 253 255 int gfits_set_bintable_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 254 int gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow ));256 int gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder)); 255 257 int gfits_set_table_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 256 258 int gfits_table_column PROTO((FTable *ftable, char *field, char *mode,...)) OHANA_FORMAT(printf, 3, 4); -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c
r38363 r38366 165 165 166 166 // define compression-specific keywords, update header as needed. 167 if (!strcasecmp(zcmptype, "RICE_1") ) {167 if (!strcasecmp(zcmptype, "RICE_1") || !strcasecmp(zcmptype, "RICE_ONE")) { 168 168 if (!gfits_modify (theader, "ZNAME1", "%s", 1, "BLOCKSIZE")) ESCAPE; 169 169 if (!gfits_modify (theader, "ZVAL1", "%d", 1, 32)) ESCAPE; … … 195 195 // copy the raw pixels from their native matrix locations to the temporary output buffer 196 196 // for float -> int scaling by zscale, zzero may be applied 197 if (!strcasecmp (zcmptype, "GZIP_2") ) {197 if (!strcasecmp (zcmptype, "GZIP_2") || !strcasecmp (zcmptype, "NONE_2")) { 198 198 if (!gfits_collect_gzp2 (matrix, raw, Nraw, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE; 199 199 } else { … … 240 240 // compression modes require swapping after compression (compresssion & decompression 241 241 // operate on native ENDIAN) 242 if (strcasecmp(zcmptype, "GZIP_1") && strcasecmp(zcmptype, "GZIP_2") && strcasecmp(zcmptype, "RICE_1")) { 242 if (strcasecmp(zcmptype, "NONE") && 243 strcasecmp(zcmptype, "NONE_2") && 244 strcasecmp(zcmptype, "GZIP_1") && 245 strcasecmp(zcmptype, "GZIP_2") && 246 strcasecmp(zcmptype, "RICE_1") && 247 strcasecmp(zcmptype, "RICE_ONE")) { 243 248 // Nzdata is number of bytes 244 249 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c
r38362 r38366 42 42 43 43 // do not actually compress : this is used for testing 44 if (!strcasecmp(cmptype, "NONE") ) {44 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_2")) { 45 45 unsigned long Nbytes = Nrawpix * rawpix_size; 46 46 … … 85 85 // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum); 86 86 87 char buffer[1000];88 87 int k; 89 88 … … 101 100 fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nout, Nrawpix); 102 101 fprintf (stderr, "cmp inp: "); 103 for (k = 0; k < Nout; k++) { fprintf (stderr, " 0x%02hhx ", zdata[k]); }102 for (k = 0; k < Nout; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 2) fprintf (stderr, " "); } 104 103 fprintf (stderr, "\n"); 105 104 } 106 107 status = fits_rdecomp_short ((unsigned char *) zdata, Nout, (unsigned short *) buffer, Nrawpix, blocksize);108 myAssert (!status, "failed to rdecomp");109 105 break; 110 106 -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c
r38356 r38366 174 174 175 175 if (!strcasecmp(cmptype, "NONE")) return TRUE; 176 if (!strcasecmp(cmptype, "NONE_2")) return TRUE; // do not compress, but shuffle a la GZIP_2 176 177 if (!strcasecmp(cmptype, "GZIP_1")) return TRUE; 177 178 if (!strcasecmp(cmptype, "GZIP_2")) return TRUE; … … 190 191 if (!strcasecmp(cmptype, "GZIP_1") || 191 192 !strcasecmp(cmptype, "GZIP_2") || 193 !strcasecmp(cmptype, "NONE_2") || 192 194 !strcasecmp(cmptype, "NONE")) { 193 195 if (out_bitpix == 8) return (1); … … 235 237 if (!strcasecmp(cmptype, "GZIP_1") || 236 238 !strcasecmp(cmptype, "GZIP_2") || 239 !strcasecmp(cmptype, "NONE_2") || 237 240 !strcasecmp(cmptype, "NONE")) { 238 241 if (out_bitpix == 8) return (1); … … 280 283 if (!strcasecmp(cmptype, "GZIP_1") || 281 284 !strcasecmp(cmptype, "GZIP_2") || 285 !strcasecmp(cmptype, "NONE_2") || 282 286 !strcasecmp(cmptype, "NONE")) { 283 287 return (out_bitpix); -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c
r38363 r38366 271 271 272 272 // expected output size for this tile 273 // Nout = gfits_tile_size (matrix, otile, ztile); 274 Nout = Nout_alloc; 273 Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile); 275 274 276 275 zdata = gfits_varlength_column_pointer (ftable, &zdef, row, &Nzdata); … … 284 283 } 285 284 286 if (strcasecmp(cmptype, "GZIP_1") && strcasecmp(cmptype, "GZIP_2") && strcasecmp(cmptype, "RICE_1")) { 285 if (strcasecmp(cmptype, "NONE") && 286 strcasecmp(cmptype, "NONE_2") && 287 strcasecmp(cmptype, "GZIP_1") && 288 strcasecmp(cmptype, "GZIP_2") && 289 strcasecmp(cmptype, "RICE_1") && 290 strcasecmp(cmptype, "RICE_ONE")) { 287 291 // Nzdata is number of bytes 288 292 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; … … 300 304 // XXX the tile must not be > 2GB 301 305 // Nout going in is number of bytes 302 if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, raw_pixsize)) ESCAPE;306 if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, Nout_alloc, raw_pixsize)) ESCAPE; 303 307 304 308 if (VERBOSE_DUMP && (row == 0)) { … … 323 327 324 328 // copy the uncompressed pixels into their correct locations 325 if (!strcasecmp(cmptype, "GZIP_2") ) {329 if (!strcasecmp(cmptype, "GZIP_2") || !strcasecmp(cmptype, "NONE_2")) { 326 330 if (!gfits_distribute_gzp2 (matrix, out, Nout, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE; 327 331 } else { -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c
r38362 r38366 28 28 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); } 29 29 30 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize) {30 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize) { 31 31 32 32 int status; 33 33 34 34 // do not actually uncompress : this is used for testing 35 if (!strcasecmp(cmptype, "NONE") ) {35 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_2")) { 36 36 memcpy (outdata, zdata, Nzdata); 37 myAssert (*Nout == Nzdata, "invalid size"); 37 38 *Nout = Nzdata / out_pixsize; 38 39 return (TRUE); … … 42 43 // unsigned long tNout = *Nout * out_pixsize; 43 44 // input value of *Nout is number of BYTES 44 unsigned long tNout = *Nout;45 unsigned long tNout = Nout_alloc; 45 46 46 47 // for GZIP data, I need to check for and remove the header on the first block: … … 52 53 status = gfits_uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata); 53 54 if (status != Z_OK) ESCAPE(FALSE); 55 myAssert (*Nout == tNout, "uncompressed size mismatch"); 54 56 *Nout = tNout / out_pixsize; 55 57 // output value of *Nout is number of PIXELS -
branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
r38363 r38366 2 2 # include <gfitsio.h> 3 3 # include <zlib.h> 4 # define VERBOSE_DUMP 0 4 5 5 6 // the user needs to specify the various compression options: … … 36 37 37 38 int Ntile, ztilelast; 39 if (!ztilelen) ztilelen = srcheader->Naxis[1]; 40 38 41 if (srcheader->Naxis[1] % ztilelen) { 39 42 Ntile = srcheader->Naxis[1] / ztilelen + 1; … … 75 78 if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tformat_cmt)) ESCAPE; 76 79 77 // XXX this should depend on the field type, but for now just use a single type (GZIP_1)80 // for now we set all fields to the requested type 78 81 strcpy (fields[i].zctype, zcmptype); 79 82 … … 125 128 max_width = MAX(max_width, fields[i].rowsize); 126 129 130 // RICE can only be used on integer fields 131 if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) { 132 if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double")) { 133 strcpy (fields[i].zctype, "GZIP_2"); 134 } 135 } 136 127 137 // compression type per column (XXX for now we are just using zcmptype, as set above) 128 138 snprintf (keyword, 81, "ZCTYP%d", i+1); … … 152 162 153 163 // copy the raw pixels from their native matrix locations to the temporary output buffer 154 if (!strcasecmp(fields[ i].zctype, "GZIP_2")) {164 if (!strcasecmp(fields[j].zctype, "GZIP_2") || !strcasecmp(fields[j].zctype, "NONE_2")) { 155 165 if (!gfits_collect_table_gzp2 (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE; 156 166 } else { … … 158 168 } 159 169 170 if (VERBOSE_DUMP) { 171 int k; 172 fprintf (stderr, "c1: "); 173 for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) { 174 fprintf (stderr, "%02hhx", raw[k]); 175 if (k % 2) fprintf (stderr, " "); 176 // if (k % 32 == 31) fprintf (stderr, "\n"); 177 } 178 fprintf (stderr, "\n"); 179 } 180 160 181 // optname, optvalue = NULL, Noptions = 0 161 182 162 183 int Nraw = Nrows*fields[j].Nvalues; // number of pixels 163 if (!strc mp(fields[j].zctype, "GZIP_1")) {184 if (!strcasecmp(fields[j].zctype, "GZIP_1")) { 164 185 if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE; 186 } 187 188 if (VERBOSE_DUMP) { 189 int k; 190 fprintf (stderr, "c2: "); 191 for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) { 192 fprintf (stderr, "%02hhx", raw[k]); 193 if (k % 2) fprintf (stderr, " "); 194 // if (k % 32 == 31) fprintf (stderr, "\n"); 195 } 196 fprintf (stderr, "\n"); 165 197 } 166 198 … … 168 200 if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize, 0, 0)) ESCAPE; 169 201 170 if (strcasecmp(fields[j].zctype, "GZIP_1") && strcasecmp(fields[j].zctype, "GZIP_2") && strcasecmp(fields[j].zctype, "RICE_1")) { 202 if (VERBOSE_DUMP) { 203 int k; 204 fprintf (stderr, "c3: "); 205 for (k = 0; k < Nzdata; k++) { 206 fprintf (stderr, "%02hhx", zdata[k]); 207 if (k % 2) fprintf (stderr, " "); 208 // if (k % 32 == 31) fprintf (stderr, "\n"); 209 } 210 fprintf (stderr, "\n"); 211 } 212 213 if (strcasecmp(fields[j].zctype, "NONE") && 214 strcasecmp(fields[j].zctype, "NONE_2") && 215 strcasecmp(fields[j].zctype, "GZIP_1") && 216 strcasecmp(fields[j].zctype, "GZIP_2") && 217 strcasecmp(fields[j].zctype, "RICE_1") && 218 strcasecmp(fields[j].zctype, "RICE_ONE")) { 171 219 if (!gfits_byteswap_zdata (zdata, Nzdata, fields[j].pixsize)) ESCAPE; 220 } 221 222 if (VERBOSE_DUMP) { 223 int k; 224 fprintf (stderr, "c4: "); 225 for (k = 0; k < Nzdata; k++) { 226 fprintf (stderr, "%02hhx", zdata[k]); 227 if (k % 2) fprintf (stderr, " "); 228 // if (k % 32 == 31) fprintf (stderr, "\n"); 229 } 230 fprintf (stderr, "\n"); 172 231 } 173 232 … … 228 287 for (i = 0; i < Nrows; i++) { 229 288 int row = row_start + i; 230 char *tgt = &raw[i*field->rowsize + k*Nrows*field->Nvalues]; 231 char *src = &table->buffer[Nx*row + field->offset + k]; 232 for (j = 0; j < field->Nvalues; j++, tgt+=field->pixsize, src++) { 233 *tgt = *src; 234 myAssert (src - raw < field-> 289 char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues]; 290 # ifdef BYTE_SWAP 291 char *tblptr = &table->buffer[Nx*row + field->offset + (field->pixsize - k - 1)]; 292 # else 293 char *tblptr = &table->buffer[Nx*row + field->offset + k]; 294 # endif 295 for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) { 296 *rawptr = *tblptr; 297 myAssert (rawptr - raw < Nrows*field->Nvalues*field->pixsize, "oops"); 298 myAssert (tblptr - table->buffer < table->header->Naxis[0]*table->header->Naxis[1], "oops"); 235 299 } 236 300 } -
branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c
r38325 r38366 17 17 18 18 void *gfits_get_bintable_column_data (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol) { 19 void *data = gfits_get_bintable_column_data_raw (header, table, label, type, Nrow, Ncol, FALSE); 20 return data; 21 } 22 23 void *gfits_get_bintable_column_data_raw (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder) { 19 24 20 25 off_t Nx, Ny; … … 87 92 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 88 93 # ifdef BYTE_SWAP 89 SWAP_BYTE;94 if (!nativeOrder) { SWAP_BYTE; } 90 95 # endif 91 96 *(short *)Pout = *(short *)Pin*Bscale + Bzero; … … 95 100 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 96 101 # ifdef BYTE_SWAP 97 SWAP_WORD;102 if (!nativeOrder) { SWAP_WORD; } 98 103 # endif 99 104 *(int *)Pout = *(int *)Pin*Bscale + Bzero; … … 104 109 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 105 110 # ifdef BYTE_SWAP 106 SWAP_DBLE;111 if (!nativeOrder) { SWAP_DBLE; } 107 112 # endif 108 113 *(int64_t *)Pout = *(int64_t *)Pin; … … 111 116 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 112 117 # ifdef BYTE_SWAP 113 SWAP_DBLE;118 if (!nativeOrder) { SWAP_DBLE; } 114 119 # endif 115 120 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; … … 120 125 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 121 126 # ifdef BYTE_SWAP 122 SWAP_WORD;127 if (!nativeOrder) { SWAP_WORD; } 123 128 # endif 124 129 *(float *)Pout = *(float *)Pin*Bscale + Bzero; … … 128 133 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 129 134 # ifdef BYTE_SWAP 130 SWAP_DBLE;135 if (!nativeOrder) { SWAP_DBLE; } 131 136 # endif 132 137 *(double *)Pout = *(double *)Pin*Bscale + Bzero; … … 176 181 if (!gfits_get_bintable_column_type_by_N (header, N, type, Nval)) return FALSE; 177 182 return (TRUE); 183 } 184 185 /***********************/ 186 int gfits_get_bintable_column_raw (Header *header, FTable *table, char *label, void **data, char nativeOrder) { 187 188 char type[16]; 189 off_t Nrow; 190 int Ncol; 191 192 char *array = gfits_get_bintable_column_data_raw (header, table, label, type, &Nrow, &Ncol, nativeOrder); 193 if (array == NULL) return (FALSE); 194 195 *data = array; 196 return TRUE; 178 197 } 179 198 -
branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c
r38329 r38366 175 175 176 176 /***********************/ 177 int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow) { 177 // convert the input data array (of the specified intype) to the desired table data type. swap unless nativeOrder is requested 178 int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder) { 178 179 179 180 off_t Nx, Ny; … … 256 257 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 257 258 # ifdef BYTE_SWAP 258 SWAP_BYTE;259 if (!nativeOrder) { SWAP_BYTE; } 259 260 # endif 260 261 } … … 265 266 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 266 267 # ifdef BYTE_SWAP 267 SWAP_WORD;268 if (!nativeOrder) { SWAP_WORD; } 268 269 # endif 269 270 } … … 274 275 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 275 276 # ifdef BYTE_SWAP 276 SWAP_DBLE;277 if (!nativeOrder) { SWAP_DBLE; } 277 278 # endif 278 279 } … … 283 284 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 284 285 # ifdef BYTE_SWAP 285 SWAP_WORD;286 if (!nativeOrder) { SWAP_WORD; } 286 287 # endif 287 288 } … … 292 293 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 293 294 # ifdef BYTE_SWAP 294 SWAP_DBLE;295 if (!nativeOrder) { SWAP_DBLE; } 295 296 # endif 296 297 } … … 315 316 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 316 317 # ifdef BYTE_SWAP 317 SWAP_BYTE;318 if (!nativeOrder) { SWAP_BYTE; } 318 319 # endif 319 320 } … … 324 325 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 325 326 # ifdef BYTE_SWAP 326 SWAP_WORD;327 if (!nativeOrder) { SWAP_WORD; } 327 328 # endif 328 329 } … … 333 334 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 334 335 # ifdef BYTE_SWAP 335 SWAP_DBLE;336 if (!nativeOrder) { SWAP_DBLE; } 336 337 # endif 337 338 } … … 342 343 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 343 344 # ifdef BYTE_SWAP 344 SWAP_WORD;345 if (!nativeOrder) { SWAP_WORD; } 345 346 # endif 346 347 } … … 351 352 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 352 353 # ifdef BYTE_SWAP 353 SWAP_DBLE;354 if (!nativeOrder) { SWAP_DBLE; } 354 355 # endif 355 356 } … … 374 375 *(short *)Pout = (*(short *)Pin - Bzero) / Bscale; 375 376 # ifdef BYTE_SWAP 376 SWAP_BYTE;377 if (!nativeOrder) { SWAP_BYTE; } 377 378 # endif 378 379 } … … 383 384 *(int *)Pout = (*(short *)Pin - Bzero) / Bscale; 384 385 # ifdef BYTE_SWAP 385 SWAP_WORD;386 if (!nativeOrder) { SWAP_WORD; } 386 387 # endif 387 388 } … … 392 393 *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale; 393 394 # ifdef BYTE_SWAP 394 SWAP_DBLE;395 if (!nativeOrder) { SWAP_DBLE; } 395 396 # endif 396 397 } … … 401 402 *(float *)Pout = (*(short *)Pin - Bzero) / Bscale; 402 403 # ifdef BYTE_SWAP 403 SWAP_WORD;404 if (!nativeOrder) { SWAP_WORD; } 404 405 # endif 405 406 } … … 410 411 *(double *)Pout = (*(short *)Pin - Bzero) / Bscale; 411 412 # ifdef BYTE_SWAP 412 SWAP_DBLE;413 if (!nativeOrder) { SWAP_DBLE; } 413 414 # endif 414 415 } … … 433 434 *(short *)Pout = (*(int *)Pin - Bzero) / Bscale; 434 435 # ifdef BYTE_SWAP 435 SWAP_BYTE;436 if (!nativeOrder) { SWAP_BYTE; } 436 437 # endif 437 438 } … … 442 443 *(int *)Pout = (*(int *)Pin - Bzero) / Bscale; 443 444 # ifdef BYTE_SWAP 444 SWAP_WORD;445 if (!nativeOrder) { SWAP_WORD; } 445 446 # endif 446 447 } … … 451 452 *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale; 452 453 # ifdef BYTE_SWAP 453 SWAP_DBLE;454 if (!nativeOrder) { SWAP_DBLE; } 454 455 # endif 455 456 } … … 460 461 *(float *)Pout = (*(int *)Pin - Bzero) / Bscale; 461 462 # ifdef BYTE_SWAP 462 SWAP_WORD;463 if (!nativeOrder) { SWAP_WORD; } 463 464 # endif 464 465 } … … 469 470 *(double *)Pout = (*(int *)Pin - Bzero) / Bscale; 470 471 # ifdef BYTE_SWAP 471 SWAP_DBLE;472 if (!nativeOrder) { SWAP_DBLE; } 472 473 # endif 473 474 } … … 492 493 *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 493 494 # ifdef BYTE_SWAP 494 SWAP_BYTE;495 if (!nativeOrder) { SWAP_BYTE; } 495 496 # endif 496 497 } … … 501 502 *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 502 503 # ifdef BYTE_SWAP 503 SWAP_WORD;504 if (!nativeOrder) { SWAP_WORD; } 504 505 # endif 505 506 } … … 510 511 *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 511 512 # ifdef BYTE_SWAP 512 SWAP_DBLE;513 if (!nativeOrder) { SWAP_DBLE; } 513 514 # endif 514 515 } … … 519 520 *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 520 521 # ifdef BYTE_SWAP 521 SWAP_WORD;522 if (!nativeOrder) { SWAP_WORD; } 522 523 # endif 523 524 } … … 528 529 *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 529 530 # ifdef BYTE_SWAP 530 SWAP_DBLE;531 if (!nativeOrder) { SWAP_DBLE; } 531 532 # endif 532 533 } … … 551 552 *(short *)Pout = (*(float *)Pin - Bzero) / Bscale; 552 553 # ifdef BYTE_SWAP 553 SWAP_BYTE;554 if (!nativeOrder) { SWAP_BYTE; } 554 555 # endif 555 556 } … … 560 561 *(int *)Pout = (*(float *)Pin - Bzero) / Bscale; 561 562 # ifdef BYTE_SWAP 562 SWAP_WORD;563 if (!nativeOrder) { SWAP_WORD; } 563 564 # endif 564 565 } … … 569 570 *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale; 570 571 # ifdef BYTE_SWAP 571 SWAP_DBLE;572 if (!nativeOrder) { SWAP_DBLE; } 572 573 # endif 573 574 } … … 578 579 *(float *)Pout = (*(float *)Pin - Bzero) / Bscale; 579 580 # ifdef BYTE_SWAP 580 SWAP_WORD;581 if (!nativeOrder) { SWAP_WORD; } 581 582 # endif 582 583 } … … 587 588 *(double *)Pout = (*(float *)Pin - Bzero) / Bscale; 588 589 # ifdef BYTE_SWAP 589 SWAP_DBLE;590 if (!nativeOrder) { SWAP_DBLE; } 590 591 # endif 591 592 } … … 610 611 *(short *)Pout = (*(double *)Pin - Bzero) / Bscale; 611 612 # ifdef BYTE_SWAP 612 SWAP_BYTE;613 if (!nativeOrder) { SWAP_BYTE; } 613 614 # endif 614 615 } … … 619 620 *(int *)Pout = (*(double *)Pin - Bzero) / Bscale; 620 621 # ifdef BYTE_SWAP 621 SWAP_WORD;622 if (!nativeOrder) { SWAP_WORD; } 622 623 # endif 623 624 } … … 628 629 *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale; 629 630 # ifdef BYTE_SWAP 630 SWAP_DBLE;631 if (!nativeOrder) { SWAP_DBLE; } 631 632 # endif 632 633 } … … 637 638 *(float *)Pout = (*(double *)Pin - Bzero) / Bscale; 638 639 # ifdef BYTE_SWAP 639 SWAP_WORD;640 if (!nativeOrder) { SWAP_WORD; } 640 641 # endif 641 642 } … … 646 647 *(double *)Pout = (*(double *)Pin - Bzero) / Bscale; 647 648 # ifdef BYTE_SWAP 648 SWAP_DBLE;649 if (!nativeOrder) { SWAP_DBLE; } 649 650 # endif 650 651 } -
branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c
r38363 r38366 13 13 # if (VERBOSE_DUMP) 14 14 int i; 15 fprintf (stderr, "%s data: ", message); 16 // for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) { 17 for (i = 0; i < 16; i++) { 18 fprintf (stderr, "0x%02hhx ", table->buffer[i]); 15 fprintf (stderr, "%s data:\n", message); 16 for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) { 17 // for (i = 0; i < 16; i++) { 18 fprintf (stderr, "%02hhx", table->buffer[i]); 19 if (i % 2) fprintf (stderr, " "); 20 if (i % 32 == 31) fprintf (stderr, "\n"); 19 21 } 20 22 fprintf (stderr, "\n"); … … 26 28 # if (VERBOSE_DUMP) 27 29 int i; 28 fprintf (stderr, "%s pntr: ", message); 29 for (i = 0; (i < 16) && (i < table->header->Naxis[0]*table->header->Naxis[1]); i++) { 30 fprintf (stderr, "0x%02hhx ", table->buffer[i]); 30 fprintf (stderr, "%s pntr:\n", message); 31 for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) { 32 fprintf (stderr, "%02hhx", table->buffer[i]); 33 if (i % 2) fprintf (stderr, " "); 34 if (i % 32 == 31) fprintf (stderr, "\n"); 31 35 } 32 36 fprintf (stderr, "\n"); 33 37 34 fprintf (stderr, "%s data: ", message); 35 for (i = 0; (i < 16) && (i < table->header->pcount); i++) { 36 fprintf (stderr, "0x%02hhx ", table->buffer[table->heap_start + i]); 38 fprintf (stderr, "%s data:\n", message); 39 for (i = 0; i < table->header->pcount; i++) { 40 fprintf (stderr, "%02hhx", table->buffer[table->heap_start + i]); 41 if (i % 2) fprintf (stderr, " "); 42 if (i % 32 == 31) fprintf (stderr, "\n"); 37 43 } 38 44 fprintf (stderr, "\n"); … … 156 162 if (!zdata) ESCAPE; 157 163 158 if (strcasecmp(fields[i].zctype, "GZIP_1") && strcasecmp(fields[i].zctype, "GZIP_2") && strcasecmp(fields[i].zctype, "RICE_1")) { 164 if (VERBOSE_DUMP) { 165 int k; 166 fprintf (stderr, "u4: "); 167 for (k = 0; k < Nzdata; k++) { 168 fprintf (stderr, "%02hhx", zdata[k]); 169 if (k % 2) fprintf (stderr, " "); 170 // if (k % 32 == 31) fprintf (stderr, "\n"); 171 } 172 fprintf (stderr, "\n"); 173 } 174 175 if (strcasecmp(fields[i].zctype, "NONE") && 176 strcasecmp(fields[i].zctype, "NONE_2") && 177 strcasecmp(fields[i].zctype, "GZIP_1") && 178 strcasecmp(fields[i].zctype, "GZIP_2") && 179 strcasecmp(fields[i].zctype, "RICE_1") && 180 strcasecmp(fields[i].zctype, "RICE_ONE")) { 159 181 // Nzdata is number of bytes 160 182 if (!gfits_byteswap_zdata (zdata, Nzdata, fields[i].pixsize)) ESCAPE; 161 183 } 162 184 185 if (VERBOSE_DUMP) { 186 int k; 187 fprintf (stderr, "u3: "); 188 for (k = 0; k < Nzdata; k++) { 189 fprintf (stderr, "%02hhx", zdata[k]); 190 if (k % 2) fprintf (stderr, " "); 191 // if (k % 32 == 31) fprintf (stderr, "\n"); 192 } 193 fprintf (stderr, "\n"); 194 } 195 163 196 int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen; 164 int Nraw = Nraw_alloc; // expected number of pixel: Nrows*fields[i].Nvalues 165 if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, fields[i].pixsize)) ESCAPE; 197 int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes 198 if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, Nraw_alloc, fields[i].pixsize)) ESCAPE; 199 200 if (VERBOSE_DUMP) { 201 int k; 202 fprintf (stderr, "u2: "); 203 for (k = 0; k < Nraw*fields[i].pixsize; k++) { 204 fprintf (stderr, "%02hhx", raw[k]); 205 if (k % 2) fprintf (stderr, " "); 206 // if (k % 32 == 31) fprintf (stderr, "\n"); 207 } 208 fprintf (stderr, "\n"); 209 } 166 210 167 211 if (!strcasecmp(fields[i].zctype, "GZIP_1")) { … … 170 214 } 171 215 216 if (VERBOSE_DUMP) { 217 int k; 218 fprintf (stderr, "u1: "); 219 for (k = 0; k < Nraw*fields[i].pixsize; k++) { 220 fprintf (stderr, "%02hhx", raw[k]); 221 if (k % 2) fprintf (stderr, " "); 222 // if (k % 32 == 31) fprintf (stderr, "\n"); 223 } 224 fprintf (stderr, "\n"); 225 } 226 172 227 // int valid = (row == 0) && (i == 0); 173 228 … … 177 232 178 233 // copy the raw pixels from their native matrix locations to the temporary output buffer 179 if (!strcasecmp(fields[i].zctype, "GZIP_2") ) {234 if (!strcasecmp(fields[i].zctype, "GZIP_2") || !strcasecmp(fields[i].zctype, "NONE_2")) { 180 235 if (!gfits_distribute_table_gzp2 (tgttable, &fields[i], raw, row_start, Nrows)) ESCAPE; 181 236 } else { … … 233 288 for (i = 0; i < Nrows; i++) { 234 289 int row = row_start + i; 235 char *src = &raw[i*field->rowsize + k*Nrows*field->Nvalues]; 236 char *tgt = &table->buffer[Nx*row + field->offset + k]; 237 for (j = 0; j < field->Nvalues; j++, tgt+=field->pixsize, src++) { 238 *tgt = *src; 290 char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues]; 291 # ifdef BYTE_SWAP 292 char *tblptr = &table->buffer[Nx*row + field->offset + (field->pixsize - k - 1)]; 293 # else 294 char *tblptr = &table->buffer[Nx*row + field->offset + k]; 295 # endif 296 for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) { 297 *tblptr = *rawptr; 239 298 } 240 299 } -
branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
r38363 r38366 5 5 tapPLAN 88 6 6 7 foreach mode NONE GZIP_1 GZIP_2 RICE_1 7 foreach mode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 8 8 # foreach mode GZIP_1 9 9 # foreach mode GZIP_2 … … 11 11 foreach bitpix 8 16 32 -32 -64 12 12 # foreach bitpix 32 13 if (($mode == RICE_1) && ($bitpix < 0)) continue ; # RICE_1 is for int only 13 if (($mode == RICE_1) && ($bitpix < 0)) continue ; # RICE_1 is for int only 14 if (($mode == RICE_ONE) && ($bitpix < 0)) continue ; # RICE_1 is for int only 14 15 tapDIAG 2 "===== bitpix = $bitpix, mode = $mode =====" 15 16 test_image_single $bitpix $mode … … 29 30 $bitpix = $1 30 31 $cmpmode = $2 32 33 delete -q x z b c d e 31 34 32 35 mcreate z 8 8 … … 121 124 macro test_table_all_single_column 122 125 126 tapPLAN 88 127 123 128 local format cmpmode 124 129 125 foreach cmpmode NONE GZIP_1 130 foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 126 131 foreach format B I J K E D 132 if (($cmpmode == RICE_1) && ($format == E)) continue ; # RICE_1 is for int only 133 if (($cmpmode == RICE_ONE) && ($format == E)) continue ; # RICE_1 is for int only 134 if (($cmpmode == RICE_1) && ($format == D)) continue ; # RICE_1 is for int only 135 if (($cmpmode == RICE_ONE) && ($format == D)) continue ; # RICE_1 is for int only 136 if (($cmpmode == RICE_1) && ($format == K)) continue ; # RICE_1 is for int only 137 if (($cmpmode == RICE_ONE) && ($format == K)) continue ; # RICE_1 is for int only 127 138 test_table_single_column $cmpmode $format 128 139 end 129 140 end 141 tapDONE 130 142 end 131 143 … … 136 148 end 137 149 138 local cmpmode 150 local cmpmode format 139 151 $cmpmode = $1 140 141 delete -q x 142 143 $NPT = 1000 144 create x 0 $NPT 145 146 local format 152 $format = $2 153 154 tapDIAG 2 "===== testing $cmpmode $format =====" 155 156 delete -q x dv 157 158 $NPT = 10000 159 160 if ($format == B) 161 create x -128 128 162 else 163 create x 0 $NPT 164 end 147 165 148 166 $fields = x 149 $format = $2150 167 151 168 write -fits test test.raw.tbl $fields -format $format … … 157 174 end 158 175 159 echo"===== $cmpmode $format raw ====="176 tapDIAG 2 "===== $cmpmode $format raw =====" 160 177 data test.raw.tbl 161 178 read -fits test $fields … … 163 180 foreach f $fields 164 181 set dv = $f - $f\_raw 165 vstat dv 166 end 167 delete -q $fields 168 169 echo "===== $cmpmode $format cmp =====" 182 vstat -q dv 183 tapOK {abs($MEAN) < 0.001} "read our raw $cmpmode $format (MEAN = $MEAN)" 184 tapOK {$SIGMA < 0.001} "read our raw $cmpmode $format (SIGMA = $SIGMA)" 185 end 186 delete -q $fields 187 188 tapDIAG 2 "===== $cmpmode $format cmp =====" 170 189 data test.cmp.tbl 171 190 read -fits test $fields … … 173 192 foreach f $fields 174 193 set dv = $f - $f\_raw 175 vstat dv 176 end 194 vstat -q dv 195 tapOK {abs($MEAN) < 0.001} "read our cmp $cmpmode $format (MEAN = $MEAN)" 196 tapOK {$SIGMA < 0.001} "read our cmp $cmpmode $format (SIGMA = $SIGMA)" 197 end 198 199 if ($cmpmode == NONE) return; # funpack will not recognize NONE 200 if ($cmpmode == RICE_ONE) return; # funpack will not recognize RICE_ONE for tables 201 if (($cmpmode == GZIP_2) && ($format == B)) return; # GZIP_2 invalid for B 202 203 tapDIAG 2 "===== $cmpmode $format fpack =====" 204 205 # try to run fpack on ours 206 if (1) 207 tapEXEC /bin/cp -f test.raw.tbl test.fpk.tbl 208 tapEXEC fpack -table -F test.fpk.tbl 209 210 data test.fpk.tbl 211 read -fits test $fields 212 213 foreach f $fields 214 set dv = $f - $f\_raw 215 vstat -q dv 216 tapOK {abs($MEAN) < 0.001} "read fpack $cmpmode $format (MEAN = $MEAN)" 217 tapOK {$SIGMA < 0.001} "read fpack $cmpmode $format (SIGMA = $SIGMA)" 218 end 219 delete -q $fields 220 end 221 222 break -auto off 223 echo $cmpmode $format 224 exec ls test.cmp.tbl test.fpk.tbl | fields -x 0 PCOUNT ZCTYP1 225 break -auto on 226 227 tapDIAG 2 "===== $cmpmode $format funpack =====" 228 229 # try to run fpack on ours 230 tapEXEC /bin/cp -f test.cmp.tbl test.fun.tbl 231 tapEXEC funpack -F test.fun.tbl 232 233 data test.fun.tbl 234 read -fits test $fields 235 236 foreach f $fields 237 set dv = $f - $f\_raw 238 vstat -q dv 239 tapOK {abs($MEAN) < 0.001} "read funpack $cmpmode $format (MEAN = $MEAN)" 240 tapOK {$SIGMA < 0.001} "read funpack $cmpmode $format (SIGMA = $SIGMA)" 241 end 242 delete -q $fields 177 243 end 178 244 … … 199 265 delete -q x y z 200 266 201 $NPT = 1000 267 $NPT = 10000 202 268 create x 0 $NPT 203 269 set y = x^2 -
branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c
r38362 r38366 5 5 int test_compress (int bitpix, char *zcmptype); 6 6 7 // char *cmptype[] = {"NONE", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL}; 8 // char *cmptype[] = {"NONE", "GZIP_1", "RICE_1", "RICE_ONE", NULL}; 9 // int bitpix[] = {8, 16, 32, -32, -64, 0}; 10 11 // char *cmptype[] = {"NONE", "GZIP_1", NULL}; 12 // char *cmptype[] = {"PLIO_1", NULL}; 13 // int bitpix[] = {8, 16, 32, 0}; 14 15 char *cmptype[] = {"GZIP_2", NULL}; 16 int bitpix[] = {-32, 0}; 7 // char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL}; 8 char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", NULL}; 9 int bitpix[] = {8, 16, 32, -32, -64, 0}; 17 10 18 11 int main (int argc, char **argv) { … … 25 18 for (i = 0; cmptype[i]; i++) { 26 19 for (j = 0; bitpix[j]; j++) { 20 if (!strcasecmp (cmptype[i], "RICE_1") && (bitpix[j] < 0)) continue; 21 if (!strcasecmp (cmptype[i], "RICE_ONE") && (bitpix[j] < 0)) continue; 27 22 test_compress (bitpix[j], cmptype[i]); 28 23 } 29 24 } 30 31 // test_compress ( 16, "NONE");32 // test_compress ( 32, "NONE");33 // test_compress (-32, "NONE");34 // test_compress (-64, "NONE");35 //36 // test_compress ( 8, "GZIP_1");37 // test_compress ( 16, "GZIP_1");38 // test_compress ( 32, "GZIP_1");39 // test_compress (-32, "GZIP_1");40 // test_compress (-64, "GZIP_1");41 42 25 exit (0); 43 26 } -
branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c
r38363 r38366 4 4 5 5 int test_compress (char *zcmptype); 6 int test_compress_single_full (char *zcmptype); 6 7 7 8 int main (int argc, char **argv) { … … 10 11 11 12 diag ("libfits tablecomp.c tests"); 13 14 test_compress_single_full ("GZIP_1"); 15 test_compress_single_full ("RICE_1"); 12 16 13 17 test_compress (NULL); 14 18 test_compress ("NONE"); 19 test_compress ("NONE_2"); 15 20 test_compress ("GZIP_1"); 16 21 test_compress ("GZIP_2"); 17 // test_compress ("GZIP_1"); 22 test_compress ("RICE_1"); 23 test_compress ("RICE_ONE"); 18 24 19 25 exit (0); … … 31 37 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 32 38 39 ok (gfits_define_bintable_column (&header, "B", "VAL", "val", "none", 1.0, 0.0), "defined byte column"); 33 40 ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column"); 34 41 ok (gfits_define_bintable_column (&header, "J", "ID", "ID", "none", 1.0, 0.0), "defined int column"); … … 40 47 41 48 int Nval = 1000; 49 char *VAL; ALLOCATE (VAL, char, Nval); 42 50 short *SEQ; ALLOCATE (SEQ, short, Nval); 43 51 int *ID; ALLOCATE (ID, int, Nval); … … 47 55 int i; 48 56 for (i = 0; i < Nval; i++) { 57 VAL[i] = i + 32; 49 58 SEQ[i] = i; 50 59 ID[i] = 10000*i + 100*i; … … 54 63 55 64 // add the columns to the output array 65 ok (gfits_set_bintable_column (&header, &ftable, "VAL", VAL, Nval), "set byte table column"); 56 66 ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short table column"); 57 67 ok (gfits_set_bintable_column (&header, &ftable, "ID", ID, Nval), "set int table column"); … … 84 94 off_t Nrow; 85 95 96 char *VAL_t = gfits_get_bintable_column_data (outheader, outtable, "VAL", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"), "read byte table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 86 97 short *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"), "read short table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 87 98 int *ID_t = gfits_get_bintable_column_data (outheader, outtable, "ID", type, &Nrow, &Ncol); ok (!strcmp (type, "int"), "read int table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); … … 90 101 91 102 // count mismatched values 103 int Nvalue = 0; 92 104 int Nseq = 0; 93 105 int Nid = 0; … … 95 107 int Ny = 0; 96 108 for (i = 0; i < Nval; i++) { 109 if (VAL[i] != VAL_t[i]) Nvalue++; 97 110 if (SEQ[i] != SEQ_t[i]) Nseq++; 98 111 if ( ID[i] != ID_t[i]) Nid++; … … 101 114 } 102 115 103 ok (!Nseq, "short values match (input vs output)"); 104 ok (!Nid, "int values match (input vs output)"); 105 ok (!Nx, "float values match (input vs output)"); 106 ok (!Ny, "double values match (input vs output)"); 116 ok (!Nvalue, "byte values match (input vs output)"); 117 ok (!Nseq, "short values match (input vs output)"); 118 ok (!Nid, "int values match (input vs output)"); 119 ok (!Nx, "float values match (input vs output)"); 120 ok (!Ny, "double values match (input vs output)"); 107 121 108 122 gfits_free_header (&header); … … 115 129 } 116 130 131 int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 132 133 Header header; 134 FTable ftable; 135 136 diag ("--- starting test_compress with zcmptype %s ---", zcmptype); 137 ok (gfits_init_header (&header), "inited the header"); 138 ok (gfits_init_table (&ftable), "inited the table"); 139 140 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 141 142 ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column"); 143 144 // generate the output array that carries the data 145 ok (gfits_create_table (&header, &ftable), "created the basic table"); 146 147 int Nval = 1000; 148 short *SEQ; ALLOCATE (SEQ, short, Nval); 149 150 int i; 151 for (i = 0; i < Nval; i++) { 152 SEQ[i] = i; 153 } 154 155 // add the columns to the output array 156 ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short table column"); 157 158 Header *outheader = &header; 159 FTable *outtable = &ftable; 160 161 if (zcmptype) { 162 Header cmpheader; 163 FTable cmptable; 164 cmptable.header = &cmpheader; 165 ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table"); 166 167 Header rawheader; 168 FTable rawtable; 169 rawtable.header = &rawheader; 170 ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table"); 171 172 gfits_free_header (&cmpheader); 173 gfits_free_table (&cmptable); 174 175 outheader = &rawheader; 176 outtable = &rawtable; 177 } 178 179 char type[16]; 180 int Ncol; 181 off_t Nrow; 182 183 short *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"), "read short table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 184 185 // count mismatched values 186 int Nseq = 0; 187 for (i = 0; i < Nval; i++) { 188 if (SEQ[i] != SEQ_t[i]) Nseq++; 189 } 190 191 ok (!Nseq, "short values match (input vs output)"); 192 193 gfits_free_header (&header); 194 gfits_free_table (&ftable); 195 if (zcmptype) { 196 gfits_free_header (outheader); 197 gfits_free_table (outtable); 198 } 199 return TRUE; 200 } 201
Note:
See TracChangeset
for help on using the changeset viewer.
