average_rasters.py
def average_op(*value_nodata_list):
    """Calculate count of valid pixels over each pixel stack."""
    result = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
    count = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
    valid_mask = numpy.zeros(result.shape, dtype=numpy.bool)
    list_len = len(value_nodata_list)
    for array, nodata in zip(
            value_nodata_list[0:list_len//2],
            value_nodata_list[list_len//2::]):
        local_valid_mask = ~numpy.isclose(array, nodata)
        count[local_valid_mask] += 1
        result[local_valid_mask] += array[local_valid_mask]
        valid_mask |= local_valid_mask
    result[valid_mask] /= count[valid_mask]
    result[~valid_mask] = AVERAGE_NODATA
    return result
Calculate count of valid pixels over each pixel stack.
Calculate count of valid pixels over each pixel stack.
Calculate count of valid pixels over each pixel stack .
def average_op(*value_nodata_list):
    result = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
    count = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
    valid_mask = numpy.zeros(result.shape, dtype=numpy.bool)
    list_len = len(value_nodata_list)
    for array, nodata in zip(
            value_nodata_list[0:list_len//2],
            value_nodata_list[list_len//2::]):
        local_valid_mask = ~numpy.isclose(array, nodata)
        count[local_valid_mask] += 1
        result[local_valid_mask] += array[local_valid_mask]
        valid_mask |= local_valid_mask
    result[valid_mask] /= count[valid_mask]
    result[~valid_mask] = AVERAGE_NODATA
    return result
def average_op ( * value_nodata_list ) : result = numpy . zeros ( value_nodata_list [ 0 ] . shape , dtype = numpy . float32 ) count = numpy . zeros ( value_nodata_list [ 0 ] . shape , dtype = numpy . float32 ) valid_mask = numpy . zeros ( result . shape , dtype = numpy . bool ) list_len = len ( value_nodata_list ) for array , nodata in zip ( value_nodata_list [ 0 : list_len // 2 ] , value_nodata_list [ list_len // 2 : : ] ) : local_valid_mask = ~ numpy . isclose ( array , nodata ) count [ local_valid_mask ] += 1 result [ local_valid_mask ] += array [ local_valid_mask ] valid_mask |= local_valid_mask result [ valid_mask ] /= count [ valid_mask ] result [ ~ valid_mask ] = AVERAGE_NODATA return result
Calculate count of valid pixels over each pixel stack.
Calculate count of valid pixels over each pixel stack .
"""Calculate count of valid pixels over each pixel stack."""