Changeset 42717
- Timestamp:
- Aug 14, 2024, 5:06:43 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2dbias/psModules/src/detrend/pmOverscan.c
r42715 r42717 441 441 if (yscan->col0 >= xscan->col0 && yscan->col0 + yscan->numCols <= xscan->col0 + xscan->numCols) 442 442 { 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); 445 467 // XXX apply the 2D bias correction here 446 468 int yDiff = yscan->row0 - image->row0; // y offset between the science and the yoverscan region … … 452 474 int iy = i + yDiff; 453 475 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]; 455 477 } 456 478 }
Note:
See TracChangeset
for help on using the changeset viewer.
