Changeset 26713
- Timestamp:
- Jan 28, 2010, 4:42:38 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/Ohana/src/libfits/table
- Files:
-
- 3 edited
-
F_define_column.c (modified) (1 diff)
-
F_get_column.c (modified) (4 diffs)
-
F_table_format.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/Ohana/src/libfits/table/F_define_column.c
r7054 r26713 23 23 sprintf (field, "TFORM%d", Nfields); 24 24 gfits_modify (header, field, "%s", 1, format); 25 sprintf (field, "TSCAL%d", Nfields); 26 gfits_modify (header, field, "%lf", 1, bscale); 27 sprintf (field, "TZERO%d", Nfields); 28 gfits_modify (header, field, "%lf", 1, bzero); 25 26 // add scaling parameters unless they amount to a noop 27 if ((bscale != 1.0) || (bzero != 0.0)) { 28 sprintf (field, "TSCAL%d", Nfields); 29 gfits_modify (header, field, "%lf", 1, bscale); 30 sprintf (field, "TZERO%d", Nfields); 31 gfits_modify (header, field, "%lf", 1, bzero); 32 } 29 33 30 34 /* update TFIELDS & NAXIS1 */ -
branches/eam_branches/20091201/Ohana/src/libfits/table/F_get_column.c
r16810 r26713 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 #include <inttypes.h> 3 4 # define SWAP_BYTE { \ 4 5 char tmp; \ … … 93 94 } 94 95 } 96 if (!strcmp (type, "int64_t")) { 97 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 98 # ifdef BYTE_SWAP 99 SWAP_DBLE; 100 # endif 101 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 102 } 103 } 95 104 if (!strcmp (type, "float")) { 96 105 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 218 227 # endif 219 228 *(int *)Pout = *(int *)Pin*Bscale + Bzero; 229 } 230 } 231 if (!strcmp (type, "int64_t")) { 232 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 233 # ifdef BYTE_SWAP 234 SWAP_DBLE; 235 # endif 236 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 220 237 } 221 238 } … … 349 366 } 350 367 } 368 if (!strcmp (type, "int64_t")) { 369 ALLOCATE (array, char, Ny*8); 370 Pout = array; 371 for (i = 0; i < Ny; i++, Pin+=Nx, Pout+=8) { 372 memcpy (line, Pin, Nval*Nbytes); 373 sscanf (line, "%" PRId64, (int64_t *)Pout); 374 } 375 } 351 376 if (!strcmp (type, "float")) { 352 377 ALLOCATE (array, char, Ny*4); -
branches/eam_branches/20091201/Ohana/src/libfits/table/F_table_format.c
r15487 r26713 17 17 18 18 *Nbytes = 0; 19 if (*Fchar == 'X') { *Nbytes = 1; strcpy (type, "char"); *Nval = 1 + (int) Nv / 8; } 20 if (*Fchar == 'L') { *Nbytes = 1; strcpy (type, "char"); *Nval = Nv; } 21 if (*Fchar == 'A') { *Nbytes = 1; strcpy (type, "char"); *Nval = Nv; } 22 if (*Fchar == 'B') { *Nbytes = 1; strcpy (type, "char"); *Nval = Nv; } 23 if (*Fchar == 'I') { *Nbytes = 2; strcpy (type, "short"); *Nval = Nv; } 24 if (*Fchar == 'J') { *Nbytes = 4; strcpy (type, "int"); *Nval = Nv; } 25 if (*Fchar == 'E') { *Nbytes = 4; strcpy (type, "float"); *Nval = Nv; } 26 if (*Fchar == 'D') { *Nbytes = 8; strcpy (type, "double"); *Nval = Nv; } 27 if (*Fchar == 'P') { *Nbytes = 8; strcpy (type, "var"); *Nval = 2*Nv; } 28 if (*Fchar == 'C') { *Nbytes = 8; strcpy (type, "float"); *Nval = 2*Nv; } 29 if (*Fchar == 'M') { *Nbytes = 16; strcpy (type, "double"); *Nval = 2*Nv; } 30 if (!*Nbytes) { return (FALSE); } 19 switch (*Fchar) { 20 case 'X': 21 { *Nbytes = 1; strcpy (type, "char"); *Nval = 1 + (int) Nv / 8; } 22 break; 23 case 'L': 24 { *Nbytes = 1; strcpy (type, "char"); *Nval = Nv; } 25 break; 26 case 'A': 27 { *Nbytes = 1; strcpy (type, "char"); *Nval = Nv; } 28 break; 29 case 'B': 30 { *Nbytes = 1; strcpy (type, "char"); *Nval = Nv; } 31 break; 32 case 'I': 33 { *Nbytes = 2; strcpy (type, "short"); *Nval = Nv; } 34 break; 35 case 'J': 36 { *Nbytes = 4; strcpy (type, "int"); *Nval = Nv; } 37 break; 38 case 'K': 39 { *Nbytes = 8; strcpy (type, "int64_t"); *Nval = Nv; } 40 break; 41 case 'E': 42 { *Nbytes = 4; strcpy (type, "float"); *Nval = Nv; } 43 break; 44 case 'D': 45 { *Nbytes = 8; strcpy (type, "double"); *Nval = Nv; } 46 break; 47 case 'P': 48 { *Nbytes = 8; strcpy (type, "var"); *Nval = 2*Nv; } 49 break; 50 case 'C': 51 { *Nbytes = 8; strcpy (type, "float"); *Nval = 2*Nv; } 52 break; 53 case 'M': 54 { *Nbytes = 16; strcpy (type, "double"); *Nval = 2*Nv; } 55 break; 56 default: 57 return (FALSE); 58 } 31 59 32 60 return (TRUE); … … 39 67 I - 16 bit int 40 68 J - 32 bit int 69 K - 64 bit int 41 70 A - char 42 71 E - float … … 199 228 short *tmpShort; 200 229 int *tmpInt; 230 int64_t *tmpInt64; 201 231 202 232 off = 0; … … 229 259 continue; 230 260 } 261 if ((tscale == 1.0) && (tzero == 0.0)) { 262 off += Nchar; 263 continue; 264 } 231 265 232 266 if (!strcmp (type, "char")) { … … 252 286 *tmpInt = *tmpInt * tscale + tzero; 253 287 } 288 } 289 } 290 if (!strcmp (type, "int64_t")) { 291 for (j = 0; j < Ny; j++) { 292 for (n = 0; n < Nval; n++) { 293 tmpInt64 = (int64_t *)&ftable[0].buffer[j*Nx + n*Nbytes + off]; 294 *tmpInt64 = *tmpInt64 * tscale + tzero; 295 } 254 296 } 255 297 } … … 269 311 short *tmpShort; 270 312 int *tmpInt; 313 int64_t *tmpInt64; 271 314 272 315 off = 0; … … 299 342 continue; 300 343 } 344 if ((tscale == 1.0) && (tzero == 0.0)) { 345 off += Nchar; 346 continue; 347 } 301 348 302 349 if (!strcmp (type, "char")) { … … 324 371 } 325 372 } 373 if (!strcmp (type, "int64_t")) { 374 for (j = 0; j < Ny; j++) { 375 for (n = 0; n < Nval; n++) { 376 tmpInt64 = (int64_t *)&ftable[0].buffer[j*Nx + n*Nbytes + off]; 377 *tmpInt64 = *tmpInt64 * tscale + tzero; 378 } 379 } 380 } 326 381 off += Nchar; 327 382 }
Note:
See TracChangeset
for help on using the changeset viewer.
