Changeset 38366 for branches/eam_branches/ohana.20150429/src/libfits/test
- Timestamp:
- Jun 4, 2015, 5:42:47 PM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libfits/test
- Files:
-
- 1 added
- 3 edited
-
compress.sh (modified) (9 diffs)
-
imagecomp.c (modified) (2 diffs)
-
tablecomp.c (modified) (11 diffs)
-
tap.dvo (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
r38363 r38366 5 5 tapPLAN 88 6 6 7 foreach mode NONE GZIP_1 GZIP_2 RICE_1 7 foreach mode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 8 8 # foreach mode GZIP_1 9 9 # foreach mode GZIP_2 … … 11 11 foreach bitpix 8 16 32 -32 -64 12 12 # 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 14 15 tapDIAG 2 "===== bitpix = $bitpix, mode = $mode =====" 15 16 test_image_single $bitpix $mode … … 29 30 $bitpix = $1 30 31 $cmpmode = $2 32 33 delete -q x z b c d e 31 34 32 35 mcreate z 8 8 … … 121 124 macro test_table_all_single_column 122 125 126 tapPLAN 88 127 123 128 local format cmpmode 124 129 125 foreach cmpmode NONE GZIP_1 130 foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE 126 131 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 127 138 test_table_single_column $cmpmode $format 128 139 end 129 140 end 141 tapDONE 130 142 end 131 143 … … 136 148 end 137 149 138 local cmpmode 150 local cmpmode format 139 151 $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 147 165 148 166 $fields = x 149 $format = $2150 167 151 168 write -fits test test.raw.tbl $fields -format $format … … 157 174 end 158 175 159 echo"===== $cmpmode $format raw ====="176 tapDIAG 2 "===== $cmpmode $format raw =====" 160 177 data test.raw.tbl 161 178 read -fits test $fields … … 163 180 foreach f $fields 164 181 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 =====" 170 189 data test.cmp.tbl 171 190 read -fits test $fields … … 173 192 foreach f $fields 174 193 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 177 243 end 178 244 … … 199 265 delete -q x y z 200 266 201 $NPT = 1000 267 $NPT = 10000 202 268 create x 0 $NPT 203 269 set y = x^2 -
branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c
r38362 r38366 5 5 int test_compress (int bitpix, char *zcmptype); 6 6 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}; 8 char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", NULL}; 9 int bitpix[] = {8, 16, 32, -32, -64, 0}; 17 10 18 11 int main (int argc, char **argv) { … … 25 18 for (i = 0; cmptype[i]; i++) { 26 19 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; 27 22 test_compress (bitpix[j], cmptype[i]); 28 23 } 29 24 } 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 42 25 exit (0); 43 26 } -
branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c
r38363 r38366 4 4 5 5 int test_compress (char *zcmptype); 6 int test_compress_single_full (char *zcmptype); 6 7 7 8 int main (int argc, char **argv) { … … 10 11 11 12 diag ("libfits tablecomp.c tests"); 13 14 test_compress_single_full ("GZIP_1"); 15 test_compress_single_full ("RICE_1"); 12 16 13 17 test_compress (NULL); 14 18 test_compress ("NONE"); 19 test_compress ("NONE_2"); 15 20 test_compress ("GZIP_1"); 16 21 test_compress ("GZIP_2"); 17 // test_compress ("GZIP_1"); 22 test_compress ("RICE_1"); 23 test_compress ("RICE_ONE"); 18 24 19 25 exit (0); … … 31 37 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 32 38 39 ok (gfits_define_bintable_column (&header, "B", "VAL", "val", "none", 1.0, 0.0), "defined byte column"); 33 40 ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column"); 34 41 ok (gfits_define_bintable_column (&header, "J", "ID", "ID", "none", 1.0, 0.0), "defined int column"); … … 40 47 41 48 int Nval = 1000; 49 char *VAL; ALLOCATE (VAL, char, Nval); 42 50 short *SEQ; ALLOCATE (SEQ, short, Nval); 43 51 int *ID; ALLOCATE (ID, int, Nval); … … 47 55 int i; 48 56 for (i = 0; i < Nval; i++) { 57 VAL[i] = i + 32; 49 58 SEQ[i] = i; 50 59 ID[i] = 10000*i + 100*i; … … 54 63 55 64 // add the columns to the output array 65 ok (gfits_set_bintable_column (&header, &ftable, "VAL", VAL, Nval), "set byte table column"); 56 66 ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short table column"); 57 67 ok (gfits_set_bintable_column (&header, &ftable, "ID", ID, Nval), "set int table column"); … … 84 94 off_t Nrow; 85 95 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"); 86 97 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"); 87 98 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"); … … 90 101 91 102 // count mismatched values 103 int Nvalue = 0; 92 104 int Nseq = 0; 93 105 int Nid = 0; … … 95 107 int Ny = 0; 96 108 for (i = 0; i < Nval; i++) { 109 if (VAL[i] != VAL_t[i]) Nvalue++; 97 110 if (SEQ[i] != SEQ_t[i]) Nseq++; 98 111 if ( ID[i] != ID_t[i]) Nid++; … … 101 114 } 102 115 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)"); 107 121 108 122 gfits_free_header (&header); … … 115 129 } 116 130 131 int 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.
