Changeset 36999
- Timestamp:
- Jul 11, 2014, 2:55:24 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140610/Ohana/src
- Files:
-
- 6 edited
-
libfits/table/F_get_column.c (modified) (1 diff)
-
libfits/table/F_set_column.c (modified) (9 diffs)
-
libfits/table/F_table_format.c (modified) (5 diffs)
-
opihi/cmd.data/read_vectors.c (modified) (10 diffs)
-
opihi/include/dvomath.h (modified) (1 diff)
-
opihi/lib.shell/VectorIO.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140610/Ohana/src/libfits/table/F_get_column.c
r36630 r36999 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; -
branches/eam_branches/ipp-20140610/Ohana/src/libfits/table/F_set_column.c
r35101 r36999 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) { -
branches/eam_branches/ipp-20140610/Ohana/src/libfits/table/F_table_format.c
r28241 r36999 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++) { -
branches/eam_branches/ipp-20140610/Ohana/src/opihi/cmd.data/read_vectors.c
r36941 r36999 321 321 } 322 322 323 # define ESCAPE( MSG) {\324 gprint (GP_ERR, "%s\n", MSG); \323 # define ESCAPE(...) { \ 324 gprint (GP_ERR, __VA_ARGS__); \ 325 325 if (CCDKeyword != NULL) free (CCDKeyword); \ 326 326 gfits_free_table (&table); \ … … 331 331 332 332 off_t Nbytes; 333 int i, j, k,N, Nextend, Ny, Binary, vecType, padIfShort;333 int i, j, N, Nextend, Ny, Binary, vecType, padIfShort; 334 334 char type[16], ID[80], *CCDKeyword; 335 335 FTable table; … … 374 374 // } 375 375 376 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ... ");377 378 if (f == NULL) ESCAPE ("file not found ");376 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...\n"); 377 378 if (f == NULL) ESCAPE ("file not found\n"); 379 379 fseeko (f, 0LL, SEEK_SET); 380 380 table.header = &header; … … 384 384 // first extension is PHU, cannot be a table. 385 385 // Nextend counts from 0 for first extension 386 if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file ");386 if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file\n"); 387 387 Nbytes = gfits_data_size (&header); 388 388 fseeko (f, Nbytes, SEEK_CUR); … … 390 390 391 391 for (i = 0; i < Nextend; i++) { 392 if (!gfits_load_header (f, &header)) ESCAPE ("extension not found");392 if (!gfits_load_header (f, &header)) ESCAPE ("extension %d not found\n", i); 393 393 Nbytes = gfits_data_size (&header); 394 394 /* skip the prior data buffers */ … … 396 396 gfits_free_header (&header); 397 397 } 398 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension ");399 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension ");398 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend); 399 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 400 400 401 401 } else { … … 428 428 continue; 429 429 } 430 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension ");430 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n"); 431 431 break; 432 432 } … … 437 437 gfits_scan (&header, "XTENSION", "%s", 1, type); 438 438 if (strcmp (type, "BINTABLE") && strcmp (type, "TABLE")) { 439 ESCAPE ("specified extension is not a table\n");439 ESCAPE ("specified extension %s is not a table\n", type); 440 440 } 441 441 Binary = !strcmp (type, "BINTABLE"); … … 497 497 } 498 498 499 if (!strcmp (type, "short")) { 500 short *Ptr = data; 501 for (j = 0; j < Ny; j++) { 502 for (k = 0; k < Nval; k++, Ptr++) { 503 vec[k][0].elements.Int[j] = *Ptr; 504 } 505 } 506 } 507 if (!strcmp (type, "int")) { 508 int *Ptr = data; 509 for (j = 0; j < Ny; j++) { 510 for (k = 0; k < Nval; k++, Ptr++) { 511 vec[k][0].elements.Int[j] = *Ptr; 512 } 513 } 514 } 515 if (!strcmp (type, "int64_t")) { 516 int64_t *Ptr = data; 517 for (j = 0; j < Ny; j++) { 518 for (k = 0; k < Nval; k++, Ptr++) { 519 vec[k][0].elements.Int[j] = *Ptr; 520 } 521 } 522 } 523 if (!strcmp (type, "float")) { 524 float *Ptr = data; 525 for (j = 0; j < Ny; j++) { 526 for (k = 0; k < Nval; k++, Ptr++) { 527 vec[k][0].elements.Flt[j] = *Ptr; 528 } 529 } 530 } 531 if (!strcmp (type, "double")) { 532 double *Ptr = data; 533 for (j = 0; j < Ny; j++) { 534 for (k = 0; k < Nval; k++, Ptr++) { 535 vec[k][0].elements.Flt[j] = *Ptr; 536 } 537 } 538 } 499 if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 500 539 501 } else { 540 502 // define the multifield vector names (Ny vectors x Nval elements) … … 549 511 } 550 512 551 if (!strcmp (type, "char")) { 552 char *Ptr = data; 553 for (j = 0; j < Ny; j++) { 554 for (k = 0; k < Nval; k++, Ptr++) { 555 vec[j][0].elements.Int[k] = *Ptr; 556 } 557 } 558 } 559 if (!strcmp (type, "short")) { 560 short *Ptr = data; 561 for (j = 0; j < Ny; j++) { 562 for (k = 0; k < Nval; k++, Ptr++) { 563 vec[j][0].elements.Int[k] = *Ptr; 564 } 565 } 566 } 567 if (!strcmp (type, "int")) { 568 int *Ptr = data; 569 for (j = 0; j < Ny; j++) { 570 for (k = 0; k < Nval; k++, Ptr++) { 571 vec[j][0].elements.Int[k] = *Ptr; 572 } 573 } 574 } 575 if (!strcmp (type, "int64_t")) { 576 int64_t *Ptr = data; 577 for (j = 0; j < Ny; j++) { 578 for (k = 0; k < Nval; k++, Ptr++) { 579 vec[j][0].elements.Int[k] = *Ptr; 580 } 581 } 582 } 583 if (!strcmp (type, "float")) { 584 float *Ptr = data; 585 for (j = 0; j < Ny; j++) { 586 for (k = 0; k < Nval; k++, Ptr++) { 587 vec[j][0].elements.Flt[k] = *Ptr; 588 } 589 } 590 } 591 if (!strcmp (type, "double")) { 592 double *Ptr = data; 593 for (j = 0; j < Ny; j++) { 594 for (k = 0; k < Nval; k++, Ptr++) { 595 vec[j][0].elements.Flt[k] = *Ptr; 596 } 597 } 598 } 513 if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 599 514 } 600 515 free (data); -
branches/eam_branches/ipp-20140610/Ohana/src/opihi/include/dvomath.h
r36375 r36999 170 170 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 171 171 172 int VectorAssignData PROTO((Vector **vec, char *type, void *data, int Nrows, int Nval)); 173 int VectorAssignDataTranspose PROTO((Vector **vec, char *type, void *data, int Nrows, int Nval)); 174 172 175 /* buffer handling */ 173 176 Buffer *InitBuffer PROTO((void)); -
branches/eam_branches/ipp-20140610/Ohana/src/opihi/lib.shell/VectorIO.c
r35109 r36999 134 134 FTable ftable; 135 135 136 int i, j , k;136 int i, j; 137 137 FILE *f = NULL; 138 138 … … 202 202 assert (status); 203 203 204 # define ASSIGN_DATA(TYPE,OPTYPE) \ 205 /* assign the data to the actual vector */ \ 206 if (!strcmp (type, #TYPE)) { \ 207 TYPE *Ptr = data; \ 208 for (k = 0; k < Nrows; k++) { \ 209 for (j = 0; j < Nval; j++, Ptr++) { \ 210 vec[Nvec + j][0].elements.OPTYPE[k] = *Ptr; \ 211 } } } 212 213 // assign the data to the actual vector 214 ASSIGN_DATA(char, Int); 215 ASSIGN_DATA(short, Int); 216 ASSIGN_DATA(int, Int); 217 ASSIGN_DATA(int64_t, Int); 218 ASSIGN_DATA(float, Flt); 219 ASSIGN_DATA(double, Flt); 204 if (!VectorAssignData(&vec[Nvec], type, data, Nrows, Nval)) { 205 // free unneeded things 206 gprint (GP_ERR, "trouble parsing data block type %s\n", type); 207 return (NULL); 208 } 220 209 221 210 free (data); … … 241 230 // return (FALSE); 242 231 } 232 233 # define ASSIGN_DATA(TYPE,DTYPE,OPTYPE) \ 234 /* assign the data to the actual vector */ \ 235 if (!strcmp (type, #TYPE)) { \ 236 DTYPE *Ptr = data; \ 237 for (k = 0; k < Nrows; k++) { \ 238 for (j = 0; j < Nval; j++, Ptr++) { \ 239 vec[j][0].elements.OPTYPE[k] = *Ptr; \ 240 } } return TRUE; } 241 242 int VectorAssignData (Vector **vec, char *type, void *data, int Nrows, int Nval) { 243 244 int j, k; 245 246 // assign the data to the actual vector 247 ASSIGN_DATA(byte, char, Int); 248 ASSIGN_DATA(char, char, Int); 249 ASSIGN_DATA(short, short, Int); 250 ASSIGN_DATA(int, int, Int); 251 ASSIGN_DATA(int64_t, int64_t, Int); 252 ASSIGN_DATA(float, float, Flt); 253 ASSIGN_DATA(double, double, Flt); 254 255 return FALSE; 256 } 257 258 # define ASSIGN_DATA_TRANSPOSE(TYPE,DTYPE,OPTYPE) \ 259 /* assign the data to the actual vector */ \ 260 if (!strcmp (type, #TYPE)) { \ 261 DTYPE *Ptr = data; \ 262 for (k = 0; k < Nrows; k++) { \ 263 for (j = 0; j < Nval; j++, Ptr++) { \ 264 vec[k][0].elements.OPTYPE[j] = *Ptr; \ 265 } } return TRUE; } 266 267 int VectorAssignDataTranspose (Vector **vec, char *type, void *data, int Nrows, int Nval) { 268 269 int j, k; 270 271 // assign the data to the actual vector 272 ASSIGN_DATA_TRANSPOSE(byte, char, Int); 273 ASSIGN_DATA_TRANSPOSE(char, char, Int); 274 ASSIGN_DATA_TRANSPOSE(short, short, Int); 275 ASSIGN_DATA_TRANSPOSE(int, int, Int); 276 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Int); 277 ASSIGN_DATA_TRANSPOSE(float, float, Flt); 278 ASSIGN_DATA_TRANSPOSE(double, double, Flt); 279 280 return FALSE; 281 }
Note:
See TracChangeset
for help on using the changeset viewer.
