Changeset 21536 for branches/cnb_branch_20090215/psModules
- Timestamp:
- Feb 19, 2009, 7:59:50 AM (17 years ago)
- Location:
- branches/cnb_branch_20090215/psModules/src
- Files:
-
- 1 added
- 27 edited
-
astrom/pmAstrometryVisual.c (modified) (27 diffs)
-
astrom/pmAstrometryVisual.h (modified) (1 diff)
-
camera/pmFPACopy.c (modified) (1 diff)
-
detrend/pmShutterCorrection.h (modified) (1 diff)
-
extras/pmVisual.c (modified) (5 diffs)
-
extras/pmVisual.h (modified) (3 diffs)
-
imcombine/Makefile.am (modified) (2 diffs)
-
imcombine/pmPSFEnvelope.c (modified) (6 diffs)
-
imcombine/pmStack.c (modified) (2 diffs)
-
imcombine/pmSubtractionIO.c (modified) (3 diffs)
-
imcombine/pmSubtractionVisual.c (modified) (10 diffs)
-
imcombine/pmSubtractionVisual.h (modified) (1 diff)
-
objects/Makefile.am (modified) (1 diff)
-
objects/pmModel.c (modified) (5 diffs)
-
objects/pmModel.h (modified) (4 diffs)
-
objects/pmPeaks.c (modified) (7 diffs)
-
objects/pmSource.c (modified) (7 diffs)
-
objects/pmSource.h (modified) (5 diffs)
-
objects/pmSourceFitModel.c (modified) (2 diffs)
-
objects/pmSourceIO.c (modified) (5 diffs)
-
objects/pmSourceIO.h (modified) (4 diffs)
-
objects/pmSourceIO_CMF_PS1_V1.c (added)
-
objects/pmSourceIO_PS1_CAL_0.c (modified) (19 diffs)
-
objects/pmSourceIO_PS1_DEV_1.c (modified) (12 diffs)
-
objects/pmSourcePhotometry.c (modified) (11 diffs)
-
objects/pmSourcePhotometry.h (modified) (2 diffs)
-
objects/pmSourceVisual.c (modified) (6 diffs)
-
objects/pmSourceVisual.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20090215/psModules/src/astrom/pmAstrometryVisual.c
r21422 r21536 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_branch_20090215/psModules/src/astrom/pmAstrometryVisual.h
r21422 r21536 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_branch_20090215/psModules/src/camera/pmFPACopy.c
r21363 r21536 457 457 psMetadataCopy(target->parent->concepts, source->parent->concepts); 458 458 459 // Update the astrometric parameters 460 target->toFPA = psMemIncrRefCounter (source->toFPA); 461 target->fromFPA = psMemIncrRefCounter (source->fromFPA); 462 463 // Update the parent fpa astrometry parameters, or check that they match 464 pmFPA *targetFPA = target->parent; 465 pmFPA *sourceFPA = source->parent; 466 // XXX should we require that both of these exist? 467 468 if (targetFPA && sourceFPA) { 469 if (targetFPA->toSky) { 470 psAssert (targetFPA->toSky == sourceFPA->toSky, "chips within FPA have inconsistent astrometry references"); 471 } else { 472 targetFPA->toSky = psMemIncrRefCounter (sourceFPA->toSky); 473 } 474 if (targetFPA->toTPA) { 475 psAssert (targetFPA->toTPA == sourceFPA->toTPA, "chips within FPA have inconsistent astrometry references"); 476 } else { 477 targetFPA->toTPA = psMemIncrRefCounter (sourceFPA->toTPA); 478 } 479 if (targetFPA->fromTPA) { 480 psAssert (targetFPA->fromTPA == sourceFPA->fromTPA, "chips within FPA have inconsistent astrometry references"); 481 } else { 482 targetFPA->fromTPA = psMemIncrRefCounter (sourceFPA->fromTPA); 483 } 484 } 485 459 486 target->data_exists = true; 460 487 return status; -
branches/cnb_branch_20090215/psModules/src/detrend/pmShutterCorrection.h
r21457 r21536 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $8 * @date $Date: 2009-02-1 2 19:33:30 $7 * @version $Revision: 1.23.2.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-02-19 17:59:50 $ 9 9 * Copyright 2006 Institute for Astronomy, University of Hawaii 10 10 */ -
branches/cnb_branch_20090215/psModules/src/extras/pmVisual.c
r21422 r21536 28 28 # define KAPAY 700 29 29 30 static bool isVisual = false; 31 32 33 bool pmVisualSetVisual(bool value) { 34 isVisual = value; 35 return true; 36 } 37 38 39 bool pmVisualIsVisual(void) {return isVisual;} 40 41 bool pmVisualClose(void) { 42 pmAstrometryVisualClose(); 43 pmSubtractionVisualClose(); 44 pmStackVisualClose(); 45 //XXX handle psphot 46 // psphotVisualClose(); 47 return true; 48 } 30 49 31 50 bool pmVisualInitWindow (int *kapid, char *name) { … … 34 53 if (*kapid == -1) { 35 54 fprintf (stderr, "Failure to open kapa.\n"); 55 isVisual = false; 36 56 return false; 37 57 } … … 52 72 53 73 54 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag)74 bool pmVisualAskUser(bool *plotFlag) 55 75 { 56 76 char key[10]; … … 63 83 } 64 84 if (key[0] == 'a') { 65 *packageFlag= false;85 isVisual = false; 66 86 } 67 87 return true; … … 304 324 305 325 #else 306 326 bool pmVisualSetVisual(bool value) {return true;} 327 bool pmVisualIsVisual(void) {return false;} 328 bool pmVisualClose(void) {return true;} 307 329 bool pmVisualInitWindow(int *kapid, char *name){return true;} 308 330 bool pmVisualInitGraph (int kapa, void *section, void *graphdata){return true;} 309 331 310 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag){return true;}332 bool pmVisualAskUser(bool *plotFlag){return true;} 311 333 bool pmVisualImStats(psImage *image, double *mean, 312 334 double *stdev, double *min, double *max){return true;} -
branches/cnb_branch_20090215/psModules/src/extras/pmVisual.h
r21422 r21536 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_branch_20090215/psModules/src/imcombine/Makefile.am
r21422 r21536 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_branch_20090215/psModules/src/imcombine/pmPSFEnvelope.c
r21363 r21536 30 30 31 31 #include "pmPSFEnvelope.h" 32 33 34 35 //#define TESTING // Enable test output32 #include "pmStackVisual.h" 33 34 35 #define TESTING // Enable test output 36 36 #define PEAK_FLUX 1.0e4 // Peak flux for each source 37 37 #define SKY_VALUE 0.0e0 // Sky value for fake image … … 162 162 psStringAppend(&name, "psf_field_%03d.fits", i); 163 163 psFits *fits = psFitsOpen(name, "w"); 164 pmStackVisualPlotTestImage(fakeRO->image, name); 164 165 psFitsWriteImage(fits, NULL, fakeRO->image, 0, NULL); 165 166 psFitsClose(fits); … … 179 180 // Write out the envelope 180 181 psFits *fits = psFitsOpen("psf_field_envelope.fits", "w"); 182 pmStackVisualPlotTestImage(envelope, "psf_field_envelope.fits"); 181 183 psFitsWriteImage(fits, NULL, envelope, 0, NULL); 182 184 psFitsClose(fits); … … 231 233 // Write out the envelope 232 234 psFits *fits = psFitsOpen("psf_field_full.fits", "w"); 235 pmStackVisualPlotTestImage(readout->image, "psf_field_full.fits"); 233 236 psFitsWriteImage(fits, NULL, readout->image, 0, NULL); 234 237 psFitsClose(fits); … … 312 315 { 313 316 psFits *fits = psFitsOpen("psf_field_model.fits", "w"); 317 pmStackVisualPlotTestImage(generated->image, "psf_field_model.fits"); 314 318 psFitsWriteImage(fits, NULL, generated->image, 0, NULL); 315 319 psFitsClose(fits); … … 318 322 { 319 323 psFits *fits = psFitsOpen("psf_field_resid.fits", "w"); 324 pmStackVisualPlotTestImage(generated->image, "psf_field_resid.fits"); 320 325 psFitsWriteImage(fits, NULL, generated->image, 0, NULL); 321 326 psFitsClose(fits); -
branches/cnb_branch_20090215/psModules/src/imcombine/pmStack.c
r21476 r21536 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 * … … 33 33 #define NUM_DIRECT_STDEV 5 // For less than this number of values, measure stdev directly 34 34 35 //#define TESTING // Enable test output 36 //#define TEST_X 2318 // x coordinate to examine 37 //#define TEST_Y 2306 // y coordinate to examine 35 //CNB change all of these to false 36 #define TESTING // Enable test output 37 #define TEST_X 2318 // x coordinate to examine 38 #define TEST_Y 2306 // y coordinate to examine 38 39 39 40 -
branches/cnb_branch_20090215/psModules/src/imcombine/pmSubtractionIO.c
r20355 r21536 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_branch_20090215/psModules/src/imcombine/pmSubtractionVisual.c
r21422 r21536 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_branch_20090215/psModules/src/imcombine/pmSubtractionVisual.h
r21422 r21536 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_branch_20090215/psModules/src/objects/Makefile.am
r20946 r21536 36 36 pmSourceIO_PS1_DEV_1.c \ 37 37 pmSourceIO_PS1_CAL_0.c \ 38 pmSourceIO_CMF_PS1_V1.c \ 38 39 pmSourcePlots.c \ 39 40 pmSourcePlotPSFModel.c \ -
branches/cnb_branch_20090215/psModules/src/objects/pmModel.c
r21381 r21536 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 20:54:14$8 * @version $Revision: 1.27.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 tmp->chisqNorm = 0.0; 60 60 tmp->nDOF = 0; 61 tmp->nPix = 0; 61 62 tmp->nIter = 0; 62 63 tmp->radiusFit = 0; … … 234 235 235 236 if (model->residuals) { 236 DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5;237 DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5;238 Ro = (model->residuals->Ro) ? model->residuals->Ro->data.F32 : NULL;239 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL;240 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL;241 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;242 if (Ro) {243 NX = model->residuals->Ro->numCols;244 NY = model->residuals->Ro->numRows;245 } 237 DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5; 238 DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5; 239 Ro = (model->residuals->Ro) ? model->residuals->Ro->data.F32 : NULL; 240 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL; 241 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL; 242 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 243 if (Ro) { 244 NX = model->residuals->Ro->numCols; 245 NY = model->residuals->Ro->numRows; 246 } 246 247 } 247 248 … … 255 256 256 257 // XXX should we use using 0.5 pixel offset? 257 // Convert to coordinate in parent image, with offset (dx,dy)258 // Convert to coordinate in parent image, with offset (dx,dy) 258 259 imageCol = ix + image->col0 - dx; 259 260 imageRow = iy + image->row0 - dy; … … 275 276 float rx = xBin*ix + DX; 276 277 277 int rx0 = rx - 0.5;278 int rx1 = rx + 0.5;279 int ry0 = ry - 0.5;280 int ry1 = ry + 0.5;281 282 if (rx0 < 0) goto skip;283 if (ry0 < 0) goto skip;284 if (rx1 >= NX) goto skip;285 if (ry1 >= NY) goto skip;286 287 // these go from 0.0 to 1.0 between the centers of the pixels 288 float fx = rx - 0.5 - rx0;289 float Fx = 1.0 - fx;290 float fy = ry - 0.5 - ry0;291 float Fy = 1.0 - fy;292 293 // check the residual image mask (if set). give up if any of the 4 pixels are masked.294 if (Rm) {295 if (Rm[ry0][rx0]) goto skip;296 if (Rm[ry0][rx1]) goto skip;297 if (Rm[ry1][rx0]) goto skip;298 if (Rm[ry1][rx1]) goto skip;299 }300 301 // a possible further optimization if we re-use these values302 // XXX allow for masked pixels, and add pixel weights303 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);304 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);305 float Vo = V0*Fy + V1*fy;306 if (!isfinite(Vo)) goto skip;307 308 float Vx = 0.0;309 float Vy = 0.0;310 311 // skip Rx,Ry if Ro is masked312 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {313 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);314 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);315 Vx = V0*Fy + V1*fy;316 317 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);318 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);319 Vy = V0*Fy + V1*fy;320 }321 if (!isfinite(Vx)) goto skip;322 if (!isfinite(Vy)) goto skip;323 324 // 2D residual variations are set for the true source position325 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);278 int rx0 = rx - 0.5; 279 int rx1 = rx + 0.5; 280 int ry0 = ry - 0.5; 281 int ry1 = ry + 0.5; 282 283 if (rx0 < 0) goto skip; 284 if (ry0 < 0) goto skip; 285 if (rx1 >= NX) goto skip; 286 if (ry1 >= NY) goto skip; 287 288 // these go from 0.0 to 1.0 between the centers of the pixels 289 float fx = rx - 0.5 - rx0; 290 float Fx = 1.0 - fx; 291 float fy = ry - 0.5 - ry0; 292 float Fy = 1.0 - fy; 293 294 // check the residual image mask (if set). give up if any of the 4 pixels are masked. 295 if (Rm) { 296 if (Rm[ry0][rx0]) goto skip; 297 if (Rm[ry0][rx1]) goto skip; 298 if (Rm[ry1][rx0]) goto skip; 299 if (Rm[ry1][rx1]) goto skip; 300 } 301 302 // a possible further optimization if we re-use these values 303 // XXX allow for masked pixels, and add pixel weights 304 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx); 305 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx); 306 float Vo = V0*Fy + V1*fy; 307 if (!isfinite(Vo)) goto skip; 308 309 float Vx = 0.0; 310 float Vy = 0.0; 311 312 // skip Rx,Ry if Ro is masked 313 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) { 314 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx); 315 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx); 316 Vx = V0*Fy + V1*fy; 317 318 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx); 319 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx); 320 Vy = V0*Fy + V1*fy; 321 } 322 if (!isfinite(Vx)) goto skip; 323 if (!isfinite(Vy)) goto skip; 324 325 // 2D residual variations are set for the true source position 326 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy); 326 327 } 327 328 328 skip:329 skip: 329 330 // add or subtract the value 330 331 if (add) { -
branches/cnb_branch_20090215/psModules/src/objects/pmModel.h
r21183 r21536 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $8 * @date $Date: 2009-0 1-27 06:39:38$7 * @version $Revision: 1.18.8.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-02-19 17:59:50 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 92 92 float mag; ///< integrated model magnitude 93 93 float magErr; ///< integrated model magnitude error 94 int nPix; ///< number of pixels used for fit 94 95 int nDOF; ///< number of degrees of freedom 95 96 int nIter; ///< number of iterations to reach min … … 150 151 pmModel *model, ///< The input pmModel 151 152 pmModelOpMode mode, ///< mode to control how the model is added into the image 152 psImageMaskType maskVal ///< Value to mask153 psImageMaskType maskVal ///< Value to mask 153 154 ); 154 155 … … 168 169 pmModel *model, ///< The input pmModel 169 170 pmModelOpMode mode, ///< mode to control how the model is added into the image 170 psImageMaskType maskVal ///< Value to mask171 psImageMaskType maskVal ///< Value to mask 171 172 ); 172 173 -
branches/cnb_branch_20090215/psModules/src/objects/pmPeaks.c
r20937 r21536 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.25.14.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 AddPeak(): A private function which allocates a psArray, if the peaks 29 29 argument is NULL, otherwise it adds the peak to that array. 30 XXX EAM : row,col now refer to image coords, NOT parent (since this is private) 30 XXX EAM : row,col now refer to image coords, NOT parent (since this is private) 31 31 XXX EAM : now also calculates fractional peak positions from 3x3 bicube region 32 32 *****************************************************************************/ … … 63 63 peak->xf = min.x + ix + image->col0; 64 64 peak->yf = min.y + iy + image->row0; 65 peak->dx = NAN; 66 peak->dy = NAN; 67 68 // xf,yf must land on image with 0 pixel border 69 peak->xf = PS_MAX (PS_MIN (peak->xf, image->numCols - 1), image->col0); 70 peak->yf = PS_MAX (PS_MIN (peak->yf, image->numRows - 1), image->row0); 65 66 // These errors are fractional errors, and should be scaled by the 67 // error on the peak pixel (see, eg, psphotFindPeaks) 68 peak->dx = min.xErr; 69 peak->dy = min.yErr; 70 71 // xf,yf must land on image with 0 pixel border 72 peak->xf = PS_MAX (PS_MIN (peak->xf, image->numCols - 1), image->col0); 73 peak->yf = PS_MAX (PS_MIN (peak->yf, image->numRows - 1), image->row0); 71 74 } else { 72 75 peak->xf = ix; 73 76 peak->yf = iy; 74 peak->dx = NAN;75 peak->dy = NAN;77 peak->dx = NAN; 78 peak->dy = NAN; 76 79 } 77 80 … … 86 89 getRowVectorFromImage(): a private function which simply returns a 87 90 psVector containing the specified row of data from the psImage. 88 91 89 92 XXX: Is there a better way to do this? 90 93 XXX EAM: does this really need to alloc a new vector??? … … 245 248 above the given threshold. Returns a vector of type PS_TYPE_U32 containing 246 249 the location (x value) of all peaks. 247 250 248 251 XXX: What types should be supported? Only F32 is implemented. 249 252 250 253 XXX: We currently step through the input vector twice; once to determine the 251 254 size of the output vector, then to set the values of the output vector. … … 253 256 *****************************************************************************/ 254 257 psVector *pmPeaksInVector(const psVector *vector, 255 psF32 threshold)258 psF32 threshold) 256 259 { 257 260 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 347 350 above the given threshold. Returns a psArray containing location (x/y value) 348 351 of all peaks. 349 352 350 353 XXX: I'm not convinced the peak type definition in the SDRS is mutually 351 354 exclusive. Some peaks can have multiple types. Edges for sure. Also, a 352 355 digonal line with the same value at each point will have a peak for every 353 356 point on that line. 354 357 355 358 XXX: This does not work if image has either a single row, or a single column. 356 359 357 360 The peak is returned in the image parent coordinates 358 361 -
branches/cnb_branch_20090215/psModules/src/objects/pmSource.c
r21363 r21536 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 02:31:25$8 * @version $Revision: 1.69.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 113 113 source->type = PM_SOURCE_TYPE_UNKNOWN; 114 114 source->mode = PM_SOURCE_MODE_DEFAULT; 115 source->tmpFlags = 0; 115 116 source->extpars = NULL; 116 117 source->region = psRegionSet(NAN, NAN, NAN, NAN); … … 534 535 float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 535 536 537 pmSourceMode noMoments = PM_SOURCE_MODE_MOMENTS_FAILURE | PM_SOURCE_MODE_SKYVAR_FAILURE | PM_SOURCE_MODE_SKY_FAILURE | PM_SOURCE_MODE_BELOW_MOMENTS_SN; 538 536 539 // XXX allow clump size to be scaled relative to sigmas? 537 540 // make rough IDs based on clumpX,Y,DX,DY … … 540 543 pmSource *source = (pmSource *) sources->data[i]; 541 544 542 if (source->peak->x < region->x0) continue; 543 if (source->peak->x > region->x1) continue; 544 if (source->peak->y < region->y0) continue; 545 if (source->peak->y > region->y1) continue; 546 547 source->peak->type = 0; 545 // psf clumps are found for image subregions: 546 // skip sources not in this region 547 if (source->peak->x < region->x0) continue; 548 if (source->peak->x >= region->x1) continue; 549 if (source->peak->y < region->y0) continue; 550 if (source->peak->y >= region->y1) continue; 551 552 // should be set by pmSourceAlloc 553 psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?"); 548 554 549 555 // we are basically classifying by moments; use the default if not found 550 556 if (!source->moments) { 551 557 source->type = PM_SOURCE_TYPE_STAR; 558 psAssert (source->mode & noMoments, "why is this source missing moments?"); 552 559 Nstar++; 553 560 continue; … … 1049 1056 } 1050 1057 1058 // sort by Seq (ascending) 1059 int pmSourceSortBySeq (const void **a, const void **b) 1060 { 1061 pmSource *A = *(pmSource **)a; 1062 pmSource *B = *(pmSource **)b; 1063 1064 int iA = A->seq; 1065 int iB = B->seq; 1066 1067 int diff = iA - iB; 1068 if (diff > 0) return (+1); 1069 if (diff < 0) return (-1); 1070 return (0); 1071 } 1072 1051 1073 pmSourceMode pmSourceModeFromString (const char *name) { 1052 1074 if (!strcasecmp (name, "DEFAULT" )) return PM_SOURCE_MODE_DEFAULT; … … 1066 1088 if (!strcasecmp (name, "CRLIMIT" )) return PM_SOURCE_MODE_CR_LIMIT; 1067 1089 if (!strcasecmp (name, "EXTLIMIT" )) return PM_SOURCE_MODE_EXT_LIMIT; 1068 if (!strcasecmp (name, "SUBTRACTED")) return PM_SOURCE_MODE_SUBTRACTED;1069 1090 return PM_SOURCE_MODE_DEFAULT; 1070 1091 } … … 1088 1109 case PM_SOURCE_MODE_CR_LIMIT : return psStringCopy ("CRLIMIT" ); 1089 1110 case PM_SOURCE_MODE_EXT_LIMIT : return psStringCopy ("EXTLIMIT" ); 1090 case PM_SOURCE_MODE_SUBTRACTED : return psStringCopy ("SUBTRACTED");1091 1111 default: 1092 1112 return NULL; -
branches/cnb_branch_20090215/psModules/src/objects/pmSource.h
r21363 r21536 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $6 * @date $Date: 2009-02- 06 02:31:25$5 * @version $Revision: 1.28.4.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 35 35 } pmSourceType; 36 36 37 // bit flags to distinguish analysis results 37 38 typedef enum { 38 PM_SOURCE_MODE_DEFAULT = 0x0000, ///< 39 PM_SOURCE_MODE_PSFMODEL = 0x0001, ///< Source fitted with a psf model (linear or non-linear) 40 PM_SOURCE_MODE_EXTMODEL = 0x0002, ///< Source fitted with an extended-source model 41 PM_SOURCE_MODE_FITTED = 0x0004, ///< Source fitted with non-linear model (PSF or EXT; good or bad) 42 PM_SOURCE_MODE_FAIL = 0x0008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) 43 PM_SOURCE_MODE_POOR = 0x0010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) 44 PM_SOURCE_MODE_PAIR = 0x0020, ///< Source fitted with a double psf 45 PM_SOURCE_MODE_PSFSTAR = 0x0040, ///< Source used to define PSF model 46 PM_SOURCE_MODE_SATSTAR = 0x0080, ///< Source model peak is above saturation 47 PM_SOURCE_MODE_BLEND = 0x0100, ///< Source is a blend with other sourcers 48 PM_SOURCE_MODE_EXTERNAL = 0x0200, ///< Source based on supplied input position 49 PM_SOURCE_MODE_BADPSF = 0x0400, ///< Failed to get good estimate of object's PSF 50 PM_SOURCE_MODE_DEFECT = 0x0800, ///< Source is thought to be a defect 51 PM_SOURCE_MODE_SATURATED = 0x1000, ///< Source is thought to be saturated pixels (bleed trail) 52 PM_SOURCE_MODE_CR_LIMIT = 0x2000, ///< Source has crNsigma above limit 53 PM_SOURCE_MODE_EXT_LIMIT = 0x4000, ///< Source has extNsigma above limit 54 PM_SOURCE_MODE_SUBTRACTED = 0x8000, ///< XXX this flag is actually only used internally (move) 39 PM_SOURCE_MODE_DEFAULT = 0x00000000, ///< Initial value: resets all bits 40 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 model 42 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 psf 46 PM_SOURCE_MODE_PSFSTAR = 0x00000040, ///< Source used to define PSF model 47 PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation 48 PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sourcers 49 PM_SOURCE_MODE_EXTERNAL = 0x00000200, ///< Source based on supplied input position 50 PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF 51 PM_SOURCE_MODE_DEFECT = 0x00000800, ///< Source is thought to be a defect 52 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 limit 54 PM_SOURCE_MODE_EXT_LIMIT = 0x00004000, ///< Source has extNsigma above limit 55 PM_SOURCE_MODE_MOMENTS_FAILURE = 0x00008000, ///< could not measure the moments 56 PM_SOURCE_MODE_SKY_FAILURE = 0x00010000, ///< could not measure the local sky 57 PM_SOURCE_MODE_SKYVAR_FAILURE = 0x00020000, ///< could not measure the local sky variance 58 PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N 59 PM_SOURCE_MODE_BIG_RADIUS = 0x00100000, ///< poor moments for small radius, try large radius 60 PM_SOURCE_MODE_AP_MAGS = 0x00200000, ///< source has an aperture magnitude 61 PM_SOURCE_MODE_BLEND_FIT = 0x00400000, ///< source was fitted as a blend 62 PM_SOURCE_MODE_EXTENDED_FIT = 0x00800000, ///< full extended fit was used 63 PM_SOURCE_MODE_EXTENDED_STATS = 0x01000000, ///< extended aperture stats calculated 64 PM_SOURCE_MODE_LINEAR_FIT = 0x02000000, ///< source fitted with the linear fit 65 PM_SOURCE_MODE_NONLINEAR_FIT = 0x04000000, ///< source fitted with the non-linear fit 66 PM_SOURCE_MODE_RADIAL_FLUX = 0x08000000, ///< radial flux measurements calculated 67 PM_SOURCE_MODE_SIZE_SKIPPED = 0x10000000, ///< size could not be determined 55 68 } pmSourceMode; 69 70 typedef enum { 71 PM_SOURCE_TMPF_MODEL_GUESS = 0x0001, 72 PM_SOURCE_TMPF_SUBTRACTED = 0x0002, 73 } pmSourceTmpF; 56 74 57 75 /** pmSource data structure … … 68 86 */ 69 87 struct pmSource { 70 const int id; ///< Unique ID for object 71 int seq; ///< ID for output (generated on write )88 const int id; ///< Unique ID for object (generated on alloc) 89 int seq; ///< ID for output (generated on write OR set on read) 72 90 pmPeak *peak; ///< Description of peak pixel. 73 91 psImage *pixels; ///< Rectangular region including object pixels. … … 83 101 pmSourceType type; ///< Best identification of object. 84 102 pmSourceMode mode; ///< analysis flags set for object. 103 pmSourceTmpF tmpFlags; ///< internal-only flags 85 104 psArray *blends; ///< collection of sources thought to be confused with object 86 105 float psfMag; ///< calculated from flux in modelPSF … … 240 259 bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal); 241 260 242 int pmSourceSortBySN (const void **a, const void **b); 243 int pmSourceSortByY (const void **a, const void **b); 261 int pmSourceSortBySN (const void **a, const void **b); 262 int pmSourceSortByY (const void **a, const void **b); 263 int pmSourceSortBySeq (const void **a, const void **b); 244 264 245 265 pmSourceMode pmSourceModeFromString (const char *name); -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceFitModel.c
r21363 r21536 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 02:31:25$8 * @version $Revision: 1.30.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 184 184 model->chisq = myMin->value; 185 185 model->nIter = myMin->iter; 186 model->nPix = y->n; 186 187 model->nDOF = y->n - nParams; 187 188 model->flags |= PM_MODEL_STATUS_FITTED; -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO.c
r20937 r21536 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.69.14.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 488 488 } 489 489 if (!strcmp (exttype, "PS1_DEV_1")) { 490 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname , xsrcname);490 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname); 491 491 } 492 492 if (!strcmp (exttype, "PS1_CAL_0")) { 493 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname, xsrcname); 493 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname); 494 } 495 if (!strcmp (exttype, "PS1_V1")) { 496 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname); 494 497 } 495 498 if (xsrcname) { … … 500 503 status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe); 501 504 } 505 if (!strcmp (exttype, "PS1_V1")) { 506 status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe); 507 } 502 508 } 503 509 if (xfitname) { … … 507 513 if (!strcmp (exttype, "PS1_CAL_0")) { 508 514 status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname); 515 } 516 if (!strcmp (exttype, "PS1_V1")) { 517 status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname); 509 518 } 510 519 } … … 929 938 sources = pmSourcesRead_PS1_DEV_1 (file->fits, hdu->header); 930 939 } 931 if (!strcmp (exttype, "PS1_ CAL_)")) {932 sources = pmSourcesRead_ PS1_CAL_0(file->fits, hdu->header);940 if (!strcmp (exttype, "PS1_V1")) { 941 sources = pmSourcesRead_CMF_PS1_V1 (file->fits, hdu->header); 933 942 } 934 943 } -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO.h
r20741 r21536 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-11-14 02:11:45$6 * @version $Revision: 1.19.16.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-19 17:59:50 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 * … … 26 26 bool pmSourcesWrite_SMPDATA (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 27 27 bool pmSourcesWrite_PS1_DEV_0 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 28 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname, char *xsrcname); 28 29 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 29 30 bool pmSourcesWrite_PS1_DEV_1_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe); 30 31 bool pmSourcesWrite_PS1_DEV_1_XFIT (psFits *fits, psArray *sources, char *extname); 31 32 32 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname , char *xsrcname);33 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 33 34 bool pmSourcesWrite_PS1_CAL_0_XSRC (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe); 34 35 bool pmSourcesWrite_PS1_CAL_0_XFIT (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname); 36 37 bool pmSourcesWrite_CMF_PS1_V1 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 38 bool pmSourcesWrite_CMF_PS1_V1_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe); 39 bool pmSourcesWrite_CMF_PS1_V1_XFIT (psFits *fits, psArray *sources, char *extname); 35 40 36 41 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config); … … 42 47 psArray *pmSourcesRead_PS1_DEV_1 (psFits *fits, psMetadata *header); 43 48 psArray *pmSourcesRead_PS1_CAL_0 (psFits *fits, psMetadata *header); 49 psArray *pmSourcesRead_CMF_PS1_V1 (psFits *fits, psMetadata *header); 44 50 45 51 bool pmSourcesWritePSFs (psArray *sources, char *filename); … … 67 73 bool pmReadoutCheckDataStatusForSources (const pmReadout *readout); 68 74 75 bool pmSourceLocalAstrometry (psSphere *ptSky, float *posAngle, float *pltScale, pmChip *chip, float xPos, float yPos); 76 69 77 /// @} 70 78 # endif /* PM_SOURCE_IO_H */ -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO_PS1_CAL_0.c
r20937 r21536 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.2.14.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 49 49 // XXX how do I generate the source tables which I need to send to PSPS? 50 50 51 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader,52 psMetadata * tableHeader, char *extname, char *xsrcname)51 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, 52 psMetadata *imageHeader, psMetadata *tableHeader, char *extname) 53 53 { 54 54 PS_ASSERT_PTR_NON_NULL(fits, false); … … 68 68 pmFPA *fpa = chip->parent; 69 69 if (!chip->toFPA || !fpa->toTPA || !fpa->toSky) { 70 psWarning ("astrometry calibration is missing, no calibrated coords");70 psWarning ("astrometry calibration is missing, no calibrated coords"); 71 71 } 72 72 … … 77 77 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 78 78 if (!status1 || !status2 || (exptime == 0.0)) { 79 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags");79 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags"); 80 80 } else { 81 magOffset = zeropt + 2.5*log10(exptime);81 magOffset = zeropt + 2.5*log10(exptime); 82 82 } 83 83 … … 90 90 for (i = 0; i < sources->n; i++) { 91 91 pmSource *source = (pmSource *) sources->data[i]; 92 if (source->seq == -1) {93 source->seq = i;94 }92 if (source->seq == -1) { 93 source->seq = i; 94 } 95 95 96 96 // no difference between PSF and non-PSF model … … 104 104 xErr = dPAR[PM_PAR_XPOS]; 105 105 yErr = dPAR[PM_PAR_YPOS]; 106 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {107 axes = pmPSF_ModelToAxes (PAR, 20.0);108 } else {109 axes.major = NAN;110 axes.minor = NAN;111 axes.theta = NAN;112 }113 chisq = model->chisq;114 115 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag.116 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];106 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 107 axes = pmPSF_ModelToAxes (PAR, 20.0); 108 } else { 109 axes.major = NAN; 110 axes.minor = NAN; 111 axes.theta = NAN; 112 } 113 chisq = model->chisq; 114 115 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag. 116 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 117 117 } else { 118 118 xPos = source->peak->xf; … … 123 123 axes.minor = NAN; 124 124 axes.theta = NAN; 125 chisq = NAN;126 errMag = NAN;127 } 128 129 float calMag = source->psfMag + magOffset;125 chisq = NAN; 126 errMag = NAN; 127 } 128 129 float calMag = source->psfMag + magOffset; 130 130 float peakMag = (source->peak->flux > 0) ? -2.5*log10(source->peak->flux) : NAN; 131 131 psS16 nImageOverlap = 1; 132 132 133 // generate RA,DEC134 psPlane ptCH, ptFP, ptTP;135 psSphere ptSky;136 137 ptCH.x = xPos;138 ptCH.y = yPos;139 if (chip->toFPA && fpa->toTPA && fpa->toSky) {140 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);141 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);142 psDeproject (&ptSky, &ptTP, fpa->toSky);143 } else {144 ptSky.r = NAN;145 ptSky.d = NAN;146 }133 // generate RA,DEC 134 psPlane ptCH, ptFP, ptTP; 135 psSphere ptSky; 136 137 ptCH.x = xPos; 138 ptCH.y = yPos; 139 if (chip->toFPA && fpa->toTPA && fpa->toSky) { 140 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 141 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 142 psDeproject (&ptSky, &ptTP, fpa->toSky); 143 } else { 144 ptSky.r = NAN; 145 ptSky.d = NAN; 146 } 147 147 148 148 row = psMetadataAlloc (); … … 150 150 psMetadataAdd (row, PS_LIST_TAIL, "RA_PSF", PS_DATA_F32, "PSF RA coordinate (degrees)", ptSky.r*PS_DEG_RAD); 151 151 psMetadataAdd (row, PS_LIST_TAIL, "DEC_PSF", PS_DATA_F32, "PSF DEC coordinate (degrees)", ptSky.d*PS_DEG_RAD); 152 // XXX need to do the error propagation correctly..152 // XXX need to do the error propagation correctly.. 153 153 // psMetadataAdd (row, PS_LIST_TAIL, "RA_PSF_SIG", PS_DATA_F32, "Sigma of PSF fit RA", dRA); 154 154 // psMetadataAdd (row, PS_LIST_TAIL, "DEC_PSF_SIG", PS_DATA_F32, "Sigma of PSF fit DEC", dDEC); … … 170 170 psMetadataAdd (row, PS_LIST_TAIL, "EXT_NSIGMA", PS_DATA_F32, "Nsigma deviations from PSF to EXT", source->extNsigma); 171 171 172 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not173 // subtracted174 175 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image176 // edge; 3) any pixels in the 3x3 peak region are masked; 172 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not 173 // subtracted 174 175 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image 176 // edge; 3) any pixels in the 3x3 peak region are masked; 177 177 178 178 // XXX these should be major and minor, not 'x' and 'y' … … 277 277 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 278 278 source->errMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 279 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;280 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;279 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 280 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN; 281 281 282 282 pmPSF_AxesToModel (PAR, axes); … … 289 289 source->pixWeight = psMetadataLookupF32 (&status, row, "PSF_QF"); 290 290 291 // note that some older versions used PSF_PROBABILITY: this was not well defined.291 // note that some older versions used PSF_PROBABILITY: this was not well defined. 292 292 model->chisq = psMetadataLookupF32 (&status, row, "PSF_CHISQ"); 293 293 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); … … 321 321 pmFPA *fpa = chip->parent; 322 322 if (!chip->toFPA || !fpa->toTPA || !fpa->toSky) { 323 psWarning ("astrometry calibration is missing, no calibrated coords");323 psWarning ("astrometry calibration is missing, no calibrated coords"); 324 324 } 325 325 … … 331 331 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 332 332 if (!status1 || !status2 || (exptime == 0.0)) { 333 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags");333 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags"); 334 334 } else { 335 magOffset = zeropt + 2.5*log10(exptime);336 calMags = true;335 magOffset = zeropt + 2.5*log10(exptime); 336 calMags = true; 337 337 } 338 338 … … 360 360 // we write out all sources, regardless of quality. the source flags tell us the state 361 361 for (int i = 0; i < sources->n; i++) { 362 // skip source if it is not a ext sourc363 // XXX we have two places that extended source parameters are measured:364 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,365 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)366 // should we require both?367 368 pmSource *source = sources->data[i];369 370 // skip sources without measurements371 if (source->extpars == NULL) continue;372 373 // we require a PSF model fit (ignore the real crud)374 pmModel *model = source->modelPSF;375 if (model == NULL) continue;376 377 // XXX I need to split the extended models from the extended aperture measurements378 PAR = model->params->data.F32;379 dPAR = model->dparams->data.F32;380 xPos = PAR[PM_PAR_XPOS];381 yPos = PAR[PM_PAR_YPOS];382 xErr = dPAR[PM_PAR_XPOS];383 yErr = dPAR[PM_PAR_YPOS];384 385 // generate RA,DEC386 psPlane ptCH, ptFP, ptTP;387 psSphere ptSky;388 389 ptCH.x = xPos;390 ptCH.y = yPos;391 if (chip->toFPA && fpa->toTPA && fpa->toSky) {392 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);393 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);394 psDeproject (&ptSky, &ptTP, fpa->toSky);395 } else {396 ptSky.r = NAN;397 ptSky.d = NAN;398 }362 // skip source if it is not a ext sourc 363 // XXX we have two places that extended source parameters are measured: 364 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models, 365 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved) 366 // should we require both? 367 368 pmSource *source = sources->data[i]; 369 370 // skip sources without measurements 371 if (source->extpars == NULL) continue; 372 373 // we require a PSF model fit (ignore the real crud) 374 pmModel *model = source->modelPSF; 375 if (model == NULL) continue; 376 377 // XXX I need to split the extended models from the extended aperture measurements 378 PAR = model->params->data.F32; 379 dPAR = model->dparams->data.F32; 380 xPos = PAR[PM_PAR_XPOS]; 381 yPos = PAR[PM_PAR_YPOS]; 382 xErr = dPAR[PM_PAR_XPOS]; 383 yErr = dPAR[PM_PAR_YPOS]; 384 385 // generate RA,DEC 386 psPlane ptCH, ptFP, ptTP; 387 psSphere ptSky; 388 389 ptCH.x = xPos; 390 ptCH.y = yPos; 391 if (chip->toFPA && fpa->toTPA && fpa->toSky) { 392 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 393 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 394 psDeproject (&ptSky, &ptTP, fpa->toSky); 395 } else { 396 ptSky.r = NAN; 397 ptSky.d = NAN; 398 } 399 399 400 400 row = psMetadataAlloc (); … … 410 410 psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG", PS_DATA_F32, "Sigma in EXT y coordinate", yErr); 411 411 412 // Petrosian measurements413 // XXX insert header data: petrosian ref radius, flux ratio414 if (doPetrosian) {415 pmSourcePetrosianValues *petrosian = source->extpars->petrosian;416 if (petrosian) {417 if (calMags) {418 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_CAL", PS_DATA_F32, "Petrosian Magnitude (calibrated)", petrosian->mag + magOffset);419 } else {420 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_INST", PS_DATA_F32, "Petrosian Magnitude (instrumental)", petrosian->mag);421 }422 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr);423 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad);424 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr);425 } else {426 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN);427 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN);428 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN);429 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN);430 }431 } 432 433 // Kron measurements434 if (doKron) {435 pmSourceKronValues *kron = source->extpars->kron;436 if (kron) {437 if (calMags) {438 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_CAL", PS_DATA_F32, "Kron Magnitude", kron->mag + magOffset);439 } else {440 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_INST", PS_DATA_F32, "Kron Magnitude", kron->mag);441 }442 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr);443 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad);444 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr);445 } else {446 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN);447 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN);448 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN);449 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN);450 }451 }452 453 // Isophot measurements454 // XXX insert header data: isophotal level455 if (doIsophotal) {456 pmSourceIsophotalValues *isophot = source->extpars->isophot;457 if (isophot) {458 if (calMags) {459 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_CAL", PS_DATA_F32, "Isophot Magnitude (calibrated)", isophot->mag + magOffset);460 } else {461 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_INST", PS_DATA_F32, "Isophot Magnitude (uncalibrated)", isophot->mag);462 }463 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr);464 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad);465 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr);466 } else {467 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN);468 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN);469 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN);470 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN);471 }472 }473 474 // Flux Annuli475 if (doAnnuli) {476 pmSourceAnnuli *annuli = source->extpars->annuli;477 if (annuli) {478 psVector *fluxVal = annuli->flux;479 psVector *fluxErr = annuli->fluxErr;480 psVector *fluxVar = annuli->fluxVar;481 482 for (int j = 0; j < fluxVal->n; j++) {483 char name[32];484 sprintf (name, "FLUX_VAL_R_%02d", j);485 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]);486 sprintf (name, "FLUX_ERR_R_%02d", j);487 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]);488 sprintf (name, "FLUX_VAR_R_%02d", j);489 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]);490 } 491 } else {492 for (int j = 0; j < radialBinsLower->n; j++) {493 char name[32];494 sprintf (name, "FLUX_VAL_R_%02d", j);495 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN);496 sprintf (name, "FLUX_ERR_R_%02d", j);497 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN);498 sprintf (name, "FLUX_VAR_R_%02d", j);499 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN);500 } 501 }502 }503 504 psArrayAdd (table, 100, row);505 psFree (row);412 // Petrosian measurements 413 // XXX insert header data: petrosian ref radius, flux ratio 414 if (doPetrosian) { 415 pmSourcePetrosianValues *petrosian = source->extpars->petrosian; 416 if (petrosian) { 417 if (calMags) { 418 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_CAL", PS_DATA_F32, "Petrosian Magnitude (calibrated)", petrosian->mag + magOffset); 419 } else { 420 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_INST", PS_DATA_F32, "Petrosian Magnitude (instrumental)", petrosian->mag); 421 } 422 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr); 423 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad); 424 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr); 425 } else { 426 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN); 427 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN); 428 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN); 429 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN); 430 } 431 } 432 433 // Kron measurements 434 if (doKron) { 435 pmSourceKronValues *kron = source->extpars->kron; 436 if (kron) { 437 if (calMags) { 438 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_CAL", PS_DATA_F32, "Kron Magnitude", kron->mag + magOffset); 439 } else { 440 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_INST", PS_DATA_F32, "Kron Magnitude", kron->mag); 441 } 442 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr); 443 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad); 444 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr); 445 } else { 446 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN); 447 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN); 448 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN); 449 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN); 450 } 451 } 452 453 // Isophot measurements 454 // XXX insert header data: isophotal level 455 if (doIsophotal) { 456 pmSourceIsophotalValues *isophot = source->extpars->isophot; 457 if (isophot) { 458 if (calMags) { 459 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_CAL", PS_DATA_F32, "Isophot Magnitude (calibrated)", isophot->mag + magOffset); 460 } else { 461 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_INST", PS_DATA_F32, "Isophot Magnitude (uncalibrated)", isophot->mag); 462 } 463 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr); 464 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad); 465 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr); 466 } else { 467 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN); 468 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN); 469 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN); 470 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN); 471 } 472 } 473 474 // Flux Annuli 475 if (doAnnuli) { 476 pmSourceAnnuli *annuli = source->extpars->annuli; 477 if (annuli) { 478 psVector *fluxVal = annuli->flux; 479 psVector *fluxErr = annuli->fluxErr; 480 psVector *fluxVar = annuli->fluxVar; 481 482 for (int j = 0; j < fluxVal->n; j++) { 483 char name[32]; 484 sprintf (name, "FLUX_VAL_R_%02d", j); 485 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]); 486 sprintf (name, "FLUX_ERR_R_%02d", j); 487 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]); 488 sprintf (name, "FLUX_VAR_R_%02d", j); 489 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]); 490 } 491 } else { 492 for (int j = 0; j < radialBinsLower->n; j++) { 493 char name[32]; 494 sprintf (name, "FLUX_VAL_R_%02d", j); 495 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN); 496 sprintf (name, "FLUX_ERR_R_%02d", j); 497 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN); 498 sprintf (name, "FLUX_VAR_R_%02d", j); 499 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN); 500 } 501 } 502 } 503 504 psArrayAdd (table, 100, row); 505 psFree (row); 506 506 } 507 507 508 508 if (table->n == 0) { 509 psFitsWriteBlank (fits, outhead, extname);510 psFree (outhead);511 psFree (table);512 return true;509 psFitsWriteBlank (fits, outhead, extname); 510 psFree (outhead); 511 psFree (table); 512 return true; 513 513 } 514 514 515 515 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 516 516 if (!psFitsWriteTable (fits, outhead, table, extname)) { 517 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);518 psFree (outhead);519 psFree(table);520 return false;517 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 518 psFree (outhead); 519 psFree(table); 520 return false; 521 521 } 522 522 psFree (outhead); … … 540 540 pmFPA *fpa = chip->parent; 541 541 if (!chip->toFPA || !fpa->toTPA || !fpa->toSky) { 542 psWarning ("astrometry calibration is missing, no calibrated coords");542 psWarning ("astrometry calibration is missing, no calibrated coords"); 543 543 } 544 544 … … 549 549 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 550 550 if (!status1 || !status2 || (exptime == 0.0)) { 551 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags");551 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags"); 552 552 } else { 553 magOffset = zeropt + 2.5*log10(exptime);553 magOffset = zeropt + 2.5*log10(exptime); 554 554 } 555 555 … … 566 566 int nParamMax = 0; 567 567 for (int i = 0; i < sources->n; i++) { 568 pmSource *source = sources->data[i];569 if (source->modelFits == NULL) continue;570 for (int j = 0; j < source->modelFits->n; j++) {571 pmModel *model = source->modelFits->data[j];572 assert (model);573 nParamMax = PS_MAX (nParamMax, model->params->n);574 }568 pmSource *source = sources->data[i]; 569 if (source->modelFits == NULL) continue; 570 for (int j = 0; j < source->modelFits->n; j++) { 571 pmModel *model = source->modelFits->data[j]; 572 assert (model); 573 nParamMax = PS_MAX (nParamMax, model->params->n); 574 } 575 575 } 576 576 … … 580 580 for (int i = 0; i < sources->n; i++) { 581 581 582 pmSource *source = sources->data[i];583 584 // XXX if no model fits are saved, write out modelEXT?585 if (source->modelFits == NULL) continue;586 587 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model)588 for (int j = 0; j < source->modelFits->n; j++) {589 590 // choose the convolved EXT model, if available, otherwise the simple one591 pmModel *model = source->modelFits->data[j];592 assert (model);593 594 PAR = model->params->data.F32;595 dPAR = model->dparams->data.F32;596 xPos = PAR[PM_PAR_XPOS];597 yPos = PAR[PM_PAR_YPOS];598 xErr = dPAR[PM_PAR_XPOS];599 yErr = dPAR[PM_PAR_YPOS];600 601 axes = pmPSF_ModelToAxes (PAR, 20.0);602 603 // generate RA,DEC604 psPlane ptCH, ptFP, ptTP;605 psSphere ptSky;606 607 ptCH.x = xPos;608 ptCH.y = yPos;609 if (chip->toFPA && fpa->toTPA && fpa->toSky) {610 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);611 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);612 psDeproject (&ptSky, &ptTP, fpa->toSky);613 } else {614 ptSky.r = NAN;615 ptSky.d = NAN;616 }617 618 row = psMetadataAlloc ();619 620 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)621 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq);622 psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT", 0, "EXT model RA (degrees)", ptSky.r);623 psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT", 0, "EXT model DEC (degrees)", ptSky.d);624 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos);625 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos);626 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr);627 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr);628 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_CAL_MAG", 0, "EXT fit calibrated magnitude", model->mag + magOffset);629 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag);630 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr);631 632 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n);633 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type));634 635 // XXX these should be major and minor, not 'x' and 'y'636 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major);637 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor);638 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta);639 640 // write out the other generic parameters641 for (int k = 0; k < nParamMax; k++) {642 if (k == PM_PAR_I0) continue;643 if (k == PM_PAR_SKY) continue;644 if (k == PM_PAR_XPOS) continue;645 if (k == PM_PAR_YPOS) continue;646 if (k == PM_PAR_SXX) continue;647 if (k == PM_PAR_SXY) continue;648 if (k == PM_PAR_SYY) continue;649 650 snprintf (name, 64, "EXT_PAR_%02d", k);651 652 if (k < model->params->n) {653 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]);654 } else {655 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN);656 }657 }658 659 // XXX other parameters which may be set.660 // XXX flag / value to define the model661 // XXX write out the model type, fit status flags662 663 psArrayAdd (table, 100, row);664 psFree (row);665 }582 pmSource *source = sources->data[i]; 583 584 // XXX if no model fits are saved, write out modelEXT? 585 if (source->modelFits == NULL) continue; 586 587 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model) 588 for (int j = 0; j < source->modelFits->n; j++) { 589 590 // choose the convolved EXT model, if available, otherwise the simple one 591 pmModel *model = source->modelFits->data[j]; 592 assert (model); 593 594 PAR = model->params->data.F32; 595 dPAR = model->dparams->data.F32; 596 xPos = PAR[PM_PAR_XPOS]; 597 yPos = PAR[PM_PAR_YPOS]; 598 xErr = dPAR[PM_PAR_XPOS]; 599 yErr = dPAR[PM_PAR_YPOS]; 600 601 axes = pmPSF_ModelToAxes (PAR, 20.0); 602 603 // generate RA,DEC 604 psPlane ptCH, ptFP, ptTP; 605 psSphere ptSky; 606 607 ptCH.x = xPos; 608 ptCH.y = yPos; 609 if (chip->toFPA && fpa->toTPA && fpa->toSky) { 610 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 611 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 612 psDeproject (&ptSky, &ptTP, fpa->toSky); 613 } else { 614 ptSky.r = NAN; 615 ptSky.d = NAN; 616 } 617 618 row = psMetadataAlloc (); 619 620 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc) 621 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 622 psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT", 0, "EXT model RA (degrees)", ptSky.r); 623 psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT", 0, "EXT model DEC (degrees)", ptSky.d); 624 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos); 625 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos); 626 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr); 627 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr); 628 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_CAL_MAG", 0, "EXT fit calibrated magnitude", model->mag + magOffset); 629 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag); 630 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr); 631 632 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n); 633 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type)); 634 635 // XXX these should be major and minor, not 'x' and 'y' 636 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major); 637 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor); 638 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta); 639 640 // write out the other generic parameters 641 for (int k = 0; k < nParamMax; k++) { 642 if (k == PM_PAR_I0) continue; 643 if (k == PM_PAR_SKY) continue; 644 if (k == PM_PAR_XPOS) continue; 645 if (k == PM_PAR_YPOS) continue; 646 if (k == PM_PAR_SXX) continue; 647 if (k == PM_PAR_SXY) continue; 648 if (k == PM_PAR_SYY) continue; 649 650 snprintf (name, 64, "EXT_PAR_%02d", k); 651 652 if (k < model->params->n) { 653 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]); 654 } else { 655 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN); 656 } 657 } 658 659 // XXX other parameters which may be set. 660 // XXX flag / value to define the model 661 // XXX write out the model type, fit status flags 662 663 psArrayAdd (table, 100, row); 664 psFree (row); 665 } 666 666 } 667 667 668 668 if (table->n == 0) { 669 psFitsWriteBlank (fits, outhead, extname);670 psFree (outhead);671 psFree (table);672 return true;669 psFitsWriteBlank (fits, outhead, extname); 670 psFree (outhead); 671 psFree (table); 672 return true; 673 673 } 674 674 675 675 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 676 676 if (!psFitsWriteTable (fits, outhead, table, extname)) { 677 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);678 psFree (outhead);679 psFree(table);680 return false;677 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 678 psFree (outhead); 679 psFree(table); 680 return false; 681 681 } 682 682 psFree (outhead); -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
r20937 r21536 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.14.14.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 49 49 // XXX how do I generate the source tables which I need to send to PSPS? 50 50 51 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader,52 psMetadata * tableHeader, char *extname, char *xsrcname)51 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, 52 psMetadata *imageHeader, psMetadata *tableHeader, char *extname) 53 53 { 54 54 PS_ASSERT_PTR_NON_NULL(fits, false); … … 73 73 for (i = 0; i < sources->n; i++) { 74 74 pmSource *source = (pmSource *) sources->data[i]; 75 if (source->seq == -1) {76 source->seq = i;77 }75 if (source->seq == -1) { 76 source->seq = i; 77 } 78 78 79 79 // no difference between PSF and non-PSF model … … 87 87 xErr = dPAR[PM_PAR_XPOS]; 88 88 yErr = dPAR[PM_PAR_YPOS]; 89 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {90 axes = pmPSF_ModelToAxes (PAR, 20.0);91 } else {92 axes.major = NAN;93 axes.minor = NAN;94 axes.theta = NAN;95 }96 chisq = model->chisq;97 98 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag.99 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];89 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 90 axes = pmPSF_ModelToAxes (PAR, 20.0); 91 } else { 92 axes.major = NAN; 93 axes.minor = NAN; 94 axes.theta = NAN; 95 } 96 chisq = model->chisq; 97 98 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag. 99 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 100 100 } else { 101 101 xPos = source->peak->xf; … … 106 106 axes.minor = NAN; 107 107 axes.theta = NAN; 108 chisq = NAN;109 errMag = NAN;108 chisq = NAN; 109 errMag = NAN; 110 110 } 111 111 … … 130 130 psMetadataAdd (row, PS_LIST_TAIL, "EXT_NSIGMA", PS_DATA_F32, "Nsigma deviations from PSF to EXT", source->extNsigma); 131 131 132 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not133 // subtracted134 135 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image136 // edge; 3) any pixels in the 3x3 peak region are masked; 137 138 // CR_NSIGMA and 132 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not 133 // subtracted 134 135 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image 136 // edge; 3) any pixels in the 3x3 peak region are masked; 137 138 // CR_NSIGMA and 139 139 140 140 // XXX these should be major and minor, not 'x' and 'y' … … 247 247 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 248 248 source->errMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 249 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;250 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;249 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 250 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN; 251 251 252 252 pmPSF_AxesToModel (PAR, axes); … … 259 259 source->pixWeight = psMetadataLookupF32 (&status, row, "PSF_QF"); 260 260 261 // note that some older versions used PSF_PROBABILITY: this was not well defined.261 // note that some older versions used PSF_PROBABILITY: this was not well defined. 262 262 model->chisq = psMetadataLookupF32 (&status, row, "PSF_CHISQ"); 263 263 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); … … 311 311 // we write out all sources, regardless of quality. the source flags tell us the state 312 312 for (int i = 0; i < sources->n; i++) { 313 // skip source if it is not a ext sourc314 // XXX we have two places that extended source parameters are measured:315 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,316 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)317 // should we require both?318 319 pmSource *source = sources->data[i];320 321 // skip sources without measurements322 if (source->extpars == NULL) continue;323 324 // we require a PSF model fit (ignore the real crud)325 pmModel *model = source->modelPSF;326 if (model == NULL) continue;327 328 // XXX I need to split the extended models from the extended aperture measurements329 PAR = model->params->data.F32;330 dPAR = model->dparams->data.F32;331 xPos = PAR[PM_PAR_XPOS];332 yPos = PAR[PM_PAR_YPOS];333 xErr = dPAR[PM_PAR_XPOS];334 yErr = dPAR[PM_PAR_YPOS];313 // skip source if it is not a ext sourc 314 // XXX we have two places that extended source parameters are measured: 315 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models, 316 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved) 317 // should we require both? 318 319 pmSource *source = sources->data[i]; 320 321 // skip sources without measurements 322 if (source->extpars == NULL) continue; 323 324 // we require a PSF model fit (ignore the real crud) 325 pmModel *model = source->modelPSF; 326 if (model == NULL) continue; 327 328 // XXX I need to split the extended models from the extended aperture measurements 329 PAR = model->params->data.F32; 330 dPAR = model->dparams->data.F32; 331 xPos = PAR[PM_PAR_XPOS]; 332 yPos = PAR[PM_PAR_YPOS]; 333 xErr = dPAR[PM_PAR_XPOS]; 334 yErr = dPAR[PM_PAR_YPOS]; 335 335 336 336 row = psMetadataAlloc (); … … 343 343 psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG", PS_DATA_F32, "Sigma in EXT y coordinate", yErr); 344 344 345 // Petrosian measurements346 // XXX insert header data: petrosian ref radius, flux ratio347 if (doPetrosian) {348 pmSourcePetrosianValues *petrosian = source->extpars->petrosian;349 if (petrosian) {350 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", petrosian->mag);351 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr);352 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad);353 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr);354 } else {355 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN);356 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN);357 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN);358 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN);359 }360 } 361 362 // Kron measurements363 if (doKron) {364 pmSourceKronValues *kron = source->extpars->kron;365 if (kron) {366 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", kron->mag);367 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr);368 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad);369 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr);370 } else {371 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN);372 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN);373 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN);374 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN);375 }376 }377 378 // Isophot measurements379 // XXX insert header data: isophotal level380 if (doIsophotal) {381 pmSourceIsophotalValues *isophot = source->extpars->isophot;382 if (isophot) {383 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", isophot->mag);384 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr);385 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad);386 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr);387 } else {388 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN);389 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN);390 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN);391 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN);392 }393 }394 395 // Flux Annuli396 if (doAnnuli) {397 pmSourceAnnuli *annuli = source->extpars->annuli;398 if (annuli) {399 psVector *fluxVal = annuli->flux;400 psVector *fluxErr = annuli->fluxErr;401 psVector *fluxVar = annuli->fluxVar;402 403 for (int j = 0; j < fluxVal->n; j++) {404 char name[32];405 sprintf (name, "FLUX_VAL_R_%02d", j);406 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]);407 sprintf (name, "FLUX_ERR_R_%02d", j);408 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]);409 sprintf (name, "FLUX_VAR_R_%02d", j);410 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]);411 } 412 } else {413 for (int j = 0; j < radialBinsLower->n; j++) {414 char name[32];415 sprintf (name, "FLUX_VAL_R_%02d", j);416 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN);417 sprintf (name, "FLUX_ERR_R_%02d", j);418 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN);419 sprintf (name, "FLUX_VAR_R_%02d", j);420 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN);421 } 422 }423 }424 425 psArrayAdd (table, 100, row);426 psFree (row);345 // Petrosian measurements 346 // XXX insert header data: petrosian ref radius, flux ratio 347 if (doPetrosian) { 348 pmSourcePetrosianValues *petrosian = source->extpars->petrosian; 349 if (petrosian) { 350 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", petrosian->mag); 351 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr); 352 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad); 353 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr); 354 } else { 355 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN); 356 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN); 357 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN); 358 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN); 359 } 360 } 361 362 // Kron measurements 363 if (doKron) { 364 pmSourceKronValues *kron = source->extpars->kron; 365 if (kron) { 366 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", kron->mag); 367 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr); 368 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad); 369 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr); 370 } else { 371 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN); 372 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN); 373 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN); 374 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN); 375 } 376 } 377 378 // Isophot measurements 379 // XXX insert header data: isophotal level 380 if (doIsophotal) { 381 pmSourceIsophotalValues *isophot = source->extpars->isophot; 382 if (isophot) { 383 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", isophot->mag); 384 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr); 385 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad); 386 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr); 387 } else { 388 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN); 389 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN); 390 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN); 391 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN); 392 } 393 } 394 395 // Flux Annuli 396 if (doAnnuli) { 397 pmSourceAnnuli *annuli = source->extpars->annuli; 398 if (annuli) { 399 psVector *fluxVal = annuli->flux; 400 psVector *fluxErr = annuli->fluxErr; 401 psVector *fluxVar = annuli->fluxVar; 402 403 for (int j = 0; j < fluxVal->n; j++) { 404 char name[32]; 405 sprintf (name, "FLUX_VAL_R_%02d", j); 406 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]); 407 sprintf (name, "FLUX_ERR_R_%02d", j); 408 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]); 409 sprintf (name, "FLUX_VAR_R_%02d", j); 410 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]); 411 } 412 } else { 413 for (int j = 0; j < radialBinsLower->n; j++) { 414 char name[32]; 415 sprintf (name, "FLUX_VAL_R_%02d", j); 416 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN); 417 sprintf (name, "FLUX_ERR_R_%02d", j); 418 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN); 419 sprintf (name, "FLUX_VAR_R_%02d", j); 420 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN); 421 } 422 } 423 } 424 425 psArrayAdd (table, 100, row); 426 psFree (row); 427 427 } 428 428 429 429 if (table->n == 0) { 430 psFitsWriteBlank (fits, outhead, extname);431 psFree (outhead);432 psFree (table);433 return true;430 psFitsWriteBlank (fits, outhead, extname); 431 psFree (outhead); 432 psFree (table); 433 return true; 434 434 } 435 435 436 436 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 437 437 if (!psFitsWriteTable (fits, outhead, table, extname)) { 438 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);439 psFree (outhead);440 psFree(table);441 return false;438 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 439 psFree (outhead); 440 psFree(table); 441 return false; 442 442 } 443 443 psFree (outhead); … … 470 470 int nParamMax = 0; 471 471 for (int i = 0; i < sources->n; i++) { 472 pmSource *source = sources->data[i];473 if (source->modelFits == NULL) continue;474 for (int j = 0; j < source->modelFits->n; j++) {475 pmModel *model = source->modelFits->data[j];476 assert (model);477 nParamMax = PS_MAX (nParamMax, model->params->n);478 }472 pmSource *source = sources->data[i]; 473 if (source->modelFits == NULL) continue; 474 for (int j = 0; j < source->modelFits->n; j++) { 475 pmModel *model = source->modelFits->data[j]; 476 assert (model); 477 nParamMax = PS_MAX (nParamMax, model->params->n); 478 } 479 479 } 480 480 … … 484 484 for (int i = 0; i < sources->n; i++) { 485 485 486 pmSource *source = sources->data[i];487 488 // XXX if no model fits are saved, write out modelEXT?489 if (source->modelFits == NULL) continue;490 491 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model)492 for (int j = 0; j < source->modelFits->n; j++) {493 494 // choose the convolved EXT model, if available, otherwise the simple one495 pmModel *model = source->modelFits->data[j];496 assert (model);497 498 PAR = model->params->data.F32;499 dPAR = model->dparams->data.F32;500 xPos = PAR[PM_PAR_XPOS];501 yPos = PAR[PM_PAR_YPOS];502 xErr = dPAR[PM_PAR_XPOS];503 yErr = dPAR[PM_PAR_YPOS];504 505 axes = pmPSF_ModelToAxes (PAR, 20.0);506 507 row = psMetadataAlloc ();508 509 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)510 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq);511 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos);512 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos);513 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr);514 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr);515 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag);516 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr);517 518 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n);519 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type));520 521 // XXX these should be major and minor, not 'x' and 'y'522 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major);523 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor);524 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta);525 526 // write out the other generic parameters527 for (int k = 0; k < nParamMax; k++) {528 if (k == PM_PAR_I0) continue;529 if (k == PM_PAR_SKY) continue;530 if (k == PM_PAR_XPOS) continue;531 if (k == PM_PAR_YPOS) continue;532 if (k == PM_PAR_SXX) continue;533 if (k == PM_PAR_SXY) continue;534 if (k == PM_PAR_SYY) continue;535 536 snprintf (name, 64, "EXT_PAR_%02d", k);537 538 if (k < model->params->n) {539 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]);540 } else {541 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN);542 }543 }544 545 // XXX other parameters which may be set.546 // XXX flag / value to define the model547 // XXX write out the model type, fit status flags548 549 psArrayAdd (table, 100, row);550 psFree (row);551 }486 pmSource *source = sources->data[i]; 487 488 // XXX if no model fits are saved, write out modelEXT? 489 if (source->modelFits == NULL) continue; 490 491 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model) 492 for (int j = 0; j < source->modelFits->n; j++) { 493 494 // choose the convolved EXT model, if available, otherwise the simple one 495 pmModel *model = source->modelFits->data[j]; 496 assert (model); 497 498 PAR = model->params->data.F32; 499 dPAR = model->dparams->data.F32; 500 xPos = PAR[PM_PAR_XPOS]; 501 yPos = PAR[PM_PAR_YPOS]; 502 xErr = dPAR[PM_PAR_XPOS]; 503 yErr = dPAR[PM_PAR_YPOS]; 504 505 axes = pmPSF_ModelToAxes (PAR, 20.0); 506 507 row = psMetadataAlloc (); 508 509 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc) 510 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 511 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos); 512 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos); 513 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr); 514 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr); 515 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag); 516 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr); 517 518 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n); 519 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type)); 520 521 // XXX these should be major and minor, not 'x' and 'y' 522 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major); 523 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor); 524 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta); 525 526 // write out the other generic parameters 527 for (int k = 0; k < nParamMax; k++) { 528 if (k == PM_PAR_I0) continue; 529 if (k == PM_PAR_SKY) continue; 530 if (k == PM_PAR_XPOS) continue; 531 if (k == PM_PAR_YPOS) continue; 532 if (k == PM_PAR_SXX) continue; 533 if (k == PM_PAR_SXY) continue; 534 if (k == PM_PAR_SYY) continue; 535 536 snprintf (name, 64, "EXT_PAR_%02d", k); 537 538 if (k < model->params->n) { 539 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]); 540 } else { 541 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN); 542 } 543 } 544 545 // XXX other parameters which may be set. 546 // XXX flag / value to define the model 547 // XXX write out the model type, fit status flags 548 549 psArrayAdd (table, 100, row); 550 psFree (row); 551 } 552 552 } 553 553 554 554 if (table->n == 0) { 555 psFitsWriteBlank (fits, outhead, extname);556 psFree (outhead);557 psFree (table);558 return true;555 psFitsWriteBlank (fits, outhead, extname); 556 psFree (outhead); 557 psFree (table); 558 return true; 559 559 } 560 560 561 561 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 562 562 if (!psFitsWriteTable (fits, outhead, table, extname)) { 563 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);564 psFree (outhead);565 psFree(table);566 return false;563 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 564 psFree (outhead); 565 psFree(table); 566 return false; 567 567 } 568 568 psFree (outhead); -
branches/cnb_branch_20090215/psModules/src/objects/pmSourcePhotometry.c
r21363 r21536 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $6 * @date $Date: 2009-02- 06 02:31:25$5 * @version $Revision: 1.49.4.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 145 145 // measure the contribution of included pixels 146 146 if (mode & PM_SOURCE_PHOT_WEIGHT) { 147 pmSourcePixelWeight (&source->pixWeight, model, source-> pixels, source->maskObj, maskVal);147 pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 148 148 } 149 149 … … 164 164 // XXX full model or just analytical? 165 165 // XXX use pmSourceAdd instead? 166 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) {166 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 167 167 pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 168 168 } … … 170 170 // if we are measuring aperture photometry and applying the growth correction, 171 171 // we need to shift the flux in the selected pixels (but not the mask) 172 // psImageShift ();173 172 psImage *flux = NULL, *mask = NULL; // Star flux and mask images, to photometer 174 173 if (mode & PM_SOURCE_PHOT_INTERP) { … … 186 185 } 187 186 188 // XXX this is test code to verify the shift is doing the right thing (seems to be)189 # if (0)190 // measure centroid of unshifted gaussian (should be 16.0,16.0)191 {192 psImage *image = source->pixels;193 float xo = 0.0;194 float yo = 0.0;195 float xo2 = 0.0;196 float yo2 = 0.0;197 float no = 0.0;198 for (int j = 0; j < image->numRows; j++)199 {200 for (int i = 0; i < image->numCols; i++) {201 xo += i*image->data.F32[j][i];202 yo += j*image->data.F32[j][i];203 xo2 += i*i*image->data.F32[j][i];204 yo2 += j*j*image->data.F32[j][i];205 no += image->data.F32[j][i];206 }207 }208 xo /= no;209 yo /= no;210 xo2 = sqrt (xo2/no - xo*xo);211 yo2 = sqrt (yo2/no - yo*yo);212 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no);213 }214 215 // measure centroid of unshifted gaussian (should be 16.0,16.0)216 {217 psImage *image = flux;218 float xo = 0.0;219 float yo = 0.0;220 float xo2 = 0.0;221 float yo2 = 0.0;222 float no = 0.0;223 for (int j = 0; j < image->numRows; j++)224 {225 for (int i = 0; i < image->numCols; i++) {226 xo += i*image->data.F32[j][i];227 yo += j*image->data.F32[j][i];228 xo2 += i*i*image->data.F32[j][i];229 yo2 += j*j*image->data.F32[j][i];230 no += image->data.F32[j][i];231 }232 }233 xo /= no;234 yo /= no;235 xo2 = sqrt (xo2/no - xo*xo);236 yo2 = sqrt (yo2/no - yo*yo);237 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no);238 }239 # endif240 241 187 } else { 242 188 flux = source->pixels; … … 269 215 // if source was originally subtracted, re-subtract object, leave local sky 270 216 // XXX replace with pmSourceSub... 271 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) {217 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 272 218 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 273 219 } … … 344 290 345 291 // return source aperture magnitude 346 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage * image, psImage *mask, psImageMaskType maskVal)292 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *mask, psImageMaskType maskVal) 347 293 { 348 294 PS_ASSERT_PTR_NON_NULL(pixWeight, false); 349 PS_ASSERT_PTR_NON_NULL(image, false);350 295 PS_ASSERT_PTR_NON_NULL(mask, false); 351 296 PS_ASSERT_PTR_NON_NULL(model, false); … … 377 322 Yo = params->data.F32[PM_PAR_YPOS]; 378 323 379 dX = Xo - image->col0;380 dP = image->numCols - dX;324 dX = Xo - mask->col0; 325 dP = mask->numCols - dX; 381 326 DX = PS_MAX(dX, dP); 382 NX = image->numCols;383 384 dY = Yo - image->row0;385 dP = image->numRows - dY;327 NX = mask->numCols; 328 329 dY = Yo - mask->row0; 330 dP = mask->numRows - dY; 386 331 DY = PS_MAX(dY, dP); 387 NY = image->numRows;332 NY = mask->numRows; 388 333 389 334 // measure modelSum and validSum. this function is applied to a sources' subimage. the … … 612 557 # endif 613 558 559 // determine chisq, etc for linear normalization-only fit 614 560 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *variance, 615 561 psImageMaskType maskVal) … … 632 578 } 633 579 } 580 model->nPix = Npix; 634 581 model->nDOF = Npix - 1; 635 582 model->chisq = dC; … … 817 764 } 818 765 766 // XXX this is test code to verify the shift is doing the right thing (seems to be) 767 # if (0) 768 // measure centroid of unshifted gaussian (should be 16.0,16.0) 769 { 770 psImage *image = source->pixels; 771 float xo = 0.0; 772 float yo = 0.0; 773 float xo2 = 0.0; 774 float yo2 = 0.0; 775 float no = 0.0; 776 for (int j = 0; j < image->numRows; j++) 777 { 778 for (int i = 0; i < image->numCols; i++) { 779 xo += i*image->data.F32[j][i]; 780 yo += j*image->data.F32[j][i]; 781 xo2 += i*i*image->data.F32[j][i]; 782 yo2 += j*j*image->data.F32[j][i]; 783 no += image->data.F32[j][i]; 784 } 785 } 786 xo /= no; 787 yo /= no; 788 xo2 = sqrt (xo2/no - xo*xo); 789 yo2 = sqrt (yo2/no - yo*yo); 790 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no); 791 } 792 793 // measure centroid of unshifted gaussian (should be 16.0,16.0) 794 { 795 psImage *image = flux; 796 float xo = 0.0; 797 float yo = 0.0; 798 float xo2 = 0.0; 799 float yo2 = 0.0; 800 float no = 0.0; 801 for (int j = 0; j < image->numRows; j++) 802 { 803 for (int i = 0; i < image->numCols; i++) { 804 xo += i*image->data.F32[j][i]; 805 yo += j*image->data.F32[j][i]; 806 xo2 += i*i*image->data.F32[j][i]; 807 yo2 += j*j*image->data.F32[j][i]; 808 no += image->data.F32[j][i]; 809 } 810 } 811 xo /= no; 812 yo /= no; 813 xo2 = sqrt (xo2/no - xo*xo); 814 yo2 = sqrt (yo2/no - yo*yo); 815 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no); 816 } 817 # endif -
branches/cnb_branch_20090215/psModules/src/objects/pmSourcePhotometry.h
r21183 r21536 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $7 * @date $Date: 2009-0 1-27 06:39:38$6 * @version $Revision: 1.12.8.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-19 17:59:50 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 46 46 psImage *image, ///< image pixels to be used 47 47 psImage *mask, ///< mask of pixels to ignore 48 psImageMaskType maskVal ///< Value to mask48 psImageMaskType maskVal ///< Value to mask 49 49 ); 50 50 51 51 bool pmSourceMagnitudesInit (psMetadata *config); 52 52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal); 53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage * image, psImage *mask, psImageMaskType maskVal);53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *mask, psImageMaskType maskVal); 54 54 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal); 55 55 -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceVisual.c
r21183 r21536 9 9 # if (HAVE_KAPA) 10 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 17 // static int kapa2 = -1; … … 20 20 bool pmSourcePlotPoints3D (int myKapa, Graphdata *graphdata, psVector *xn, psVector *yn, psVector *zn, float theta, float phi); 21 21 22 bool pmSourceSetVisual (bool mode) {23 24 isVisual = mode;25 return true;26 }27 22 28 23 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask) { 29 24 30 KapaSection section; // put the positive profile in one and the residuals in another? 25 KapaSection section; // put the positive profile in one and the residuals in another? 31 26 32 27 Graphdata graphdata; 33 28 34 if (! isVisual) return true;29 if (!pmVisualIsVisual()) return true; 35 30 36 31 if (kapa1 == -1) { 37 32 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 } 33 if (kapa1 == -1) { 34 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 35 pmVisualSetVisual(false); 36 return false; 37 } 38 } 44 39 45 40 KapaClearPlots (kapa1); … … 55 50 56 51 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]);52 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 53 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i]; 54 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 55 min = PS_MIN (min, resid->data.F32[i]); 56 max = PS_MAX (max, resid->data.F32[i]); 57 Min = PS_MIN (min, param->data.F32[i]); 58 Max = PS_MAX (max, param->data.F32[i]); 64 59 } 65 60 … … 70 65 psVector *Fn = psVectorAlloc (x->n, PS_TYPE_F32); 71 66 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);67 xn->data.F32[i] = x->data.F32[i] / 5000.0; 68 yn->data.F32[i] = y->data.F32[i] / 5000.0; 69 zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min); 70 Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min); 71 Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min); 77 72 } 78 73 … … 155 150 fprintf (stdout, "[c]ontinue? "); 156 151 if (!fgets(key, 8, stdin)) { 157 psWarning("Unable to read option");152 psWarning("Unable to read option"); 158 153 } 159 154 return true; … … 173 168 174 169 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]);170 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); 171 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); 172 zv->data.F32[2*i+0] = -yn->data.F32[i]*sin(phi) + zn->data.F32[i]*cos(phi); 173 xv->data.F32[2*i+1] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi); 174 yv->data.F32[2*i+1] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi); 175 zv->data.F32[2*i+1] = -yn->data.F32[i]*sin(phi); 176 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+0]); 177 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+0]); 178 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+0]); 179 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+0]); 180 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+1]); 181 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+1]); 182 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+1]); 183 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+1]); 189 184 } 190 185 xv->n = xn->n; -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceVisual.h
r20582 r21536 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 */ … … 15 15 /// @{ 16 16 17 bool pmSourceSetVisual (bool mode);18 17 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask); 19 18
Note:
See TracChangeset
for help on using the changeset viewer.
