Exemplo n.º 1
0
    def setUp(self):
        np.random.seed(1)
        self.bbox = Box2I(Point2I(1000, 2000), Extent2I(200, 100))
        self.filters = ["G", "R", "I"]

        self.imgValue = 10
        images = [ImageF(self.bbox, self.imgValue) for f in self.filters]
        mImage = MultibandImage.fromImages(self.filters, images)

        self.Mask = Mask[MaskPixel]
        # Store the default mask planes for later use
        maskPlaneDict = self.Mask().getMaskPlaneDict()
        self.defaultMaskPlanes = sorted(maskPlaneDict,
                                        key=maskPlaneDict.__getitem__)

        # reset so tests will be deterministic
        self.Mask.clearMaskPlaneDict()
        for p in ("BAD", "SAT", "INTRP", "CR", "EDGE"):
            self.Mask.addMaskPlane(p)

        self.maskValue = self.Mask.getPlaneBitMask("BAD")
        singles = [self.Mask(self.bbox) for f in range(len(self.filters))]
        for n in range(len(singles)):
            singles[n].set(self.maskValue)
        mMask = MultibandMask.fromMasks(self.filters, singles)

        self.varValue = 1e-2
        images = [ImageF(self.bbox, self.varValue) for f in self.filters]
        mVariance = MultibandImage.fromImages(self.filters, images)

        self.maskedImage = MultibandMaskedImage(self.filters,
                                                image=mImage,
                                                mask=mMask,
                                                variance=mVariance)
Exemplo n.º 2
0
    def fromArrays(filters,
                   image,
                   mask=None,
                   variance=None,
                   footprint=None,
                   xy0=None,
                   thresh=0,
                   peaks=None):
        """Create a `MultibandFootprint` from an `image`, `mask`, `variance`

        Parameters
        ----------
        filters: `list`
            List of filter names.
        image: array
            An array to convert into `HeavyFootprint` objects.
            Only pixels above the `thresh` value for at least one band
            will be included in the `SpanSet` and resulting footprints.
        mask: array
            Mask for the `image` array.
        variance: array
            Variance of the `image` array.
        footprint: `Footprint`
            `Footprint` that contains the `SpanSet` and `PeakCatalog`
            to use for the `HeavyFootprint` in each band.
            If `footprint` is `None` then the `thresh` is used to create a
            `Footprint` based on the pixels above the `thresh` value.
        xy0: `Point2I`
            If `image` is an array and `footprint` is `None` then specifying
            `xy0` gives the location of the minimum `x` and `y` value of the
            `images`.
        thresh: float or list of floats
            Threshold in each band (or the same threshold to be used in all bands)
            to include a pixel in the `SpanSet` of the `MultibandFootprint`.
            If `Footprint` is not `None` then `thresh` is ignored.
        peaks: `PeakCatalog`
            Catalog containing information about the peaks located in the
            footprints.

        Returns
        -------
        result: `MultibandFootprint`
            MultibandFootprint created from the arrays
        """
        # Generate a new Footprint if one has not been specified
        if footprint is None:
            spans, imageBBox = getSpanSetFromImages(image, thresh, xy0)
            footprint = Footprint(spans)
        else:
            imageBBox = footprint.getBBox()

        if peaks is not None:
            footprint.setPeakCatalog(peaks)
        mMaskedImage = MultibandMaskedImage.fromArrays(filters, image, mask,
                                                       variance, imageBBox)
        singles = [
            makeHeavyFootprint(footprint, maskedImage)
            for maskedImage in mMaskedImage
        ]
        return MultibandFootprint(filters, singles)
Exemplo n.º 3
0
    def fromArrays(filters, image, mask=None, variance=None, footprint=None, xy0=None, thresh=0, peaks=None):
        """Create a `MultibandFootprint` from an `image`, `mask`, `variance`

        Parameters
        ----------
        filters: `list`
            List of filter names.
        image: array
            An array to convert into `HeavyFootprint` objects.
            Only pixels above the `thresh` value for at least one band
            will be included in the `SpanSet` and resulting footprints.
        mask: array
            Mask for the `image` array.
        variance: array
            Variance of the `image` array.
        footprint: `Footprint`
            `Footprint` that contains the `SpanSet` and `PeakCatalog`
            to use for the `HeavyFootprint` in each band.
            If `footprint` is `None` then the `thresh` is used to create a
            `Footprint` based on the pixels above the `thresh` value.
        xy0: `Point2I`
            If `image` is an array and `footprint` is `None` then specifying
            `xy0` gives the location of the minimum `x` and `y` value of the
            `images`.
        thresh: float or list of floats
            Threshold in each band (or the same threshold to be used in all bands)
            to include a pixel in the `SpanSet` of the `MultibandFootprint`.
            If `Footprint` is not `None` then `thresh` is ignored.
        peaks: `PeakCatalog`
            Catalog containing information about the peaks located in the
            footprints.

        Returns
        -------
        result: `MultibandFootprint`
            MultibandFootprint created from the arrays
        """
        # Generate a new Footprint if one has not been specified
        if footprint is None:
            spans, imageBBox = getSpanSetFromImages(image, thresh, xy0)
            footprint = Footprint(spans)
        else:
            imageBBox = footprint.getBBox()

        if peaks is not None:
            footprint.setPeakCatalog(peaks)
        mMaskedImage = MultibandMaskedImage.fromArrays(filters, image, mask, variance, imageBBox)
        singles = [makeHeavyFootprint(footprint, maskedImage) for maskedImage in mMaskedImage]
        return MultibandFootprint(filters, singles)
Exemplo n.º 4
0
    def fromImages(filters,
                   image,
                   mask=None,
                   variance=None,
                   footprint=None,
                   thresh=0,
                   peaks=None):
        """Create a `MultibandFootprint` from an `image`, `mask`, `variance`

        Parameters
        ----------
        filters: list
            List of filter names.
        image: `MultibandImage`, or list of `Image`
            A `MultibandImage` (or collection of images in each band)
            to convert into `HeavyFootprint` objects.
            Only pixels above the `thresh` value for at least one band
            will be included in the `SpanSet` and resulting footprints.
        mask: `MultibandMask` or list of `Mask`
            Mask for the `image`.
        variance: `MultibandImage`, or list of `Image`
            Variance of the `image`.
        thresh: `float` or `list` of floats
            Threshold in each band (or the same threshold to be used in all bands)
            to include a pixel in the `SpanSet` of the `MultibandFootprint`.
            If `Footprint` is not `None` then `thresh` is ignored.
        peaks: `PeakCatalog`
            Catalog containing information about the peaks located in the
            footprints.

        Returns
        -------
        result: `MultibandFootprint`
            MultibandFootprint created from the image, mask, and variance
        """
        # Generate a new Footprint if one has not been specified
        if footprint is None:
            spans, imageBBox = getSpanSetFromImages(image, thresh)
            footprint = Footprint(spans)

        if peaks is not None:
            footprint.setPeakCatalog(peaks)
        mMaskedImage = MultibandMaskedImage(filters, image, mask, variance)
        singles = [
            makeHeavyFootprint(footprint, maskedImage)
            for maskedImage in mMaskedImage
        ]
        return MultibandFootprint(filters, singles)