Changeset 5462
- Timestamp:
- Nov 2, 2005, 3:30:32 PM (21 years ago)
- Location:
- trunk/archive/scripts/src/phase2
- Files:
-
- 14 edited
-
papPhase2.c (modified) (14 diffs)
-
phase2.config (modified) (2 diffs)
-
pmConfig.c (modified) (3 diffs)
-
pmFPA.c (modified) (1 diff)
-
pmFPA.h (modified) (1 diff)
-
pmFPAConceptsGet.c (modified) (21 diffs)
-
pmFPAConceptsSet.c (modified) (7 diffs)
-
pmFPAConstruct.c (modified) (6 diffs)
-
pmFlatField.c (modified) (3 diffs)
-
pmFlatField.h (modified) (2 diffs)
-
pmFlatFieldErrors.h (modified) (1 diff)
-
pmSubtractBias.c (modified) (10 diffs)
-
pmSubtractBias.h (modified) (2 diffs)
-
psAdditionals.c (modified) (11 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 -
trunk/archive/scripts/src/phase2/phase2.config
r5371 r5462 3 3 # List of tasks to perform 4 4 MASK BOOL FALSE # Mask bad pixels 5 NONLIN BOOL FALSE # Non-linearity correction5 NONLIN BOOL TRUE # Non-linearity correction 6 6 BIAS BOOL FALSE # Bias subtraction 7 7 DARK BOOL FALSE # Dark subtraction 8 OVERSCAN BOOL TRUE # Overscan subtraction8 OVERSCAN BOOL FALSE # Overscan subtraction 9 9 FLAT BOOL FALSE # Flat-field normalisation 10 10 FRINGE BOOL FALSE # Fringe subtraction … … 58 58 # Overscan subtraction 59 59 OVERSCAN.MODE STR INDIVIDUAL # NONE | INDIVIDUAL | ALL 60 OVERSCAN.FIT STR SPLINE # NONE | POLYNOMIAL | SPLINE 61 OVERSCAN.ORDER S32 10 # Order of polynomial fit 60 #OVERSCAN.FIT STR SPLINE # NONE | POLYNOMIAL | SPLINE 61 OVERSCAN.FIT STR POLYNOMIAL # NONE | POLYNOMIAL | SPLINE 62 OVERSCAN.ORDER S32 5 # Order of polynomial fit 62 63 OVERSCAN.BIN S32 0 # Number of pixels per bin 63 64 OVERSCAN.STAT STR MEAN # MEAN | MEDIAN -
trunk/archive/scripts/src/phase2/pmConfig.c
r5104 r5462 141 141 psMetadataItem *traceItem = NULL; // Item from MD iteration 142 142 while (traceItem = psMetadataGetAndIncrement(traceIter)) { 143 if (traceItem->type != PS_ META_S32) {143 if (traceItem->type != PS_DATA_S32) { 144 144 psLogMsg(__func__, PS_LOG_WARN, "The level for trace component %s is not of type S32 (%x)\n", 145 145 traceItem->name, traceItem->type); … … 181 181 // Check to see if the rule works 182 182 switch (ruleItem->type) { 183 case PS_ META_STR:183 case PS_DATA_STRING: 184 184 psTrace(__func__, 8, "Matching %s: '%s' vs '%s'\n", ruleItem->name, 185 185 ruleItem->data.V, headerItem->data.V); … … 247 247 cameraItem->comment); 248 248 psMetadata *camera = NULL; // The camera metadata 249 if (cameraItem->type == PS_ META_META) {249 if (cameraItem->type == PS_DATA_METADATA) { 250 250 camera = psMemIncrRefCounter(cameraItem->data.md); 251 } else if (cameraItem->type == PS_ META_STR) {251 } else if (cameraItem->type == PS_DATA_STRING) { 252 252 psTrace(__func__, 5, "Reading camera configuration for %s...\n", cameraItem->name); 253 253 int badLines = 0; // Number of bad lines in reading camera configuration -
trunk/archive/scripts/src/phase2/pmFPA.c
r5371 r5462 202 202 pmReadout *readout = psAlloc(sizeof(pmReadout)); 203 203 psMemSetDeallocator(readout, (psFreeFunc)p_pmReadoutFree); 204 cell->readouts = psArrayAdd(cell->readouts, 0, readout); 204 if (cell) { 205 cell->readouts = psArrayAdd(cell->readouts, 0, readout); 206 } 205 207 206 208 // Set the components -
trunk/archive/scripts/src/phase2/pmFPA.h
r5371 r5462 6 6 7 7 // Temporary metadata types 8 #define PS_META_CHIP PS_META_UNKNOWN9 #define PS_META_CELL PS_META_UNKNOWN8 //#define PS_META_CHIP PS_DATA_UNKNOWN 9 //#define PS_META_CELL PS_DATA_UNKNOWN 10 10 11 11 typedef struct { -
trunk/archive/scripts/src/phase2/pmFPAConceptsGet.c
r5371 r5462 100 100 psMetadataItem *defItem = psMetadataLookup(defaults, concept); 101 101 if (defItem) { 102 if (defItem->type == PS_ META_META) {102 if (defItem->type == PS_DATA_METADATA) { 103 103 // A dependent default 104 104 psTrace(__func__, 7, "Evaluating dependent default....\n"); … … 122 122 return NULL; 123 123 } 124 if (depItem->type != PS_ META_STR) {124 if (depItem->type != PS_DATA_STRING) { 125 125 psError(PS_ERR_IO, true, "Value of %s is not of type string, as required for dependency" 126 126 " --- ignored.\n", dependsOn); … … 270 270 if (item) { 271 271 switch (item->type) { 272 case PS_ META_F32:272 case PS_DATA_F32: 273 273 value = item->data.F32; 274 274 break; 275 case PS_ META_F64:275 case PS_DATA_F64: 276 276 // Assume it's OK to truncate to floating point from double 277 277 value = (float)item->data.F64; 278 278 break; 279 case PS_ META_S32:279 case PS_DATA_S32: 280 280 // Promote to float 281 281 value = (float)item->data.S32; … … 370 370 if (item) { 371 371 switch (item->type) { 372 case PS_ META_STR:372 case PS_DATA_STRING: 373 373 value = item->data.V; 374 374 break; … … 383 383 psTrace(__func__, 7, "Adding %s (%s): %s\n", name, comment, value); 384 384 385 psMetadataAdd(concepts, PS_LIST_TAIL, name, PS_ META_STR, comment, value);385 psMetadataAdd(concepts, PS_LIST_TAIL, name, PS_DATA_STRING, comment, value); 386 386 } 387 387 … … 428 428 ra = raItem->data.F64; 429 429 break; 430 case PS_ META_STR:430 case PS_DATA_STRING: 431 431 // Sexagesimal format 432 432 { … … 480 480 } 481 481 482 psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.RA", PS_ META_F64,482 psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.RA", PS_DATA_F64, 483 483 "Right Ascension of the boresight (radians)", ra); 484 484 … … 497 497 dec = decItem->data.F64; 498 498 break; 499 case PS_ META_STR:499 case PS_DATA_STRING: 500 500 // Sexagesimal format 501 501 { … … 549 549 } 550 550 551 psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.DEC", PS_ META_F64,551 psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.DEC", PS_DATA_F64, 552 552 "Declination of the boresight (radians)", dec); 553 553 … … 633 633 psError(PS_ERR_IO, false, "Couldn't find CELL.TRIMSEC.\n"); 634 634 *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0); 635 } else if (secItem->type != PS_ META_STR) {635 } else if (secItem->type != PS_DATA_STRING) { 636 636 psError(PS_ERR_IO, true, "CELL.TRIMSEC is not of type STR (%x)\n", secItem->type); 637 637 *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0); … … 643 643 psError(PS_ERR_IO, false, "Couldn't find CELL.TRIMSEC.SOURCE.\n"); 644 644 *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0); 645 } else if (sourceItem->type != PS_ META_STR) {645 } else if (sourceItem->type != PS_DATA_STRING) { 646 646 psError(PS_ERR_IO, true, "CELL.TRIMSEC.SOURCE is not of type STR (%x)\n", sourceItem->type); 647 647 *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0); … … 681 681 } // Looking up CELL.TRIMSEC 682 682 683 psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TRIMSEC", PS_ META_UNKNOWN,683 psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TRIMSEC", PS_DATA_UNKNOWN, 684 684 "Trim section", trimsec); 685 685 psFree(trimsec); … … 693 693 if (! secItem) { 694 694 psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.\n"); 695 } else if (secItem->type != PS_ META_STR) {695 } else if (secItem->type != PS_DATA_STRING) { 696 696 psError(PS_ERR_IO, true, "CELL.BIASSEC is not of type STR (%x)\n", secItem->type); 697 697 } else { … … 701 701 if (! sourceItem) { 702 702 psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.SOURCE.\n"); 703 } else if (sourceItem->type != PS_ META_STR) {703 } else if (sourceItem->type != PS_DATA_STRING) { 704 704 psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE is not of type STR (%x)\n", sourceItem->type); 705 705 } else { … … 752 752 } // Looking up CELL.BIASSEC 753 753 754 psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.BIASSEC", PS_ META_LIST, "Bias sections", biassecs);754 psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.BIASSEC", PS_DATA_LIST, "Bias sections", biassecs); 755 755 psFree(biassecs); 756 756 } … … 762 762 if (! binItem) { 763 763 psError(PS_ERR_IO, false, "Couldn't find CELL.XBIN.\n"); 764 } else if (binItem->type == PS_ META_STR) {764 } else if (binItem->type == PS_DATA_STRING) { 765 765 psString binString = binItem->data.V; // The string containing the binning 766 766 if (sscanf(binString, "%d %*d", &xBin) != 1 && … … 784 784 if (! binItem) { 785 785 psError(PS_ERR_IO, false, "Couldn't find CELL.YBIN.\n"); 786 } else if (binItem->type == PS_ META_STR) {786 } else if (binItem->type == PS_DATA_STRING) { 787 787 psString binString = binItem->data.V; // The string containing the binning 788 788 if (sscanf(binString, "%*d %d", &yBin) != 1 && … … 809 809 if (! sysItem) { 810 810 psError(PS_ERR_IO, true, "Couldn't find CELL.TIMESYS --- assuming UTC.\n"); 811 } else if (sysItem->type != PS_ META_STR) {811 } else if (sysItem->type != PS_DATA_STRING) { 812 812 psError(PS_ERR_IO, true, "CELL.TIMESYS isn't of type STRING --- assuming UTC.\n"); 813 813 } else { … … 839 839 if (mdok && strlen(timeFormat) > 0) { 840 840 switch (timeItem->type) { 841 case PS_ META_STR:841 case PS_DATA_STRING: 842 842 { 843 843 psString timeString = timeItem->data.V; // String with the time … … 887 887 psError(PS_ERR_IO, false, "Unable to find time header: %s\n", 888 888 timeName); 889 } else if (timeItem->type == PS_ META_STR) {889 } else if (timeItem->type == PS_DATA_STRING) { 890 890 // Time is a string, in the usual way: 891 891 psStringAppend(&dateString, "T%s", timeItem->data.V); … … 965 965 } // Getting CELL.TIME 966 966 967 psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TIME", PS_ META_UNKNOWN, "Time of exposure", time);967 psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TIME", PS_DATA_UNKNOWN, "Time of exposure", time); 968 968 psFree(time); 969 969 } -
trunk/archive/scripts/src/phase2/pmFPAConceptsSet.c
r5371 r5462 68 68 } 69 69 return (item1->data.F64 == item2->data.F64) ? true : false; 70 case PS_ META_STR:71 if (item2->type != PS_ META_STR) {70 case PS_DATA_STRING: 71 if (item2->type != PS_DATA_STRING) { 72 72 return false; 73 73 } … … 112 112 // XXX: Need to expand range of types 113 113 switch (concept->type) { 114 case PS_ META_STR:114 case PS_DATA_STRING: 115 115 headerItem = psMetadataItemAllocStr(keyword, concept->comment, concept->data.V); 116 116 break; 117 case PS_ META_S32:117 case PS_DATA_S32: 118 118 headerItem = psMetadataItemAllocS32(keyword, concept->comment, concept->data.S32); 119 119 break; 120 case PS_ META_F32:120 case PS_DATA_F32: 121 121 headerItem = psMetadataItemAllocF32(keyword, concept->comment, concept->data.F32); 122 122 break; 123 case PS_ META_F64:123 case PS_DATA_F64: 124 124 headerItem = psMetadataItemAllocF64(keyword, concept->comment, concept->data.F64); 125 125 break; … … 183 183 psMetadataItem *defItem = psMetadataLookup(defaults, concept->name); 184 184 if (defItem) { 185 if (defItem->type == PS_ META_META) {185 if (defItem->type == PS_DATA_METADATA) { 186 186 // A dependent default 187 187 psTrace(__func__, 7, "Evaluating dependent default....\n"); … … 205 205 return false; 206 206 } 207 if (depItem->type != PS_ META_STR) {207 if (depItem->type != PS_DATA_STRING) { 208 208 psError(PS_ERR_IO, true, "Value of %s is not of type string, as required for dependency" 209 209 " --- ignored.\n", dependsOn); … … 555 555 if (! sourceItem) { 556 556 psError(PS_ERR_IO, false, "Couldn't find CELL.TRIMSEC.SOURCE.\n"); 557 } else if (sourceItem->type != PS_ META_STR) {557 } else if (sourceItem->type != PS_DATA_STRING) { 558 558 psError(PS_ERR_IO, true, "CELL.TRIMSEC.SOURCE is not of type STR (%x)\n", sourceItem->type); 559 559 } else { … … 596 596 if (! sourceItem) { 597 597 psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.SOURCE.\n"); 598 } else if (sourceItem->type != PS_ META_STR) {598 } else if (sourceItem->type != PS_DATA_STRING) { 599 599 psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE is not of type STR (%x)\n", sourceItem->type); 600 600 } else { … … 668 668 psRegion *biassec = psListGetAndIncrement(biassecsIter); 669 669 psString biassecString = psRegionToString(*biassec); 670 psMetadataAdd(header, PS_LIST_TAIL, keyword, PS_ META_STR| PS_META_REPLACE,670 psMetadataAdd(header, PS_LIST_TAIL, keyword, PS_DATA_STRING | PS_META_REPLACE, 671 671 "Bias section", biassecString); 672 672 psFree(biassecString); -
trunk/archive/scripts/src/phase2/pmFPAConstruct.c
r5371 r5462 37 37 psMetadataItem *item = NULL; // Item from iteration 38 38 while (item = psMetadataGetAndIncrement(iter)) { 39 if (item->type == PS_ META_MULTI || item->type == PS_META_META) {40 psLogMsg(__func__, PS_LOG_WARN, "PS_ META_MULTI and PS_META_META are not supported in a cell"41 " definition --- %s ignored.\n", item->name);39 if (item->type == PS_DATA_METADATA_MULTI || item->type == PS_DATA_METADATA) { 40 psLogMsg(__func__, PS_LOG_WARN, "PS_DATA_METADATA_MULTI and PS_DATA_METADATA are not supported " 41 "in a cell definition --- %s ignored.\n", item->name); 42 42 continue; 43 43 } … … 89 89 pmChip *chip = pmChipAlloc(fpa, extName); // The chip 90 90 chip->data = pmPixelDataAlloc(extName); // Prepare chip to receive FITS data 91 if (contentItem->type != PS_ META_STR) {91 if (contentItem->type != PS_DATA_STRING) { 92 92 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", 93 93 contentItem->type); … … 117 117 psTrace(__func__, 1, "Getting %s....\n", extName); 118 118 119 if (contentItem->type != PS_ META_STR) {119 if (contentItem->type != PS_DATA_STRING) { 120 120 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", 121 121 contentItem->type); … … 136 136 if (! chipItem) { 137 137 chip = pmChipAlloc(fpa, chipName); 138 psMetadataAdd(chips, PS_LIST_TAIL, chipName, PS_ META_CHIP, "", chip);138 psMetadataAdd(chips, PS_LIST_TAIL, chipName, PS_DATA_UNKNOWN, "", chip); 139 139 } else { 140 140 chip = psMemIncrRefCounter(chipItem->data.V); … … 161 161 psString chipName = contentItem->name; // The name of the chip 162 162 163 if (contentItem->type != PS_ META_STR) {163 if (contentItem->type != PS_DATA_STRING) { 164 164 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", 165 165 contentItem->type); … … 234 234 psString extName = contentItem->name; // The name of the extension 235 235 // Content is a cell type 236 if (contentItem->type != PS_ META_STR) {236 if (contentItem->type != PS_DATA_STRING) { 237 237 psLogMsg(__func__, PS_LOG_WARN, 238 238 "CONTENT metadata for extension %s is not of type string, but %x --- ignored\n", -
trunk/archive/scripts/src/phase2/pmFlatField.c
r5107 r5462 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2005- 09-23 02:58:30$20 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-11-03 01:30:32 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 24 24 */ 25 25 26 #include <stdio.h> 26 #if HAVE_CONFIG_H 27 #include <config.h> 28 #endif 29 30 #include<stdio.h> 31 #include<math.h> 27 32 #include <string.h> 33 28 34 #include "pslib.h" 29 30 #include "pmFPA.h"31 35 #include "pmFlatField.h" 32 36 #include "pmMaskBadPixels.h" … … 34 38 35 39 36 bool pmFlatField(pmReadout *in, const pmReadout *flat)40 bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat) 37 41 { 42 // XXX: Not sure if this is correct. Must consult with IfA. 43 PS_ASSERT_PTR_NON_NULL(mask, false); 38 44 int i = 0; 39 45 int j = 0; … … 67 73 PS_ERRORTEXT_pmFlatField_NULL_FLAT_IMAGE); 68 74 return false; 69 } else if(in->mask == NULL) {70 in->mask = psImageAlloc(inImage->numCols, inImage->numRows, PS_TYPE_MASK);71 memset(in->mask->data.V[0], 0, inImage->numCols*inImage->numRows*PSELEMTYPE_SIZEOF(PS_TYPE_MASK));72 75 } 73 inMask = in->mask;76 inMask = mask->image; 74 77 75 78 // Check input image and its mask are not larger than flat image 76 if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) { 79 80 if (inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) { 77 81 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 78 82 PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE, 79 83 inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols); 80 84 return false; 81 } else if(inMask->numRows>flatImage->numRows || inMask->numCols > flatImage->numCols) { 85 } 86 if (inMask->numRows > flatImage->numRows || inMask->numCols > flatImage->numCols) { 82 87 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 83 88 PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE, -
trunk/archive/scripts/src/phase2/pmFlatField.h
r5107 r5462 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2005- 09-23 02:58:30$20 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-11-03 01:30:32 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 24 24 */ 25 26 #include "pslib.h" 27 #include "pmFPA.h" // #include "pmAstrometry.h" 28 25 29 26 30 /** Execute flat field module. … … 31 35 * @return bool: True or false for success or failure 32 36 */ 33 34 #include "pmFPA.h"35 36 37 bool pmFlatField( 37 pmReadout *in, ///< Redout with input image and mask 38 pmReadout *in, ///< Readout with input image 39 pmReadout *mask, ///< Input image mask 38 40 const pmReadout *flat ///< Readout with flat image 39 41 ); -
trunk/archive/scripts/src/phase2/pmFlatFieldErrors.h
r5107 r5462 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2005- 09-23 02:59:05$9 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-11-03 01:30:32 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii -
trunk/archive/scripts/src/phase2/pmSubtractBias.c
r5107 r5462 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005- 09-23 02:58:30$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-11-03 01:30:32 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 #define PM_SUBTRACT_BIAS_SPLINE_ORDER 3 23 23 24 // XXX: put these in psConstants.h 25 void PS_POLY1D_PRINT(psPolynomial1D *poly) 26 { 27 printf("-------------- PS_POLY1D_PRINT() --------------\n"); 28 printf("poly->nX is %d\n", poly->nX); 29 for (psS32 i = 0 ; i < (1 + poly->nX) ; i++) { 30 printf("poly->coeff[%d] is %f\n", i, poly->coeff[i]); 31 } 32 } 33 34 void PS_PRINT_SPLINE(psSpline1D *mySpline) 35 { 36 printf("-------------- PS_PRINT_SPLINE() --------------\n"); 37 printf("mySpline->n is %d\n", mySpline->n); 38 for (psS32 i = 0 ; i < mySpline->n ; i++) { 39 PS_POLY1D_PRINT(mySpline->spline[i]); 40 } 41 PS_VECTOR_PRINT_F32(mySpline->knots); 42 } 43 44 #define PS_IMAGE_PRINT_F32_HIDEF(NAME) \ 45 printf("======== printing %s ========\n", #NAME); \ 46 for (int i = 0 ; i < (NAME)->numRows ; i++) { \ 47 for (int j = 0 ; j < (NAME)->numCols ; j++) { \ 48 printf("%.5f ", (NAME)->data.F32[i][j]); \ 49 } \ 50 printf("\n"); \ 51 }\ 52 24 53 /****************************************************************************** 25 54 psSubtractFrame(): this routine will take as input a readout for the input 26 55 image and a readout for the bias image. The bias image is subtracted in 27 56 place from the input image. 28 *****************************************************************************/57 *****************************************************************************/ 29 58 static pmReadout *SubtractFrame(pmReadout *in, 30 59 const pmReadout *bias) … … 143 172 return(opt); 144 173 } 174 175 145 176 146 177 /****************************************************************************** … … 161 192 psTrace(".psModule.pmSubtracBias.ScaleOverscanVector", 4, 162 193 "---- ScaleOverscanVector() begin (%d -> %d) ----\n", overscanVector->n, n); 194 // PS_VECTOR_PRINT_F32(overscanVector); 163 195 164 196 if (NULL == overscanVector) { … … 182 214 psF32 x; 183 215 psS32 i; 184 216 printf("Got here\n"); 185 217 if (fit == PM_FIT_POLYNOMIAL) { 186 218 // Fit a polynomial to the old overscan vector. … … 204 236 // Fit a spline to the old overscan vector. 205 237 mySpline = (psSpline1D *) fitSpec; 238 // XXX: Does it make any sense to have a psSpline argument? 206 239 if (mySpline == NULL) { 207 240 mustFreeSpline = 1; … … 210 243 // 211 244 // NOTE: Since the X arg in the psVectorFitSpline1D() function is NULL, 212 // splines en points will be from 0.0 to overscanVector->n-1. Must scale245 // splines endpoints will be from 0.0 to overscanVector->n-1. Must scale 213 246 // properly when doing the spline eval. 214 247 // 215 mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL); 248 // mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL); 249 mySpline = psVectorFitSpline1D(NULL, overscanVector); 216 250 if (mySpline == NULL) { 217 251 psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector()(2): Could not fit a spline to the psVector.\n"); 218 252 return(NULL); 219 253 } 254 // PS_PRINT_SPLINE(mySpline); 220 255 221 256 // For each element of the new vector, convert the x-ordinate to that … … 230 265 psFree(mySpline); 231 266 } 267 // PS_VECTOR_PRINT_F32(newVec); 268 232 269 233 270 } else { … … 376 413 tmpOverscan = (psListElem *) overscans->head; 377 414 while (NULL != tmpOverscan) { 415 // PS_IMAGE_PRINT_F32_HIDEF(in->image); 378 416 myOverscanImage = (psImage *) tmpOverscan->data; 379 417 … … 557 595 } 558 596 } else if (fit == PM_FIT_SPLINE) { 597 // XXX: This makes no sense 598 // XXX: must free mySpline? 559 599 mySpline = (psSpline1D *) fitSpec; 560 mySpline = psVectorFitSpline1D( mySpline, NULL, overscanVector, NULL);600 mySpline = psVectorFitSpline1D(NULL, overscanVector); 561 601 if (mySpline == NULL) { 562 602 psError(PS_ERR_UNKNOWN, false, "Could not fit a spline to overscan vector. Returning in image.\n"); -
trunk/archive/scripts/src/phase2/pmSubtractBias.h
r5107 r5462 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005- 09-23 02:58:30$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-11-03 01:30:32 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include<math.h> 24 24 #include "pslib.h" 25 #include "pmFPA.h" 25 26 #include "pmFPA.h" //#include "pmAstrometry.h" 26 27 27 28 typedef enum { -
trunk/archive/scripts/src/phase2/psAdditionals.c
r5104 r5462 15 15 psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n"); 16 16 } 17 } else if (item->type != PS_ META_META) {17 } else if (item->type != PS_DATA_METADATA) { 18 18 // The value at the key isn't metadata 19 19 if (status) { 20 20 *status = false; 21 21 } else { 22 psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_ META_META, as expected.\n");22 psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_DATA_METADATA, as expected.\n"); 23 23 } 24 24 value = NULL; … … 45 45 psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n"); 46 46 } 47 } else if (item->type != PS_ META_STR) {47 } else if (item->type != PS_DATA_STRING) { 48 48 // The value at the key isn't of the desired type 49 49 if (status) { 50 50 *status = false; 51 51 } else { 52 psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_ META_STR, as expected.\n");52 psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_DATA_STRING, as expected.\n"); 53 53 } 54 54 value = NULL; … … 79 79 printf(": "); 80 80 switch (item->type) { 81 case PS_ META_STR:81 case PS_DATA_STRING: 82 82 printf("%s", item->data.V); 83 83 break; 84 case PS_ META_BOOL:84 case PS_DATA_BOOL: 85 85 if (item->data.B) { 86 86 printf("True"); … … 89 89 } 90 90 break; 91 case PS_ META_S32:91 case PS_DATA_S32: 92 92 printf("%d", item->data.S32); 93 93 break; 94 case PS_ META_F32:94 case PS_DATA_F32: 95 95 printf("%f", item->data.F32); 96 96 break; 97 case PS_ META_F64:97 case PS_DATA_F64: 98 98 printf("%f", item->data.F64); 99 99 break; 100 case PS_ META_META:100 case PS_DATA_METADATA: 101 101 printf("\n"); 102 102 psMetadataPrint(item->data.V, level + 1); … … 200 200 switch(item->type) { 201 201 // Only doing a representative set of types 202 case PS_ META_S32:202 case PS_DATA_S32: 203 203 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atoi(argv[argnum])); 204 204 psArgumentRemove(argnum, argc, argv); 205 205 break; 206 case PS_ META_F32:206 case PS_DATA_F32: 207 207 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atof(argv[argnum])); 208 208 psArgumentRemove(argnum, argc, argv); 209 209 break; 210 case PS_ META_BOOL:210 case PS_DATA_BOOL: 211 211 // Turn option on; no optional argument to remove 212 212 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, true); 213 213 break; 214 214 // XXX: Include the other numerical types 215 case PS_ META_STR:215 case PS_DATA_STRING: 216 216 { 217 217 //psString string = psStringCopy(argv[argnum]); // Get the argument into PS memory management … … 250 250 if (argItem) { 251 251 psArgumentRemove(i, argc, argv); // Remove the switch 252 if (argItem->type != PS_ META_MULTI) {253 if (argItem->type != PS_ META_BOOL && *argc < i + 1) {252 if (argItem->type != PS_DATA_METADATA_MULTI) { 253 if (argItem->type != PS_DATA_BOOL && *argc < i + 1) { 254 254 psError(PS_ERR_IO, true, "Required argument for %s is missing.\n", argItem->name); 255 255 // XXX: Cleanup before returning … … 318 318 switch (oldItem->type) { 319 319 // Only doing a representative set of types 320 case PS_ META_S32:320 case PS_DATA_S32: 321 321 oldItem->data.S32 = newItem->data.S32; 322 322 break; 323 case PS_ META_F32:323 case PS_DATA_F32: 324 324 oldItem->data.F32 = newItem->data.F32; 325 325 break; 326 case PS_ META_BOOL:326 case PS_DATA_BOOL: 327 327 oldItem->data.B = newItem->data.B; 328 328 break; 329 329 // XXX: Include the other numerical types 330 case PS_ META_STR:330 case PS_DATA_STRING: 331 331 psFree(oldItem->data.V); 332 332 oldItem->data.V = psMemIncrRefCounter(newItem->data.V); 333 333 break; 334 case PS_ META_MULTI:334 case PS_DATA_METADATA_MULTI: 335 335 { 336 336 psList *newMulti = psMemIncrRefCounter(newItem->data.V); // The new list of MULTI … … 347 347 switch (oldMultiItem->type) { 348 348 // Only doing a representative set of types 349 case PS_ META_S32:349 case PS_DATA_S32: 350 350 oldItem->data.S32 = newItem->data.S32; 351 351 break; 352 case PS_ META_F32:352 case PS_DATA_F32: 353 353 oldItem->data.F32 = newItem->data.F32; 354 354 break; 355 355 // XXX: Include the other numerical types 356 case PS_ META_STR:356 case PS_DATA_STRING: 357 357 psFree(oldItem->data.V); 358 358 oldItem->data.V = psMemIncrRefCounter(newItem->data.V); … … 385 385 switch (arg->type) { 386 386 // Only doing a representative set of types 387 case PS_ META_S32:387 case PS_DATA_S32: 388 388 return arg->data.S32 >= 0 ? (int)log10f((float)arg->data.S32) + 1 : 389 389 (int)log10f(-(float)arg->data.S32) + 2; 390 390 // XXX: Other numerical types 391 case PS_ META_F32:391 case PS_DATA_F32: 392 392 return arg->data.F32 >= 0 ? 12 : 13; // -d.dddddde?dd 393 case PS_ META_F64:393 case PS_DATA_F64: 394 394 return arg->data.F64 >= 0 ? 12 : 13; // -d.dddddde?dd 395 case PS_ META_BOOL:395 case PS_DATA_BOOL: 396 396 return arg->data.B ? 4 : 5; 397 case PS_ META_STR:397 case PS_DATA_STRING: 398 398 return strlen(arg->data.V); 399 399 default: … … 450 450 switch (argItem->type) { 451 451 // Only doing a representative set of types 452 case PS_ META_S32:452 case PS_DATA_S32: 453 453 printf("%d", argItem->data.S32); 454 454 break; 455 455 // XXX: Other numerical types 456 case PS_ META_F32:456 case PS_DATA_F32: 457 457 printf("%.6e", argItem->data.F32); 458 458 break; 459 case PS_ META_F64:459 case PS_DATA_F64: 460 460 printf("%.6e", argItem->data.F64); 461 461 break; 462 case PS_ META_BOOL:462 case PS_DATA_BOOL: 463 463 if (argItem->data.B) { 464 464 printf("TRUE"); … … 467 467 } 468 468 break; 469 case PS_ META_STR:469 case PS_DATA_STRING: 470 470 printf("%s", argItem->data.V); 471 471 break;
Note:
See TracChangeset
for help on using the changeset viewer.
