How to call InSARStackOverview in python module

How to call InSARStackOverview in python module. where can I find a documentation about snappy

You can find information in the sticky post of this category


and also here

You can also get to the Developer Guide from the website in the Documentation section.

Actually, I only want to use the function of calculate Baseline (it’s InSAR Stack Overview in desktop,I just want use it with python ). I want to find best Interference baseline in many files.
could you tell me how to use the function? I didn‘t find in java scripts.

you can load the class as follows

import snappy
InSARStackOverview = snappy.jpy.get_type(org.esa.s1tbx.insar.gpf.InSARStackOverview)
stack_overview = InSARStackOverview()
stack_overview.setInput(…)

But the class InSARStackOverview does not have a calculateBaseline method. So I don’t know what you want to call.
InSAR Stack Overview is doing much more than just calling one method.

However , I can get perpendicular baseline by InSAR Stack Overview on the desktop. SO, the class InSARStackOverview will be not?

It is not the only one you need to use. But I can’t tell you want you need to do. I’m not working with SAR data.

I just want to realize the InSAR Stack Overview function of SNAP DESKTOP by snappy.

Maybe @cwong or @timmoorhouse can shed some light o it.
Or maybe someone else did it already?
But you can have a look at our repository and see what needs to be done.
The entry point is the class org.esa.s1tbx.insar.rcp.dialogs.InSARStackOverviewDialog and its method processStack.

Thank you very much. I will try to do it.Thanks

Does anyone found out how to call InSARStackOverview from snappy python?

I get the following error while calling the function, see the snippet below:

InSARStackOverview = snappy.jpy.get_type(‘org.esa.s1tbx.insar.gpf.In
SARStackOverview’)
stack_overview = InSARStackOverview()
stack_overview.calculateInSAROverview(insar_stack)

How have you created your insar_stack?
I think it needs to be created like this:

insar_stack=jpy.array('org.esa.snap.core.datamodel.Product', 5)
insar_stack[0] = product1
...
insar_stack[4] = product5
# or loop over it

@marpet Thanks for the reply, below is the full code.

slc_paths =  glob.glob(r'C:\Users\Placeholder\Desktop\Pre-Processing_Module\Quering\Download\*.zip')

insar_stack = snappy.jpy.array('org.esa.snap.core.datamodel.Product', len(slc_paths))

for i, slc_path in enumerate(slc_paths):

    slc_product = snappy.ProductIO.readProduct(slc_path)

    insar_stack[i] = slc_product

InSARStackOverview = snappy.jpy.get_type('org.esa.s1tbx.insar.gpf.InSARStackOverview')

stack_overview = InSARStackOverview()

stack_overview.calculateInSAROverview(insar_stack)

I still get the same error. Please let me know if I am doing something wrong.

Thanks in advance.

Now I see. calculateInSAROverview is a static method.
Don’t use the instance stack_overview of InSARStackOverview.

Try directly:
InSARStackOverview.calculateInSAROverview(insar_stack)

1 Like

@marpet Thanks for your quick reply; I was successful in getting the name of the optimal master product. However, I was curious how I could extract the other data like perpendicular baseline, temporal baseline and modelled coherence.

snippet to get the name of optimal_master

InSARStackOverview = snappy.jpy.get_type(‘org.esa.s1tbx.insar.gpf.InSARStackOverview’)

optimal_master = InSARStackOverview.findOptimalMasterProduct(insar_stack).getName()

Thanks in advance

I’m not familiar wir SAR processing.
So, I’m also only guessing by looking at the code.

I think you need to call. This gives you an IfgStack array.
ifgStack = InSARStackOverview.calculateInSAROverview(insar_stack)

Each of the entries has a master and a master_slave. You can get the master_slave by
ifgpairs = ifgStack[0].getMasterSlave()
This is an array of IfgPair instances.
On these IfgPair instances you can call

ifgpairs[0].getPerpendicularBaseline()
ifgpairs[0].getTemporalBaseline()
ifgpairs[0].getCoherence()

and more.
See

@marpet Thank you so much, will try them.