Set parameters in snappy L2A-GIPP, resolution sen2cor 2.4.0 snap 6.0

I am getting a L2A-GIPP-custom.xml problem when executing sen2cor correction via snappy.
The execution log records the following L2A_GIPP used, which is neither the one I am trying to specify, nor the default one in home/cfg folder. Even more weird is that the custom GIPP file cerated on the fly seems to favor visibility and aerosol parameters in the L2A_GIPP.xml in the home/cfg folder, but not the DEM folder - it states “NONE”, while I have the default set to a directory on home\dem. excerpt from the log:

INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterOp: Executing tool ‘Sen2Cor’ with command line: ‘C:\Users\antonevdokimov.snap\auxdata\Sen2Cor-2.4.0-win64\L2A_Process.bat --resolution 60 C:\t\S2A_MSIL1C_20170527T102031_N0205_R065_T32TNS_20170527T102301.SAFE --GIP_L2A C:\Users\user\documents\sen2cor\L2A-GIPP-custom.xml’
INFO: org.esa.snap.core.gpf.operators.tooladapter.DefaultOutputConsumer: Sentinel-2 Level 2A Processor (Sen2Cor), 2.4.0, created: 2017.06.05 started …


parameters = snappy.HashMap()
parameters.put = (‘GIP_L2A’, ‘C:\t\L2A_GIPP.xml’)
input_image = snappy.ProductIO.readProduct(path)
L2A_image = snappy.GPF.createProduct(‘Sen2Cor’, parameters, input_image)

The other issue is that i am used to getting all resolutions through command line interface by simply omitting resolution specification. It does not work the same through snappy for me. If omitted it only produces the 60m. I can get 10m and 20m if specify 10m - that’s fine, but still wonder if I can get them all in one go.

I am running a SNAP6.0 and sen2cor 2.4.0 standalone install configured for python.

Appreciate any help. And by the way, is there a description on what other parameters are available for sen2cor via snappy? e.g. I have seen “target_file” here on the forums but not anywhere in documentation.

Hi James,

since version 6.0 it is possible to define all the parameters that are present in the GIPP file. If you see the help in gpt by executing in your command line:
gpt Sen2Cor -h
you will find which are these parameters (for using them in snappy, you have to remove the ‘-P’ prefix in the parameter list). As an example, you could define the aerosol, altitude, ozone… See attached file. parametersSen2CorOperator (4.2 KB)

Every parameter is also configurable via SNAP desktop:

To make this possible, the plugin contains a GIPP template that we use to create the L2A-GIPP-custom.xml by replacing the values with the selected ones. If anyone is not introduced, then the default value is used.

Currently, to define the GIP_L2A to overwrite this template is not working, so you have two solutions:

  • defining in snappy all the parameters individually
  • execute sen2cor directly from your command line instead of using the sen2cor plugin (i.e. execute directly L2A_Process.bat from your python script instead of using the gpt operator)

On the other hand, we haven’t yet included the option to compute all the resolution, but perhaps it is a good improvement that we could add in the next module update.

Thank you for your feedback. Regards,

Hi Omar,

Thank you for this valuable information. Now I can pass all required parameters to the process and they seem to be accepted. Sorry for late reply, I am the original poster, but somehow the thread got duplicated under another user id…

Hi antoioevd,

could you send me the code were you have included the parameters in snappy. I struggle to do that succesfully and cant find examples in the net.

Sorry for late reply, here is my example for python 2.7:

import snappy

def Sen2Cor(f):
parameters = snappy.HashMap()
parameters.put(‘resolution’, ‘10’)
#parameters.put(‘targetProductFile’,‘output file’)
#parameters.put(‘GIP_L2A’, ‘C:\t\L2A_GIPP.xml’)
input_image = snappy.ProductIO.readProduct(f)
L2A_image = snappy.GPF.createProduct(‘Sen2Cor’, parameters, input_image)

return f


if name == ‘main’: