- Timestamp:
- Jun 4, 2015, 5:42:47 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
r38363 r38366 2 2 # include <gfitsio.h> 3 3 # include <zlib.h> 4 # define VERBOSE_DUMP 0 4 5 5 6 // the user needs to specify the various compression options: … … 36 37 37 38 int Ntile, ztilelast; 39 if (!ztilelen) ztilelen = srcheader->Naxis[1]; 40 38 41 if (srcheader->Naxis[1] % ztilelen) { 39 42 Ntile = srcheader->Naxis[1] / ztilelen + 1; … … 75 78 if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tformat_cmt)) ESCAPE; 76 79 77 // XXX this should depend on the field type, but for now just use a single type (GZIP_1)80 // for now we set all fields to the requested type 78 81 strcpy (fields[i].zctype, zcmptype); 79 82 … … 125 128 max_width = MAX(max_width, fields[i].rowsize); 126 129 130 // RICE can only be used on integer fields 131 if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) { 132 if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double")) { 133 strcpy (fields[i].zctype, "GZIP_2"); 134 } 135 } 136 127 137 // compression type per column (XXX for now we are just using zcmptype, as set above) 128 138 snprintf (keyword, 81, "ZCTYP%d", i+1); … … 152 162 153 163 // copy the raw pixels from their native matrix locations to the temporary output buffer 154 if (!strcasecmp(fields[ i].zctype, "GZIP_2")) {164 if (!strcasecmp(fields[j].zctype, "GZIP_2") || !strcasecmp(fields[j].zctype, "NONE_2")) { 155 165 if (!gfits_collect_table_gzp2 (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE; 156 166 } else { … … 158 168 } 159 169 170 if (VERBOSE_DUMP) { 171 int k; 172 fprintf (stderr, "c1: "); 173 for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) { 174 fprintf (stderr, "%02hhx", raw[k]); 175 if (k % 2) fprintf (stderr, " "); 176 // if (k % 32 == 31) fprintf (stderr, "\n"); 177 } 178 fprintf (stderr, "\n"); 179 } 180 160 181 // optname, optvalue = NULL, Noptions = 0 161 182 162 183 int Nraw = Nrows*fields[j].Nvalues; // number of pixels 163 if (!strc mp(fields[j].zctype, "GZIP_1")) {184 if (!strcasecmp(fields[j].zctype, "GZIP_1")) { 164 185 if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE; 186 } 187 188 if (VERBOSE_DUMP) { 189 int k; 190 fprintf (stderr, "c2: "); 191 for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) { 192 fprintf (stderr, "%02hhx", raw[k]); 193 if (k % 2) fprintf (stderr, " "); 194 // if (k % 32 == 31) fprintf (stderr, "\n"); 195 } 196 fprintf (stderr, "\n"); 165 197 } 166 198 … … 168 200 if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize, 0, 0)) ESCAPE; 169 201 170 if (strcasecmp(fields[j].zctype, "GZIP_1") && strcasecmp(fields[j].zctype, "GZIP_2") && strcasecmp(fields[j].zctype, "RICE_1")) { 202 if (VERBOSE_DUMP) { 203 int k; 204 fprintf (stderr, "c3: "); 205 for (k = 0; k < Nzdata; k++) { 206 fprintf (stderr, "%02hhx", zdata[k]); 207 if (k % 2) fprintf (stderr, " "); 208 // if (k % 32 == 31) fprintf (stderr, "\n"); 209 } 210 fprintf (stderr, "\n"); 211 } 212 213 if (strcasecmp(fields[j].zctype, "NONE") && 214 strcasecmp(fields[j].zctype, "NONE_2") && 215 strcasecmp(fields[j].zctype, "GZIP_1") && 216 strcasecmp(fields[j].zctype, "GZIP_2") && 217 strcasecmp(fields[j].zctype, "RICE_1") && 218 strcasecmp(fields[j].zctype, "RICE_ONE")) { 171 219 if (!gfits_byteswap_zdata (zdata, Nzdata, fields[j].pixsize)) ESCAPE; 220 } 221 222 if (VERBOSE_DUMP) { 223 int k; 224 fprintf (stderr, "c4: "); 225 for (k = 0; k < Nzdata; k++) { 226 fprintf (stderr, "%02hhx", zdata[k]); 227 if (k % 2) fprintf (stderr, " "); 228 // if (k % 32 == 31) fprintf (stderr, "\n"); 229 } 230 fprintf (stderr, "\n"); 172 231 } 173 232 … … 228 287 for (i = 0; i < Nrows; i++) { 229 288 int row = row_start + i; 230 char *tgt = &raw[i*field->rowsize + k*Nrows*field->Nvalues]; 231 char *src = &table->buffer[Nx*row + field->offset + k]; 232 for (j = 0; j < field->Nvalues; j++, tgt+=field->pixsize, src++) { 233 *tgt = *src; 234 myAssert (src - raw < field-> 289 char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues]; 290 # ifdef BYTE_SWAP 291 char *tblptr = &table->buffer[Nx*row + field->offset + (field->pixsize - k - 1)]; 292 # else 293 char *tblptr = &table->buffer[Nx*row + field->offset + k]; 294 # endif 295 for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) { 296 *rawptr = *tblptr; 297 myAssert (rawptr - raw < Nrows*field->Nvalues*field->pixsize, "oops"); 298 myAssert (tblptr - table->buffer < table->header->Naxis[0]*table->header->Naxis[1], "oops"); 235 299 } 236 300 }
Note:
See TracChangeset
for help on using the changeset viewer.
