LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+a41d3748ce,g1470d8bcf6+6be6c9203b,g2079a07aa2+14824f138e,g212a7c68fe+a4f2ea4efa,g2305ad1205+72971fe858,g295015adf3+ab2c85acae,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+31b3a28dff,g487adcacf7+082e807817,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+b2918d57ae,g5a732f18d5+66d966b544,g64a986408d+a41d3748ce,g858d7b2824+a41d3748ce,g8a8a8dda67+a6fc98d2e7,g99cad8db69+7fe4acdf18,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+84af8b3ff8,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+d8d527deb2,gc07e1c2157+b2dbe6b631,gc120e1dc64+61440b2abb,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+31b3a28dff,gdaeeff99f8+a38ce5ea23,ge6526c86ff+39927bb362,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+a41d3748ce,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lsst.afw.image._image._multiband.MultibandMask Class Reference
Inheritance diagram for lsst.afw.image._image._multiband.MultibandMask:
lsst.afw.image._image._multiband.MultibandImageBase lsst.afw.multiband.MultibandBase

Public Member Functions

 __init__ (self, filters, array, bbox=None)
 
 getMaskPlane (self, key)
 
 getPlaneBitMask (self, names)
 
 getNumPlanesMax (self)
 
 getNumPlanesUsed (self)
 
 getMaskPlaneDict (self)
 
 removeAndClearMaskPlane (self, name, removeFromDefault=False)
 
 clearAllMaskPlanes (self)
 
 __ior__ (self, others)
 
 __iand__ (self, others)
 
 __ixor__ (self, others)
 

Static Public Member Functions

 fromMasks (filters, singles)
 
 fromKwargs (filters, filterKwargs, singleType=ImageF, **kwargs)
 
 clearMaskPlaneDict ()
 
 addMaskPlane (name)
 
 removeMaskPlane (name)
 

Public Attributes

 singles
 

Protected Member Functions

 _getOtherMasks (self, others)
 

Protected Attributes

 _refMask
 

Detailed Description

Multiband Mask class

See `MultibandImageBase` for a description of the parameters.

Definition at line 353 of file _multiband.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.afw.image._image._multiband.MultibandMask.__init__ ( self,
filters,
array,
bbox = None )

Reimplemented from lsst.afw.image._image._multiband.MultibandImageBase.

Definition at line 358 of file _multiband.py.

358 def __init__(self, filters, array, bbox=None):
359 super().__init__(filters, array, Mask, bbox)
360 # Set Mask specific properties
361 self._refMask = self._singles[0]
362 refMask = self._refMask
363 assert np.all([refMask.getMaskPlaneDict() == m.getMaskPlaneDict() for m in self.singles])
364 assert np.all([refMask.getNumPlanesMax() == m.getNumPlanesMax() for m in self.singles])
365 assert np.all([refMask.getNumPlanesUsed() == m.getNumPlanesUsed() for m in self.singles])
366

Member Function Documentation

◆ __iand__()

lsst.afw.image._image._multiband.MultibandMask.__iand__ ( self,
others )

Definition at line 541 of file _multiband.py.

541 def __iand__(self, others):
542 _others = self._getOtherMasks(others)
543 for s, o in zip(self.singles, _others):
544 s &= o
545 return self
546

◆ __ior__()

lsst.afw.image._image._multiband.MultibandMask.__ior__ ( self,
others )

Definition at line 535 of file _multiband.py.

535 def __ior__(self, others):
536 _others = self._getOtherMasks(others)
537 for s, o in zip(self.singles, _others):
538 s |= o
539 return self
540

◆ __ixor__()

lsst.afw.image._image._multiband.MultibandMask.__ixor__ ( self,
others )

Definition at line 547 of file _multiband.py.

547 def __ixor__(self, others):
548 _others = self._getOtherMasks(others)
549 for s, o in zip(self.singles, _others):
550 s ^= o
551 return self
552
553

◆ _getOtherMasks()

lsst.afw.image._image._multiband.MultibandMask._getOtherMasks ( self,
others )
protected
Check if two masks can be combined

This method checks that `self` and `others`
have the same number of bands, or if
others is a single value, creates a list
to use for updating all of the `singles`.

Definition at line 518 of file _multiband.py.

518 def _getOtherMasks(self, others):
519 """Check if two masks can be combined
520
521 This method checks that `self` and `others`
522 have the same number of bands, or if
523 others is a single value, creates a list
524 to use for updating all of the `singles`.
525 """
526 if isinstance(others, MultibandMask):
527 if len(self.singles) != len(others.singles) or self.filters != others.filters:
528 msg = "Both `MultibandMask` objects must have the same number of bands to combine"
529 raise ValueError(msg)
530 result = [s for s in others.singles]
531 else:
532 result = [others]*len(self.singles)
533 return result
534

◆ addMaskPlane()

lsst.afw.image._image._multiband.MultibandMask.addMaskPlane ( name)
static
Add a mask to the mask plane

Parameters
----------
name : `str`
   Name of the new mask plane

Returns
-------
index : `int`
   Bit value of the mask in the mask plane.

Definition at line 465 of file _multiband.py.

465 def addMaskPlane(name):
466 """Add a mask to the mask plane
467
468 Parameters
469 ----------
470 name : `str`
471 Name of the new mask plane
472
473 Returns
474 -------
475 index : `int`
476 Bit value of the mask in the mask plane.
477 """
478 idx = Mask[MaskPixel].addMaskPlane(name)
479 return idx
480

◆ clearAllMaskPlanes()

lsst.afw.image._image._multiband.MultibandMask.clearAllMaskPlanes ( self)
Clear all the pixels

Definition at line 513 of file _multiband.py.

513 def clearAllMaskPlanes(self):
514 """Clear all the pixels
515 """
516 self._refMask.clearAllMaskPlanes()
517

◆ clearMaskPlaneDict()

lsst.afw.image._image._multiband.MultibandMask.clearMaskPlaneDict ( )
static
Reset the mask plane dictionary

Definition at line 459 of file _multiband.py.

459 def clearMaskPlaneDict():
460 """Reset the mask plane dictionary
461 """
462 Mask[MaskPixel].clearMaskPlaneDict()
463

◆ fromKwargs()

lsst.afw.image._image._multiband.MultibandMask.fromKwargs ( filters,
filterKwargs,
singleType = ImageF,
** kwargs )
static
Build a MultibandImage from a set of keyword arguments

see `makeImageFromKwargs` for a description of parameters

Definition at line 376 of file _multiband.py.

376 def fromKwargs(filters, filterKwargs, singleType=ImageF, **kwargs):
377 """Build a MultibandImage from a set of keyword arguments
378
379 see `makeImageFromKwargs` for a description of parameters
380 """
381 return makeImageFromKwargs(MultibandMask, filters, filterKwargs, singleType, **kwargs)
382

◆ fromMasks()

lsst.afw.image._image._multiband.MultibandMask.fromMasks ( filters,
singles )
static
Construct a MultibandImage from a collection of single band images

see `fromSingles` for a description of parameters

Definition at line 368 of file _multiband.py.

368 def fromMasks(filters, singles):
369 """Construct a MultibandImage from a collection of single band images
370
371 see `fromSingles` for a description of parameters
372 """
373 return makeImageFromSingles(MultibandMask, filters, singles)
374

◆ getMaskPlane()

lsst.afw.image._image._multiband.MultibandMask.getMaskPlane ( self,
key )
Get the bit number of a mask in the `MaskPlaneDict`

Each `key` in the mask plane has an associated bit value
in the mask. This method returns the bit number of the
`key` in the `MaskPlaneDict`.
This is in contrast to `getPlaneBitMask`, which returns the
value of the bit number.

For example, if `getMaskPlane` returns `8`, then `getPlaneBitMask`
returns `256`.

Parameters
----------
key : `str`
   Name of the key in the `MaskPlaneDict`

Returns
-------
bit : `int`
   Bit number for mask `key`

Definition at line 383 of file _multiband.py.

383 def getMaskPlane(self, key):
384 """Get the bit number of a mask in the `MaskPlaneDict`
385
386 Each `key` in the mask plane has an associated bit value
387 in the mask. This method returns the bit number of the
388 `key` in the `MaskPlaneDict`.
389 This is in contrast to `getPlaneBitMask`, which returns the
390 value of the bit number.
391
392 For example, if `getMaskPlane` returns `8`, then `getPlaneBitMask`
393 returns `256`.
394
395 Parameters
396 ----------
397 key : `str`
398 Name of the key in the `MaskPlaneDict`
399
400 Returns
401 -------
402 bit : `int`
403 Bit number for mask `key`
404 """
405 return self._refMask.getMaskPlaneDict()[key]
406

◆ getMaskPlaneDict()

lsst.afw.image._image._multiband.MultibandMask.getMaskPlaneDict ( self)
Dictionary of Mask Plane bit values

Definition at line 453 of file _multiband.py.

453 def getMaskPlaneDict(self):
454 """Dictionary of Mask Plane bit values
455 """
456 return self._refMask.getMaskPlaneDict()
457

◆ getNumPlanesMax()

lsst.afw.image._image._multiband.MultibandMask.getNumPlanesMax ( self)
Maximum number of mask planes available

This is required to be the same for all of the single
band `Mask` objects.

Definition at line 437 of file _multiband.py.

437 def getNumPlanesMax(self):
438 """Maximum number of mask planes available
439
440 This is required to be the same for all of the single
441 band `Mask` objects.
442 """
443 return self._refMask.getNumPlanesMax()
444

◆ getNumPlanesUsed()

lsst.afw.image._image._multiband.MultibandMask.getNumPlanesUsed ( self)
Number of mask planes used

This is required to be the same for all of the single
band `Mask` objects.

Definition at line 445 of file _multiband.py.

445 def getNumPlanesUsed(self):
446 """Number of mask planes used
447
448 This is required to be the same for all of the single
449 band `Mask` objects.
450 """
451 return self._refMask.getNumPlanesUsed()
452

◆ getPlaneBitMask()

lsst.afw.image._image._multiband.MultibandMask.getPlaneBitMask ( self,
names )
Get the bit number of a mask in the `MaskPlaneDict`

Each `key` in the mask plane has an associated bit value
in the mask. This method returns the bit number of the
`key` in the `MaskPlaneDict`.
This is in contrast to `getPlaneBitMask`, which returns the
value of the bit number.

For example, if `getMaskPlane` returns `8`, then `getPlaneBitMask`
returns `256`.

Parameters
----------
names : `str` or list of `str`
   Name of the key in the `MaskPlaneDict` or a list of keys.
   If multiple keys are used, the value returned is the integer
   value of the number with all of the bit values in `names`.

   For example if `MaskPlaneDict("CR")=3` and
   `MaskPlaneDict("NO_DATA)=8`, then
   `getPlaneBitMask(("CR", "NO_DATA"))=264`

Returns
-------
bit value : `int`
   Bit value for all of the combined bits described by `names`.

Definition at line 407 of file _multiband.py.

407 def getPlaneBitMask(self, names):
408 """Get the bit number of a mask in the `MaskPlaneDict`
409
410 Each `key` in the mask plane has an associated bit value
411 in the mask. This method returns the bit number of the
412 `key` in the `MaskPlaneDict`.
413 This is in contrast to `getPlaneBitMask`, which returns the
414 value of the bit number.
415
416 For example, if `getMaskPlane` returns `8`, then `getPlaneBitMask`
417 returns `256`.
418
419 Parameters
420 ----------
421 names : `str` or list of `str`
422 Name of the key in the `MaskPlaneDict` or a list of keys.
423 If multiple keys are used, the value returned is the integer
424 value of the number with all of the bit values in `names`.
425
426 For example if `MaskPlaneDict("CR")=3` and
427 `MaskPlaneDict("NO_DATA)=8`, then
428 `getPlaneBitMask(("CR", "NO_DATA"))=264`
429
430 Returns
431 -------
432 bit value : `int`
433 Bit value for all of the combined bits described by `names`.
434 """
435 return self._refMask.getPlaneBitMask(names)
436

◆ removeAndClearMaskPlane()

lsst.afw.image._image._multiband.MultibandMask.removeAndClearMaskPlane ( self,
name,
removeFromDefault = False )
Remove and clear a mask from the mask plane

Clear all pixels of the specified mask and remove the plane from the
mask plane dictionary.  Also optionally remove the plane from the
default dictionary.

Parameters
----------
name : `str`
   Name of the mask plane to remove
removeFromDefault : `bool`, optional
   Whether to remove the mask plane from the default dictionary.
   Default is `False`.

Definition at line 492 of file _multiband.py.

492 def removeAndClearMaskPlane(self, name, removeFromDefault=False):
493 """Remove and clear a mask from the mask plane
494
495 Clear all pixels of the specified mask and remove the plane from the
496 mask plane dictionary. Also optionally remove the plane from the
497 default dictionary.
498
499 Parameters
500 ----------
501 name : `str`
502 Name of the mask plane to remove
503 removeFromDefault : `bool`, optional
504 Whether to remove the mask plane from the default dictionary.
505 Default is `False`.
506 """
507 # Clear all masks in MultibandMask but leave in default dict for now
508 for single in self.singles:
509 single.removeAndClearMaskPlane(name, removeFromDefault=False)
510 # Now remove from default dict according to removeFromDefault
511 self._refMask.removeAndClearMaskPlane(name, removeFromDefault)
512

◆ removeMaskPlane()

lsst.afw.image._image._multiband.MultibandMask.removeMaskPlane ( name)
static
Remove a mask from the mask plane

Parameters
----------
name : `str`
   Name of the mask plane to remove

Definition at line 482 of file _multiband.py.

482 def removeMaskPlane(name):
483 """Remove a mask from the mask plane
484
485 Parameters
486 ----------
487 name : `str`
488 Name of the mask plane to remove
489 """
490 Mask[MaskPixel].removeMaskPlane(name)
491

Member Data Documentation

◆ _refMask

lsst.afw.image._image._multiband.MultibandMask._refMask
protected

Definition at line 361 of file _multiband.py.

◆ singles

lsst.afw.image._image._multiband.MultibandMask.singles

Definition at line 527 of file _multiband.py.


The documentation for this class was generated from the following file: