Skip to content

Commit

Permalink
Stop using ndarray::Array::asEigen
Browse files Browse the repository at this point in the history
Replace it with ndarray::asEigenArray, which returns an Eigen::Map
instead of an ndarray::EigenView
  • Loading branch information
r-owen committed Jun 13, 2018
1 parent 66b7bb6 commit cb55f0a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/PsfFlux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ void PsfFluxAlgorithm::measure(afw::table::SourceRecord& measRecord,
throw LSST_EXCEPT(MeasurementError, NO_GOOD_PIXELS.doc, NO_GOOD_PIXELS.number);
}
typedef afw::detection::Psf::Pixel PsfPixel;
auto model = fitRegion.getSpans()
->flatten(psfImage->getArray(), psfImage->getXY0())
.asEigen<Eigen::ArrayXpr>();
auto data = fitRegion.getSpans()
->flatten(exposure.getMaskedImage().getImage()->getArray(), exposure.getXY0())
.asEigen<Eigen::ArrayXpr>();
auto variance = fitRegion.getSpans()
->flatten(exposure.getMaskedImage().getVariance()->getArray(), exposure.getXY0())
.asEigen<Eigen::ArrayXpr>();
// SpanSet::flatten returns a new ndarray::Array, which must stay in scope
// while we use an Eigen::Map view of it
auto modelNd = fitRegion.getSpans()->flatten(psfImage->getArray(), psfImage->getXY0());
auto dataNd = fitRegion.getSpans()->flatten(exposure.getMaskedImage().getImage()->getArray(),
exposure.getXY0());
auto varianceNd = fitRegion.getSpans()->flatten(exposure.getMaskedImage().getVariance()->getArray(),
exposure.getXY0());
auto model = ndarray::asEigenArray(modelNd);
auto data = ndarray::asEigenArray(dataNd);
auto variance = ndarray::asEigenArray(varianceNd);
PsfPixel alpha = model.matrix().squaredNorm();
FluxResult result;
result.flux = model.matrix().dot(data.matrix().cast<PsfPixel>()) / alpha;
Expand Down

0 comments on commit cb55f0a

Please sign in to comment.