Changeset 13900 for trunk/psphot/src/psphotAddNoise.c
- Timestamp:
- Jun 19, 2007, 4:40:44 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotAddNoise.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotAddNoise.c
r13330 r13900 1 1 # include "psphotInternal.h" 2 2 3 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add ) {3 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add, psMaskType maskVal) { 4 4 5 5 bool status = false; … … 34 34 // loop over all source 35 35 for (int i = 0; i < sources->n; i++) { 36 pmSource *source = sources->data[i];36 pmSource *source = sources->data[i]; 37 37 38 // skip sources which were not subtracted39 if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue;38 // skip sources which were not subtracted 39 if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue; 40 40 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 50 44 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 } 52 50 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; 58 52 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]; 68 58 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; 77 77 } 78 78 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")); 80 80 } 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")); 82 82 } 83 83 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
