# BandMaths snappy - Calculating ration between two Bands

Hello!

i have read a few articles about BandMaths in snappy but still can’t manage to divide one band by another. I understand the logic for BandMaths calculations within a band, but I don’t understand how I can divide 2 bands

I have a product with 2 bands of which I want to calculate the ratio.

I have a Band A and a Band B. What I want is A/B.

Can anyone help me?

This is my code:

``````parameters = HashMap()
BandDescriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp\$BandDescriptor')
targetBand_1 = BandDescriptor()
targetBand_1.name = 'Intensity_VH'

targetBand_2 = BandDescriptor()
targetBand_2.name = 'Intensity_VV'

targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp\$BandDescriptor', 2)
targetBands[0] = targetBand_1
targetBands[1] = targetBand_2

parameters.put('targetBands', targetBands)
parameters.put('validExpression', 'Intensity_VH / Intensity_VV')
output = GPF.createProduct('BandMaths', parameters, source)
``````

RuntimeError: java.lang.IllegalArgumentException: code is null

i also tried:

``````parameters = HashMap()
BandDescriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp\$BandDescriptor')
targetBand_1 = BandDescriptor()
targetBand_1.name = 'Intensity_VH_VV'
targetBand_1.type = 'float32'
targetBand_1.expression = 'Intensity_VH / Intensity_VV'

targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp\$BandDescriptor', 1)
targetBands[0] = targetBand_1

parameters.put('targetBands', targetBands)
output = GPF.createProduct('BandMaths', parameters, source)``````

You second approach looks quite good. What is the error you get?
Still “IllegalArgumentException: code is null”?

There was no error message for the second attempt. The band of the final product had only 0 values.
After I emptied the environment and restarted everything, the second approach worked. Thanks for support. I did not know where the error was. Sorry for wasting your time