Indeed, as noted above, the .bands()
method is convenience functionality (currently a feature only available in the openeo Python client, called “band math”) to build a reduce_dimension
operation along the “band” dimension, using standard math operators. E.g.
red = cube.band("red")
green = cube.band("green")
result = 2 * red - 5 * green
will translate to something like (pseudo code):
reduce_dimension(
dimension="bands",
reducer=subtract(multiply(array_element(cube, "red"), 2), multiply(array_element(cube, "green"))))
)
Obviously, the math notation version is easier to understand.
.filter_bands()
however is a standard openEO process to filter out specific bands (one or more) from a cube. It does not allow the same “band math” functionality, because it does not imply a reduce_dimension
along the band dimension.
However, on the output of .filter_bands()
, just like a normal DataCube, you still can apply mathematical operators. E.g.
cube = cube.filter_bands(["red", "green"])
cube = 2.5 * cube
This does not translate to reduce_dimension
, but a “pixel-wise” apply
, (scaling all pixel values with factor 2.5 in this case).
I hope this makes some things clear