Problem to correct Sentinel 2 images

Post Reply
xavi_s
Posts: 7
Joined: Tue Feb 23, 2021 11:57 am
company / institution: Universitat de València
Location: Paterna

Problem to correct Sentinel 2 images

Post by xavi_s »

Sorry, I don't know how solve this error.

Can you help me?


(base) free@free-VirtualBox:~/Documents/polymer-v4.13$ python polymer_cli.py /home/free/Imatges/S2A_MSIL1C_20170208T110211_N0204_R094_T30SXJ_20170208T110245.SAFE
File "polymer_cli.py", line 11, in <module>
from polymer.main import run_atm_corr, Level1, Level2
File "/home/free/Documents/polymer-v4.13/polymer/main.py", line 18, in <module>
from polymer.polymer_main import PolymerMinimizer
ModuleNotFoundError: No module named 'polymer.polymer_main'
User avatar
fsteinmetz
Site Admin
Posts: 306
Joined: Fri Sep 07, 2018 1:34 pm
company / institution: Hygeos
Location: Lille, France
Contact:

Re: Problem to correct Sentinel 2 images

Post by fsteinmetz »

Hello,
Have you compiled the code ?
Cheers,
François
xavi_s
Posts: 7
Joined: Tue Feb 23, 2021 11:57 am
company / institution: Universitat de València
Location: Paterna

Re: Problem to correct Sentinel 2 images

Post by xavi_s »

Ok, finally we compile the code, but now we have another problem.

The https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/ do not exist.

Starting processing at 2021-05-11 16:48:21.592197
Traceback (most recent call last):
File "polymer_cli.py", line 34, in <module>
run_atm_corr(Level1(args.input_file),
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/main.py", line 496, in run_atm_corr
with level2 as l2, level1 as l1:
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/level1.py", line 106, in __enter__
self.level1 = L1(self.filename, **self.kwargs)
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/level1_msi.py", line 106, in __init__
self.ancillary = Ancillary_NASA()
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/ancillary.py", line 160, in __init__
assert isdir(directory), 'Directory {} does not exist. Please create it, by default it will be automatically populated with ancillary data. Please see help for class Ancillary_NASA for more details.'.format(directory)
AssertionError: Directory ANCILLARY/METEO/ does not exist. Please create it, by default it will be automatically populated with ancillary data. Please see help for class Ancillary_NASA for more details.


Alternatives?
User avatar
fsteinmetz
Site Admin
Posts: 306
Joined: Fri Sep 07, 2018 1:34 pm
company / institution: Hygeos
Location: Lille, France
Contact:

Re: Problem to correct Sentinel 2 images

Post by fsteinmetz »

Hi,
As stated in the error message, you have to create the directory for storing the ancillary data :

Code: Select all

mkdir -p ANCILLARY/METEO/
Cheers,
François
xavi_s
Posts: 7
Joined: Tue Feb 23, 2021 11:57 am
company / institution: Universitat de València
Location: Paterna

Re: Problem to correct Sentinel 2 images

Post by xavi_s »

Hi François, sorry but we have another error.

(base) [root@localhost polymer-v4.13]# python polymer_cli.py /home/flexe/Escritorio/Combinada/S2A_SIL1C_20180322T105021_N0206_R051_T30SYJ_20180M322T111317.SAFE/GRANULE/L1C_T30SYJ_A014348_20180322T105809 S2A_SIL2C_20180322.nc
Starting processing at 2021-05-17 15:18:01.201330
Initialize MSI projection EPSG:32630
/root/anaconda3/lib/python3.8/site-packages/pyproj/crs/crs.py:280: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable ... -in-proj-6
projstring = _prepare_from_string(projparams)
Trying to download https://oceandata.sci.gsfc.nasa.gov/cgi ... MI_24h.hdf ...
2021-05-17 15:18:04 URL:https://urs.earthdata.nasa.gov/oauth/au ... _type=code [12265] -> "ANCILLARY/METEO/2018/081/N201808100_O3_AURAOMI_24h.hdf.tmp" [1]
Traceback (most recent call last):
File "polymer_cli.py", line 34, in <module>
run_atm_corr(Level1(args.input_file),
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/main.py", line 496, in run_atm_corr
with level2 as l2, level1 as l1:
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/level1.py", line 106, in __enter__
self.level1 = L1(self.filename, **self.kwargs)
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/level1_msi.py", line 151, in __init__
self.init_ancillary()
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/level1_msi.py", line 180, in init_ancillary
self.ozone = self.ancillary.get('ozone', self.date)
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/ancillary.py", line 242, in get
res = self.find_ozone(date)
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/ancillary.py", line 369, in find_ozone
f1 = self.try_resources(self.ozone_patterns, rolling(t0, self.delta, timedelta(days=1)))
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/ancillary.py", line 340, in try_resources
ret = self.download(url, target)
File "/home/flexe/Escritorio/Combinada/polymer-v4.13/polymer/ancillary.py", line 306, in download
assert not fp.read(100).startswith(b'<!DOCTYPE html>'), errormsg
AssertionError: Error authenticating to NASA EarthData for downloading ancillary data. Please provide authentication through .netrc. See more information on https://support.earthdata.nasa.gov/inde ... l-and-wget

I open this url and I understand that I have to change in ancillary.py the line 296.
Cut this: 'wget -nv --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies --auth-no-challenge {} -O {}'
And paste this: wget --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies --auth-no-challenge http://server/path

But I don't sure.

Thanks for your patience.

Xavi
User avatar
fsteinmetz
Site Admin
Posts: 306
Joined: Fri Sep 07, 2018 1:34 pm
company / institution: Hygeos
Location: Lille, France
Contact:

Re: Problem to correct Sentinel 2 images

Post by fsteinmetz »

Hi Xavi,

You should not have to modify ancillary.py ; only steps 1 and 2 of this guide are required. The data is then downloaded by ancillary.py.
Have you provided your earthdata credentials in ~/.netrc ?
Cheers,
François
xavi_s
Posts: 7
Joined: Tue Feb 23, 2021 11:57 am
company / institution: Universitat de València
Location: Paterna

Re: Problem to correct Sentinel 2 images

Post by xavi_s »

Yes, finally we run polymer and we correct an image.

Thank you for all
Post Reply