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)

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

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.

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 ?

@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.

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.

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.

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.