Changeset 36718 for trunk/psModules
- Timestamp:
- May 1, 2014, 4:36:26 PM (12 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 3 edited
-
pmSource.h (modified) (1 diff)
-
pmSourceExtendedPars.h (modified) (1 diff)
-
pmSourceIO_CMF.c.in (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSource.h
r36623 r36718 119 119 pmSourceExtendedPars *extpars; ///< extended source parameters 120 120 pmSourceDiffStats *diffStats; ///< extra parameters for difference detections 121 p mSourceGalaxyFits *galaxyFits;///< fits to galaxy models (psphotFullForce only)121 psArray *galaxyFits; ///< fits to galaxy models (psphotFullForce only) 122 122 pmSourceLensing *lensingOBJ; ///< lensing moments parameters (per object) 123 123 pmSourceLensing *lensingPSF; ///< lensing moments parameters (psf, interpolated) -
trunk/psModules/src/objects/pmSourceExtendedPars.h
r36623 r36718 83 83 84 84 typedef struct { 85 int modelType; 85 86 psVector *Flux; 86 87 psVector *dFlux; -
trunk/psModules/src/objects/pmSourceIO_CMF.c.in
r36623 r36718 482 482 } 483 483 484 #ifdef SORT_EXTENSIONS_BY_FLUX 484 485 // let's write these out in S/N order 485 486 sources = psArraySort (sources, pmSourceSortByFlux); 487 #endif 486 488 487 489 table = psArrayAllocEmpty (sources->n); … … 821 823 psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "xsrc table extension", extname); 822 824 825 #ifdef SORT_EXTENSIONS_BY_FLUX 823 826 // let's write these out in S/N order 824 827 sources = psArraySort (sources, pmSourceSortByFlux); 828 #endif 825 829 826 830 float magOffset; … … 1225 1229 psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES"); 1226 1230 1231 #ifdef SORT_EXTENSIONS_BY_FLUX 1227 1232 // let's write these out in S/N order 1228 1233 sources = psArraySort (sources, pmSourceSortByFlux); 1234 #endif 1229 1235 1230 1236 table = psArrayAllocEmpty (sources->n); … … 1441 1447 psMetadataAddStr (outhead, PS_LIST_TAIL, "HI", PS_META_REPLACE, "does this get through?", "THERE"); 1442 1448 1443 // let's write these out in S/N order1444 sources = psArraySort (sources, pmSourceSortBy Flux);1449 // They are probably already in this order but ... 1450 sources = psArraySort (sources, pmSourceSortBySeq); 1445 1451 1446 1452 psArray *table = psArrayAllocEmpty (sources->n); … … 1459 1465 if (source->galaxyFits == NULL) continue; 1460 1466 1461 pmModel *model = source->modelFits->data[0]; 1462 if (!model) return false; 1463 1464 // X,Y coordinates are stored with the model parameters 1465 psF32 *PAR = model->params->data.F32; 1466 1467 psMetadata *row = psMetadataAlloc (); 1468 1469 // we write out the x,y positions so people can link to the psf either way (position or ID) 1470 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 1471 psMetadataAddF32 (row, PS_LIST_TAIL, "X_FIT", 0, "model x coordinate", PAR[PM_PAR_XPOS]); 1472 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_FIT", 0, "model y coordinate", PAR[PM_PAR_YPOS]); 1473 psMetadataAddF32 (row, PS_LIST_TAIL, "NPIX", 0, "number of pixels for fits", source->galaxyFits->nPix); 1474 1475 psVector *Flux = source->galaxyFits->Flux; 1476 psVector *dFlux = source->galaxyFits->dFlux; 1477 psVector *chisq = source->galaxyFits->chisq; 1478 1479 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX", PS_META_REPLACE, "normalization for galaxy flux", Flux); 1480 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX_ERR", PS_META_REPLACE, "error on normalization", dFlux); 1481 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_CHISQ", PS_META_REPLACE, "galaxy fit chisq", chisq); 1482 1483 psArrayAdd (table, 100, row); 1484 psFree (row); 1467 for (int iModel = 0; iModel < source->modelFits->n; iModel++) { 1468 pmModel *model = source->modelFits->data[iModel]; 1469 pmSourceGalaxyFits *galaxyFits = source->galaxyFits->data[iModel]; 1470 1471 if (!model || !galaxyFits) return false; 1472 1473 // XXX: TODO: we should search for the model that has the same type as the fits 1474 psAssert(model->type == galaxyFits->modelType, "galaxyFits model type does not match model type"); 1475 1476 // X,Y coordinates are stored with the model parameters 1477 psF32 *PAR = model->params->data.F32; 1478 1479 psMetadata *row = psMetadataAlloc (); 1480 1481 // we write out the x,y positions so people can link to the psf either way (position or ID) 1482 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 1483 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "model type", galaxyFits->modelType); 1484 psMetadataAddF32 (row, PS_LIST_TAIL, "X_FIT", 0, "model x coordinate", PAR[PM_PAR_XPOS]); 1485 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_FIT", 0, "model y coordinate", PAR[PM_PAR_YPOS]); 1486 psMetadataAddF32 (row, PS_LIST_TAIL, "NPIX", 0, "number of pixels for fits", galaxyFits->nPix); 1487 1488 psVector *Flux = galaxyFits->Flux; 1489 psVector *dFlux = galaxyFits->dFlux; 1490 psVector *chisq = galaxyFits->chisq; 1491 1492 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX", PS_META_REPLACE, "normalization for galaxy flux", Flux); 1493 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX_ERR", PS_META_REPLACE, "error on normalization", dFlux); 1494 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_CHISQ", PS_META_REPLACE, "galaxy fit chisq", chisq); 1495 1496 psArrayAdd (table, 100, row); 1497 psFree (row); 1498 } 1485 1499 } 1486 1500 … … 1541 1555 } 1542 1556 1557 int modelType = psMetadataLookupS32 (&status, row, "MODEL_TYPE"); 1543 1558 psVector *Flux = psMetadataLookupVector(&status, row, "GAL_FLUX"); 1544 1559 psVector *dFlux = psMetadataLookupVector(&status, row, "GAL_FLUX_ERR"); … … 1546 1561 1547 1562 if (Flux && Flux->n > 0) { 1548 psFree(source->galaxyFits); 1549 source->galaxyFits = pmSourceGalaxyFitsAlloc(); 1550 source->galaxyFits->nPix = psMetadataLookupF32(&status, row, "NPIX"); 1551 1552 psFree(source->galaxyFits->Flux); 1553 source->galaxyFits->Flux = psMemIncrRefCounter(Flux); 1554 psFree(source->galaxyFits->dFlux); 1555 source->galaxyFits->dFlux = psMemIncrRefCounter(dFlux); 1556 psFree(source->galaxyFits->chisq); 1557 source->galaxyFits->chisq = psMemIncrRefCounter(chisq); 1563 if (!source->galaxyFits) { 1564 source->galaxyFits = psArrayAllocEmpty(1); 1565 } 1566 1567 pmSourceGalaxyFits *galaxyFits = pmSourceGalaxyFitsAlloc(); 1568 1569 psArrayAdd(source->galaxyFits, 1, galaxyFits); 1570 1571 psFree(galaxyFits); 1572 galaxyFits->modelType = modelType; 1573 galaxyFits->nPix = psMetadataLookupF32(&status, row, "NPIX"); 1574 1575 psFree(galaxyFits->Flux); 1576 galaxyFits->Flux = psMemIncrRefCounter(Flux); 1577 psFree(galaxyFits->dFlux); 1578 galaxyFits->dFlux = psMemIncrRefCounter(dFlux); 1579 psFree(galaxyFits->chisq); 1580 galaxyFits->chisq = psMemIncrRefCounter(chisq); 1558 1581 } 1559 1582
Note:
See TracChangeset
for help on using the changeset viewer.
