Skip to content

Commit

Permalink
Add a factory method for OwnedImagePlanes
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkannawadi committed Nov 16, 2023
1 parent 9faf7ed commit 37b13c6
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions python/lsst/cell_coadds/_image_planes.py
Expand Up @@ -29,12 +29,12 @@

from abc import ABC, abstractmethod
from collections.abc import Callable, Sequence
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Self

from lsst.afw.image import MaskedImageF

if TYPE_CHECKING:
from lsst.afw.image import Mask
from lsst.afw.image import Mask, MaskedImage
from lsst.geom import Box2I

from .typing_helpers import ImageLike
Expand Down Expand Up @@ -116,6 +116,22 @@ def __init__(
self._mask_fractions = mask_fractions
self._noise_realizations = tuple(noise_realizations)

@classmethod
def from_masked_image(
cls,
masked_image: MaskedImage,
mask_fractions: ImageLike | None = None,
noise_realizations: Sequence[ImageLike] = (),
) -> Self:
"""Construct from an `lsst.afw.image.MaskedImage`."""
return cls(
image=masked_image.image,
mask=masked_image.mask,
variance=masked_image.variance,
mask_fractions=mask_fractions,
noise_realizations=noise_realizations,
)

@property
def bbox(self) -> Box2I:
# Docstring inherited.
Expand Down

0 comments on commit 37b13c6

Please sign in to comment.