Changeset 37039
- Timestamp:
- Jul 17, 2014, 10:14:43 AM (12 years ago)
- Location:
- trunk/Ohana/src/libfits
- Files:
-
- 4 edited
-
include/gfitsio.h (modified) (1 diff)
-
table/F_get_column.c (modified) (1 diff)
-
table/F_set_column.c (modified) (9 diffs)
-
table/F_table_format.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/include/gfitsio.h
r35756 r37039 27 27 # define FT_RECORD_SIZE 2880 /* FITS block size */ 28 28 29 # define FT_BZERO_INT8 -1.0*0x80 29 30 # define FT_BZERO_INT16 1.0*0x8000 30 31 # define FT_BZERO_INT32 1.0*0x80000000 32 # define FT_BZERO_INT64 1.0*0x8000000000000000 31 33 32 34 /* this structure defines the buffer which contains a header -
trunk/Ohana/src/libfits/table/F_get_column.c
r36630 r37039 75 75 Pout = array; 76 76 if (!strcmp (type, "char")) { 77 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 78 *(char *)Pout = *(char *)Pin*Bscale + Bzero; 79 } 80 } 81 if (!strcmp (type, "byte")) { 77 82 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 78 83 *(char *)Pout = *(char *)Pin*Bscale + Bzero; -
trunk/Ohana/src/libfits/table/F_set_column.c
r35101 r37039 81 81 Pin = data; 82 82 Pout = array; 83 // does it makes sense to scale 'char' data? 83 84 if (!strcmp (type, "char")) { 85 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 86 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 87 } 88 } 89 if (!strcmp (type, "byte")) { 84 90 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 85 91 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; … … 221 227 Pout = array; 222 228 229 // # define ASSIGN_DATA(ITYPE,INAME,ISIZE,OTYPE,ONAME) 230 // if (!strcmp (intype, #ITYPE)) { 231 223 232 /** input == char **/ 224 233 if (!strcmp (outtype, "char") && !strcmp (intype, "char")) { … … 228 237 } 229 238 } 239 if (!strcmp (outtype, "byte") && !strcmp (intype, "char")) { 240 int NbytesIn = 1; 241 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 242 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 243 } 244 } 230 245 if (!strcmp (outtype, "short") && !strcmp (intype, "char")) { 231 246 int NbytesIn = 1; … … 265 280 } 266 281 if (!strcmp (outtype, "double") && !strcmp (intype, "char")) { 282 int NbytesIn = 1; 283 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 284 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 285 # ifdef BYTE_SWAP 286 SWAP_DBLE; 287 # endif 288 } 289 } 290 291 /** input == byte **/ 292 if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) { 293 int NbytesIn = 1; 294 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 295 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 296 } 297 } 298 if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) { 299 int NbytesIn = 1; 300 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 301 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 302 } 303 } 304 if (!strcmp (outtype, "short") && !strcmp (intype, "byte")) { 305 int NbytesIn = 1; 306 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 307 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 308 # ifdef BYTE_SWAP 309 SWAP_BYTE; 310 # endif 311 } 312 } 313 if (!strcmp (outtype, "int") && !strcmp (intype, "byte")) { 314 int NbytesIn = 1; 315 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 316 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 317 # ifdef BYTE_SWAP 318 SWAP_WORD; 319 # endif 320 } 321 } 322 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "byte")) { 323 int NbytesIn = 1; 324 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 325 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 326 # ifdef BYTE_SWAP 327 SWAP_DBLE; 328 # endif 329 } 330 } 331 if (!strcmp (outtype, "float") && !strcmp (intype, "byte")) { 332 int NbytesIn = 1; 333 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 334 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 335 # ifdef BYTE_SWAP 336 SWAP_WORD; 337 # endif 338 } 339 } 340 if (!strcmp (outtype, "double") && !strcmp (intype, "byte")) { 267 341 int NbytesIn = 1; 268 342 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { … … 281 355 } 282 356 } 357 if (!strcmp (outtype, "byte") && !strcmp (intype, "short")) { 358 int NbytesIn = 2; 359 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 360 *(char *)Pout = (*(short *)Pin - Bzero) / Bscale; 361 } 362 } 283 363 if (!strcmp (outtype, "short") && !strcmp (intype, "short")) { 284 364 int NbytesIn = 2; … … 334 414 } 335 415 } 416 if (!strcmp (outtype, "byte") && !strcmp (intype, "int")) { 417 int NbytesIn = 4; 418 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 419 *(char *)Pout = (*(int *)Pin - Bzero) / Bscale; 420 } 421 } 336 422 if (!strcmp (outtype, "short") && !strcmp (intype, "int")) { 337 423 int NbytesIn = 4; … … 387 473 } 388 474 } 475 if (!strcmp (outtype, "byte") && !strcmp (intype, "int64_t")) { 476 int NbytesIn = 8; 477 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 478 *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 479 } 480 } 389 481 if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) { 390 482 int NbytesIn = 8; … … 440 532 } 441 533 } 534 if (!strcmp (outtype, "byte") && !strcmp (intype, "float")) { 535 int NbytesIn = 4; 536 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 537 *(char *)Pout = (*(float *)Pin - Bzero) / Bscale; 538 } 539 } 442 540 if (!strcmp (outtype, "short") && !strcmp (intype, "float")) { 443 541 int NbytesIn = 4; … … 488 586 /** input == double **/ 489 587 if (!strcmp (outtype, "char") && !strcmp (intype, "double")) { 588 int NbytesIn = 8; 589 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 590 *(char *)Pout = (*(double *)Pin - Bzero) / Bscale; 591 } 592 } 593 if (!strcmp (outtype, "byte") && !strcmp (intype, "double")) { 490 594 int NbytesIn = 8; 491 595 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { -
trunk/Ohana/src/libfits/table/F_table_format.c
r28241 r37039 19 19 if ((Nv == 0) && (Fchar == format)) Nv = 1; 20 20 21 // NOTE: X, L, B all are stored in 1-byte columns (X by default has at least room for 8 bits) 22 // I report these as type 'byte' as opposed to 'char', which is interpreted as a string 23 21 24 *Nbytes = 0; 22 25 switch (*Fchar) { 23 26 case 'X': 24 { *Nbytes = 1; strcpy (type, " char"); *Nval = 1 + (int) Nv / 8; }27 { *Nbytes = 1; strcpy (type, "byte"); *Nval = 1 + (int) Nv / 8; } 25 28 break; 26 29 case 'L': 27 { *Nbytes = 1; strcpy (type, " char"); *Nval = Nv; }30 { *Nbytes = 1; strcpy (type, "byte"); *Nval = Nv; } 28 31 break; 29 32 case 'A': … … 31 34 break; 32 35 case 'B': 33 { *Nbytes = 1; strcpy (type, " char"); *Nval = Nv; }36 { *Nbytes = 1; strcpy (type, "byte"); *Nval = Nv; } 34 37 break; 35 38 case 'I': … … 268 271 } 269 272 273 // Does it make sense to scale 'char' data (as opposed to 'byte')? 270 274 if (!strcmp (type, "char")) { 275 for (j = 0; j < Ny; j++) { 276 for (n = 0; n < Nval; n++) { 277 tmpChar = (char *)&ftable[0].buffer[j*Nx + n*Nbytes + off]; 278 *tmpChar = *tmpChar * tscale + tzero; 279 } 280 } 281 } 282 if (!strcmp (type, "byte")) { 271 283 for (j = 0; j < Ny; j++) { 272 284 for (n = 0; n < Nval; n++) { … … 352 364 } 353 365 366 // does this make sense? (see note above) 354 367 if (!strcmp (type, "char")) { 355 368 for (j = 0; j < Ny; j++) { … … 360 373 } 361 374 } 375 if (!strcmp (type, "byte")) { 376 for (j = 0; j < Ny; j++) { 377 for (n = 0; n < Nval; n++) { 378 tmpChar = (char *)&ftable[0].buffer[j*Nx + n*Nbytes + off]; 379 *tmpChar = (*tmpChar - tzero) / tscale; 380 } 381 } 382 } 362 383 if (!strcmp (type, "short")) { 363 384 for (j = 0; j < Ny; j++) {
Note:
See TracChangeset
for help on using the changeset viewer.
