Error when processing sunglint correction for S2

Technical questions about ACOLITE
Post Reply
matheushtavares
Posts: 5
Joined: Tue Feb 15, 2022 5:35 pm

Error when processing sunglint correction for S2

Post by matheushtavares »

Hello Quinten!

I'm testing AC for Sentinel-2 for the black waters of the Negro river, but I'm having an issue when processing sunglint. I ran ACOLITE without the sunglint correction and it worked fine. I'm running it on Ubuntu 20.04 with python 3.11. Here are my settings:

settings = {"s2_target_res": 20,
"l2w_parameters":'rhow_*',
"dsf_residual_glint_correction": True,
"l2w_mask_negative_rhow": False,
"l2w_mask": True,
"l2w_mask_threshold": 0.05,
"l2w_export_geotiff": True}

And here is the error message:

Code: Select all

ValueError                                Traceback (most recent call last)
Cell In[16], line 1
----> 1 ac.acolite.acolite_run(settings=settings)

File ~/Documents/GET/acolite-main/acolite/acolite/acolite_run.py:167, in acolite_run(settings, inputfile, output)
    164 if l1r_setu['atmospheric_correction']:
    165     if gatts['acolite_file_type'] == 'L1R':
    166         ## run ACOLITE
--> 167         ret = ac.acolite.acolite_l2r(l1r, settings = l1r_setu, verbosity = ac.config['verbosity'])
    168         if len(ret) != 2:
    169             l2r, l2r_setu = [], {k:l1r_setu[k] for k in l1r_setu}

File ~/Documents/GET/acolite-main/acolite/acolite/acolite_l2r.py:1502, in acolite_l2r(gem, output, sub, settings, output_file, target_file, return_gem, verbosity)
   1498 ## compute where to apply the glint correction
   1499 ## sub_gc has the idx for non masked data with rhos_ref below the masking threshold
   1500 gc_mask_data = gemo.data(gc_mask)
-> 1502 if gc_mask_data == (): ## can be an empty tuple for night time images (should not be processed, but this avoids a crash)
   1503     print('No glint mask could be determined.')
   1504 else:

ValueError: operands could not be broadcast together with shapes (5490,5490) (0,) 
I have also attached the log file. What could be causing this error?

Thank you in advance,
Matheus
Attachments
acolite_run_20230727_170913_log_file.txt
(10.45 KiB) Downloaded 183 times
quinten
Posts: 1019
Joined: Tue Mar 03, 2015 8:13 am

Re: Error when processing sunglint correction for S2

Post by quinten »

Hi Matheus

Thanks for the report! It seems this comparison to an empty tuple is now throwing an exception in the latest versions of Python. I have changed this to an "is None" which seems to be working also on Python 3.11. I suggest you pull the last commits and try again! Please let me know if you run into any further issues.

Quinten
matheushtavares
Posts: 5
Joined: Tue Feb 15, 2022 5:35 pm

Re: Error when processing sunglint correction for S2

Post by matheushtavares »

Awesome, thank you for the quick fix, it is working now!
Cheers,
Matheus
Post Reply