Skip to content

Commit

Permalink
Additional speed improvements for MEDIAN_PER_ROW overscan.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed May 31, 2022
1 parent fce0252 commit 45a5a08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions python/lsst/ip/isr/overscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ def measureVectorOverscan(self, image):
if isTransposed:
masked = masked.transpose()

mi.getImage().getArray()[:, :] = masked.data[:, :]
mi.image.array[:, :] = masked.data[:, :]
if bool(masked.mask.shape):
mi.getMask().getArray()[:, :] = masked.mask[:, :]
mi.mask.array[:, :] = masked.mask[:, :]

overscanVector = fitOverscanImage(mi, self.config.maskPlanes, isTransposed)
maskArray = self.maskExtrapolated(overscanVector)
Expand Down Expand Up @@ -522,7 +522,7 @@ def measureVectorOverscan(self, image):
overscanVector = evaler(indices, coeffs)
maskArray = self.maskExtrapolated(collapsed)
endTime = time.perf_counter()
self.log.info(f"Overscan measurement took {endTime - startTime} s {self.config.fitType}")
self.log.info(f"Overscan measurement took {endTime - startTime}s for {self.config.fitType}")
return pipeBase.Struct(overscanValue=np.array(overscanVector),
maskArray=maskArray,
isTransposed=isTransposed)
Expand Down
29 changes: 14 additions & 15 deletions src/Isr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,24 @@ std::vector<double> fitOverscanImage(

afw::math::StatisticsControl statControl;
statControl.setAndMask(overscan.getMask()->getPlaneBitMask(badPixelMask));

const int x0 = overscan.getX0();
const int y0 = overscan.getY0();
for (int x = 0; x < length; ++x) {
/**
geom::Box2I bbox = geom::Box2I( geom::Point2I(0, y),
geom::Point2I(0, width) );
The above was how this was defined before ticket #1556. As I understand it
the following is the new way to do this
**/
geom::Box2I bbox;
if (isTransposed) {
bbox = geom::Box2I(geom::Point2I(x0 + x,y0), geom::Extent2I(1,height));
}
else {
bbox = geom::Box2I(geom::Point2I(x0,y0 + x), geom::Extent2I(width,1));
}
MaskedImage mi = MaskedImage(overscan, bbox);
auto origin = geom::Point2I(x0, y0);
geom::Extent2I shifter;
geom::Extent2I extents;
if (isTransposed) {
shifter = geom::Extent2I(1, 0);
extents = geom::Extent2I(1, height);
} else {
shifter = geom::Extent2I(0, 1);
extents = geom::Extent2I(width, 1);
}

for (int x = 0; x < length; ++x) {
MaskedImage mi = MaskedImage(overscan, geom::Box2I(origin, extents));
values[x] = afw::math::makeStatistics(mi, afw::math::MEDIAN, statControl).getValue();
origin.shift(shifter);
}
return values;
}
Expand Down

0 comments on commit 45a5a08

Please sign in to comment.