LSSTApplications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-11-ga6ea59e8e+47cba9fc36,21.0.0-2-g103fe59+914993bf7c,21.0.0-2-g1367e85+e2614ded12,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g4bc9b9f+7b2b5f8678,21.0.0-2-g5242d73+e2614ded12,21.0.0-2-g54e2caa+6403186824,21.0.0-2-g7f82c8f+3ac4acbffc,21.0.0-2-g8dde007+04a6aea1af,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+3ac4acbffc,21.0.0-2-ga63a54e+81dd751046,21.0.0-2-gc738bc1+5f65c6e7a9,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0993ddc9bd,21.0.0-2-gfc62afb+e2614ded12,21.0.0-21-gba890a8+5a4f502a26,21.0.0-23-g9966ff26+03098d1af8,21.0.0-3-g357aad2+8ad216c477,21.0.0-3-g4be5c26+e2614ded12,21.0.0-3-g6d51c4a+4d2fe0280d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+522e0f12c2,21.0.0-3-ge02ed75+4d2fe0280d,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-gc004bbf+eac6615e82,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-gd1c1571+18b81799f9,21.0.0-5-g7b47fff+4d2fe0280d,21.0.0-5-gb155db7+d2632f662b,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g722ad07+28c848f42a,21.0.0-7-g959bb79+522e0f12c2,21.0.0-7-gfd72ab2+cf01990774,21.0.0-9-g87fb7b8d+e2ab11cdd6,w.2021.04
LSSTDataManagementBasePackage
CoaddPsf.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 /*
26  * Represent a PSF as for a Coadd based on the James Jee stacking
27  * algorithm which was extracted from Stackfit.
28  */
29 #include <cmath>
30 #include <sstream>
31 #include <iostream>
32 #include <numeric>
33 #include "boost/iterator/iterator_adaptor.hpp"
34 #include "boost/iterator/transform_iterator.hpp"
35 #include "ndarray/eigen.h"
36 #include "lsst/base.h"
37 #include "lsst/pex/exceptions.h"
38 #include "lsst/geom/Box.h"
47 
48 namespace lsst {
49 namespace afw {
50 namespace table {
51 namespace io {
52 
55 
56 } // namespace io
57 } // namespace table
58 } // namespace afw
59 namespace meas {
60 namespace algorithms {
61 
62 namespace {
63 
64 // Struct used to simplify calculations in computeAveragePosition; lets us use
65 // std::accumulate instead of explicit for loop.
66 struct AvgPosItem {
67  double wx; // weighted x position
68  double wy; // weighted y position
69  double w; // weight value
70 
71  explicit AvgPosItem(double wx_ = 0.0, double wy_ = 0.0, double w_ = 0.0) : wx(wx_), wy(wy_), w(w_) {}
72 
73  // return point, assuming this is a sum of many AvgPosItems
74  geom::Point2D getPoint() const { return geom::Point2D(wx / w, wy / w); }
75 
76  // comparison so we can sort by weights
77  bool operator<(AvgPosItem const &other) const { return w < other.w; }
78 
79  AvgPosItem &operator+=(AvgPosItem const &other) {
80  wx += other.wx;
81  wy += other.wy;
82  w += other.w;
83  return *this;
84  }
85 
86  AvgPosItem &operator-=(AvgPosItem const &other) {
87  wx -= other.wx;
88  wy -= other.wy;
89  w -= other.w;
90  return *this;
91  }
92 
93  friend AvgPosItem operator+(AvgPosItem a, AvgPosItem const &b) { return a += b; }
94 
95  friend AvgPosItem operator-(AvgPosItem a, AvgPosItem const &b) { return a -= b; }
96 };
97 
98 geom::Point2D computeAveragePosition(afw::table::ExposureCatalog const &catalog,
99  afw::geom::SkyWcs const &coaddWcs, afw::table::Key<double> weightKey) {
100  afw::table::Key<int> goodPixKey;
101  try {
102  goodPixKey = catalog.getSchema()["goodpix"];
103  } catch (pex::exceptions::NotFoundError &) {
104  }
106  items.reserve(catalog.size());
107  for (afw::table::ExposureCatalog::const_iterator i = catalog.begin(); i != catalog.end(); ++i) {
108  geom::Point2D p = coaddWcs.skyToPixel(i->getWcs()->pixelToSky(i->getPsf()->getAveragePosition()));
109  AvgPosItem item(p.getX(), p.getY(), i->get(weightKey));
110  if (goodPixKey.isValid()) {
111  item.w *= i->get(goodPixKey);
112  }
113  item.wx *= item.w;
114  item.wy *= item.w;
115  items.push_back(item);
116  }
117  // This is a bit pessimistic - we save and sort all the weights all the time,
118  // even though we'll only need them if the average position from all of them
119  // is invalid. But it makes for simpler code, and it's not that expensive
120  // computationally anyhow.
121  std::sort(items.begin(), items.end());
122  AvgPosItem result = std::accumulate(items.begin(), items.end(), AvgPosItem());
123  // If the position isn't valid (no input frames contain it), we remove frames
124  // from the average until it does.
126  catalog.subsetContaining(result.getPoint(), coaddWcs, true).empty(); ++iter) {
127  if (iter == items.end()) {
128  // This should only happen if there are no inputs at all,
129  // or if constituent Psfs have a badly-behaved implementation
130  // of getAveragePosition().
131  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
132  "Could not find a valid average position for CoaddPsf");
133  }
134  result -= *iter;
135  }
136  return result.getPoint();
137 }
138 
139 } // namespace
140 
141 CoaddPsf::CoaddPsf(afw::table::ExposureCatalog const &catalog, afw::geom::SkyWcs const &coaddWcs,
142  std::string const &weightFieldName, std::string const &warpingKernelName, int cacheSize)
143  : _coaddWcs(coaddWcs),
144  _warpingKernelName(warpingKernelName),
145  _warpingControl(std::make_shared<afw::math::WarpingControl>(warpingKernelName, "", cacheSize)) {
146  afw::table::SchemaMapper mapper(catalog.getSchema());
147  mapper.addMinimalSchema(afw::table::ExposureTable::makeMinimalSchema(), true);
148 
149  // copy the field "goodpix", if available, for computeAveragePosition to use
150  try {
151  afw::table::Key<int> goodPixKey = catalog.getSchema()["goodpix"]; // auto does not work
152  mapper.addMapping(goodPixKey, true);
153  } catch (pex::exceptions::NotFoundError &) {
154  }
155 
156  // copy the field specified by weightFieldName to field "weight"
157  afw::table::Field<double> weightField = afw::table::Field<double>("weight", "Coadd weight");
158  afw::table::Key<double> weightKey = catalog.getSchema()[weightFieldName];
159  _weightKey = mapper.addMapping(weightKey, weightField);
160 
161  _catalog = afw::table::ExposureCatalog(mapper.getOutputSchema());
162  for (afw::table::ExposureCatalog::const_iterator i = catalog.begin(); i != catalog.end(); ++i) {
163  PTR(afw::table::ExposureRecord) record = _catalog.getTable()->makeRecord();
164  record->assign(*i, mapper);
165  _catalog.push_back(record);
166  }
167  _averagePosition = computeAveragePosition(_catalog, _coaddWcs, _weightKey);
168 }
169 
170 PTR(afw::detection::Psf) CoaddPsf::clone() const { return std::make_shared<CoaddPsf>(*this); }
171 
172 PTR(afw::detection::Psf) CoaddPsf::resized(int width, int height) const {
173  // Not implemented for WarpedPsf
174  throw LSST_EXCEPT(pex::exceptions::LogicError, "Not Implemented");
175 }
176 
177 // Read all the images from the Image Vector and return the BBox in xy0 offset coordinates
178 
181  // Calculate the box which will contain them all
182  for (unsigned int i = 0; i < imgVector.size(); i++) {
183  PTR(afw::image::Image<double>) componentImg = imgVector[i];
184  geom::Box2I cBBox = componentImg->getBBox();
185  bbox.include(cBBox); // JFB: this works even on empty bboxes
186  }
187  return bbox;
188 }
189 
190 // Read all the images from the Image Vector and add them to image
191 
193  std::vector<PTR(afw::image::Image<double>)> const &imgVector,
194  std::vector<double> const &weightVector) {
195  assert(imgVector.size() == weightVector.size());
196  for (unsigned int i = 0; i < imgVector.size(); i++) {
197  PTR(afw::image::Image<double>) componentImg = imgVector[i];
198  double weight = weightVector[i];
199  double sum = ndarray::asEigenMatrix(componentImg->getArray()).sum();
200 
201  // Now get the portion of the component image which is appropriate to add
202  // If the default image size is used, the component is guaranteed to fit,
203  // but not if a size has been specified.
204  geom::Box2I cBBox = componentImg->getBBox();
205  geom::Box2I overlap(cBBox);
206  overlap.clip(image->getBBox());
207  // JFB: A subimage view of the image we want to add to, containing only the overlap region.
208  afw::image::Image<double> targetSubImage(*image, overlap);
209  // JFB: A subimage view of the image we want to add from, containing only the overlap region.
210  afw::image::Image<double> cSubImage(*componentImg, overlap);
211  targetSubImage.scaledPlus(weight / sum, cSubImage);
212  }
213 }
214 
216  afw::table::ExposureCatalog subcat = _catalog.subsetContaining(ccdXY, _coaddWcs, true);
217  if (subcat.empty()) {
218  throw LSST_EXCEPT(
220  (boost::format("Cannot compute BBox at point %s; no input images at that point.") % ccdXY)
221  .str());
222  }
223 
224  geom::Box2I ret;
225  for (auto const &exposureRecord : subcat) {
226  // compute transform from exposure pixels to coadd pixels
227  auto exposureToCoadd = afw::geom::makeWcsPairTransform(*exposureRecord.getWcs(), _coaddWcs);
228  WarpedPsf warpedPsf = WarpedPsf(exposureRecord.getPsf(), exposureToCoadd, _warpingControl);
229  geom::Box2I componentBBox = warpedPsf.computeBBox(ccdXY, color);
230  ret.include(componentBBox);
231  }
232 
233  return ret;
234 }
235 
237 CoaddPsf::doComputeKernelImage(geom::Point2D const &ccdXY, afw::image::Color const &color) const {
238  // Get the subset of expoures which contain our coordinate within their validPolygons.
239  afw::table::ExposureCatalog subcat = _catalog.subsetContaining(ccdXY, _coaddWcs, true);
240  if (subcat.empty()) {
241  throw LSST_EXCEPT(
243  (boost::format("Cannot compute CoaddPsf at point %s; no input images at that point.") % ccdXY)
244  .str());
245  }
246  double weightSum = 0.0;
247 
248  // Read all the Psf images into a vector. The code is set up so that this can be done in chunks,
249  // with the image modified to accomodate
250  // However, we currently read all of the images.
252  std::vector<double> weightVector;
253 
254  for (auto const &exposureRecord : subcat) {
255  // compute transform from exposure pixels to coadd pixels
256  auto exposureToCoadd = afw::geom::makeWcsPairTransform(*exposureRecord.getWcs(), _coaddWcs);
257  PTR(afw::image::Image<double>) componentImg;
258  try {
259  WarpedPsf warpedPsf = WarpedPsf(exposureRecord.getPsf(), exposureToCoadd, _warpingControl);
260  componentImg = warpedPsf.computeKernelImage(ccdXY, color);
261  } catch (pex::exceptions::RangeError &exc) {
262  LSST_EXCEPT_ADD(exc, (boost::format("Computing WarpedPsf kernel image for id=%d") %
263  exposureRecord.getId())
264  .str());
265  throw exc;
266  }
267  imgVector.push_back(componentImg);
268  weightSum += exposureRecord.get(_weightKey);
269  weightVector.push_back(exposureRecord.get(_weightKey));
270  }
271 
272  geom::Box2I bbox = getOverallBBox(imgVector);
273 
274  // create a zero image of the right size to sum into
275  PTR(afw::detection::Psf::Image) image = std::make_shared<afw::detection::Psf::Image>(bbox);
276  *image = 0.0;
277  addToImage(image, imgVector, weightVector);
278  *image /= weightSum;
279  return image;
280 }
281 
282 int CoaddPsf::getComponentCount() const { return _catalog.size(); }
283 
285  if (index < 0 || index >= getComponentCount()) {
286  throw LSST_EXCEPT(pex::exceptions::RangeError, "index of CoaddPsf component out of range");
287  }
288  return _catalog[index].getPsf();
289 }
290 
292  if (index < 0 || index >= getComponentCount()) {
293  throw LSST_EXCEPT(pex::exceptions::RangeError, "index of CoaddPsf component out of range");
294  }
295  return *_catalog[index].getWcs();
296 }
297 
299  if (index < 0 || index >= getComponentCount()) {
300  throw LSST_EXCEPT(pex::exceptions::RangeError, "index of CoaddPsf component out of range");
301  }
302  return _catalog[index].getValidPolygon();
303 }
304 
305 double CoaddPsf::getWeight(int index) {
306  if (index < 0 || index >= getComponentCount()) {
307  throw LSST_EXCEPT(pex::exceptions::RangeError, "index of CoaddPsf component out of range");
308  }
309  return _catalog[index].get(_weightKey);
310 }
311 
313  if (index < 0 || index >= getComponentCount()) {
314  throw LSST_EXCEPT(pex::exceptions::RangeError, "index of CoaddPsf component out of range");
315  }
316  return _catalog[index].getId();
317 }
318 
320  if (index < 0 || index >= getComponentCount()) {
321  throw LSST_EXCEPT(pex::exceptions::RangeError, "index of CoaddPsf component out of range");
322  }
323  return _catalog[index].getBBox();
324 }
325 
326 // ---------- Persistence -----------------------------------------------------------------------------------
327 
328 // For persistence of CoaddPsf, we have two catalogs: the first has just one record, and contains
329 // the archive ID of the coadd WCS, the size of the warping cache, the name of the warping kernel,
330 // and the average position. The latter is simply the ExposureCatalog.
331 
332 namespace {
333 
334 // Singleton class that manages the first persistence catalog's schema and keys
335 class CoaddPsfPersistenceHelper {
336 public:
337  afw::table::Schema schema;
338  afw::table::Key<int> coaddWcs;
339  afw::table::Key<int> cacheSize;
340  afw::table::PointKey<double> averagePosition;
341  afw::table::Key<std::string> warpingKernelName;
342 
343  static CoaddPsfPersistenceHelper const &get() {
344  static CoaddPsfPersistenceHelper const instance;
345  return instance;
346  }
347 
348 private:
349  CoaddPsfPersistenceHelper()
350  : schema(),
351  coaddWcs(schema.addField<int>("coaddwcs", "archive ID of the coadd's WCS")),
352  cacheSize(schema.addField<int>("cachesize", "size of the warping cache")),
353  averagePosition(afw::table::PointKey<double>::addFields(
354  schema, "avgpos", "PSF accessors default position", "pixel")),
356  schema.addField<std::string>("warpingkernelname", "warping kernel name", 32)) {}
357 };
358 
359 } // namespace
360 
362 public:
364  read(InputArchive const &archive, CatalogVector const &catalogs) const {
365  if (catalogs.size() == 1u) {
366  // Old CoaddPsfs were saved in only one catalog, because we didn't
367  // save the warping parameters and average position, and we could
368  // save the coadd Wcs in a special final record.
369  return readV0(archive, catalogs);
370  }
371  LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
372  CoaddPsfPersistenceHelper const &keys1 = CoaddPsfPersistenceHelper::get();
373  LSST_ARCHIVE_ASSERT(catalogs.front().getSchema() == keys1.schema);
374  afw::table::BaseRecord const &record1 = catalogs.front().front();
375  return PTR(CoaddPsf)(
376  new CoaddPsf(afw::table::ExposureCatalog::readFromArchive(archive, catalogs.back()),
377  *archive.get<afw::geom::SkyWcs>(record1.get(keys1.coaddWcs)),
378  record1.get(keys1.averagePosition), record1.get(keys1.warpingKernelName),
379  record1.get(keys1.cacheSize)));
380  }
381 
382  // Backwards compatibility for files saved before meas_algorithms commit
383  // 53e61fae (7/10/2013). Prior to that change, the warping configuration
384  // and the average position were not saved at all, making it impossible to
385  // reconstruct the average position exactly, but it's better to
386  // approximate than to fail completely.
388  CatalogVector const &catalogs) const {
389  auto internalCat = afw::table::ExposureCatalog::readFromArchive(archive, catalogs.front());
390  // Coadd WCS is stored in a special last record.
391  auto coaddWcs = internalCat.back().getWcs();
392  internalCat.pop_back();
393  // Attempt to reconstruct the average position. We can't do this
394  // exactly, since the catalog we saved isn't the same one that was
395  // used to compute the original average position.
396  afw::table::Key<double> weightKey;
397  try {
398  weightKey = internalCat.getSchema()["weight"];
399  } catch (pex::exceptions::NotFoundError &) {
400  }
401  auto averagePos = computeAveragePosition(internalCat, *coaddWcs, weightKey);
402  return std::shared_ptr<CoaddPsf>(new CoaddPsf(internalCat, *coaddWcs, averagePos));
403  }
404 
405  Factory(std::string const &name) : afw::table::io::PersistableFactory(name) {}
406 };
407 
408 namespace {
409 
410 std::string getCoaddPsfPersistenceName() { return "CoaddPsf"; }
411 
412 CoaddPsf::Factory registration(getCoaddPsfPersistenceName());
413 
414 } // namespace
415 
416 std::string CoaddPsf::getPersistenceName() const { return getCoaddPsfPersistenceName(); }
417 
418 std::string CoaddPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
419 
421  CoaddPsfPersistenceHelper const &keys1 = CoaddPsfPersistenceHelper::get();
422  afw::table::BaseCatalog cat1 = handle.makeCatalog(keys1.schema);
423  PTR(afw::table::BaseRecord) record1 = cat1.addNew();
424  auto coaddWcsPtr = std::make_shared<afw::geom::SkyWcs>(_coaddWcs);
425  record1->set(keys1.coaddWcs, handle.put(coaddWcsPtr));
426  record1->set(keys1.cacheSize, _warpingControl->getCacheSize());
427  record1->set(keys1.averagePosition, _averagePosition);
428  record1->set(keys1.warpingKernelName, _warpingKernelName);
429  handle.saveCatalog(cat1);
430  _catalog.writeToArchive(handle, false);
431 }
432 
435  : _catalog(catalog),
436  _coaddWcs(coaddWcs),
437  _weightKey(_catalog.getSchema()["weight"]),
438  _averagePosition(averagePosition),
439  _warpingKernelName(warpingKernelName),
440  _warpingControl(new afw::math::WarpingControl(warpingKernelName, "", cacheSize)) {}
441 
442 } // namespace algorithms
443 } // namespace meas
444 } // namespace lsst
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::meas::algorithms::CoaddPsf::resized
boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const override
Return a clone with specified kernel dimensions.
Definition: CoaddPsf.cc:172
wy
double wy
Definition: CoaddPsf.cc:68
Persistable.cc
lsst::afw::table::ExposureTable::makeMinimalSchema
static Schema makeMinimalSchema()
Return a minimal schema for Exposure tables and records.
Definition: Exposure.h:216
std::string
STL class.
std::shared_ptr
STL class.
wx
double wx
Definition: CoaddPsf.cc:67
lsst::afw::table::BaseRecord::get
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
lsst::meas::algorithms::CoaddPsf::getWcs
afw::geom::SkyWcs getWcs(int index)
Get the Wcs of the component image at index.
Definition: CoaddPsf.cc:291
lsst::afw::table::io::OutputArchiveHandle
An object passed to Persistable::write to allow it to persist itself.
Definition: OutputArchive.h:118
CoaddPsf.h
cacheSize
afw::table::Key< int > cacheSize
Definition: CoaddPsf.cc:339
std::vector
STL class.
std::vector::size
T size(T... args)
lsst::meas::algorithms::CoaddPsf::clone
boost::shared_ptr< afw::detection::Psf > clone() const override
Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.
Definition: CoaddPsf.cc:170
lsst.pex::exceptions::NotFoundError
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151
lsst.pex::exceptions::RangeError
Reports when the result of an operation cannot be represented by the destination type.
Definition: Runtime.h:115
LSST_EXCEPT_ADD
#define LSST_EXCEPT_ADD(e, m)
Add the current location and a message to an existing exception before rethrowing it.
Definition: Exception.h:54
lsst::afw::table::io::OutputArchiveHandle::saveCatalog
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
Definition: OutputArchive.cc:211
lsst::afw::table::ExposureCatalogT
Custom catalog class for ExposureRecord/Table.
Definition: Exposure.h:311
lsst::meas::algorithms::CoaddPsf::CoaddPsf
CoaddPsf(afw::table::ExposureCatalog const &catalog, afw::geom::SkyWcs const &coaddWcs, std::string const &weightFieldName="weight", std::string const &warpingKernelName="lanczos3", int cacheSize=10000)
Main constructors for CoaddPsf.
Definition: CoaddPsf.cc:141
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::table::io::InputArchive
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:31
exceptions.h
averagePosition
afw::table::PointKey< double > averagePosition
Definition: CoaddPsf.cc:340
CatalogVector.h
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::geom::SkyWcs
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
lsst::afw::table::ExposureCatalogT::readFromArchive
static ExposureCatalogT readFromArchive(io::InputArchive const &archive, BaseCatalog const &catalog)
Convenience input function for Persistables that contain an ExposureCatalog.
Definition: Exposure.cc:456
lsst::meas::algorithms::CoaddPsf::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: CoaddPsf.cc:420
std::vector::front
T front(T... args)
std::sort
T sort(T... args)
warpingKernelName
afw::table::Key< std::string > warpingKernelName
Definition: CoaddPsf.cc:341
lsst::afw::image::Image::scaledPlus
void scaledPlus(double const c, Image< PixelT > const &rhs)
Add Image c*rhs to lhs.
Definition: Image.cc:494
std::vector::push_back
T push_back(T... args)
lsst::afw::table::io::OutputArchiveHandle::makeCatalog
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
Definition: OutputArchive.cc:207
lsst::meas::algorithms::CoaddPsf::getPythonModule
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition: CoaddPsf.cc:418
lsst::meas::algorithms::getOverallBBox
geom::Box2I getOverallBBox(std::vector< boost::shared_ptr< afw::image::Image< double > >> const &imgVector)
Definition: CoaddPsf.cc:179
lsst::afw::geom::polygon::Polygon
Cartesian polygons.
Definition: Polygon.h:59
LSST_ARCHIVE_ASSERT
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:48
image
afw::table::Key< afw::table::Array< ImagePixelT > > image
Definition: HeavyFootprint.cc:216
lsst::afw::table::ExposureCatalogT::const_iterator
Base::const_iterator const_iterator
Definition: Exposure.h:319
lsst::meas::algorithms::CoaddPsf::Factory::readV0
std::shared_ptr< afw::table::io::Persistable > readV0(InputArchive const &archive, CatalogVector const &catalogs) const
Definition: CoaddPsf.cc:387
lsst::meas::algorithms::CoaddPsf::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: CoaddPsf.cc:416
lsst::geom::Box2I::include
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Definition: Box.cc:152
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::BaseRecord
Base class for all records.
Definition: BaseRecord.h:31
lsst.pex::exceptions::LogicError
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
lsst::afw::table::SchemaMapper
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
lsst::afw::table::io::CatalogVector
A vector of catalogs used by Persistable.
Definition: CatalogVector.h:29
lsst::afw::image::operator-
std::shared_ptr< Image< PixelT > > operator-(Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
Overload operator-()
Definition: ImageSlice.cc:89
lsst::afw::table::Key< int >
lsst::meas::algorithms::addToImage
void addToImage(boost::shared_ptr< afw::image::Image< double > > image, std::vector< boost::shared_ptr< afw::image::Image< double > >> const &imgVector, std::vector< double > const &weightVector)
Definition: CoaddPsf.cc:192
lsst::afw::table::CatalogIterator
Iterator class for CatalogT.
Definition: Catalog.h:39
lsst.pipe.tasks.cli.cmd.commands.str
str
Definition: commands.py:50
lsst::afw::table::io::PersistableFactory
A base class for factory classes used to reconstruct objects from records.
Definition: Persistable.h:228
schema
afw::table::Schema schema
Definition: CoaddPsf.cc:337
std::accumulate
T accumulate(T... args)
PTR
#define PTR(...)
Definition: base.h:41
std::int64_t
lsst::meas::algorithms::CoaddPsf::getBBox
geom::Box2I getBBox(int index)
Get the bounding box (in component image Pixel coordinates) of the component image at index.
Definition: CoaddPsf.cc:319
lsst::meas::algorithms::WarpedPsf
A Psf class that maps an arbitrary Psf through a coordinate transformation.
Definition: WarpedPsf.h:50
lsst::afw::image::operator-=
Image< LhsPixelT > & operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different.
Definition: Image.cc:671
result
py::object result
Definition: _schema.cc:429
weight
afw::table::Key< double > weight
Definition: CoaddBoundedField.cc:166
b
table::Key< int > b
Definition: TransmissionCurve.cc:467
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
coaddWcs
afw::table::Key< int > coaddWcs
Definition: CoaddPsf.cc:338
lsst::geom
Definition: AffineTransform.h:36
lsst::afw::table::io::Persistable
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
lsst::meas::algorithms::CoaddPsf::getId
afw::table::RecordId getId(int index)
Get the exposure ID of the component image at index.
Definition: CoaddPsf.cc:312
base.h
Basic LSST definitions.
lsst::meas::algorithms::CoaddPsf::getValidPolygon
boost::shared_ptr< afw::geom::polygon::Polygon const > getValidPolygon(int index)
Get the validPolygon (in component image Pixel coordinates) of the component image at index.
Definition: CoaddPsf.cc:298
items
std::vector< SchemaItem< Flag > > * items
Definition: BaseColumnView.cc:142
lsst::afw::table::Field
A description of a field in a table.
Definition: Field.h:24
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::geom::Box2I::clip
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*this).
Definition: Box.cc:189
lsst::meas::algorithms::CoaddPsf::getPsf
boost::shared_ptr< afw::detection::Psf const > getPsf(int index)
Get the Psf of the component image at index.
Definition: CoaddPsf.cc:284
lsst::afw::image.slicing.Factory
Factory
Definition: slicing.py:252
lsst::meas::algorithms::CoaddPsf
CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
Definition: CoaddPsf.h:58
lsst::afw::table::io::PersistableFacade::dynamicCast
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18
lsst::afw::geom::makeWcsPairTransform
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
Definition: SkyWcs.cc:151
a
table::Key< int > a
Definition: TransmissionCurve.cc:466
Statistics.h
lsst::afw::image::operator+
std::shared_ptr< Image< PixelT > > operator+(Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
Overload operator+()
Definition: ImageSlice.cc:69
lsst::afw::detection::Psf::computeBBox
lsst::geom::Box2I computeBBox(lsst::geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Return the bounding box of the image returned by computeKernelImage()
Definition: Psf.cc:128
std
STL namespace.
lsst::geom::Point< double, 2 >
lsst::afw::table::ExposureCatalogT::subsetContaining
ExposureCatalogT subsetContaining(lsst::geom::SpherePoint const &coord, bool includeValidPolygon=false) const
Return a shallow subset of the catalog with only those records that contain the given point.
Definition: Exposure.cc:471
lsst::afw::table::ExposureCatalogT::writeToArchive
void writeToArchive(io::OutputArchiveHandle &handle, bool ignoreUnpersistable=true) const
Convenience output function for Persistables that contain an ExposureCatalog.
Definition: Exposure.cc:444
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
mapper
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
lsst::afw::table::ExposureRecord
Record class used to store exposure metadata.
Definition: Exposure.h:79
w
double w
Definition: CoaddPsf.cc:69
InputArchive.h
ImageUtils.h
lsst::meas::algorithms::CoaddPsf::doComputeBBox
geom::Box2I doComputeBBox(geom::Point2D const &position, afw::image::Color const &color) const override
Definition: CoaddPsf.cc:215
lsst::afw::image::operator+=
Image< LhsPixelT > & operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different.
Definition: Image.cc:665
lsst::afw::table::io::OutputArchiveHandle::put
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
Definition: OutputArchive.cc:216
lsst::afw::detection::Psf
A polymorphic base class for representing an image's Point Spread Function.
Definition: Psf.h:76
lsst::afw::table::CatalogT::addNew
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Definition: Catalog.h:485
lsst::afw::table::ExposureCatalog
ExposureCatalogT< ExposureRecord > ExposureCatalog
Definition: Exposure.h:489
lsst::afw::image::Image
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
lsst::meas::algorithms::CoaddPsf::getComponentCount
int getComponentCount() const
Return the number of component Psfs in this CoaddPsf.
Definition: CoaddPsf.cc:282
lsst::afw::detection::Psf::computeKernelImage
std::shared_ptr< Image > computeKernelImage(lsst::geom::Point2D position=makeNullPoint(), image::Color color=image::Color(), ImageOwnerEnum owner=COPY) const
Return an Image of the PSF, in a form suitable for convolution.
Definition: Psf.cc:115
lsst::afw::table::CatalogT< BaseRecord >
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88
Box.h
CONST_PTR
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
OutputArchive.h
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::meas::algorithms::CoaddPsf::Factory::Factory
Factory(std::string const &name)
Definition: CoaddPsf.cc:405
lsst::afw::image::Color
Describe the colour of a source.
Definition: Color.h:26
WarpedPsf.h
lsst::meas::algorithms::CoaddPsf::getWeight
double getWeight(int index)
Get the weight of the component image at index.
Definition: CoaddPsf.cc:305