ubarsc / python-fmask

A set of command line utilities and Python modules that implement the ‘fmask’ algorithm
https://www.pythonfmask.org
GNU General Public License v3.0
74 stars 21 forks source link

Why does the package not work with Sentinel 2A? #35

Closed diogocaribe closed 4 years ago

diogocaribe commented 4 years ago

I would like to run fmask with Sentinel 2A. Theoretically speaking, is there any problem?

neilflood commented 4 years ago

The package works fine with Sentinel-2A.

If you have a problem, please give full details.

  1. The command you are running which causes problems
  2. The error message you get
  3. The version of python-fmask
  4. The commands you used to install it.
diogocaribe commented 4 years ago

Thanks for your help.

See the answers above:

  1. The command you are running which causes problems
    1. The error message you get
~/workspace/python-fmask$ fmask_sentinel2Stacked.py -o cloud2A.img --safedir ./img_files/S2A_MSIL2A_20200111T125301_N0213_R052_T24LXN_20200111T144307.SAFE
Traceback (most recent call last):
  File "/home/diogo/.ve/fmask/bin/fmask_sentinel2Stacked.py", line 22, in <module>
    sentinel2Stacked.mainRoutine()
  File "/home/diogo/.ve/fmask/lib/python3.8/site-packages/fmask/cmdline/sentinel2Stacked.py", line 285, in mainRoutine
    resampledBands = makeStackAndAngles(cmdargs)
  File "/home/diogo/.ve/fmask/lib/python3.8/site-packages/fmask/cmdline/sentinel2Stacked.py", line 165, in makeStackAndAngles
    cmdargs.granuledir = findGranuleDir(cmdargs.safedir)
  File "/home/diogo/.ve/fmask/lib/python3.8/site-packages/fmask/cmdline/sentinel2Stacked.py", line 251, in findGranuleDir
    raise fmaskerrors.FmaskFileError("Unable to find GRANULE sub-directory {}".format(granuleDirPattern))
fmask.fmaskerrors.FmaskFileError: Unable to find GRANULE sub-directory ./img_files/S2A_MSIL2A_20200111T125301_N0213_R052_T24LXN_20200111T144307.SAFE/GRANULE/L1C_*
  1. The version of python-fmask 0.5.4

  2. The commands you used to install it. python setup.py build python setup.py install

neilflood commented 4 years ago

The Fmask algorithm only works with the Level-1C data from ESA. It requires all of the bands available in that.

The file you are using is the Level-2A data. You will need to download the L1C product in order to run python-fmask. At the moment, there is no way to adapt it to work with L2A.

The code and documentation was written before the L2A product existed, but your question has raised a good point. I should add to the documentation to make this clearer, and try to add an error message about it.

thank you.

diogocaribe commented 4 years ago

I debug the code and what I saw is that the sentinel2Stacked.py has some problems in order to find files. From Level 1C to 2A the difference is that GRANULE folder organize files by pixel resolution. So, if there is not things, theoretically speaking, in order to run in Level 2A I believe that change the input from sentinel2Stacked.py will fix the problem. What do you think about it?

neilflood commented 4 years ago

This will not work. The Level-2A product does not include the Cirrus band, which is fairly important in the Sentinel version of the algorithm.

diogocaribe commented 4 years ago

The band that you are talking is B10 - SWIR - CIRRUS with 20 meters? I can see it in .SAFE folder.

Screenshot from 2020-03-17 18-08-55

neilflood commented 4 years ago

I cannot see band 10. The one highlighted in the screenshot is band 11.

If you read here https://sentinel.esa.int/web/sentinel/user-guides/sentinel-2-msi/processing-levels/level-2 it also says explicitly that the cirrus band is omitted from the surface reflectance product, as it does not contain surface information.

diogocaribe commented 4 years ago

Ohhh God. Am I becoming crazy? Yes. For fure. It wasn't there. Thks