IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 30, 2015, 7:59:48 PM (11 years ago)
Author:
eugene
Message:

more work on compression : cfitsio assumes gzip, not zlib (I have made uncompress general )

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

Legend:

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

    r38339 r38340  
     1
     2macro testall
     3
     4  foreach bitpix 8 16 32 -32 -64
     5    echo ===== bitpix = $bitpix =====
     6    test1 $bitpix
     7  end
     8end
    19
    210macro test1
    3  mcreate z 500 500
     11 if ($0 != 2)
     12   echo "USAGE: test_image (bitpix)"
     13   break
     14 end
     15
     16 mcreate z 8 8
    417 set x = xramp(z)
    5  wd x test.raw.fits -bitpix -32 -bzero 0 -bscale 1
    6  wd x test.cmp.fits -bitpix -32 -bzero 0 -bscale 1 -compress
     18 wd x test.raw.fits -bitpix $1 -bzero 0 -bscale 1
     19 wd x test.cmp.fits -bitpix $1 -bzero 0 -bscale 1 -compress
    720 rd b test.cmp.fits -x 0
    821 set d = x - b
    922 stat d
    10  exec fpack -g -S test.raw.fits > test.fpk.fits
    11  exec funpack -S test.cmp.fits > test.fun.fits
     23
     24 if ($bitpix == -64)
     25   echo "*** bitpix $bitpix fails fpack / funpack ***"
     26 else
     27   exec fpack -g -S test.raw.fits > test.fpk.fits
     28   echo "load fpack version"
     29   rd c test.fpk.fits -x 0
     30   set d = x - c
     31   stat d
     32 end
     33
     34 if ($bitpix == -64)
     35   echo "*** bitpix $bitpix fails fpack / funpack ***"
     36 else
     37   exec funpack -S test.cmp.fits > test.fun.fits
     38   rd e test.fun.fits
     39   set d = x - e
     40   stat d
     41 end
    1242end
    1343
     
    2555macro test3
    2656
     57 $NPT = 10
     58 create x 0 $NPT
     59 set y = x^2
     60 create ID 1 {$NPT + 1} -int
     61
     62 write -fits test test.raw.tbl x y ID
     63 write -fits test test.cmp.tbl x y ID -compress-mode NONE
     64
     65 foreach f x y ID
     66   set $f\_raw = $f
     67   delete $f
     68 end
     69
     70 echo "===== raw ====="
     71 data test.raw.tbl
     72 read -fits test x y ID
     73
     74 foreach f x y ID
     75   set dv = $f - $f\_raw
     76   vstat dv
     77 end
     78 delete -q x y ID
     79
     80 echo "===== cmp ====="
     81 data test.cmp.tbl
     82 read -fits test x y ID
     83
     84 foreach f x y ID
     85   set dv = $f - $f\_raw
     86   vstat dv
     87 end
     88end
     89
     90macro test4
     91
    2792 create x 0 100
    2893 set y = x^2
     94 create ID 1 101 -int
    2995
    30  create ID 1 101 -int
    3196 write -fits test test.raw.tbl x y ID
     97 write -fits test test.cmp.tbl x y ID -compress
    3298
    33  write -fits test test.cmp.tbl x y ID -compress
     99 foreach f x y ID
     100   set $f\_raw = $f
     101   delete $f
     102 end
     103
     104 echo "===== raw ====="
     105 data test.raw.tbl
     106 read -fits test x y ID
     107
     108 foreach f x y ID
     109   set dv = $f - $f\_raw
     110   vstat dv
     111 end
     112 delete -q x y ID
     113
     114 echo "===== cmp ====="
     115 data test.cmp.tbl
     116 read -fits test x y ID
     117
     118 foreach f x y ID
     119   set dv = $f - $f\_raw
     120   vstat dv
     121 end
    34122end
  • branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c

    r38335 r38340  
    33# include "tap_ohana.h"
    44
    5 int test_compress (char *zcmptype);
     5int test_compress (int bitpix, char *zcmptype);
    66
    77int main (int argc, char **argv) {
     
    1111  diag ("libfits imagecomp.c tests");
    1212
    13   test_compress ("NONE");
    14   test_compress ("GZIP_1");
     13  test_compress (  8, "NONE");
     14  test_compress ( 16, "NONE");
     15  test_compress ( 32, "NONE");
     16  test_compress (-32, "NONE");
     17  test_compress (-64, "NONE");
     18
     19  test_compress (  8, "GZIP_1");
     20  test_compress ( 16, "GZIP_1");
     21  test_compress ( 32, "GZIP_1");
     22  test_compress (-32, "GZIP_1");
     23  test_compress (-64, "GZIP_1");
    1524
    1625  exit (0);
     
    2029# define NY 100
    2130
    22 int test_compress (char *zcmptype) { // make a table, compress, uncompress, compare : use compression zcmptype
     31int test_compress (int bitpix, char *zcmptype) { // make a table, compress, uncompress, compare : use compression zcmptype
    2332
    2433  Header rawheader;
     
    3140  ftable.header = &theader;
    3241
    33   diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
     42  diag ("--- starting test_compress with bitpix %d, zcmptype %s ---", bitpix, zcmptype);
    3443  ok (gfits_init_header (&rawheader), "init'ed the raw header");
    3544  ok (gfits_init_matrix (&rawmatrix), "init'ed the raw matrix");
     
    3847
    3948  /* assign the necessary internal values */
    40   rawheader.bitpix   = -32;
     49  rawheader.bitpix   = bitpix;
    4150  rawheader.Naxes = 2;
    4251  rawheader.Naxis[0] = NX;
     
    4655  ok (gfits_create_header (&rawheader),          "created header");
    4756  ok (gfits_create_matrix (&rawheader, &rawmatrix), "created matrix");
    48 
    49   float *rawdata = (float *) rawmatrix.buffer;
     57 
     58  char   *rawdata_char   = (char   *) rawmatrix.buffer;
     59  short  *rawdata_short  = (short  *) rawmatrix.buffer;
     60  int    *rawdata_int    = (int    *) rawmatrix.buffer;
     61  float  *rawdata_float  = (float  *) rawmatrix.buffer;
     62  double *rawdata_double = (double *) rawmatrix.buffer;
     63 
    5064  int ix, iy;
    5165  for (ix = 0; ix < NX; ix++) {
    5266    for (iy = 0; iy < NY; iy++) {
    53       rawdata[ix + NX*iy] = ix * iy*iy;
     67      switch (bitpix) {
     68        case   8: rawdata_char  [ix + NX*iy] = ix + iy*iy; break;
     69        case  16: rawdata_short [ix + NX*iy] = ix + iy*iy; break;
     70        case  32: rawdata_int   [ix + NX*iy] = ix + iy*iy; break;
     71        case -32: rawdata_float [ix + NX*iy] = ix + iy*iy; break;
     72        case -64: rawdata_double[ix + NX*iy] = ix + iy*iy; break;
     73        default: myAbort ("bad bitpix value");
     74      }
    5475    }
    5576  }     
     
    6485  int Nbad = 0;
    6586
    66   float *outdata = (float *) outmatrix.buffer;
     87  char   *outdata_char   = (char   *) outmatrix.buffer;
     88  short  *outdata_short  = (short  *) outmatrix.buffer;
     89  int    *outdata_int    = (int    *) outmatrix.buffer;
     90  float  *outdata_float  = (float  *) outmatrix.buffer;
     91  double *outdata_double = (double *) outmatrix.buffer;
     92
    6793  for (ix = 0; ix < NX; ix++) {
    6894    for (iy = 0; iy < NY; iy++) {
    69       if (rawdata[ix + NX*iy] != outdata[ix + NX*iy]) Nbad ++;
     95      switch (bitpix) {
     96        case   8: if (rawdata_char  [ix + NX*iy] != outdata_char  [ix + NX*iy]) Nbad ++; break;
     97        case  16: if (rawdata_short [ix + NX*iy] != outdata_short [ix + NX*iy]) Nbad ++; break;
     98        case  32: if (rawdata_int   [ix + NX*iy] != outdata_int   [ix + NX*iy]) Nbad ++; break;
     99        case -32: if (rawdata_float [ix + NX*iy] != outdata_float [ix + NX*iy]) Nbad ++; break;
     100        case -64: if (rawdata_double[ix + NX*iy] != outdata_double[ix + NX*iy]) Nbad ++; break;
     101        default: myAbort ("bad bitpix value");
     102      }
    70103    }
    71104  }     
  • branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c

    r38335 r38340  
    8282  off_t Nrow;
    8383
    84   short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column");
    85   int     *ID_t = gfits_get_bintable_column_data (outheader, outtable,  "ID", type, &Nrow, &Ncol); ok (!strcmp (type, "int"),    "read int    table column");
    86   float    *X_t = gfits_get_bintable_column_data (outheader, outtable,   "X", type, &Nrow, &Ncol); ok (!strcmp (type, "float"),  "read float  table column");
    87   double   *Y_t = gfits_get_bintable_column_data (outheader, outtable,   "Y", type, &Nrow, &Ncol); ok (!strcmp (type, "double"), "read double table column");
    88    
     84  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");
     85  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");
     86  float    *X_t = gfits_get_bintable_column_data (outheader, outtable,   "X", type, &Nrow, &Ncol); ok (!strcmp (type, "float"),  "read float  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     87  double   *Y_t = gfits_get_bintable_column_data (outheader, outtable,   "Y", type, &Nrow, &Ncol); ok (!strcmp (type, "double"), "read double table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     88
    8989  // count mismatched values
    9090  int Nseq = 0;
Note: See TracChangeset for help on using the changeset viewer.