IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38408


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

Location:
branches/eam_branches/ohana.20150429/src/libfits
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c

    r38404 r38408  
    129129
    130130    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") ||
    132133          !strcmp (fields[i].datatype, "double")||
    133134          !strcmp (fields[i].datatype, "int64_t")) {
     
    135136        goto got_cmptype;
    136137      }
    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")) {
    140139        strcpy (fields[i].zctype, "RICE_1");
    141140        goto got_cmptype;
    142141      }
    143       if (!strcmp (fields[i].datatype, "char")) {
     142      if (!strcmp (fields[i].datatype, "byte") ||
     143          !strcmp (fields[i].datatype, "char")) {
    144144        strcpy (fields[i].zctype, "GZIP_1");
    145145        goto got_cmptype;
     
    154154        strcpy (fields[i].zctype, "GZIP_2");
    155155      }
     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");
    156161    }
    157162
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c

    r38404 r38408  
    266266  SET_VALUES("int",         int, "char", char, SWAP_WORD, 1);
    267267  SET_VALUES("int64_t", int64_t, "char", char, SWAP_DBLE, 1);
     268  SET_VALUES("float",     float, "char", char, SWAP_WORD, 1);
    268269  SET_VALUES("double",   double, "char", char, SWAP_DBLE, 1);
    269   SET_VALUES("float",     float, "char", char, SWAP_WORD, 1);
    270270
    271271  SET_VALUES("char",       char, "byte", char, SWAP_NONE, 1);
     
    274274  SET_VALUES("int",         int, "byte", char, SWAP_WORD, 1);
    275275  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);
    278278
    279279  SET_VALUES("char",       char, "short", short, SWAP_NONE, 2);
     
    282282  SET_VALUES("int",         int, "short", short, SWAP_WORD, 2);
    283283  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);
    286286
    287287  SET_VALUES("char",       char, "int", int, SWAP_NONE, 4);
     
    290290  SET_VALUES("int",         int, "int", int, SWAP_WORD, 4);
    291291  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);
    294294
    295295  SET_VALUES("char",       char, "int64_t", int64_t, SWAP_NONE, 8);
     
    298298  SET_VALUES("int",         int, "int64_t", int64_t, SWAP_WORD, 8);
    299299  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);
    302302
    303303  SET_VALUES("char",       char, "float", float, SWAP_NONE, 4);
     
    306306  SET_VALUES("int",         int, "float", float, SWAP_WORD, 4);
    307307  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);
    310310
    311311  SET_VALUES("char",       char, "double", double, SWAP_NONE, 8);
     
    314314  SET_VALUES("int",         int, "double", double, SWAP_WORD, 8);
    315315  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);
    318318
    319319# if (0)
  • 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.