IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2015, 5:42:47 PM (11 years ago)
Author:
eugene
Message:

libfits compressed I/O seems to be generally working

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

Legend:

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

    r38363 r38366  
    55  tapPLAN 88
    66
    7   foreach mode NONE GZIP_1 GZIP_2 RICE_1
     7  foreach mode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE
    88  # foreach mode GZIP_1
    99  # foreach mode GZIP_2
     
    1111    foreach bitpix 8 16 32 -32 -64
    1212    # 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
    1415      tapDIAG 2 "===== bitpix = $bitpix, mode = $mode ====="
    1516      test_image_single $bitpix $mode
     
    2930 $bitpix = $1
    3031 $cmpmode = $2
     32
     33 delete -q x z b c d e
    3134
    3235 mcreate z 8 8
     
    121124macro test_table_all_single_column
    122125
     126  tapPLAN 88
     127
    123128  local format cmpmode
    124129
    125   foreach cmpmode NONE GZIP_1
     130  foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE
    126131    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
    127138      test_table_single_column $cmpmode $format
    128139    end
    129140  end
     141  tapDONE
    130142end
    131143
     
    136148 end
    137149
    138  local cmpmode
     150 local cmpmode format
    139151 $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
    147165
    148166 $fields = x
    149  $format = $2
    150167
    151168 write -fits test test.raw.tbl $fields -format $format
     
    157174 end
    158175
    159  echo "===== $cmpmode $format raw ====="
     176 tapDIAG 2 "===== $cmpmode $format raw ====="
    160177 data test.raw.tbl
    161178 read -fits test $fields
     
    163180 foreach f $fields
    164181   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 ====="
    170189 data test.cmp.tbl
    171190 read -fits test $fields
     
    173192 foreach f $fields
    174193   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
    177243end
    178244
     
    199265 delete -q x y z
    200266
    201  $NPT = 1000
     267 $NPT = 10000
    202268 create x 0 $NPT
    203269 set y = x^2
  • branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c

    r38362 r38366  
    55int test_compress (int bitpix, char *zcmptype);
    66
    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};
     8char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", NULL};
     9int bitpix[] = {8, 16, 32, -32, -64, 0};
    1710
    1811int main (int argc, char **argv) {
     
    2518  for (i = 0; cmptype[i]; i++) {
    2619    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;
    2722      test_compress (bitpix[j], cmptype[i]);
    2823    }
    2924  }
    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 
    4225  exit (0);
    4326}
  • branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c

    r38363 r38366  
    44
    55int test_compress (char *zcmptype);
     6int test_compress_single_full (char *zcmptype);
    67
    78int main (int argc, char **argv) {
     
    1011
    1112  diag ("libfits tablecomp.c tests");
     13
     14  test_compress_single_full ("GZIP_1");
     15  test_compress_single_full ("RICE_1");
    1216
    1317  test_compress (NULL);
    1418  test_compress ("NONE");
     19  test_compress ("NONE_2");
    1520  test_compress ("GZIP_1");
    1621  test_compress ("GZIP_2");
    17   // test_compress ("GZIP_1");
     22  test_compress ("RICE_1");
     23  test_compress ("RICE_ONE");
    1824
    1925  exit (0);
     
    3137  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
    3238
     39  ok (gfits_define_bintable_column (&header, "B", "VAL", "val", "none", 1.0, 0.0), "defined byte column");
    3340  ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
    3441  ok (gfits_define_bintable_column (&header, "J", "ID",  "ID", "none", 1.0, 0.0),  "defined int column");
     
    4047
    4148  int Nval = 1000;
     49  char  *VAL;  ALLOCATE (VAL, char,   Nval);
    4250  short *SEQ;  ALLOCATE (SEQ, short,  Nval);
    4351  int    *ID;  ALLOCATE (ID,  int,    Nval);
     
    4755  int i;
    4856  for (i = 0; i < Nval; i++) {
     57    VAL[i] = i + 32;
    4958    SEQ[i] = i;
    5059    ID[i] = 10000*i + 100*i;
     
    5463
    5564  // add the columns to the output array
     65  ok (gfits_set_bintable_column (&header, &ftable, "VAL", VAL, Nval), "set byte   table column");
    5666  ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
    5767  ok (gfits_set_bintable_column (&header, &ftable,  "ID",  ID, Nval), "set int    table column");
     
    8494  off_t Nrow;
    8595
     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");
    8697  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");
    8798  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");
     
    90101
    91102  // count mismatched values
     103  int Nvalue = 0;
    92104  int Nseq = 0;
    93105  int  Nid = 0;
     
    95107  int   Ny = 0;
    96108  for (i = 0; i < Nval; i++) {
     109    if (VAL[i] != VAL_t[i]) Nvalue++;
    97110    if (SEQ[i] != SEQ_t[i]) Nseq++;
    98111    if ( ID[i] !=  ID_t[i]) Nid++;
     
    101114  }
    102115
    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)");
    107121
    108122  gfits_free_header (&header);
     
    115129}
    116130
     131int 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.