Changeset 36270 for branches/eam_branches/ipp-20130904/psModules
- Timestamp:
- Nov 8, 2013, 10:41:29 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psModules/src
- Files:
-
- 4 edited
-
camera/pmFPAfileIO.c (modified) (2 diffs)
-
objects/pmSourceIO.c (modified) (1 diff)
-
objects/pmSourceIO.h (modified) (1 diff)
-
objects/pmSourceIO_CFF.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psModules/src/camera/pmFPAfileIO.c
r36162 r36270 485 485 case PM_FPA_FILE_CMP: 486 486 case PM_FPA_FILE_CMF: 487 case PM_FPA_FILE_CFF: 487 488 status = pmFPAviewWriteObjects (view, file, config); 488 489 break; … … 515 516 case PM_FPA_FILE_WCS: 516 517 psError(PS_ERR_IO, true, "cannot write type WCS (%s)", file->name); 517 return false;518 519 case PM_FPA_FILE_CFF:520 psError(PS_ERR_IO, true, "cannot write type CFF (%s)", file->name);521 518 return false; 522 519 -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO.c
r36215 r36270 645 645 return false; 646 646 647 case PM_FPA_FILE_CFF: { 648 hdu = pmFPAviewThisHDU (view, fpa); 649 pmConfigConformHeader(hdu->header, file->format); 650 psFitsWriteBlank (file->fits, hdu->header, NULL); 651 file->header = hdu->header; 652 file->wrote_phu = true; 653 if (!pmSourcesWrite_CFF(file->fits, sources, hdu->header, recipe)) { 654 psError(PS_ERR_UNKNOWN, false, "failed to write CFF"); 655 return false; 656 } 657 break; 658 } 659 647 660 default: 648 661 fprintf (stderr, "warning: type mismatch\n"); -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO.h
r36162 r36270 54 54 psArray *pmSourcesReadCMP (char *filename, psMetadata *header); 55 55 psArray *pmSourcesRead_CFF (psFits *fits, psMetadata *header); 56 bool pmSourcesWrite_CFF (psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe); 56 57 57 58 bool pmSourcesWritePSFs (psArray *sources, char *filename); -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CFF.c
r36244 r36270 65 65 int modelType = pmModelClassGetType ("PS_MODEL_GAUSS"); 66 66 67 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSF _NAME");67 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSFMODEL"); 68 68 if (PSF_NAME != NULL) { 69 69 modelType = pmModelClassGetType (PSF_NAME); … … 107 107 // XXX: we need to put a lookup table in the cff header to define the correspondence of the 108 108 // model type values in the cff with our models. (We want to use an interger for efficiency 109 // but the values depend on the array in pmModelClass.c 109 // but the value for each model type is set on the organization of the the array in pmModelClass.c 110 // For now use the input values verbatim and trust the user that this is valid value 110 111 int galaxyModelType = psMetadataLookupS32(&status, row, "MODEL_TYPE"); 111 112 float Sindex = psMetadataLookupF32 (&status, row, "INDEX"); // Should this be PAR_07 not sersic index … … 173 174 } 174 175 175 if (fitGalaxy) { 176 // XXX: should use < 0 as invalid galaxyModelType 177 178 if (fitGalaxy && galaxyModelType > 0) { 176 179 source->modelFits = psArrayAllocEmpty (1); 177 180 pmModel *model = pmModelAlloc(galaxyModelType); … … 192 195 xPAR[PM_PAR_7] = 0.5 / Sindex; 193 196 } 197 // XXX: set source->modelEXT to this model and flag as extended so that we have a better 198 // shot at subtracting extended sources? 194 199 195 200 psArrayAdd (source->modelFits, 1, model); … … 204 209 } 205 210 211 bool pmSourcesWrite_CFF(psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe) { 212 213 char *extname = "SkyChip.cff"; 214 215 psArray *table = psArrayAllocEmpty(sources->n); 216 217 pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSCIC"); 218 219 for (int i = 0; i < sources->n; i++) { 220 pmSource *thisSource = sources->data[i]; 221 pmSource *source = thisSource->parent ? thisSource->parent : thisSource; 222 223 psF32 xPos, yPos, flux, rMajor, rMinor, theta; 224 psS32 modelType = 0; 225 bool fitGalaxy = false; 226 bool psfStar = false; 227 psS32 sersicIndex = 0; 228 if (source->modelFits == NULL) { 229 pmModel *model = source->modelPSF; 230 if (model == NULL) continue; 231 psF32 *PAR = model->params->data.F32; 232 if (!isfinite(PAR[PM_PAR_SXX]) || !isfinite(PAR[PM_PAR_SYY]) || !isfinite(PAR[PM_PAR_SXY]) || 233 !isfinite(source->psfFlux)) { 234 continue; 235 } 236 237 xPos = model->params->data.F32[PM_PAR_XPOS]; 238 yPos = model->params->data.F32[PM_PAR_YPOS]; 239 flux = source->psfFlux; 240 psfStar = (source->mode & PM_SOURCE_MODE_PSFSTAR) ? true : false; 241 rMajor = 0; 242 rMinor = 0; 243 theta = 0; 244 } else { 245 // Choose the extended model to use for this source. 246 // For now we use the one set as the modelEXT for this source which had the best fit. 247 // XXX: make this controllable by recipe 248 // use best (as implemented here) 249 // choose specific type 250 int iModel = -1; 251 if (source->modelEXT) { 252 pmModelType ext_model_type = source->modelEXT->type; 253 for (int j=0; j<source->modelFits->n; j++) { 254 pmModel *aModel = source->modelFits->data[j]; 255 if (aModel->type == ext_model_type) { 256 iModel = j; 257 break; 258 } 259 } 260 } 261 if (iModel == -1) { 262 // Can this happen? perhaps if model type is qgauss (extended but below s/n for model fits? 263 // XXX: Should this be an assert? 264 continue; 265 } 266 pmModel *model = source->modelFits->data[iModel]; 267 psF32 *PAR = model->params->data.F32; 268 xPos = PAR[PM_PAR_XPOS]; 269 yPos = PAR[PM_PAR_YPOS]; 270 if (model->type == pmModelClassGetType("PS_MODEL_TRAIL")) { 271 // XXX: do we need to handle this type 272 continue; 273 } else { 274 if (!isfinite(PAR[PM_PAR_SXX]) || !isfinite(PAR[PM_PAR_SYY]) || !isfinite(PAR[PM_PAR_SXY]) || 275 !isfinite(model->mag)) { 276 // bad model 277 continue; 278 } 279 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->type); 280 rMajor = axes.major; 281 rMinor = axes.minor; 282 theta = axes.theta*PS_DEG_RAD; 283 flux = pow(10.0, -0.4*model->mag); 284 fitGalaxy = true; 285 } 286 modelType = model->type; 287 if (modelType == sersicModelType) { 288 sersicIndex = 0.5 / PAR[PM_PAR_7]; 289 } 290 } 291 psMetadata *row = psMetadataAlloc(); 292 psMetadataAddU32 (row, PS_LIST_TAIL, "ID", 0, "IPP detection identifier", source->seq); 293 psMetadataAddF32 (row, PS_LIST_TAIL, "X", 0, "x coordinate", xPos); 294 psMetadataAddF32 (row, PS_LIST_TAIL, "Y", 0, "y coordinate", yPos); 295 psMetadataAddF32 (row, PS_LIST_TAIL, "FLUX", 0, "flux", flux); 296 psMetadataAddF32 (row, PS_LIST_TAIL, "AP_RADIUS", 0, "aperture radius", source->apRadius); 297 psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_RADIUS", 0, "Kron radius", source->moments->Mrf * 2.5); 298 psMetadataAddF32 (row, PS_LIST_TAIL, "PETRO_RADIUS", 0, "Petrosian Radius", source->extpars ? source->extpars->petrosianRadius : NAN); 299 psMetadataAddBool (row, PS_LIST_TAIL, "FIT_GALAXY", 0, "source has xfit", fitGalaxy); 300 psMetadataAddBool (row, PS_LIST_TAIL, "PSF_STAR", 0, "source was psf star", psfStar); 301 psMetadataAddF32 (row, PS_LIST_TAIL, "R_MAJOR", 0, "radius of major axis", rMajor); 302 psMetadataAddF32 (row, PS_LIST_TAIL, "R_MINOR", 0, "radius of minor axis", rMinor); 303 psMetadataAddF32 (row, PS_LIST_TAIL, "THETA", 0, "theta", theta); 304 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "model type", modelType); 305 psMetadataAddS32 (row, PS_LIST_TAIL, "INDEX", 0, "sersic index", sersicIndex); 306 307 psArrayAdd(table, 100, row); 308 } 309 310 if (!psFitsWriteTable(fits, NULL, table, extname)) { 311 psError(psErrorCodeLast(), false, "writing ext data %s\n", extname); 312 psFree(table); 313 psFree(header); 314 return false; 315 } 316 psFree(table); 317 // psFree(header); 318 319 return true; 320 }
Note:
See TracChangeset
for help on using the changeset viewer.
