Changeset 38404
- Timestamp:
- Jun 6, 2015, 7:55:16 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libfits
- Files:
-
- 8 edited
-
Makefile (modified) (2 diffs)
-
table/F_compress_T.c (modified) (1 diff)
-
table/F_get_column.c (modified) (5 diffs)
-
table/F_set_column.c (modified) (6 diffs)
-
test/compress.sh (modified) (3 diffs)
-
test/ricetest.c (modified) (1 diff)
-
test/tablecomp.c (modified) (1 diff)
-
test/zlib.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/Makefile
r38378 r38404 1 1 default: install 2 2 help: 3 @echo "make options: install libfits man clean dist "3 @echo "make options: install libfits man clean dist test test.verbose test.clean" 4 4 5 5 include ../../Makefile.System … … 26 26 TEST_LDFLAGS = $(BASE_LDFLAGS) -lFITS -lohana -ltap_ohana 27 27 28 TESTPROG = imagecomp tablecomp zlib ricetest 28 # zlib 29 TESTPROG = imagecomp tablecomp ricetest 29 30 $(TESTPROG) : % : $(TESTBIN)/% 30 31 test: $(TESTPROG) 31 for i in $(TESTPROG); do $(TESTBIN)/$$i; done 32 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 33 test.verbose: $(TESTPROG) 34 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done 32 35 33 36 install: $(DESTLIB)/libFITS.a $(DESTLIB)/libFITS.$(DLLTYPE) $(DESTMAN)/fits.1 -
branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
r38399 r38404 149 149 150 150 151 // RICE can only be used on integer fields151 // OVERRIDE: RICE can only be used on integer fields 152 152 if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) { 153 if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double") ) {153 if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double") || !strcmp (fields[i].datatype, "int64_t")) { 154 154 strcpy (fields[i].zctype, "GZIP_2"); 155 155 } -
branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c
r38366 r38404 76 76 } 77 77 78 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 78 // NOTE: we have already copied the data to 'array', so the blocks below 79 // only need to swap if this is a direct copy 79 80 Pin = array; 80 81 Pout = array; 82 int directCopy = (Bzero == 0.0) && (Bscale == 1.0); 83 84 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 81 85 if (!strcmp (type, "char")) { 82 86 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 83 *(char *)Pout = *(char *)Pin*Bscale + Bzero;87 if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; } 84 88 } 85 89 } 86 90 if (!strcmp (type, "byte")) { 87 91 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 88 *(char *)Pout = *(char *)Pin*Bscale + Bzero;92 if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; } 89 93 } 90 94 } … … 94 98 if (!nativeOrder) { SWAP_BYTE; } 95 99 # endif 96 *(short *)Pout = *(short *)Pin*Bscale + Bzero;100 if (!directCopy) { *(short *)Pout = *(short *)Pin*Bscale + Bzero; } 97 101 } 98 102 } … … 102 106 if (!nativeOrder) { SWAP_WORD; } 103 107 # endif 104 *(int *)Pout = *(int *)Pin*Bscale + Bzero;108 if (!directCopy) { *(int *)Pout = *(int *)Pin*Bscale + Bzero; } 105 109 } 106 110 } 107 111 if (!strcmp (type, "int64_t")) { 108 if ((Bzero == 0.0) && (Bscale == 1.0)) { 109 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 110 # ifdef BYTE_SWAP 111 if (!nativeOrder) { SWAP_DBLE; } 112 # endif 113 *(int64_t *)Pout = *(int64_t *)Pin; 114 } 115 } else { 116 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 117 # ifdef BYTE_SWAP 118 if (!nativeOrder) { SWAP_DBLE; } 119 # endif 120 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 121 } 112 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 113 # ifdef BYTE_SWAP 114 if (!nativeOrder) { SWAP_DBLE; } 115 # endif 116 if (!directCopy) { *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; } 122 117 } 123 118 } … … 127 122 if (!nativeOrder) { SWAP_WORD; } 128 123 # endif 129 *(float *)Pout = *(float *)Pin*Bscale + Bzero;124 if (!directCopy) { *(float *)Pout = *(float *)Pin*Bscale + Bzero; } 130 125 } 131 126 } … … 135 130 if (!nativeOrder) { SWAP_DBLE; } 136 131 # endif 137 *(double *)Pout = *(double *)Pin*Bscale + Bzero;132 if (!directCopy) { *(double *)Pout = *(double *)Pin*Bscale + Bzero; } 138 133 } 139 134 } -
branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c
r38366 r38404 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 4 # define SWAP_NONE 5 6 # ifdef BYTE_SWAP 3 7 # define SWAP_BYTE { \ 4 8 char tmp; \ … … 14 18 tmp = Pout[2]; Pout[2] = Pout[5]; Pout[5] = tmp; \ 15 19 tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; } 20 # else 21 # define SWAP_BYTE 22 # define SWAP_WORD 23 # define SWAP_DBLE 24 # endif 16 25 17 26 /***********************/ … … 239 248 // if (!strcmp (intype, #ITYPE)) { 240 249 250 int directCopy = (Bzero == 0.0) && (Bscale == 1.0); 251 252 # define SET_VALUES(OUTNAME, OUTTYPE, INNAME, INTYPE, SWAP_OP, NBYTES_IN) \ 253 if (!strcmp (outtype, OUTNAME) && !strcmp (intype, INNAME)) { \ 254 int NbytesIn = NBYTES_IN; \ 255 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \ 256 if (directCopy) { \ 257 *(OUTTYPE *)Pout = *(INTYPE *)Pin; \ 258 } else { \ 259 *(OUTTYPE *)Pout = (*(INTYPE *)Pin - Bzero) / Bscale; \ 260 } \ 261 if (!nativeOrder) { SWAP_OP; }}} 262 263 SET_VALUES("char", char, "char", char, SWAP_NONE, 1); 264 SET_VALUES("byte", char, "char", char, SWAP_NONE, 1); 265 SET_VALUES("short", short, "char", char, SWAP_BYTE, 1); 266 SET_VALUES("int", int, "char", char, SWAP_WORD, 1); 267 SET_VALUES("int64_t", int64_t, "char", char, SWAP_DBLE, 1); 268 SET_VALUES("double", double, "char", char, SWAP_DBLE, 1); 269 SET_VALUES("float", float, "char", char, SWAP_WORD, 1); 270 271 SET_VALUES("char", char, "byte", char, SWAP_NONE, 1); 272 SET_VALUES("byte", char, "byte", char, SWAP_NONE, 1); 273 SET_VALUES("short", short, "byte", char, SWAP_BYTE, 1); 274 SET_VALUES("int", int, "byte", char, SWAP_WORD, 1); 275 SET_VALUES("int64_t", int64_t, "byte", char, SWAP_DBLE, 1); 276 SET_VALUES("float", float, "byte", char, SWAP_DBLE, 1); 277 SET_VALUES("double", double, "byte", char, SWAP_WORD, 1); 278 279 SET_VALUES("char", char, "short", short, SWAP_NONE, 2); 280 SET_VALUES("byte", char, "short", short, SWAP_NONE, 2); 281 SET_VALUES("short", short, "short", short, SWAP_BYTE, 2); 282 SET_VALUES("int", int, "short", short, SWAP_WORD, 2); 283 SET_VALUES("int64_t", int64_t, "short", short, SWAP_DBLE, 2); 284 SET_VALUES("float", float, "short", short, SWAP_DBLE, 2); 285 SET_VALUES("double", double, "short", short, SWAP_WORD, 2); 286 287 SET_VALUES("char", char, "int", int, SWAP_NONE, 4); 288 SET_VALUES("byte", char, "int", int, SWAP_NONE, 4); 289 SET_VALUES("short", short, "int", int, SWAP_BYTE, 4); 290 SET_VALUES("int", int, "int", int, SWAP_WORD, 4); 291 SET_VALUES("int64_t", int64_t, "int", int, SWAP_DBLE, 4); 292 SET_VALUES("float", float, "int", int, SWAP_DBLE, 4); 293 SET_VALUES("double", double, "int", int, SWAP_WORD, 4); 294 295 SET_VALUES("char", char, "int64_t", int64_t, SWAP_NONE, 8); 296 SET_VALUES("byte", char, "int64_t", int64_t, SWAP_NONE, 8); 297 SET_VALUES("short", short, "int64_t", int64_t, SWAP_BYTE, 8); 298 SET_VALUES("int", int, "int64_t", int64_t, SWAP_WORD, 8); 299 SET_VALUES("int64_t", int64_t, "int64_t", int64_t, SWAP_DBLE, 8); 300 SET_VALUES("float", float, "int64_t", int64_t, SWAP_DBLE, 8); 301 SET_VALUES("double", double, "int64_t", int64_t, SWAP_WORD, 8); 302 303 SET_VALUES("char", char, "float", float, SWAP_NONE, 4); 304 SET_VALUES("byte", char, "float", float, SWAP_NONE, 4); 305 SET_VALUES("short", short, "float", float, SWAP_BYTE, 4); 306 SET_VALUES("int", int, "float", float, SWAP_WORD, 4); 307 SET_VALUES("int64_t", int64_t, "float", float, SWAP_DBLE, 4); 308 SET_VALUES("float", float, "float", float, SWAP_DBLE, 4); 309 SET_VALUES("double", double, "float", float, SWAP_WORD, 4); 310 311 SET_VALUES("char", char, "double", double, SWAP_NONE, 8); 312 SET_VALUES("byte", char, "double", double, SWAP_NONE, 8); 313 SET_VALUES("short", short, "double", double, SWAP_BYTE, 8); 314 SET_VALUES("int", int, "double", double, SWAP_WORD, 8); 315 SET_VALUES("int64_t", int64_t, "double", double, SWAP_DBLE, 8); 316 SET_VALUES("float", float, "double", double, SWAP_DBLE, 8); 317 SET_VALUES("double", double, "double", double, SWAP_WORD, 8); 318 319 # if (0) 241 320 /** input == char **/ 242 321 if (!strcmp (outtype, "char") && !strcmp (intype, "char")) { 243 322 int NbytesIn = 1; 244 323 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 245 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 324 if (directCopy) { *(char *)Pout = *(char *)Pin; } else { 325 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 326 } 246 327 } 247 328 } … … 249 330 int NbytesIn = 1; 250 331 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 251 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 332 if (directCopy) { *(char *)Pout = *(char *)Pin; } else { 333 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 334 } 252 335 } 253 336 } … … 255 338 int NbytesIn = 1; 256 339 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 257 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 340 if (directCopy) { *(short *)Pout = *(char *)Pin; } else { 341 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 342 } 258 343 # ifdef BYTE_SWAP 259 344 if (!nativeOrder) { SWAP_BYTE; } … … 651 736 } 652 737 } 738 # endif 653 739 654 740 /* check array space */ -
branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
r38366 r38404 330 330 # lrnd generates rnd int between 0 and 0x7fffff (2^31 - 1 inclusive) 331 331 332 $NPT = 1000 332 # $NPT = 1000 333 $NPT = 30 333 334 create ni 0 $NPT -int 334 335 set Achar = lrnd(ni) & 0x7f … … 339 340 create nf 0 $NPT 340 341 set Ffloat = drnd(nf)*1e20 341 set Fdouble = drnd(nf)*1e 100342 set Fdouble = drnd(nf)*1e50 342 343 343 344 local format … … 346 347 $format = BIJKED 347 348 349 #$fields = Ffloat 350 #$format = E 351 348 352 write -fits test test.raw.tbl $fields -format $format 349 353 write -fits test test.cmp.tbl $fields -format $format -compress-mode $cmpmode -
branches/eam_branches/ohana.20150429/src/libfits/test/ricetest.c
r38399 r38404 16 16 char cmpdata[NBYTE]; 17 17 char outdata[NBYTE]; 18 19 // ok (1, "failure"); 18 20 19 21 if (1) { -
branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c
r38400 r38404 11 11 int main (int argc, char **argv) { 12 12 13 plan_tests ( 286);13 plan_tests (668); 14 14 15 15 diag ("libfits tablecomp.c tests"); 16 17 // test_compress ("RICE_1"); 18 // test_compress_fullrange ("RICE_1"); 16 19 17 20 # if (1) -
branches/eam_branches/ohana.20150429/src/libfits/test/zlib.c
r38399 r38404 53 53 err = deflateInit(&zdn, 5); 54 54 // fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out); 55 if (err != Z_OK) { fprintf (std err, "error 1: %d vs %d\n", err, Z_OK); exit (1); }55 if (err != Z_OK) { fprintf (stdout, "not ok: error 1: %d vs %d\n", err, Z_OK); exit (1); } 56 56 57 57 err = deflate(&zdn, Z_FINISH); 58 58 // fprintf (stderr, "out buffers cmp 1: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out); 59 if (err != Z_STREAM_END) { fprintf (std err, "error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }59 if (err != Z_STREAM_END) { fprintf (stdout, "not ok: error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); } 60 60 // fprintf (stderr, "out buffers cmp 2: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out); 61 61 … … 92 92 err = inflateInit(&zup); 93 93 // fprintf (stderr, "out buffers unc 0: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out); 94 if (err != Z_OK) { fprintf (std err, "error 1: %d vs %d\n", err, Z_OK); exit (1); }94 if (err != Z_OK) { fprintf (stdout, "not ok: error 1: %d vs %d\n", err, Z_OK); exit (1); } 95 95 96 96 err = inflate(&zup, Z_FINISH); … … 116 116 } 117 117 } 118 118 119 return exit_status(); 119 120 }
Note:
See TracChangeset
for help on using the changeset viewer.
