Changeset 23351
- Timestamp:
- Mar 17, 2009, 12:07:42 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301/psModules
- Files:
-
- 14 deleted
- 59 edited
- 7 copied
-
. (modified) (1 prop)
-
src/astrom/pmAstrometryVisual.c (modified) (27 diffs)
-
src/astrom/pmAstrometryVisual.h (modified) (1 diff)
-
src/camera/pmFPACopy.c (modified) (2 diffs)
-
src/camera/pmFPAMaskWeight.c (modified) (3 diffs)
-
src/camera/pmFPAWrite.c (modified) (3 diffs)
-
src/camera/pmFPA_JPEG.c (modified) (1 diff)
-
src/camera/pmFPAfile.c (modified) (2 diffs)
-
src/camera/pmFPAfile.h (modified) (1 diff)
-
src/camera/pmFPAfileDefine.c (modified) (12 diffs)
-
src/camera/pmFPAfileDefine.h (modified) (2 diffs)
-
src/camera/pmFPAfileIO.c (modified) (5 diffs)
-
src/camera/pmHDUGenerate.c (modified) (1 diff)
-
src/concepts/pmConceptsStandard.c (modified) (1 diff)
-
src/config/Makefile.am (modified) (3 diffs)
-
src/config/pmConfig.c (modified) (12 diffs)
-
src/config/pmConfigCamera.c (modified) (2 diffs)
-
src/config/pmConfigDump.c (modified) (1 diff)
-
src/config/pmConfigRecipes.c (modified) (6 diffs)
-
src/config/pmConfigRecipes.h (modified) (3 diffs)
-
src/config/pmConfigRun.c (copied) (copied from trunk/psModules/src/config/pmConfigRun.c )
-
src/config/pmConfigRun.h (copied) (copied from trunk/psModules/src/config/pmConfigRun.h )
-
src/config/pmVersion.c (modified) (1 diff)
-
src/config/pmVersion.h (modified) (3 diffs)
-
src/detrend/pmDetrendDB.c (modified) (6 diffs)
-
src/detrend/pmDetrendDB.h (modified) (2 diffs)
-
src/detrend/pmFringeStats.c (modified) (1 diff)
-
src/detrend/pmRemnance.c (modified) (1 diff)
-
src/detrend/pmShutterCorrection.c (modified) (1 diff)
-
src/extras/pmVisual.c (modified) (8 diffs)
-
src/extras/pmVisual.h (modified) (3 diffs)
-
src/imcombine/Makefile.am (modified) (2 diffs)
-
src/imcombine/pmPSFEnvelope.c (modified) (7 diffs)
-
src/imcombine/pmStack.c (modified) (1 diff)
-
src/imcombine/pmStackVisual.c (copied) (copied from trunk/psModules/src/imcombine/pmStackVisual.c )
-
src/imcombine/pmStackVisual.h (copied) (copied from trunk/psModules/src/imcombine/pmStackVisual.h )
-
src/imcombine/pmSubtractionIO.c (modified) (3 diffs)
-
src/imcombine/pmSubtractionMatch.c (modified) (4 diffs)
-
src/imcombine/pmSubtractionMatch.h (modified) (1 diff)
-
src/imcombine/pmSubtractionVisual.c (modified) (10 diffs)
-
src/imcombine/pmSubtractionVisual.h (modified) (1 diff)
-
src/imsubtract (deleted)
-
src/objects/Makefile.am (modified) (2 diffs)
-
src/objects/pmFootprint.c (modified) (3 diffs)
-
src/objects/pmModel.c (modified) (13 diffs)
-
src/objects/pmMoments.c (modified) (2 diffs)
-
src/objects/pmPeaks.c (modified) (19 diffs)
-
src/objects/pmSource.c (modified) (12 diffs)
-
src/objects/pmSource.h (modified) (3 diffs)
-
src/objects/pmSourceContour.c (modified) (20 diffs)
-
src/objects/pmSourceFitModel.c (modified) (2 diffs)
-
src/objects/pmSourceFitSet.c (modified) (3 diffs)
-
src/objects/pmSourceIO_CMF_PS1_V1.c (copied) (copied from trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c )
-
src/objects/pmSourceMasks.c (copied) (copied from trunk/psModules/src/objects/pmSourceMasks.c )
-
src/objects/pmSourceMasks.h (copied) (copied from trunk/psModules/src/objects/pmSourceMasks.h )
-
src/objects/pmSourceMatch.c (modified) (25 diffs)
-
src/objects/pmSourceMatch.h (modified) (2 diffs)
-
src/objects/pmSourceSky.c (modified) (6 diffs)
-
src/objects/pmSourceUtils.c (modified) (2 diffs)
-
src/objects/pmSourceVisual.c (modified) (6 diffs)
-
src/objects/pmSourceVisual.h (modified) (2 diffs)
-
src/photom (deleted)
-
src/pslib (deleted)
-
src/psmodules.h (modified) (2 diffs)
-
src/sky (deleted)
-
templates (deleted)
-
test/astrom/verified (deleted)
-
test/config/verified (deleted)
-
test/detrend/tap_pmMaskBadPixels.c (modified) (12 diffs)
-
test/detrend/verified (deleted)
-
test/imcombine/tap_pmImageCombine.c (modified) (1 diff)
-
test/imcombine/verified (deleted)
-
test/imsubtract (deleted)
-
test/objects/tap_pmFringe.c (modified) (1 diff)
-
test/objects/tap_pmSourceFitModel.c (modified) (1 diff)
-
test/objects/tap_pmSourceFitModel_Delta.c (modified) (2 diffs)
-
test/objects/verified (deleted)
-
test/photom (deleted)
-
test/pslib (deleted)
-
test/verified (deleted)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/psModules merged eligible /trunk/psModules merged eligible /branches/cnb_branch_20090215/psModules 21495-22685 /branches/eam_branches/eam_branch_20090303/psModules 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryVisual.c
r21422 r23351 23 23 24 24 //variables to determine when things are plotted 25 static bool isVisual = false;26 25 static bool plotGridMatch = true; 27 26 static bool plotTweak = true; … … 48 47 /* Initialization Routines */ 49 48 50 bool pmAstromSetVisual (bool mode) {51 isVisual = mode;52 return true;53 }54 55 56 49 bool pmAstromVisualClose() 57 50 { … … 68 61 { 69 62 // make sure we want to plot this 70 if (!plotRawStars || ! isVisual) return true;63 if (!plotRawStars || !pmVisualIsVisual()) return true; 71 64 72 65 //set up plot region 73 66 if (!pmVisualInitWindow (&kapa, "psastro:plots")){ 74 isVisual = false;75 67 return false; 76 68 } … … 222 214 223 215 // pause and wait for user input: 224 pmVisualAskUser(&plotRawStars , &isVisual);216 pmVisualAskUser(&plotRawStars); 225 217 226 218 psFree (xVec); … … 234 226 { 235 227 //make sure we want to plot this 236 if (! isVisual|| !plotRefStars) return true;228 if (!pmVisualIsVisual() || !plotRefStars) return true; 237 229 238 230 //set up plotting variables 239 231 if (!pmVisualInitWindow (&kapa, "psastro:plots")) { 240 isVisual = false;241 232 return false; 242 233 } … … 284 275 285 276 // pause and wait for user input: 286 pmVisualAskUser(&plotRefStars , &isVisual);277 pmVisualAskUser(&plotRefStars); 287 278 288 279 psFree (xVec); … … 301 292 302 293 // make sure we want to plot this 303 if ( ! isVisual|| !plotLumFunc ) return true;294 if ( !pmVisualIsVisual() || !plotLumFunc ) return true; 304 295 305 296 //set up plotting variables 306 297 if ( !pmVisualInitWindow (&kapa, "psastro:plots")){ 307 isVisual = false;308 298 return false; 309 299 } … … 377 367 378 368 // pause and wait for user input: 379 pmVisualAskUser (&plotLumFunc , &isVisual);369 pmVisualAskUser (&plotLumFunc); 380 370 } 381 371 return true; … … 391 381 392 382 //make sure we want to plot this 393 if (! isVisual|| !plotRemoveClumps) return true;383 if (!pmVisualIsVisual() || !plotRemoveClumps) return true; 394 384 395 385 //set up plot variables 396 386 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) { 397 isVisual = false;398 387 return false; 399 388 } … … 480 469 481 470 //ask for user input and finish 482 pmVisualAskUser (&plotRemoveClumps , &isVisual);471 pmVisualAskUser (&plotRemoveClumps); 483 472 psFree (xVec); 484 473 psFree (yVec); … … 496 485 497 486 //make sure we want to plot this 498 if (! isVisual|| !plotOneChipFit)487 if (!pmVisualIsVisual() || !plotOneChipFit) 499 488 return true; 500 489 501 490 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 502 isVisual = false;503 491 return false; 504 492 } … … 511 499 512 500 //ask for user input and finish 513 pmVisualAskUser(&plotOneChipFit , &isVisual);501 pmVisualAskUser(&plotOneChipFit); 514 502 return true; 515 503 } … … 522 510 { 523 511 //make sure we want to plot this 524 if(! isVisual|| !plotFixChips) return true;512 if(!pmVisualIsVisual() || !plotFixChips) return true; 525 513 526 514 if(!pmVisualInitWindow(&kapa, "psastro:plots")) { 527 isVisual = false;528 515 return false; 529 516 } … … 588 575 KapaPlotVector (kapa, xNew->n, yNew->data.F32, "y"); 589 576 590 pmVisualAskUser(&plotFixChips , &isVisual);577 pmVisualAskUser(&plotFixChips); 591 578 psFree(xNew); 592 579 psFree(yNew); … … 606 593 607 594 //make sure we want to plot this 608 if (! isVisual|| !plotAstromGuessCheck) return true;595 if (!pmVisualIsVisual() || !plotAstromGuessCheck) return true; 609 596 610 597 //set up graph window 611 598 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) { 612 isVisual = false;613 599 return false; 614 600 } … … 686 672 psFree(xResid); 687 673 psFree(yResid); 688 pmVisualAskUser (&plotAstromGuessCheck , &isVisual);674 pmVisualAskUser (&plotAstromGuessCheck); 689 675 return true; 690 676 } … … 696 682 { 697 683 //make sure we want to plot this 698 if (! isVisual|| !plotCommonScale) return true;684 if (!pmVisualIsVisual() || !plotCommonScale) return true; 699 685 700 686 if (!pmVisualInitWindow(&kapa, "psastro:plots")){ 701 isVisual = false;702 687 return false; 703 688 } … … 736 721 KapaSendLabel (kapa, "Old Pixel Scale of FPA Chips (Not to Scale)", KAPA_LABEL_XP); 737 722 738 pmVisualAskUser (&plotCommonScale , &isVisual);723 pmVisualAskUser (&plotCommonScale); 739 724 740 725 psFree(xVec); … … 750 735 751 736 //make sure we want to plot this 752 if (! isVisual|| !plotMosaicOneChip) return true;737 if (!pmVisualIsVisual() || !plotMosaicOneChip) return true; 753 738 754 739 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 755 isVisual = false;756 740 return false; 757 741 } … … 759 743 //plot the residuals 760 744 if (!residPlot(rawstars, refstars, match, recipe, "Single Chip Fit Residuals - Mosaic Mode")) { 761 isVisual = false;745 pmVisualSetVisual(false); 762 746 return false; 763 747 } 764 748 765 749 //ask for user input and finish 766 pmVisualAskUser(&plotMosaicOneChip , &isVisual);750 pmVisualAskUser(&plotMosaicOneChip); 767 751 768 752 return true; … … 775 759 { 776 760 //make sure we want to plot this 777 if (! isVisual|| !plotMosaicMatches) return true;761 if (!pmVisualIsVisual() || !plotMosaicMatches) return true; 778 762 779 763 char title[60]; … … 782 766 783 767 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 784 isVisual = false;785 768 return false; 786 769 } 787 770 788 771 if (!residPlot(rawstars, refstars, match, recipe, title)){ 789 isVisual = false;772 pmVisualSetVisual(false); 790 773 return false; 791 774 } 792 775 793 776 //ask for user input 794 pmVisualAskUser (&plotMosaicMatches , &isVisual);777 pmVisualAskUser (&plotMosaicMatches); 795 778 return true; 796 779 } … … 807 790 { 808 791 //make sure we want to plot this 809 if (! isVisual|| !plotGridMatch) return true;792 if (!pmVisualIsVisual() || !plotGridMatch) return true; 810 793 if (!pmVisualInitWindow(&kapa, "psastro:plots")){ 811 isVisual = false;812 794 return false; 813 795 } … … 952 934 KapaPlotVector (kapa, 2, yslice, "y"); 953 935 954 pmVisualAskUser(&plotGridMatch , &isVisual);936 pmVisualAskUser(&plotGridMatch); 955 937 psFree(dXplot); 956 938 psFree(dYplot); … … 966 948 { 967 949 //make sure we want to plot this 968 if (! isVisual|| !plotTweak) return true;950 if (!pmVisualIsVisual() || !plotTweak) return true; 969 951 if (!pmVisualInitWindow(&kapa, "psastro:plots")) { 970 isVisual = false;971 952 return false; 972 953 } … … 1051 1032 KAPA_LABEL_XP); 1052 1033 1053 pmVisualAskUser(&plotTweak , &isVisual);1034 pmVisualAskUser(&plotTweak); 1054 1035 1055 1036 psFree(xIndices); … … 1341 1322 # else 1342 1323 1343 bool pmAstromSetVisual(bool mode) { return true; }1344 1324 bool pmAstromVisualClose() { return true; } 1345 1325 bool pmAstromVisualPlotGridMatch (const psArray *raw, const psArray *ref, psImage *gridNP, double offsetX, double offsetY, double maxOffpix, double Scale, double Offset) { return true; } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryVisual.h
r21422 r23351 22 22 int sPeak; ///< sum of stars to peak bin 23 23 } pmLumFunc; 24 25 26 /** Enable or disable visual plotting for psastro routines27 * @param mode true/false to enable/disable plotting28 * @return true for success */29 bool pmAstromSetVisual(bool mode);30 24 31 25 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPACopy.c
r22699 r23351 173 173 int xParityTarget = psMetadataLookupS32(&mdokT, target->concepts, "CELL.XPARITY"); // Target x parity 174 174 assert(mdokS && mdokT); 175 176 if (xParityTarget == 0) { 177 psMetadataItem *item = psMetadataLookup(target->concepts, "CELL.XPARITY"); // Item with parity 178 xParityTarget = item->data.S32 = xParitySource; 179 } 180 175 181 psAssert (abs(xParitySource) == 1, "CELL.XPARITY not set for source"); 176 182 psAssert (abs(xParityTarget) == 1, "CELL.XPARITY not set for target"); … … 192 198 int yParitySource = psMetadataLookupS32(&mdokS, source->concepts, "CELL.YPARITY"); // Source parity 193 199 assert(mdokS && mdokT); 200 201 if (yParityTarget == 0) { 202 psMetadataItem *item = psMetadataLookup(target->concepts, "CELL.YPARITY"); // Item with parity 203 yParityTarget = item->data.S32 = yParitySource; 204 } 205 194 206 psAssert (abs(yParitySource) == 1, "CELL.YPARITY not set for source"); 195 207 psAssert (abs(yParityTarget) == 1, "CELL.YPARITY not set for target"); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAMaskWeight.c
r21363 r23351 331 331 332 332 if (!psMemIncrRefCounter(rng)) { 333 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);333 rng = psRandomAlloc(PS_RANDOM_TAUS); 334 334 } 335 335 … … 371 371 372 372 if (!psMemIncrRefCounter(rng)) { 373 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);373 rng = psRandomAlloc(PS_RANDOM_TAUS); 374 374 } 375 375 … … 532 532 533 533 if (!psMemIncrRefCounter(rng)) { 534 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);534 rng = psRandomAlloc(PS_RANDOM_TAUS); 535 535 } 536 536 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAWrite.c
r22699 r23351 692 692 "Centre of covariance matrix in y", -yMinCovar); 693 693 694 // Turn off compression 695 int bitpix = fits->options ? fits->options->bitpix : 0; // Desired bits per pixel 696 psFitsCompression *compress = psFitsCompressionGet(fits); // Current compression options 697 if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) { 698 psError(PS_ERR_UNKNOWN, false, "Unable to set FITS compression to NONE"); 699 psFree(extname); 700 psFree(header); 701 psFree(images); 702 psFree(compress); 703 return false; 704 } 705 if (fits->options) { 706 fits->options->bitpix = 0; 707 } 708 694 709 // Write images 695 710 if (!psFitsWriteImageCube(fits, header, images, extname)) { … … 699 714 psFree(header); 700 715 psFree(images); 716 if (fits->options) { 717 fits->options->bitpix = bitpix; 718 } 719 psFitsCompressionApply(fits, compress); 720 psFree(compress); 701 721 return 0; 702 722 } … … 704 724 psFree(header); 705 725 psFree(images); 726 727 // Restore compression 728 if (fits->options) { 729 fits->options->bitpix = bitpix; 730 } 731 if (!psFitsCompressionApply(fits, compress)) { 732 psError(PS_ERR_UNKNOWN, false, "Unable to set FITS compression to NONE"); 733 psFree(compress); 734 return false; 735 } 736 psFree(compress); 706 737 707 738 return true; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPA_JPEG.c
r21183 r23351 154 154 155 155 // measure the image statistics for scaling 156 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);156 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 157 157 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 158 158 stats->nSubsample = 10000; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfile.c
r22699 r23351 50 50 51 51 psFree (file->filename); 52 psFree (file->origname); 52 53 psFree (file->extname); 53 54 … … 88 89 89 90 file->filename = NULL; 91 file->origname = NULL; 90 92 file->extname = NULL; 91 93 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfile.h
r21363 r23351 91 91 char *name; // the name of the rule (useful for debugging / tracing) 92 92 char *filename; // the current name of an active file 93 char *origname; // the original name (before mangling) of an active file 93 94 char *extname; // the current name of an active file extension 94 95 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileDefine.c
r22699 r23351 11 11 #include "pmConfig.h" 12 12 #include "pmConfigMask.h" 13 #include "pmConfigRun.h" 13 14 #include "pmDetrendDB.h" 14 15 … … 216 217 file->imageId = config->imageId; 217 218 } 218 219 // XXX this seems a bit of a hack: use the cameraName to determine the mosaic level...220 # if (0)221 if (cameraName) {222 if (!strcmp(cameraName + strlen(cameraName) - 5, "-CHIP")) {223 file->mosaicLevel = PM_FPA_LEVEL_CHIP;224 }225 if (!strcmp(cameraName + strlen(cameraName) - 5, "-FPA")) {226 file->mosaicLevel = PM_FPA_LEVEL_FPA;227 }228 }229 # endif230 219 231 220 // Use the format we were told to, the format specified in the file rule, or default to the default format … … 383 372 } 384 373 385 psTrace ("psModules.camera", 5, "file: %s, format: %s, fileLevel: %s, extLevel: %s, dataLevel: %s, freeLevel: %s\n", 386 file->name, file->formatName, pmFPALevelToName (file->fileLevel), pmFPALevelToName(extLevel), pmFPALevelToName (file->dataLevel), pmFPALevelToName (file->freeLevel)); 374 psTrace("psModules.camera", 5, 375 "file: %s, format: %s, fileLevel: %s, extLevel: %s, dataLevel: %s, freeLevel: %s\n", 376 file->name, file->formatName, pmFPALevelToName(file->fileLevel), pmFPALevelToName(extLevel), 377 pmFPALevelToName(file->dataLevel), pmFPALevelToName(file->freeLevel)); 387 378 388 379 // add argument-supplied OUTPUT name to this file 389 380 char *outname = psMetadataLookupStr(&status, config->arguments, "OUTPUT"); 390 psMetadataAddStr(file->names, PS_LIST_TAIL, "OUTPUT", PS_META_NO_REPLACE, " ", outname);381 psMetadataAddStr(file->names, PS_LIST_TAIL, "OUTPUT", PS_META_NO_REPLACE, "Output file name", outname); 391 382 392 383 // place the resulting file in the config system 393 psMetadataAddPtr (config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file);384 psMetadataAddPtr(config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "Output file", file); 394 385 psFree(file); // we free this copy of file, but 'files' still has a copy 395 386 return file; // the returned value is a view into the version on 'files' … … 426 417 } 427 418 428 // search for argname on the config->argument list 429 // construct an FPA based on the files in this list (must represent a single FPA) 430 // built the association between the FPA elements (CHIP/CELL) and the files 431 // define the pmFPAfile filename and bind it to this FPA 432 // save the pmFPAfile on config->files 433 // return the pmFPAfile (a view to the one saved on config->files) 434 pmFPAfile *pmFPAfileDefineFromArgs(bool *success, pmConfig *config, const char *filename, const char *argname) 419 420 /// Define a file from an array of filenames 421 static pmFPAfile *fpaFileDefineFromArray(pmConfig *config, // Configuration 422 pmFPAfile *bind, // File to bind to, or NULL 423 const char *name, // Name of file 424 const psArray *filenames // Array of file names 425 ) 426 { 427 PS_ASSERT_PTR_NON_NULL(config, NULL); 428 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 429 430 pmFPA *fpa = NULL; // FPA for file 431 psMetadata *format = NULL; // Camera format configuration 432 psString formatName = NULL; // Name of camera format 433 psString cameraName = NULL; // Name of camera 434 pmFPALevel fileLevel = PM_FPA_LEVEL_NONE; // Level for files 435 psMetadata *phu = NULL; // Primary header 436 if (bind) { 437 // Use the FPA we're binding to 438 fpa = psMemIncrRefCounter(bind->fpa); 439 fileLevel = bind->fileLevel; 440 } else { 441 // Need to generate an FPA 442 psString realName = pmConfigConvertFilename(filenames->data[0], config, false, false); 443 if (!realName) { 444 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *)filenames->data[0]); 445 return NULL; 446 } 447 448 // load the header of the first image 449 // EXTWORD (fits->extword) is not relevant to the PHU 450 psFits *fits = psFitsOpen(realName, "r"); // FITS file 451 if (!fits) { 452 psError(PS_ERR_IO, false, "Failed to open file %s", realName); 453 psFree(realName); 454 return NULL; 455 } 456 phu = psFitsReadHeader (NULL, fits); // Primary header 457 if (!phu) { 458 psError(PS_ERR_IO, false, "Failed to read file header %s", realName); 459 psFree(realName); 460 return NULL; 461 } 462 psFitsClose(fits); 463 464 // Determine the current format from the header; determine camera if not specified already. 465 psMetadata *camera = NULL; // Camera configuration 466 format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true); 467 if (!format) { 468 psError(PS_ERR_IO, false, "Failed to determine camera format for %s", realName); 469 psFree(camera); 470 psFree(formatName); 471 psFree(realName); 472 psFree(phu); 473 return NULL; 474 } 475 476 fileLevel = pmFPAPHULevel(format); 477 if (fileLevel == PM_FPA_LEVEL_NONE) { 478 psError(PS_ERR_IO, true, "Unable to determine file level for %s", realName); 479 psFree(camera); 480 psFree(formatName); 481 psFree(realName); 482 psFree(phu); 483 return NULL; 484 } 485 486 // build the template fpa, set up the basic view 487 // XXX do we want this to be the baseCamera name or the metaCamera name? 488 fpa = pmFPAConstruct(camera, cameraName); 489 psFree(camera); 490 if (!fpa) { 491 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName); 492 psFree(formatName); 493 psFree(realName); 494 psFree(format); 495 psFree(phu); 496 return NULL; 497 } 498 psFree(realName); 499 } 500 501 // load the given filerule (from config->camera) and bind it to the fpa 502 // the returned file is just a view to the entry on config->files 503 pmFPAfile *file = pmFPAfileDefineInput(config, fpa, cameraName, name); // File, to return 504 if (!file) { 505 psError(PS_ERR_IO, false, "File %s not defined", name); 506 psFree(formatName); 507 psFree(format); 508 psFree(fpa); 509 psFree(phu); 510 return NULL; 511 } 512 psFree(cameraName); 513 psFree(fpa); // Drop reference 514 515 file->format = format; 516 file->formatName = formatName; 517 file->fileLevel = fileLevel; 518 519 // We use the filerule and filesrc to identify the files in the file->names data 520 psFree(file->filerule); // this is set in pmFPAfileDefineInput 521 file->filerule = psStringCopy("@FILES"); 522 file->filesrc = psStringCopy("{CHIP.NAME}.{CELL.NAME}"); 523 524 // Examine the list of input files and validate their cameras 525 // Associate each filename with an element of the FPA 526 // Save the association on file->names 527 for (int i = 0; i < filenames->n; i++) { 528 // Check that the file corresponds to the same camera and format 529 if (!phu) { 530 psString realName = pmConfigConvertFilename(filenames->data[i], config, false, false); 531 if (!realName) { 532 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char*)filenames->data[i]); 533 return NULL; 534 } 535 psFits *fits = psFitsOpen(realName, "r"); // FITS file 536 if (!fits) { 537 psError(PS_ERR_IO, false, "Failed to open file %s", realName); 538 psFree(realName); 539 return NULL; 540 } 541 phu = psFitsReadHeader(NULL, fits); 542 psFitsClose(fits); 543 if (!phu) { 544 psError(PS_ERR_IO, false, "Failed to read file header %s", realName); 545 psFree(realName); 546 return NULL; 547 } 548 psFree(realName); 549 } 550 551 if (i == 0 && file->type == PM_FPA_FILE_MASK) { 552 if (!pmConfigMaskReadHeader(config, phu)) { 553 psError(PS_ERR_IO, false, "Error reading mask bits"); 554 psFree(phu); 555 return NULL; 556 } 557 } 558 559 if (bind || i > 0) { 560 if (format) { 561 bool valid = false; 562 if (!pmConfigValidateCameraFormat(&valid, format, phu)) { 563 psError(PS_ERR_UNKNOWN, false, "Error in config scripts\n"); 564 psFree(phu); 565 return NULL; 566 } 567 if (!valid) { 568 psError(PS_ERR_IO, false, "File %s is not from the required camera", 569 (char*)filenames->data[i]); 570 psFree(phu); 571 return NULL; 572 } 573 } else { 574 format = pmConfigCameraFormatFromHeader(NULL, NULL, NULL, config, phu, true); 575 if (!format) { 576 psError(PS_ERR_IO, false, "Failed to determine camera format from %s", 577 (char*)filenames->data[i]); 578 psFree(phu); 579 return NULL; 580 } 581 } 582 } 583 584 // Ensure the format is set 585 if (!file->format) { 586 file->format = format; 587 } 588 if (!file->formatName) { 589 file->formatName = formatName; 590 } 591 592 // Set the view to the corresponding entry for this phu 593 pmFPAview *view = NULL; // View to PHU 594 if (bind) { 595 view = pmFPAIdentifySourceFromHeader(bind->fpa, phu, format); 596 } else { 597 view = pmFPAAddSourceFromHeader(fpa, phu, format); 598 } 599 psFree(phu); 600 phu = NULL; 601 if (!view) { 602 psError(PS_ERR_IO, false, "Unable to determine source for %s", name); 603 return NULL; 604 } 605 606 // Associate the filename with the FPA element 607 psString location = pmFPAfileNameFromRule(file->filesrc, file, view); 608 psFree(view); 609 psMetadataAddStr(file->names, PS_LIST_TAIL, location, 0, "Location of file", filenames->data[i]); 610 psFree(location); 611 } 612 613 return file; 614 } 615 616 617 pmFPAfile *pmFPAfileDefineFromArgs(bool *success, pmConfig *config, 618 const char *filename, const char *argname) 435 619 { 436 620 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 438 622 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 439 623 440 bool status; 441 pmFPA *fpa = NULL; 442 psFits *fits = NULL; 443 pmFPAfile *file = NULL; 444 psMetadata *phu = NULL; 445 psMetadata *format = NULL; 446 psMetadata *camera = NULL; 447 psString formatName = NULL; 448 449 // use success to identify valid exit conditions (as opposed to 'argument not supplied') 450 if (success) { 451 *success = false; 452 } 453 454 // we search the argument data for the named fileset (argname) 455 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname); 624 // Search the argument data for the named fileset (argname) 625 bool status; // Status of MD lookup 626 psArray *filenames = psMetadataLookupPtr(&status, config->arguments, argname); // Filenames for file 456 627 if (!status) { 457 628 if (success) { … … 460 631 return NULL; 461 632 } 462 if (infiles->n < 1) { 463 psError(PS_ERR_IO, false, "Found n == %ld files in %s in arguments\n", infiles->n, argname); 464 return NULL; 465 } 466 467 // this function is implicitly an INPUT operation: do not create the file 468 psString realName = pmConfigConvertFilename (infiles->data[0], config, false, false); 469 if (!realName) { 470 psError(PS_ERR_IO, false, "Failed to convert file name %s\n", (char *) infiles->data[0]); 471 return NULL; 472 } 473 474 // load the header of the first image 475 // EXTWORD (fits->extword) is not relevant to the PHU 476 fits = psFitsOpen (realName, "r"); 477 if (!fits) { 478 psError(PS_ERR_IO, false, "Failed to open file %s\n", realName); 479 psFree (realName); 480 return NULL; 481 } 482 phu = psFitsReadHeader (NULL, fits); 483 484 if (!phu) { 485 psError(PS_ERR_IO, false, "Failed to read file header %s\n", realName); 486 psFree (realName); 487 return NULL; 488 } 489 psFitsClose(fits); 490 491 // Determine the current format from the header; Determine camera if not specified already. 492 // the returned pointers 'camera' and 'formatName' are allocated here 493 psString cameraName = NULL; 494 format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true); 495 if (!format) { 496 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName); 497 psFree(phu); 498 psFree(camera); 499 psFree(formatName); 500 psFree(realName); 501 return NULL; 502 } 503 504 // build the template fpa, set up the basic view 505 // XXX do we want this to be the baseCamera name or the metaCamera name? 506 fpa = pmFPAConstruct(camera, cameraName); 507 if (!fpa) { 508 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName); 509 psFree(phu); 510 psFree(camera); 511 psFree(formatName); 512 psFree(realName); 513 psFree(format); 514 return NULL; 515 } 516 psFree (realName); 517 psFree (camera); 518 519 // load the given filerule (from config->camera) and bind it to the fpa 520 // the returned file is just a view to the entry on config->files 521 file = pmFPAfileDefineInput(config, fpa, cameraName, filename); 522 if (!file) { 523 psError(PS_ERR_IO, false, "file %s not defined\n", filename); 524 psFree(phu); 525 psFree(formatName); 526 psFree(format); 527 psFree(fpa); 528 return NULL; 529 } 530 psFree (cameraName); 531 psFree (file->filerule); // this is set in pmFPAfileDefineInput 532 533 file->format = format; 534 file->formatName = formatName; 535 file->filerule = psStringCopy("@FILES"); 536 file->filesrc = psStringCopy("{CHIP.NAME}.{CELL.NAME}"); 537 // we use the above rules to identify these files in the file->names data 538 539 file->fileLevel = pmFPAPHULevel(format); 540 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 541 psError(PS_ERR_IO, true, "Unable to determine file level for %s\n", file->name); 542 psFree(phu); 543 psFree(fpa); 544 return NULL; 545 } 546 547 if (file->type == PM_FPA_FILE_MASK) { 548 if (!pmConfigMaskReadHeader (config, phu)) { 549 psError(PS_ERR_IO, false, "error in mask bits"); 550 return NULL; 551 } 552 } 553 554 // examine the list of input files and validate their cameras 555 // associated each filename with an element of the FPA 556 // save the association on file->names 557 for (int i = 0; i < infiles->n; i++) { 558 if (i > 0) { 559 // this function is implicitly an INPUT operation: do not create the file 560 psString realName = pmConfigConvertFilename (infiles->data[i], config, false, false); 561 if (!realName) { 562 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]); 563 psFree(phu); 564 psFree(fpa); 565 return NULL; 566 } 567 // EXTWORD (fits->extword) is not relevant to the PHU 568 fits = psFitsOpen (realName, "r"); 569 if (!fits) { 570 psError(PS_ERR_IO, false, "Failed to open file %s\n", realName); 571 psFree(realName); 572 psFree(phu); 573 psFree(fpa); 574 return NULL; 575 } 576 phu = psFitsReadHeader (NULL, fits); 577 if (!phu) { 578 psError(PS_ERR_IO, false, "Failed to read file header %s", realName); 579 psFree(realName); 580 psFitsClose(fits); 581 psFree(phu); 582 psFree(fpa); 583 return NULL; 584 } 585 bool valid = false; 586 if (!pmConfigValidateCameraFormat (&valid, format, phu)) { 587 psError(PS_ERR_UNKNOWN, false, "Error in config scripts\n"); 588 psFree(realName); 589 psFitsClose(fits); 590 psFree(phu); 591 psFree(fpa); 592 return NULL; 593 } 594 if (!valid) { 595 psError(PS_ERR_IO, false, "file %s is not from the required camera", realName); 596 psFree(realName); 597 psFitsClose(fits); 598 psFree(phu); 599 psFree(fpa); 600 return NULL; 601 } 602 psFree(realName); 603 psFitsClose(fits); 604 } 605 606 // set the view to the corresponding entry for this phu 607 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format); 608 if (!view) { 609 psError(PS_ERR_IO, false, "Unable to determine source for %s", file->name); 610 psFree(phu); 611 psFree(fpa); 612 return NULL; 613 } 614 615 // associate the filename with the FPA element 616 char *name = pmFPAfileNameFromRule(file->filesrc, file, view); 617 618 // save the name association in the pmFPAfile structure 619 psMetadataAddStr(file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]); 620 621 psFree(view); 622 psFree(name); 623 psFree(phu); 624 } 625 psFree(fpa); 633 if (filenames->n == 0) { 634 psError(PS_ERR_IO, false, "No files in array in %s in arguments", argname); 635 if (success) { 636 *success = false; 637 } 638 return NULL; 639 } 640 641 pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, filenames); // File of interest 642 626 643 if (success) { 627 *success = true; 628 } 629 630 return file; 631 } 632 633 // search for argname on the config->argument list 634 // construct an FPA based on the files in this list (must represent a single FPA) 635 // built the association between the FPA elements (CHIP/CELL) and the files 636 // define the pmFPAfile filename and bind it to this FPA 637 // save the pmFPAfile on config->files 638 // return the pmFPAfile (a view to the one saved on config->files) 639 pmFPAfile *pmFPAfileBindFromArgs (bool *success, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname) 644 *success = file ? true : false; 645 } 646 647 return file; 648 } 649 650 pmFPAfile *pmFPAfileBindFromArgs(bool *success, pmFPAfile *input, pmConfig *config, 651 const char *filename, const char *argname) 640 652 { 641 653 PS_ASSERT_PTR_NON_NULL(input, NULL); … … 644 656 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 645 657 646 bool status; 647 psFits *fits = NULL; 648 pmFPAfile *file = NULL; 649 psMetadata *phu = NULL; 650 651 // use success to identify valid exit conditions (as opposed to 'argument not supplied') 652 if (success) { 653 *success = false; 654 } 655 656 // we search the argument data for the named fileset (argname) 657 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname); 658 // Search the argument data for the named fileset (argname) 659 bool status; // Status of MD lookup 660 psArray *filenames = psMetadataLookupPtr(&status, config->arguments, argname); // Filenames for file 658 661 if (!status) { 659 // this is not an error: this just means no matching argument was supplied660 662 if (success) { 661 663 *success = true; … … 663 665 return NULL; 664 666 } 665 if (infiles->n < 1) { 666 psError(PS_ERR_IO, false, "Found n == %ld files in %s in arguments\n", infiles->n, argname); 667 return NULL; 668 } 669 670 // load the given filerule (from config->camera) and bind it to the fpa 671 // the returned file is just a view to the entry on config->files 672 file = pmFPAfileDefineInput (config, input->fpa, NULL, filename); 673 if (!file) { 674 psError(PS_ERR_IO, false, "file %s not defined\n", filename); 675 psFree(phu); 676 return NULL; 677 } 678 679 // set derived values 680 file->fileLevel = input->fileLevel; 681 682 683 // define the rule to identify these files in the file->names data 684 psFree (file->filerule); 685 psFree (file->filesrc); 686 file->filerule = psStringCopy ("@FILES"); 687 file->filesrc = psStringCopy ("{CHIP.NAME}.{CELL.NAME}"); 688 689 // examine the list of input files and validate their cameras 690 // associated each filename with an element of the FPA 691 // save the association on file->names 692 psMetadata *format = NULL; 693 for (int i = 0; i < infiles->n; i++) { 694 // this function is implicitly an INPUT operation: do not create the file 695 psString realName = pmConfigConvertFilename (infiles->data[i], config, false, false); 696 if (!realName) { 697 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]); 698 return NULL; 699 } 700 // EXTWORD (fits->extword) is not relevant to the PHU 701 fits = psFitsOpen (realName, "r"); 702 if (!fits) { 703 psError(PS_ERR_IO, false, "Failed to open file %s\n", realName); 704 psFree(realName); 705 return NULL; 706 } 707 phu = psFitsReadHeader (NULL, fits); 708 if (!phu) { 709 psError(PS_ERR_IO, false, "Failed to read file header %s", realName); 710 psFree(realName); 711 psFitsClose(fits); 712 return NULL; 713 } 714 715 if (!format) { 716 format = pmConfigCameraFormatFromHeader(NULL, NULL, NULL, config, phu, true); 717 if (!format) { 718 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName); 719 psFree(phu); 720 psFree(realName); 721 psFitsClose(fits); 722 return NULL; 723 } 724 } else { 725 bool valid = false; 726 if (!pmConfigValidateCameraFormat(&valid, format, phu)) { 727 psError(PS_ERR_UNKNOWN, false, "Error in config scripts\n"); 728 psFree(realName); 729 psFitsClose(fits); 730 return NULL; 731 } 732 if (!valid) { 733 psError(PS_ERR_IO, false, "specified data file %s does not match format of supplied INPUT\n", 734 realName); 735 psFree(realName); 736 psFitsClose(fits); 737 return NULL; 738 } 739 } 740 741 psFree(realName); 742 psFitsClose(fits); 743 744 // set the view to the corresponding entry for this phu 745 pmFPAview *view = pmFPAIdentifySourceFromHeader (input->fpa, phu, format); 746 if (!view) { 747 psError(PS_ERR_IO, false, "Unable to determine source for %s", file->name); 748 psFree(phu); 749 return NULL; 750 } 751 752 // associate the filename with the FPA element 753 char *name = pmFPAfileNameFromRule(file->filesrc, file, view); 754 755 // save the name association in the pmFPAfile structure 756 psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]); 757 758 if ((i == 0) && (file->type == PM_FPA_FILE_MASK)) { 759 if (!pmConfigMaskReadHeader (config, phu)) { 760 psError(PS_ERR_IO, false, "error in mask bits"); 761 return NULL; 762 } 763 } 764 765 psFree(view); 766 psFree(name); 767 psFree(phu); 768 } 769 file->format = format; 770 file->formatName = psStringCopy(config->formatName); 667 if (filenames->n == 0) { 668 psError(PS_ERR_IO, false, "No files in array in %s in arguments", argname); 669 if (success) { 670 *success = false; 671 } 672 return NULL; 673 } 674 675 pmFPAfile *file = fpaFileDefineFromArray(config, input, filename, filenames); // File of interest 771 676 772 677 if (success) { 773 *success = true; 774 } 775 return file; 776 } 777 778 // search for argname on the config->argument list 779 // construct an FPA based on the files in this list (each represents the same FPA) 780 // built the association between the FPA elements (CHIP/CELL) and the files 781 // define the pmFPAfile filenames and bind them to the FPAs 782 // save the pmFPAfiles on config->files 783 // return the pmFPAfiles (a view to the one saved on config->files) 784 pmFPAfile *pmFPAfileDefineSingleFromArgs (bool *success, pmConfig *config, const char *filename, 785 const char *argname, int entry) 678 *success = file ? true : false; 679 } 680 681 return file; 682 } 683 684 pmFPAfile *pmFPAfileDefineSingleFromArgs(bool *success, pmConfig *config, const char *filename, 685 const char *argname, int entry) 786 686 { 787 687 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 789 689 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 790 690 791 bool status; 792 pmFPA *fpa = NULL; 793 psFits *fits = NULL; 794 pmFPAfile *file = NULL; 795 psMetadata *phu = NULL; 796 psMetadata *format = NULL; 797 798 if (success) { 799 *success = false; 800 } 801 802 // we search the argument data for the named fileset (argname) 803 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname); 691 // Search the argument data for the named fileset (argname) 692 bool status; // Status from MD lookup 693 psArray *filenames = psMetadataLookupPtr(&status, config->arguments, argname); // Filenames for file 804 694 if (!status) { 805 psTrace("psModules.camera", 5, "Failed to find %s in argument list", argname);806 695 if (success) { 807 696 *success = true; … … 809 698 return NULL; 810 699 } 811 if (infiles->n <= entry) { 812 psError(PS_ERR_IO, false, "only %ld files in %s in argument, entry %d requested\n", 813 infiles->n, argname, entry); 814 return NULL; 815 } 816 817 // examine the list of input files and validate their cameras 818 // associated each filename with an element of the FPA 819 // save the association on file->names 820 // EXTWORD (fits->extword) is not relevant to the PHU 821 fits = psFitsOpen (infiles->data[entry], "r"); 822 phu = psFitsReadHeader (NULL, fits); 823 psFitsClose (fits); 824 825 // on first call to this function, config->camera is not set. 826 // later calls will give an error if the cameras do not match 827 psMetadata *camera = NULL; 828 psString formatName = NULL; 829 psString cameraName = NULL; 830 format = pmConfigCameraFormatFromHeader (&camera, &cameraName, &formatName, config, phu, true); 831 if (!format) { 832 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", (char *)infiles->data[0]); 833 psFree(phu); 834 psFree(camera); 835 psFree(formatName); 836 return NULL; 837 } 838 839 // build the template fpa, set up the basic view 840 fpa = pmFPAConstruct (camera, cameraName); 841 if (!fpa) { 842 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", (char *)infiles->data[0]); 843 psFree(phu); 844 psFree(camera); 845 psFree(formatName); 846 psFree(format); 847 return NULL; 848 } 849 psFree(camera); 850 851 // load the given filerule (from config->camera) and bind it to the fpa 852 // the returned file is just a view to the entry on config->files 853 // we need a variable name here... (but in filerule) 854 file = pmFPAfileDefineInput (config, fpa, cameraName, filename); 855 if (!file) { 856 psError(PS_ERR_IO, false, "file %s not defined\n", filename); 857 psFree(phu); 858 psFree(fpa); 859 psFree(format); 860 return NULL; 861 } 862 psFree(cameraName); 863 FPA_TEST_ASSERT (file); 864 865 file->format = format; 866 file->formatName = formatName; 867 file->filerule = psStringCopy ("@FILES"); 868 file->filesrc = psStringCopy ("{CHIP.NAME}.{CELL.NAME}"); 869 // adjust the above rules to identify these files in the file->names data 870 871 file->fileLevel = pmFPAPHULevel(format); 872 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 873 psError(PS_ERR_IO, true, "Unable to determine file level for %s\n", file->name); 874 psFree(phu); 875 psFree(fpa); 876 return NULL; 877 } 878 879 if (file->type == PM_FPA_FILE_MASK) { 880 if (!pmConfigMaskReadHeader (config, phu)) { 881 psError(PS_ERR_IO, false, "error in mask bits"); 882 return NULL; 883 } 884 } 885 886 // set the view to the corresponding entry for this phu 887 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format); 888 if (!view) { 889 psError(PS_ERR_IO, false, "Unable to determine source for %s", file->name); 890 psFree(phu); 891 psFree(fpa); 892 return NULL; 893 } 894 895 // associate the filename with the FPA element 896 char *name = pmFPAfileNameFromRule (file->filesrc, file, view); 897 898 // save the name association in the pmFPAfile structure 899 psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[entry]); 900 901 psFree(phu); 902 psFree(fpa); 903 psFree(view); 904 psFree(name); 700 if (filenames->n <= entry) { 701 psError(PS_ERR_IO, false, "Insufficient files (%ld) in array in %s in arguments", 702 filenames->n, argname); 703 if (success) { 704 *success = false; 705 } 706 return NULL; 707 } 708 709 psArray *single = psArrayAlloc(1); // Array of single filename of interest 710 single->data[0] = psMemIncrRefCounter(filenames->data[entry]); 711 pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, single); // File of interest 712 psFree(single); 905 713 906 714 if (success) { 907 *success = true; 908 } 909 return file; 910 } 715 *success = file ? true : false; 716 } 717 718 return file; 719 } 720 721 pmFPAfile *pmFPAfileDefineFromRun(bool *success, pmConfig *config, const char *filename) 722 { 723 PS_ASSERT_PTR_NON_NULL(config, NULL); 724 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 725 726 psArray *filenames = pmConfigRunFileGet(config, filename); // Filenames used, or NULL 727 if (!filenames) { 728 if (success) { 729 *success = true; 730 } 731 return NULL; 732 } 733 734 pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, filenames); // File of interest 735 psFree(filenames); 736 737 if (success) { 738 *success = file ? true : false; 739 } 740 741 return file; 742 } 743 911 744 912 745 // define the named pmFPAfile from the camera->config 913 746 // only valid for pmFPAfile->mode = READ 914 pmFPAfile *pmFPAfileDefineFromConf (bool *success, const pmConfig *config, const char *filename)747 pmFPAfile *pmFPAfileDefineFromConf(bool *success, const pmConfig *config, const char *filename) 915 748 { 916 749 PS_ASSERT_PTR_NON_NULL(config, false); … … 991 824 pmFPA *fpa = NULL; 992 825 pmFPAfile *file = NULL; 826 827 if (type == PM_DETREND_TYPE_NONE) { 828 return NULL; 829 } 993 830 994 831 if (success) { … … 1177 1014 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 1178 1015 1179 pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName, 1180 src->formatName); 1016 pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName, src->formatName); 1017 if (!file) { 1018 psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename); 1019 return NULL; 1020 } 1181 1021 file->src = psMemIncrRefCounter(src->fpa); // inherit output elements from this source pmFPA 1182 1022 file->xBin = xBin; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileDefine.h
r20637 r23351 53 53 // Note that the returned pmFPAfile is a view only, so it should not be freed by the caller --- the only 54 54 // reference count is held by the config->files metadata. 55 pmFPAfile *pmFPAfileDefineFromArgs (bool *found, pmConfig *config, const char *filename, const char *argname);55 pmFPAfile *pmFPAfileDefineFromArgs(bool *found, pmConfig *config, const char *filename, const char *argname); 56 56 57 57 // look for the given argname on the argument list; bind the associated files to the specified … … 59 59 // Note that the returned pmFPAfile is a view only, so it should not be freed by the caller --- the only 60 60 // reference count is held by the config->files metadata. 61 pmFPAfile *pmFPAfileBindFromArgs (bool *found, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname); 61 pmFPAfile *pmFPAfileBindFromArgs(bool *found, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname); 62 63 /// Define a file based on the filenames in the RUN metadata in the configuration 64 /// 65 /// Note that the returned pmFPAfile is a view only, so it should not be freed by the caller --- the only 66 /// reference count is held by the config->files metadata. 67 pmFPAfile *pmFPAfileDefineFromRun( 68 bool *found, ///< Found files? 69 pmConfig *config, ///< Configuration 70 const char *filename ///< Name of file 71 ); 72 62 73 63 74 // look for the given argname on the argument list. find the give filename from the file rules -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileIO.c
r21363 r23351 22 22 #include "pmFPARead.h" 23 23 #include "pmFPAWrite.h" 24 #include "pmFPAfileIO.h"25 24 #include "pmFPAfileFitsIO.h" 26 25 #include "pmSpan.h" … … 44 43 #include "pmSubtractionIO.h" 45 44 #include "pmConcepts.h" 45 #include "pmConfigRun.h" 46 47 #include "pmFPAfileIO.h" 46 48 47 49 // attempt create, read, write, close, or free pmFPAfiles available in files files are … … 164 166 } 165 167 168 if (!pmConfigRunFileAdd(config, file)) { 169 psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information"); 170 return false; 171 } 172 166 173 // select a reading method 167 174 bool status = true; … … 412 419 return false; 413 420 } 421 } 422 423 if (!pmConfigRunFileAdd(config, file)) { 424 psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information"); 425 return false; 414 426 } 415 427 … … 728 740 // apply filename mangling rules (file://, path://, neb://) 729 741 bool create = file->mode == PM_FPA_MODE_WRITE ? true : false; 730 psString tmpName = pmConfigConvertFilename(file->filename, config, create, false);731 if (! tmpName) {742 psString realName = pmConfigConvertFilename(file->filename, config, create, false); 743 if (!realName) { 732 744 psError(PS_ERR_IO, false, "failed to determine real name from template for %s\n", file->filename); 733 745 return false; 734 746 } 735 psFree (file->filename); 736 file->filename = tmpName; 747 psFree(file->origname); 748 file->origname = file->filename; 749 file->filename = realName; 737 750 738 751 switch (file->type) { -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmHDUGenerate.c
r21363 r23351 474 474 } 475 475 476 if (!biassecs || !readout->bias) { 477 // No need to worry about bias section 478 continue; 479 } 480 476 481 if (biassecs->n != readout->bias->n) { 477 482 psWarning("Number of bias sections (%ld) and number of biases (%ld) do not match.\n", -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsStandard.c
r22699 r23351 888 888 default: 889 889 psError(PS_ERR_UNKNOWN, true, "Unable to parse %s.\n", pattern->name); 890 return NULL; 891 } 892 893 if (!time) { 894 psError(PS_ERR_BAD_PARAMETER_SIZE, false, "Unable to parse time for %s", pattern->name); 890 895 return NULL; 891 896 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/Makefile.am
r18905 r23351 1 1 noinst_LTLIBRARIES = libpsmodulesconfig.la 2 2 3 libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) 3 # PSMODULES_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PSMODULES_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PSMODULES_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 7 # Force recompilation of pmVersion.c, since it gets the version information 8 # pmVersion.c: FORCE 9 # touch pmVersion.c 10 # FORCE: ; 11 12 libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -DPSMODULES_VERSION=$(SVN_VERSION) -DPSMODULES_BRANCH=$(SVN_BRANCH) -DPSMODULES_SOURCE=$(SVN_SOURCE) 4 13 libpsmodulesconfig_la_LDFLAGS = -release $(PACKAGE_VERSION) 5 14 libpsmodulesconfig_la_SOURCES = \ … … 10 19 pmConfigMask.c \ 11 20 pmConfigDump.c \ 21 pmConfigRun.c \ 12 22 pmVersion.c \ 13 23 pmErrorCodes.c … … 20 30 pmConfigMask.h \ 21 31 pmConfigDump.h \ 32 pmConfigRun.h \ 22 33 pmVersion.h \ 23 34 pmErrorCodes.h -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfig.c
r21314 r23351 13 13 14 14 #include <stdio.h> 15 #include <stdlib.h> 15 16 #include <string.h> 16 17 #include <strings.h> /* for strn?casecmp */ … … 24 25 #include <pslib.h> 25 26 26 #include "pmConfig.h"27 27 #include "pmErrorCodes.h" 28 28 #include "pmFPALevel.h" 29 29 #include "pmConfigRecipes.h" 30 30 #include "pmConfigCamera.h" 31 #include "pmConfigRun.h" 32 33 #include "pmConfig.h" 31 34 32 35 #ifdef HAVE_NEBCLIENT … … 142 145 config->format = NULL; 143 146 config->formatName = NULL; 144 config->recipes = psMetadataAlloc();147 config->recipes = NULL; 145 148 config->recipesRead = PM_RECIPE_SOURCE_NONE; 146 149 config->recipesCamera = psMetadataAlloc(); … … 432 435 // variable will contain the name of the configuration file. 433 436 434 char *configFile = NULL; 435 // 437 char *configFile = NULL; // Name of configuration file 438 436 439 // First, try command line 437 //438 440 psS32 argNum = psArgumentGet(*argc, argv, "-ipprc"); 439 441 if (argNum != 0) { … … 447 449 } 448 450 } 449 // 451 450 452 // Next, try environment variable 451 //452 453 if (!configFile) { 453 454 configFile = getenv(IPPRC_ENV); 454 455 if (configFile) { 455 configFile = psStringCopy (configFile); 456 } 457 } 458 459 // 456 configFile = psStringCopy(configFile); 457 } 458 } 459 460 460 // Last chance is ~/.ipprc 461 //462 461 if (!configFile) { 463 462 char *home = getenv("HOME"); … … 466 465 } 467 466 468 // We have the configuration filename; now we read and parse the config 469 // file and store in psMetadata struct user. 467 // Read and parse the config file and store in struct user. 470 468 // XXX move this section to pmConfigReadUser.c ? 471 472 469 if (!pmConfigFileRead(&config->user, configFile, "user")) { 473 470 psFree(config); … … 477 474 psFree(configFile); 478 475 479 // XXX why was this being called here? Is someone calling pmConfigRead multiple times? 480 // pmConfigDone(); 481 assert (configPath == NULL); 476 pmConfigRunCommand(config, *argc, argv); 482 477 483 478 // define the config-file search path (configPath). 479 psAssert(configPath == NULL, "Configuration path is already defined."); 484 480 psString path = psMetadataLookupStr(NULL, config->user, "PATH"); 485 pmConfigSet (path);481 pmConfigSet(path); 486 482 487 483 // read the SITE file … … 525 521 psLogSetLevel(logLevel); 526 522 } 527 528 523 529 524 // Set logging format … … 648 643 } 649 644 645 // Set the random number generator seed 646 { 647 psU64 seed = 0; // RNG seed 648 int argNum = psArgumentGet(*argc, argv, "-seed"); // Argument number 649 if (argNum > 0) { 650 psArgumentRemove(argNum, argc, argv); 651 if (argNum >= *argc) { 652 psWarning("-seed command-line switch provided without the required seed value --- ignored."); 653 } else { 654 char *end = NULL; // Pointer to end of consumed string 655 seed = strtoll(argv[argNum], &end, 0); 656 if (strlen(end) > 0) { 657 psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]); 658 psFree(config); 659 return NULL; 660 } 661 psArgumentRemove(argNum, argc, argv); 662 } 663 } 664 pmConfigRunSeed(config, seed); 665 } 666 650 667 // Next, we do a similar thing for the camera configuration file. The 651 668 // file is read and parsed into psMetadata struct "camera". … … 1110 1127 // camera. If we are discovering the camera (config->camera == NULL), then we also load the 1111 1128 // recipe files for the camera. 1112 psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName, 1113 pmConfig *config, const psMetadata *header, bool readRecipes)1129 psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName, 1130 pmConfig *config, const psMetadata *header, bool readRecipes) 1114 1131 { 1115 1132 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 1672 1689 // if the object does not exist and create isn't set, then we 1673 1690 // should puke 1674 psError(PM_ERR_SYS, true, "Unable to access file %s ", filename);1691 psError(PM_ERR_SYS, true, "Unable to access file %s: %s", filename, nebErr(server)); 1675 1692 nebServerFree(server); 1676 1693 return NULL; … … 1685 1702 if (trunc) { 1686 1703 if(truncate(path, 0) != 0) { 1687 psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n", filename, path); 1704 psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n", 1705 filename, path); 1688 1706 return NULL; 1689 1707 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigCamera.c
r22700 r23351 213 213 psStringAppend(&newName, "_%s-SKYCELL", name); 214 214 if (psMetadataLookup(oldCameras, newName)) { 215 psFree(newName); 215 216 return true; 216 217 } … … 469 470 psStringAppend(&newName, "_%s-%s", name, mosaicLevel == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA"); 470 471 if (psMetadataLookup(oldCameras, newName)) { 472 psFree(newName); 471 473 return true; 472 474 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigDump.c
r19399 r23351 54 54 psArray *keep = psStringSplitArray(save, " ,;", false); // List of items to keep 55 55 56 bool result = configCull(config->recipes, keep); // Result of culling 56 if (!configCull(config->recipes, keep)) { 57 psError(PS_ERR_UNKNOWN, false, "Unable to cull system recipes."); 58 psFree(keep); 59 return false; 60 } 57 61 psFree(keep); 58 62 59 return result; 63 // Need to cull recipes from all cameras as well 64 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // Known cameras 65 if (!cameras) { 66 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the system configuration.\n"); 67 return false; 68 } 69 70 psMetadataIterator *iter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator for cameras 71 psMetadataItem *item; // Item from iteration 72 keep = psArrayAllocEmpty(1); 73 while ((item = psMetadataGetAndIncrement(iter))) { 74 psAssert(item->type == PS_DATA_METADATA, "Should only be metadata types on the camera list."); 75 psMetadata *camera = item->data.md; // Camera configuration 76 bool mdok; // Status of MD lookup 77 psMetadata *recipes = psMetadataLookupMetadata(&mdok, camera, "RECIPES"); // Recipe overrides 78 if (!recipes) { 79 continue; 80 } 81 if (!configCull(recipes, keep)) { 82 psError(PS_ERR_UNKNOWN, false, "Unable to cull recipes for camera %s", item->name); 83 psFree(iter); 84 psFree(keep); 85 return false; 86 } 87 } 88 psFree(iter); 89 psFree(keep); 90 91 return true; 60 92 } 61 93 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRecipes.c
r21387 r23351 11 11 #include "pmConfigRecipes.h" 12 12 13 static bool loadRecipeSystem(bool *status, pmConfig *config , psMetadata *source);13 static bool loadRecipeSystem(bool *status, pmConfig *config); 14 14 static bool loadRecipeCamera(bool *status, pmConfig *config, psMetadata *source); 15 15 static bool loadRecipeSymbols(bool *status, pmConfig *config, pmRecipeSource source); … … 56 56 PS_ASSERT_PTR_NON_NULL(config, false); 57 57 58 if (!config->recipes) {59 config->recipes = psMetadataAlloc();60 }61 62 58 // Read the recipe file names from the system configuration and camera configuration 63 59 // It is an error for config->system:recipes not to exist. all programs install their 64 60 // master recipe files in the system:recipe location when they are built. 65 61 psAssert(config->system, "base config data defined"); 66 if ( source & PM_RECIPE_SOURCE_SYSTEM) {67 if (!loadRecipeSystem(&status, config , config->system)) {62 if (!config->recipes || (source & PM_RECIPE_SOURCE_SYSTEM)) { 63 if (!loadRecipeSystem(&status, config)) { 68 64 psError(PS_ERR_IO, false, "Failed to read recipes from system config"); 69 65 return false; … … 321 317 // Load the recipe files for SYSTEM : REQUIRED 322 318 static bool loadRecipeSystem(bool *status, 323 pmConfig *config, // The configuration into which to read the recipes 324 psMetadata *source // The source configuration, from which to read the filenames 319 pmConfig *config // The configuration into which to read the recipes 325 320 ) 326 321 { … … 329 324 *status = false; 330 325 331 if (! source) {326 if (!config->system) { 332 327 psError(PS_ERR_IO, true, 333 328 "The system configuration has not been read --- cannot read recipes from this location.\n"); … … 336 331 } 337 332 338 psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes339 if (!recipes) {340 psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");341 return false;342 }343 344 // Copy contents of the filenames to config->recipes from the "RECIPES" metadata in the source.345 // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type. 346 // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.347 psMetadataIterator *recipesIter = psMetadataIteratorAlloc( recipes, PS_LIST_HEAD, NULL); // Iterator333 if (!config->recipes) { 334 config->recipes = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->system, "RECIPES")); // The list of recipes 335 if (!config->recipes) { 336 psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n"); 337 return false; 338 } 339 } 340 341 // Read in the component recipes 342 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipes, PS_LIST_HEAD, NULL); // Iterator 348 343 psMetadataItem *item = NULL; // MD item containing the filename, from recipe iteration 349 344 while ((item = psMetadataGetAndIncrement(recipesIter))) { … … 353 348 psFree(recipesIter); 354 349 return false; 355 } 356 357 // add the contents of this recipe file to config->recipes 358 psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, 359 item->comment, item->data.md); 350 } 360 351 } 361 352 psFree(recipesIter); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRecipes.h
r12916 r23351 1 1 /* @file pmConfigRecipes.h 2 2 * @brief Configuration Recipe functions 3 * 3 * 4 4 * @author ?, MHPCC 5 5 * @author Paul Price, IfA 6 6 * @author Eugene Magnier, IfA 7 * 7 * 8 8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 9 * @date $Date: 2007-04-19 02:10:12 $ … … 13 13 #ifndef PM_CONFIG_RECIPES_H 14 14 #define PM_CONFIG_RECIPES_H 15 16 #include <pmConfig.h> 15 17 16 18 /// @addtogroup Config Configuration System … … 26 28 27 29 28 bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config);29 bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag);30 psMetadata *pmConfigRecipeOptions (pmConfig *config, char *recipe);30 bool pmConfigLoadRecipeArguments(int *argc, char **argv, pmConfig *config); 31 bool pmConfigLoadRecipeOptions(int *argc, char **argv, pmConfig *config, char *flag); 32 psMetadata *pmConfigRecipeOptions(pmConfig *config, char *recipe); 31 33 32 34 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmVersion.c
r10291 r23351 8 8 #include "pmVersion.h" 9 9 10 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 10 #ifndef PSMODULES_VERSION 11 #error "PSMODULES_VERSION is not set" 12 #endif 13 #ifndef PSMODULES_BRANCH 14 #error "PSMODULES_BRANCH is not set" 15 #endif 16 #ifndef PSMODULES_SOURCE 17 #error "PSMODULES_SOURCE is not set" 18 #endif 19 20 #define xstr(s) str(s) 21 #define str(s) #s 11 22 12 23 psString psModulesVersion(void) 13 24 { 14 psString version = NULL; // Version, to return15 psStringAppend(&v ersion, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);16 return v ersion;25 char *value = NULL; 26 psStringAppend(&value, "%s@%s", xstr(PSMODULES_BRANCH), xstr(PSMODULES_VERSION)); 27 return value; 17 28 } 29 30 psString psModulesSource(void) 31 { 32 return psStringCopy(xstr(PSMODULES_SOURCE)); 33 } 34 18 35 19 36 psString psModulesVersionLong(void) 20 37 { 21 psString version = psModulesVersion(); // Version, to return22 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag38 psString version = psModulesVersion(); // Version, to return 39 psString source = psModulesSource(); // Source 23 40 24 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 41 psStringPrepend(&version, "psModules "); 42 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 43 psFree(source); 25 44 26 psFree(tag); 45 #ifdef __OPTIMIZE__ 46 psStringAppend(&version, " optimised"); 47 #else 48 psStringAppend(&version, " unoptimised"); 49 #endif 50 51 #ifdef HAVE_NEBCLIENT 52 psStringAppend(&version, " with nebclient"); 53 #else 54 psStringAppend(&version, " without nebclient"); 55 #endif 56 27 57 return version; 58 }; 59 60 61 bool psModulesVersionHeader(psMetadata *header) 62 { 63 PS_ASSERT_METADATA_NON_NULL(header, false); 64 65 psString version = psModulesVersion(); // Software version 66 psString source = psModulesSource(); // Software source 67 68 psStringPrepend(&version, "psModules version: "); 69 psStringPrepend(&source, "psModules source: "); 70 71 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 72 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 73 74 psFree(version); 75 psFree(source); 76 77 return true; 28 78 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmVersion.h
r12696 r23351 1 1 /* @file pmVersion.h 2 2 * @brief Version functions 3 * 3 * 4 4 * @author Paul Price, IfA 5 5 * @author Eugene Magnier, IfA 6 * 6 * 7 7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 8 * @date $Date: 2007-03-30 21:12:56 $ … … 22 22 * @return psString: String with version name. 23 23 */ 24 psString psModulesVersion( 25 void 26 ); 24 psString psModulesVersion(void); 25 26 /** Get current psModules source 27 * 28 * Returns the current psModules source as a string. 29 * 30 * @return psString: String with source. 31 */ 32 psString psModulesSource(void); 27 33 28 34 /** Get current psModules version (full identification) … … 34 40 psString psModulesVersionLong(void); 35 41 42 /// Populate a header with version information 43 bool psModulesVersionHeader( 44 psMetadata *header ///< Header to populate 45 ); 46 47 36 48 /// @} 37 49 #endif -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmDetrendDB.c
r20401 r23351 20 20 21 21 // 22 static void pmDetrendSelectOptionsFree (pmDetrendSelectOptions *options)23 { 24 25 if (!options) 22 static void pmDetrendSelectOptionsFree(pmDetrendSelectOptions *options) 23 { 24 25 if (!options) { 26 26 return; 27 28 psFree (options->camera); 29 psFree (options->filter); 30 psFree (options->dettype); 31 psFree (options->version); 27 } 28 29 psFree(options->camera); 30 psFree(options->filter); 31 psFree(options->dettype); 32 psFree(options->version); 32 33 33 34 return; … … 37 38 pmDetrendSelectOptions *pmDetrendSelectOptionsAlloc(const char *camera, psTime time, pmDetrendType type) 38 39 { 39 40 40 pmDetrendSelectOptions *options = psAlloc(sizeof(pmDetrendSelectOptions)); 41 41 psMemSetDeallocator(options, (psFreeFunc) pmDetrendSelectOptionsFree); … … 63 63 } 64 64 65 static void pmDetrendSelectResultsFree (pmDetrendSelectResults *results)66 { 67 68 if (!results) 65 static void pmDetrendSelectResultsFree(pmDetrendSelectResults *results) 66 { 67 68 if (!results) { 69 69 return; 70 71 psFree (results->detID); 70 } 71 72 psFree(results->detID); 72 73 psFree(results->level); 73 74 … … 75 76 } 76 77 77 pmDetrendSelectResults *pmDetrendSelectResultsAlloc ()78 pmDetrendSelectResults *pmDetrendSelectResultsAlloc(void) 78 79 { 79 80 … … 87 88 } 88 89 89 psString pmDetrendTypeToString (pmDetrendType type)90 { 91 92 # define DETREND_STRING_CASE(TTT) \93 case PM_DETREND_TYPE_##TTT: \94 return psStringCopy (#TTT);90 psString pmDetrendTypeToString(pmDetrendType type) 91 { 92 93 #define DETREND_STRING_CASE(TYPE) \ 94 case PM_DETREND_TYPE_##TYPE: \ 95 return psStringCopy(#TYPE); 95 96 96 97 switch (type) { 97 DETREND_STRING_CASE (MASK); 98 DETREND_STRING_CASE (BIAS); 99 DETREND_STRING_CASE (DARK); 100 DETREND_STRING_CASE (FLAT); 101 DETREND_STRING_CASE (FLATCORR); 102 DETREND_STRING_CASE (SHUTTER); 103 DETREND_STRING_CASE (FRINGE); 104 DETREND_STRING_CASE (ASTROM); 98 DETREND_STRING_CASE(NONE); 99 DETREND_STRING_CASE(MASK); 100 DETREND_STRING_CASE(BIAS); 101 DETREND_STRING_CASE(DARK); 102 DETREND_STRING_CASE(FLAT); 103 DETREND_STRING_CASE(FLATCORR); 104 DETREND_STRING_CASE(SHUTTER); 105 DETREND_STRING_CASE(FRINGE); 106 DETREND_STRING_CASE(ASTROM); 105 107 default: 106 108 return NULL; … … 111 113 // detselect -camera (camera) -time (time) -type (type) [others] 112 114 // returns: (type) (class) (exp_flag) DONE 113 pmDetrendSelectResults *pmDetrendSelect (const pmDetrendSelectOptions *options, 114 const pmConfig *config) 115 pmDetrendSelectResults *pmDetrendSelect(const pmDetrendSelectOptions *options, const pmConfig *config) 115 116 { 116 117 PS_ASSERT_PTR_NON_NULL(options, NULL); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmDetrendDB.h
r20401 r23351 25 25 26 26 typedef enum { 27 PM_DETREND_TYPE_NONE, 27 28 PM_DETREND_TYPE_MASK, 28 29 PM_DETREND_TYPE_BIAS, … … 59 60 } pmDetrendSelectResults; 60 61 61 psString pmDetrendTypeToString (pmDetrendType type);62 psString pmDetrendTypeToString(pmDetrendType type); 62 63 63 64 pmDetrendSelectOptions *pmDetrendSelectOptionsAlloc(const char *camera, psTime time, pmDetrendType type); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmFringeStats.c
r21183 r23351 65 65 rng = psMemIncrRefCounter(random); 66 66 } else { 67 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);67 rng = psRandomAlloc(PS_RANDOM_TAUS); 68 68 } 69 69 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmRemnance.c
r21183 r23351 28 28 int numCols = image->numCols, numRows = image->numRows; // Size of image 29 29 30 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator30 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 31 31 32 32 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmShutterCorrection.c
r21457 r23351 911 911 psStats *stats = psStatsAlloc(meanStat | stdevStat); // Statistics to apply 912 912 if (!rng) { 913 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);913 rng = psRandomAlloc(PS_RANDOM_TAUS); 914 914 } else { 915 915 psMemIncrRefCounter(rng); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/pmVisual.c
r21422 r23351 18 18 #include "pmHDU.h" 19 19 #include "pmFPA.h" 20 #include "pmFPAfile.h" 20 21 #include "pmAstrometryObjects.h" 22 #include "pmSubtractionStamps.h" 23 #include "pmTrend2D.h" 21 24 #include "pmFPAExtent.h" 22 25 … … 28 31 # define KAPAY 700 29 32 33 #include "pmAstrometryVisual.h" 34 #include "pmSubtractionVisual.h" 35 #include "pmStackVisual.h" 36 #include "pmSourceVisual.h" 37 38 //#define TESTING 39 40 static bool isVisual = false; 41 42 43 bool pmVisualSetVisual(bool value) { 44 isVisual = value; 45 return true; 46 } 47 48 49 bool pmVisualIsVisual(void) {return isVisual;} 50 51 bool pmVisualClose(void) { 52 pmAstromVisualClose(); 53 pmSubtractionVisualClose(); 54 pmStackVisualClose(); 55 pmSourceVisualClose(); 56 //XXX handle psphot 57 // psphotVisualClose(); 58 return true; 59 } 30 60 31 61 bool pmVisualInitWindow (int *kapid, char *name) { … … 34 64 if (*kapid == -1) { 35 65 fprintf (stderr, "Failure to open kapa.\n"); 66 isVisual = false; 36 67 return false; 37 68 } … … 52 83 53 84 54 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag)85 bool pmVisualAskUser(bool *plotFlag) 55 86 { 56 87 char key[10]; … … 63 94 } 64 95 if (key[0] == 'a') { 65 *packageFlag= false;96 isVisual = false; 66 97 } 67 98 return true; … … 182 213 183 214 bool pmVisualScaleImage(int kapaFD, psImage *inImage, const char *name, int channel, bool clip) { 184 185 215 KiiImage image; 186 216 KapaImageData data; 187 217 Coords coords; 188 218 189 //make sure we have a compatible image type 219 //make sure we have a compatible image 220 if (inImage == NULL) { 221 fprintf(stderr, "Image is NULL, and cannot be displayed\n"); 222 return false; 223 } 224 190 225 if(inImage->type.type != PS_TYPE_F32) { 191 226 fprintf(stderr, "Cannot display this image (imcompatible data type)\n"); … … 194 229 195 230 strcpy (coords.ctype, "RA---TAN"); 231 196 232 197 233 double min, max, stdev, mean; … … 304 340 305 341 #else 306 342 bool pmVisualSetVisual(bool value) {return true;} 343 bool pmVisualIsVisual(void) {return false;} 344 bool pmVisualClose(void) {return true;} 307 345 bool pmVisualInitWindow(int *kapid, char *name){return true;} 308 346 bool pmVisualInitGraph (int kapa, void *section, void *graphdata){return true;} 309 347 310 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag){return true;}348 bool pmVisualAskUser(bool *plotFlag){return true;} 311 349 bool pmVisualImStats(psImage *image, double *mean, 312 350 double *stdev, double *min, double *max){return true;} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/pmVisual.h
r21422 r23351 10 10 11 11 #if (HAVE_KAPA) 12 13 14 /** Globally enable or disable plotting 15 * @param value - true to enable plotting 16 * @return true 17 */ 18 bool pmVisualSetVisual(bool value); 19 20 21 /** Check whether plotting is enabled 22 * @retrun true if plots should be generated 23 */ 24 bool pmVisualIsVisual(void); 25 26 27 /** Destroy plotting windows at the end of a run 28 * @return true for success */ 29 bool pmVisualClose(void); 12 30 13 31 … … 32 50 * At the user's request, this will disable diagnostic plotting. 33 51 * @param plotFlag, set to false if this plot should be disabled in the future 34 * @param packageFlag, set to false if all plots from this package (e.g. psastro, pmSubtraction)35 * should be disabled.36 52 */ 37 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag);53 bool pmVisualAskUser(bool *plotFlag); 38 54 39 55 … … 115 131 116 132 // kapa-specific data types are changed to void 133 bool pmVisualSetVisual(bool value); 134 bool pmVisualIsVisual(void); 135 bool pmVisualClose(void); 117 136 bool pmVisualInitWindow (int *kapid, char *name); 118 137 bool pmVisualInitGraph (int kapa, void *section, void *graphdata); 119 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag);138 bool pmVisualAskUser(bool *plotFlag); 120 139 bool pmVisualScaleImage(int kapaFD, psImage *inImage, 121 140 const char *name, int channel, bool clip); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/Makefile.am
r21422 r23351 19 19 pmSubtractionThreads.c \ 20 20 pmPSFEnvelope.c \ 21 pmSubtractionVisual.c 21 pmSubtractionVisual.c \ 22 pmStackVisual.c 22 23 23 24 pkginclude_HEADERS = \ … … 37 38 pmSubtractionThreads.h \ 38 39 pmPSFEnvelope.h \ 39 pmSubtractionVisual.h 40 pmSubtractionVisual.h \ 41 pmStackVisual.h 40 42 41 43 CLEANFILES = *~ -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmPSFEnvelope.c
r21363 r23351 30 30 31 31 #include "pmPSFEnvelope.h" 32 32 #include "pmStackVisual.h" 33 33 34 34 … … 115 115 for (int i = 0; i < inputs->n; i++) { 116 116 pmPSF *psf = inputs->data[i]; // PSF of interest 117 if (!psf) { 118 continue; 119 } 117 120 pmResiduals *resid = psf->residuals;// PSF residuals 118 121 psf->residuals = NULL; … … 162 165 psStringAppend(&name, "psf_field_%03d.fits", i); 163 166 psFits *fits = psFitsOpen(name, "w"); 167 pmStackVisualPlotTestImage(fakeRO->image, name); 164 168 psFitsWriteImage(fits, NULL, fakeRO->image, 0, NULL); 165 169 psFitsClose(fits); … … 179 183 // Write out the envelope 180 184 psFits *fits = psFitsOpen("psf_field_envelope.fits", "w"); 185 pmStackVisualPlotTestImage(envelope, "psf_field_envelope.fits"); 181 186 psFitsWriteImage(fits, NULL, envelope, 0, NULL); 182 187 psFitsClose(fits); … … 231 236 // Write out the envelope 232 237 psFits *fits = psFitsOpen("psf_field_full.fits", "w"); 238 pmStackVisualPlotTestImage(readout->image, "psf_field_full.fits"); 233 239 psFitsWriteImage(fits, NULL, readout->image, 0, NULL); 234 240 psFitsClose(fits); … … 312 318 { 313 319 psFits *fits = psFitsOpen("psf_field_model.fits", "w"); 320 pmStackVisualPlotTestImage(generated->image, "psf_field_model.fits"); 314 321 psFitsWriteImage(fits, NULL, generated->image, 0, NULL); 315 322 psFitsClose(fits); … … 318 325 { 319 326 psFits *fits = psFitsOpen("psf_field_resid.fits", "w"); 327 pmStackVisualPlotTestImage(generated->image, "psf_field_resid.fits"); 320 328 psFitsWriteImage(fits, NULL, generated->image, 0, NULL); 321 329 psFitsClose(fits); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmStack.c
r21476 r23351 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.48 $ $Name: not supported by cvs2svn $11 * @date $Date: 2009-02-1 3 23:52:14$10 * @version $Revision: 1.48.2.1 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-02-19 17:59:50 $ 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 13 13 * -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionIO.c
r22699 r23351 16 16 17 17 #include "pmSubtractionIO.h" 18 #include "pmStackVisual.h" 18 19 19 20 #define ARRAY_BUFFER 16 // Number to add to array at a time … … 144 145 // CVS tags, used to identify the version of this file (in case incompatibilities are introduced) 145 146 psString cvsFile = psStringCopy("$RCSfile: pmSubtractionIO.c,v $"); 146 psString cvsRev = psStringCopy("$Revision: 1.9 $");147 psString cvsDate = psStringCopy("$Date: 200 8-10-24 21:21:06$");147 psString cvsRev = psStringCopy("$Revision: 1.9.18.1 $"); 148 psString cvsDate = psStringCopy("$Date: 2009-02-19 17:59:50 $"); 148 149 psStringSubstitute(&cvsFile, NULL, "RCSfile: "); 149 150 psStringSubstitute(&cvsRev, NULL, "Revision: "); … … 167 168 168 169 psImage *image = psMetadataLookupPtr(NULL, ro->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL_IMAGE); // Image 170 pmStackVisualPlotTestImage(image, "Subtraction_kernels.fits"); 171 169 172 if (image && !psFitsWriteImage(fits, header, image, 0, EXTNAME_IMAGE)) { 170 173 psError(PS_ERR_IO, false, "Unable to write subtraction kernel image."); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionMatch.c
r21422 r23351 90 90 } 91 91 92 // Check input arguments 93 static bool subtractionMatchCheck(pmReadout *conv1, pmReadout *conv2, // Convolved images 94 const pmReadout *ro1, const pmReadout *ro2, // Input images 95 int stride, // Size for convolution patches 96 float sysError, // Relative systematic error 97 psImageMaskType maskVal, // Value to mask for input 98 psImageMaskType maskBad, // Mask for output bad pixels 99 psImageMaskType maskPoor, // Mask for output poor pixels 100 float poorFrac, // Fraction for "poor" 101 float badFrac, // Maximum fraction of bad input pixels to accept 102 pmSubtractionMode subMode // Mode of subtraction 103 ) 104 { 105 if (subMode != PM_SUBTRACTION_MODE_2) { 106 PM_ASSERT_READOUT_NON_NULL(conv1, false); 107 if (conv1->image) { 108 psFree(conv1->image); 109 conv1->image = NULL; 110 } 111 if (conv1->mask) { 112 psFree(conv1->mask); 113 conv1->mask = NULL; 114 } 115 if (conv1->variance) { 116 psFree(conv1->variance); 117 conv1->variance = NULL; 118 } 119 } 120 if (subMode != PM_SUBTRACTION_MODE_1) { 121 PM_ASSERT_READOUT_NON_NULL(conv2, false); 122 if (conv2->image) { 123 psFree(conv2->image); 124 conv2->image = NULL; 125 } 126 if (conv2->mask) { 127 psFree(conv2->mask); 128 conv2->mask = NULL; 129 } 130 if (conv2->variance) { 131 psFree(conv2->variance); 132 conv2->variance = NULL; 133 } 134 } 135 136 PM_ASSERT_READOUT_NON_NULL(ro1, false); 137 PM_ASSERT_READOUT_NON_NULL(ro2, false); 138 PM_ASSERT_READOUT_IMAGE(ro1, false); 139 PM_ASSERT_READOUT_IMAGE(ro2, false); 140 PS_ASSERT_IMAGES_SIZE_EQUAL(ro1->image, ro2->image, false); 141 PS_ASSERT_INT_NONNEGATIVE(stride, false); 142 if (isfinite(sysError)) { 143 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(sysError, 0.0, false); 144 PS_ASSERT_FLOAT_LESS_THAN(sysError, 1.0, false); 145 } 146 // Don't care about maskVal 147 // Don't care about maskBad 148 // Don't care about maskPoor 149 PS_ASSERT_FLOAT_LARGER_THAN(poorFrac, 0.0, false); 150 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(poorFrac, 1.0, false); 151 if (isfinite(badFrac)) { 152 PS_ASSERT_FLOAT_LARGER_THAN(badFrac, 0.0, false); 153 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(badFrac, 1.0, false); 154 } 155 156 return true; 157 } 158 159 160 161 bool pmSubtractionMatchPrecalc(pmReadout *conv1, pmReadout *conv2, const pmReadout *ro1, const pmReadout *ro2, 162 psMetadata *analysis, int stride, float sysError, 163 psImageMaskType maskVal, psImageMaskType maskBad, psImageMaskType maskPoor, 164 float poorFrac, float badFrac) 165 { 166 PS_ASSERT_METADATA_NON_NULL(analysis, false); 167 168 // Extract the kernels 169 pmSubtractionMode mode = PM_SUBTRACTION_MODE_UNSURE; // Subtraction mode: which image to convolve 170 int size = 0; // Size of kernel 171 psList *kernelList = psListAlloc(NULL); // List of kernels 172 { 173 psMetadataIterator *iter = psMetadataIteratorAlloc(analysis, PS_LIST_HEAD, 174 "^" PM_SUBTRACTION_ANALYSIS_KERNEL "$"); 175 psMetadataItem *item; // Item from iteration 176 while ((item = psMetadataGetAndIncrement(iter))) { 177 if (item->type != PS_DATA_UNKNOWN) { 178 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unexpected type for kernel."); 179 psFree(iter); 180 psFree(kernelList); 181 return false; 182 } 183 pmSubtractionKernels *kernel = item->data.V; // Kernel 184 PM_ASSERT_SUBTRACTION_KERNELS_NON_NULL(kernel, false); 185 size = PS_MAX(size, kernel->size); 186 if (mode == PM_SUBTRACTION_MODE_UNSURE) { 187 mode = kernel->mode; 188 } else if (kernel->mode != mode) { 189 // There's some confusion, so let's set the mode to dual convolution. 190 // This is only used for the subtraction mask, so it's not a big deal. 191 mode = PM_SUBTRACTION_MODE_DUAL; 192 } 193 psListAdd(kernelList, PS_LIST_TAIL, kernel); 194 } 195 psFree(iter); 196 } 197 if (psListLength(kernelList) == 0) { 198 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find kernels"); 199 psFree(kernelList); 200 return false; 201 } 202 psArray *kernels = psListToArray(kernelList); // Array of kernels 203 psFree(kernelList); 204 205 // Extract the regions 206 psArray *regions = psArrayAllocEmpty(kernels->n); // Array of regions 207 { 208 psMetadataIterator *iter = psMetadataIteratorAlloc(analysis, PS_LIST_HEAD, 209 "^" PM_SUBTRACTION_ANALYSIS_REGION "$"); 210 psMetadataItem *item; // Item from iteration 211 while ((item = psMetadataGetAndIncrement(iter))) { 212 if (item->type != PS_DATA_REGION) { 213 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unexpected type for region."); 214 psFree(iter); 215 psFree(kernels); 216 psFree(regions); 217 return false; 218 } 219 psRegion *region = item->data.V; // Region 220 psArrayAdd(regions, regions->n, region); 221 } 222 psFree(iter); 223 } 224 if (regions->n != kernels->n) { 225 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Differing number of kernels (%ld) and regions (%ld)", 226 kernels->n, regions->n); 227 psFree(regions); 228 psFree(kernels); 229 return false; 230 } 231 232 if (!subtractionMatchCheck(conv1, conv2, ro1, ro2, stride, sysError, maskVal, maskBad, maskPoor, 233 poorFrac, badFrac, mode)) { 234 psFree(kernels); 235 psFree(regions); 236 return false; 237 } 238 239 psImage *subMask = pmSubtractionMask(ro1->mask, ro2 ? ro2->mask : NULL, maskVal, size, 0, 240 badFrac, useFFT); // Subtraction mask 241 if (!subMask) { 242 psError(PS_ERR_UNKNOWN, false, "Unable to generate subtraction mask."); 243 psFree(kernels); 244 psFree(regions); 245 return false; 246 } 247 248 psMetadata *outAnalysis = psMetadataAlloc(); // Output analysis values 249 250 psTrace("psModules.imcombine", 2, "Convolving...\n"); 251 for (int i = 0; i < kernels->n; i++) { 252 pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest 253 psRegion *region = regions->data[i]; // Region of interest 254 255 if (!pmSubtractionAnalysis(outAnalysis, kernel, region, ro1->image->numCols, ro1->image->numRows)) { 256 psError(PS_ERR_UNKNOWN, false, "Unable to generate QA data"); 257 psFree(outAnalysis); 258 psFree(subMask); 259 psFree(kernels); 260 psFree(regions); 261 return false; 262 } 263 264 if (!pmSubtractionConvolve(conv1, conv2, ro1, ro2, subMask, stride, maskBad, maskPoor, poorFrac, 265 sysError, region, kernel, true, useFFT)) { 266 psError(PS_ERR_UNKNOWN, false, "Unable to convolve image."); 267 psFree(outAnalysis); 268 psFree(subMask); 269 psFree(kernels); 270 psFree(regions); 271 return false; 272 } 273 } 274 275 psFree(subMask); 276 psFree(kernels); 277 psFree(regions); 278 279 if (conv1) { 280 psMetadataCopy(conv1->analysis, outAnalysis); 281 } 282 if (conv2) { 283 psMetadataCopy(conv2->analysis, outAnalysis); 284 } 285 psFree(outAnalysis); 286 287 return true; 288 } 289 92 290 93 291 bool pmSubtractionMatch(pmReadout *conv1, pmReadout *conv2, const pmReadout *ro1, const pmReadout *ro2, … … 101 299 psImageMaskType maskPoor, float poorFrac, float badFrac, pmSubtractionMode subMode) 102 300 { 103 if (subMode != PM_SUBTRACTION_MODE_2) { 104 PM_ASSERT_READOUT_NON_NULL(conv1, false); 105 if (conv1->image) { 106 psFree(conv1->image); 107 conv1->image = NULL; 108 } 109 if (conv1->mask) { 110 psFree(conv1->mask); 111 conv1->mask = NULL; 112 } 113 if (conv1->variance) { 114 psFree(conv1->variance); 115 conv1->variance = NULL; 116 } 117 } 118 if (subMode != PM_SUBTRACTION_MODE_1) { 119 PM_ASSERT_READOUT_NON_NULL(conv2, false); 120 if (conv2->image) { 121 psFree(conv2->image); 122 conv2->image = NULL; 123 } 124 if (conv2->mask) { 125 psFree(conv2->mask); 126 conv2->mask = NULL; 127 } 128 if (conv2->variance) { 129 psFree(conv2->variance); 130 conv2->variance = NULL; 131 } 132 } 133 134 PM_ASSERT_READOUT_NON_NULL(ro1, false); 135 PM_ASSERT_READOUT_NON_NULL(ro2, false); 136 PM_ASSERT_READOUT_IMAGE(ro1, false); 137 PM_ASSERT_READOUT_IMAGE(ro2, false); 138 PS_ASSERT_IMAGES_SIZE_EQUAL(ro1->image, ro2->image, false); 301 if (!subtractionMatchCheck(conv1, conv2, ro1, ro2, stride, sysError, maskVal, maskBad, maskPoor, 302 poorFrac, badFrac, subMode)) { 303 return false; 304 } 139 305 140 306 PS_ASSERT_INT_NONNEGATIVE(footprint, false); 141 PS_ASSERT_INT_NONNEGATIVE(stride, false);142 307 // regionSize can be just about anything (except maybe negative, but it can be NAN) 143 308 PS_ASSERT_FLOAT_LARGER_THAN(stampSpacing, 0.0, false); … … 168 333 PS_ASSERT_INT_POSITIVE(iter, false); 169 334 PS_ASSERT_FLOAT_LARGER_THAN(rej, 0.0, false); 170 if (isfinite(sysError)) {171 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(sysError, 0.0, NULL);172 PS_ASSERT_FLOAT_LESS_THAN(sysError, 1.0, NULL);173 }174 // Don't care about maskVal175 // Don't care about maskBad176 // Don't care about maskPoor177 PS_ASSERT_FLOAT_LARGER_THAN(poorFrac, 0.0, NULL);178 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(poorFrac, 1.0, NULL);179 if (isfinite(badFrac)) {180 PS_ASSERT_FLOAT_LARGER_THAN(badFrac, 0.0, NULL);181 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(badFrac, 1.0, NULL);182 }183 335 184 336 // If the stamp footprint is smaller than the kernel size, then we won't get much signal in the outer … … 214 366 int numCols = ro1->image->numCols, numRows = ro1->image->numRows; // Image dimensions 215 367 216 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator368 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 217 369 218 370 memCheck("start"); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionMatch.h
r21183 r23351 48 48 ); 49 49 50 /// Match two images using precalculated kernel 51 bool pmSubtractionMatchPrecalc(pmReadout *conv1, ///< Output convolved data for image 1 52 pmReadout *conv2, ///< Output convolved data for image 2 53 const pmReadout *ro1, ///< Image 1 54 const pmReadout *ro2, ///< Image 2 55 psMetadata *analysis, ///< Analysis metadata with pre-calculated kernel, region 56 int stride, ///< Size for convolution patches 57 float sysError, ///< Relative systematic error 58 psImageMaskType maskVal, ///< Value to mask for input 59 psImageMaskType maskBad, ///< Mask for output bad pixels 60 psImageMaskType maskPoor, ///< Mask for output poor pixels 61 float poorFrac, ///< Fraction for "poor" 62 float badFrac ///< Maximum fraction of bad input pixels to accept 63 ); 64 50 65 /// Execute a thread job to measure the PSF width ratios 51 66 bool pmSubtractionOrderThread(psThreadJob *job ///< Job to execute -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionVisual.c
r21422 r23351 28 28 29 29 //variables to determine when things are plotted 30 static bool isVisual = false;31 30 static bool plotConvKernels = true; 32 31 static bool plotStamps = true; … … 42 41 // Initialization Routines 43 42 44 /** start or stop plotting */45 bool pmSubtractionSetVisual (bool mode) {46 isVisual = mode;47 return true;48 }49 43 50 44 … … 65 59 * @return true for success */ 66 60 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) { 67 if (! isVisual|| !plotConvKernels) return true;61 if (!pmVisualIsVisual() || !plotConvKernels) return true; 68 62 if (!pmVisualInitWindow(&kapa, "ppSub:Images")) { 69 isVisual = false;70 63 return false; 71 64 } 72 65 pmVisualScaleImage(kapa, convKernels, "Convolution_Kernels", 0, true); 73 pmVisualAskUser(&plotConvKernels , &isVisual);66 pmVisualAskUser(&plotConvKernels); 74 67 return true; 75 68 } … … 80 73 @return true for success */ 81 74 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro) { 82 if (! isVisual|| !plotStamps) return true;75 if (!pmVisualIsVisual() || !plotStamps) return true; 83 76 if (!pmVisualInitWindow (&kapa, "ppSub:Images")) { 84 isVisual = false;85 77 return false; 86 78 } 87 79 if (!pmVisualInitWindow (&kapa2, "ppSub:StampMasterImage")) { 88 isVisual = false;89 80 return false; 90 81 } … … 145 136 pmVisualScaleImage(kapa, canvas, "Subtraction_Stamps", 0, true); 146 137 147 pmVisualAskUser(&plotStamps , &isVisual);138 pmVisualAskUser(&plotStamps); 148 139 return true; 149 140 } … … 152 143 bool pmSubtractionVisualPlotLeastSquares (pmSubtractionStampList *stamps, bool dual) { 153 144 154 if (! isVisual|| !plotLeastSquares) return true;145 if (!pmVisualIsVisual() || !plotLeastSquares) return true; 155 146 if (!pmVisualInitWindow (&kapa, "PPSub:Images")) { 156 isVisual = false;157 147 return false; 158 148 } … … 209 199 pmVisualScaleImage(kapa, canvas32, "Least_Squares", 0, true); 210 200 211 pmVisualAskUser(&plotLeastSquares , &isVisual);201 pmVisualAskUser(&plotLeastSquares); 212 202 psFree(canvas); 213 203 psFree(canvas32); … … 216 206 217 207 bool pmSubtractionVisualShowSubtraction(psImage *image, psImage *ref, psImage *sub) { 218 if (! isVisual|| !plotImage) return true;208 if (!pmVisualIsVisual() || !plotImage) return true; 219 209 if (!pmVisualInitWindow (&kapa, "PPSub:Images")) { 220 isVisual = false;221 210 return false; 222 211 } … … 225 214 pmVisualScaleImage(kapa, ref, "Reference", 1, true); 226 215 pmVisualScaleImage(kapa, sub, "Subtraction", 2, true); 227 pmVisualAskUser(&plotImage , &isVisual);216 pmVisualAskUser(&plotImage); 228 217 return true; 229 218 } … … 267 256 268 257 #else 269 bool pmSubtractionSetVisual (bool mode) {return true;}270 258 bool pmSubtractionVisualClose() {return true;} 271 259 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) {return true;} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionVisual.h
r21422 r23351 2 2 #define PM_SUBTRACTION_VISUAL_H 3 3 4 bool pmSubtractionSetVisual (bool mode);5 4 bool pmSubtractionVisualClose(); 6 5 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/Makefile.am
r21516 r23351 19 19 pmModelUtils.c \ 20 20 pmSource.c \ 21 pmSourceMasks.c \ 21 22 pmSourceMoments.c \ 22 23 pmSourceExtendedPars.c \ … … 69 70 pmModelUtils.h \ 70 71 pmSource.h \ 72 pmSourceMasks.h \ 71 73 pmSourceExtendedPars.h \ 72 74 pmSourceUtils.h \ -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmFootprint.c
r20937 r23351 28 28 } 29 29 30 psTrace("psModules.objects", 5, "---- begin ----\n");30 psTrace("psModules.objects", 10, "---- begin ----\n"); 31 31 32 32 psFree(tmp->spans); 33 33 psFree(tmp->peaks); 34 34 35 psTrace("psModules.objects", 5, "---- end ----\n");35 psTrace("psModules.objects", 10, "---- end ----\n"); 36 36 } 37 37 … … 42 42 const psImage *image) // region footprint lives in 43 43 { 44 psTrace("psModules.objects", 5, "---- begin ----\n");44 psTrace("psModules.objects", 10, "---- begin ----\n"); 45 45 46 46 static int id = 1; … … 69 69 } 70 70 71 psTrace("psModules.objects", 5, "---- end ----\n");71 psTrace("psModules.objects", 10, "---- end ----\n"); 72 72 return(footprint); 73 73 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmModel.c
r21515 r23351 32 32 static void modelFree(pmModel *tmp) 33 33 { 34 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);34 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 35 35 psFree(tmp->params); 36 36 psFree(tmp->dparams); 37 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);37 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 38 38 } 39 39 … … 44 44 pmModel *pmModelAlloc(pmModelType type) 45 45 { 46 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);46 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 47 47 48 48 pmModelClass *class = pmModelClassSelect (type); … … 87 87 tmp->modelFitStatus = class->modelFitStatus; 88 88 89 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);89 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 90 90 return(tmp); 91 91 } … … 130 130 psF32 pmModelEval(pmModel *model, psImage *image, psS32 col, psS32 row) 131 131 { 132 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);132 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 133 133 PS_ASSERT_PTR_NON_NULL(image, NAN); 134 134 PS_ASSERT_PTR_NON_NULL(model, NAN); … … 144 144 tmpF = model->modelFunc (NULL, model->params, x); 145 145 psFree(x); 146 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);146 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 147 147 return(tmpF); 148 148 } … … 150 150 psF32 pmModelEvalWithOffset(pmModel *model, psImage *image, psS32 col, psS32 row, int dx, int dy) 151 151 { 152 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);152 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 153 153 PS_ASSERT_PTR_NON_NULL(image, false); 154 154 PS_ASSERT_PTR_NON_NULL(model, false); … … 164 164 tmpF = model->modelFunc (NULL, model->params, x); 165 165 psFree(x); 166 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);166 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 167 167 return(tmpF); 168 168 } … … 180 180 ) 181 181 { 182 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);182 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 183 183 184 184 PS_ASSERT_PTR_NON_NULL(model, false); … … 344 344 345 345 psFree(x); 346 psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);346 psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__); 347 347 return(true); 348 348 } … … 356 356 psImageMaskType maskVal) 357 357 { 358 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);358 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 359 359 psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal, 0.0, 0.0); 360 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);360 psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc); 361 361 return(rc); 362 362 } … … 370 370 psImageMaskType maskVal) 371 371 { 372 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);372 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 373 373 psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal, 0.0, 0.0); 374 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);374 psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc); 375 375 return(rc); 376 376 } … … 386 386 int dy) 387 387 { 388 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);388 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 389 389 psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal, dx, dy); 390 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);390 psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc); 391 391 return(rc); 392 392 } … … 402 402 int dy) 403 403 { 404 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);404 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 405 405 psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal, dx, dy); 406 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);406 psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc); 407 407 return(rc); 408 408 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmMoments.c
r19879 r23351 27 27 pmMoments *pmMomentsAlloc() 28 28 { 29 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);29 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 30 30 pmMoments *tmp = (pmMoments *) psAlloc(sizeof(pmMoments)); 31 31 tmp->Mx = 0.0; … … 52 52 tmp->nPixels = 0; 53 53 54 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);54 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 55 55 return(tmp); 56 56 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmPeaks.c
r21514 r23351 37 37 pmPeakType type) 38 38 { 39 psTrace("psModules.objects", 5, "---- begin ----\n");39 psTrace("psModules.objects", 10, "---- begin ----\n"); 40 40 41 41 if (peaks == NULL) { … … 82 82 psFree (peak); 83 83 84 psTrace("psModules.objects", 5, "---- end ----\n");84 psTrace("psModules.objects", 10, "---- end ----\n"); 85 85 return(peaks); 86 86 } … … 96 96 psU32 row) 97 97 { 98 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);98 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 99 99 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 100 100 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL); … … 104 104 tmpVector->data.F32[col] = image->data.F32[row][col]; 105 105 } 106 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);106 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 107 107 return(tmpVector); 108 108 } … … 117 117 psS32 y) 118 118 { 119 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);119 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 120 120 if ((x >= valid.x0) && 121 121 (x <= valid.x1) && 122 122 (y >= valid.y0) && 123 123 (y <= valid.y1)) { 124 psTrace("psModules.objects", 4, "---- %s(true) end ----\n", __func__);124 psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__); 125 125 return(true); 126 126 } 127 psTrace("psModules.objects", 4, "---- %s(false) end ----\n", __func__);127 psTrace("psModules.objects", 10, "---- %s(false) end ----\n", __func__); 128 128 return(false); 129 129 } … … 140 140 pmPeakType type) 141 141 { 142 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);142 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 143 143 static int id = 1; 144 144 pmPeak *tmp = (pmPeak *) psAlloc(sizeof(pmPeak)); … … 157 157 psMemSetDeallocator(tmp, (psFreeFunc) peakFree); 158 158 159 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);159 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 160 160 return(tmp); 161 161 } … … 172 172 int pmPeaksCompareAscend (const void **a, const void **b) 173 173 { 174 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);174 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 175 175 pmPeak *A = *(pmPeak **)a; 176 176 pmPeak *B = *(pmPeak **)b; … … 180 180 diff = A->value - B->value; 181 181 if (diff < FLT_EPSILON) { 182 psTrace("psModules.objects", 3, "---- %s(-1) end ----\n", __func__);182 psTrace("psModules.objects", 10, "---- %s(-1) end ----\n", __func__); 183 183 return (-1); 184 184 } else if (diff > FLT_EPSILON) { 185 psTrace("psModules.objects", 3, "---- %s(+1) end ----\n", __func__);185 psTrace("psModules.objects", 10, "---- %s(+1) end ----\n", __func__); 186 186 return (+1); 187 187 } 188 psTrace("psModules.objects", 3, "---- %s(0) end ----\n", __func__);188 psTrace("psModules.objects", 10, "---- %s(0) end ----\n", __func__); 189 189 return (0); 190 190 } … … 194 194 int pmPeaksCompareDescend (const void **a, const void **b) 195 195 { 196 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);196 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 197 197 pmPeak *A = *(pmPeak **)a; 198 198 pmPeak *B = *(pmPeak **)b; … … 202 202 diff = A->value - B->value; 203 203 if (diff < FLT_EPSILON) { 204 psTrace("psModules.objects", 3, "---- %s(+1) end ----\n", __func__);204 psTrace("psModules.objects", 10, "---- %s(+1) end ----\n", __func__); 205 205 return (+1); 206 206 } else if (diff > FLT_EPSILON) { 207 psTrace("psModules.objects", 3, "---- %s(-1) end ----\n", __func__);207 psTrace("psModules.objects", 10, "---- %s(-1) end ----\n", __func__); 208 208 return (-1); 209 209 } 210 psTrace("psModules.objects", 3, "---- %s(0) end ----\n", __func__);210 psTrace("psModules.objects", 10, "---- %s(0) end ----\n", __func__); 211 211 return (0); 212 212 } … … 258 258 psF32 threshold) 259 259 { 260 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);260 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 261 261 PS_ASSERT_VECTOR_NON_NULL(vector, NULL); 262 262 PS_ASSERT_VECTOR_NON_EMPTY(vector, NULL); … … 276 276 tmpVector = psVectorAlloc(0, PS_TYPE_U32); 277 277 } 278 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);278 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 279 279 return(tmpVector); 280 280 } … … 341 341 } 342 342 343 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);343 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 344 344 return(tmpVector); 345 345 } … … 363 363 psArray *pmPeaksInImage(const psImage *image, psF32 threshold) 364 364 { 365 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);365 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 366 366 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 367 367 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL); 368 368 if ((image->numRows == 1) || (image->numCols == 1)) { 369 369 psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns."); 370 psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);370 psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__); 371 371 return(NULL); 372 372 } … … 425 425 // 426 426 if (image->numRows == 1) { 427 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);427 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 428 428 return(list); 429 429 } … … 549 549 psFree (tmpRow); 550 550 psFree (row1); 551 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);551 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 552 552 return(list); 553 553 } … … 560 560 const psRegion valid) 561 561 { 562 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);562 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 563 563 PS_ASSERT_PTR_NON_NULL(peaks, NULL); 564 564 … … 575 575 psArrayAdd (output, 200, tmpPeak); 576 576 } 577 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);577 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 578 578 return(output); 579 579 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSource.c
r21513 r23351 41 41 return; 42 42 43 psTrace("psModules.objects", 5, "---- begin ----\n");43 psTrace("psModules.objects", 10, "---- begin ----\n"); 44 44 psFree(tmp->peak); 45 45 psFree(tmp->pixels); … … 55 55 psFree(tmp->extpars); 56 56 psFree(tmp->blends); 57 psTrace("psModules.objects", 5, "---- end ----\n");57 psTrace("psModules.objects", 10, "---- end ----\n"); 58 58 } 59 59 … … 94 94 pmSource *pmSourceAlloc() 95 95 { 96 psTrace("psModules.objects", 5, "---- begin ----\n");96 psTrace("psModules.objects", 10, "---- begin ----\n"); 97 97 static int id = 1; 98 98 pmSource *source = (pmSource *) psAlloc(sizeof(pmSource)); … … 131 131 source->extNsigma = NAN; 132 132 133 psTrace("psModules.objects", 5, "---- end ----\n");133 psTrace("psModules.objects", 10, "---- end ----\n"); 134 134 return(source); 135 135 } … … 280 280 pmPSFClump pmSourcePSFClump(psRegion *region, psArray *sources, psMetadata *recipe) 281 281 { 282 psTrace("psModules.objects", 5, "---- begin ----\n");282 psTrace("psModules.objects", 10, "---- begin ----\n"); 283 283 284 284 psArray *peaks = NULL; … … 496 496 } 497 497 498 psTrace("psModules.objects", 5, "---- end ----\n");498 psTrace("psModules.objects", 10, "---- end ----\n"); 499 499 return (psfClump); 500 500 } … … 508 508 bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, psImageMaskType maskSat) 509 509 { 510 psTrace("psModules.objects", 5, "---- begin ----");510 psTrace("psModules.objects", 10, "---- begin ----"); 511 511 512 512 PS_ASSERT_PTR_NON_NULL(sources, false); … … 664 664 psTrace ("psModules.objects", 2, "Ncr: %3d\n", Ncr); 665 665 666 psTrace("psModules.objects", 5, "---- end ----\n");666 psTrace("psModules.objects", 10, "---- end ----\n"); 667 667 return true; 668 668 } … … 692 692 psF32 radius) 693 693 { 694 psTrace("psModules.objects", 5, "---- begin ----\n");694 psTrace("psModules.objects", 10, "---- begin ----\n"); 695 695 PS_ASSERT_PTR_NON_NULL(source, false); 696 696 PS_ASSERT_PTR_NON_NULL(source->peak, false); … … 807 807 psTrace ("psModules.objects", 3, "insufficient valid pixels (%d vs %d; %f) for source\n", 808 808 numPixels, (int)(0.75*R2), Sum); 809 psTrace("psModules.objects", 5, "---- end (false) ----\n");809 psTrace("psModules.objects", 10, "---- end (false) ----\n"); 810 810 return (false); 811 811 } … … 824 824 psTrace ("psModules.objects", 3, "large centroid swing; invalid peak %d, %d\n", 825 825 source->peak->x, source->peak->y); 826 psTrace("psModules.objects", 5, "---- end(false) ----\n");826 psTrace("psModules.objects", 10, "---- end(false) ----\n"); 827 827 return (false); 828 828 } … … 850 850 source->moments->Mxx, source->moments->Myy, source->moments->Mxy); 851 851 852 psTrace("psModules.objects", 5, "---- end ----\n");852 psTrace("psModules.objects", 10, "---- end ----\n"); 853 853 return(true); 854 854 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSource.h
r21516 r23351 19 19 /// @addtogroup Objects Object Detection / Analysis Functions 20 20 /// @{ 21 22 #include <pmSourceMasks.h> 21 23 22 24 /** pmSourceType enumeration … … 34 36 PM_SOURCE_TYPE_EXTENDED, ///< an extended object (eg, galaxy) (subtracted model is EXT) 35 37 } pmSourceType; 36 37 // bit flags to distinguish analysis results38 typedef enum {39 PM_SOURCE_MODE_DEFAULT = 0x00000000, ///< Initial value: resets all bits40 PM_SOURCE_MODE_PSFMODEL = 0x00000001, ///< Source fitted with a psf model (linear or non-linear)41 PM_SOURCE_MODE_EXTMODEL = 0x00000002, ///< Source fitted with an extended-source model42 PM_SOURCE_MODE_FITTED = 0x00000004, ///< Source fitted with non-linear model (PSF or EXT; good or bad)43 PM_SOURCE_MODE_FAIL = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero)44 PM_SOURCE_MODE_POOR = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?)45 PM_SOURCE_MODE_PAIR = 0x00000020, ///< Source fitted with a double psf46 PM_SOURCE_MODE_PSFSTAR = 0x00000040, ///< Source used to define PSF model47 PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation48 PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sourcers49 PM_SOURCE_MODE_EXTERNAL = 0x00000200, ///< Source based on supplied input position50 PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF51 PM_SOURCE_MODE_DEFECT = 0x00000800, ///< Source is thought to be a defect52 PM_SOURCE_MODE_SATURATED = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail)53 PM_SOURCE_MODE_CR_LIMIT = 0x00002000, ///< Source has crNsigma above limit54 PM_SOURCE_MODE_EXT_LIMIT = 0x00004000, ///< Source has extNsigma above limit55 PM_SOURCE_MODE_MOMENTS_FAILURE = 0x00008000, ///< could not measure the moments56 PM_SOURCE_MODE_SKY_FAILURE = 0x00010000, ///< could not measure the local sky57 PM_SOURCE_MODE_SKYVAR_FAILURE = 0x00020000, ///< could not measure the local sky variance58 PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N59 PM_SOURCE_MODE_BIG_RADIUS = 0x00100000, ///< poor moments for small radius, try large radius60 PM_SOURCE_MODE_AP_MAGS = 0x00200000, ///< source has an aperture magnitude61 PM_SOURCE_MODE_BLEND_FIT = 0x00400000, ///< source was fitted as a blend62 PM_SOURCE_MODE_EXTENDED_FIT = 0x00800000, ///< full extended fit was used63 PM_SOURCE_MODE_EXTENDED_STATS = 0x01000000, ///< extended aperture stats calculated64 PM_SOURCE_MODE_LINEAR_FIT = 0x02000000, ///< source fitted with the linear fit65 PM_SOURCE_MODE_NONLINEAR_FIT = 0x04000000, ///< source fitted with the non-linear fit66 PM_SOURCE_MODE_RADIAL_FLUX = 0x08000000, ///< radial flux measurements calculated67 PM_SOURCE_MODE_SIZE_SKIPPED = 0x10000000, ///< size could not be determined68 } pmSourceMode;69 38 70 39 typedef enum { … … 101 70 pmSourceType type; ///< Best identification of object. 102 71 pmSourceMode mode; ///< analysis flags set for object. 103 pmSourceTmpF tmpFlags; ///< internal-only flags72 pmSourceTmpF tmpFlags; ///< internal-only flags 104 73 psArray *blends; ///< collection of sources thought to be confused with object 105 74 float psfMag; ///< calculated from flux in modelPSF -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceContour.c
r20937 r23351 59 59 { 60 60 61 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);61 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 62 62 63 63 // We define variables incr and lastColumn so that we can use the same loop … … 80 80 float value = image->data.F32[y][subCol]; 81 81 if (value <= threshold) { 82 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);82 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 83 83 return (subCol); 84 84 } 85 85 subCol += incr; 86 86 } 87 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);87 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 88 88 return (lastColumn); 89 89 } … … 99 99 { 100 100 101 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);101 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 102 102 103 103 // We define variables incr and lastColumn so that we can use the same loop … … 119 119 float value = image->data.F32[y][subCol]; 120 120 if (value >= threshold) { 121 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);121 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 122 122 if (subCol == x) { 123 123 return (subCol); … … 127 127 subCol += incr; 128 128 } 129 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);129 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 130 130 return (lastColumn); 131 131 } … … 149 149 psU32 dir) 150 150 { 151 psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);151 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 152 152 // 153 153 // Convert coords to subImage space. … … 159 159 if (!((0 <= subCol) && (subCol < source->pixels->numCols))) { 160 160 psError(PS_ERR_UNKNOWN, true, "Starting column outside subImage range"); 161 psTrace("psModules.objects", 4, "---- %s(NAN) end ----\n", __func__);161 psTrace("psModules.objects", 10, "---- %s(NAN) end ----\n", __func__); 162 162 return(NAN); 163 163 } 164 164 if (!((0 <= subRow) && (subRow < source->pixels->numRows))) { 165 psTrace("psModules.objects", 4, "---- %s(NAN) end ----\n", __func__);165 psTrace("psModules.objects", 10, "---- %s(NAN) end ----\n", __func__); 166 166 psError(PS_ERR_UNKNOWN, true, "Starting row outside subImage range"); 167 167 return(NAN); … … 172 172 psF32 oldValue = pmModelEval(source->modelEXT, source->pixels, subCol, subRow); 173 173 if (oldValue == level) { 174 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);174 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 175 175 return(((psF32) (subCol + source->pixels->col0))); 176 176 } … … 194 194 psF32 newValue = pmModelEval(source->modelEXT, source->pixels, subCol, subRow); 195 195 if (oldValue == level) { 196 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);196 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 197 197 return((psF32) (subCol + source->pixels->col0)); 198 198 } … … 200 200 if ((newValue <= level) && (level <= oldValue)) { 201 201 // This is simple linear interpolation. 202 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);202 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 203 203 return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - newValue) / (oldValue - newValue)) ); 204 204 } … … 206 206 if ((oldValue <= level) && (level <= newValue)) { 207 207 // This is simple linear interpolation. 208 psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);208 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 209 209 return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - oldValue) / (newValue - oldValue)) ); 210 210 } … … 213 213 } 214 214 215 psTrace("psModules.objects", 4, "---- %s(NAN) end ----\n", __func__);215 psTrace("psModules.objects", 10, "---- %s(NAN) end ----\n", __func__); 216 216 return(NAN); 217 217 } … … 222 222 psArray *pmSourceContour (psImage *image, int xc, int yc, float threshold) 223 223 { 224 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);224 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 225 225 PS_ASSERT_PTR_NON_NULL(image, NULL); 226 226 … … 339 339 tmpArray->data[0] = (psPtr *) xVec; 340 340 tmpArray->data[1] = (psPtr *) yVec; 341 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);341 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 342 342 return(tmpArray); 343 343 } … … 360 360 psF32 level) 361 361 { 362 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);362 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 363 363 PS_ASSERT_PTR_NON_NULL(source, false); 364 364 PS_ASSERT_PTR_NON_NULL(image, false); … … 390 390 psFree(xVec); 391 391 psFree(yVec); 392 psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);392 psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__); 393 393 return(NULL); 394 394 //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n"); … … 403 403 psFree(xVec); 404 404 psFree(yVec); 405 psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);405 psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__); 406 406 return(NULL); 407 407 //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n"); … … 428 428 psFree(xVec); 429 429 psFree(yVec); 430 psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);430 psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__); 431 431 return(NULL); 432 432 //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n"); … … 440 440 psFree(xVec); 441 441 psFree(yVec); 442 psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);442 psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__); 443 443 return(NULL); 444 444 //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n"); … … 457 457 tmpArray->data[0] = (psPtr *) yVec; 458 458 tmpArray->data[1] = (psPtr *) xVec; 459 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);459 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 460 460 return(tmpArray); 461 461 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceFitModel.c
r21512 r23351 58 58 psImageMaskType maskVal) 59 59 { 60 psTrace("psModules.objects", 5, "---- %s begin ----\n", __func__);60 psTrace("psModules.objects", 10, "---- %s begin ----\n", __func__); 61 61 PS_ASSERT_PTR_NON_NULL(source, false); 62 62 PS_ASSERT_PTR_NON_NULL(source->pixels, false); … … 231 231 232 232 rc = (onPic && fitStatus); 233 psTrace("psModules.objects", 5, "---- %s(%d) end ----\n", __func__, rc);233 psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc); 234 234 return(rc); 235 235 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceFitSet.c
r21363 r23351 446 446 psImageMaskType maskVal) 447 447 { 448 psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__);448 psTrace("psModules.objects", 10, "---- %s begin ----\n", __func__); 449 449 PS_ASSERT_PTR_NON_NULL(source, false); 450 450 PS_ASSERT_PTR_NON_NULL(source->pixels, false); … … 533 533 if (nPix < thisSet->nParamSet + 1) { 534 534 psTrace (__func__, 4, "insufficient valid pixels\n"); 535 psTrace("psModules.objects", 3, "---- %s() end : fail pixels ----\n", __func__);535 psTrace("psModules.objects", 10, "---- %s() end : fail pixels ----\n", __func__); 536 536 for (int i = 0; i < modelSet->n; i++) { 537 537 pmModel *model = modelSet->data[i]; … … 602 602 603 603 bool rc = (onPic && fitStatus); 604 psTrace("psModules.objects", 5, "---- %s end (%d) ----\n", __func__, rc);604 psTrace("psModules.objects", 10, "---- %s end (%d) ----\n", __func__, rc); 605 605 return(rc); 606 606 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceMatch.c
r21266 r23351 16 16 #define SOURCE_FAINTEST 50.0 // Faintest magnitude to consider 17 17 #define SOURCES_MAX_LEAF 2 // Maximum number of points on a tree leaf 18 18 #define ARRAY_BUFFER 16 // Buffer for array 19 19 20 20 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 63 63 pmSource *source = sources->data[i]; // Source of interest 64 64 if (!source) continue; 65 if (source->mode & SOURCE_MASK) continue;66 if (!isfinite(source->psfMag)) continue;67 if (!isfinite(source->errMag)) continue;68 if (source->psfMag > SOURCE_FAINTEST) continue;65 if (source->mode & SOURCE_MASK) continue; 66 if (!isfinite(source->psfMag)) continue; 67 if (!isfinite(source->errMag)) continue; 68 if (source->psfMag > SOURCE_FAINTEST) continue; 69 69 70 70 float xSrc, ySrc; // Coordinates of source … … 113 113 } 114 114 115 pmSourceMatch *pmSourceMatchAlloc(int num // Maximum number of images 116 ) 115 pmSourceMatch *pmSourceMatchAlloc(void) 117 116 { 118 117 pmSourceMatch *match = psAlloc(sizeof(pmSourceMatch)); // Match data … … 120 119 121 120 match->num = 0; 122 match->mag = psVectorAllocEmpty( num, PS_TYPE_F32);123 match->magErr = psVectorAllocEmpty( num, PS_TYPE_F32);124 match->image = psVectorAllocEmpty( num, PS_TYPE_U32);125 match->index = psVectorAllocEmpty( num, PS_TYPE_U32);126 match->mask = psVectorAllocEmpty( num, PS_TYPE_VECTOR_MASK);121 match->mag = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_F32); 122 match->magErr = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_F32); 123 match->image = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_U32); 124 match->index = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_U32); 125 match->mask = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_VECTOR_MASK); 127 126 128 127 return match; … … 136 135 { 137 136 int num = match->num; // Number of matches 138 psAssert(num <= match->mag->nalloc, "Too many matches."); 139 psAssert(num <= match->magErr->nalloc, "Too many matches."); 140 psAssert(num <= match->image->nalloc, "Too many matches."); 141 psAssert(num <= match->index->nalloc, "Too many matches."); 137 138 match->mag = psVectorExtend(match->mag, match->mag->nalloc, 1); 139 match->magErr = psVectorExtend(match->magErr, match->magErr->nalloc, 1); 140 match->image = psVectorExtend(match->image, match->image->nalloc, 1); 141 match->index = psVectorExtend(match->index, match->index->nalloc, 1); 142 match->mask = psVectorExtend(match->mask, match->mask->nalloc, 1); 142 143 143 144 match->mag->data.F32[num] = mag; … … 148 149 match->num++; 149 150 150 match->mag->n = match->magErr->n = match->image->n = match->index->n = match->mask->n = match->num;151 } 152 153 154 psArray *pmSourceMatchSources(const psArray *sourceArrays, float radius )151 return; 152 } 153 154 155 psArray *pmSourceMatchSources(const psArray *sourceArrays, float radius, bool cullSingles) 155 156 { 156 157 PS_ASSERT_ARRAY_NON_NULL(sourceArrays, NULL); … … 185 186 matches = psArrayAlloc(numSources); 186 187 for (int j = 0; j < numSources; j++) { 187 pmSourceMatch *match = pmSourceMatchAlloc( numImages); // Match data188 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 188 189 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 189 190 matches->data[j] = match; 190 191 } 191 192 numMaster += numSources; 192 goto match_image_done; 193 } 194 195 if (boundsImage->x0 > boundsMaster->x1 || boundsImage->x1 < boundsMaster->x0 || 196 boundsImage->y0 > boundsMaster->y1 || boundsImage->y1 < boundsMaster->y0) { 193 } else if (boundsImage->x0 > boundsMaster->x1 || boundsImage->x1 < boundsMaster->x0 || 194 boundsImage->y0 > boundsMaster->y1 || boundsImage->y1 < boundsMaster->y0) { 195 // Bounds don't overlap --- can just add everything in to the master list 197 196 psTrace("psModules.objects", 7, "Bounds don't overlap\n"); 198 // Add everything in to the master list199 197 long size = numMaster + numSources; // New size 200 198 xMaster = psVectorRealloc(xMaster, size); … … 207 205 numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32)); 208 206 for (int j = 0, k = numMaster; j < numSources; j++, k++) { 209 pmSourceMatch *match = pmSourceMatchAlloc( numImages); // Match data207 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 210 208 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 211 209 matches->data[k] = match; … … 215 213 yMaster->n = size; 216 214 matches->n = size; 217 218 goto match_image_done; 219 } 220 221 // Match with the master list 222 223 psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources 224 long numMatch = 0; // Number of matches 225 226 long size = numMaster + numSources; // New size 227 xMaster = psVectorRealloc(xMaster, size); 228 yMaster = psVectorRealloc(yMaster, size); 229 matches = psArrayRealloc(matches, size); 230 231 psVector *coords = psVectorAlloc(2, PS_TYPE_F32); // Coordinates for tree lookup 232 for (int j = 0; j < numSources; j++) { 233 coords->data.F32[0] = xImage->data.F32[j]; 234 coords->data.F32[1] = yImage->data.F32[j]; 235 long index = psTreeNearestWithin(tree, coords, radius); // Match index 236 if (index >= 0) { 237 // Record the match 238 pmSourceMatch *match = matches->data[index]; // Match data 239 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 240 numMatch++; 241 } else { 242 // Add to the master list 243 pmSourceMatch *match = pmSourceMatchAlloc(numImages); // Match data 244 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 245 xMaster->data.F32[numMaster] = xImage->data.F32[j]; 246 yMaster->data.F32[numMaster] = yImage->data.F32[j]; 247 matches->data[numMaster] = match; 248 numMaster++; 249 xMaster->n = yMaster->n = matches->n = numMaster; 250 } 251 252 } 253 psFree(coords); 254 psFree(tree); 255 256 257 match_image_done: 215 } else { 216 // Match with the master list 217 psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources 218 long numMatch = 0; // Number of matches 219 220 long size = numMaster + numSources; // New size 221 xMaster = psVectorRealloc(xMaster, size); 222 yMaster = psVectorRealloc(yMaster, size); 223 matches = psArrayRealloc(matches, size); 224 225 psVector *coords = psVectorAlloc(2, PS_TYPE_F32); // Coordinates for tree lookup 226 for (int j = 0; j < numSources; j++) { 227 coords->data.F32[0] = xImage->data.F32[j]; 228 coords->data.F32[1] = yImage->data.F32[j]; 229 long index = psTreeNearestWithin(tree, coords, radius); // Match index 230 if (index >= 0) { 231 // Record the match 232 pmSourceMatch *match = matches->data[index]; // Match data 233 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 234 numMatch++; 235 } else { 236 // Add to the master list 237 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 238 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 239 xMaster->data.F32[numMaster] = xImage->data.F32[j]; 240 yMaster->data.F32[numMaster] = yImage->data.F32[j]; 241 matches->data[numMaster] = match; 242 numMaster++; 243 xMaster->n = yMaster->n = matches->n = numMaster; 244 } 245 246 } 247 psFree(coords); 248 psFree(tree); 249 } 250 258 251 psFree(boundsImage); 259 252 psFree(xImage); … … 263 256 } 264 257 265 // Now cull the matches that contain only a single star 266 int numGood = 0; // Number of good matches 258 if (cullSingles) { 259 // Now cull the matches that contain only a single star 260 int numGood = 0; // Number of good matches 261 for (int i = 0; i < matches->n; i++) { 262 pmSourceMatch *match = matches->data[i]; // Match of interest 263 if (match->num > 1) { 264 if (i != numGood) { 265 psFree(matches->data[numGood]); 266 matches->data[numGood] = psMemIncrRefCounter(match); 267 } 268 numGood++; 269 } 270 } 271 matches->n = numGood; 272 for (int i = numGood; i < numMaster; i++) { 273 psFree(matches->data[i]); 274 matches->data[i] = NULL; 275 } 276 } 277 278 return matches; 279 } 280 281 282 psArray *pmSourceMatchMerge(psArray *sourceArrays, float radius) 283 { 284 PS_ASSERT_ARRAY_NON_NULL(sourceArrays, NULL); 285 PS_ASSERT_FLOAT_LARGER_THAN(radius, 0.0, NULL); 286 287 psArray *matches = pmSourceMatchSources(sourceArrays, radius, false); // Source matches 288 if (!matches) { 289 psError(PS_ERR_UNKNOWN, false, "Unable to match source lists."); 290 return NULL; 291 } 292 293 int index = 0; // Index to current position on list 267 294 for (int i = 0; i < matches->n; i++) { 295 pmSource *source = NULL; // Source to put in merged list 268 296 pmSourceMatch *match = matches->data[i]; // Match of interest 269 if (match->num > 1) { 270 if (i != numGood) { 271 psFree(matches->data[numGood]); 272 matches->data[numGood] = psMemIncrRefCounter(match); 273 // psFree(match); 274 } 275 numGood++; 276 } 277 } 278 matches->n = numGood; 279 for (int i = numGood; i < numMaster; i++) { 280 psFree(matches->data[i]); 281 matches->data[i] = NULL; 282 } 297 for (int j = 0; j < match->num && !source; j++) { 298 if (!isfinite(match->mag->data.F32[j]) || !isfinite(match->magErr->data.F32[j])) { 299 continue; 300 } 301 int imgIndex = match->image->data.S32[j]; // Index of image 302 int srcIndex = match->index->data.S32[j]; // Index of source for image 303 psArray *list = sourceArrays->data[imgIndex]; // List of interest 304 source = list->data[srcIndex]; 305 break; 306 } 307 308 if (source) { 309 psFree(matches->data[index]); 310 matches->data[index] = psMemIncrRefCounter(source); 311 index++; 312 } 313 } 314 315 // Clear out the rest of the list 316 int num = index; // Number of good sources 317 for (; index < matches->n; index++) { 318 psFree(matches->data[index]); 319 matches->data[index] = NULL; 320 } 321 matches->n = num; 283 322 284 323 return matches; 285 324 } 286 287 325 288 326 // Iterate on the star magnitudes and image transparencies … … 290 328 static float sourceMatchRelphotIterate(psVector *trans, // Transparencies 291 329 psVector *stars, // Star magnitudes 330 psVector *badImage, // Bad image mask 292 331 const psArray *matches, // Array of matches 293 332 const psVector *zp, // Zero points for each image (incl. airmass term) … … 363 402 for (int i = 0; i < numImages; i++) { 364 403 trans->data.F32[i] = accum->data.F64[i] / accumErr->data.F64[i]; 365 404 if (!isfinite(trans->data.F32[i])) { 405 badImage->data.U8[i] = 0xFF; 406 } 366 407 psTrace("psModules.objects", 3, "Transparency for image %d: %f\n", i, trans->data.F32[i]); 367 408 } … … 379 420 } 380 421 int index = match->image->data.U32[j]; // Image index 422 if (badImage->data.U8[index]) { 423 continue; 424 } 381 425 float mag = match->mag->data.F32[j]; // Measured magnitude 382 426 float magErr2 = PS_SQR(match->magErr->data.F32[j]) + sysErr2; // Error in measured magnitude … … 402 446 static int sourceMatchRelphotPhotometric(psVector *photo, // Photometric determination 403 447 const psVector *trans, // Estimated transparencies 448 const psVector *badImage, // Bad image? 404 449 int transIter, // Iterations for transparency 405 450 float transClip, // Clipping level for transparency … … 409 454 psAssert(photo && photo->type.type == PS_TYPE_U8, "Need photometric determination"); 410 455 psAssert(trans && trans->type.type == PS_TYPE_F32, "Need transparencies"); 456 psAssert(badImage && badImage->type.type == PS_TYPE_U8, "Need bad image determination"); 411 457 412 458 int numImages = photo->n; // Number of images 413 459 414 460 psAssert(trans->n == numImages, "Not enough transparencies: %ld", trans->n); 461 psAssert(badImage->n == numImages, "Not enough bad image determinations: %ld", badImage->n); 415 462 psAssert(transIter >= 0, "Iterations for transparency must be non-negative: %d", transIter); 416 463 psAssert(transClip > 0, "Clipping level for transparency must be positive: %f", transClip); … … 421 468 stats->clipSigma = transClip; 422 469 423 if (!psVectorStats(stats, trans, NULL, NULL, 0)) {470 if (!psVectorStats(stats, trans, NULL, badImage, 0xFF)) { 424 471 psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on transparencies."); 425 472 psFree(stats); … … 432 479 int numPhoto = 0; // Number of photometric images 433 480 for (int i = 0; i < numImages; i++) { 481 if (badImage->data.U8[i]) { 482 continue; 483 } 434 484 if (trans->data.F32[i] < thresh) { 435 485 photo->data.U8[i] = 0xFF; … … 451 501 const psVector *zp, // Zero points for each image 452 502 const psVector *photo, // Photometric image? 503 const psVector *badImage, // Bad image? 453 504 float starClip, // Clipping for stars 454 505 float sysErr2 // Systematic error squared … … 468 519 psAssert(!photo || photo->type.type == PS_TYPE_U8, "Photometric determination is wrong type"); 469 520 psAssert(!photo || photo->n == numImages, "Not enough photometric determinations: %ld", photo->n); 521 psAssert(!badImage || badImage->type.type == PS_TYPE_U8, "Photometric determination is wrong type"); 522 psAssert(!badImage || badImage->n == numImages, "Not enough bad determinations: %ld", badImage->n); 470 523 471 524 starClip = PS_SQR(starClip); … … 481 534 numMeasurements++; 482 535 int index = match->image->data.U32[j]; // Image index 536 if (badImage->data.U8[index]) { 537 continue; 538 } 483 539 float mag = match->mag->data.F32[j]; // Measured magnitude 484 540 float magErr = match->magErr->data.F32[j]; // Error in measured magnitude … … 489 545 float dev = mag + cal - stars->data.F32[i]; // Deviation 490 546 491 // only reject detections from photometric images (non-photometric images can492 // have large errors. XXX Or: allow a much higher rejection threshold493 if (photo->data.U8[index]) {494 if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) {495 numRejected++;496 match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF;497 }498 }547 // only reject detections from photometric images (non-photometric images can 548 // have large errors. XXX Or: allow a much higher rejection threshold 549 if (photo->data.U8[index]) { 550 if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) { 551 numRejected++; 552 match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF; 553 } 554 } 499 555 } 500 556 } … … 506 562 psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches 507 563 const psVector *zp, // Zero points for each image (including airmass term) 508 int maxIter, // Maximum number of iterations509 564 float tol, // Relative tolerance for convergence 565 int iter1, // Number of iterations for pass 1 566 float rej1, // Limit on rejection between iterations for pass 1 567 float sys1, // Systematic error in measurements for pass 1 568 int iter2, // Number of iterations for pass 2 569 float rej2, // Limit on rejection between iterations for pass 2 570 float sys2, // Systematic error in measurements for pass 2 510 571 float rejLimit, // Limit on rejection between iterations 511 572 int transIter, // Clipping iterations for transparency 512 573 float transClip, // Clipping level for transparency 513 float photoLevel, // Level at which we declare image is photometric 514 float starClip, // Clipping for stars 515 float sysErr // Systematic error in measurements 574 float photoLevel // Level at which we declare image is photometric 516 575 ) 517 576 { … … 521 580 PS_ASSERT_FLOAT_LARGER_THAN(transClip, 0.0, NULL); 522 581 523 sysErr *= sysErr; 582 sys1 *= sys1; 583 sys2 *= sys2; 524 584 525 585 int numImages = zp->n; // Number of images … … 529 589 psVector *photo = psVectorAlloc(numImages, PS_TYPE_U8); // Photometric determination for each image 530 590 psVectorInit(photo, 0); 591 psVector *badImage = psVectorAlloc(numImages, PS_TYPE_U8); // Bad image? 592 psVectorInit(badImage, 0); 531 593 psVector *stars = psVectorAlloc(numStars, PS_TYPE_F32); // Magnitudes for each star 532 594 533 float chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, sysErr); // chi^2 for solution 595 float chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, 596 photo, sys1); // chi^2 for solution 534 597 psTrace("psModules.objects", 1, "Initial: chi^2 = %f\n", chi2); 535 598 float lastChi2 = INFINITY; // chi^2 on last iteration 536 599 float fracRej = INFINITY; // Fraction of measurements rejected 537 600 538 // in the first passes, the transparencies are not well deteremined: use high systematic error and the rejection thresholds 539 for (int i = 0; i < 5; i++) { 601 // In the first passes, the transparencies are not well deteremined: use high systematic error and 602 // rejection thresholds 603 for (int i = 0; i < iter1; i++) { 540 604 541 605 // Identify photometric nights 542 int numPhoto = sourceMatchRelphotPhotometric(photo, trans, transIter, transClip, photoLevel); // Number of photometric images 543 if (numPhoto < 0) { 544 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometric determination"); 545 psFree(trans); 546 psFree(photo); 547 psFree(stars); 548 return NULL; 549 } 550 psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages); 551 552 // XXX use 20 sigma rejection and 0.1 mag systematic error (move these to the recipe) 553 fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, 20.0, PS_SQR(0.1)); 554 psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100); 555 556 // XXX use 0.05 mag systematic error (move these to the recipe) 557 chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, PS_SQR(0.1)); // chi^2 for solution 558 psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej); 559 } 560 561 for (int i = 0; i < maxIter && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) { 562 lastChi2 = chi2; 563 564 // Identify photometric nights 565 int numPhoto = sourceMatchRelphotPhotometric(photo, trans, transIter, transClip, 606 int numPhoto = sourceMatchRelphotPhotometric(photo, trans, badImage, transIter, transClip, 566 607 photoLevel); // Number of photometric images 567 608 if (numPhoto < 0) { … … 572 613 return NULL; 573 614 } 574 psTrace("psModules.objects", 3, "Determined %d/%d are photometric", numPhoto, numImages); 575 576 fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, starClip, sysErr); 577 psTrace("psModules.objects", 3, "%f%% of measurements rejected", fracRej * 100); 578 579 chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, sysErr); // chi^2 for solution 580 psTrace("psModules.objects", 1, "iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej); 615 psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages); 616 617 fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej1, sys1); 618 psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100); 619 620 chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys1); 621 psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej); 622 } 623 624 for (int i = 0; i < iter2 && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) { 625 lastChi2 = chi2; 626 627 // Identify photometric nights 628 int numPhoto = sourceMatchRelphotPhotometric(photo, trans, badImage, transIter, transClip, 629 photoLevel); // Number of photometric images 630 if (numPhoto < 0) { 631 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometric determination"); 632 psFree(trans); 633 psFree(photo); 634 psFree(stars); 635 return NULL; 636 } 637 psTrace("psModules.objects", 3, "Pass 2: Determined %d/%d are photometric", numPhoto, numImages); 638 639 fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej2, sys2); 640 psTrace("psModules.objects", 3, "Pass 2: %f%% of measurements rejected", fracRej * 100); 641 642 chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys2); 643 psTrace("psModules.objects", 1, "Pass 2: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej); 581 644 } 582 645 583 646 psFree(photo); 647 psFree(badImage); 584 648 psFree(stars); 585 649 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceMatch.h
r20953 r23351 33 33 34 34 /// Allocator for pmSourceMatch 35 pmSourceMatch *pmSourceMatchAlloc(int num // Maximum number of images 36 ); 35 pmSourceMatch *pmSourceMatchAlloc(void); 37 36 38 37 /// Add a source to a match … … 48 47 /// 49 48 /// Returns an array of psSourceMatch 50 psArray *pmSourceMatchSources(const psArray *sourceArrays, // Array of arrays of sources on each image 51 float radius // Correlation radius 49 psArray *pmSourceMatchSources(const psArray *sourceArrays, ///< Array of arrays of sources on each image 50 float radius, ///< Matching radius 51 bool cullSingles ///< Cull "matches" with only a single source? 52 52 ); 53 54 /// Merge two source lists 55 /// 56 /// Sources are pulled from the lists into a new list, with no effort made to adjust them. 57 psArray *pmSourceMatchMerge(psArray *sourceArrays, ///< Array of arrays of sources on each image 58 float radius ///< Matching radius 59 ); 53 60 54 61 /// Perform relative photometry to calibrate images 55 62 psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches 56 63 const psVector *zp, // Zero points for each image (including airmass term) 57 int maxIter, // Maximum number of iterations58 64 float tol, // Relative tolerance for convergence 65 int iter1, // Number of iterations for pass 1 66 float rej1, // Limit on rejection between iterations for pass 1 67 float sys1, // Systematic error in measurements for pass 1 68 int iter2, // Number of iterations for pass 2 69 float rej2, // Limit on rejection between iterations for pass 2 70 float sys2, // Systematic error in measurements for pass 2 59 71 float rejLimit, // Limit on rejection between iterations 60 72 int transIter, // Clipping iterations for transparency 61 73 float transClip, // Clipping level for transparency 62 float photoLevel, // Level at which we declare image is photometric 63 float starClip, // Clipping for stars 64 float sysErr // Systematic error in measurements 74 float photoLevel // Level at which we declare image is photometric 65 75 ); 66 76 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceSky.c
r21363 r23351 55 55 psImageMaskType markVal) 56 56 { 57 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);57 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 58 58 PS_ASSERT_PTR_NON_NULL(source, false); 59 59 PS_ASSERT_IMAGE_NON_NULL(source->pixels, false); … … 91 91 92 92 if (isnan(value)) { 93 psTrace("psModules.objects", 3, "---- %s(false) end ----\n", __func__);93 psTrace("psModules.objects", 10, "---- %s(false) end ----\n", __func__); 94 94 return(false); 95 95 } … … 98 98 } 99 99 source->moments->Sky = value; 100 psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);100 psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__); 101 101 return (true); 102 102 } … … 111 111 ) 112 112 { 113 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);113 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 114 114 PS_ASSERT_PTR_NON_NULL(source, false); 115 115 PS_ASSERT_IMAGE_NON_NULL(source->variance, false); … … 147 147 148 148 if (isnan(value)) { 149 psTrace("psModules.objects", 3, "---- %s(false) end ----\n", __func__);149 psTrace("psModules.objects", 10, "---- %s(false) end ----\n", __func__); 150 150 return(false); 151 151 } … … 154 154 } 155 155 source->moments->dSky = value; 156 psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);156 psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__); 157 157 return (true); 158 158 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceUtils.c
r20937 r23351 49 49 pmModelType modelType) 50 50 { 51 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);51 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 52 52 PS_ASSERT_PTR_NON_NULL(source, NULL); 53 53 PS_ASSERT_PTR_NON_NULL(source->moments, NULL); … … 61 61 } 62 62 63 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);63 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 64 64 return(model); 65 65 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceVisual.c
r21183 r23351 7 7 #include "pmSourceVisual.h" 8 8 9 # if (HAVE_KAPA) 10 # include <kapa.h> 9 #if (HAVE_KAPA) 10 #include <kapa.h> 11 #include "pmVisual.h" 11 12 12 13 // functions used to visualize the analysis as it goes 13 14 // these are invoked by the -visual options 14 15 15 static bool isVisual = false;16 16 static int kapa1 = -1; 17 static bool plotPSF = true; 17 18 // static int kapa2 = -1; 18 19 // static int kapa3 = -1; 19 20 21 bool pmSourceVisualClose() { 22 if (kapa1 != -1) 23 KiiClose(kapa1); 24 return true; 25 } 26 20 27 bool pmSourcePlotPoints3D (int myKapa, Graphdata *graphdata, psVector *xn, psVector *yn, psVector *zn, float theta, float phi); 21 28 22 bool pmSourceSetVisual (bool mode) {23 24 isVisual = mode;25 return true;26 }27 29 28 30 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask) { 29 31 30 KapaSection section; // put the positive profile in one and the residuals in another? 32 KapaSection section; // put the positive profile in one and the residuals in another? 31 33 32 34 Graphdata graphdata; 33 35 34 if (! isVisual) return true;36 if (!pmVisualIsVisual() || !plotPSF) return true; 35 37 36 38 if (kapa1 == -1) { 37 39 kapa1 = KapaOpenNamedSocket ("kapa", "pmSource:plots"); 38 if (kapa1 == -1) {39 fprintf (stderr, "failure to open kapa; visual mode disabled\n");40 isVisual = false;41 return false;42 }43 } 40 if (kapa1 == -1) { 41 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 42 pmVisualSetVisual(false); 43 return false; 44 } 45 } 44 46 45 47 KapaClearPlots (kapa1); … … 55 57 56 58 for (int i = 0; i < x->n; i++) { 57 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]);58 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i];59 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;60 min = PS_MIN (min, resid->data.F32[i]);61 max = PS_MAX (max, resid->data.F32[i]);62 Min = PS_MIN (min, param->data.F32[i]);63 Max = PS_MAX (max, param->data.F32[i]);59 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 60 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i]; 61 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 62 min = PS_MIN (min, resid->data.F32[i]); 63 max = PS_MAX (max, resid->data.F32[i]); 64 Min = PS_MIN (min, param->data.F32[i]); 65 Max = PS_MAX (max, param->data.F32[i]); 64 66 } 65 67 … … 70 72 psVector *Fn = psVectorAlloc (x->n, PS_TYPE_F32); 71 73 for (int i = 0; i < x->n; i++) { 72 xn->data.F32[i] = x->data.F32[i] / 5000.0;73 yn->data.F32[i] = y->data.F32[i] / 5000.0;74 zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min);75 Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min);76 Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min);74 xn->data.F32[i] = x->data.F32[i] / 5000.0; 75 yn->data.F32[i] = y->data.F32[i] / 5000.0; 76 zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min); 77 Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min); 78 Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min); 77 79 } 78 80 … … 152 154 // pause and wait for user input: 153 155 // continue, save (provide name), ?? 154 char key[10]; 155 fprintf (stdout, "[c]ontinue? "); 156 if (!fgets(key, 8, stdin)) { 157 psWarning("Unable to read option"); 158 } 156 pmVisualAskUser(&plotPSF); 157 159 158 return true; 160 159 } … … 173 172 174 173 for (int i = 0; i < xn->n; i++) { 175 xv->data.F32[2*i+0] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi) + zn->data.F32[i]*sin(theta)*sin(phi);176 yv->data.F32[2*i+0] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi) + zn->data.F32[i]*cos(theta)*sin(phi);177 zv->data.F32[2*i+0] = -yn->data.F32[i]*sin(phi) + zn->data.F32[i]*cos(phi);178 xv->data.F32[2*i+1] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi);179 yv->data.F32[2*i+1] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi);180 zv->data.F32[2*i+1] = -yn->data.F32[i]*sin(phi);181 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+0]);182 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+0]);183 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+0]);184 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+0]);185 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+1]);186 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+1]);187 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+1]);188 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+1]);174 xv->data.F32[2*i+0] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi) + zn->data.F32[i]*sin(theta)*sin(phi); 175 yv->data.F32[2*i+0] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi) + zn->data.F32[i]*cos(theta)*sin(phi); 176 zv->data.F32[2*i+0] = -yn->data.F32[i]*sin(phi) + zn->data.F32[i]*cos(phi); 177 xv->data.F32[2*i+1] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi); 178 yv->data.F32[2*i+1] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi); 179 zv->data.F32[2*i+1] = -yn->data.F32[i]*sin(phi); 180 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+0]); 181 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+0]); 182 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+0]); 183 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+0]); 184 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+1]); 185 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+1]); 186 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+1]); 187 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+1]); 189 188 } 190 189 xv->n = xn->n; … … 253 252 } 254 253 255 # else 256 # endif 254 #else 255 256 bool pmSourceSetVisual(bool mode) 257 { 258 return true; 259 } 260 261 bool pmSourceVisualPSFModelResid(pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask) 262 { 263 return true; 264 } 265 266 #endif -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceVisual.h
r20582 r23351 1 1 /* @file pmKapaPlots.h 2 * @brief functions to make plots with the external program 'kapa' 2 * @brief functions to make plots with the external program 'kapa' 3 3 * 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-11-08 01:52:34$6 * @version $Revision: 1.1.16.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-19 17:59:50 $ 8 8 * Copyright 2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 12 12 #define PM_SOURCE_VISUAL_H 13 13 14 bool pmSourceVisualClose(void); 15 14 16 /// @addtogroup Extras Miscellaneous Funtions 15 17 /// @{ 16 18 17 bool pmSourceSetVisual (bool mode);18 19 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask); 19 20 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/psmodules.h
r22699 r23351 101 101 #include <pmReadoutCombine.h> 102 102 #include <pmSubtractionVisual.h> 103 #include <pmStackVisual.h> 103 104 104 105 // the following headers are from psModule:objects … … 113 114 #include <pmPSF.h> 114 115 #include <pmModel.h> 116 #include <pmSourceMasks.h> 115 117 #include <pmSource.h> 116 118 #include <pmSourceUtils.h> -
branches/cnb_branches/cnb_branch_20090301/psModules/test/detrend/tap_pmMaskBadPixels.c
r15160 r23351 282 282 pmCell *cell = generateSimpleCell(NULL); 283 283 pmReadout *in = generateSimpleReadout(cell); 284 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);284 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 285 285 286 286 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with NULL input pmReadout"); … … 301 301 psFree(in->image); 302 302 in->image = NULL; 303 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);303 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 304 304 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with NULL input pmReadout->image"); 305 305 psFree(rng); … … 319 319 psFree(in->image); 320 320 in->image = psImageAlloc(0, 0, PS_TYPE_F32); 321 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);321 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 322 322 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with empty input pmReadout->image"); 323 323 psFree(rng); … … 337 337 psFree(in->image); 338 338 in->image = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_S32); 339 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);339 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 340 340 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect type for pmReadout->image"); 341 341 psFree(rng); … … 355 355 psFree(in->mask); 356 356 in->mask = psImageAlloc(0, 0, PS_TYPE_MASK); 357 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);357 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 358 358 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect type for pmReadout->image"); 359 359 psFree(rng); … … 373 373 psFree(in->mask); 374 374 in->mask = psImageAlloc(TEST_NUM_COLS/2, TEST_NUM_ROWS/2, PS_TYPE_MASK); 375 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);375 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 376 376 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with bad size for in->mask"); 377 377 psFree(rng); … … 391 391 psFree(in->mask); 392 392 in->mask = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_S32); 393 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);393 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 394 394 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with bad type for in->mask"); 395 395 psFree(rng); … … 407 407 pmCell *cell = generateSimpleCell(NULL); 408 408 pmReadout *in = generateSimpleReadout(cell); 409 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);409 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 410 410 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with empty out image"); 411 411 psFree(rng); … … 423 423 pmCell *cell = generateSimpleCell(NULL); 424 424 pmReadout *in = generateSimpleReadout(cell); 425 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);425 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 426 426 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect type for out image"); 427 427 psFree(rng); … … 439 439 pmCell *cell = generateSimpleCell(NULL); 440 440 pmReadout *in = generateSimpleReadout(cell); 441 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);441 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 442 442 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect size for out image"); 443 443 psFree(rng); … … 455 455 pmCell *cell = generateSimpleCell(NULL); 456 456 pmReadout *in = generateSimpleReadout(cell); 457 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);457 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 458 458 459 459 ok(!pmMaskFlagSuspectPixels(out, in, 0.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with rej input <= 0.0"); … … 472 472 pmCell *cell = generateSimpleCell(NULL); 473 473 pmReadout *in = generateSimpleReadout(cell); 474 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);474 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 475 475 476 476 ok(!pmMaskFlagSuspectPixels(out, in, 1.0, 1, -1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with frac input < 0.0"); -
branches/cnb_branches/cnb_branch_20090301/psModules/test/imcombine/tap_pmImageCombine.c
r11118 r23351 9 9 psArray *generate_images(void) 10 10 { 11 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345); // Random Number Generator11 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); // Random Number Generator 12 12 13 13 // Generate images -
branches/cnb_branches/cnb_branch_20090301/psModules/test/objects/tap_pmFringe.c
r15726 r23351 89 89 ok(fringe != NULL, "pmFringeRegionsAlloc() returned non-NULL"); 90 90 psImage *img = psImageAlloc(NUM_COLS, NUM_ROWS, PS_TYPE_F32); 91 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 10);91 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 10); 92 92 fringe->x = psVectorAlloc(NUM_FRINGE_PNTS/2, PS_TYPE_F32); 93 93 fringe->y = psVectorAlloc(NUM_FRINGE_PNTS/2, PS_TYPE_F32); -
branches/cnb_branches/cnb_branch_20090301/psModules/test/objects/tap_pmSourceFitModel.c
r14654 r23351 27 27 28 28 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) 29 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);29 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 30 30 31 31 static float radius[] = {3.0, 5.0, 7.0, 10.0, 15.0, 25.0}; -
branches/cnb_branches/cnb_branch_20090301/psModules/test/objects/tap_pmSourceFitModel_Delta.c
r14654 r23351 23 23 24 24 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) 25 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);25 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 26 26 27 27 // noise vector to noise up the image … … 167 167 168 168 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) 169 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);169 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 170 170 171 171 static float radius[] = {3.0, 5.0, 7.0, 10.0, 15.0, 25.0};
Note:
See TracChangeset
for help on using the changeset viewer.
