Changeset 36633 for trunk/psphot/src
- Timestamp:
- Apr 2, 2014, 10:50:14 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
. (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotFullForce.SourceStats.c (modified) (1 diff)
-
psphot/src/psphotFullForceReadout.c (modified) (2 diffs)
-
psphot/src/psphotFullForceSummary.c (modified) (2 diffs)
-
psphot/src/psphotFullForceSummaryReadout.c (modified) (3 diffs)
-
psphot/src/psphotGalaxyShape.c (modified) (3 diffs)
-
psphot/src/psphotStackImageLoop.c (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/tags/ipp-20140114 merged: 36557,36559-36560,36584-36588,36597-36602,36607-36609
- Property svn:mergeinfo changed
-
trunk/psphot/src
- Property svn:mergeinfo changed
/tags/ipp-20140114/psphot/src merged: 36588,36599,36607
- Property svn:mergeinfo changed
-
trunk/psphot/src/psphotFullForce.SourceStats.c
r36375 r36633 85 85 psAssert (markVal, "missing MARK.PSPHOT"); 86 86 87 psArray *sources = detections->allSources; 87 // psArray *sources = detections->allSources; 88 psArray *sources = detections->newSources ? detections->newSources : detections->allSources; 88 89 89 90 // generate the array of sources, define the associated pixel -
trunk/psphot/src/psphotFullForceReadout.c
r36630 r36633 52 52 psphotLoadExtSources (config, view, filerule); 53 53 54 #ifdef notmoved 55 // XXX: moved down below 54 56 // merge the newly selected sources into the existing list (detections->allSources) 55 57 // NOTE: merge OLD and NEW 56 58 psphotMergeSources (config, view, filerule); 59 #endif 57 60 58 61 // construct sources and measure moments and other basic stats (saved on detections->allSources) … … 63 66 return psphotReadoutCleanup (config, view, filerule); 64 67 } 68 69 // classify sources based on moments, brightness. if a PSF model has been loaded, the PSF 70 // clump defined for it is used not measured (detections->newSources) 71 if (!psphotRoughClass (config, view, filerule)) { // pass 1 72 psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications"); 73 return psphotReadoutCleanup (config, view, filerule); 74 } 75 76 // merge the newly selected sources into the existing list (detections->allSources) 77 // NOTE: merge OLD and NEW 78 psphotMergeSources (config, view, filerule); 79 65 80 66 81 // generate a psf model for any readouts which need one -
trunk/psphot/src/psphotFullForceSummary.c
r36441 r36633 78 78 usage(); 79 79 } 80 if ((N = psArgumentGet(argc, argv, "-cff"))) { 81 if (argc <= N+1) { 82 psErrorStackPrint(stderr, "Expected to see 1 more argument; saw %d", argc - 1); 83 usage(); 84 } 85 psArgumentRemove(N, &argc, argv); 86 87 // We read CFF file as table not as sources. All we want are the nominal parameters input to psphotFullForce 88 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "CFF_FILE", 0, "CFF file with nominal parameters", argv[N]); 89 psArgumentRemove(N, &argc, argv); 90 } else { 91 psErrorStackPrint(stderr, "-cff must be supplied."); 92 usage(); 93 } 80 94 81 95 if (argc < 2) { … … 148 162 } 149 163 output->save = true; 164 165 // We read cff file as a table not as sources 166 psString cffName = psMetadataLookupStr(NULL, config->arguments, "CFF_FILE"); 167 if (!cffName) { 168 psError(PSPHOT_ERR_CONFIG, true, "CFF_FILE is missing from arguments"); 169 return false; 170 } 171 psString resolvedName = pmConfigConvertFilename(cffName, config, false, false); 172 if (!resolvedName) { 173 psError(PSPHOT_ERR_CONFIG, false, "failed to resolve CFF_FILE %s", cffName); 174 return false; 175 } 176 psFits *fits = psFitsOpen(resolvedName, "r"); 177 if (!fits) { 178 psError(PSPHOT_ERR_CONFIG, false, "failed to open fits CFF_FILE %s", resolvedName); 179 return false; 180 } 181 psArray *inTable = psFitsReadTable(fits); 182 if (!inTable) { 183 psError(PSPHOT_ERR_CONFIG, false, "failed to read cff fits table from CFF_FILE %s", resolvedName); 184 return false; 185 } 186 psFitsClose(fits); 187 188 // Convert to an array indexed by ID 189 psArray *sortedTable = psArrayAlloc(4*inTable->n); 190 for (int i=0; i<inTable->n; i++) { 191 psMetadata *row = inTable->data[i]; 192 psS32 ID = psMetadataLookupS32(&status, row, "ID"); 193 if (ID >= sortedTable->n) { 194 sortedTable = psArrayRealloc(sortedTable, 2*ID); 195 } 196 if (sortedTable->data[ID]) { 197 psError(PSPHOT_ERR_CONFIG, true, "Duplicate row with ID %d", ID); 198 return false; 199 } 200 sortedTable->data[ID] = psMemIncrRefCounter(row); 201 } 202 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "CFF_TABLE", PS_META_REPLACE, "cff table", sortedTable); 203 psFree(inTable); 204 psFree(sortedTable); 150 205 151 206 return true; -
trunk/psphot/src/psphotFullForceSummaryReadout.c
r36441 r36633 14 14 psArray *zeroPt; 15 15 psArray *exptime; 16 psArray *cffTable; 16 17 } galaxyShapeOptions; 17 18 … … 69 70 if (!setOptions(&options, readout, recipe, true)) { 70 71 psError (PS_ERR_UNKNOWN, false, "problem determining galaxy shape options."); 72 return false; 73 } 74 options.cffTable = psMetadataLookupPtr(NULL, config->arguments, "CFF_TABLE"); 75 if (!options.cffTable) { 76 psError (PS_ERR_UNKNOWN, true, "Cannot find cff table in arguments."); 71 77 return false; 72 78 } … … 309 315 // copy the best fit params to the model 310 316 psEllipseAxes axes = pmPSF_ModelToAxes(outSrc->modelEXT->params->data.F32, outSrc->modelEXT->type); 311 axes.major *= options->rMajor->data.F32[min_j]; 312 axes.minor *= options->rMinor->data.F32[min_j]; 317 if (outSrc->seq >= options->cffTable->n) { 318 psError(PS_ERR_PROGRAMMING, true, "object sequence number %d is larger than cff table length %ld", 319 outSrc->seq, options->cffTable->n); 320 return NULL; 321 } 322 psMetadata *row = options->cffTable->data[outSrc->seq]; 323 if (!row) { 324 psError (PS_ERR_PROGRAMMING, true, "NO cff data for object %d", outSrc->seq); 325 psFree(outSrc); 326 return NULL; 327 } 328 bool mdok; 329 psF32 rMajor = psMetadataLookupF32(&mdok, row, "R_MAJOR"); 330 if (!mdok) { 331 psError (PS_ERR_PROGRAMMING, true, "can't find R_MAJOR for object %d", outSrc->seq); 332 psFree(outSrc); 333 return NULL; 334 } 335 psF32 rMinor = psMetadataLookupF32(&mdok, row, "R_MINOR"); 336 if (!mdok) { 337 psError (PS_ERR_PROGRAMMING, true, "can't find R_MINOR for object %d", outSrc->seq); 338 psFree(outSrc); 339 return NULL; 340 } 341 axes.major = rMajor * options->rMajor->data.F32[min_j]; 342 axes.minor = rMinor * options->rMinor->data.F32[min_j]; 313 343 pmPSF_AxesToModel (outSrc->modelEXT->params->data.F32, axes, outSrc->modelEXT->type); 314 344 outSrc->modelEXT->chisq = minChisq; -
trunk/psphot/src/psphotGalaxyShape.c
r36441 r36633 205 205 if (!(source->tmpFlags & PM_SOURCE_TMPF_MOMENTS_MEASURED)) continue; 206 206 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 207 if (!source->modelPSF) continue; 207 208 208 209 // psphotSetRadiusMomentsExact sets the radius based on Mrf … … 274 275 275 276 int i = source->galaxyFits->chisq->n - 1; 276 float thisChisq = source->galaxyFits->chisq->data.F32[i]; 277 if (isfinite(thisChisq) && (!isfinite(chisqBest) || thisChisq < chisqBest)) { 278 chisqBest = thisChisq; 279 fRmajorBest = fRmajor; 280 fRminorBest = fRminor; 277 float flux = source->galaxyFits->Flux->data.F32[i]; 278 if (isfinite(flux)) { 279 float thisChisq = source->galaxyFits->chisq->data.F32[i]; 280 if (isfinite(thisChisq) && isfinite(flux) && (!isfinite(chisqBest) || thisChisq < chisqBest)) { 281 chisqBest = thisChisq; 282 fRmajorBest = fRmajor; 283 fRminorBest = fRminor; 284 } 281 285 } 286 // reset I0 to avoid potential problems on the next iteration 287 PAR[PM_PAR_I0] = 1.0; 282 288 } 283 289 } 284 290 291 #define SAVE_BEST_MODEL 285 292 #ifdef SAVE_BEST_MODEL 286 293 // Save model with smallest chisq … … 301 308 psphotGalaxyShapeSource (pcm, source, maskVal, psfSize, false); 302 309 303 // Replace modelEXT with this model 304 // XXX: only do this if the model is good 305 psFree (source->modelEXT); 306 307 source->modelEXT = psMemIncrRefCounter (pcm->modelConv); 308 source->type = PM_SOURCE_TYPE_EXTENDED; 309 source->mode |= PM_SOURCE_MODE_EXTMODEL; 310 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 311 312 // cache the model flux 313 pmPCMCacheModel (source, maskVal, psfSize, fitOptions->nsigma); 310 // Replace modelEXT with this model, if the model is good 311 if (isfinite(PAR[PM_PAR_I0])) { 312 psFree (source->modelEXT); 313 314 source->modelEXT = psMemIncrRefCounter (pcm->modelConv); 315 source->type = PM_SOURCE_TYPE_EXTENDED; 316 source->mode |= PM_SOURCE_MODE_EXTMODEL; 317 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 318 319 // cache the model flux 320 pmPCMCacheModel (source, maskVal, psfSize, fitOptions->nsigma); 321 } 314 322 } 315 323 -
trunk/psphot/src/psphotStackImageLoop.c
- Property svn:mergeinfo changed (with no actual effect on merging)
Note:
See TracChangeset
for help on using the changeset viewer.
