OpenJPEG and no such child: Granule errors

Hello. I am new to using SNAP and sen2cor. My advisor suggested that I use Sentinel-2 data for my thesis work and part of it requires the use of this tool. I have a clean install on a Windows 10 desktop and consistently receive the follow errors no matter which .SAFE I select. I also have selected not to downsample 20 to 60:

image

yet in the output it says:

20 m resolution will be downsampled to 60 m

which doesn’t make sense to me, but more importantly, things seem to otherwise progress well enough until near the end and I start getting these errors:

Progress[%]: 27.64 : PID-24700, L2A_Tables: start export for 20 m resolution, elapsed time[s]: 0.005, total: 0:11:58.683000
OpenJPEG function failure.
Traceback (most recent call last):
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_Tables.py”, line 2446, in exportBandList
self.glymurWrapper(filename, band)
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_Tables.py”, line 2606, in glymurWrapper
*glymur.Jp2k(filename, band, *kwargs)
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\lib\site-packages\glymur\jp2k.py”, line 177, in __init__
*self._write(data, *kwargs)
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\lib\site-packages\glymur\jp2k.py”, line 539, in _write
self._write_openjp2(img_array, verbose=verbose)
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\lib\site-packages\glymur\jp2k.py”, line 783, in _write_openjp2
opj2.start_compress(codec, image, strm)
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\lib\site-packages\glymur\lib\openjp2.py”, line 1299, in start_compress
OPENJP2.opj_start_compress(codec, image, stream)
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\lib\site-packages\glymur\lib\openjp2.py”, line 594, in check_error
raise OpenJPEGLibraryError(“OpenJPEG function failure.”)
OpenJPEGLibraryError: OpenJPEG function failure.
Progress[%]: 27.65 : PID-24700, L2A_Tables: preparing downsampled export for 60 m resolution, elapsed time[s]: 0.106, total: 0:11:58.789000
Progress[%]: 27.65 : PID-24700, L2A_Tables: start export for 60 m resolution, elapsed time[s]: 0.005, total: 0:11:58.794000
no such child: Granule
Traceback (most recent call last):
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_Process.py”, line 495, in main
if tile.process() == True:
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_ProcessTileToolbox.py”, line 118, in process
if not self.process_resolution(20):
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_ProcessTileToolbox.py”, line 148, in process_resolution
return self._process()
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_ProcessTileToolbox.py”, line 192, in _process
if self.postprocess() == False:
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_ProcessTileToolbox.py”, line 263, in postprocess
self.tables.downsampleBandList_20to60_andExport()
File “C:\Users\XXXX.snap\auxdata\Sen2Cor-02.08.00-win64\Lib\site-packages\sen2cor\L2A_Tables.py”, line 2187, in downsampleBandList_20to60_andExport
Granule = pi.Product_Organisation.Granule_List.Granule
File “src/lxml/lxml.objectify.pyx”, line 229, in lxml.objectify.ObjectifiedElement.__getattr__ (src\lxml\lxml.objectify.c:3835)
File “src/lxml/lxml.objectify.pyx”, line 450, in lxml.objectify._lookupChildOrRaise (src\lxml\lxml.objectify.c:6539)
AttributeError: no such child: Granule
Progress[%]: 100.00 : Application terminated with at least one error.
Finished tool execution in 724 seconds

I have attempted to uninstall and reinstall both SNAP as a whole as well as the sen2cor plugins. I have tried both 2.8.0 (what my advisor uses and suggested) and 2.9.0 (latest available to me to download). 2.9.0 fails instantly with

“wrong identifier for xml structure.
unspecific error in metadata
Syntax error in metadata, see report file for details.”

Though, it is a .SAFE and using the .xml within it as instructed.

2.8.0 gives me the best output so far, I DO actually get an output directory, though it is incomplete due to the errors mentioned above.

I would appreciate any insight on how to get beyond these issues. I have a month until the end of the semester when all my data needs to be corrected.
Thank you.

I’m still at a complete loss. The errors continue without fail, no matter what I try. Any thoughts or suggestions would be greatly appreciated.

What did you select as the output format? BEAM-DiMap is currently the safest.

@Amalia-Castro-Gomez could you investigate?

Again, I’m new with this, so I apologize for my lack of knowledge but I don’t have any options for output in the sen2cor screen that pops up. Where do I set that?

image

Dear cpyywhite,

I imagine you are already doing it, but a general advice is to unzip the S2 L1C product and to not apply any other processing step to the dataset before using it as input for Sen2Cor. Then, inside the Sen2Cor tool, in I/O Parameters, you could try using as input the MTD_MSIL1C.xml file that is inside your unzipped S2 L1C product.

I am going to take a bit more time to explore this in detail.

In the meantime, could we get your advice @marpet ? What do you think is happening?

Yes, the MTD_MSIL1C.xml is the file I am selecting:

Should I be selecting it another way?

Hi cpyywhite,

There is already a version 2.10 available. It is available here: Sen2Cor – STEP (esa.int)

Using BEAM-DIMAP as output format is not working.
Sen2Cor is an external tool and does not use the SNAP functionality. SNAP is only providing a way to invoke the tool via a graphical user interface. Sen2Cor writes its own format. It is like the SAFE format.

This issue has been reported already multiple times:
Search results for ‘AttributeError: no such child: Granule’ - STEP Forum (esa.int)

For the latest version 2.10.1 there seems to be an issue in the source code, respectively there is a library missing. At least the following threads are indicating this

It seems that it works in some cases and in others not. Otherwise, there would have been more reports.

I think the sen2cor teams need to have a look at it.

In the meantime, cppywhite, you can try to call sen2cor directly from the command line. This removes the tool wrapper and thereby one source of possible errors.

Thank you. I did read the manual and saw the command line section but found it a little hard to follow and understand what the correct syntax was that I needed.

Yes, I know. It is not simple to use.