Changeset 38341 for branches/eam_branches/ohana.20150429/src/opihi/cmd.data
- Timestamp:
- May 31, 2015, 8:36:04 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/opihi/cmd.data
- Files:
-
- 2 edited
-
read_vectors.c (modified) (7 diffs)
-
wd.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c
r38340 r38341 1 1 # include "data.h" 2 int dump_raw_table (FTable *table, char *message); 3 int dump_cmp_table (FTable *table, char *message); 2 4 3 5 FILE *f = (FILE *) NULL; … … 412 414 table.header = &header; 413 415 414 int IsCompressed = FALSE; 415 416 /* load appropriate extension (if extname is a number, use count) */ 416 /**** find the appropriate extension and read header (if extname is a number, use count) ****/ 417 417 if (Nextend > -1) { 418 418 // first extension is PHU, cannot be a table. … … 431 431 } 432 432 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend); 433 434 IsCompressed = gfits_extension_is_compressed_table (&header);435 436 if (getSizes && !IsCompressed) {437 read_table_sizes (&header);438 if (CCDKeyword != NULL) free (CCDKeyword);439 gfits_free_header (&header);440 return TRUE;441 }442 if (IsCompressed) {443 if (getSizes) {444 gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname);445 gfits_free_header (&header);446 return FALSE;447 }448 if ((start > 0) || (Nrows > -1)) {449 gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname);450 gfits_free_header (&header);451 return FALSE;452 }453 }454 455 if (Nrows == -1) {456 Nrows = header.Naxis[1] - start;457 }458 if (start < 0) ESCAPE ("invalid range: start < 0\n");459 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);460 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");461 462 // just a warning:463 if (start + Nrows > header.Naxis[1]) {464 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);465 }466 467 // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100468 // Ny = 100, start = 10, Nrows = 90469 470 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);471 433 } else { 472 434 if (CCDKeyword == NULL) { … … 476 438 CCDKeyword = strcreate ("EXTNAME"); 477 439 } 478 479 440 while (1) { 480 441 if (!gfits_load_header (f, &header)) { … … 485 446 return (TRUE); 486 447 } 487 488 448 Nbytes = gfits_data_size (&header); 489 449 … … 498 458 continue; 499 459 } 500 501 IsCompressed = gfits_extension_is_compressed_table (&header);502 503 if (getSizes && !IsCompressed) {504 read_table_sizes (&header);505 if (CCDKeyword != NULL) free (CCDKeyword);506 gfits_free_header (&header);507 return TRUE;508 }509 if (IsCompressed) {510 if (getSizes) {511 gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname);512 gfits_free_header (&header);513 return FALSE;514 }515 if ((start > 0) || (Nrows > -1)) {516 gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname);517 gfits_free_header (&header);518 return FALSE;519 }520 }521 522 if (Nrows == -1) {523 Nrows = header.Naxis[1] - start;524 }525 if (start < 0) ESCAPE ("invalid range: start < 0\n");526 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);527 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");528 529 // just a warning:530 if (start + Nrows > header.Naxis[1]) {531 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);532 }533 534 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);535 460 break; 536 461 } 462 } 463 464 int IsCompressed = gfits_extension_is_compressed_table (&header); 465 466 if (getSizes && !IsCompressed) { 467 read_table_sizes (&header); 468 if (CCDKeyword != NULL) free (CCDKeyword); 469 gfits_free_header (&header); 470 return TRUE; 471 } 472 if (IsCompressed) { 473 if (getSizes) { 474 gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname); 475 gfits_free_header (&header); 476 return FALSE; 477 } 478 if ((start > 0) || (Nrows > -1)) { 479 gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname); 480 gfits_free_header (&header); 481 return FALSE; 482 } 483 } 484 485 if (Nrows == -1) { 486 Nrows = header.Naxis[1] - start; 487 } 488 if (start < 0) ESCAPE ("invalid range: start < 0\n"); 489 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]); 490 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n"); 491 492 // just a warning: 493 if (start + Nrows > header.Naxis[1]) { 494 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start); 495 } 496 497 // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100 498 // Ny = 100, start = 10, Nrows = 90 499 500 if (IsCompressed) { 501 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 502 } else { 503 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); 537 504 } 538 505 … … 553 520 if (IsCompressed) { 554 521 rawtable.header = &rawheader; 522 523 dump_cmp_table (&table, "rd cmp"); 555 524 if (!gfits_uncompress_table (&table, &rawtable)) ESCAPE ("failed to uncompress table"); 525 dump_raw_table (&rawtable, "rd raw"); 526 556 527 outheader = &rawheader; 557 528 outtable = &rawtable; -
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/wd.c
r38340 r38341 3 3 int wd (int argc, char **argv) { 4 4 5 int N, Extend , Compress;5 int N, Extend; 6 6 int newUnsign, newBitpix, newScale, newZero; 7 7 int outUnsign, outBitpix; … … 18 18 } 19 19 20 Compress = FALSE;21 if ((N = get_argument (argc, argv, "-compress"))) {22 remove_argument (N, &argc, argv);23 Compress = TRUE;24 }25 26 20 char *CompressMode = NULL; 27 21 if ((N = get_argument (argc, argv, "-compress-mode"))) { … … 29 23 CompressMode = strcreate(argv[N]); 30 24 remove_argument (N, &argc, argv); 31 } 32 if (!CompressMode) CompressMode = strcreate("GZIP_1"); 25 } else if ((N = get_argument (argc, argv, "-compress"))) { 26 remove_argument (N, &argc, argv); 27 CompressMode = strcreate("GZIP_1"); 28 } 33 29 34 30 outZero = 0; … … 180 176 181 177 // not compatible with extend 182 if (Compress ) {178 if (CompressMode) { 183 179 Header myHeader; 184 180 Matrix myMatrix;
Note:
See TracChangeset
for help on using the changeset viewer.
