How to label or relabel a datacube band?

In the following code the datacube called datacube_CR is created containing a band without name (label). When I call rename_labels to apply a label to the band I get a message:
ValueError: Invalid dimension ‘bands’. Should be one of [‘x’, ‘y’]
How can I label the band of the datacube created?
Thanks in advance, Best Regards,
Chris Kiranoudis, Professor NTUA

import openeo
from openeo.processes import array_element, normalized_difference

def CR_function(data):
VV = data[0]
VH = data[1]
result = VH / VV
return result

datacube = connection.load_collection(
“SENTINEL1_GRD”,
spatial_extent={“west”: 16.06, “south”: 48.06, “east”: 16.07, “north”: 48.07},
temporal_extent=[“2020-04-01”, “2020-06-01”],
bands=[“VV”, “VH”]
)
datacube = datacube.reduce_dimension(dimension = “t”, reducer = “mean”)
datacube_CR = datacube.reduce_dimension(reducer = CR_function, dimension = “bands”).rename_labels(dimension = “bands”, target = [“CR”])
datacube = datacube.merge_cubes(datacube_CR)
datacube.download(“s1-aggregate.tiff”, format = “GTiff”)

If you reduce the bands dimension, the dimension is completely removed. So a three-dimensional cube with x,y,bands gets reduced to x,y (as seen in the error message) and you can’t rename it any longer. You can either add the dimension again with the label you want to set or you can simply work with the 2D data cube.

Fot details please see: API — openEO Python Client 0.10.1a1 documentation

So basically datacube.add_dimension("bands", "CR", type = "bands") woudlk add the dimension again.

Thank you Matthias.
datacube_CR = datacube.reduce_dimension(reducer = CR_function, dimension = “bands”).add_dimension(“bands”, “CR”, type = “bands”)
It now works fine.
Best Regards, Chris