Ok. Now I’m sure. Something is wrong somewhere. The operators I’m ineterested in are Resample, Reproject, Subset and Rad2Ref. So, there are a few arguments I’d like to discuss…
- I have the following script:
#!/usr/bin/python
coding: utf8
import snappy
from snappy import GPF
‘’’
def get_snap_info(operator):
“”"
Returns information about SNAP operators and their parameters
“”"
op_spi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operator)
print(‘Op name:’, op_spi.getOperatorDescriptor().getName())
print(‘Op alias:’, op_spi.getOperatorDescriptor().getAlias())
param_Desc = op_spi.getOperatorDescriptor().getParameterDescriptors()
for param in param_Desc:
print(param.getName(), “or”, param.getAlias())
print “BandMaths”
get_snap_info(“BandMaths”)
‘’’
inp = snappy.ProductIO.readProduct("/MyPath/S3B_SL_1_RBT____20190219T092217_20190219T092517_20190219T113119_0179_022_150_2160_MAR_O_NR_003.SEN3/xfdumanifest.xml")
2. Set parameters
Rad2Refl:
HashMap = snappy.jpy.get_type(‘java.util.HashMap’)
parRad = HashMap()
parRad.put(“sensor”, “SLSTR_500m”)
parRad.put(“conversionMode”, “RAD_TO_REFL”)
parRad.put(“copyTiePointGrids”, “false”)
parRad.put(“copyFlagBandsAndMasks”, “false”)
parRad.put(“copyNonSpectralBands”, “false”)
Resample:
parResam = HashMap()
parResam.put(“targetWidth”, 3000)
parResam.put(“targetHeight”, 2400)
parResam.put(“upsampling”, “Nearest”)
parResam.put(“downsampling”, “First”)
parResam.put(“flagDownsampling”, “First”)
parResam.put(“resampleOnPyramidLevels”, “true”)
Reproject:
parProj = HashMap()
parProj.put(“crs”, ‘PROJCS[“WGS 84 / UTM zone 32N”, GEOGCS[“WGS 84”, DATUM[“World Geodetic System 1984”, SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]], AUTHORITY[“EPSG”,“6326”]], PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]], UNIT[“degree”, 0.017453292519943295], AXIS[“Geodetic longitude”, EAST], AXIS[“Geodetic latitude”, NORTH], AUTHORITY[“EPSG”,“4326”]], PROJECTION[“Transverse_Mercator”, AUTHORITY[“EPSG”,“9807”]], PARAMETER[“central_meridian”, 9.0], PARAMETER[“latitude_of_origin”, 0.0], PARAMETER[“scale_factor”, 0.9996], PARAMETER[“false_easting”, 500000.0], PARAMETER[“false_northing”, 0.0], UNIT[“m”, 1.0], AXIS[“Easting”, EAST], AXIS[“Northing”, NORTH], AUTHORITY[“EPSG”,“32632”]]’)
parProj.put(“resampling”, “Nearest”)
parProj.put(“orthorectify”, “false”)
parProj.put(“noDataValue”, -32768.0)
parProj.put(“includeTiePointGrids”, “true”)
parProj.put(“addDeltaBands”, “false”)
Subset:
parSub1 = HashMap()
parSub1.put(“bandNames”, “S1_reflectance_an,S2_reflectance_an,S3_reflectance_an,S5_reflectance_an,S6_reflectance_an”)
parSub1.put(“copyMetadata”, “true”)
outResam = GPF.createProduct(“Resample”, parResam, inp)
outRad = GPF.createProduct(“Rad2Refl”, parRad, outResam)
outSub1 = GPF.createProduct(“Subset”, parSub1, outRad)
outProj = GPF.createProduct(“Reproject”, parProj, outSub1)
outSub2 = GPF.createProduct(“Subset”, parSub1, outProj)
print “End”
I noticed that when I uncomment the first part (lines 7-22), I get the error:
outRad = GPF.createProduct(“Rad2Refl”, parRad, outResam)
RuntimeError: org.esa.snap.core.gpf.OperatorException: Sensor ‘SLSTR 500m’ not compliant with input product. Please check your selection.
while when they are commented out everything is working fine. I’m not sure it should work like that. I’m not changing the input, am I?
-
The above code is part of two scripts of mine one that is almost identical to the above and another one a little longer (it has a few other features as well). Yesterday evening I run both, the smaller one worked fine and the longer one gave me the error mentioned above. I tried several times both and I checked that the part of the 4 operators was identical between the scripts. This morning I run them again, without changing anything and none of them worked. I find this strange and it reminded me this topic: Best practice to convert and reproject Sentinel-3 radiances to reflectance, talking, unfortunately, about the same operator (Rad2Ref), although regarding a different aspect. Marpet is telling somewhere that there was a bug presented randomly and I thought it could apply to my case too. Just in case, I run snappy on windows and I have recently installed it so I have SNAP version 6.
-
I’ve noticed that Subset and Reproject don’t work directly with the .xml (which contains bands of different spatial resolution), without resampling first. It would be more practical if they worked even on mixed products so that people wouldn’t have to repeat the operators twice, once for the 500m and once for the 1Km bands…
-
I’ve tried two different workflows on snappy:
Resample -> Rad2Ref -> Subset -> Reprojet -> Subset
and
Resample -> Reproject ->Rad2Ref -> Subset
and although none gives me an error, the second one gives me wrong results. The radiances haven’t been divided by 10.000 and even if I manually divide the result, some points still present differences that go from -0.7077 to 0.6235 (quite high for a variable that should stay within [0,1] (reflectance)).
Finished!! I’m sorry for the giant post. I just wanted to share my probably insignificant observations with everyone, in case snappy has made others too getting doubts on their mental health…
Have a nice day.