IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 12:45:24 PM (17 years ago)
Author:
eugene
Message:

update from mainline

Location:
branches/eam_branches/20090715
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715

  • branches/eam_branches/20090715/psModules/src/imcombine/pmReadoutCombine.c

    r24791 r25022  
    281281    #endif
    282282
     283    // set up windows for visualization (if selected)
     284    pmReadoutCombineVisualInit();
     285
    283286    // Dereference output products
    284287    psF32 **outputImage  = output->image->data.F32; // Output image
     
    397400            outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine);
    398401
     402            if (!isfinite(outputImage[yOut][xOut])) {
     403                pmReadoutCombineVisualPixels(pixels, mask, outputImage[yOut][xOut]);
     404            }
     405
    399406            if (isnan(outputImage[yOut][xOut])) {
    400407                outputImage[yOut][xOut] = NAN;
     
    434441}
    435442
     443#if (HAVE_KAPA)
     444#include <kapa.h>
     445#include "pmKapaPlots.h"
     446#include "pmVisual.h"
     447
     448static int kapa = -1;
     449static bool plotFlag = true;
     450
     451// this init function only gets the ordinates for the first readout...
     452bool pmReadoutCombineVisualInit(void) {
     453   
     454    if (!pmVisualIsVisual()) return true;
     455
     456    // skip if we have already opened the windows (or if none are requested...)
     457    if (kapa != -1) return true;
     458
     459    pmVisualInitWindow(&kapa, "ppmerge");
     460    return true;
     461}
     462
     463bool pmReadoutCombineVisualPixels(psVector *pixels, psVector *mask, float mean) {
     464
     465    Graphdata graphdata;
     466    float xline[2], yline[2];
     467   
     468    if (!pmVisualIsVisual()) return true;
     469
     470    if (!plotFlag) return true;
     471
     472    KapaInitGraph(&graphdata);
     473
     474    psVector *xAll = psVectorAlloc(pixels->n, PS_TYPE_F32);
     475    psVector *xSub = psVectorAlloc(pixels->n, PS_TYPE_F32);
     476    psVector *ySub = psVectorAlloc(pixels->n, PS_TYPE_F32);
     477
     478    // generate vectors of the unmasked values
     479    int nSub = 0;
     480    for (int j = 0; j < pixels->n; j++) {
     481        xAll->data.F32[j] = j;
     482        if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) continue;
     483        xSub->data.F32[nSub] = j;
     484        ySub->data.F32[nSub] = pixels->data.F32[j];
     485        nSub ++;
     486    }
     487    xSub->n = ySub->n = nSub;
     488    xAll->n = pixels->n;
     489       
     490    xline[0] = 0;
     491    xline[1] = pixels->n;
     492    yline[0] = mean;
     493    yline[1] = mean;
     494
     495    // plot the unmasked values
     496    pmVisualScaleGraphdata (&graphdata, xAll, pixels, false);
     497    KapaSetGraphData(kapa, &graphdata);
     498    KapaSetLimits(kapa, &graphdata);
     499    KapaClearPlots (kapa);
     500
     501    KapaSetFont (kapa, "courier", 14);
     502    KapaBox (kapa, &graphdata);
     503    KapaSendLabel (kapa, "ordinate", KAPA_LABEL_XM);
     504    KapaSendLabel (kapa, "pixel values", KAPA_LABEL_YM);
     505
     506    graphdata.color = KapaColorByName("black");
     507    graphdata.style = 2;
     508    graphdata.ptype = 2;
     509    KapaPrepPlot  (kapa, xSub->n, &graphdata);
     510    KapaPlotVector(kapa, xSub->n, xSub->data.F32, "x");
     511    KapaPlotVector(kapa, xSub->n, ySub->data.F32, "y");
     512
     513    graphdata.color = KapaColorByName("red");
     514    graphdata.style = 2;
     515    graphdata.ptype = 7;
     516    KapaPrepPlot  (kapa, xAll->n, &graphdata);
     517    KapaPlotVector(kapa, xAll->n, xAll->data.F32, "x");
     518    KapaPlotVector(kapa, xAll->n, pixels->data.F32, "y");
     519
     520    graphdata.color = KapaColorByName("blue");
     521    graphdata.style = 0;
     522    graphdata.ptype = 7;
     523    KapaPrepPlot  (kapa, 2, &graphdata);
     524    KapaPlotVector(kapa, 2, xline, "x");
     525    KapaPlotVector(kapa, 2, yline, "y");
     526
     527    pmVisualAskUser (&plotFlag);
     528    return true;
     529}
     530
     531bool pmReadoutCombineVisualCleanup(void) {
     532
     533    if (!pmVisualIsVisual()) return true;
     534    if (kapa == -1) return true;
     535
     536    KapaClose(kapa);
     537    return true;
     538}
     539
     540# else
     541
     542bool pmReadoutCombineVisualInit(void) { return true; }
     543bool pmReadoutCombineVisualPixels(psVector *pixels, psVector *mask, float mean) { return true; }
     544bool pmReadoutCombineVisualCleanup(void) { return true; }
     545
     546# endif
  • branches/eam_branches/20090715/psModules/src/imcombine/pmReadoutCombine.h

    r21363 r25022  
    4747                     );
    4848
     49bool pmReadoutCombineVisualInit(void);
     50bool pmReadoutCombineVisualPixels(psVector *pixels, psVector *mask, float mean);
     51bool pmReadoutCombineVisualCleanup(void);
     52
    4953/// @}
    5054#endif
  • branches/eam_branches/20090715/psModules/src/imcombine/pmSubtractionEquation.c

    r24621 r25022  
    793793
    794794#ifdef TESTING
    795               // XXX double-check for NAN in data:
    796                 for (int iy = 0; iy < stamp->matrix1->numRows; iy++) {
    797                     for (int ix = 0; ix < stamp->matrix1->numCols; ix++) {
    798                         if (!isfinite(stamp->matrix1->data.F64[iy][ix])) {
    799                             fprintf (stderr, "WARNING: NAN in matrix1\n");
    800                         }
    801                     }
    802                 }
    803                 for (int ix = 0; ix < stamp->vector1->n; ix++) {
    804                     if (!isfinite(stamp->vector1->data.F64[ix])) {
    805                         fprintf (stderr, "WARNING: NAN in vector1\n");
    806                     }
    807                 }
     795              // XXX double-check for NAN in data:
     796                for (int iy = 0; iy < stamp->matrix1->numRows; iy++) {
     797                    for (int ix = 0; ix < stamp->matrix1->numCols; ix++) {
     798                        if (!isfinite(stamp->matrix1->data.F64[iy][ix])) {
     799                            fprintf (stderr, "WARNING: NAN in matrix1\n");
     800                        }
     801                    }
     802                }
     803                for (int ix = 0; ix < stamp->vector1->n; ix++) {
     804                    if (!isfinite(stamp->vector1->data.F64[ix])) {
     805                        fprintf (stderr, "WARNING: NAN in vector1\n");
     806                    }
     807                }
    808808#endif
    809809
     
    818818
    819819#ifdef TESTING
    820         for (int ix = 0; ix < sumVector->n; ix++) {
    821             if (!isfinite(sumVector->data.F64[ix])) {
    822                 fprintf (stderr, "WARNING: NAN in vector1\n");
    823             }
    824         }
     820        for (int ix = 0; ix < sumVector->n; ix++) {
     821            if (!isfinite(sumVector->data.F64[ix])) {
     822                fprintf (stderr, "WARNING: NAN in vector1\n");
     823            }
     824        }
    825825#endif
    826826
     
    828828
    829829#ifdef TESTING
    830         for (int ix = 0; ix < sumVector->n; ix++) {
    831             if (!isfinite(sumVector->data.F64[ix])) {
    832                 fprintf (stderr, "WARNING: NAN in vector1\n");
    833             }
    834         }
     830        for (int ix = 0; ix < sumVector->n; ix++) {
     831            if (!isfinite(sumVector->data.F64[ix])) {
     832                fprintf (stderr, "WARNING: NAN in vector1\n");
     833            }
     834        }
    835835        {
    836836            psImage *inverse = psMatrixInvert(NULL, sumMatrix, NULL);
     
    866866
    867867#ifdef TESTING
    868         // XXX double-check for NAN in data:
    869         for (int ix = 0; ix < kernels->solution1->n; ix++) {
    870             if (!isfinite(kernels->solution1->data.F64[ix])) {
    871                 fprintf (stderr, "WARNING: NAN in vector1\n");
    872             }
    873         }
     868        // XXX double-check for NAN in data:
     869        for (int ix = 0; ix < kernels->solution1->n; ix++) {
     870            if (!isfinite(kernels->solution1->data.F64[ix])) {
     871                fprintf (stderr, "WARNING: NAN in vector1\n");
     872            }
     873        }
    874874#endif
    875875
     
    11271127                source = stamp->image1;
    11281128                convolutions = stamp->convolutions1;
     1129
     1130                // Having convolved image1 and changed its normalisation, we need to renormalise the residual
     1131                // so that it is on the scale of image1.
     1132                psImage *image = pmSubtractionKernelImage(kernels, stamp->xNorm, stamp->yNorm,
     1133                                                          false); // Kernel image
     1134                if (!image) {
     1135                    psError(PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");
     1136                    return false;
     1137                }
     1138                double sumKernel = 0;   // Sum of kernel, for normalising residual
     1139                int size = kernels->size; // Half-size of kernel
     1140                int fullSize = 2 * size + 1; // Full size of kernel
     1141                for (int y = 0; y < fullSize; y++) {
     1142                    for (int x = 0; x < fullSize; x++) {
     1143                        sumKernel += image->data.F32[y][x];
     1144                    }
     1145                }
     1146                psFree(image);
     1147                devNorm = 1.0 / sumKernel / numPixels;
    11291148                break;
    11301149              case PM_SUBTRACTION_MODE_2:
Note: See TracChangeset for help on using the changeset viewer.