Can't process some tiles, Sen2Cor IndexError: list index out of range

Hi everyone,

I noticed that some tiles can’t be processed with Sen2Cor. I’m using version 2.4.0 and I’m tring to process tile S2B_MSIL1C_20171109T00109_N0206_R073_T55HDA_20171109T165835.SAFE

The following error ocurrs:

Sentinel-2 Level 2A Processor (Sen2Cor), 2.4.0, created: 2017.06.05 started …
no resolution specified, will process all resolutions.
Process L2A_ProcessTile-1:
Traceback (most recent call last):
File “/home/rasdaman/Sen2Cor-2.4.0-Linux64/lib/python2.7/multiprocessing/process.py”, line 258, in bootstrap
self.run()
File “/home/rasdaman/Sen2Cor-2.4.0-Linux64/lib/python2.7/site-packages/sen2cor/L2A_ProcessTile.py”, line 121, in run
if self.process_60() == False:
File “/home/rasdaman/Sen2Cor-2.4.0-Linux64/lib/python2.7/site-packages/sen2cor/L2A_ProcessTile.py”, line 146, in process_60
self.tables = L2A_Tables(self.config)
File “/home/rasdaman/Sen2Cor-2.4.0-Linux64/lib/python2.7/site-packages/sen2cor/L2A_Tables.py”, line 163, in init
t2a_split[2] + '
’ + t2a_split[1] + ‘_’ + t1c_split[10]
IndexError: list index out of range

I made sure I downloaded the product completely, I even downloaded the same product from AWS. Same error…
Anyone got any clues?

Cheers,
Ognjen

On further analysis, I found out the following:

By adding
print(t1c_split)
print(t2a_split)

below line 158 in file Sen2Cor-2.4.0-Linux64/lib/python2.7/site-packages/sen2cor/L2A_Tables.py , i found out the difference in the tiles that are working with L2A_Process and the ones throwing an error. Here are the 2 different outputs of print(t1c_split) statement:
[‘S2B’, ‘OPER’, ‘MSI’, ‘L1C’, ‘TL’, ‘SGS’, ‘’, ‘20170920T031613’, ‘A002816’, ‘T55JGH’, ‘N02.05’]
[‘S2B’, ‘OPER’, ‘MSI’, ‘L1C’, ‘TL’, ‘EPAE’, ‘20171109T165835’, ‘A003531’, ‘T55JGL’, ‘N02.06’]

So, I see that in the upper case there are 11 items in the list (there is one empty item at position 7 > ‘’), while in the lower there are only 10, hence the t1csplit[10] throws an IndexError. So i changed t1csplit[10] in line 163 to t1csplit[-1] and this appears to solve the issue.

6 Likes

Thanks a ton Ognjen - your solution worked on my end. Curiously sen2cor worked flawlessly from SNAP when I first upgraded to 6.0, but today I experienced this issue.

Hello, I’m Portuguese, my English is not good.

I tried this alternative and I did not succeed. Could you share how you got the code on line 163?

Thank you

I have the same error in Sen2cor 2.4.0

@ngerrells Glad I helped :slight_smile:

This is how I edited the code in L2A_Tables.py:
self.tileId2a = t1c_split[0] + ‘USER’ + t1c_split[2] + '’ + t2a_split[0] + ‘’ +
t1c_split[4] + '
’ + t1c_split[5] + ‘’ + t2a_split[3] + '’ +
t2a_split[2] + ‘’ + t2a_split[1] + '’ + t1c_split[-1]

Cheers,
Ognjen

1 Like

@Ognjen
Thanks for your help, I have sloven my question.
Have a nice day!

HI everyone !

I’ve been trying to compute Sen2Cor on line command.
First of all, I tried with a 10 m resolution. My path to images is correct, but I got this ‘AttributeError’.
May I ask for your help plz ?

C:\WINDOWS\system32>L2A_Process --resolution 10 C:\Users\arnau\Downloads\S2B_MSIL1C_20180130T071129_N0206_R106_T39RXP_20180130T082434\S2B_MSIL1C_20180130T071129_N0206_R106_T39RXP_20180130T082434.SAFE

Sentinel-2 Level 2A Processor (Sen2Cor), 2.4.0, created: 2017.06.05 started …
selected resolution is 10 m.
Syntax error in metadata, see report file for details.
Parsing error:
Schema file: S2-PDGS-TAS-DI-PSD-V14.2_Schema\S2_PDI_Level-2A_Datastrip_Metadata.xsd
Details: Element ‘{https://psd-14.sentinel2.eo.esa.int/PSD/S2_PDI_Level-2A_Datastrip_Metadata.xsd}Level-2A_DataStrip_ID’: No matching global declaration available for the validation root. (line 0)
Progress[%]: 0.26 : PID-17440, 20 m resolution must be processed first, elapsed time[s]: 8.530
Syntax error in metadata, see report file for details.
Parsing error:
Schema file: S2-PDGS-TAS-DI-PSD-V14.2_Schema\S2_PDI_Level-2A_Datastrip_Metadata.xsd
Details: Element ‘{https://psd-14.sentinel2.eo.esa.int/PSD/S2_PDI_Level-2A_Datastrip_Metadata.xsd}Level-2A_DataStrip_ID’: No matching global declaration available for the validation root. (line 0)
Process L2A_ProcessTile-1:
Traceback (most recent call last):
File “C:\ProgramData\Anaconda2\lib\multiprocessing\process.py”, line 258, in _bootstrap
self.run()
File “C:\ProgramData\Anaconda2\lib\site-packages\sen2cor-2.4.0-py2.7.egg\sen2cor\L2A_ProcessTile.py”, line 135, in run
if self.process_10() == False:
File “C:\ProgramData\Anaconda2\lib\site-packages\sen2cor-2.4.0-py2.7.egg\sen2cor\L2A_ProcessTile.py”, line 178, in process_10
if not self.process_20():
File “C:\ProgramData\Anaconda2\lib\site-packages\sen2cor-2.4.0-py2.7.egg\sen2cor\L2A_ProcessTile.py”, line 157, in process_20
return self.process()
File “C:\ProgramData\Anaconda2\lib\site-packages\sen2cor-2.4.0-py2.7.egg\sen2cor\L2A_ProcessTile.py”, line 187, in process
self.config.readTileMetadata()
File “C:\ProgramData\Anaconda2\lib\site-packages\sen2cor-2.4.0-py2.7.egg\sen2cor\L2A_Config.py”, line 4465, in readTileMetadata
self.acquisitionDate = st.text
AttributeError: ‘bool’ object has no attribute ‘text’

Some issues are also faced by me when I am using the 10m resolution as an output. Showing the error of metadata and in the output, few bands are not included.

I would believe this is a major bug in the parsing of the files.

I am currently looking into the code and I don’t think this ‘pythonesque’ list comprehension trick works
Because if one parsing should be empty and is absent in the list, everything is shifted after index 6 in t1csplit or whatever you sparse afterwards. It is just lucky that t1csplit is not used for indexes 6,7 and 8. I suppose this bug should be corrected. Either in the entry file or in the python code

The second error is also weird… TiOld cannot have a value user (text) because it is a boolean of value ‘False’ in my case.
I figured out that this was due to former errors in building the aborted S2A_L2A folders. Delete the folders and you will go forward

Then you have an error message linked with the a variable in the xml metadata
You can find out here about it
However I have tried the suggested correction and I still have the same xml error.

Schema file: S2-PDGS-TAS-DI-PSD-V14.2_Schema/S2_PDI_Level-2A_Tile_Metadata.xsd
Details: Element ‘{https://psd-14.sentinel2.eo.esa.int/PSD/S2_PDI_Level-2A_Tile_Metadata.xsd}Level-2A_Tile_ID’: No matching global declaration available for the validation root.

Seems like quite a few cascading problems

Hope that helps a bit

good! it worked for me too…
Thanks,

i have problem like this. where you enter this code (mean which place i need to insert this code)