IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 29, 2010, 2:35:46 PM (16 years ago)
Author:
eugene
Message:

attempting to get a better starting guess; attempting to downweight neighbor detections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.c

    r28676 r28781  
    966966    bool addNoise = mode & PM_MODEL_OP_NOISE;
    967967
    968     if (source->modelFlux) {
     968    // require the use of pmModelAddWithOffset if we are adding noise (because the model size and norm are rescaled)
     969    if (!addNoise && source->modelFlux) {
    969970        // add in the pixels from the modelFlux image
    970971        int dX = source->modelFlux->col0 - source->pixels->col0;
     
    987988
    988989        psF32 **target = source->pixels->data.F32;
    989         if (addNoise) {
    990             // when adding noise, we assume the shape and Io have been modified
    991             target = source->variance->data.F32;
    992         }
    993990
    994991        for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
     
    10051002            }
    10061003        }
    1007         if (!addNoise) {
    1008             if (add) {
    1009                 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1010             } else {
    1011                 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    1012             }
     1004        if (add) {
     1005            source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
     1006        } else {
     1007            source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    10131008        }
    10141009        return true;
     
    10291024        }
    10301025    }
     1026
     1027    return true;
     1028}
     1029
     1030// should we call pmSourceCacheModel if it does not exist?
     1031bool pmSourceNoiseOp (pmSource *source, pmModelOpMode mode, float FACTOR, float SIZE, bool add, psImageMaskType maskVal, int dx, int dy)
     1032{
     1033    assert (mode & PM_MODEL_OP_NOISE);
     1034    PS_ASSERT_PTR_NON_NULL(source, false);
     1035    PS_ASSERT_PTR_NON_NULL(source->peak, false);
     1036
     1037    if (add) {
     1038        psTrace ("psphot", 3, "adding noise to object at %f,%f\n", source->peak->xf, source->peak->yf);
     1039    } else {
     1040        psTrace ("psphot", 3, "removing noise from object at %f,%f\n", source->peak->xf, source->peak->yf);
     1041    }
     1042
     1043    pmSourceNoiseOpModel (source->modelPSF, source, mode, FACTOR, SIZE, add, maskVal, dx, dy);
     1044
     1045    if (source->modelEXT) {
     1046        pmSourceNoiseOpModel (source->modelEXT, source, mode, FACTOR, SIZE, add, maskVal, dx, dy);
     1047    }
     1048
     1049    return true;
     1050}
     1051
     1052bool pmSourceNoiseOpModel (pmModel *model, pmSource *source, pmModelOpMode mode, float FACTOR, float SIZE, bool add, psImageMaskType maskVal, int dx, int dy)
     1053{
     1054    bool status;
     1055    psEllipseShape oldshape;
     1056    psEllipseShape newshape;
     1057    psEllipseAxes axes;
     1058
     1059    if (add) {
     1060        psTrace ("psphot", 4, "adding noise for object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
     1061    } else {
     1062        psTrace ("psphot", 4, "remove noise for object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
     1063    }
     1064
     1065    psF32 *PAR = model->params->data.F32;
     1066
     1067    // save original values
     1068    float oldI0  = PAR[PM_PAR_I0];
     1069    oldshape.sx  = PAR[PM_PAR_SXX];
     1070    oldshape.sy  = PAR[PM_PAR_SYY];
     1071    oldshape.sxy = PAR[PM_PAR_SXY];
     1072
     1073    // XXX can this be done more intelligently?
     1074    if (oldI0 == 0.0) return false;
     1075    if (!isfinite(oldI0)) return false;
     1076
     1077    // increase size and height of source
     1078    axes = psEllipseShapeToAxes (oldshape, 20.0);
     1079    axes.major *= SIZE;
     1080    axes.minor *= SIZE;
     1081    newshape = psEllipseAxesToShape (axes);
     1082    PAR[PM_PAR_I0]  = FACTOR*oldI0;
     1083    PAR[PM_PAR_SXX] = newshape.sx;
     1084    PAR[PM_PAR_SYY] = newshape.sy;
     1085    PAR[PM_PAR_SXY] = newshape.sxy;
     1086
     1087    psImage *target = source->variance;
     1088
     1089    if (add) {
     1090        status = pmModelAddWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
     1091    } else {
     1092        status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
     1093    }
     1094
     1095    // restore original values
     1096    PAR[PM_PAR_I0]  = oldI0;
     1097    PAR[PM_PAR_SXX] = oldshape.sx;
     1098    PAR[PM_PAR_SYY] = oldshape.sy;
     1099    PAR[PM_PAR_SXY] = oldshape.sxy;
    10311100
    10321101    return true;
Note: See TracChangeset for help on using the changeset viewer.