- Timestamp:
- Nov 22, 2013, 2:38:49 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CFF.c
r36270 r36299 69 69 modelType = pmModelClassGetType (PSF_NAME); 70 70 } 71 assert (modelType > -1);71 PS_ASSERT_INT_NONNEGATIVE(modelType, NULL); 72 72 73 73 // We get the size of the table, and allocate the array of sources first because the table … … 90 90 unsigned int ID = psMetadataLookupU32 (&status, row, "ID"); 91 91 float X = psMetadataLookupF32 (&status, row, "X"); 92 assert(status); 92 assert(status); // poorly constructed cff 93 93 float Y = psMetadataLookupF32 (&status, row, "Y"); 94 assert(status); 94 assert(status); // poorly constructed cff 95 95 float flux = psMetadataLookupF32 (&status, row, "FLUX"); // guess at the instrumental flux 96 if (!isfinite(X) || !isfinite(Y) || !isfinite(flux)) { 97 psError(PS_ERR_IO, true, "source ID %d is invalid x: %f y: %f flux: %f", ID, X, Y, flux); 98 psFree(sources); 99 return NULL; 100 } 101 96 102 97 103 float apRadius = psMetadataLookupF32 (&status, row, "AP_RADIUS"); … … 155 161 pmPSF_AxesToModel (PAR, axes, modelType); 156 162 157 // peak->detValue, rawFlux, smoothFlux are all set to the flux argument 163 // peak->detValue, rawFlux, smoothFlux are all set to the flux argument which is counts per second 158 164 source->peak = pmPeakAlloc(X, Y, flux, PM_PEAK_LONE); 159 165 source->peak->xf = X; // pmPeakAlloc converts X,Y to int, so reset here … … 167 173 source->moments->Mrf = kronRadius * 0.4; // kronRadius is 2.5 * first radial moment 168 174 source->tmpFlags |= PM_SOURCE_TMPF_MOMENTS_MEASURED; 169 // XXX does the above cause a problem with pmSourceMoments (do we run it? )175 // XXX does the above cause a problem with pmSourceMoments (do we run it? yes we do) 170 176 171 177 if (isfinite(petRadius)) { … … 195 201 xPAR[PM_PAR_7] = 0.5 / Sindex; 196 202 } 203 204 psArrayAdd (source->modelFits, 1, model); 205 206 #ifdef notyet 197 207 // XXX: set source->modelEXT to this model and flag as extended so that we have a better 198 208 // shot at subtracting extended sources? 199 209 200 psArrayAdd (source->modelFits, 1, model); 210 // This doesn't work right. Need to do some more work to flesh out the model before it can be 211 // used in subtaction. Better idea might be to do 2 passes in psphotFullForceReadout to 212 // First find the best extended models and then do everything else. 213 source->modelEXT = psMemIncrRefCounter(model); 214 // is this safe? (no see above) 215 source->type = PM_SOURCE_TYPE_EXTENDED; 216 source->mode |= PM_SOURCE_MODE_EXTMODEL; 217 #endif 218 201 219 psFree (model); 202 220 } … … 209 227 } 210 228 211 bool pmSourcesWrite_CFF(p sFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe) {229 bool pmSourcesWrite_CFF(pmReadout *readout, psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe) { 212 230 213 231 char *extname = "SkyChip.cff"; 214 232 233 bool mdok; 234 psF32 exptime = psMetadataLookupF32(&mdok, readout->parent->concepts, "CELL.EXPOSURE"); 235 PS_ASSERT(mdok, false); 236 215 237 psArray *table = psArrayAllocEmpty(sources->n); 216 238 217 pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERS CIC");239 pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSIC"); 218 240 219 241 for (int i = 0; i < sources->n; i++) { … … 225 247 bool fitGalaxy = false; 226 248 bool psfStar = false; 227 ps S32 sersicIndex = 0;249 psF32 sersicIndex = 0; 228 250 if (source->modelFits == NULL) { 229 251 pmModel *model = source->modelPSF; … … 286 308 modelType = model->type; 287 309 if (modelType == sersicModelType) { 310 PS_ASSERT_FLOAT_LARGER_THAN(PAR[PM_PAR_7], 0.0, false); 288 311 sersicIndex = 0.5 / PAR[PM_PAR_7]; 289 312 } … … 293 316 psMetadataAddF32 (row, PS_LIST_TAIL, "X", 0, "x coordinate", xPos); 294 317 psMetadataAddF32 (row, PS_LIST_TAIL, "Y", 0, "y coordinate", yPos); 295 psMetadataAddF32 (row, PS_LIST_TAIL, "FLUX", 0, "flux ", flux);318 psMetadataAddF32 (row, PS_LIST_TAIL, "FLUX", 0, "flux per second", flux/exptime); 296 319 psMetadataAddF32 (row, PS_LIST_TAIL, "AP_RADIUS", 0, "aperture radius", source->apRadius); 297 320 psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_RADIUS", 0, "Kron radius", source->moments->Mrf * 2.5); … … 303 326 psMetadataAddF32 (row, PS_LIST_TAIL, "THETA", 0, "theta", theta); 304 327 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "model type", modelType); 305 psMetadataAdd S32 (row, PS_LIST_TAIL, "INDEX", 0, "sersic index", sersicIndex);328 psMetadataAddF32 (row, PS_LIST_TAIL, "INDEX", 0, "sersic index", sersicIndex); 306 329 307 330 psArrayAdd(table, 100, row);
Note:
See TracChangeset
for help on using the changeset viewer.
