IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:40:44 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested with psModules (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels. For
this reason, I have left the "gutter" pixels (cell gaps) set to 0
instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotAddNoise.c

    r13330 r13900  
    11# include "psphotInternal.h"
    22
    3 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add) {
     3bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add, psMaskType maskVal) {
    44
    55    bool status = false;
     
    3434    // loop over all source
    3535    for (int i = 0; i < sources->n; i++) {
    36         pmSource *source = sources->data[i];
     36        pmSource *source = sources->data[i];
    3737
    38         // skip sources which were not subtracted
    39         if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue;
     38        // skip sources which were not subtracted
     39        if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue;
    4040
    41         // select appropriate model
    42         pmModel *model = pmSourceGetModel (NULL, source);
    43         if (model == NULL) continue;  // model must be defined
    44        
    45         if (add) {
    46             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]);
    47         } else {
    48             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]);
    49         }
     41        // select appropriate model
     42        pmModel *model = pmSourceGetModel (NULL, source);
     43        if (model == NULL) continue;  // model must be defined
    5044
    51         psF32 *PAR = model->params->data.F32;
     45        if (add) {
     46            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]);
     47        } else {
     48            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]);
     49        }
    5250
    53         // save original values
    54         float oldI0  = PAR[PM_PAR_I0];
    55         oldshape.sx  = PAR[PM_PAR_SXX];
    56         oldshape.sy  = PAR[PM_PAR_SYY];
    57         oldshape.sxy = PAR[PM_PAR_SXY];
     51        psF32 *PAR = model->params->data.F32;
    5852
    59         // increase size and height of source
    60         axes = psEllipseShapeToAxes (oldshape, 20.0);
    61         axes.major *= SIZE;
    62         axes.minor *= SIZE;
    63         newshape = psEllipseAxesToShape (axes);
    64         PAR[PM_PAR_I0]  = FACTOR*PS_SQR(oldI0);
    65         PAR[PM_PAR_SXX] = newshape.sx;
    66         PAR[PM_PAR_SYY] = newshape.sy;
    67         PAR[PM_PAR_SXY] = newshape.sxy;
     53        // save original values
     54        float oldI0  = PAR[PM_PAR_I0];
     55        oldshape.sx  = PAR[PM_PAR_SXX];
     56        oldshape.sy  = PAR[PM_PAR_SYY];
     57        oldshape.sxy = PAR[PM_PAR_SXY];
    6858
    69         // XXX if we use pmSourceOp, the size (and possibly Io) will not be respected
    70         pmSourceOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, add);
    71        
    72         // restore original values
    73         PAR[PM_PAR_I0]  = oldI0;       
    74         PAR[PM_PAR_SXX] = oldshape.sx;
    75         PAR[PM_PAR_SYY] = oldshape.sy;
    76         PAR[PM_PAR_SXY] = oldshape.sxy;
     59        // increase size and height of source
     60        axes = psEllipseShapeToAxes (oldshape, 20.0);
     61        axes.major *= SIZE;
     62        axes.minor *= SIZE;
     63        newshape = psEllipseAxesToShape (axes);
     64        PAR[PM_PAR_I0]  = FACTOR*PS_SQR(oldI0);
     65        PAR[PM_PAR_SXX] = newshape.sx;
     66        PAR[PM_PAR_SYY] = newshape.sy;
     67        PAR[PM_PAR_SXY] = newshape.sxy;
     68
     69        // XXX if we use pmSourceOp, the size (and possibly Io) will not be respected
     70        pmSourceOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, add, maskVal);
     71
     72        // restore original values
     73        PAR[PM_PAR_I0]  = oldI0;
     74        PAR[PM_PAR_SXX] = oldshape.sx;
     75        PAR[PM_PAR_SYY] = oldshape.sy;
     76        PAR[PM_PAR_SXY] = oldshape.sxy;
    7777    }
    7878    if (add) {
    79         psLogMsg ("psphot.noise", PS_LOG_INFO, "add noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
     79        psLogMsg ("psphot.noise", PS_LOG_INFO, "add noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
    8080    } else {
    81         psLogMsg ("psphot.noise", PS_LOG_INFO, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
     81        psLogMsg ("psphot.noise", PS_LOG_INFO, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
    8282    }
    8383    return true;
Note: See TracChangeset for help on using the changeset viewer.