Last active
February 10, 2020 04:54
-
-
Save vincentsarago/b8c649ac876241cc05a1da3c098a9670 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Custom stddev pixel selection method.""" | |
import numpy | |
from rio_tiler_mosaic.methods.base import MosaicMethodBase | |
class bidx_stddev(MosaicMethodBase): | |
"""Return bands stddev.""" | |
def __init__(self): | |
"""Overwrite base and init bands stddev method.""" | |
super(bidx_stddev, self).__init__() | |
self.exit_when_filled = True | |
def feed(self, tile): | |
"""Add data to tile.""" | |
tile = numpy.ma.std(tile, axis=0, keepdims=True) | |
if self.tile is None: | |
self.tile = tile | |
pidex = self.tile.mask & ~tile.mask | |
mask = numpy.where(pidex, tile.mask, self.tile.mask) | |
self.tile = numpy.ma.where(pidex, tile, self.tile) | |
self.tile.mask = mask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment