Preprocessing in Python

Hi all,

I managed to download a sentinel1 product, and I now want to go ahead with the preprocessing using python. I want to first apply the orbit file and then do the thermal noise removal, whereby I wrote the functions based on keywords from SNAP and also the script on GitHub (https://github.com/wajuqi/Sentinel-1-preprocessing-using-Snappy/blob/dfa9cb71b3b487c5adabca45a25a492e86520257/s1_preprocessing.py).

The apply orbit file function looks as follows:

def do_apply_orbit_file(source):
parameters = HashMap()
parameters.put(“OrbitStateVectors”, “SentinelPrecise”)
parameters.put(“PolynomialDegree”,3)
output = GPF.createProduct(‘Apply-Orbit-File’, parameters, source)
return output

This function appears to be working.
Afterward, I apply the following function for the thermal noise removal:

def do_thermal_noise_removal(source):
parameters = HashMap()
parameters.put(“Selected_Polarisations”,“VH,VV”)
parameters.put(“RemoveThermalNoise”, True)
output = GPF.createProduct(“ThermalNoiseRemoval”,parameters,source)

This function, however, returns the following error:
RuntimeError: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException

Have I written the functions properly? I am not proficient in JAVA, so I do not know if I am using the HashMap() correctly. Any comments on the way the functions are written, and on how the output works are greatly appreciated.
@ABraun @arnab @marpet

P.S: I have a couple more functions that do not work, as well as two more that do.

Working:
def do_calibration(source):
parameters = HashMap()
parameters.put(“outputBetaBand”,True)
parameters.put(“selectedPolarisations”,“VH,VV”)
output = GPF.createProduct(“Calibration”, parameters, source)
return output

def do_subset(source, wkt):
parameters = HashMap()
parameters.put(‘geoRegion’, wkt)
output = GPF.createProduct(‘Subset’, parameters, source)
return output

Not Working:
def do_terrain_flattening(source):
parameters = HashMap()
parameters.put(“SourceBands”,“Beta0_VH,Beta0_VV”)
parameters.put(“DigitalElevationModel”,“SRTM1SecHGT”)
parameters.put(“DEMResamplingMethod”,“BILINEAR_INTERPOLATION”)
parameters.put(“AdditionalOverlapPercentage”,0.1)
parameters.put(“OversamplingMultiple”,1.5)
output = GPF.createProduct(“Terrain-Flattening”,parameters,source)

def do_terrain_correction(source):
parameters = HashMap()
parameters.put(“SourceBands”,“Gamma0_VH,Gamma0_VV”)
parameters.put(“DigitalElevationModel”,“SRTM1SecHGT”)
parameters.put(“DEMResamplingMethod”,“BILINEAR_INTERPOLATION”)
parameters.put(“imgResamplingMethod”,“BILINEAR_INTERPOLATION”)
parameters.put(“PixelSpacing(m)”,10.01)
parameters.put(“PixelSpacing(deg)”,8.992135994036409E-5)
parameters.put(“MapProjection”,“WGS84(DD)”)
parameters.put(“Selectsourceband”,True)
parameters.put(“DEM”,True)
parameters.put(“Latitude&Longitude”,True)
parameters.put(“Incidenceanglefromellipsoid”,True)
parameters.put(“Localinscidenceangle”,True)
parameters.put(“Projectedlocalincidenceangle”,True)
output = GPF.createProduct(“Terrain-Correction”,parameters,source)

Both of these return “NoneType” objects an output.