IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33963 for trunk/psModules


Ignore:
Timestamp:
May 30, 2012, 1:46:12 PM (14 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20120405

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules

  • trunk/psModules/src/objects/pmModelFuncs.h

    r29004 r33963  
    4646
    4747typedef enum {
    48     PM_MODEL_OP_NONE    = 0x00,
    49     PM_MODEL_OP_FUNC    = 0x01,
    50     PM_MODEL_OP_RES0    = 0x02,
    51     PM_MODEL_OP_RES1    = 0x04,
    52     PM_MODEL_OP_FULL    = 0x07,
    53     PM_MODEL_OP_SKY     = 0x08,
    54     PM_MODEL_OP_CENTER  = 0x10,
    55     PM_MODEL_OP_NORM    = 0x20,
    56     PM_MODEL_OP_NOISE   = 0x40,
     48    PM_MODEL_OP_NONE     = 0x00,
     49    PM_MODEL_OP_FUNC     = 0x01,
     50    PM_MODEL_OP_RES0     = 0x02,
     51    PM_MODEL_OP_RES1     = 0x04,
     52    PM_MODEL_OP_FULL     = 0x07,
     53    PM_MODEL_OP_SKY      = 0x08,
     54    PM_MODEL_OP_CENTER   = 0x10,
     55    PM_MODEL_OP_NORM     = 0x20,
     56    PM_MODEL_OP_NOISE    = 0x40,
     57    PM_MODEL_OP_MODELVAR = 0x80,
    5758} pmModelOpMode;
    5859
  • trunk/psModules/src/objects/pmSource.c

    r33879 r33963  
    5151    psFree(tmp->pixels);
    5252    psFree(tmp->variance);
     53    psFree(tmp->modelVar);
    5354    psFree(tmp->maskObj);
    5455    psFree(tmp->maskView);
     
    7778    psFree (source->pixels);
    7879    psFree (source->variance);
     80    psFree (source->modelVar);
    7981    psFree (source->maskObj);
    8082    psFree (source->maskView);
     
    8486    source->pixels = NULL;
    8587    source->variance = NULL;
     88    source->modelVar = NULL;
    8689    source->maskObj = NULL;
    8790    source->maskView = NULL;
     
    113116    source->pixels = NULL;
    114117    source->variance = NULL;
     118    source->modelVar = NULL;
    115119    source->maskObj = NULL;
    116120    source->maskView = NULL;
     
    200204    source->pixels   = in->pixels   ? psImageCopyView(NULL, in->pixels)   : NULL;
    201205    source->variance = in->variance ? psImageCopyView(NULL, in->variance) : NULL;
     206    source->modelVar = NULL;
    202207    source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
    203208
     
    10281033
    10291034    bool addNoise = mode & PM_MODEL_OP_NOISE;
     1035    bool addModelVar = mode & PM_MODEL_OP_MODELVAR;
     1036
     1037    if (addModelVar) psAssert (source->modelVar, "programming error");
    10301038
    10311039    // require the use of pmModelAddWithOffset if we are adding noise (because the model size and norm are rescaled)
     
    10501058        }
    10511059
    1052         psF32 **target = source->pixels->data.F32;
     1060        psF32 **target = addModelVar ? source->modelVar->data.F32 : source->pixels->data.F32;
    10531061
    10541062        for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
     
    10651073            }
    10661074        }
    1067         if (add) {
    1068             source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1069         } else {
    1070             source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
     1075        if (!addModelVar) {
     1076            if (add) {
     1077                source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
     1078            } else {
     1079                source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
     1080            }
    10711081        }
    10721082        return true;
     
    10771087        target = source->variance;
    10781088    }
     1089    if (addModelVar) {
     1090        target = source->modelVar;
     1091    }
    10791092
    10801093    if (add) {
    10811094        status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
    1082         source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
     1095        if (!addNoise && !addModelVar) source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    10831096    } else {
    10841097        status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
    1085         source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
     1098        if (!addNoise && !addModelVar) source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    10861099    }
    10871100
  • trunk/psModules/src/objects/pmSource.h

    r33879 r33963  
    7272    psImage *pixels;                    ///< Rectangular region including object pixels.
    7373    psImage *variance;                  ///< Image variance.
     74    psImage *modelVar;                  ///< variance based on current models
    7475    psImage *maskObj;                   ///< unique mask for this object which marks included pixels associated with objects.
    7576    psImage *maskView;                  ///< view into global image mask for this object region
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r32998 r33963  
    899899}
    900900
    901 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     901double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    902902{
    903903    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
    904     double flux = 0, wt = 0, factor = 0;
     904    double flux = 0, wt = 1.0, factor = 0;
    905905
    906906    const psImage *Pi = Mi->modelFlux;
    907907    assert (Pi != NULL);
    908     const psImage *Wi = Mi->variance;
    909     if (!unweighted_sum) {
    910         assert (Wi != NULL);
    911     }
     908
     909    const psImage *Wi = NULL;
     910    switch (fitVarMode) {
     911      case PM_SOURCE_PHOTFIT_CONST:
     912        break;
     913      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     914        Wi = Mi->variance;
     915        psAssert (Wi, "programming error");
     916        break;
     917      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     918        Wi = Mi->modelVar;
     919        psAssert (Wi, "programming error");
     920        break;
     921      case PM_SOURCE_PHOTFIT_NONE:
     922        psAbort("programming error");
     923    }   
     924
    912925    const psImage *Ti = Mi->maskObj;
    913926    assert (Ti != NULL);
     
    915928    for (int yi = 0; yi < Pi->numRows; yi++) {
    916929        for (int xi = 0; xi < Pi->numCols; xi++) {
    917             if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
    918                 continue;
    919             if (!unweighted_sum) {
     930            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal) continue;
     931            if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
    920932                wt = covarFactor * Wi->data.F32[yi][xi];
    921                 if (wt == 0)
    922                     continue;
     933                if (wt == 0) continue;
    923934            }
    924935
     
    937948            }
    938949
    939             if (unweighted_sum) {
    940                 flux += (factor * Pi->data.F32[yi][xi]);
    941             } else {
    942                 flux += (factor * Pi->data.F32[yi][xi]) / wt;
    943             }
     950            // wt is 1.0 for CONST
     951            flux += (factor * Pi->data.F32[yi][xi]) / wt;
    944952        }
    945953    }
     
    947955}
    948956
    949 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     957double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    950958{
    951959    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    955963    int xIs, xJs, yIs, yJs;
    956964    int xIe, yIe;
    957     double flux, wt;
     965    double flux;
     966    double wt = 1.0;
    958967
    959968    const psImage *Pi = Mi->modelFlux;
     
    962971    assert (Pj != NULL);
    963972
    964     const psImage *Wi = Mi->variance;
    965     if (!unweighted_sum) {
    966         assert (Wi != NULL);
    967     }
     973    const psImage *Wi = NULL;
     974    switch (fitVarMode) {
     975      case PM_SOURCE_PHOTFIT_CONST:
     976        break;
     977      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     978        Wi = Mi->variance;
     979        psAssert (Wi, "programming error");
     980        break;
     981      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     982        Wi = Mi->modelVar;
     983        psAssert (Wi, "programming error");
     984        break;
     985      case PM_SOURCE_PHOTFIT_NONE:
     986        psAbort("programming error");
     987    }   
    968988
    969989    const psImage *Ti = Mi->maskObj;
     
    9951015                continue;
    9961016
    997             // XXX skip the nonsense weight pixels?
    998             if (unweighted_sum) {
    999                 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1000             } else {
     1017            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1018            switch (fitVarMode) {
     1019              case PM_SOURCE_PHOTFIT_CONST:
     1020                wt = 1.0;
     1021                break;
     1022              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1023              case PM_SOURCE_PHOTFIT_MODEL_VAR:
    10011024                wt = covarFactor * Wi->data.F32[yi][xi];
    1002                 if (wt > 0) {
    1003                     flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
    1004                 }
    1005             }
     1025                break;
     1026              case PM_SOURCE_PHOTFIT_NONE:
     1027                psAbort("programming error");
     1028            }
     1029            // skip pixels with nonsense weight values
     1030            if (wt <= 0) continue;
     1031
     1032            flux += value / wt;
    10061033        }
    10071034    }
     
    10091036}
    10101037
    1011 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     1038double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    10121039{
    10131040    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    10171044    int xIs, xJs, yIs, yJs;
    10181045    int xIe, yIe;
    1019     double flux, wt;
     1046    double flux;
     1047    double wt = 1.0;
    10201048
    10211049    const psImage *Pi = Mi->pixels;
     
    10241052    assert (Pj != NULL);
    10251053
    1026     const psImage *Wi = Mi->variance;
    1027     if (!unweighted_sum) {
    1028         assert (Wi != NULL);
    1029     }
     1054    const psImage *Wi = NULL;
     1055    switch (fitVarMode) {
     1056      case PM_SOURCE_PHOTFIT_CONST:
     1057        break;
     1058      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1059        Wi = Mi->variance;
     1060        psAssert (Wi, "programming error");
     1061        break;
     1062      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1063        Wi = Mi->modelVar;
     1064        psAssert (Wi, "programming error");
     1065        break;
     1066      case PM_SOURCE_PHOTFIT_NONE:
     1067        psAbort("programming error");
     1068    }   
    10301069
    10311070    const psImage *Ti = Mi->maskObj;
     
    10571096                continue;
    10581097
    1059             // XXX skip the nonsense weight pixels?
    1060             if (unweighted_sum) {
    1061                 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1062             } else {
     1098            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1099            switch (fitVarMode) {
     1100              case PM_SOURCE_PHOTFIT_CONST:
     1101                wt = 1.0;
     1102                break;
     1103              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1104              case PM_SOURCE_PHOTFIT_MODEL_VAR:
    10631105                wt = covarFactor * Wi->data.F32[yi][xi];
    1064                 if (wt > 0) {
    1065                     flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
    1066                 }
    1067             }
     1106                break;
     1107              case PM_SOURCE_PHOTFIT_NONE:
     1108                psAbort("programming error");
     1109            }
     1110            // skip pixels with nonsense weight values
     1111            if (wt <= 0) continue;
     1112
     1113            flux += value / wt;
     1114
    10681115        }
    10691116    }
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r31670 r33963  
    3838} pmSourcePhotometryMode;
    3939
     40typedef enum {
     41    PM_SOURCE_PHOTFIT_NONE       = 0,
     42    PM_SOURCE_PHOTFIT_CONST      = 1,
     43    PM_SOURCE_PHOTFIT_IMAGE_VAR  = 2,
     44    PM_SOURCE_PHOTFIT_MODEL_VAR  = 3,
     45} pmSourceFitVarMode;
     46
    4047bool pmSourcePhotometryModel(
    4148    float *fitMag,                      ///< integrated fit magnitude
     
    7582bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal);
    7683
    77 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
    78 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
    79 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
     84double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
     85double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
     86double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
    8087
    8188bool pmSourceNeighborFlags (pmSource *source);
Note: See TracChangeset for help on using the changeset viewer.