IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18179


Ignore:
Timestamp:
Jun 18, 2008, 2:39:33 PM (18 years ago)
Author:
Paul Price
Message:

Calculate and record the variance factor (required for transforming between variances on large scales and small scales)

Location:
trunk/pswarp/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarp.h

    r17955 r18179  
    1414#define PSWARP_RECIPE  "PSWARP" // Name of the recipe to use
    1515#define PSASTRO_RECIPE "PSASTRO" // Name of the recipe to use
     16
     17#define PSWARP_ANALYSIS_VARFACTOR "PSWARP.VARFACTOR" // Name for variance factor in analysis metadata
     18#define PSWARP_ANALYSIS_GOODPIX   "PSWARP.GOODPIX" // Name for number of good pixels in analysis metadata
    1619
    1720// a single pswarpMap converts coordinates from one image to a second image
  • trunk/pswarp/src/pswarpLoop.c

    r18068 r18179  
    253253    }
    254254
     255    // Set variance factor
     256    {
     257        float varFactor = psMetadataLookupF32(NULL, output->analysis, PSWARP_ANALYSIS_VARFACTOR);
     258        psAssert(isfinite(varFactor), "Should be something here.");
     259        long goodPix = psMetadataLookupS64(NULL, output->analysis, PSWARP_ANALYSIS_GOODPIX);
     260        psAssert(goodPix > 0, "Should be something here.");
     261        varFactor /= goodPix;
     262
     263        psMetadataItem *vfItem = psMetadataLookup(outCell->concepts, "CELL.VARFACTOR"); // Item to update
     264        psAssert(vfItem && vfItem->type == PS_TYPE_F64, "Concept should be as specified.");
     265        if (!isfinite(vfItem->data.F64)) {
     266            vfItem->data.F64 = varFactor;
     267        } else {
     268            vfItem->data.F64 *= varFactor;
     269        }
     270    }
     271
    255272    if (!pmConceptsAverageCells(outCell, cells, NULL, NULL, false)) {
    256273        psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
  • trunk/pswarp/src/pswarpTransformReadout_Opt.c

    r17780 r18179  
    8686
    8787    // Iterate over the output image pixels (parent frame)
    88     bool goodPixels = false;            // Any input pixels landing on the output image?
     88    long goodPixels = 0;                // Number of input pixels landing on the output image
    8989    for (int y = minY; y < maxY; y++) {
    9090        if (y >= nextGridY) {
     
    117117            if (inPix->y - inRow0 >= inImage->numRows) continue;
    118118
    119             goodPixels = true;
     119            goodPixels++;
    120120
    121121            // XXX include mask
     
    146146    psFree(grid);
    147147
     148    // Store the variance factor and number of good pixels
     149    if (goodPixels > 0) {
     150        float varFactor = psImageInterpolateVarianceFactor(output->image->numCols, output->image->numRows,
     151                                                           interp); // Variance factor: large --> small scale
     152        psMetadataItem *vfItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_VARFACTOR);
     153        if (vfItem) {
     154            psMetadataItem *goodpixItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_GOODPIX);
     155            psAssert(goodpixItem, "It should be where we left it!");
     156            psAssert(vfItem->type == PS_TYPE_F32 && goodpixItem->type == PS_TYPE_S64,
     157                     "Should be the type we said.");
     158
     159            vfItem->data.F32 += varFactor * goodPixels;
     160            goodpixItem->data.S64 += goodPixels;
     161        } else {
     162            psMetadataAddF32(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_VARFACTOR, 0,
     163                             "Variance factor weighted by the good pixels", varFactor * goodPixels);
     164            psMetadataAddS64(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_GOODPIX, 0,
     165                             "Number of good pixels", goodPixels);
     166        }
     167    }
     168
    148169    // Transform sources
    149170    psArray *inSources = psMetadataLookupPtr(&mdok, input->analysis, "PSPHOT.SOURCES"); // Sources in source
    150     if (goodPixels && mdok && inSources) {
     171    if (goodPixels > 0 && mdok && inSources) {
    151172        pswarpMapGrid *sourceGrid = pswarpMapGridFromImage(output, input, nGridX, nGridY); // Grid for sources
    152173
Note: See TracChangeset for help on using the changeset viewer.