LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
Mask.cc
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2
3/*
4 * LSST Data Management System
5 * Copyright 2008-2016 AURA/LSST.
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 * The fundamental type defined here is Mask; a 2-d array of pixels. Each of
27 * these pixels should be thought of as a set of bits, and the names of these
28 * bits are given by MaskPlaneDict (which is implemented as a std::map)
29 */
30
31#include <functional>
32#include <list>
33#include <string>
34#include "boost/format.hpp"
35
36#include "lsst/daf/base.h"
37#include "lsst/geom.h"
38#include "lsst/pex/exceptions.h"
39#include "lsst/log/Log.h"
40#include "lsst/afw/image/Mask.h"
44
45namespace dafBase = lsst::daf::base;
47
48namespace lsst {
49namespace afw {
50namespace image {
51
52namespace {} // namespace
53
54template <typename MaskPixelT>
55void Mask<MaskPixelT>::_initializePlanes(MaskPlaneDict const& planeDefs) {
56 LOGL_DEBUG("lsst.afw.image.Mask", "Number of mask planes: %d", getNumPlanesMax());
57
58 _maskDict = detail::MaskDict::copyOrGetDefault(planeDefs);
59}
60
61template <typename MaskPixelT>
62Mask<MaskPixelT>::Mask(unsigned int width, unsigned int height, MaskPlaneDict const& planeDefs)
63 : ImageBase<MaskPixelT>(lsst::geom::ExtentI(width, height)) {
64 _initializePlanes(planeDefs);
65 *this = 0x0;
66}
67
68template <typename MaskPixelT>
69Mask<MaskPixelT>::Mask(unsigned int width, unsigned int height, MaskPixelT initialValue,
70 MaskPlaneDict const& planeDefs)
71 : ImageBase<MaskPixelT>(lsst::geom::ExtentI(width, height)) {
72 _initializePlanes(planeDefs);
73 *this = initialValue;
74}
75
76template <typename MaskPixelT>
78 : ImageBase<MaskPixelT>(dimensions) {
79 _initializePlanes(planeDefs);
80 *this = 0x0;
81}
82
83template <typename MaskPixelT>
85 MaskPlaneDict const& planeDefs)
86 : ImageBase<MaskPixelT>(dimensions) {
87 _initializePlanes(planeDefs);
88 *this = initialValue;
89}
90
91template <typename MaskPixelT>
93 : ImageBase<MaskPixelT>(bbox) {
94 _initializePlanes(planeDefs);
95 *this = 0x0;
96}
97
98template <typename MaskPixelT>
99Mask<MaskPixelT>::Mask(lsst::geom::Box2I const& bbox, MaskPixelT initialValue, MaskPlaneDict const& planeDefs)
100 : ImageBase<MaskPixelT>(bbox) {
101 _initializePlanes(planeDefs);
102 *this = initialValue;
103}
104
105template <typename MaskPixelT>
107 bool const deep)
108 : ImageBase<MaskPixelT>(rhs, bbox, origin, deep), _maskDict(rhs._maskDict) {}
109
110template <typename MaskPixelT>
111Mask<MaskPixelT>::Mask(Mask const& rhs, bool deep)
112 : ImageBase<MaskPixelT>(rhs, deep), _maskDict(rhs._maskDict) {}
113// Delegate to copy-constructor for backwards compatibility
114template <typename MaskPixelT>
115Mask<MaskPixelT>::Mask(Mask&& rhs) : Mask(rhs, false) {}
116
117template <typename MaskPixelT>
118Mask<MaskPixelT>::~Mask() = default;
119
120template <typename MaskPixelT>
121Mask<MaskPixelT>::Mask(ndarray::Array<MaskPixelT, 2, 1> const& array, bool deep,
122 lsst::geom::Point2I const& xy0)
123 : image::ImageBase<MaskPixelT>(array, deep, xy0), _maskDict(detail::MaskDict::getDefault()) {}
125template <typename PixelT>
127 using std::swap; // See Meyers, Effective C++, Item 25
128
130 swap(_maskDict, rhs._maskDict);
131}
133template <typename PixelT>
135 a.swap(b);
136}
137
138template <typename MaskPixelT>
140 Mask tmp(rhs);
141 swap(tmp); // See Meyers, Effective C++, Item 11
142
143 return *this;
144}
145// Delegate to copy-assignment for backwards compatibility
146template <typename MaskPixelT>
148 return *this = rhs;
149}
150
151template <typename MaskPixelT>
153 fill_pixels(_getRawView(), rhs);
154
155 return *this;
156}
157
158#ifndef DOXYGEN // doc for this section is already in header
159
160template <typename MaskPixelT>
162 lsst::geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks, bool allowUnsafe)
163 : ImageBase<MaskPixelT>(), _maskDict(detail::MaskDict::getDefault()) {
164 MaskFitsReader reader(fileName, hdu);
165 *this = reader.read<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
166 if (metadata) {
167 metadata->combine(*reader.readMetadata());
168 }
169}
170
171template <typename MaskPixelT>
172Mask<MaskPixelT>::Mask(fits::MemFileManager& manager, int hdu,
174 ImageOrigin origin, bool conformMasks, bool allowUnsafe)
175 : ImageBase<MaskPixelT>(), _maskDict(detail::MaskDict::getDefault()) {
176 MaskFitsReader reader(manager, hdu);
177 *this = reader.read<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
178 if (metadata) {
179 metadata->combine(*reader.readMetadata());
180 }
181}
182
183template <typename MaskPixelT>
185 lsst::geom::Box2I const& bbox, ImageOrigin const origin, bool const conformMasks,
186 bool allowUnsafe)
187 : ImageBase<MaskPixelT>(), _maskDict(detail::MaskDict::getDefault()) {
188 MaskFitsReader reader(&fitsFile);
189 *this = reader.read<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
190 if (metadata) {
191 metadata->combine(*reader.readMetadata());
192 }
193}
194
195template <typename MaskPixelT>
196void Mask<MaskPixelT>::writeFits(std::string const& fileName,
197 daf::base::PropertySet const * metadata_i,
198 std::string const& mode) const {
199 fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
200 writeFits(fitsfile, metadata_i);
201}
202
203template <typename MaskPixelT>
204void Mask<MaskPixelT>::writeFits(std::string const& fileName,
206 std::string const& mode) const {
207 writeFits(fileName, metadata_i.get(), mode);
208}
209
210template <typename MaskPixelT>
211void Mask<MaskPixelT>::writeFits(fits::MemFileManager& manager,
212 daf::base::PropertySet const * metadata_i,
213 std::string const& mode) const {
214 fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
215 writeFits(fitsfile, metadata_i);
216}
217
218template <typename MaskPixelT>
219void Mask<MaskPixelT>::writeFits(fits::MemFileManager& manager,
221 std::string const& mode) const {
222 writeFits(manager, metadata_i.get(), mode);
223}
224
225template <typename MaskPixelT>
226void Mask<MaskPixelT>::writeFits(fits::Fits& fitsfile,
227 daf::base::PropertySet const * metadata) const {
228 writeFits(fitsfile, fits::ImageWriteOptions(*this), metadata);
231template <typename MaskPixelT>
234 writeFits(fitsfile, metadata.get());
235}
236
237template <typename MaskPixelT>
238void Mask<MaskPixelT>::writeFits(std::string const& filename, fits::ImageWriteOptions const& options,
239 std::string const& mode,
240 daf::base::PropertySet const * header) const {
241 fits::Fits fitsfile(filename, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
242 writeFits(fitsfile, options, header);
244
245template <typename MaskPixelT>
247 std::string const& mode,
249 writeFits(filename, options, mode, header.get());
252template <typename MaskPixelT>
254 std::string const& mode,
255 daf::base::PropertySet const * header) const {
257 writeFits(fitsfile, options, header);
258}
260template <typename MaskPixelT>
262 std::string const& mode,
264 writeFits(manager, options, mode, header.get());
265}
266
267template <typename MaskPixelT>
269 daf::base::PropertySet const * header) const {
271 header ? header->deepCopy() : std::make_shared<dafBase::PropertySet>();
272 addMaskPlanesToMetadata(useHeader);
273 fitsfile.writeImage(*this, options, useHeader.get());
274}
275
276template <typename MaskPixelT>
279 writeFits(fitsfile, options, header.get());
280}
281
282#endif // !DOXYGEN
283
284template <typename MaskPixelT>
286 std::string result = "";
287 MaskPlaneDict const& mpd = _maskPlaneDict()->getMaskPlaneDict();
288 for (auto const &iter : mpd) {
289 if (value & getBitMask(iter.second)) {
290 if (result.size() > 0) {
291 result += ",";
292 }
293 result += iter.first;
294 }
296 return result;
297}
298
299template <typename MaskPixelT>
301 int id = getMaskPlaneNoThrow(name); // see if the plane is already available
302
303 if (id < 0) { // doesn't exist
304 id = _maskPlaneDict()->getUnusedPlane();
305 }
306
307 // build new entry, adding the plane to all Masks where this is no contradiction
308
309 if (id >= getNumPlanesMax()) { // Max number of planes is already allocated
311 str(boost::format("Max number of planes (%1%) already used") % getNumPlanesMax()));
312 }
313
315
316 return id;
317}
319template <typename MaskPixelT>
321 if (planeId < 0 || planeId >= getNumPlanesMax()) {
322 throw LSST_EXCEPT(
324 str(boost::format("mask plane ID must be between 0 and %1%") % (getNumPlanesMax() - 1)));
325 }
327 _maskPlaneDict()->add(name, planeId);
328
329 return planeId;
330}
331
332template <typename MaskPixelT>
334 return _maskDict->getMaskPlaneDict();
335}
336
337template <typename MaskPixelT>
339 if (detail::MaskDict::getDefault()->getMaskPlane(name) < 0) {
341 str(boost::format("Plane %s doesn't exist in the default Mask") % name));
342 }
343
344 detail::MaskDict::detachDefault(); // leave current Masks alone
345 _maskPlaneDict()->erase(name);
346}
347
348template <typename MaskPixelT>
349void Mask<MaskPixelT>::removeAndClearMaskPlane(const std::string& name, bool const removeFromDefault
350
351) {
352 clearMaskPlane(getMaskPlane(name)); // clear this bits in this Mask
353
354 if (_maskDict == detail::MaskDict::getDefault() && removeFromDefault) { // we are the default
355 ;
356 } else {
357 _maskDict = _maskDict->clone();
358 }
359
360 _maskDict->erase(name);
361
362 if (removeFromDefault && detail::MaskDict::getDefault()->getMaskPlane(name) >= 0) {
363 removeMaskPlane(name);
364 }
365}
366
367template <typename MaskPixelT>
368MaskPixelT Mask<MaskPixelT>::getBitMaskNoThrow(int planeId) {
369 return (planeId >= 0 && planeId < getNumPlanesMax()) ? (1 << planeId) : 0;
370}
371
372template <typename MaskPixelT>
373MaskPixelT Mask<MaskPixelT>::getBitMask(int planeId) {
374 MaskPlaneDict const& mpd = _maskPlaneDict()->getMaskPlaneDict();
375
376 for (auto const &i : mpd) {
377 if (planeId == i.second) {
378 MaskPixelT const bitmask = getBitMaskNoThrow(planeId);
379 if (bitmask == 0) { // failed
380 break;
381 }
382 return bitmask;
383 }
384 }
386 str(boost::format("Invalid mask plane ID: %d") % planeId));
387}
388
389template <typename MaskPixelT>
391 int const plane = getMaskPlaneNoThrow(name);
392
393 if (plane < 0) {
395 str(boost::format("Invalid mask plane name: %s") % name));
396 } else {
397 return plane;
398 }
399}
400
401template <typename MaskPixelT>
403 return _maskPlaneDict()->getMaskPlane(name);
404}
405
406template <typename MaskPixelT>
408 return getBitMask(getMaskPlane(name));
409}
410
411template <typename MaskPixelT>
413 MaskPixelT mpix = 0x0;
414 for (auto const &it : name) {
415 mpix |= getBitMask(getMaskPlane(it));
416 }
417 return mpix;
418}
419
420template <typename MaskPixelT>
422 return _maskPlaneDict()->size();
423}
424
425template <typename MaskPixelT>
427 _maskPlaneDict()->clear();
428}
429
430template <typename MaskPixelT>
432 *this = 0;
433}
434
435template <typename MaskPixelT>
437 *this &= ~getBitMask(planeId);
438}
439
440template <typename MaskPixelT>
443
444 if (*_maskDict == *currentMD) {
445 if (*detail::MaskDict::getDefault() == *_maskDict) {
446 return; // nothing to do
447 }
448 } else {
449 //
450 // Find out which planes need to be permuted
451 //
452 MaskPixelT keepBitmask = 0; // mask of bits to keep
453 MaskPixelT canonicalMask[sizeof(MaskPixelT) * 8]; // bits in lsst::afw::image::Mask that should be
454 MaskPixelT currentMask[sizeof(MaskPixelT) * 8]; // mapped to these bits
455 int numReMap = 0;
456
457 for (auto const &i : currentPlaneDict) {
458 std::string const name = i.first; // name of mask plane
459 int const currentPlaneNumber = i.second; // plane number currently in use
460 int canonicalPlaneNumber = getMaskPlaneNoThrow(name); // plane number in lsst::afw::image::Mask
461
462 if (canonicalPlaneNumber < 0) { // no such plane; add it
463 canonicalPlaneNumber = addMaskPlane(name);
464 }
465
466 if (canonicalPlaneNumber == currentPlaneNumber) {
467 keepBitmask |= getBitMask(canonicalPlaneNumber); // bit is unchanged, so preserve it
468 } else {
469 canonicalMask[numReMap] = getBitMask(canonicalPlaneNumber);
470 currentMask[numReMap] = getBitMaskNoThrow(currentPlaneNumber);
471 numReMap++;
472 }
473 }
474
475 // Now loop over all pixels in Mask
476 if (numReMap > 0) {
477 for (int r = 0; r != this->getHeight(); ++r) { // "this->": Meyers, Effective C++, Item 43
478 for (typename Mask::x_iterator ptr = this->row_begin(r), end = this->row_end(r); ptr != end;
479 ++ptr) {
480 MaskPixelT const pixel = *ptr;
482 MaskPixelT newPixel = pixel & keepBitmask; // value of invariant mask bits
483 for (int i = 0; i < numReMap; i++) {
484 if (pixel & currentMask[i]) newPixel |= canonicalMask[i];
485 }
486
487 *ptr = newPixel;
489 }
490 }
491 }
492 // We've made the planes match the current mask dictionary
496template <typename MaskPixelT>
498 return this->ImageBase<MaskPixelT>::operator()(x, y);
499}
500
501template <typename MaskPixelT>
503 CheckIndices const& check) {
504 return this->ImageBase<MaskPixelT>::operator()(x, y, check);
506
507template <typename MaskPixelT>
509 return this->ImageBase<MaskPixelT>::operator()(x, y);
510}
511
512template <typename MaskPixelT>
514 int x, int y, CheckIndices const& check) const {
515 return this->ImageBase<MaskPixelT>::operator()(x, y, check);
516}
517
518template <typename MaskPixelT>
519bool Mask<MaskPixelT>::operator()(int x, int y, int planeId) const {
520 // !! converts an int to a bool
521 return !!(this->ImageBase<MaskPixelT>::operator()(x, y) & getBitMask(planeId));
522}
523
524template <typename MaskPixelT>
525bool Mask<MaskPixelT>::operator()(int x, int y, int planeId, CheckIndices const& check) const {
526 // !! converts an int to a bool
527 return !!(this->ImageBase<MaskPixelT>::operator()(x, y, check) & getBitMask(planeId));
528}
529
530template <typename MaskPixelT>
532 if (*_maskDict != *other._maskDict) {
533 throw LSST_EXCEPT(pexExcept::RuntimeError, "Mask dictionaries do not match");
534 }
535}
536
537template <typename MaskPixelT>
539 transform_pixels(_getRawView(), _getRawView(),
540 [&val](MaskPixelT const& l) -> MaskPixelT { return l | val; });
541 return *this;
542}
543
544template <typename MaskPixelT>
546 checkMaskDictionaries(rhs);
547
548 if (this->getDimensions() != rhs.getDimensions()) {
550 str(boost::format("Images are of different size, %dx%d v %dx%d") %
551 this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()));
552 }
553 transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
554 [](MaskPixelT const& l, MaskPixelT const& r) -> MaskPixelT { return l | r; });
555 return *this;
556}
557
558template <typename MaskPixelT>
560 transform_pixels(_getRawView(), _getRawView(), [&val](MaskPixelT const& l) { return l & val; });
561 return *this;
562}
563
564template <typename MaskPixelT>
566 checkMaskDictionaries(rhs);
567
568 if (this->getDimensions() != rhs.getDimensions()) {
570 str(boost::format("Images are of different size, %dx%d v %dx%d") %
571 this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()));
572 }
573 transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
574 [](MaskPixelT const& l, MaskPixelT const& r) -> MaskPixelT { return l & r; });
575 return *this;
576}
577
578template <typename MaskPixelT>
580 transform_pixels(_getRawView(), _getRawView(),
581 [&val](MaskPixelT const& l) -> MaskPixelT { return l ^ val; });
582 return *this;
583}
584
585template <typename MaskPixelT>
587 checkMaskDictionaries(rhs);
588
589 if (this->getDimensions() != rhs.getDimensions()) {
591 str(boost::format("Images are of different size, %dx%d v %dx%d") %
592 this->getWidth() % this->getHeight() % rhs.getWidth() % rhs.getHeight()));
593 }
594 transform_pixels(_getRawView(), rhs._getRawView(), _getRawView(),
595 [](MaskPixelT const& l, MaskPixelT const& r) -> MaskPixelT { return l ^ r; });
596 return *this;
597}
598
599template <typename MaskPixelT>
600void Mask<MaskPixelT>::setMaskPlaneValues(int const planeId, int const x0, int const x1, int const y) {
601 MaskPixelT const bitMask = getBitMask(planeId);
602
603 for (int x = x0; x <= x1; x++) {
604 operator()(x, y) = operator()(x, y) | bitMask;
605 }
606}
607
608template <typename MaskPixelT>
610 if (!metadata) {
611 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "Null std::shared_ptr<PropertySet>");
612 }
613
614 // First, clear existing MaskPlane metadata
615 using NameList = std::vector<std::string>;
616 NameList paramNames = metadata->paramNames(false);
617 for (auto const &paramName : paramNames) {
618 if (paramName.compare(0, maskPlanePrefix.size(), maskPlanePrefix) == 0) {
619 metadata->remove(paramName);
620 }
621 }
622
623 MaskPlaneDict const& mpd = _maskPlaneDict()->getMaskPlaneDict();
624
625 // Add new MaskPlane metadata
626 for (auto const &i : mpd) {
627 std::string const& planeName = i.first;
628 int const planeNumber = i.second;
629
630 if (planeName != "") {
631 metadata->add(maskPlanePrefix + planeName, planeNumber);
632 }
633 }
634}
635
636template <typename MaskPixelT>
639 MaskPlaneDict newDict;
640
641 // First, clear existing MaskPlane metadata
642 using NameList = std::vector<std::string>;
643 NameList paramNames = metadata->paramNames(false);
644 int numPlanesUsed = 0; // number of planes used
645
646 // Iterate over childless properties with names starting with maskPlanePrefix
647 for (auto const &paramName : paramNames) {
648 if (paramName.compare(0, maskPlanePrefix.size(), maskPlanePrefix) == 0) {
649 // split off maskPlanePrefix to obtain plane name
650 std::string planeName = paramName.substr(maskPlanePrefix.size());
651 int const planeId = metadata->getAsInt(paramName);
652
653 MaskPlaneDict::const_iterator plane = newDict.find(planeName);
654 if (plane != newDict.end() && planeId != plane->second) {
655 throw LSST_EXCEPT(pexExcept::RuntimeError, "File specifies plane " + planeName + " twice");
656 }
657 for (MaskPlaneDict::const_iterator j = newDict.begin(); j != newDict.end(); ++j) {
658 if (planeId == j->second) {
660 str(boost::format("File specifies plane %s has same value (%d) as %s") %
661 planeName % planeId % j->first));
662 }
663 }
664 // build new entry
665 if (numPlanesUsed >= getNumPlanesMax()) {
666 // Max number of planes already allocated
667 throw LSST_EXCEPT(
669 str(boost::format("Max number of planes (%1%) already used") % getNumPlanesMax()));
670 }
671 newDict[planeName] = planeId;
672 }
673 }
674 return newDict;
675}
676
677template <typename MaskPixelT>
679 _maskDict->print();
680}
681
682/*
683 * Static members of Mask
684 */
685template <typename MaskPixelT>
687
688template <typename MaskPixelT>
691}
692
693//
694// Explicit instantiations
695//
696template class Mask<MaskPixel>;
697} // namespace image
698} // namespace afw
699} // namespace lsst
py::object result
Definition: _schema.cc:429
table::Key< std::string > name
Definition: Amplifier.cc:116
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
int end
double x
table::PointKey< int > pixel
table::Key< int > id
Definition: Detector.cc:162
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:48
LSST DM logging module built on log4cxx.
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition: Log.h:515
uint64_t * ptr
Definition: RangeSet.cc:88
int y
Definition: SpanSet.cc:48
table::Key< int > b
table::Key< int > a
T begin(T... args)
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:308
void writeImage(ndarray::Array< T const, N, C > const &array)
Write an ndarray::Array to a FITS image HDU.
Definition: fits.h:498
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:125
A class used to request that array accesses be checked.
Definition: ImageBase.h:74
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: ImageBase.h:102
typename Reference< PixelT >::type PixelReference
A Reference to a PixelT.
Definition: ImageBase.h:117
PixelReference operator()(int x, int y)
Return a reference to the pixel (x, y) in LOCAL coordinates.
Definition: Image.cc:171
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition: ImageBase.h:356
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
typename _view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
_view_t _getRawView() const
Definition: ImageBase.h:465
void swap(ImageBase &rhs)
Definition: Image.cc:233
typename ConstReference< PixelT >::type PixelConstReference
A ConstReference to a PixelT.
Definition: ImageBase.h:119
A FITS reader class for Masks.
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
void swap(Mask &rhs)
Definition: Mask.cc:126
Mask & operator=(MaskPixelT const rhs)
Definition: Mask.cc:152
friend class MaskFitsReader
Definition: Mask.h:552
void printMaskPlanes() const
print the mask plane dictionary to std::cout
Definition: Mask.cc:678
static int getMaskPlane(const std::string &name)
Return the mask plane number corresponding to a plane name.
Definition: Mask.cc:390
static std::string interpret(MaskPixelT value)
Interpret a mask value as a comma-separated list of mask plane names.
Definition: Mask.cc:285
static void removeMaskPlane(const std::string &name)
Definition: Mask.cc:338
void removeAndClearMaskPlane(const std::string &name, bool const removeFromDefault=false)
Clear all pixels of the specified mask and remove the plane from the mask plane dictionary; optionall...
Definition: Mask.cc:349
static void clearMaskPlaneDict()
Reset the maskPlane dictionary.
Definition: Mask.cc:426
void setMaskPlaneValues(const int plane, const int x0, const int x1, const int y)
Set the bit specified by "planeId" for pixels (x0, y) ... (x1, y)
Definition: Mask.cc:600
static void addMaskPlanesToMetadata(std::shared_ptr< lsst::daf::base::PropertySet >)
Given a PropertySet, replace any existing MaskPlane assignments with the current ones.
Definition: Mask.cc:609
ImageBase< MaskPixelT >::PixelReference operator()(int x, int y)
get a reference to the specified pixel
Definition: Mask.cc:497
Mask & operator^=(Mask const &rhs)
XOR a Mask into a Mask.
Definition: Mask.cc:586
static int addMaskPlane(const std::string &name)
Definition: Mask.cc:300
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Definition: Mask.cc:412
Mask(unsigned int width, unsigned int height, MaskPlaneDict const &planeDefs=MaskPlaneDict())
Construct a Mask initialized to 0x0.
Definition: Mask.cc:62
MaskPlaneDict const & getMaskPlaneDict() const
Return the Mask's maskPlaneDict.
Definition: Mask.cc:333
void conformMaskPlanes(const MaskPlaneDict &masterPlaneDict)
Adjust this mask to conform to the standard Mask class's mask plane dictionary, adding any new mask p...
Definition: Mask.cc:441
Mask & operator|=(Mask const &rhs)
OR a Mask into a Mask.
Definition: Mask.cc:545
static MaskPlaneDict parseMaskPlaneMetadata(std::shared_ptr< lsst::daf::base::PropertySet const > metadata)
Given a PropertySet that contains the MaskPlane assignments, setup the MaskPlanes.
Definition: Mask.cc:637
void clearAllMaskPlanes()
Clear all the pixels.
Definition: Mask.cc:431
static int getNumPlanesUsed()
Definition: Mask.cc:421
void clearMaskPlane(int plane)
Clear the specified bit in all pixels.
Definition: Mask.cc:436
void writeFits(std::string const &fileName, daf::base::PropertySet const *metadata=nullptr, std::string const &mode="w") const
Write a mask to a regular FITS file.
Mask & operator&=(Mask const &rhs)
AND a Mask into a Mask.
Definition: Mask.cc:565
static void addAllMasksPlane(std::string const &name, int bitId)
Definition: MaskDict.cc:127
static std::shared_ptr< MaskDict > detachDefault()
Definition: MaskDict.cc:123
static std::shared_ptr< MaskDict > getDefault()
Definition: MaskDict.cc:115
static std::shared_ptr< MaskDict > copyOrGetDefault(MaskPlaneDict const &dict)
Definition: MaskDict.cc:111
Class for storing generic metadata.
Definition: PropertySet.h:66
virtual std::shared_ptr< PropertySet > deepCopy() const
Make a deep copy of the PropertySet and all of its contents.
An integer coordinate rectangle.
Definition: Box.h:55
Reports invalid arguments.
Definition: Runtime.h:66
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
Reports when the result of an operation cannot be represented by the destination type.
Definition: Runtime.h:115
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
T end(T... args)
T find(T... args)
T get(T... args)
def writeFits(filename, stamps, metadata, type_name, write_mask, write_variance, write_archive=False)
Definition: stamps.py:42
ImageT val
Definition: CR.cc:146
Options for writing an image to FITS.
Definition: fits.h:223
T substr(T... args)
T swap(T... args)