Changeset 12391
- Timestamp:
- Mar 9, 2007, 3:19:11 PM (19 years ago)
- Location:
- trunk/Ohana/src/libdvo/src
- Files:
-
- 3 edited
-
dvo_catalog_mef.c (modified) (6 diffs)
-
dvo_catalog_raw.c (modified) (4 diffs)
-
dvo_catalog_split.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
r12332 r12391 170 170 } 171 171 172 /* make sure header is consistent with data */173 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage);174 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure);175 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing);176 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);177 gfits_modify (&catalog[0].header, "EXTEND", "%t", 1, TRUE);178 179 f = catalog[0].f;180 /* rewind file pointers and truncate */181 fseek (f, 0, SEEK_SET);182 ftruncate (fileno (catalog[0].f), 0);183 ftable.header = &header;184 185 /* write table PHU header */186 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) {187 fprintf (stderr, "can't write primary header");188 return (FALSE);189 }190 191 /* this is probably a NOP, do I have to keep it in? */192 gfits_create_matrix (&catalog[0].header, &matrix);193 if (!gfits_fwrite_matrix (catalog[0].f, &matrix)) {194 fprintf (stderr, "can't write primary matrix");195 return (FALSE);196 }197 gfits_free_matrix (&matrix);198 199 172 /* for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary */ 200 173 if ((catalog[0].catformat == DVO_FORMAT_ELIXIR) || // special case for ELIXIR … … 218 191 } 219 192 193 /* make sure header is consistent with data */ 194 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage); 195 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure); 196 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing); 197 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 198 gfits_modify (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 199 200 f = catalog[0].f; 201 /* rewind file pointers and truncate */ 202 fseek (f, 0, SEEK_SET); 203 ftruncate (fileno (catalog[0].f), 0); 204 ftable.header = &header; 205 206 /* write table PHU header */ 207 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) { 208 fprintf (stderr, "can't write primary header"); 209 goto failure; 210 } 211 212 /* this is probably a NOP, do I have to keep it in? */ 213 gfits_create_matrix (&catalog[0].header, &matrix); 214 if (!gfits_fwrite_matrix (catalog[0].f, &matrix)) { 215 fprintf (stderr, "can't write primary matrix"); 216 goto failure; 217 } 218 gfits_free_matrix (&matrix); 219 220 220 /* write out Average table (convert to FITS table format) */ 221 221 AverageToFtable (&ftable, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary); 222 222 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 223 223 fprintf (stderr, "can't write table header"); 224 return (FALSE);224 goto failure; 225 225 } 226 226 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 227 227 fprintf (stderr, "can't write table data"); 228 return (FALSE);228 goto failure; 229 229 } 230 230 gfits_free_table (&ftable); … … 235 235 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 236 236 fprintf (stderr, "can't write table header"); 237 return (FALSE);237 goto failure; 238 238 } 239 239 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 240 240 fprintf (stderr, "can't write table data"); 241 return (FALSE);241 goto failure; 242 242 } 243 243 gfits_free_table (&ftable); … … 248 248 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 249 249 fprintf (stderr, "can't write table header"); 250 return (FALSE);250 goto failure; 251 251 } 252 252 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 253 253 fprintf (stderr, "can't write table data"); 254 return (FALSE);254 goto failure; 255 255 } 256 256 gfits_free_table (&ftable); … … 262 262 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 263 263 fprintf (stderr, "can't write table header"); 264 return (FALSE);264 goto failure; 265 265 } 266 266 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 267 267 fprintf (stderr, "can't write table data"); 268 return (FALSE);268 goto failure; 269 269 } 270 270 gfits_free_table (&ftable); … … 276 276 free (secfilt); 277 277 } 278 279 278 return (TRUE); 279 280 failure: 281 /* free temp storage */ 282 if (primary != NULL) { 283 free (primary); 284 free (secfilt); 285 } 286 return (FALSE); 280 287 } 281 288 -
trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c
r12332 r12391 230 230 } 231 231 232 /* make sure header is consistent with data */233 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage);234 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure);235 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing);236 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);237 238 /* specify the appropriate data format */239 if (catalog[0].catformat == DVO_FORMAT_INTERNAL) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "INTERNAL");240 if (catalog[0].catformat == DVO_FORMAT_LONEOS) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "LONEOS");241 if (catalog[0].catformat == DVO_FORMAT_ELIXIR) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "ELIXIR");242 if (catalog[0].catformat == DVO_FORMAT_PANSTARRS_DEV_0) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS_DEV_0");243 // if (catalog[0].catformat == DVO_FORMAT_PANSTARRS) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS");244 // if (catalog[0].catformat == DVO_FORMAT_PMTEST) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PMTEST");245 246 /* rewind file pointers and truncate file */247 f = catalog[0].f;248 fseek (f, 0, SEEK_SET);249 ftruncate (fileno (catalog[0].f), 0);250 251 /* write header data (use gfits_write_header?) */252 nitems = fwrite (catalog[0].header.buffer, 1, catalog[0].header.size, f);253 if (nitems != catalog[0].header.size) {254 if (VERBOSE) fprintf (stderr, "failed to write header\n");255 return (FALSE);256 }257 258 232 /* for the appropriate types, pull out the first secfilt and pass to WriteRawAverage as primary */ 259 233 if ((catalog[0].catformat == DVO_FORMAT_ELIXIR) || // special case for ELIXIR … … 277 251 } 278 252 253 /* make sure header is consistent with data */ 254 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage); 255 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure); 256 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing); 257 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt); 258 259 /* specify the appropriate data format */ 260 if (catalog[0].catformat == DVO_FORMAT_INTERNAL) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "INTERNAL"); 261 if (catalog[0].catformat == DVO_FORMAT_LONEOS) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "LONEOS"); 262 if (catalog[0].catformat == DVO_FORMAT_ELIXIR) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "ELIXIR"); 263 if (catalog[0].catformat == DVO_FORMAT_PANSTARRS_DEV_0) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS_DEV_0"); 264 // if (catalog[0].catformat == DVO_FORMAT_PANSTARRS) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS"); 265 // if (catalog[0].catformat == DVO_FORMAT_PMTEST) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PMTEST"); 266 267 /* rewind file pointers and truncate file */ 268 f = catalog[0].f; 269 fseek (f, 0, SEEK_SET); 270 ftruncate (fileno (catalog[0].f), 0); 271 272 /* write header data (use gfits_write_header?) */ 273 nitems = fwrite (catalog[0].header.buffer, 1, catalog[0].header.size, f); 274 if (nitems != catalog[0].header.size) { 275 if (VERBOSE) fprintf (stderr, "failed to write header\n"); 276 goto failure; 277 } 278 279 279 /* write averages and measures */ 280 280 WriteRawAverage (f, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary); … … 287 287 if (nitems != Nitems) { 288 288 if (VERBOSE) fprintf (stderr, "failed to write catalog file missing %s\n", catalog[0].filename); 289 return (FALSE);289 goto failure; 290 290 } 291 291 … … 298 298 free (secfilt); 299 299 } 300 301 300 return (TRUE); 301 302 failure: 303 /* free temp storage */ 304 if (primary != NULL) { 305 free (primary); 306 free (secfilt); 307 } 308 return (FALSE); 302 309 } 303 310 -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r12332 r12391 298 298 } 299 299 300 /* make sure header is consistent with data */301 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage);302 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure);303 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing);304 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);305 gfits_modify (&catalog[0].header, "EXTEND", "%t", 1, TRUE);306 307 /* rewind file pointers and truncate (file is still open) */308 fseek (catalog[0].f, 0, SEEK_SET);309 310 /* write table PHU header - always write this out */311 /* XXX EAM : check if disk file size has changed */312 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) {313 fprintf (stderr, "can't write primary header");314 return (FALSE);315 }316 317 /* in split mode, we can save only part of the data */318 319 300 /* for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary */ 320 301 if ((catalog[0].catformat == DVO_FORMAT_ELIXIR) || // special case for ELIXIR … … 344 325 } 345 326 327 /* make sure header is consistent with data */ 328 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage); 329 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure); 330 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing); 331 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 332 gfits_modify (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 333 334 /* rewind file pointers and truncate (file is still open) */ 335 fseek (catalog[0].f, 0, SEEK_SET); 336 337 /* write table PHU header - always write this out */ 338 /* XXX EAM : check if disk file size has changed */ 339 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) { 340 fprintf (stderr, "can't write primary header"); 341 goto failure; 342 } 343 344 /* in split mode, we can save only part of the data */ 345 346 346 /*** Average Table ***/ 347 347 … … 353 353 if (!gfits_fwrite_matrix (catalog[0].f, &matrix)) { 354 354 fprintf (stderr, "can't write primary matrix"); 355 return (FALSE);355 goto failure; 356 356 } 357 357 gfits_free_matrix (&matrix); … … 361 361 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 362 362 fprintf (stderr, "can't write table header"); 363 return (FALSE);363 goto failure; 364 364 } 365 365 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 366 366 fprintf (stderr, "can't write table data"); 367 return (FALSE);367 goto failure; 368 368 } 369 369 gfits_free_table (&ftable); … … 390 390 if (!gfits_fwrite_header (catfile[0].f, &catfile[0].header)) { 391 391 fprintf (stderr, "can't write primary header"); 392 return (FALSE);392 goto failure; 393 393 } 394 394 … … 397 397 if (!gfits_fwrite_matrix (catfile[0].f, &matrix)) { 398 398 fprintf (stderr, "can't write primary matrix"); 399 return (FALSE);399 goto failure; 400 400 } 401 401 gfits_free_matrix (&matrix); … … 405 405 if (!gfits_fwrite_Theader (catfile[0].f, &header)) { 406 406 fprintf (stderr, "can't write table header"); 407 return (FALSE);407 goto failure; 408 408 } 409 409 if (!gfits_fwrite_table (catfile[0].f, &ftable)) { 410 410 fprintf (stderr, "can't write table data"); 411 return (FALSE);411 goto failure; 412 412 } 413 413 gfits_free_table (&ftable); … … 428 428 if (!gfits_fwrite_header (catfile[0].f, &catfile[0].header)) { 429 429 fprintf (stderr, "can't write primary header"); 430 return (FALSE);430 goto failure; 431 431 } 432 432 … … 435 435 if (!gfits_fwrite_matrix (catfile[0].f, &matrix)) { 436 436 fprintf (stderr, "can't write primary matrix"); 437 return (FALSE);437 goto failure; 438 438 } 439 439 gfits_free_matrix (&matrix); … … 443 443 if (!gfits_fwrite_Theader (catfile[0].f, &header)) { 444 444 fprintf (stderr, "can't write table header"); 445 return (FALSE);445 goto failure; 446 446 } 447 447 if (!gfits_fwrite_table (catfile[0].f, &ftable)) { 448 448 fprintf (stderr, "can't write table data"); 449 return (FALSE);449 goto failure; 450 450 } 451 451 gfits_free_table (&ftable); … … 466 466 if (!gfits_fwrite_header (catfile[0].f, &catfile[0].header)) { 467 467 fprintf (stderr, "can't write primary header"); 468 return (FALSE);468 goto failure; 469 469 } 470 470 … … 473 473 if (!gfits_fwrite_matrix (catfile[0].f, &matrix)) { 474 474 fprintf (stderr, "can't write primary matrix"); 475 return (FALSE);475 goto failure; 476 476 } 477 477 gfits_free_matrix (&matrix); … … 482 482 if (!gfits_fwrite_Theader (catfile[0].f, &header)) { 483 483 fprintf (stderr, "can't write table header"); 484 return (FALSE);484 goto failure; 485 485 } 486 486 if (!gfits_fwrite_table (catfile[0].f, &ftable)) { 487 487 fprintf (stderr, "can't write table data"); 488 return (FALSE);488 goto failure; 489 489 } 490 490 gfits_free_table (&ftable); … … 499 499 500 500 return (TRUE); 501 502 failure: 503 /* free temp storage */ 504 if (primary != NULL) { 505 free (primary); 506 free (secfilt); 507 } 508 return (FALSE); 501 509 } 502 510 … … 524 532 if (VERBOSE) fprintf (stderr, "no stars in catalog, skipping\n"); 525 533 return (TRUE); 526 }527 528 /* make sure header is consistent with data */529 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage);530 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure + catalog[0].Nmeas_off);531 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing);532 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);533 gfits_modify (&catalog[0].header, "EXTEND", "%t", 1, TRUE);534 535 /* rewind file pointers and truncate (file is still open) */536 fseek (catalog[0].f, 0, SEEK_SET);537 538 /* write table PHU header - always write this out */539 /* XXX EAM : check if disk file size has changed */540 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) {541 fprintf (stderr, "can't write primary header");542 return (FALSE);543 534 } 544 535 … … 570 561 } 571 562 563 /* make sure header is consistent with data */ 564 gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage); 565 gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure + catalog[0].Nmeas_off); 566 gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing); 567 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 568 gfits_modify (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 569 570 /* rewind file pointers and truncate (file is still open) */ 571 fseek (catalog[0].f, 0, SEEK_SET); 572 573 /* write table PHU header - always write this out */ 574 /* XXX EAM : check if disk file size has changed */ 575 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) { 576 fprintf (stderr, "can't write primary header"); 577 goto failure; 578 } 579 572 580 /*** Average Table ***/ 573 581 if (catalog[0].average != NULL) { … … 587 595 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 588 596 fprintf (stderr, "can't write table header"); 589 return (FALSE);597 goto failure; 590 598 } 591 599 if (!gfits_fwrite_vtable (catalog[0].f, &vtable)) { 592 600 fprintf (stderr, "can't write table data"); 593 return (FALSE);601 goto failure; 594 602 } 595 603 gfits_free_vtable (&vtable); … … 637 645 if (!gfits_fwrite_Theader (catfile[0].f, &header)) { 638 646 fprintf (stderr, "can't write table header"); 639 return (FALSE);647 goto failure; 640 648 } 641 649 if (!gfits_fwrite_vtable (catfile[0].f, &vtable)) { 642 650 fprintf (stderr, "can't write table data"); 643 return (FALSE);651 goto failure; 644 652 } 645 653 gfits_free_vtable (&vtable); … … 663 671 if (!gfits_fwrite_header (catfile[0].f, &catfile[0].header)) { 664 672 fprintf (stderr, "can't write primary header"); 665 return (FALSE);673 goto failure; 666 674 } 667 675 … … 670 678 if (!gfits_fwrite_matrix (catfile[0].f, &matrix)) { 671 679 fprintf (stderr, "can't write primary matrix"); 672 return (FALSE);680 goto failure; 673 681 } 674 682 gfits_free_matrix (&matrix); … … 678 686 if (!gfits_fwrite_Theader (catfile[0].f, &header)) { 679 687 fprintf (stderr, "can't write table header"); 680 return (FALSE);688 goto failure; 681 689 } 682 690 if (!gfits_fwrite_table (catfile[0].f, &ftable)) { 683 691 fprintf (stderr, "can't write table data"); 684 return (FALSE);692 goto failure; 685 693 } 686 694 gfits_free_table (&ftable); … … 709 717 if (!gfits_fwrite_Theader (catfile[0].f, &header)) { 710 718 fprintf (stderr, "can't write table header"); 711 return (FALSE);719 goto failure; 712 720 } 713 721 if (!gfits_fwrite_vtable (catfile[0].f, &vtable)) { 714 722 fprintf (stderr, "can't write table data"); 715 return (FALSE);723 goto failure; 716 724 } 717 725 gfits_free_vtable (&vtable); … … 727 735 728 736 return (TRUE); 737 738 failure: 739 /* free temp storage */ 740 if (primary != NULL) { 741 free (primary); 742 free (secfilt); 743 } 744 return (FALSE); 729 745 } 730 746
Note:
See TracChangeset
for help on using the changeset viewer.
