When I finished c2rcc processing , I want to extract those pixels with kd_z90max < 1.5 meters to form a new band, those pixels with kd_z90max >= 1.5 are set to zero . I tested expression ‘(kd_z90max < 1.5) * 1/kdmin’ in Band maths of SNAP desktop and the result is as I expected. But when I applied in python with esa-snappy , the code is as follows:
I got error message:
RuntimeError: org.esa.snap.core.gpf.OperatorException: Could not parse expression: ‘(kd_z90max < 1.5) * 1/kdmin’. Numeric operands expected for binary ‘*’ operator.
How can I solve this issue?Great thanks.
Probably the boolean result from the first part of the expression (kd_z90max < 1.5) is in desktop mode correctly converted to one but not in Python mode.
I would suggest a different expression: kd_z90max < 1.5 ? kd_z90max : 0
This sets the value of kd_z90max if smaller than 1.5 and sets zero if equal or greater.
Very grateful to Marco for your kind and timely technical guidance! the issue is solved perfectly.
I want to go even further 2 steps with esa-snappy: 1)After the masking with kd_z90max < 1.1 as valid pixels for water transparancy retrieval (this will will exclude those pixels which are nore more than 1.5 meter SD depth by experience), I want to apply a lake boundary polygon shape(which is converted to wkt) to kd_z90max and set the pixels outside the polygon with value 0.
2)with StatisticsOp GPF operator applied to the kd_z90max after previous step and get the resulting kd_z90max-mean,tsm-mean,chl-mean,btot-mean, and ohter IOPs,etc.
Is this workflow with Python possible?
Yes, this should be doable. Usually, you can do with Python what you can do in the desktop or with GPT on the command line.
With the SNAPISTA API, which is meanwhile installed along snappy, you can create graphs and execute them as if they were started from the command line.