IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38342


Ignore:
Timestamp:
May 31, 2015, 8:36:59 AM (11 years ago)
Author:
eugene
Message:

adding compressed table I/O tests

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

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/extern/gzip.c

    r38340 r38342  
    22# include <gfitsio.h>
    33# include <zlib.h>
    4 # define EXTRA_VERBOSE 1
     4# define EXTRA_VERBOSE 0
    55
    66/** the two functions in this file re-implement the uncompress function of zlib. 
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c

    r38334 r38342  
    178178}
    179179
     180# define VERBOSE 0
     181
    180182// raw_pixsize is the bytes / pixel for the input matrix
    181183// place the raw image bytes for the current tile into the tile buffer
     
    188190  off_t Nx = table->header->Naxis[0];
    189191
     192  if (VERBOSE) fprintf (stderr, "collect: ");
    190193  for (i = 0; i < Nrows; i++) {
    191194    int row = row_start + i;
    192195    memcpy (&raw[i*rowsize], &table->buffer[Nx*row + col], rowsize);
    193   }
     196# if (VERBOSE)
     197    int j; for (j = 0; j < rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + col + j]);
     198# endif
     199  }
     200  if (VERBOSE) fprintf (stderr, "\n");
    194201
    195202  return (TRUE);
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_table_varlength.c

    r38334 r38342  
    141141  }
    142142
     143  // fprintf (stderr, "length: %d, offset: %d\n", (int) *length, (int) offset);
     144
    143145  result = (void *) (ftable->buffer + ftable->heap_start + offset);
    144146  return result;
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c

    r38340 r38342  
    146146}
    147147
     148# define VERBOSE 0
     149
    148150// raw_pixsize is the bytes / pixel for the input matrix
    149151// place the raw image bytes for the current tile into the tile buffer
     
    156158  off_t Nx = table->header->Naxis[0];
    157159
     160  if (VERBOSE) fprintf (stderr, "collect: ");
    158161  for (i = 0; i < Nrows; i++) {
    159162    int row = row_start + i;
    160163    memcpy (&table->buffer[Nx*row + col], &raw[i*rowsize], rowsize);
     164# if (VERBOSE)
     165    int j; for (j = 0; j < rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + col + j]);
     166# endif
    161167  }
     168  if (VERBOSE) fprintf (stderr, "\n");
    162169
    163170  return (TRUE);
  • branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh

    r38340 r38342  
    11
    2 macro testall
    3 
    4   foreach bitpix 8 16 32 -32 -64
    5     echo ===== bitpix = $bitpix =====
    6     test1 $bitpix
    7   end
    8 end
    9 
    10 macro test1
    11  if ($0 != 2)
    12    echo "USAGE: test_image (bitpix)"
    13    break
    14  end
     2macro test_image_all
     3
     4  foreach mode NONE GZIP_1
     5    foreach bitpix 8 16 32 -32 -64
     6      echo ===== bitpix = $bitpix =====
     7      test_image_single $bitpix $mode
     8    end
     9  end
     10end
     11
     12macro test_image_single
     13 if ($0 != 3)
     14   echo "USAGE: test_image_single (bitpix) (mode)"
     15   break
     16 end
     17
     18 local bitpix cmpmode
     19 $bitpix = $1
     20 $cmpmode = $2
    1521
    1622 mcreate z 8 8
    1723 set x = xramp(z)
    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
     24 wd x test.raw.fits -bitpix $bitpix -bzero 0 -bscale 1
     25 wd x test.cmp.fits -bitpix $bitpix -bzero 0 -bscale 1 -compress-mode $cmpmode
    2026 rd b test.cmp.fits -x 0
    2127 set d = x - b
    2228 stat d
     29
     30 if ($cmpmode == NONE) return
    2331
    2432 if ($bitpix == -64)
     
    4250end
    4351
    44 macro test2
    45  mcreate z 500 500
    46  set x = xramp(z)
    47  wd x test.raw.fits -bitpix -32 -bzero 0 -bscale 1
    48  wd x test.cmp.fits -bitpix -32 -bzero 0 -bscale 1 -compress -compress-mode NONE
    49  rd b test.cmp.fits -x 0
    50  set d = x - b
    51  stat d
    52  # exec funpack -S test.cmp.fits > test.fun.fits
    53 end
    54 
    55 macro test3
     52macro test_table_single_mode
     53 if ($0 != 2)
     54   echo "USAGE: test_table_single_mode (mode)"
     55   break
     56 end
     57
     58 local cmpmode
     59 $cmpmode = $1
     60
     61 delete -q x y ID
    5662
    5763 $NPT = 10
     
    6066 create ID 1 {$NPT + 1} -int
    6167
    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
     68 $fields = ID x y
     69 $format = IEE
     70
     71 write -fits test test.raw.tbl $fields -format $format
     72 write -fits test test.cmp.tbl $fields -format $format -compress-mode $cmpmode
     73
     74 foreach f $fields
    6675   set $f\_raw = $f
    6776   delete $f
     
    7079 echo "===== raw ====="
    7180 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
     81 read -fits test $fields
     82
     83 foreach f $fields
     84   set dv = $f - $f\_raw
     85   vstat dv
     86 end
     87 delete -q $fields
    7988
    8089 echo "===== cmp ====="
    8190 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
    88 end
    89 
    90 macro test4
    91 
    92  create x 0 100
     91 read -fits test $fields
     92
     93 foreach f $fields
     94   set dv = $f - $f\_raw
     95   vstat dv
     96 end
     97end
     98
     99macro test_table_all_single_column
     100
     101  local format cmpmode
     102
     103  foreach cmpmode NONE GZIP_1
     104    foreach format B I J K E D
     105      test_table_single_column $cmpmode $format
     106    end
     107  end
     108end
     109
     110macro test_table_single_column
     111 if ($0 != 3)
     112   echo "USAGE: test_table_single_column (mode) (format)"
     113   break
     114 end
     115
     116 local cmpmode
     117 $cmpmode = $1
     118
     119 delete -q x
     120
     121 $NPT = 10
     122 create x 0 $NPT
     123
     124 local format
     125
     126 $fields = x
     127 $format = $2
     128
     129 write -fits test test.raw.tbl $fields -format $format
     130 write -fits test test.cmp.tbl $fields -format $format -compress-mode $cmpmode
     131
     132 foreach f $fields
     133   set $f\_raw = $f
     134   delete $f
     135 end
     136
     137 echo "===== $cmpmode $format raw ====="
     138 data test.raw.tbl
     139 read -fits test $fields
     140
     141 foreach f $fields
     142   set dv = $f - $f\_raw
     143   vstat dv
     144 end
     145 delete -q $fields
     146
     147 echo "===== $cmpmode $format cmp ====="
     148 data test.cmp.tbl
     149 read -fits test $fields
     150
     151 foreach f $fields
     152   set dv = $f - $f\_raw
     153   vstat dv
     154 end
     155end
     156
     157macro test_table_all_multi_column
     158
     159  local format cmpmode
     160
     161  foreach cmpmode NONE GZIP_1
     162    foreach format B I J K E D
     163      test_table_multi_column $cmpmode $format
     164    end
     165  end
     166end
     167
     168macro test_table_multi_column
     169 if ($0 != 3)
     170   echo "USAGE: test_table_multi_column (mode) (format)"
     171   break
     172 end
     173
     174 local cmpmode
     175 $cmpmode = $1
     176
     177 delete -q x y z
     178
     179 $NPT = 10
     180 create x 0 $NPT
    93181 set y = x^2
    94  create ID 1 101 -int
    95 
    96  write -fits test test.raw.tbl x y ID
    97  write -fits test test.cmp.tbl x y ID -compress
    98 
    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
    122 end
     182 set z = 0.01*x
     183
     184 local format
     185
     186 $fields = x y z
     187 $format = $2\$2\$2
     188
     189 $fields = x y
     190 $format = $2\$2
     191
     192 write -fits test test.raw.tbl $fields -format $format
     193 write -fits test test.cmp.tbl $fields -format $format -compress-mode $cmpmode
     194
     195 foreach f $fields
     196   set $f\_raw = $f
     197   delete $f
     198 end
     199
     200 echo "===== $cmpmode $format raw ====="
     201 data test.raw.tbl
     202 read -fits test $fields
     203
     204 foreach f $fields
     205   set dv = $f - $f\_raw
     206   vstat dv
     207 end
     208 delete -q $fields
     209
     210 echo "===== $cmpmode $format cmp ====="
     211 data test.cmp.tbl
     212 read -fits test $fields
     213
     214 foreach f $fields
     215   set dv = $f - $f\_raw
     216   vstat dv
     217 end
     218end
     219
     220
     221macro test_table_all_rnd
     222
     223  local format cmpmode
     224
     225  foreach cmpmode NONE GZIP_1
     226    test_table_rnd $cmpmode
     227  end
     228end
     229
     230macro test_table_rnd
     231 if ($0 != 2)
     232   echo "USAGE: test_table_rnd (mode)"
     233   break
     234 end
     235
     236 local cmpmode
     237 $cmpmode = $1
     238
     239 delete -q Achar Ashort Aint Along
     240 delete -q Ffloat Fdouble
     241
     242 # lrnd generates rnd int between 0 and 0x7fffff (2^31 - 1 inclusive)
     243
     244 $NPT = 1000
     245 create ni 0 $NPT -int
     246 set Achar  = lrnd(ni) & 0x7f
     247 set Ashort = lrnd(ni) & 0x7fff
     248 set Aint   = lrnd(ni)
     249 set Along  = lrnd(ni); # I cannot represent the full dynamic range of 64 bit with mana vector ints
     250
     251 create nf 0 $NPT
     252 set Ffloat = drnd(nf)*1e20
     253 set Fdouble = drnd(nf)*1e100
     254
     255 local format
     256
     257 $fields = Achar Ashort Aint Along Ffloat Fdouble
     258 $format = BIJKED
     259
     260 write -fits test test.raw.tbl $fields -format $format
     261 write -fits test test.cmp.tbl $fields -format $format -compress-mode $cmpmode
     262
     263 foreach f $fields
     264   set $f\_raw = $f
     265   delete $f
     266 end
     267
     268 echo "===== $cmpmode $format raw ====="
     269 data test.raw.tbl
     270 read -fits test $fields
     271
     272 foreach f $fields
     273   set dv = $f - $f\_raw
     274   vstat dv
     275 end
     276 delete -q $fields
     277
     278 echo "===== $cmpmode $format cmp ====="
     279 data test.cmp.tbl
     280 read -fits test $fields
     281
     282 foreach f $fields
     283   set dv = $f - $f\_raw
     284   vstat dv
     285 end
     286end
Note: See TracChangeset for help on using the changeset viewer.