IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2014, 4:36:26 PM (12 years ago)
Author:
bills
Message:

Modify psphotFullForce and psphotFullForceSummary to support forcing
multiple extended model fits per source.

Location:
trunk/psModules/src/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSource.h

    r36623 r36718  
    119119    pmSourceExtendedPars *extpars;      ///< extended source parameters
    120120    pmSourceDiffStats *diffStats;       ///< extra parameters for difference detections
    121     pmSourceGalaxyFits *galaxyFits;     ///< fits to galaxy models (psphotFullForce only)
     121    psArray *galaxyFits;                ///< fits to galaxy models (psphotFullForce only)
    122122    pmSourceLensing *lensingOBJ;        ///< lensing moments parameters (per object)
    123123    pmSourceLensing *lensingPSF;        ///< lensing moments parameters (psf, interpolated)
  • trunk/psModules/src/objects/pmSourceExtendedPars.h

    r36623 r36718  
    8383
    8484typedef struct {
     85  int       modelType;
    8586  psVector *Flux;
    8687  psVector *dFlux;
  • trunk/psModules/src/objects/pmSourceIO_CMF.c.in

    r36623 r36718  
    482482    }
    483483
     484#ifdef SORT_EXTENSIONS_BY_FLUX
    484485    // let's write these out in S/N order
    485486    sources = psArraySort (sources, pmSourceSortByFlux);
     487#endif
    486488
    487489    table = psArrayAllocEmpty (sources->n);
     
    821823    psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "xsrc table extension", extname);
    822824
     825#ifdef SORT_EXTENSIONS_BY_FLUX
    823826    // let's write these out in S/N order
    824827    sources = psArraySort (sources, pmSourceSortByFlux);
     828#endif
    825829
    826830    float magOffset;
     
    12251229    psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES");
    12261230
     1231#ifdef SORT_EXTENSIONS_BY_FLUX
    12271232    // let's write these out in S/N order
    12281233    sources = psArraySort (sources, pmSourceSortByFlux);
     1234#endif
    12291235
    12301236    table = psArrayAllocEmpty (sources->n);
     
    14411447    psMetadataAddStr (outhead, PS_LIST_TAIL, "HI", PS_META_REPLACE, "does this get through?", "THERE");
    14421448
    1443     // let's write these out in S/N order
    1444     sources = psArraySort (sources, pmSourceSortByFlux);
     1449    // They are probably already in this order but ...
     1450    sources = psArraySort (sources, pmSourceSortBySeq);
    14451451
    14461452    psArray *table = psArrayAllocEmpty (sources->n);
     
    14591465        if (source->galaxyFits == NULL) continue;
    14601466
    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        }
    14851499    }
    14861500
     
    15411555        }
    15421556
     1557        int modelType = psMetadataLookupS32 (&status,    row, "MODEL_TYPE");
    15431558        psVector *Flux  = psMetadataLookupVector(&status, row, "GAL_FLUX");
    15441559        psVector *dFlux = psMetadataLookupVector(&status, row, "GAL_FLUX_ERR");
     
    15461561
    15471562        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);
    15581581        }
    15591582
Note: See TracChangeset for help on using the changeset viewer.