GPF operation in computeTile function

Hi all! For a plugin that I am writing in Python I am aiming at three steps that I wish to perform. Firstly, I wish to Collocate two input images, then I wish to do some arithmetic in Numpy and finally I wish to apply a correction, say Range Dopppler Terrain Correction.

I know that the -op.py script in which this should take place contains a class which holds a def initialize, a def computeTile. The first step, the collocation, I can do in the initialize function. The second step, the numpy operation, (I believe) I have to do in the computeTile function. The third step, the terrain correction, then also needs to take place in the computeTile function.

So, I know that the collocation can be done like this:
self.src_collocated = snappy.GPF.createProduct(‘Collocate’, params, src)

where params is a hashmap with the function options. How do I do this for the terrain correction, but now in the computeTile function where I am working with tiles and not src variables?

Best regards,

Lars

Hello Lars,

the operators are actually not intended for such work flow. Probably it is best to only implement the numpy operation in Python operator. For the collocation and the terrain correction just rely on a GPF XML graph which is then invoked from the commandline. This graph would have 3 steps (nodes), actually 5. 2 nodes for reading, the collocation node, the numpy node and the terrain correction node.

If you don’t like this you can write a wrapper operator. Still, just implement the numpy operator. Then you write a second operator which wraps the calls to the 3 operators in its initialise method.

Hi Marco,

Thank you for your reply. I would prefer going with the second option, as I will want to have the program as an extension to SNAP.

In my understanding you say the following is then the way to go:
Write the extension with Collocation through something like
self.src_collocated = snappy.GPF.createProduct(‘Collocate’, params, src)
in the initialize function. Then apply the numpy steps in the computeTile function. Then wrap up the extension. After that, I create a new extension in SNAP where I call the former extension and apply my Range Doppler Terrain Correction afterwards. However, this time I can call all of these in the initialize function. This would mean that I need a snappy.GPF.createProduct() call to the custom extension. How do I know by which name I need to call it?

Actually the init method could look like the following snippit:

...
self.src_collocated = snappy.GPF.createProduct(‘Collocate’, params, src)
...
self.src_numpy = snappy.GPF.createProduct(‘NumpyOperation’, params, src_collocated)
...
self.src_terrain = snappy.GPF.createProduct(‘Terrain-Correction’, params, src_numpy )
context.setTargetProduct(src_terrain)

Between the calls, you configure the params. For this wrapper, you don’t need to implement the computeTile method.

As lookup-name for your NumpyOperation, you need to use the alias you have specified in the info.xml file.

Thank you! that set-up looks straightforward and is flexible as well.
What about the params HashMap for the NumpyOperation. How do the variable names in the -info.xml file of the NumpyOperation module translate to the HashMap needed for the operation?

The name you use in the info.xml file for the parameter can also be used as key in the parameters HashMap.

<parameter>
    <name>enable_switch</name>
    <description>switch to enable/disable something</description>
    <dataType>boolean</dataType>
    <defaultValue>True</defaultValue>
</parameter>

–> params.put(‘enable_switch’, False)

Excellent, I will give it a try. Thank you!