IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36299


Ignore:
Timestamp:
Nov 22, 2013, 2:38:49 PM (13 years ago)
Author:
bills
Message:

when saving flux in cff file divide by the exposure time so that the value is counts per second.
psphotLoadExtSources multiples the flux value by CELL.EXPOSURE for cff sources
added some sanity checking to cff files

Location:
branches/eam_branches/ipp-20130904
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO.c

    r36281 r36299  
    658658        file->header = hdu->header;
    659659        file->wrote_phu = true;
    660         if (!pmSourcesWrite_CFF(file->fits, sources, hdu->header, recipe)) {
     660        if (!pmSourcesWrite_CFF(readout, file->fits, sources, hdu->header, recipe)) {
    661661            psError(PS_ERR_UNKNOWN, false, "failed to write CFF");
    662662            return false;
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO.h

    r36270 r36299  
    5454psArray *pmSourcesReadCMP (char *filename, psMetadata *header);
    5555psArray *pmSourcesRead_CFF (psFits *fits, psMetadata *header);
    56 bool pmSourcesWrite_CFF (psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe);
     56bool pmSourcesWrite_CFF (pmReadout *readout, psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe);
    5757
    5858bool pmSourcesWritePSFs (psArray *sources, char *filename);
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CFF.c

    r36270 r36299  
    6969        modelType = pmModelClassGetType (PSF_NAME);
    7070    }
    71     assert (modelType > -1);
     71    PS_ASSERT_INT_NONNEGATIVE(modelType, NULL);
    7272
    7373    // We get the size of the table, and allocate the array of sources first because the table
     
    9090        unsigned int ID  = psMetadataLookupU32 (&status, row, "ID");
    9191        float X          = psMetadataLookupF32 (&status, row, "X");
    92         assert(status);
     92        assert(status);  // poorly constructed cff
    9393        float Y          = psMetadataLookupF32 (&status, row, "Y");
    94         assert(status);
     94        assert(status);  // poorly constructed cff
    9595        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
    96102
    97103        float apRadius   = psMetadataLookupF32 (&status, row, "AP_RADIUS");
     
    155161        pmPSF_AxesToModel (PAR, axes, modelType);
    156162
    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
    158164        source->peak      = pmPeakAlloc(X, Y, flux, PM_PEAK_LONE);
    159165        source->peak->xf  = X; // pmPeakAlloc converts X,Y to int, so reset here
     
    167173        source->moments->Mrf = kronRadius * 0.4; // kronRadius is 2.5 * first radial moment
    168174        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)
    170176
    171177        if (isfinite(petRadius)) {
     
    195201                xPAR[PM_PAR_7] = 0.5 / Sindex;
    196202            }
     203
     204            psArrayAdd (source->modelFits, 1, model);
     205
     206#ifdef notyet
    197207            // XXX: set source->modelEXT to this model and flag as extended so that we have a better
    198208            // shot at subtracting extended sources?
    199209
    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
    201219            psFree (model);
    202220        }
     
    209227}
    210228
    211 bool pmSourcesWrite_CFF(psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe) {
     229bool pmSourcesWrite_CFF(pmReadout *readout, psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe) {
    212230   
    213231    char *extname = "SkyChip.cff";
    214232   
     233    bool mdok;
     234    psF32 exptime = psMetadataLookupF32(&mdok, readout->parent->concepts, "CELL.EXPOSURE");
     235    PS_ASSERT(mdok, false);
     236
    215237    psArray *table = psArrayAllocEmpty(sources->n);
    216238
    217     pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSCIC");
     239    pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSIC");
    218240
    219241    for (int i = 0; i < sources->n; i++) {
     
    225247        bool fitGalaxy = false;
    226248        bool psfStar = false;
    227         psS32 sersicIndex = 0;
     249        psF32 sersicIndex = 0;
    228250        if (source->modelFits == NULL) {
    229251            pmModel *model = source->modelPSF;
     
    286308            modelType = model->type;
    287309            if (modelType == sersicModelType) {
     310                PS_ASSERT_FLOAT_LARGER_THAN(PAR[PM_PAR_7], 0.0, false);
    288311                sersicIndex = 0.5 / PAR[PM_PAR_7];
    289312            }
     
    293316        psMetadataAddF32 (row, PS_LIST_TAIL, "X",                0, "x coordinate",          xPos);
    294317        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);
    296319        psMetadataAddF32 (row, PS_LIST_TAIL, "AP_RADIUS",        0, "aperture radius",       source->apRadius);
    297320        psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_RADIUS",      0, "Kron radius",           source->moments->Mrf * 2.5);
     
    303326        psMetadataAddF32 (row, PS_LIST_TAIL, "THETA",            0, "theta",                 theta);
    304327        psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE",       0, "model type",            modelType);
    305         psMetadataAddS32 (row, PS_LIST_TAIL, "INDEX",            0, "sersic index",          sersicIndex);
     328        psMetadataAddF32 (row, PS_LIST_TAIL, "INDEX",            0, "sersic index",          sersicIndex);
    306329
    307330        psArrayAdd(table, 100, row);
  • branches/eam_branches/ipp-20130904/psphot/src/psphotMergeSources.c

    r36213 r36299  
    129129        extCFF = psMetadataLookupPtr (NULL, readoutCFF->analysis, "PSPHOT.DETECTIONS");
    130130        if (extCFF) {
     131            psF32 exptime = psMetadataLookupF32(NULL, readout->parent->concepts, "CELL.EXPOSURE");
    131132            for (int i = 0; i < extCFF->allSources->n; i++) {
    132133                pmSource *source = extCFF->allSources->data[i];
     
    136137                source->mode |= PM_SOURCE_MODE_EXTERNAL;
    137138
    138                 // source->peak->detValue,rawFlux,smoothFlux all set to input flux value
     139                // source->peak->detValue,rawFlux,smoothFlux all set to input flux value which is scaled
     140                // to 1 second exposure time. Scale to this image's exposure.
     141                source->peak->rawFlux    *= exptime;
     142                source->peak->smoothFlux *= exptime;
     143                source->peak->detValue   *= exptime;
    139144                // source->peak->xf,yf, moments->Mx,My all set to input position
    140145
Note: See TracChangeset for help on using the changeset viewer.