Changeset 17314
- Timestamp:
- Apr 2, 2008, 8:04:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080324/psphot/src/psphotExtendedSourceFits.c
r17276 r17314 6 6 bool status; 7 7 int Next = 0; 8 int Nconvolve = 0; 9 int Nplain = 0; 8 10 9 11 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 46 48 psAbort ("Unknown model class for EXTENDED_SOURCE_MODEL entry %s: %s", item->name, modelType); 47 49 } 50 psMetadataAddS32 (model, PS_LIST_TAIL, "MODEL_TYPE", PS_META_REPLACE, "", modelType); 48 51 49 52 // check on the SNLIM, set a float value … … 72 75 float SN_LIM = psMetadataLookupF32 (&status, recipe, "EXTENDED_SOURCE_SN_LIM"); 73 76 77 // what fraction of the PSF is used? (radius in pixels : 2 -> 5x5 box) 78 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 79 if (!status) { 80 psfSize = 2; 81 } 82 74 83 // source analysis is done in S/N order (brightest first) 75 84 sources = psArraySort (sources, pmSourceSortBySN); … … 84 93 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 85 94 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 86 87 // limit selection to some SN limit88 // XXX move this inside model loop89 assert (source->peak); // how can a source not have a peak?90 if (source->peak->SN < SN_LIM) continue;91 95 92 96 // XXX this should use peak? … … 119 123 assert (status); 120 124 121 if (X < SNlim) {122 continue;123 }125 // limit selection to some SN limit 126 assert (source->peak); // how can a source not have a peak? 127 if (source->peak->SN < SNlim) continue; 124 128 125 129 // check on the model type 126 char *modelName = psMetadataLookupStr (&status, model, "MODEL");130 pmModelType modelType = psMetadataLookupS32 (&status, model, "MODEL_TYPE"); 127 131 assert (status); 128 132 … … 134 138 // XXX use the values above, rework this function 135 139 if (convolved) { 136 pmModel *EXT = psphotPSFConvModel (source, recipe, maskVal); 140 pmModel *EXT = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize); 141 Nconvolve ++; 137 142 } else { 138 pmModel *EXT = psphotFitExt (readout, source, maskVal); 143 pmModel *EXT = psphotFitExt (readout, source, modelType, maskVal); 144 Nplain ++; 139 145 } 140 146 if (!EXT) { … … 143 149 } 144 150 145 // XXX do something with the resulting fit 151 if (source->modelFits == NULL) { 152 source->modelFits = psArrayAllocEmpty (5); 153 } 146 154 147 148 155 // test for fit quality / result 156 psArrayAdd (source->modelFits, 5, EXT); 149 157 } 150 158 151 159 // evaluate the relative quality of the models, choose one 160 float minChisq = 0;0; 161 int minModel = -1; 162 for (int i = 0; i < source->modelFits->n; i++) { 163 pmModel *model = source->modelFits->data[i]; 164 165 if (!(model->flags & PM_MODEL_STATUS_FITTED)) continue; 166 167 if (model->flags & (PM_MODEL_STATUS_BADARGS)) continue; 168 if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue; 169 if (model->flags & (PM_MODEL_STATUS_OFFIMAGE)) continue; 170 171 if ((minModel < 0) || (model->chisq < minChisq)) { 172 minChisq = model->chisq; 173 minModel = i; 174 } 175 } 176 177 if (minModel == -1) { 178 psAbort ("failed to fit extended source model"); 179 } 180 181 // XXX probably need to free the current value 182 psFree (source->modelEXT); 183 source->modelEXT = source->modelFits->data[minModel]; 152 184 153 185 // cache only the chosen model 154 186 pmSourceCacheModel (source, maskVal); // XXX put this in the source model function? 155 187 psTrace ("psphot", 5, "psf-convolved model for source at %7.1f, %7.1f", source->moments->x, source->moments->y); 156 Nconvolve ++;157 188 158 189 // re-subtract the object, leave local sky … … 163 194 psLogMsg ("psphot", PS_LOG_INFO, "extended source analysis: %f sec for %d objects\n", psTimerMark ("psphot"), Next); 164 195 psLogMsg ("psphot", PS_LOG_INFO, " %d convolved models\n", Nconvolve); 165 psLogMsg ("psphot", PS_LOG_INFO, " %d petrosian\n", Npetro); 166 psLogMsg ("psphot", PS_LOG_INFO, " %d isophotal\n", Nisophot); 167 psLogMsg ("psphot", PS_LOG_INFO, " %d annuli\n", Nannuli); 168 psLogMsg ("psphot", PS_LOG_INFO, " %d kron\n", Nkron); 196 psLogMsg ("psphot", PS_LOG_INFO, " %d plain models\n", Nplain); 169 197 return true; 170 198 }
Note:
See TracChangeset
for help on using the changeset viewer.
