Workaround for sen2cor bug at resolution 10 m

Thank you for the response but if I include the spaces I get the below therefor the reason why I left out the spaces?

Just to tell everyone that this method also works for me. Thank you ChristianSeverin!

the entire method body of postprocess() needs to be indented relative to the def postprocess(self) line

Hi Christian,

Thank you I have managed to correct all the spaces, looking good so far, will advise on the outcome. Thank you again.

not sure what occurred now, has anyone came across this error?

full report :
C:\Users\Riyaadh>L2A_Process --resolution 10 C:\S2A_OPER_PRD_MSIL1C_PDMC_2016020
6T201011_R121_V20160206T084754_20160206T084754.SAFE

Sentinel-2 Level 2A Prototype Processor (Sen2Cor), 2.0.6, created: 2015.12.02 st
arted …
check if 20m table exists …
check if 60m table exists…
Validating metadata file S2A_OPER_MTD_L1C_TL_SGS__20160206T154949_A003264_T33HYB
.xml against scheme …
Metadata file is valid.
L2A_Process: processing with resolution 60 m, elapsed time[s]: 1.576
Progress[%]: 0.11 : L2A_Process: start of pre processing, elapsed time[s]: 0.016

Progress[%]: 0.11 : Validating metadata file S2A_OPER_MTD_SAFL1C_PDMC_20160206T2
01011_R121_V20160206T084754_20160206T084754.xml against scheme …
Metadata file is invalid, see logfile for details.
Validating metadata file S2A_OPER_MTD_L1C_TL_SGS__20160206T154949_A003264_T33HYB
.xml against scheme …
Metadata file is valid.
Validating metadata file S2A_OPER_MTD_L1C_DS_SGS__20160206T154949_S20160206T0847
54.xml against scheme …
Metadata file is valid.
L2A_Tables: start import, elapsed time[s]: 0.592
Progress[%]: 0.04 : L2A_Tables: band B01 imported, elapsed time[s]: 1.139
Progress[%]: 0.12 : L2A_Tables: band B02 imported, elapsed time[s]: 7.457
Progress[%]: 0.61 : L2A_Tables: band B03 imported, elapsed time[s]: 7.535
Progress[%]: 1.11 : L2A_Tables: band B04 imported, elapsed time[s]: 7.581
Progress[%]: 1.62 : L2A_Tables: band B05 imported, elapsed time[s]: 2.418
Progress[%]: 1.78 : L2A_Tables: band B06 imported, elapsed time[s]: 2.403
Progress[%]: 1.94 : L2A_Tables: band B07 imported, elapsed time[s]: 2.465
Progress[%]: 2.11 : L2A_Tables: band B8A imported, elapsed time[s]: 2.496
Progress[%]: 2.27 : L2A_Tables: band B09 imported, elapsed time[s]: 0.982
Progress[%]: 2.34 : L2A_Tables: band B10 imported, elapsed time[s]: 0.593
Progress[%]: 2.38 : L2A_Tables: band B11 imported, elapsed time[s]: 2.449
Progress[%]: 2.54 : L2A_Tables: band B12 imported, elapsed time[s]: 2.637
Progress[%]: 2.72 : L2A_Tables: stop import, elapsed time[s]: 0.000
Progress[%]: 2.72 : L2A_Process: start of Scene Classification, elapsed time[s]:
0.015
Progress[%]: 2.72 : Pre process , elapsed time[s]: 0.234
Progress[%]: 2.73 : L2A_SC init , elapsed time[s]: 0.156
Progress[%]: 2.74 : L2A_CSND_1_1 , elapsed time[s]: 0.281
Progress[%]: 2.76 : L2A_CSND_1_2 , elapsed time[s]: 0.219
Progress[%]: 2.78 : L2A_CSND_3 , elapsed time[s]: 1.185
Progress[%]: 2.86 : L2A_CSND_4 , elapsed time[s]: 0.234
Progress[%]: 2.87 : L2A_CSHD_5_1 , elapsed time[s]: 0.312
Progress[%]: 2.89 : L2A_CSND_5_2 , elapsed time[s]: 0.421
Progress[%]: 2.92 : L2A_CSND_6 , elapsed time[s]: 0.203
Progress[%]: 2.93 : L2A_CSND_7 , elapsed time[s]: 0.203
Progress[%]: 2.95 : L2A_SHD , elapsed time[s]: 2.730
Progress[%]: 3.13 : Soil recovery, elapsed time[s]: 0.125
Progress[%]: 3.14 : DV recovery , elapsed time[s]: 0.249
Progress[%]: 3.15 : WP recovery , elapsed time[s]: 0.141
Progress[%]: 3.16 : Post process , elapsed time[s]: 0.577
Progress[%]: 3.20 : L2A_Process: start of Atmospheric Correction, elapsed time[s ]: 0.000
Progress[%]: 3.20 : L2A_AtmCorr: starting data processing, elapsed time[s]: 0.04
7
Progress[%]: 3.21 : L2A_AtmCorr: end of calculation terrain maps, elapsed time[s ]: 0.249
Progress[%]: 3.22 : L2A_AtmCorr: start of AOT retrieval at 550nm, elapsed time[s ]: 0.000
Progress[%]: 3.22 : L2A_AtmCorr: end of AOT retrieval at 550nm, elapsed time[s]:
0.624
Progress[%]: 3.26 : L2A_AtmCorr: end of internal classification, elapsed time[s]
: 1.295
Progress[%]: 3.35 : L2A_AtmCorr: end of interpolation LUTs, elapsed time[s]: 0.5
58
Progress[%]: 3.39 : L2A_AtmCorr: end retreiving reference pixels for dark areas,
elapsed time[s]: 0.000
Progress[%]: 3.39 : L2A_AtmCorr: end of check for dense bright vegetation pixels
, elapsed time[s]: 4.134
Progress[%]: 3.66 : L2A_AtmCorr: end of receiving atmospheric functions for all
altitudes and visibilities, elapsed time[s]: 0.983
Progress[%]: 3.73 : L2A_AtmCorr: start of WV retrieval, elapsed time[s]: 0.000
Progress[%]: 3.73 : L2A_AtmCorr: end of WV retrieval preparation, elapsed time[s ]: 0.920
Progress[%]: 3.79 : L2A_AtmCorr: end of WV retrieval, elapsed time[s]: 17.662
Progress[%]: 4.97 : L2A_AtmCorr: start of rho retrieval, elapsed time[s]: 0.000
Progress[%]: 4.97 : L2A_AtmCorr: end of rho retrieval preparation, elapsed time[
s]: 4.134
Progress[%]: 5.24 : L2A_AtmCorr: end of rho retrieval step 1, elapsed time[s]: 1
7.105
Progress[%]: 6.38 : L2A_AtmCorr: end of rho retrieval step 2, elapsed time[s]: 7
.116
Progress[%]: 6.86 : L2A_Process: start of post processing, elapsed time[s]: 0.01
6
Progress[%]: 6.86 : L2A_Tables: start export, elapsed time[s]: 0.000
Progress[%]: 6.86 : L2A_Tables: band B01 exported, elapsed time[s]: 1.310
Progress[%]: 6.95 : L2A_Tables: band B02 exported, elapsed time[s]: 1.342
Progress[%]: 7.04 : L2A_Tables: band B03 exported, elapsed time[s]: 1.331
Progress[%]: 7.12 : L2A_Tables: band B04 exported, elapsed time[s]: 1.314
Progress[%]: 7.21 : L2A_Tables: band B05 exported, elapsed time[s]: 1.396
Progress[%]: 7.30 : L2A_Tables: band B06 exported, elapsed time[s]: 1.357
Progress[%]: 7.39 : L2A_Tables: band B07 exported, elapsed time[s]: 1.282
Progress[%]: 7.48 : L2A_Tables: band B8A exported, elapsed time[s]: 1.331
Progress[%]: 7.57 : L2A_Tables: band B09 exported, elapsed time[s]: 1.201
Progress[%]: 7.65 : L2A_Tables: band B11 exported, elapsed time[s]: 1.248
Progress[%]: 7.73 : L2A_Tables: band B12 exported, elapsed time[s]: 1.186
Progress[%]: 7.81 : L2A_Tables: band SCL exported, elapsed time[s]: 0.327
Progress[%]: 7.83 : L2A_Tables: band SNW exported, elapsed time[s]: 0.094
Progress[%]: 7.84 : L2A_Tables: band CLD exported, elapsed time[s]: 0.390
Progress[%]: 7.87 : L2A_Tables: band AOT exported, elapsed time[s]: 0.156
Progress[%]: 7.88 : L2A_Tables: band WVP exported, elapsed time[s]: 0.655
Progress[%]: 7.92 : L2A_Tables: band VIS exported, elapsed time[s]: 0.109
Progress[%]: 7.93 : L2A_Tables: preview image exported, elapsed time[s]: 0.266
Progress[%]: 7.94 : L2A_Tables: stop export, elapsed time[s]: 0.031
Progress[%]: 7.95 : Validating metadata file S2A_USER_MTD_SAFL2A_PDMC_20160206T2
01011_R121_V20160206T084754_20160206T084754.xml against scheme …
Metadata file is invalid, see logfile for details.
Validating metadata file S2A_USER_MTD_L2A_TL_SGS__20160206T154949_A003264_T33HYB
.xml against scheme …
Metadata file is invalid, see logfile for details.
Validating metadata file S2A_USER_MTD_L2A_DS_SGS__20160206T154949_S20160206T0847
54.xml against scheme …
Metadata file is valid.
L2A_Process: processing with resolution 20 m, elapsed time[s]: 0.468
Progress[%]: 7.98 : L2A_Process: start of pre processing, elapsed time[s]: 0.000

Progress[%]: 7.98 : Validating metadata file S2A_OPER_MTD_SAFL1C_PDMC_20160206T2
01011_R121_V20160206T084754_20160206T084754.xml against scheme …
Metadata file is invalid, see logfile for details.
Validating metadata file S2A_OPER_MTD_L1C_TL_SGS__20160206T154949_A003264_T33HYB
.xml against scheme …
Metadata file is valid.
Validating metadata file S2A_OPER_MTD_L1C_DS_SGS__20160206T154949_S20160206T0847
54.xml against scheme …
Metadata file is valid.
L2A_Tables: start import, elapsed time[s]: 0.577
Progress[%]: 0.04 : L2A_Tables: band B01 imported, elapsed time[s]: 5.288
Progress[%]: 0.39 : L2A_Tables: band B02 imported, elapsed time[s]: 8.440
Progress[%]: 0.95 : L2A_Tables: band B03 imported, elapsed time[s]: 8.758
Progress[%]: 1.54 : L2A_Tables: band B04 imported, elapsed time[s]: 8.671
Progress[%]: 2.12 : L2A_Tables: band B05 imported, elapsed time[s]: 8.979
Progress[%]: 2.71 : L2A_Tables: band B06 imported, elapsed time[s]: 8.743
Progress[%]: 3.30 : L2A_Tables: band B07 imported, elapsed time[s]: 8.736
Progress[%]: 3.88 : L2A_Tables: band B8A imported, elapsed time[s]: 8.767
Progress[%]: 4.46 : L2A_Tables: band B09 imported, elapsed time[s]: 5.054
Progress[%]: 4.80 : L2A_Tables: band B10 imported, elapsed time[s]: 4.322
Progress[%]: 5.09 : L2A_Tables: band B11 imported, elapsed time[s]: 12.058
Progress[%]: 5.89 : L2A_Tables: band B12 imported, elapsed time[s]: 8.253
Progress[%]: 6.44 : L2A_Tables: stop import, elapsed time[s]: 0.000
Progress[%]: 6.44 : L2A_Process: start of Scene Classification, elapsed time[s]:
0.016
Progress[%]: 6.44 : Pre process , elapsed time[s]: 0.967
Progress[%]: 6.51 : L2A_SC init , elapsed time[s]: 0.873
Progress[%]: 6.57 : L2A_CSND_1_1 , elapsed time[s]: 1.576
Progress[%]: 6.67 : L2A_CSND_1_2 , elapsed time[s]: 1.794
Progress[%]: 6.79 : L2A_CSND_3 , elapsed time[s]: 2.231
Progress[%]: 6.94 : L2A_CSND_4 , elapsed time[s]: 1.497
Progress[%]: 7.04 : L2A_CSHD_5_1 , elapsed time[s]: 1.919
Progress[%]: 7.17 : L2A_CSND_5_2 , elapsed time[s]: 3.042
Progress[%]: 7.37 : L2A_CSND_6 , elapsed time[s]: 1.611
Progress[%]: 7.48 : L2A_CSND_7 , elapsed time[s]: 1.668
Progress[%]: 7.59 : L2A_SHD , elapsed time[s]: 24.064
Progress[%]: 9.19 : Soil recovery, elapsed time[s]: 1.046
Progress[%]: 9.26 : DV recovery , elapsed time[s]: 1.872
Progress[%]: 9.39 : WP recovery , elapsed time[s]: 1.045
Progress[%]: 9.46 : Post process , elapsed time[s]: 3.779
Progress[%]: 9.71 : L2A_Process: start of Atmospheric Correction, elapsed time[s ]: 0.000
Progress[%]: 9.71 : L2A_AtmCorr: starting data processing, elapsed time[s]: 0.03
1
Progress[%]: 9.71 : L2A_AtmCorr: end of calculation terrain maps, elapsed time[s ]: 2.073
Progress[%]: 9.85 : L2A_AtmCorr: start of AOT retrieval at 550nm, elapsed time[s ]: 0.000
Progress[%]: 9.85 : L2A_AtmCorr: end of AOT retrieval at 550nm, elapsed time[s]:
0.562
Progress[%]: 9.89 : L2A_AtmCorr: end of internal classification, elapsed time[s]
: 10.492
Progress[%]: 10.59 : L2A_AtmCorr: end of interpolation LUTs, elapsed time[s]: 0.
561
Progress[%]: 10.62 : L2A_AtmCorr: end retreiving reference pixels for dark areas
, elapsed time[s]: 0.000
Progress[%]: 10.62 : L2A_AtmCorr: end of check for dense bright vegetation pixel
s, elapsed time[s]: 35.209
Progress[%]: 12.97 : L2A_AtmCorr: end of receiving atmospheric functions for all
altitudes and visibilities, elapsed time[s]: 4.509
Progress[%]: 13.27 : L2A_AtmCorr: start of WV retrieval, elapsed time[s]: 0.000
Progress[%]: 13.27 : L2A_AtmCorr: end of WV retrieval preparation, elapsed time[
s]: 3.759
Progress[%]: 13.52 : L2A_AtmCorr: end of WV retrieval, elapsed time[s]: 203.361
Progress[%]: 27.08 : L2A_AtmCorr: start of rho retrieval, elapsed time[s]: 0.000

Progress[%]: 27.08 : L2A_AtmCorr: end of rho retrieval preparation, elapsed time
[s]: 5.679
Progress[%]: 27.46 : L2A_AtmCorr: end of rho retrieval step 1, elapsed time[s]:
152.908
Progress[%]: 37.65 : L2A_AtmCorr: end of rho retrieval step 2, elapsed time[s]:
50.705
Progress[%]: 41.03 : L2A_Process: start of post processing, elapsed time[s]: 0.0
62
Progress[%]: 41.04 : L2A_Tables: start export, elapsed time[s]: 0.000
Progress[%]: 41.04 : L2A_Tables: band B02 exported, elapsed time[s]: 10.717
Progress[%]: 41.75 : L2A_Tables: band B03 exported, elapsed time[s]: 10.359
Progress[%]: 42.44 : L2A_Tables: band B04 exported, elapsed time[s]: 10.467
Progress[%]: 43.14 : L2A_Tables: band B05 exported, elapsed time[s]: 9.595
Progress[%]: 43.78 : L2A_Tables: band B06 exported, elapsed time[s]: 9.750
Progress[%]: 44.43 : L2A_Tables: band B07 exported, elapsed time[s]: 9.531
Progress[%]: 45.07 : L2A_Tables: band B8A exported, elapsed time[s]: 9.672
Progress[%]: 45.71 : L2A_Tables: band B11 exported, elapsed time[s]: 8.970
Progress[%]: 46.31 : L2A_Tables: band B12 exported, elapsed time[s]: 9.079
Progress[%]: 46.91 : L2A_Tables: band SCL exported, elapsed time[s]: 2.574
Progress[%]: 47.08 : L2A_Tables: band SNW exported, elapsed time[s]: 1.061
Progress[%]: 47.16 : L2A_Tables: band CLD exported, elapsed time[s]: 3.058
Progress[%]: 47.36 : L2A_Tables: band AOT exported, elapsed time[s]: 1.201
Progress[%]: 47.44 : L2A_Tables: band WVP exported, elapsed time[s]: 4.493
Progress[%]: 47.74 : L2A_Tables: band VIS exported, elapsed time[s]: 1.154
Progress[%]: 47.82 : L2A_Tables: stop export, elapsed time[s]: 0.172
Progress[%]: 47.83 : Validating metadata file S2A_USER_MTD_SAFL2A_PDMC_20160206T
201011_R121_V20160206T084754_20160206T084754.xml against scheme …
Metadata file is invalid, see logfile for details.
Validating metadata file S2A_USER_MTD_L2A_TL_SGS__20160206T154949_A003264_T33HYB
.xml against scheme …
Metadata file is invalid, see logfile for details.
Validating metadata file S2A_USER_MTD_L2A_DS_SGS__20160206T154949_S20160206T0847
54.xml against scheme …
Metadata file is valid.
Fatal error occurred, see tracefile for details.

When Running 20m no errors are received with the same L2A Tables

Hi @gaodiansuan, @riyaadh91 @chris

I have done the steps that @ChristianSeverin explained and much appreciated his effort.**
However, I did not get the processed L2B 10 Resolution .
Can some one have alook on the images below and tell me if possible where is my mistakes?
Thanks guys,
D

The command line for cmd was :
L2A_Process --resolution 10 R:\Hi\e\S2A_OPER_PRD_MSIL_1C_PDMC_20151229T185657_R137_V20151229T111920_20151229T111920
then I change the L2A_Tables.py as below:


and the process stopped as it said the file being used by other process !

See below how mine looks there are some differences by the If command, also with Command Prompt I received a fatal error, I used WindowsPowershell to fix the fatal error, sometimes when it seems as if it is freezing, pressing enter resolves this, my 10m is working perfectly, the folder size is 8.4GB.

Thanks a lot @riyaadh91.

However, I compare my script with yours , All the same but I am still getting the message as above!

Any possibility to send me your L2A_Tables.py ? and to describe how exactly I can fix the fatal error ?
Your help and time are much appreciated!
Thanks, D

Hi Daniel,

Not a problem at all, please find attached L2A Tables.L2A_Tables.py (60.4 KB)

Kindly note that the change of Christian is the only updates I have made to my Tables.

Thanks @riyaadh91
It works for me for 20m and 60m but not for the 10m ! any idea why , I am still getting the same message I have posted. any idea how to solve it.
the size of the out put folder for the proccessed L2B for the 20m Resolution is 10.1 MB and for the 60m Resolution is 584 MB . The original L2C folder is 14.5 GB , so is it normal to have less size for the resampled images ?

Thanks again, D

Hi Deniel,

Could you check whether or not you have updated the L2A_Table.py in c:\Anaconda2\lib\site-packages\sen2cor-2.0.6-py2.7.egg\sen2cor\L2A_Table.py , in stead of files with the same name but under other roots?

Hope it helps~

Regards Gao.

Hi Daniel1, I agree with Gaodiansuan, I installed my Anaconda to the default folder though so mine was under C:\Users\Riyaadh\Anaconda2\Lib\site-packages\sen2cor-2.0.6-py2.7.egg\sen2cor. please make sure you are updating the correct L2A_Tables, Like I said previously the 10m never worked for me via command prompt, I had to use WindowsPowershell. also there are 2 ways of running the command, you could either specify L2A_Process –resolution 10 folderlocation or L2A_Process folderlocation --resolution 10 or 20 or 60. Also when you installed Anaconda, did you select for all users as this does not work when doing the conversion as well. I had a similar issue but then forced everything to uninstall then re-installed. If you like I can explain to you the way I removed and re-installed?

Thanks a lot @gaodiansuan and @riyaadh91

@riyaadh91 it has worked after about more than 5 hours processing time with 10m resoultion. The band 8 was there but the strange thing is when I opened the generated product not all the granules bands were generated and some of them are disappeared although I have the 16 granules with their corrected bands (except B10).

Thanks again for your help !
D

@ChristianSeverin

I have changed L2A_Tables as per your instructions but when I process 10 meter resolution by cmd the iI get following error.

C:\Users\Adnan Aziz>L2A_Process --resolution 10 D:\S2A_OPER_PRD_MSIL1C_PDMC_2016
0210T210959_R037_V20160210T112214_20160210T112214
Traceback (most recent call last):
  File "C:\Anaconda2\Scripts\L2A_Process-script.py", line 9, in <module>
    load_entry_point('sen2cor==2.0.6', 'console_scripts', 'L2A_Process')()
  File "C:\Anaconda2\lib\site-packages\sen2cor-2.0.6-py2.7.egg\sen2cor\L2A_Proce
ss.py", line 237, in main
    processor = L2A_Process(directory)
  File "C:\Anaconda2\lib\site-packages\sen2cor-2.0.6-py2.7.egg\sen2cor\L2A_Proce
ss.py", line 21, in __init__
    self._config = L2A_Config(workdir)
  File "C:\Anaconda2\lib\site-packages\sen2cor-2.0.6-py2.7.egg\sen2cor\L2A_Confi
g.py", line 27, in __init__
    self._home = os.environ['SEN2COR_HOME'] + '/'
  File "C:\Anaconda2\lib\os.py", line 425, in __getitem__
    return self.data[key.upper()]
KeyError: 'SEN2COR_HOME'

Kindly Help me

@adnanaziz
Please don’t add questions to old topics; instead please open a new topic for your question. In doing so you get a few suggestions for topics that might answer your question.

Another thing: when posting error messages, it helps to post them as Preformatted Text (see the </> button at the top of the Edit window); otherwise, important details like asterisks ‘*’ or underscores ‘_’ get converted to Markup tags, so that “self._home” shows up as “self.home”. This both looks odd and is incorrect.

I created a new topic with an attempt at an answer for your question here.

Please install the new version of sen2Cor 2.2.1 as can be downloaded from here:

http://step.esa.int/main/third-party-plugins-2/sen2cor/

The new Version has a fix for this problem (among others). Please read the release note for further info on the applied fixes.

how would you know that?

long path tool is very useful tool. i use it and it is very good tool.