Changing Bandnames deletes Pixel Values of Sentinel 1 Image

Hi,

I am working on Sentinel 1 Images with Snappy. I have a workflow for preprocessing and was wondering that when I change the Bandnames it does not work.

This works:

sentinel_1proc = do_calibration(source = sentinel_1proc ,polarization = polarization ,pols = pols)
file_result = ‘D:\output\test1’
stack_subset = do_subset(sentinel_1proc, m.wkt)
WriteOp = jpy.get_type(‘org.esa.snap.core.gpf.common.WriteOp’)
WriteOp = WriteOp(stack_subset, File(file_result), ‘GeoTIFF’)
WriteOp.writeProduct(ProgressMonitor.NULL)

The output is an image with useful values :

Now when I do the same process and change the Bandnames, the Pixel Values will be set to 0:

date = 20200927
sentinel_1proc = do_calibration(source = sentinel_1proc,polarization = polarization ,pols = pols)
sentinel_1proc.getBand(‘Sigma0_VH’).setName(‘Sigma0_VH_’ + date)
sentinel_1proc.getBand(‘Sigma0_VV’).setName(‘Sigma0_VV_’ + date)
name = sentinel_1proc.getBandNames()
list(name)
[‘Sigma0_VH_20200927’, ‘Sigma0_VV_20200927’]
file_result = ‘D:\output\test_2’
stack_subset = do_subset(sentinel_1proc, m.wkt)
WriteOp = jpy.get_type(‘org.esa.snap.core.gpf.common.WriteOp’)
WriteOp = WriteOp(stack_subset, File(file_result), ‘GeoTIFF’)
WriteOp.writeProduct(ProgressMonitor.NULL)

Now the image looks like this during the same process besides the name change:

Does anyone know why the pixel values are changed or what I am doing wrong?

After some research I found out in this post that changing the band names requires a copy of the product to continue working with the product.

It is explained in this post: Cannot write a product after band renaming

So for me creating a copy before renaming band names worked fine:

date = 20200927
sentinel_1proc = do_calibration(source = sentinel_1proc,polarization = polarization ,pols = pols)

parameters = HashMap()
parameters.put(‘copyMetadata’, True)
sentinel_copy = GPF.createProduct(‘Subset’, parameters, sentinel_1proc)

sentinel_copy.getBand(‘Sigma0_VH’).setName(‘Sigma0_VH_’ + date)
sentinel_copy.getBand(‘Sigma0_VV’).setName(‘Sigma0_VV_’ + date)
name = sentinel_copy.getBandNames()
list(name)
[‘Sigma0_VH_20200927’, ‘Sigma0_VV_20200927’]
file_result = ‘D:\output\test_2’
stack_subset = do_subset(sentinel_copy, m.wkt)
WriteOp = jpy.get_type(‘org.esa.snap.core.gpf.common.WriteOp’)
WriteOp = WriteOp(stack_subset, File(file_result), ‘GeoTIFF’)
WriteOp.writeProduct(ProgressMonitor.NULL)