IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 29, 2012, 5:09:48 PM (14 years ago)
Author:
eugene
Message:

merging changes from trunk

Location:
branches/eam_branches/ipp-20120405/psModules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120405/psModules

  • branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.c

    r33947 r33951  
    3939#include "pmSourceExtendedPars.h"
    4040#include "pmSourceDiffStats.h"
     41#include "pmSourcePhotometry.h"
    4142#include "pmSource.h"
    4243
     
    163164    source->radialAper = NULL;
    164165    source->parent = NULL;
     166    source->tmpPtr = NULL;
    165167    source->imageID = -1;
    166168    source->nFrames = 0;
     
    11701172    PAR[PM_PAR_SYY] = oldshape.sy;
    11711173    PAR[PM_PAR_SXY] = oldshape.sxy;
     1174
     1175    return true;
     1176}
     1177
     1178bool pmSourceSmoothOp (pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy)
     1179{
     1180//    assert (mode & PM_MODEL_OP_NOISE);
     1181    PS_ASSERT_PTR_NON_NULL(source, false);
     1182    PS_ASSERT_PTR_NON_NULL(source->peak, false);
     1183    PS_ASSERT_PTR_NON_NULL(target, false);
     1184
     1185    if (add) {
     1186        psTrace ("psphot", 3, "adding smoothed object at %f,%f\n", source->peak->xf, source->peak->yf);
     1187    } else {
     1188        psTrace ("psphot", 3, "removing smooted object at %f,%f\n", source->peak->xf, source->peak->yf);
     1189    }
     1190
     1191    pmModel *model = pmSourceGetModel(NULL, source);
     1192    if (!model) {
     1193        return false;
     1194    }
     1195    pmSourceSmoothOpModel (model, source, mode, target, sigma, add, maskVal, dx, dy);
     1196
     1197    return true;
     1198}
     1199
     1200bool pmSourceSmoothOpModel (pmModel *model, pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy)
     1201{
     1202    bool status;
     1203    psEllipseShape oldshape;
     1204    psEllipseShape newshape;
     1205    psEllipseAxes axes;
     1206
     1207    if (add) {
     1208        psTrace ("psphot", 4, "adding smoothed object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
     1209    } else {
     1210        psTrace ("psphot", 4, "removing smoothed object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
     1211    }
     1212
     1213    psF32 *PAR = model->params->data.F32;
     1214
     1215    // Isn't this hanging around somewhere?
     1216    float oldFlux = NAN;
     1217    if (!pmSourcePhotometryModel (NULL, &oldFlux, model)) return false;
     1218
     1219    // save original values
     1220    float oldI0  = PAR[PM_PAR_I0];
     1221    float oldsxx = PAR[PM_PAR_SXX];
     1222    float oldsyy = PAR[PM_PAR_SYY];
     1223    float oldsxy = PAR[PM_PAR_SXY];
     1224
     1225    // Since we are going to scale the flux correctly we need to get our
     1226    // factors of sqrt(2) right
     1227    oldshape.sx  = oldsxx / M_SQRT2;
     1228    oldshape.sy  = oldsyy / M_SQRT2;
     1229    oldshape.sxy = oldsxy;
     1230
     1231    // XXX can this be done more intelligently?
     1232    if (oldI0 == 0.0) return false;
     1233    if (!isfinite(oldI0)) return false;
     1234
     1235    // increase size and height of source
     1236    axes = psEllipseShapeToAxes (oldshape, 20.0);
     1237    axes.major = sqrt(PS_SQR(axes.major) + PS_SQR(sigma));
     1238    axes.minor = sqrt(PS_SQR(axes.minor) + PS_SQR(sigma));
     1239    newshape = psEllipseAxesToShape (axes);
     1240    PAR[PM_PAR_SXX] = newshape.sx * M_SQRT2;
     1241    PAR[PM_PAR_SYY] = newshape.sy * M_SQRT2;
     1242    PAR[PM_PAR_SXY] = newshape.sxy;
     1243
     1244    PAR[PM_PAR_I0]  = 1.0;
     1245
     1246    float newFlux;
     1247    if (!pmSourcePhotometryModel (NULL, &newFlux, model)) return false;
     1248
     1249    PAR[PM_PAR_I0]  = oldFlux / newFlux;
     1250
     1251    if (add) {
     1252        status = pmModelAddWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
     1253    } else {
     1254        status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
     1255    }
     1256
     1257    // restore original values
     1258    PAR[PM_PAR_I0]  = oldI0;
     1259    PAR[PM_PAR_SXX] = oldsxx;
     1260    PAR[PM_PAR_SYY] = oldsyy;
     1261    PAR[PM_PAR_SXY] = oldsxy;
    11721262
    11731263    return true;
Note: See TracChangeset for help on using the changeset viewer.