IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2015, 10:04:55 AM (11 years ago)
Author:
eugene
Message:

fix AUTO types to match funpack needs; swap double correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh

    r38404 r38408  
    128128  local format cmpmode
    129129
    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
    131132    foreach format B I J K E D
    132133      if (($cmpmode == RICE_1)   && ($format == E)) continue ; # RICE_1 is for int only
     
    199200 if ($cmpmode == NONE) return; # funpack will not recognize NONE
    200201 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
    202202
    203203 tapDIAG 2 "===== $cmpmode $format fpack ====="
     
    311311  local format cmpmode
    312312
    313   foreach cmpmode NONE GZIP_1
     313  foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE
    314314    test_table_rnd $cmpmode
    315315  end
     
    325325 $cmpmode = $1
    326326
     327 tapDIAG 2 "===== testing $cmpmode ====="
     328
    327329 delete -q Achar Ashort Aint Along
    328330 delete -q Ffloat Fdouble
     
    330332 # lrnd generates rnd int between 0 and 0x7fffff (2^31 - 1 inclusive)
    331333
    332  # $NPT = 1000
    333  $NPT = 30
     334 $NPT = 1000
     335 # $NPT = 30
    334336 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))
    336341 set Ashort = lrnd(ni) & 0x7fff
    337342 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)
    343353
    344354 local format
     
    347357 $format = BIJKED
    348358
    349  #$fields = Ffloat
    350  #$format = E
     359 #$fields = Along
     360 #$format = K
    351361
    352362 write -fits test test.raw.tbl $fields -format $format
     
    358368 end
    359369
    360  echo "===== $cmpmode $format raw ====="
     370 tapDIAG 2 "===== $cmpmode $format raw ====="
    361371 data test.raw.tbl
    362372 read -fits test $fields
     
    364374 foreach f $fields
    365375   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 ====="
    371383 data test.cmp.tbl
    372384 read -fits test $fields
     
    374386 foreach f $fields
    375387   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
     437end
     438
Note: See TracChangeset for help on using the changeset viewer.