Changeset 28970
- Timestamp:
- Aug 19, 2010, 4:08:32 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourceIO_CMF_PS1_SV1.c (modified) (9 diffs)
-
pmSourceIO_CMF_PS1_V3.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceIO_CMF_PS1_SV1.c
r28909 r28970 71 71 psF32 errMag, chisq, apRadius; 72 72 psS32 nPix, nDOF; 73 char keyword1[80], keyword2[80]; 73 74 74 75 pmChip *chip = readout->parent->parent; … … 104 105 // we use this just to define the output vectors (which must be present for all objects) 105 106 bool status = false; 107 psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER"); 106 108 psVector *radMax = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER"); 107 109 psAssert (radMax, "this must have been defined and tested earlier!"); 108 110 psAssert (radMax->n, "this must have been defined and tested earlier!"); 111 psAssert (radMin->n == radMax->n, "inconsistent annular bins"); 112 113 // write the radial profile apertures to header 114 for (int i = 0; i < radMax->n; i++) { 115 sprintf (keyword1, "RMIN_%02d", i); 116 sprintf (keyword2, "RMAX_%02d", i); 117 psMetadataAddF32 (imageHeader, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]); 118 psMetadataAddF32 (imageHeader, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]); 119 } 120 109 121 110 122 // we write out PSF-fits for all sources, regardless of quality. the source flags tell us the state … … 202 214 psMetadataAdd (row, PS_LIST_TAIL, "PSF_MINOR", PS_DATA_F32, "PSF width (minor axis)", axes.minor); 203 215 psMetadataAdd (row, PS_LIST_TAIL, "PSF_THETA", PS_DATA_F32, "PSF orientation angle", axes.theta); 204 psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF", PS_DATA_F32, "PSF coverage/quality factor", source->pixWeightNotBad); 216 psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF", PS_DATA_F32, "PSF coverage/quality factor (bad)", source->pixWeightNotBad); 217 psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT", PS_DATA_F32, "PSF coverage/quality factor (poor)", source->pixWeightNotPoor); 205 218 psMetadataAdd (row, PS_LIST_TAIL, "PSF_NDOF", PS_DATA_S32, "degrees of freedom", nDOF); 206 219 psMetadataAdd (row, PS_LIST_TAIL, "PSF_NPIX", PS_DATA_S32, "number of pixels in fit", nPix); 207 220 208 221 // distinguish moments measure from window vs S/N > XX ?? 209 float mxx = source->moments ? source->moments->Mxx : NAN; 210 float mxy = source->moments ? source->moments->Mxy : NAN; 211 float myy = source->moments ? source->moments->Myy : NAN; 212 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_XX", PS_DATA_F32, "second moments (X^2)", mxx); 213 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_XY", PS_DATA_F32, "second moments (X*Y)", mxy); 214 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_YY", PS_DATA_F32, "second moments (Y*Y)", myy); 215 216 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS", PS_DATA_U32, "psphot analysis flags", source->mode); 222 float Mxx = source->moments ? source->moments->Mxx : NAN; 223 float Mxy = source->moments ? source->moments->Mxy : NAN; 224 float Myy = source->moments ? source->moments->Myy : NAN; 225 226 float Mrf = source->moments ? source->moments->Mrf : NAN; 227 float Mrh = source->moments ? source->moments->Mrh : NAN; 228 float Krf = source->moments ? source->moments->KronFlux : NAN; 229 float dKrf = source->moments ? source->moments->KronFluxErr : NAN; 230 231 float Kinner = source->moments ? source->moments->KronFinner : NAN; 232 float Kouter = source->moments ? source->moments->KronFouter : NAN; 233 234 float M_c3 = source->moments ? 1.0*source->moments->Mxxx - 3.0*source->moments->Mxyy : NAN; 235 float M_s3 = source->moments ? 3.0*source->moments->Mxxy - 1.0*source->moments->Myyy : NAN; 236 float M_c4 = source->moments ? 1.0*source->moments->Mxxxx - 6.0*source->moments->Mxxyy + 1.0*source->moments->Myyyy : NAN; 237 float M_s4 = source->moments ? 4.0*source->moments->Mxxxy - 4.0*source->moments->Mxyyy : NAN; 238 239 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_XX", PS_DATA_F32, "second moments (X^2)", Mxx); 240 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_XY", PS_DATA_F32, "second moments (X*Y)", Mxy); 241 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_YY", PS_DATA_F32, "second moments (Y*Y)", Myy); 242 243 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M3C", PS_DATA_F32, "third momemt cos theta", M_c3); 244 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M3S", PS_DATA_F32, "third momemt sin theta", M_s3); 245 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M4C", PS_DATA_F32, "fourth momemt cos theta", M_c4); 246 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_M4S", PS_DATA_F32, "fourth momemt sin theta", M_s4); 247 248 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1", PS_DATA_F32, "first radial moment", Mrf); 249 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_RH", PS_DATA_F32, "half radial moment", Mrh); 250 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX", PS_DATA_F32, "Kron Flux (in 2.5 R1)", Krf); 251 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_ERR", PS_DATA_F32, "Kron Flux Error", dKrf); 252 253 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER", PS_DATA_F32, "Kron Flux (in 2.5 R1)", Kinner); 254 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER", PS_DATA_F32, "Kron Flux (in 2.5 R1)", Kouter); 255 256 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS", PS_DATA_U32, "psphot analysis flags", source->mode); 257 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2", PS_DATA_U32, "psphot analysis flags", source->mode2); 217 258 218 259 psVector *radFlux = psVectorAlloc(radMax->n, PS_TYPE_F32); … … 372 413 373 414 source->pixWeightNotBad = psMetadataLookupF32 (&status, row, "PSF_QF"); 415 source->pixWeightNotPoor = psMetadataLookupF32 (&status, row, "PSF_QF_PERFECT"); 374 416 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); 375 417 source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA"); … … 386 428 source->moments->Myy = psMetadataLookupF32 (&status, row, "MOMENTS_YY"); 387 429 430 source->moments->Mrf = psMetadataLookupF32 (&status, row, "MOMENTS_R1"); 431 source->moments->Mrh = psMetadataLookupF32 (&status, row, "MOMENTS_RH"); 432 source->moments->KronFlux = psMetadataLookupF32 (&status, row, "KRON_FLUX"); 433 source->moments->KronFluxErr = psMetadataLookupF32 (&status, row, "KRON_FLUX_ERR"); 434 435 source->moments->KronFinner = psMetadataLookupF32 (&status, row, "KRON_FLUX_INNER"); 436 source->moments->KronFouter = psMetadataLookupF32 (&status, row, "KRON_FLUX_OUTER"); 437 438 // XXX we do not save all of the 3rd and 4th moment parameters. when we load in data, 439 // we are storing enough information so the output will be consistent with the input 440 source->moments->Mxxx = +1.0 * psMetadataLookupF32 (&status, row, "MOMENTS_M3C"); 441 source->moments->Mxxy = 0.0; 442 source->moments->Mxyy = 0.0; 443 source->moments->Myyy = -1.0 * psMetadataLookupF32 (&status, row, "MOMENTS_M3S"); 444 445 source->moments->Mxxxx = +1.00 * psMetadataLookupF32 (&status, row, "MOMENTS_M4C"); 446 source->moments->Mxxxy = 0.0; 447 source->moments->Mxxyy = 0.0; 448 source->moments->Mxyyy = -0.25 * psMetadataLookupF32 (&status, row, "MOMENTS_M4S"); 449 source->moments->Myyyy = 0.0; 450 388 451 source->mode = psMetadataLookupU32 (&status, row, "FLAGS"); 452 source->mode2 = psMetadataLookupU32 (&status, row, "FLAGS2"); 389 453 assert (status); 390 454 … … 406 470 psF32 xErr, yErr; 407 471 int nRow = -1; 472 char keyword1[80], keyword2[80]; 408 473 409 474 // create a header to hold the output data … … 437 502 bool doAnnuli = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI"); 438 503 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN"); 439 // bool doIsophotal = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ISOPHOTAL");440 // bool doKron = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_KRON");441 504 442 505 psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER"); … … 444 507 psAssert (radMin->n == radMax->n, "inconsistent annular bins"); 445 508 446 // int nRadialBins = 0; 447 // if (doAnnuli) { 448 // // get the max count of radial bins 449 // for (int i = 0; i < sources->n; i++) { 450 // pmSource *source = sources->data[i]; 451 // if (!source->extpars) continue; 452 // if (!source->extpars->radProfile ) continue; 453 // if (!source->extpars->radProfile->binSB) continue; 454 // nRadialBins = PS_MAX(nRadialBins, source->extpars->radProfile->binSB->n); 455 // } 456 // } 509 // write the radial profile apertures to header 510 for (int i = 0; i < radMax->n; i++) { 511 sprintf (keyword1, "RMIN_%02d", i); 512 sprintf (keyword2, "RMAX_%02d", i); 513 psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]); 514 psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]); 515 } 457 516 458 517 // we write out all sources, regardless of quality. the source flags tell us the state 459 518 for (int i = 0; i < sources->n; i++) { 460 // skip source if it is not a ext sourc461 // XXX we have two places that extended source parameters are measured:462 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,463 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)464 // should we require both?465 466 519 pmSource *source = sources->data[i]; 467 520 … … 529 582 } 530 583 531 # if (0)532 // Kron measurements533 if (doKron) {534 pmSourceKronValues *kron = source->extpars->kron;535 if (kron) {536 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", kron->mag);537 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr);538 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad);539 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr);540 } else {541 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN);542 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN);543 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN);544 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN);545 }546 }547 548 // Isophot measurements549 // XXX insert header data: isophotal level550 if (doIsophotal) {551 pmSourceIsophotalValues *isophot = source->extpars->isophot;552 if (isophot) {553 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", isophot->mag);554 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr);555 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad);556 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr);557 } else {558 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN);559 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN);560 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN);561 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN);562 }563 }564 # endif565 566 584 // Flux Annuli (if we have extended source measurements, we have these. only optionally save them) 567 585 if (doAnnuli) { -
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceIO_CMF_PS1_V3.c
r28909 r28970 174 174 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 175 175 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", errMag); 176 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental magnitude",source->psfFlux);177 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude",source->psfFluxErr);176 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental flux (counts)", source->psfFlux); 177 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux", source->psfFluxErr); 178 178 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 179 179 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", apRadius); … … 233 233 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER", PS_DATA_F32, "Kron Flux (in 2.5 R1)", Kouter); 234 234 235 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS", PS_DATA_U32, "psphot analysis flags", source->mode); 235 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS", PS_DATA_U32, "psphot analysis flags", source->mode); 236 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2", PS_DATA_U32, "psphot analysis flags", source->mode2); 236 237 237 238 // XXX not sure how to get this : need to load Nimages with weight? … … 353 354 source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], peakFlux, PM_PEAK_LONE); 354 355 source->peak->flux = peakFlux; 356 source->peak->xf = PAR[PM_PAR_XPOS]; // more accurate position 357 source->peak->yf = PAR[PM_PAR_YPOS]; // more accurate position 355 358 source->peak->dx = dPAR[PM_PAR_XPOS]; 356 359 source->peak->dy = dPAR[PM_PAR_YPOS]; 357 source->peak->xf = PAR[PM_PAR_XPOS]; // more accurate position358 source->peak->yf = PAR[PM_PAR_YPOS]; // more accurate position359 360 if (isfinite (source->errMag) && (source->errMag > 0.0)) { 360 361 source->peak->SN = 1.0 / source->errMag; … … 401 402 402 403 source->mode = psMetadataLookupU32 (&status, row, "FLAGS"); 404 source->mode2 = psMetadataLookupU32 (&status, row, "FLAGS2"); 403 405 assert (status); 404 406 … … 412 414 bool pmSourcesWrite_CMF_PS1_V3_XSRC (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe) 413 415 { 414 415 416 bool status; 416 417 psArray *table; … … 420 421 psF32 xErr, yErr; 421 422 int nRow = -1; 423 char keyword1[80], keyword2[80]; 422 424 423 425 // create a header to hold the output data … … 451 453 bool doAnnuli = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI"); 452 454 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN"); 453 // bool doIsophotal = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ISOPHOTAL");454 // bool doKron = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_KRON");455 455 456 456 psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER"); … … 458 458 psAssert (radMin->n == radMax->n, "inconsistent annular bins"); 459 459 460 // int nRadialBins = 0; 461 // if (doAnnuli) { 462 // // get the max count of radial bins 463 // for (int i = 0; i < sources->n; i++) { 464 // pmSource *source = sources->data[i]; 465 // if (!source->extpars) continue; 466 // if (!source->extpars->radProfile ) continue; 467 // if (!source->extpars->radProfile->binSB) continue; 468 // nRadialBins = PS_MAX(nRadialBins, source->extpars->radProfile->binSB->n); 469 // } 470 // } 460 // write the radial profile apertures to header 461 for (int i = 0; i < radMax->n; i++) { 462 sprintf (keyword1, "RMIN_%02d", i); 463 sprintf (keyword2, "RMAX_%02d", i); 464 psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]); 465 psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]); 466 } 471 467 472 468 // we write out all sources, regardless of quality. the source flags tell us the state 473 469 for (int i = 0; i < sources->n; i++) { 474 // skip source if it is not a ext sourc475 // XXX we have two places that extended source parameters are measured:476 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,477 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)478 // should we require both?479 480 470 pmSource *source = sources->data[i]; 481 471 … … 543 533 } 544 534 545 # if (0)546 // Kron measurements547 if (doKron) {548 pmSourceKronValues *kron = source->extpars->kron;549 if (kron) {550 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", kron->mag);551 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr);552 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad);553 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr);554 } else {555 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN);556 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN);557 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN);558 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN);559 }560 }561 562 // Isophot measurements563 // XXX insert header data: isophotal level564 if (doIsophotal) {565 pmSourceIsophotalValues *isophot = source->extpars->isophot;566 if (isophot) {567 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", isophot->mag);568 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr);569 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad);570 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr);571 } else {572 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN);573 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN);574 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN);575 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN);576 }577 }578 # endif579 580 535 // Flux Annuli (if we have extended source measurements, we have these. only optionally save them) 581 536 if (doAnnuli) {
Note:
See TracChangeset
for help on using the changeset viewer.
