IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30868


Ignore:
Timestamp:
Mar 10, 2011, 5:28:23 PM (15 years ago)
Author:
eugene
Message:

deprecate the old names for fitted mean stats; define a larger window than the superpixel size for the background model, fix an error in the missing-pixel interpolation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/psphotModelBackground.c

    r30785 r30868  
    6767    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS);
    6868
     69    float dXsample = psMetadataLookupF32(&status, recipe, "BACKGROUND.XSAMPLE");
     70    if (!status) dXsample = 1.0;
     71    float dYsample = psMetadataLookupF32(&status, recipe, "BACKGROUND.YSAMPLE");
     72    if (!status) dYsample = 1.0;
     73
    6974    // subtract this amount extra from the sky
    7075    float SKY_BIAS = psMetadataLookupF32 (&status, recipe, "SKY_BIAS");
     
    8489                                 PS_STAT_ROBUST_QUARTILE |
    8590                                 PS_STAT_CLIPPED_MEAN |
    86                                  PS_STAT_FITTED_MEAN |
    87                                  PS_STAT_FITTED_MEAN_V2 |
    88                                  PS_STAT_FITTED_MEAN_V3 |
    89                                  PS_STAT_FITTED_MEAN_V4))) {
     91                                 PS_STAT_FITTED_MEAN))) {
    9092        statsOptionLocation = PS_STAT_FITTED_MEAN;
    9193    }
     
    9597        statsOptionWidth = PS_STAT_SAMPLE_STDEV;
    9698    } else if (statsOptionLocation & (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_QUARTILE)) {
    97 #if 1
    98         statsOptionWidth = PS_STAT_ROBUST_STDEV; // not set; => NaN
    99 #else
    100         statsOptionWidth = PS_STAT_FITTED_STDEV;
    101 #endif
     99        statsOptionWidth = PS_STAT_ROBUST_STDEV;
    102100    } else if (statsOptionLocation & PS_STAT_FITTED_MEAN) {
    103101        statsOptionWidth = PS_STAT_FITTED_STDEV;
    104102    } else if (statsOptionLocation & PS_STAT_CLIPPED_MEAN) {
    105103        statsOptionWidth = PS_STAT_CLIPPED_STDEV;
    106     } else if (statsOptionLocation & PS_STAT_FITTED_MEAN_V2) {
    107         statsOptionWidth = PS_STAT_FITTED_STDEV_V2;
    108     } else if (statsOptionLocation & PS_STAT_FITTED_MEAN_V3) {
    109         statsOptionWidth = PS_STAT_FITTED_STDEV_V3;
    110     } else if (statsOptionLocation & PS_STAT_FITTED_MEAN_V4) {
    111         statsOptionWidth = PS_STAT_FITTED_STDEV_V4;
    112104    } else {
    113105        psAbort("Unable to estimate variance of selected statsOptionLocations 0x%x", statsOptionLocation);
     
    138130    stats->clipSigma = psMetadataLookupF32 (&status, recipe, "SKY_CLIP_SIGMA");
    139131    if (!status) {
    140         if ((stats->options & PS_STAT_FITTED_MEAN) || (stats->options & PS_STAT_FITTED_MEAN_V2)) {
     132        if (stats->options & PS_STAT_FITTED_MEAN) {
    141133            stats->clipSigma = 1.0;
    142134        } else {
     
    160152    int nFailures = 0;
    161153    psImageBackgroundInit();
     154
     155    // we have Nx * Ny model points, but we can use a window which is larger (or smaller) than
     156    // 1 superpixel.  If we have a window of size dXsample * dYsample, then the regions run from:
     157    // (ix + 0.5) - dX to (ix + 0.5) + dX
    162158
    163159    // measure clipped median for subimages
     
    168164
    169165            // convert the ruff grid cell to the equivalent fine grid cell
    170             // XXX we need to watch out for row0,col0
    171             ruffRegion = psRegionSet (ix, ix + 1, iy, iy + 1);
     166            ruffRegion = psRegionSet (ix + 0.5 - 0.5*dXsample, ix + 0.5 + 0.5*dXsample,
     167                                      iy + 0.5 - 0.5*dYsample, iy + 0.5 + 0.5*dYsample);
    172168            fineRegion = psImageBinningSetFineRegion (binning, ruffRegion);
    173169            fineRegion = psRegionForImage (image, fineRegion);
     
    205201
    206202            if (gotX && gotY) {
    207                 (void) psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6);
     203                (void) psTraceSetLevel ("psLib.math.vectorFittedStats", 6);
    208204                (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 6);
    209205            } else {
    210                 (void) psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0);
     206                (void) psTraceSetLevel ("psLib.math.vectorFittedStats", 0);
    211207                (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 0);
    212208            }
     
    270266    for (int iy = 0; iy < model->numRows; iy++) {
    271267        for (int ix = 0; ix < model->numCols; ix++) {
    272             if (!isnan(modelData[iy][ix])) {
     268            if (isfinite(modelData[iy][ix])) {
    273269                Value += modelData[iy][ix];
    274270                ValueStdev += modelStdevData[iy][ix];
     
    286282                    if (jx   <   0) continue;
    287283                    if (jx   >= model->numCols) continue;
     284                    if (!isfinite(modelData[jy][jx])) continue;
    288285                    value += modelData[jy][jx];
    289286                    count += 1.0;
    290287                }
    291288            }
    292             if (count > 0) modelData[iy][ix] = value / count;
     289            if (count > 0) {
     290                psLogMsg ("psphot", PS_LOG_DETAIL, "patching background %d, %d: %f (%d pts)\n", ix, iy, (value / count), (int) count);
     291                modelData[iy][ix] = value / count;
     292            }
    293293        }
    294294    }
Note: See TracChangeset for help on using the changeset viewer.