Changeset 5462 for trunk/archive/scripts/src/phase2/papPhase2.c
- Timestamp:
- Nov 2, 2005, 3:30:32 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/archive/scripts/src/phase2/papPhase2.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/scripts/src/phase2/papPhase2.c
r5371 r5462 250 250 overscanFitType = PM_FIT_SPLINE; 251 251 int order = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER"); // Order of polynomial fit 252 // overscanFit = psSpline1DAlloc(order, PS_POLYNOMIAL_ORD); 252 overscanFit = NULL; 253 // overscanFit = psSpline1DAlloc(); 253 254 } else if (strcasecmp(fit, "NONE") != 0) { 254 255 psLogMsg("phase2", PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:" … … 292 293 293 294 // Read in the input pixels 295 psLogMsg("phase2", PS_LOG_INFO, "Opening input image: %s\n", inputName); 294 296 if (! pmFPARead(input, inputFile, header, database)) { 295 297 psErrorStackPrint(stderr, "Unable to populate camera from FITS file: %s\n", inputName); … … 316 318 exit(EXIT_FAILURE); 317 319 } 320 psLogMsg("phase2", PS_LOG_INFO, "Opening bias image: %s\n", biasName); 321 if (! pmFPARead(bias, biasFile, biasHeader, database)) { 322 psErrorStackPrint(stderr, "Unable to populate bias camera from fits FITS: %s\n", biasName); 323 exit(EXIT_FAILURE); 324 } 318 325 psFree(biasHeader); 319 if (! pmFPARead(bias, biasFile, NULL, database)) {320 psErrorStackPrint(stderr, "Unable to populate bias camera from fits FITS: %s\n", biasName);321 exit(EXIT_FAILURE);322 }323 326 #ifdef PRODUCTION 324 327 psFitsClose(biasFile); … … 339 342 exit(EXIT_FAILURE); 340 343 } 344 psLogMsg("phase2", PS_LOG_INFO, "Opening dark image: %s\n", darkName); 345 if (! pmFPARead(dark, darkFile, darkHeader, database)) { 346 psErrorStackPrint(stderr, "Unable to populate dark camera from fits FITS: %s\n", darkName); 347 exit(EXIT_FAILURE); 348 } 341 349 psFree(darkHeader); 342 if (! pmFPARead(dark, darkFile, NULL, database)) {343 psErrorStackPrint(stderr, "Unable to populate dark camera from fits FITS: %s\n", darkName);344 exit(EXIT_FAILURE);345 }346 350 #ifdef PRODUCTION 347 351 psFitsClose(darkFile); … … 362 366 exit(EXIT_FAILURE); 363 367 } 368 psLogMsg("phase2", PS_LOG_INFO, "Opening mask image: %s\n", maskName); 369 if (! pmFPARead(mask, maskFile, maskHeader, database)) { 370 psErrorStackPrint(stderr, "Unable to populate mask camera from fits FITS: %s\n", maskName); 371 exit(EXIT_FAILURE); 372 } 364 373 psFree(maskHeader); 365 if (! pmFPARead(mask, maskFile, NULL, database)) { 366 psErrorStackPrint(stderr, "Unable to populate mask camera from fits FITS: %s\n", maskName); 367 exit(EXIT_FAILURE); 368 } 374 369 375 #ifdef PRODUCTION 370 376 psFitsClose(maskFile); … … 380 386 psFits *flatFile = psFitsAlloc(flatName); 381 387 #endif 388 if (! flatFile) { 389 psErrorStackPrint(stderr, "Can't open flat image: %s\n", flatName); 390 exit(EXIT_FAILURE); 391 } 382 392 psMetadata *flatHeader = psFitsReadHeader(NULL, flatFile); // FITS header for flat 383 393 if (! pmConfigValidateCamera(camera, flatHeader)) { … … 385 395 exit(EXIT_FAILURE); 386 396 } 397 psLogMsg("phase2", PS_LOG_INFO, "Opening flat image: %s\n", flatName); 398 if (! pmFPARead(flat, flatFile, flatHeader, database)) { 399 psErrorStackPrint(stderr, "Unable to populate flat camera from fits FITS: %s\n", flatName); 400 exit(EXIT_FAILURE); 401 } 387 402 psFree(flatHeader); 388 if (! pmFPARead(flat, flatFile, NULL, database)) {389 psErrorStackPrint(stderr, "Unable to populate flat camera from fits FITS: %s\n", flatName);390 exit(EXIT_FAILURE);391 }392 403 #ifdef PRODUCTION 393 404 psFitsClose(flatFile); … … 499 510 } else { 500 511 switch (dataItem->type) { 501 case PS_ META_VEC:512 case PS_DATA_VECTOR: 502 513 { 503 514 // These are the polynomial coefficients … … 518 529 } 519 530 break; 520 case PS_ META_STR:531 case PS_DATA_STRING: 521 532 { 522 533 // This is a filename … … 536 547 } 537 548 break; 538 case PS_ META_META:549 case PS_DATA_METADATA: 539 550 { 540 551 // This is a menu … … 550 561 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " 551 562 "for non-linearity correction --- ignored.\n", concept); 552 } else if (conceptValueItem->type != PS_ META_STR) {563 } else if (conceptValueItem->type != PS_DATA_STRING) { 553 564 psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as" 554 565 " expected for non-linearity correction --- ignored.\n", … … 561 572 psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" 562 573 " --- ignored.\n", conceptValue); 563 } else if (optionItem->type == PS_ META_VEC) {574 } else if (optionItem->type == PS_DATA_VECTOR) { 564 575 // These are the polynomial coefficients 565 576 psVector *coeff = optionItem->data.V; // The coefficient vector … … 578 589 psFree(coeff); 579 590 psFree(correction); 580 } else if (optionItem->type == PS_ META_STR) {591 } else if (optionItem->type == PS_DATA_STRING) { 581 592 // This is a filename 582 593 psString tableName = optionItem->data.V; // The filename … … 673 684 // Output overscan fit results, if required 674 685 if (doOverscan) { 675 switch (overscanFitType) { 676 case PM_FIT_POLYNOMIAL: 677 { 678 psPolynomial1D *poly = (psPolynomial1D*)overscanFit; // The polynomial 679 psString coeffs = NULL; // String containing the coefficients 680 for (int i = 0; i < poly->n; i++) { 681 psStringAppend(&coeffs, "%e ", poly->coeff[i]); 682 } 683 psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n", 684 coeffs); 685 psFree(coeffs); 686 } 687 break; 688 case PM_FIT_SPLINE: 689 { 690 psSpline1D *spline = (psSpline1D*)overscanFit; // The spline 691 psString coeffs = NULL; // String containing the coefficients 692 for (int i = 0; i < spline->n; i++) { 693 psPolynomial1D *poly = spline->spline[i]; // i-th polynomial 694 psStringAppend(&coeffs, "%d: ", i); 695 for (int j = 0; j < poly->n; j++) { 686 if (! overscanFit) { 687 psLogMsg("phase2", PS_LOG_WARN, "No fit generated!\n"); 688 } else { 689 switch (overscanFitType) { 690 case PM_FIT_POLYNOMIAL: 691 { 692 psPolynomial1D *poly = (psPolynomial1D*)overscanFit; // The polynomial 693 psString coeffs = NULL; // String containing the coefficients 694 for (int i = 0; i < poly->nX; i++) { 696 695 psStringAppend(&coeffs, "%e ", poly->coeff[i]); 697 696 } 698 psStringAppend(&coeffs, "\n"); 697 psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n", 698 coeffs); 699 psFree(coeffs); 699 700 } 700 psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n", 701 coeffs); 702 psFree(coeffs); 701 break; 702 case PM_FIT_SPLINE: 703 { 704 psSpline1D *spline = (psSpline1D*)overscanFit; // The spline 705 psString coeffs = NULL; // String containing the coefficients 706 for (int i = 0; i < spline->n; i++) { 707 psPolynomial1D *poly = spline->spline[i]; // i-th polynomial 708 psStringAppend(&coeffs, "%d: ", i); 709 for (int j = 0; j < poly->nX; j++) { 710 psStringAppend(&coeffs, "%e ", poly->coeff[i]); 711 } 712 psStringAppend(&coeffs, "\n"); 713 } 714 psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n", 715 coeffs); 716 psFree(coeffs); 717 } 718 break; 719 case PM_FIT_NONE: 720 break; 721 default: 722 psAbort(__func__, "Should never get here!!!\n"); 703 723 } 704 break;705 case PM_FIT_NONE:706 break;707 default:708 psAbort(__func__, "Should never get here!!!\n");709 724 } 710 725 } 711 726 } 712 727 728 // Trim, so that flat, fringe etc computations are faster. 729 psRegion *trimRegion = psMetadataLookupPtr(NULL, inputCell->concepts, "CELL.TRIMSEC"); 730 psImage *trimmed = psImageSubset(inputReadout->image, *trimRegion); 731 psFree(inputReadout->image); 732 inputReadout->image = trimmed; 733 713 734 // Flat-field correction 714 735 if (doFlat) { 715 (void)pmFlatField(inputReadout, flatReadout); 736 psLogMsg("phase2", PS_LOG_INFO, "Performing flat field.\n"); 737 #ifndef PRODUCTION 738 psImage *dummyImage = psImageAlloc(inputReadout->image->numCols, 739 inputReadout->image->numRows, 740 PS_TYPE_U8); 741 pmReadout *dummyMask = pmReadoutAlloc(NULL, dummyImage, NULL, 0, 0, 1, 1, 1, 1); 742 (void)pmFlatField(inputReadout, dummyMask, flatReadout); 743 psFree(dummyMask); 744 psFree(dummyImage); 745 #endif 716 746 } 717 747
Note:
See TracChangeset
for help on using the changeset viewer.
