I’m currently writing a script to automate Calibration and Terrain Correction of SAR GRD datasets.
I’m struggling to find any documentation on what the parameters are named to pass into the GPF.createProduct() methods, they don’t line up with the names used within the SNAP gui application. Could anyone lead me to these?
In particular I can’t seem to work out what Mask out areas without elevation is.
You can see the names of the parameters on the command line when you call gpt <operator_name> -h
It’s also possible to ask for it in python. The following snippet print the names and their aliases. You can use both. But I would prefer the alias, because they are in general better readable.
opSpi = GPF.getOperatorSpiRegistry().getOperatorSpi("operatorName")
paramDescList = opSpi.getOperatorDescriptor().getParameterDescriptors()
for param in paramDescList:
print(param.getName(), "or", param.getAlias())
Now I would also like to display all the possible values for each parameter. On the link marpet provided I managed to find the getValueSet method which “Gets the set of values which can be assigned to a parameter field.”, exactly what I want.
The problem is that when I execute the code:
param_Desc = op_spi.getOperatorDescriptor().getParameterDescriptors()
a = param_Desc[0].getValueSet()
the result is a Java string: [Ljava.lang.String;(objectRef=0x0000000030096308) but I don’t know how to print the values in the string any suggestions? thank you!
Yeah thank you, probably that’s the way of showing it, but can you explain why the majority of them result as an empty object?
If, for example, I choose to display the list of possible values for the parameter demName, of the Terrain-Correction operator I get this as the output of my function after adding your last code snippet:
demName: The digital elevation model.
Default Value: SRTM 3Sec
Possible other values: []
Possible other values, where I inserted print(list(value_set)) just gives me an empty object
Isn’t that supposed to return all the available values among which I can choose using SNAP GUI? (In this case they would be ACE2_5Min, ACE30, ASTER 1sec GDEM,GETASSE30, SRTM 1sec grid, SRTM 1sec HGT, SRTM 3sec, External DEM )
This is often not possible to have this information.
The value_set is a static information. It is specified at development time. For example for the available DEMs can change by adding a or removing a plugin.
For the parameter demResamplingMethod of Terrain-Correction, you should get a value set.
We have already thought about collecting such information at runtime. Also, because we want to have it with the help when using gpt -h. This is not yet implemented.
Hi, I have some questions
Q1: I want to know how to list the default values of all parameters of each operator?
Q2: How to output the maximum and minimum values of variables of esa.snap.core.datamodel.product type?
Q3: How to output the incidence angle values of sentinel1 SAR data?
pDescriptors = op_spi.getOperatorDescriptor().getParameterDescriptors()
gives you a list of descriptors, one for each parameter.
for i in range(len(pDescriptors )):
print(pDescriptors[i].getAlias(), " default: ", pDescriptors[i].getDefaultValue())
Q2: product.getBand('bandname').getStx().getMaximum() # or getMinimum()
Q3:
I don’ know how you want to output those values.
But you can get them by:
iangle = product.getTiePointGrid('IW1_incident_angle')
# then you can read the values
data= numpy.zeros(width*height, dtype=numpy.float32)
iangle.readPixels(x,y,width, height, data)
# now you have the values in the data array and can print them.
Code should be like this. Sort of. Have not tested it.