Polymer 4.13 installation for Sentinel-2 data processing

Post Reply
samaaouch
Posts: 2
Joined: Fri Jun 05, 2020 1:32 pm
company / institution: ARGANS Ltd
Location: Brest

Polymer 4.13 installation for Sentinel-2 data processing

Post by samaaouch »

Hi everyone

I try to use Polymer 4.13 to process MSI data. I work with Python 3.4, I change some function to use Polymer 4.13 with Python 3.4 (f-string in .format). I'm trying to launch the example.py program which only launch the following command:

Code: Select all

run_atm_corr(
            Level1_MSI("/mount/internal/home/users/samaaouch/_unix/Test img/S2B_MSIL1C_20190716T110629_N0208_R137_T30UVV_20190716T131056.SAFE/GRANULE/L1C_T30UVV_A012318_20190716T111721/",
                        resolution='60'  # if not provided, use the 60m resolution
                        ),
            Level2_NETCDF()  # by default, output in the same folder as input
            )
But I have some troubles with glymur module, I'm using glymur 0.8.0 and OpenJPEG 1.5.2. When I launch python3 example.py I have these errors:

Code: Select all

Initialize MSI projection EPSG:32630
Starting processing at 2020-06-30 15:53:46.903814
Initializing output file "/mount/internal/home/users/samaaouch/_unix/Test img/S2B_MSIL1C_20190716T110629_N0208_R137_T30UVV_20190716T131056.SAFE/GRANULE/L1C_T30UVV_A012318_20190716T111721.nc"
/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/jp2box.py:196: UserWarning: Encountered an unrecoverable ValueError while parsing a XML box at byte offset 142.  The original error message was "Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration."
  warnings.warn(msg, UserWarning)
Traceback (most recent call last):
  File "/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/jp2k.py", line 1155, in _read_openjpeg
    data = extract_image_cube(image)
  File "/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/jp2k.py", line 1847, in extract_image_cube
    ncomps = image.contents.numcomps
ValueError: NULL pointer access

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "example.py", line 120, in <module>
    example_msi()
  File "example.py", line 47, in example_msi
    Level2_NETCDF()  # by default, output in the same folder as input
  File "/usr/local/polymere/polymer-v4.13/polymer/main.py", line 517, in run_atm_corr
    for block in block_iter:
  File "/usr/local/polymere/polymer-v4.13/polymer/main.py", line 434, in blockiterator
    for block in level1.blocks(params.bands_read()):
  File "/usr/local/polymere/polymer-v4.13/polymer/level1_msi.py", line 402, in blocks
    yield self.read_block(size, offset, bands_read)
  File "/usr/local/polymere/polymer-v4.13/polymer/level1_msi.py", line 333, in read_block
    raw_data = self.read_TOA(band, size, offset)
  File "/usr/local/polymere/polymer-v4.13/polymer/level1_msi.py", line 280, in read_TOA
    int(xrat*(xoffset+self.scol)) : int(xrat*(xoffset+self.scol+xsize))
  File "/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/jp2k.py", line 1020, in __getitem__
    data = self._read(area=area, rlevel=rlevel)
  File "/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/jp2k.py", line 1041, in _read
    img = self._read_openjpeg(**kwargs)
  File "/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/jp2k.py", line 1158, in _read_openjpeg
    opj2.check_error(0)
  File "/mount/internal/home/users/samaaouch/_unix/.local/lib/python3.4/site-packages/glymur/lib/openjp2.py", line 591, in check_error
    raise IOError(msg)
OSError: OpenJPEG library error:  Integer overflow in box->length
OpenJPEG library error:  Failed to decode jp2 structure
The error occurs in level1_msi.py between in read_TOA function when "datao" line 278.

I think it is maybe a problem of OpenJPEG version but I don't find any solutions on the web.

Any ideas?

Thank you

Kind regards

Sonia
samaaouch
Posts: 2
Joined: Fri Jun 05, 2020 1:32 pm
company / institution: ARGANS Ltd
Location: Brest

Re: Polymer 4.13 installation for Sentinel-2 data processing

Post by samaaouch »

Solution found!
If anyone wants to know, it was a problem of openJPEG version, I used openJPEG 2.1.2 and the processing works.


Sorry!

Kind regards

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

Re: Polymer 4.13 installation for Sentinel-2 data processing

Post by fsteinmetz »

Hello Sonia,
Good to know that you found a solution!
For your information, I am currently using openJPEG 2.3.1 from the anaconda distribution.
Cheers,
François
Post Reply