Snaphu Export in SNAP 8 rises IndexOutOfBoundsException

When exporting files for Snaphu running it from Snappy python package, the IndexOutOfBoundsException exception occurs as shown below.

The exception occurs in SNAP 8. It works in SNAP 8 GUI, but fails when called from Snappy. The same code works fine in SNAP 7, but fails in SNAP 8 I am afraid it might be caused by changes in read/write introduced in SNAP 8.0 release. Could you please check what might be the cause of this error ? I will be grateful for your help.

Code example:

from snappy import GPF, ProductIO
...
# 'product' contains interferogram and all the related data
# 'parameters' specify parameters for SnaphuExport
product_snaphu = GPF.createProduct('SnaphuExport', parameters, product)
ProductIO.writeProduct(product_snaphu, output_path, 'Snaphu')

The exception:

Exception in thread "pool-1-thread-1" java.lang.IndexOutOfBoundsException
	at java.io.RandomAccessFile.writeBytes(Native Method)
	at java.io.RandomAccessFile.write(RandomAccessFile.java:525)
	at org.esa.s1tbx.commons.io.EnhancedRandomAccessFile.flush(EnhancedRandomAccessFile.java:397)
	at org.esa.s1tbx.commons.io.EnhancedRandomAccessFile.seek(EnhancedRandomAccessFile.java:300)
	at org.esa.s1tbx.commons.io.FileImageOutputStreamExtImpl.seek(FileImageOutputStreamExtImpl.java:143)
	at org.esa.snap.core.datamodel.ProductData.writeTo(ProductData.java:1000)
	at org.jlinda.nest.dataio.SnaphuWriter.writeBandRasterData(SnaphuWriter.java:167)
	at org.esa.snap.core.datamodel.Band.writeRasterData(Band.java:359)
	at org.esa.snap.core.dataio.ProductIO.writeTile(ProductIO.java:605)
	at org.esa.snap.core.dataio.ProductIO.lambda$writeRasterDataFully$0(ProductIO.java:578)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
2 Likes

My codes is from https://forum.step.esa.int/t/snaphu-read-error-due-to-non-ascii-unreadable-file/14374/3, which is similar to @luc and when I export files for Snaphu, I get the same IndexOutOfBoundsException exception in python3.6.9 Snappy package.

The exception occurs in SNAP 8 Snappy. The same code works fine in SNAP 6.0 Snappy.

I found the exception actually occurs in the code “ProductIO.writeProduct(product_snaphu, output_path, ‘Snaphu’)”, sometimes it won’t stop even the exception occurs, but then stopped when running “snaphu -f snaphu.conf Phase_ifg_*.snaphu.img 6341”, the error message is
“Unexpected or abnormal exit of child process 13076
Abort”

Grateful for any help!@ABraun

1 Like

I think this is not related to Python. I guess this issue happens also when exporting from SNAP Desktop, right?
So, I have moved it into the S1TBX category.

I used SNAP 8 Desktop to SnaphuExport and SnaphuInport, it works well.
And I use the command “snaphu -f snaphu.conf Phase_ifg_*.snaphu.img 6341” to process the unwrapping part instead of the Snaphu-unwraping.

The exception acturally occers in the snaphuExport part of the snappy processing.

1 Like

Okay, then I move it back to the python category.
But still, I think the issue is probably, I don’t know, in Snaphu or in s1tbx, maybe it only occurs under certain circumstances when called from Python.
But I can’t help here. I have no knwoledge of snaphu.

The SnaphuExport works in SNAP 8 Desktop, but fails when called from Snappy.

The same code in Snappy works fine in SNAP 7, but fails in SNAP 8 I am afraid it is caused by changes in read/write introduced in SNAP 8. It is quite serious issue. For large scale processing you want to avoid desktop version. Running all automatically using Snappy is very convenient. This issue makes the use of SnaphuExport outside the desktop unusable. It prevents me from upgrading to SNAP 8. Please is there any core developer familiar with Snappy who could help ?

1 Like

@lveci or @jun_lu can you investigate this? You can reproduce this issue much easier as I could and
I assume that it is not related to snappy. Snappy didn’t really change since SNAP7 and actually it just delegates to the Java methods.

1 Like

We will look into the problem. A JIRA ticket (https://senbox.atlassian.net/browse/SITBX-865) has been created to track the problem. Thanks for reporting the issue.

2 Likes

Thank you for opening the ticket. It would be great if you can give it a high priority. This issue was probably introduced by changes to write operations created in SNAP 8.0 release. It is a serious issue. It is not possible to run headless (non-gui) interferometric pipelines (which includes export for phase unwrapping). It works in SNAP 7, but SNAP 7 will not be compatible with newest versions of Ubuntu due to its dependency on libgfortran3. Thank you for taking care about this issue.

1 Like

Did anybody found a solution for this? I am running into the same problem with Snap 8.0 with snappy.

Looked at the JIRA ticket, was no update.

2 Likes

Hello @luc, were you able to find a solution to this issue? I’m having the same problem. SNAPHU export works fine from GUI but not snappy.

Thank you,
Andrew

1 Like

Hello, has there been any updates on this issue? Thank you,
Andrew

1 Like

Hi Andrew, unfortunately the problem still persists. SnaphuExport fails in SNAP 8 when you are running it from Python. I have to perform this part of my processing pipeline in a docker where I still keep SNAP 7 and compatible ubuntu. Other processing steps can use SNAP 8, but this part only works in SNAP 7 :confused: If you will find a better workaround how to make it work with SNAP 8, please let me know.

2 Likes

I tried the same with just running snaphuExport in SNAP 7 and that worked. I tried running the entire process in SNAP 7 but unfortunately SNAP 7 automatic download of orbit files is broken due to the shift from ESA. This combo of SNAP 7 and 8 is all I can get to work. Thanks for the tip!

1 Like

@jun_lu This issue needs attention as it’s blocking people from upgrading to SNAP 8/9.

1 Like

Any update about this topic?

1 Like