IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30104


Ignore:
Timestamp:
Dec 17, 2010, 10:06:58 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20101205/psLib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psLib/src/imageops

  • branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageMapFit.c

    r30019 r30104  
    4848
    4949// map defines the output image dimensions and scaling.
    50 bool psImageMapFit(bool *goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     50bool psImageMapFit(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    5151                   const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    5252{
    5353    // XXX Add Asserts
    5454
    55     *goodFit = false;
     55    *pGoodFit = false;
    5656
    5757    // dimensions of the output map image
     
    8383        map->map->data.F32[0][0]   = psStatsGetValue(map->stats, mean);
    8484        map->error->data.F32[0][0] = psStatsGetValue(map->stats, stdev);
    85         *goodFit = true;
     85        if (isfinite(map->map->data.F32[0][0]) && isfinite( map->error->data.F32[0][0])) {
     86            *pGoodFit = true;
     87        }
    8688        return true;
    8789    }
     
    8991    if (Nx == 1) {
    9092        bool status;
    91         status = psImageMapFit1DinY (goodFit, map, mask, maskValue, x, y, f, df);
     93        status = psImageMapFit1DinY (pGoodFit, map, mask, maskValue, x, y, f, df);
    9294        return status;
    9395    }
    9496    if (Ny == 1) {
    9597        bool status;
    96         status = psImageMapFit1DinX (goodFit, map, mask, maskValue, x, y, f, df);
     98        status = psImageMapFit1DinX (pGoodFit, map, mask, maskValue, x, y, f, df);
    9799        return status;
    98100    }
     
    339341    psFree (Empty);
    340342
    341     *goodFit = true;
     343    *pGoodFit = true;
    342344    return true;
    343345}
    344346
    345347// measure residuals on each pass and clip outliers based on stats
    346 bool psImageMapClipFit(bool *goodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
     348bool psImageMapClipFit(bool *pGoodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
    347349                       const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    348350{
     
    354356    psAssert(f, "impossible");
    355357
    356     *goodFit = false;
     358    *pGoodFit = false;
    357359
    358360    // the user supplies one of various stats option pairs,
     
    398400        psTrace("psLib.imageops", 6, "Loop iteration %d.  Calling psImageMapFit()\n", N);
    399401        psS32 Nkeep = 0;
    400         if (!psImageMapFit(goodFit, map, mask, maskValue, x, y, f, df)) {
     402        if (!psImageMapFit(pGoodFit, map, mask, maskValue, x, y, f, df)) {
    401403            psError(PS_ERR_UNKNOWN, false, "Could not fit image map.\n");
    402404            psFree(resid);
     
    404406            return false;
    405407        }
    406         if (!goodFit) {
     408        if (!*pGoodFit) {
    407409            psWarning ("bad fit to image map, try something else");
    408410            return true;
     
    463465    psFree(resid);
    464466    if (!inMask) psFree (mask);
    465     *goodFit = true; // XXX probably don't need to set this (set by psImageMapFit)
     467    *pGoodFit = true; // XXX probably don't need to set this (set by psImageMapFit)
    466468    return true;
    467469}
    468470
    469471// map defines the output image dimensions and scaling.
    470 bool psImageMapFit1DinY(bool *goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     472bool psImageMapFit1DinY(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    471473                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    472474{
     
    474476    assert (map->binning->nXruff == 1);
    475477
    476     *goodFit = false;
     478    *pGoodFit = false;
    477479
    478480    // dimensions of the output map image
     
    613615    psFree (Empty);
    614616
    615     *goodFit = true;
     617    *pGoodFit = true;
    616618    return true;
    617619}
    618620
    619621// map defines the output image dimensions and scaling.
    620 bool psImageMapFit1DinX(bool *goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     622bool psImageMapFit1DinX(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    621623                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    622624{
     
    624626    assert (map->binning->nYruff == 1);
    625627
    626     *goodFit = false;
     628    *pGoodFit = false;
    627629
    628630    // dimensions of the output map image
     
    763765    psFree (Empty);
    764766
    765     *goodFit = true;
     767    *pGoodFit = true;
    766768    return true;
    767769}
  • branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageMapFit.h

    r30019 r30104  
    88
    99// fit the image map to a set of points
    10 bool psImageMapFit(bool *goodFit,
     10bool psImageMapFit(bool *pGoodFit,
    1111                   psImageMap *map,
    1212                   const psVector *mask,
     
    1919
    2020// fit the image map to a set of points
    21 bool psImageMapClipFit(bool *goodFit,
     21bool psImageMapClipFit(bool *pGoodFit,
    2222                       psImageMap *map,
    2323                       psStats *stats,
     
    3030    );
    3131
    32 bool psImageMapFit1DinY(bool *goodFit,
     32bool psImageMapFit1DinY(bool *pGoodFit,
    3333                        psImageMap *map,
    3434                        const psVector *mask,
     
    4040    );
    4141
    42 bool psImageMapFit1DinX(bool *goodFit,
     42bool psImageMapFit1DinX(bool *pGoodFit,
    4343                        psImageMap *map,
    4444                        const psVector *mask,
  • branches/eam_branches/ipp-20101205/psLib/src/math/psStats.c

    r28998 r30104  
    827827        // values; nearly bi-modal distribution).  if so, keep only points within 5? 10?
    828828        // bins of that excess bin:
    829         int nMaxBin = 0;
     829        int nMaxBin = histogram->nums->data.F32[0];
    830830        int iMaxBin = 0;
    831831        for (long i = 1; i < histogram->nums->n; i++) {
     
    843843                if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) continue;
    844844                bool invalid = false;
    845                 invalid |= (myVector->data.F32[i] <= minKeep);
    846                 invalid |= (myVector->data.F32[i] >= maxKeep);
     845                invalid |= (myVector->data.F32[i] < minKeep);
     846                invalid |= (myVector->data.F32[i] > maxKeep);
    847847                invalid |= (!isfinite(myVector->data.F32[i]));
    848848                if (!invalid) continue;
     
    852852
    853853            if (nInvalid) {
    854               psTrace(TRACE, 6, "data is concentrated in a single bin, masking %d extreme outliers and retrying\n", nInvalid);
     854              psTrace(TRACE, 6, "data is concentrated in a single bin (%d = %f - %f), masking %d extreme outliers and retrying\n",
     855                      iMaxBin, histogram->bounds->data.F32[iMaxBin], histogram->bounds->data.F32[iMaxBin+1], nInvalid);
    855856              psFree(histogram);
    856857              psFree(cumulative);
     
    11081109    // If the mean is NAN, then generate a warning and set the stdev to NAN.
    11091110    if (isnan(stats->robustMedian)) {
    1110         stats->fittedStdev = NAN;
    1111         stats->fittedStdev = NAN;
     1111        stats->fittedMean = NAN;
     1112        stats->fittedStdev = NAN;
     1113        stats->results |= PS_STAT_FITTED_MEAN;
     1114        stats->results |= PS_STAT_FITTED_STDEV;
     1115        return true;
     1116    }
     1117
     1118    if (stats->robustStdev <= FLT_EPSILON) {
     1119        stats->fittedMean = stats->robustMedian;
     1120        stats->fittedStdev = stats->robustStdev;
     1121        stats->results |= PS_STAT_FITTED_MEAN;
     1122        stats->results |= PS_STAT_FITTED_STDEV;
    11121123        return true;
    11131124    }
     
    12891300    // If the mean is NAN, then generate a warning and set the stdev to NAN.
    12901301    if (isnan(stats->robustMedian)) {
    1291         stats->fittedStdev = NAN;
    1292         stats->fittedStdev = NAN;
    1293         psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
     1302        stats->fittedMean = NAN;
     1303        stats->fittedStdev = NAN;
     1304        stats->results |= PS_STAT_FITTED_MEAN_V2;
     1305        stats->results |= PS_STAT_FITTED_STDEV_V2;
     1306        return true;
     1307    }
     1308
     1309    if (stats->robustStdev <= FLT_EPSILON) {
     1310        stats->fittedMean = stats->robustMedian;
     1311        stats->fittedStdev = stats->robustStdev;
     1312        stats->results |= PS_STAT_FITTED_MEAN_V2;
     1313        stats->results |= PS_STAT_FITTED_STDEV_V2;
    12941314        return true;
    12951315    }
     
    14861506    // If the mean is NAN, then generate a warning and set the stdev to NAN.
    14871507    if (isnan(stats->robustMedian)) {
    1488         stats->fittedStdev = NAN;
    1489         stats->fittedStdev = NAN;
    1490         psTrace(TRACE, 4, "---- %s() end ----\n", __func__);
     1508        stats->fittedMean = NAN;
     1509        stats->fittedStdev = NAN;
     1510        stats->results |= PS_STAT_FITTED_MEAN_V3;
     1511        stats->results |= PS_STAT_FITTED_STDEV_V3;
     1512        return true;
     1513    }
     1514
     1515    if (stats->robustStdev <= FLT_EPSILON) {
     1516        stats->fittedMean = stats->robustMedian;
     1517        stats->fittedStdev = stats->robustStdev;
     1518        stats->results |= PS_STAT_FITTED_MEAN_V3;
     1519        stats->results |= PS_STAT_FITTED_STDEV_V3;
    14911520        return true;
    14921521    }
     
    17821811
    17831812    // If the mean is NAN, then generate a warning and set the stdev to NAN.
    1784     if (isnan(stats->robustMedian)) goto escape;
     1813    if (isnan(stats->robustMedian)) {
     1814        stats->fittedMean = NAN;
     1815        stats->fittedStdev = NAN;
     1816        stats->results |= PS_STAT_FITTED_MEAN_V4;
     1817        stats->results |= PS_STAT_FITTED_STDEV_V4;
     1818        return true;
     1819    }
     1820
     1821    if (stats->robustStdev <= FLT_EPSILON) {
     1822        stats->fittedMean = stats->robustMedian;
     1823        stats->fittedStdev = stats->robustStdev;
     1824        stats->results |= PS_STAT_FITTED_MEAN_V4;
     1825        stats->results |= PS_STAT_FITTED_STDEV_V4;
     1826        return true;
     1827    }
    17851828
    17861829    float guessStdev = stats->robustStdev;  // pass the guess sigma
  • branches/eam_branches/ipp-20101205/psLib/src/types/psMetadata.c

    r29833 r30104  
    13711371            break;
    13721372        case PS_DATA_S64:
    1373             fprintf(fd, "%jd\n", item->data.S64);
     1373            fprintf(fd, "%" PRId64 "\n", item->data.S64);
    13741374            break;
    13751375        case PS_DATA_U8:
     
    13831383            break;
    13841384        case PS_DATA_U64:
    1385             fprintf(fd, "%ju\n", item->data.U64);
     1385            fprintf(fd, "%" PRIu64 "\n", item->data.U64);
    13861386            break;
    13871387        case PS_DATA_F32:
     
    14581458              fprintf(fd, "U64  ");
    14591459              for (int i = 0; i < vector->n; i++) {
    1460                   fprintf(fd, "%ju ", vector->data.U64[i]);
     1460                  fprintf(fd, "%" PRIu64, vector->data.U64[i]);
    14611461              }
    14621462              fprintf(fd, "\n");
     
    14861486              fprintf(fd, "S64  ");
    14871487              for (int i = 0; i < vector->n; i++) {
    1488                   fprintf(fd, "%jd ", vector->data.S64[i]);
     1488                  fprintf(fd, "%" PRId64, vector->data.S64[i]);
    14891489              }
    14901490              fprintf(fd, "\n");
  • branches/eam_branches/ipp-20101205/psLib/test/math

Note: See TracChangeset for help on using the changeset viewer.