What does the GPF-module?

Hello,

I tried to understand the examples in the snappy directory and a lot of the code is clear, but I don’t get what the GPF module does.
The beginning of the code in example snappy_bmaths.py is:
import sys
from snappy import ProductIO
from snappy import GPF
from snappy import jpy

Can someone explain how the GPF funktions work?
As an example: result=GPF.createProduct('BandMaths', parameters, product) ?

Thank you.

Hi, as linked in my previous answer, the code from the Java API is documented here, it also describes what those methods do.

For example, GPF.createProduct() does:

http://step.esa.int/docs/v5.0/apidoc/engine/org/esa/snap/core/gpf/GPF.html

Ok. Thanks. For me it is kind of difficult to understand this documentation, because I’m new to python and never worked with java. More precisely: python is kind of my first computer language.
Thus, I do not really get what the benefit is from GPF.

Think of it as like running a process on your data, for example if you want to do terrain correction, you would do:

params = HashMap()
params.put('demResamplingMethod', 'BILINEAR_INTERPOLATION')
params.put('imgResamplingMethod', 'BILINEAR_INTERPOLATION')
params.put('demName', 'SRTM 3Sec')
params.put('pixelSpacingInMeter', 10.0)
params.put('sourceBands', 'Sigma0_VH')
params.put('nodataValueAtSea', False)

terrain_corrected_product = GPF.createProduct("Terrain-Correction", params, product)

If python is your first language then I appreciate Java docs will look scary, but you don’t need to be able to code in Java to try map them back :slight_smile:
How much python/programming have you done? Something this undocumented in a python environment might be quite tricky!

GPF as I understand is what does all the main processing within the SNAP Desktop Application, if you can do it on the GUI you’ll probably need to use GPF.

I understand that GDF kind of put the results together in one result. Is this right? This is what your code looks like.

I have some basic skills in python, which I learned in some lectures/courses at university. I am a student trainee in a work group and my task is to get in touch with snappy and to introduce myself to this application - and yes, it is very tricky, because I’m the first person in this work group which tries to work with snappy.

Thus, I’m very thankful for the forum. :slight_smile:

@MaraM Dealing with snappy as your first real programming task is a big deal.

I would recommend that you get familiar first with SNAP Desktop. Have a look at its features and the help pages.
Then you should try gpt from the command line. gpt is the ‘Graph Processing Tool’ which invokes GPF from the command line.
Using GPF from Python is also the most common use case. So it will be good to know the tool before using it from the API side.

And if you have questions… The forum waits for ypu :wink:

1 Like

I worked a little bit with SNAP Desktop, but probably it will be easier for me if i go deeper into working with SNAP Desktop and then try to work more with snappy.