Changeset 38408
- Timestamp:
- Jun 6, 2015, 10:04:55 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libfits
- Files:
-
- 3 edited
-
table/F_compress_T.c (modified) (3 diffs)
-
table/F_set_column.c (modified) (7 diffs)
-
test/compress.sh (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
r38404 r38408 129 129 130 130 if (!strcasecmp (fields[i].zctype, "AUTO")) { 131 if (!strcmp (fields[i].datatype, "float") || 131 if (!strcmp (fields[i].datatype, "short") || 132 !strcmp (fields[i].datatype, "float") || 132 133 !strcmp (fields[i].datatype, "double")|| 133 134 !strcmp (fields[i].datatype, "int64_t")) { … … 135 136 goto got_cmptype; 136 137 } 137 if (!strcmp (fields[i].datatype, "byte") || 138 !strcmp (fields[i].datatype, "short") || 139 !strcmp (fields[i].datatype, "int")) { 138 if (!strcmp (fields[i].datatype, "int")) { 140 139 strcpy (fields[i].zctype, "RICE_1"); 141 140 goto got_cmptype; 142 141 } 143 if (!strcmp (fields[i].datatype, "char")) { 142 if (!strcmp (fields[i].datatype, "byte") || 143 !strcmp (fields[i].datatype, "char")) { 144 144 strcpy (fields[i].zctype, "GZIP_1"); 145 145 goto got_cmptype; … … 154 154 strcpy (fields[i].zctype, "GZIP_2"); 155 155 } 156 } 157 158 // OVERRIDE: GZIP_2 invalid for B (use GZIP_1) 159 if (!strcasecmp (fields[i].zctype, "GZIP_2") && !strcmp (fields[i].datatype, "byte")) { 160 strcpy (fields[i].zctype, "GZIP_1"); 156 161 } 157 162 -
branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c
r38404 r38408 266 266 SET_VALUES("int", int, "char", char, SWAP_WORD, 1); 267 267 SET_VALUES("int64_t", int64_t, "char", char, SWAP_DBLE, 1); 268 SET_VALUES("float", float, "char", char, SWAP_WORD, 1); 268 269 SET_VALUES("double", double, "char", char, SWAP_DBLE, 1); 269 SET_VALUES("float", float, "char", char, SWAP_WORD, 1);270 270 271 271 SET_VALUES("char", char, "byte", char, SWAP_NONE, 1); … … 274 274 SET_VALUES("int", int, "byte", char, SWAP_WORD, 1); 275 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);276 SET_VALUES("float", float, "byte", char, SWAP_WORD, 1); 277 SET_VALUES("double", double, "byte", char, SWAP_DBLE, 1); 278 278 279 279 SET_VALUES("char", char, "short", short, SWAP_NONE, 2); … … 282 282 SET_VALUES("int", int, "short", short, SWAP_WORD, 2); 283 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);284 SET_VALUES("float", float, "short", short, SWAP_WORD, 2); 285 SET_VALUES("double", double, "short", short, SWAP_DBLE, 2); 286 286 287 287 SET_VALUES("char", char, "int", int, SWAP_NONE, 4); … … 290 290 SET_VALUES("int", int, "int", int, SWAP_WORD, 4); 291 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);292 SET_VALUES("float", float, "int", int, SWAP_WORD, 4); 293 SET_VALUES("double", double, "int", int, SWAP_DBLE, 4); 294 294 295 295 SET_VALUES("char", char, "int64_t", int64_t, SWAP_NONE, 8); … … 298 298 SET_VALUES("int", int, "int64_t", int64_t, SWAP_WORD, 8); 299 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);300 SET_VALUES("float", float, "int64_t", int64_t, SWAP_WORD, 8); 301 SET_VALUES("double", double, "int64_t", int64_t, SWAP_DBLE, 8); 302 302 303 303 SET_VALUES("char", char, "float", float, SWAP_NONE, 4); … … 306 306 SET_VALUES("int", int, "float", float, SWAP_WORD, 4); 307 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);308 SET_VALUES("float", float, "float", float, SWAP_WORD, 4); 309 SET_VALUES("double", double, "float", float, SWAP_DBLE, 4); 310 310 311 311 SET_VALUES("char", char, "double", double, SWAP_NONE, 8); … … 314 314 SET_VALUES("int", int, "double", double, SWAP_WORD, 8); 315 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);316 SET_VALUES("float", float, "double", double, SWAP_WORD, 8); 317 SET_VALUES("double", double, "double", double, SWAP_DBLE, 8); 318 318 319 319 # if (0) -
branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
r38404 r38408 128 128 local format cmpmode 129 129 130 foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 130 # foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 131 foreach cmpmode GZIP_2 131 132 foreach format B I J K E D 132 133 if (($cmpmode == RICE_1) && ($format == E)) continue ; # RICE_1 is for int only … … 199 200 if ($cmpmode == NONE) return; # funpack will not recognize NONE 200 201 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 B202 202 203 203 tapDIAG 2 "===== $cmpmode $format fpack =====" … … 311 311 local format cmpmode 312 312 313 foreach cmpmode NONE GZIP_1 313 foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 314 314 test_table_rnd $cmpmode 315 315 end … … 325 325 $cmpmode = $1 326 326 327 tapDIAG 2 "===== testing $cmpmode =====" 328 327 329 delete -q Achar Ashort Aint Along 328 330 delete -q Ffloat Fdouble … … 330 332 # lrnd generates rnd int between 0 and 0x7fffff (2^31 - 1 inclusive) 331 333 332 #$NPT = 1000333 $NPT = 30334 $NPT = 1000 335 # $NPT = 30 334 336 create ni 0 $NPT -int 335 set Achar = lrnd(ni) & 0x7f 337 create nf 0 $NPT 338 339 # set Achar = lrnd(ni) & 0x7f 340 set Achar = int(255.999*(drnd(ni) - 0.5)) 336 341 set Ashort = lrnd(ni) & 0x7fff 337 342 set Aint = lrnd(ni) 338 set Along = lrnd(ni); # I cannot represent the full dynamic range of 64 bit with mana vector ints 339 340 create nf 0 $NPT 341 set Ffloat = drnd(nf)*1e20 342 set Fdouble = drnd(nf)*1e50 343 344 # I cannot represent the full dynamic range of 64 bit with mana vector ints, but 345 # I can with the (double) floating point vector. however, I get the wrong bits 346 set Along_dbl = 9.223371e18 * (2.0*drnd(nf) - 1.0); 347 348 cast Along = Along_dbl as int64 349 350 set Ffloat_dbl = 3.402822e+38 * (2.0*drnd(nf) - 1.0) 351 cast Ffloat = Ffloat_dbl as single 352 set Fdouble = 1.797692e+308 * (2.0*drnd(nf) - 1.0) 343 353 344 354 local format … … 347 357 $format = BIJKED 348 358 349 #$fields = Ffloat350 #$format = E359 #$fields = Along 360 #$format = K 351 361 352 362 write -fits test test.raw.tbl $fields -format $format … … 358 368 end 359 369 360 echo"===== $cmpmode $format raw ====="370 tapDIAG 2 "===== $cmpmode $format raw =====" 361 371 data test.raw.tbl 362 372 read -fits test $fields … … 364 374 foreach f $fields 365 375 set dv = $f - $f\_raw 366 vstat dv 367 end 368 delete -q $fields 369 370 echo "===== $cmpmode $format cmp =====" 376 vstat -q dv 377 tapOK {abs($MEAN) < 0.001} "read our raw $f $cmpmode $format (MEAN = $MEAN)" 378 tapOK {$SIGMA < 0.001} "read our raw $f $cmpmode $format (SIGMA = $SIGMA)" 379 end 380 delete -q $fields 381 382 tapDIAG 2 "===== $cmpmode $format cmp =====" 371 383 data test.cmp.tbl 372 384 read -fits test $fields … … 374 386 foreach f $fields 375 387 set dv = $f - $f\_raw 376 vstat dv 377 end 378 end 388 vstat -q dv 389 tapOK {abs($MEAN) < 0.001} "read our cmp $f $cmpmode $format (MEAN = $MEAN)" 390 tapOK {$SIGMA < 0.001} "read our cmp $f $cmpmode $format (SIGMA = $SIGMA)" 391 end 392 delete -q $fields 393 394 tapDIAG 2 "===== $cmpmode $format fpack =====" 395 396 # try to run fpack on ours 397 if (1) 398 tapEXEC /bin/cp -f test.raw.tbl test.fpk.tbl 399 tapEXEC fpack -table -F test.fpk.tbl 400 401 data test.fpk.tbl 402 read -fits test $fields 403 404 foreach f $fields 405 set dv = $f - $f\_raw 406 vstat -q dv 407 tapOK {abs($MEAN) < 0.001} "read fpack $f $cmpmode $format (MEAN = $MEAN)" 408 tapOK {$SIGMA < 0.001} "read fpack $f $cmpmode $format (SIGMA = $SIGMA)" 409 end 410 delete -q $fields 411 end 412 413 break -auto off 414 echo $cmpmode $format 415 exec ls test.cmp.tbl test.fpk.tbl | fields -x 0 PCOUNT ZCTYP1 ZCTYP2 ZCTYP3 ZCTYP4 ZCTYP5 ZCTYP6 416 break -auto on 417 418 if ($cmpmode == NONE) return; # funpack will not recognize NONE 419 if ($cmpmode == RICE_ONE) return; # funpack will not recognize RICE_ONE for tables 420 421 tapDIAG 2 "===== $cmpmode $format funpack =====" 422 423 # try to run fpack on ours 424 tapEXEC /bin/cp -f test.cmp.tbl test.fun.tbl 425 tapEXEC funpack -F test.fun.tbl 426 427 data test.fun.tbl 428 read -fits test $fields 429 430 foreach f $fields 431 set dv = $f - $f\_raw 432 vstat -q dv 433 tapOK {abs($MEAN) < 0.001} "read funpack $f $cmpmode $format (MEAN = $MEAN)" 434 tapOK {$SIGMA < 0.001} "read funpack $f $cmpmode $format (SIGMA = $SIGMA)" 435 end 436 delete -q $fields 437 end 438
Note:
See TracChangeset
for help on using the changeset viewer.
