Changeset 38057
- Timestamp:
- Mar 29, 2015, 5:55:41 AM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150112/psphot
- Files:
-
- 17 edited
- 2 copied
-
. (modified) (1 prop)
-
src (modified) (1 prop)
-
src/Makefile.am (modified) (2 diffs)
-
src/psphot.h (modified) (1 diff)
-
src/psphotCleanup.c (modified) (1 diff)
-
src/psphotExtendedSourceFits.c (modified) (1 diff)
-
src/psphotFitSourcesLinear.c (modified) (1 diff)
-
src/psphotFullForce.c (modified) (2 diffs)
-
src/psphotFullForceArguments.c (modified) (1 diff)
-
src/psphotGalaxyParams.c (modified) (4 diffs)
-
src/psphotInternal.h (modified) (1 diff)
-
src/psphotLensing.c (modified) (9 diffs)
-
src/psphotModelBackground.c (modified) (3 diffs)
-
src/psphotReadoutCleanup.c (modified) (2 diffs)
-
src/psphotReadoutMinimal.c (modified) (2 diffs)
-
src/psphotStandAlone.h (modified) (1 diff)
-
src/psphotStatsFile.c (copied) (copied from trunk/psphot/src/psphotStatsFile.c )
-
src/psphotStatsFile.h (copied) (copied from trunk/psphot/src/psphotStatsFile.h )
-
src/psphotSubtractBackground.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150112/psphot
- Property svn:mergeinfo set to
-
branches/eam_branches/ipp-20150112/psphot/src
- Property svn:ignore
-
old new 27 27 psmakecff 28 28 psphotFullForceSummary 29 psphotVersionDefinitions.h.tmp
-
- Property svn:ignore
-
branches/eam_branches/ipp-20150112/psphot/src/Makefile.am
r37466 r38057 1 1 lib_LTLIBRARIES = libpsphot.la 2 3 if HAVE_SVNVERSION4 PSPHOT_VERSION=`$(SVNVERSION) ..`5 else6 PSPHOT_VERSION="UNKNOWN"7 endif8 9 if HAVE_SVN10 PSPHOT_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`11 PSPHOT_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`12 else13 PSPHOT_BRANCH="UNKNOWN"14 PSPHOT_SOURCE="UNKNOWN"15 endif16 2 17 3 # Force recompilation of psphotVersion.c, since it gets the version information 18 4 psphotVersion.c: psphotVersionDefinitions.h 19 5 psphotVersionDefinitions.h: psphotVersionDefinitions.h.in FORCE 20 -$(RM) psphotVersionDefinitions.h 21 $(SED) -e "s|@PSPHOT_VERSION@|\"$(PSPHOT_VERSION)\"|" -e "s|@PSPHOT_BRANCH@|\"$(PSPHOT_BRANCH)\"|" -e "s|@PSPHOT_SOURCE@|\"$(PSPHOT_SOURCE)\"|" psphotVersionDefinitions.h.in > psphotVersionDefinitions.h 6 pslib-setsvnversion.pl PSPHOT psphotVersionDefinitions.h.in psphotVersionDefinitions.h 22 7 FORCE: ; 23 8 … … 230 215 psphotLoadSRCTEXT.c \ 231 216 psphotReadoutCleanup.c \ 217 psphotStatsFile.c \ 232 218 psphotSourcePlots.c \ 233 219 psphotRadialPlot.c \ -
branches/eam_branches/ipp-20150112/psphot/src/psphot.h
r37767 r38057 45 45 bool psphotReadoutCleanup (pmConfig *config, const pmFPAview *view, const char *filerule); 46 46 bool psphotReadoutCleanupReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe); 47 bool psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule); 48 bool psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe); 47 49 48 50 bool psphotDefineFiles (pmConfig *config, pmFPAfile *input); -
branches/eam_branches/ipp-20150112/psphot/src/psphotCleanup.c
r37609 r38057 10 10 (void)pmConfigRecipesCull(config,NULL); 11 11 pmConfigDump(config, dump_file); 12 } 13 14 // if the program has stats write it out 15 psphotStatsFile *statsFile = psphotStatsFileGet(); 16 if (statsFile) { 17 psphotStatsFileSave(config, statsFile); 12 18 } 13 19 -
branches/eam_branches/ipp-20150112/psphot/src/psphotExtendedSourceFits.c
r37624 r38057 534 534 Nconvolve ++; 535 535 if (!(modelFit->flags & badModel)) { 536 float *PAR = modelFit->params->data.F32; 537 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, modelFit->class->useReff); 538 if (axes.major >= 100) { 539 Nfail ++; 540 source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_FAIL; 541 psFree(modelFit); 542 continue; 543 } 536 544 NconvolvePass ++; 537 545 source->mode |= PM_SOURCE_MODE_EXTENDED_FIT; -
branches/eam_branches/ipp-20150112/psphot/src/psphotFitSourcesLinear.c
r37555 r38057 688 688 assert (modelVar); 689 689 690 psMetadataRemoveKey (readout->analysis, "PSPHOT.MODEL.VAR"); 690 if (modelVar) { 691 psMetadataRemoveKey (readout->analysis, "PSPHOT.MODEL.VAR"); 692 } 691 693 692 694 // clear modelVar pointers for all of the source models -
branches/eam_branches/ipp-20150112/psphot/src/psphotFullForce.c
r36375 r38057 10 10 pmConfig *config = psphotFullForceArguments (argc, argv); 11 11 assert(config); 12 13 if (!psphotStatsFileOpen(config)) { 14 psErrorStackPrint(stderr, "Error creating statsFile\n"); 15 exit (psphotGetExitStatus()); 16 } 12 17 13 18 psphotVersionPrint(); … … 25 30 } 26 31 27 psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));32 psLogMsg ("psphot", 3, "complete psphotFullForce run: %f sec\n", psTimerMark ("complete")); 28 33 29 34 psErrorCode exit_status = psphotGetExitStatus(); -
branches/eam_branches/ipp-20150112/psphot/src/psphotFullForceArguments.c
r36375 r38057 65 65 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]); 66 66 psArgumentRemove (N, &argc, argv); 67 } 68 69 if ((N = psArgumentGet(argc, argv, "-stats"))) { 70 psArgumentRemove(N, &argc, argv); 71 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "STATS", PS_DATA_STRING, 72 "Filename for statistics of output file", argv[N]); 73 psArgumentRemove(N, &argc, argv); 67 74 } 68 75 -
branches/eam_branches/ipp-20150112/psphot/src/psphotGalaxyParams.c
r37811 r38057 152 152 153 153 // set this to 0 to run without threading 154 # if ( 0)154 # if (1) 155 155 if (!psThreadJobAddPending(job)) { 156 156 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); … … 270 270 badModel |= PM_MODEL_PCM_FAIL_GUESS; 271 271 272 badModel |= PM_MODEL_STATUS_LIMITS; 273 272 274 pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSIC"); 273 275 … … 334 336 if (!sersicModel) SKIP (Nskip8); 335 337 if (sersicModel->flags & badModel) SKIP (Nskip8); 338 339 // check out the model params and skip those that are too large 340 psF32 *PAR = sersicModel->params->data.F32; 341 psF32 Xo = PAR[PM_PAR_XPOS]; 342 psF32 Yo = PAR[PM_PAR_YPOS]; 343 psF32 Io = PAR[PM_PAR_I0]; 344 // 345 // The half light radius to the major axis of the model 346 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, sersicModel->class->useReff); 347 if (axes.major >= 100) SKIP (Nskip8); 348 349 source->extpars->ghalfLightRadius = axes.major; 336 350 Next ++; 337 351 … … 353 367 // do we need this? 354 368 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 355 #ifdef notdef 356 #endif 357 } 358 359 360 psF32 *PAR = sersicModel->params->data.F32; 361 psF32 Xo = PAR[PM_PAR_XPOS]; 362 psF32 Yo = PAR[PM_PAR_YPOS]; 363 psF32 Io = PAR[PM_PAR_I0]; 364 // For now: set the half light radius to the major axis of the model 365 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, sersicModel->class->useReff); 366 source->extpars->ghalfLightRadius = axes.major; 369 } 370 371 367 372 // and we will integrate out to 2 * half light radius 368 373 psF32 R = 2 * axes.major; -
branches/eam_branches/ipp-20150112/psphot/src/psphotInternal.h
r12805 r38057 14 14 #include <psmodules.h> 15 15 #include "psphot.h" 16 #include "psphotStatsFile.h" 16 17 17 18 #endif -
branches/eam_branches/ipp-20150112/psphot/src/psphotLensing.c
r36865 r38057 138 138 psVector *psf_e1sh = psVectorAllocEmpty (300, PS_TYPE_F32); 139 139 psVector *psf_e2sh = psVectorAllocEmpty (300, PS_TYPE_F32); 140 psVector *psf_e1 = psVectorAllocEmpty (300, PS_TYPE_F32); 141 psVector *psf_e2 = psVectorAllocEmpty (300, PS_TYPE_F32); 140 142 psVector *xPos = psVectorAllocEmpty (300, PS_TYPE_F32); 141 143 psVector *yPos = psVectorAllocEmpty (300, PS_TYPE_F32); … … 178 180 179 181 pmModel *model = source->modelPSF; 182 183 float R = source->moments->Mxx + source->moments->Myy; 184 source->lensingOBJ->e1 = (source->moments->Mxx - source->moments->Myy) / R; 185 source->lensingOBJ->e2 = 2*source->moments->Mxy / R; 180 186 181 187 psVectorAppend (xPos, model->params->data.F32[PM_PAR_XPOS]); … … 191 197 psVectorAppend (psf_e1sh, source->lensingOBJ->shear->e1); 192 198 psVectorAppend (psf_e2sh, source->lensingOBJ->shear->e2); 199 psVectorAppend (psf_e1, source->lensingOBJ->e1); 200 psVectorAppend (psf_e2, source->lensingOBJ->e2); 193 201 Npsf ++; 194 202 } … … 247 255 pmTrend2D *trend_e2sh = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats); 248 256 257 pmTrend2D *trend_e1 = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats); 258 pmTrend2D *trend_e2 = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats); 259 249 260 bool goodFit = false; 250 261 if (!pmTrend2DFit (&goodFit, trendX11sm, NULL, 0xff, xPos, yPos, psfX11sm, NULL)) { psWarning ("failed to measure X11 smear trend"); } … … 259 270 if (!pmTrend2DFit (&goodFit, trend_e1sh, NULL, 0xff, xPos, yPos, psf_e1sh, NULL)) { psWarning ("failed to measure e1 shear trend"); } 260 271 if (!pmTrend2DFit (&goodFit, trend_e2sh, NULL, 0xff, xPos, yPos, psf_e2sh, NULL)) { psWarning ("failed to measure e2 shear trend"); } 272 273 if (!pmTrend2DFit (&goodFit, trend_e1, NULL, 0xff, xPos, yPos, psf_e1, NULL)) { psWarning ("failed to measure e1 trend"); } 274 if (!pmTrend2DFit (&goodFit, trend_e2, NULL, 0xff, xPos, yPos, psf_e2, NULL)) { psWarning ("failed to measure e2 trend"); } 261 275 262 276 // evaluate the PSF trend maps at the location of all sources … … 295 309 smear->e1 = pmTrend2DEval (trend_e1sm, xPos, yPos); 296 310 smear->e2 = pmTrend2DEval (trend_e2sm, xPos, yPos); 311 312 lensing->e1 = pmTrend2DEval (trend_e1, xPos, yPos); 313 lensing->e2 = pmTrend2DEval (trend_e2, xPos, yPos); 297 314 } 298 315 … … 309 326 psFree (trend_e2sh); 310 327 328 psFree (trend_e1); 329 psFree (trend_e2); 330 311 331 psFree (psfX11sm); 312 332 psFree (psfX12sm); … … 314 334 psFree (psf_e1sm); 315 335 psFree (psf_e2sm); 336 316 337 psFree (psfX11sh); 317 338 psFree (psfX12sh); … … 319 340 psFree (psf_e1sh); 320 341 psFree (psf_e2sh); 342 343 psFree (psf_e1); 344 psFree (psf_e2); 345 321 346 psFree (xPos ); 322 347 psFree (yPos ); -
branches/eam_branches/ipp-20150112/psphot/src/psphotModelBackground.c
r35769 r38057 277 277 psFree(binning); 278 278 psFree(rng); 279 psFree(dQ); 279 280 return false; 280 281 } … … 386 387 387 388 if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config, false)) { 388 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 389 int lastError = psErrorCodeLast(); 390 if (lastError == PSPHOT_ERR_DATA) { 391 // depending on context this value may or may not be used 392 psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "PSPHOT_QUALITY", PS_META_REPLACE, "quality error due to poor data", lastError); 393 } 394 psError(lastError, false, "Unable to generate background model"); 389 395 return false; 390 396 } … … 404 410 for (int i = 0; i < num; i++) { 405 411 if (!psphotModelBackgroundReadoutFileIndex(config, view, filerule, i)) { 406 psError (PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", filerule, i); 412 int lastError = psErrorCodeLast(); 413 psError (lastError ? lastError : PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", filerule, i); 407 414 return false; 408 415 } -
branches/eam_branches/ipp-20150112/psphot/src/psphotReadoutCleanup.c
r37767 r38057 54 54 psArray *sources = detections ? detections->allSources : NULL; 55 55 // XXX where do we free these, in here (psMetadataRemove?) 56 57 int quality = psMetadataLookupS32 (&status, readout->analysis, "PSPHOT_QUALITY"); 58 if (quality) { 59 // if there is no stats file this will be a no-op 60 psphotStatsFileSetQuality(quality); 61 } 56 62 57 63 // use the psf-model to measure FWHM stats … … 111 117 return true; 112 118 } 119 120 // for now, let's store the detections on the readout->analysis for each readout 121 bool psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule) 122 { 123 bool status = true; 124 125 // remove internal pmFPAfiles, if created 126 if (psErrorCodeLast() == (psErrorCode) PSPHOT_ERR_DATA) { 127 psErrorStackPrint(stderr, "Error in the psphot readout analysis"); 128 psErrorClear(); 129 } 130 if (psErrorCodeLast() != PS_ERR_NONE) { 131 return false; 132 } 133 134 // select the appropriate recipe information 135 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 136 psAssert (recipe, "missing recipe?"); 137 138 int num = psphotFileruleCount(config, filerule); 139 140 // loop over the available readouts 141 for (int i = 0; i < num; i++) { 142 if (!psphotReadoutCleanupReadoutMinimal (config, view, filerule, i, recipe)) { 143 psError (PSPHOT_ERR_CONFIG, false, "failed on psphotReadoutCleanupMinimal for %s entry %d", filerule, i); 144 return false; 145 } 146 } 147 148 // XXX move this to top of loop? 149 pmKapaClose (); 150 151 return true; 152 } 153 154 // psphotReadoutCleanupMinimal is called on exit from psphotReadoutMinimal. If the last raised error is 155 // not a DATA error, then there was a serious problem. Only in this case, or if the fail 156 // on the stats measurement, do we return false 157 bool psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe) { 158 159 bool status = true; 160 161 // find the currently selected readout 162 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest 163 psAssert (file, "missing file?"); 164 165 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 166 psAssert (readout, "missing readout?"); 167 168 // when psphotReadoutCleanupMinimal is called, these are not necessarily defined 169 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 170 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 171 psArray *sources = detections ? detections->allSources : NULL; 172 // XXX where do we free these, in here (psMetadataRemove?) 173 174 // create an output header with stats results currently saved on readout->analysis 175 psMetadata *header = psphotDefineHeader (readout->analysis); 176 177 // write NSTARS to the image header 178 psphotSetHeaderNstars (header, sources); 179 180 // save the results of the analysis 181 // this should happen way up stream (when needed?) 182 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER", PS_DATA_METADATA | PS_META_REPLACE, "header stats", header); 183 184 if (psf) { 185 // XXX this seems a little silly : we saved the psf on readout->analysis above, but now 186 // we are moving it to chip->analysis. 187 // save the psf for possible output. if there was already an entry, it was loaded from external sources 188 // the new one may have been updated or modified, so replace the existing entry. We 189 // are required to save it on the chip, but this will cause problems if we ever want to 190 // run psphot on an unmosaiced image 191 pmCell *cell = readout->parent; 192 pmChip *chip = cell->parent; 193 psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot psf", psf); 194 } 195 196 if (psErrorCodeLast() != PS_ERR_NONE) { 197 psErrorStackPrint(stderr, "unexpected remaining errors"); 198 abort(); 199 } 200 201 psFree (header); 202 return true; 203 } -
branches/eam_branches/ipp-20150112/psphot/src/psphotReadoutMinimal.c
r34317 r38057 90 90 psphotKronIterate(config, view, filerule, 1); 91 91 92 psphotChipParams (config, view, filerule); 93 92 94 // measure source size for the remaining sources 93 95 psphotSourceSize (config, view, filerule, false); … … 112 114 113 115 // create the exported-metadata and free local data 114 return psphotReadoutCleanup (config, view, filerule);116 return psphotReadoutCleanupMinimal (config, view, filerule); 115 117 } -
branches/eam_branches/ipp-20150112/psphot/src/psphotStandAlone.h
r31154 r38057 10 10 #include <psmodules.h> 11 11 #include "psphot.h" 12 #include "psphotStatsFile.h" 12 13 13 14 // Top level functions -
branches/eam_branches/ipp-20150112/psphot/src/psphotSubtractBackground.c
r34528 r38057 29 29 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 30 30 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 31 assert (maskVal);31 psAssert (maskVal, "MASK.PSPHOT missing from recipe"); 32 32 33 33 psImageBinning *binning = psMetadataLookupPtr(&status, model->analysis, "PSPHOT.BACKGROUND.BINNING");
Note:
See TracChangeset
for help on using the changeset viewer.
