IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42717


Ignore:
Timestamp:
Aug 14, 2024, 5:06:43 PM (2 years ago)
Author:
hgao
Message:

more robust normalization of the xReduced vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2dbias/psModules/src/detrend/pmOverscan.c

    r42715 r42717  
    441441                if (yscan->col0 >= xscan->col0 && yscan->col0 + yscan->numCols <= xscan->col0 + xscan->numCols)
    442442                {
    443                         // define where to normalize the xReduced vector
    444                         int j0 = yscan->col0 - xscan->col0 + (int)(yscan->numCols / 2) - 1;
     443                        // define how to normalize the xReduced vector
     444                        // slice the part overlapping withe yoverscan from xReduced
     445                        long startIndex = yscan->col0 - xscan->col0;
     446                        long normSize = xReduced->n - startIndex; // Calculate the size of the new vector
     447                        // Allocate the new vector
     448                        psVector *normVector = psVectorAlloc(normSize, PS_TYPE_F32);
     449                        // Copy the data from xReduced starting from startIndex to the end
     450                        for (long i = startIndex; i < xReduced->n; i++)
     451                        {
     452                                normVector->data.F32[i - startIndex] = xReduced->data.F32[i];
     453                        }
     454                        // Now normVector holds the sliced data; then, compute its robust mean
     455                        psStatsOptions statistic = PS_STAT_CLIPPED_MEAN;
     456                        psStats *stats = psStatsAlloc(statistic);
     457                        if (!psVectorStats(stats, normVector, NULL, NULL, 0))
     458                        {
     459                                psError(PS_ERR_UNKNOWN, false, "failure to measure clipped mean as normalization of xReduced");
     460                                psFree(stats);
     461                                psFree(normVector);
     462                                return NULL;
     463                        }
     464                        float xReducedNormalized = psStatsGetValue(stats, statistic);
     465                        psFree(stats);
     466                        psFree(normVector);
    445467                        // XXX apply the 2D bias correction here
    446468                        int yDiff = yscan->row0 - image->row0; // y offset between the science and the yoverscan region
     
    452474                                        int iy = i + yDiff;
    453475                                        int jx = j + xDiff;
    454                                         image->data.F32[i][j] -= yReduced->data.F32[iy] - xReduced->data.F32[j0] + xReduced->data.F32[jx];
     476                                        image->data.F32[i][j] -= yReduced->data.F32[iy] - xReducedNormalized + xReduced->data.F32[jx];
    455477                                }
    456478                        }
Note: See TracChangeset for help on using the changeset viewer.