IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 27, 2009, 11:36:17 AM (17 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/20090715/psModules/src/imcombine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/psModules/src/imcombine/pmPSFEnvelope.c

    r25496 r25626  
    3434
    3535// #define TESTING                         // Enable test output
     36// #define PEAK_NORM                       // Normalise peaks?
    3637#define PEAK_FLUX 1.0e4                 // Peak flux for each source
    3738#define SKY_VALUE 0.0e0                 // Sky value for fake image
     
    122123            continue;
    123124        }
     125
     126        if (psTraceGetLevel("psModules.imcombine") >= 1) {
     127            psString string = NULL;     // String with values
     128            psStringAppend(&string, "PSF %d: ", i);
     129            float x = numCols / 2.0, y = numRows / 2.0; // Coordinates of interest
     130            for (int j = 4; j < psf->params->n; j++) {
     131                pmTrend2D *trend = psf->params->data[j]; // Trend of interest
     132                double val = pmTrend2DEval(trend, x, y);
     133                double err;
     134                switch (trend->mode) {
     135                  case PM_TREND_POLY_ORD:
     136                  case PM_TREND_POLY_CHEB:
     137                    err = NAN;
     138                    break;
     139                  case PM_TREND_MAP:
     140                    err = psImageUnbinPixel(x, y, trend->map->error, trend->map->binning);
     141                    break;
     142                  default:
     143                    psAbort("Unsupported mode: %x", trend->mode);
     144                }
     145                psStringAppend(&string, "%lf %lf   ", val, err);
     146            }
     147            psTrace("psModules.imcombine", 1, "%s\n", string);
     148            psFree(string);
     149        }
     150
    124151        pmResiduals *resid = psf->residuals;// PSF residuals
    125152        psf->residuals = NULL;
     
    144171            float y = source->peak->yf + yOffset->data.S32[j]; // y coordinate of source
    145172
    146             double flux = fakeRO->image->data.F32[(int)y][(int)x];
     173#ifdef PEAK_NORM
     174            // Perhaps I'm being paranoid, but specify a range to check
     175            int uMax = PS_MIN(x + radius, numCols - 1), uMin = PS_MAX(x - radius, 0);
     176            int vMax = PS_MIN(y + radius, numRows - 1), vMin = PS_MAX(y - radius, 0);
     177
     178            double flux = -INFINITY;    // Peak flux
     179            for (int v = vMin; v <= vMax; v++) {
     180                for (int u = uMin; u <= uMax; u++) {
     181                    if (fakeRO->image->data.F32[v][u] > flux) {
     182                        flux = fakeRO->image->data.F32[v][u];
     183                    }
     184                }
     185            }
    147186            if (!isfinite(flux) || flux < 0) {
    148187                continue;
    149188            }
    150189            float norm = PEAK_FLUX / flux; // Normalisation for source
     190#endif
    151191            psRegion region = psRegionSet(x - radius, x + radius, y - radius, y + radius); // PSF region
    152192            psImage *subImage = psImageSubset(fakeRO->image, region); // Subimage of fake PSF
    153193            psImage *subEnv = psImageSubset(envelope, region); // Subimage of envelope
     194#ifdef PEAK_NORM
    154195            psBinaryOp(subImage, subImage, "*", psScalarAlloc(norm, PS_TYPE_F32));
     196#endif
    155197            psBinaryOp(subEnv, subEnv, "MAX", subImage);
    156198            psFree(subImage);
     
    345387    psFree(try);
    346388
     389    if (psTraceGetLevel("psModules.imcombine") >= 1) {
     390        psString string = NULL;     // String with values
     391        psStringAppend(&string, "Envelope PSF: ");
     392        float x = numCols / 2.0, y = numRows / 2.0; // Coordinates of interest
     393        for (int j = 4; j < psf->params->n; j++) {
     394            pmTrend2D *trend = psf->params->data[j]; // Trend of interest
     395            double val = pmTrend2DEval(trend, x, y);
     396            double err;
     397            switch (trend->mode) {
     398              case PM_TREND_POLY_ORD:
     399              case PM_TREND_POLY_CHEB:
     400                err = NAN;
     401                break;
     402              case PM_TREND_MAP:
     403                err = psImageUnbinPixel(x, y, trend->map->error, trend->map->binning);
     404                break;
     405              default:
     406                psAbort("Unsupported mode: %x", trend->mode);
     407            }
     408            psStringAppend(&string, "%lf %lf   ", val, err);
     409        }
     410        psTrace("psModules.imcombine", 1, "%s\n", string);
     411        psFree(string);
     412    }
     413
    347414#ifdef TESTING
    348415    {
     
    358425
    359426        pmReadout *generated = pmReadoutAlloc(NULL); // Generated image
    360         pmReadoutFakeFromSources(generated, numCols, numRows, fakes, NULL, NULL, psf, NAN, radius,
     427        pmReadoutFakeFromSources(generated, numCols, numRows, fakes, 0, NULL, NULL, psf, NAN, radius,
    361428                                 false, true);
    362429        {
  • branches/eam_branches/20090715/psModules/src/imcombine/pmStackReject.c

    r21351 r25626  
    4343    if (box > 0) {
    4444        // Convolve a subimage, then stick it in the target
    45         // XXX if (threaded) {
    46         // XXX     psMutexLock(source);
    47         // XXX }
    4845        psImage *mask = psImageSubset(source, psRegionSet(xMin - box, xMax + box,
    4946                                                          yMin - box, yMax + box)); // Mask to convolve
    50         // XXX if (threaded) {
    51         // XXX     psMutexUnlock(source);
    52         // XXX }
    5347        psImage *convolved = psImageConvolveMask(NULL, mask, PM_STACK_MASK_BAD, PM_STACK_MASK_CONVOLVE,
    5448                                                 -box, box, -box, box); // Convolved mask
    55         // XXX if (threaded) {
    56         // XXX     psMutexLock(source);
    57         // XXX }
    5849        psFree(mask);
    59         // XXX if (threaded) {
    60         // XXX     psMutexUnlock(source);
    61         // XXX }
    6250
    6351        int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy
     
    162150    pmReadout *inRO = pmReadoutAlloc(NULL); // Readout with input image
    163151    inRO->image = image;
    164     // XXX if (threaded) {
    165     // XXX     psMutexInit(image);
    166     // XXX }
    167152    for (int i = 0; i < numRegions; i++) {
    168153        psRegion *region = subRegions->data[i]; // Region of interest
    169154        pmSubtractionKernels *kernels = subKernels->data[i]; // Kernel of interest
    170         if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, stride, 0, 0, 1.0, 0.0,
     155        if (!pmSubtractionConvolve(NULL, convRO, NULL, inRO, NULL, stride, 0, 0, 1.0, 0.0,
    171156                                   region, kernels, false, true)) {
    172157            psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i);
     
    211196        }
    212197    }
    213     // XXX if (threaded) {
    214     // XXX     psMutexDestroy(image);
    215     // XXX }
    216198    psFree(inRO);
    217199    psImage *convolved = psMemIncrRefCounter(convRO->image);
     
    264246    psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image
    265247    psImageInit(target, 0);
    266     // XXX if (threaded) {
    267     // XXX     psMutexInit(source);
    268     // XXX }
    269248    for (int i = 0; i < subRegions->n; i++) {
    270249        psRegion *region = subRegions->data[i]; // Subtraction region
     
    287266                    psArray *args = job->args; // Job arguments
    288267                    psArrayAdd(args, 1, target);
    289                     // XXX psMutexLock(source);
    290268                    psArrayAdd(args, 1, source);
    291                     // XXX psMutexUnlock(source);
    292269                    psArrayAdd(args, 1, kernels);
    293270                    PS_ARRAY_ADD_SCALAR(args, numCols, PS_TYPE_S32);
     
    332309        }
    333310
    334         // XXX psMutexDestroy(source);
    335311    }
    336312
  • branches/eam_branches/20090715/psModules/src/imcombine/pmSubtractionMatch.c

    r25407 r25626  
    628628    variance = NULL;
    629629
    630     if (!pmSubtractionBorder(conv1->image, conv1->variance, conv1->mask, size, maskBad)) {
     630    if (conv1 && !pmSubtractionBorder(conv1->image, conv1->variance, conv1->mask, size, maskBad)) {
     631        psError(PS_ERR_UNKNOWN, false, "Unable to set border of convolved image.");
     632        goto MATCH_ERROR;
     633    }
     634    if (conv2 && !pmSubtractionBorder(conv2->image, conv2->variance, conv2->mask, size, maskBad)) {
    631635        psError(PS_ERR_UNKNOWN, false, "Unable to set border of convolved image.");
    632636        goto MATCH_ERROR;
Note: See TracChangeset for help on using the changeset viewer.