INSAR / DINSAR - Perpendicular baseline calculation

For anyone who still wants to compute the baseline with snappy, I ended up using the getBaselines method of the CreateStackOp operator (there may be a better way, but it is the only one that works for me at the moment):

import snappy as snap
# read products
product1 = snap.ProductIO.readProduct('/path/to/product1.zip')
product2 = snap.ProductIO.readProduct('/path/to/product2.zip')
# import the stack operator
create_stack = snap.jpy.get_type('org.esa.s1tbx.insar.gpf.coregistration.CreateStackOp')
# Use the getBaselines method.
# 1st argument: list of products between which you want to compute the baseline
# 2nd argument: a product that will receive the baselines as new metadata
create_stack.getBaselines([product1, product2], product1)
# Now there is a new piece of metadata in product one called 'Baselines'
baseline_root_metadata = product1.getMetadataRoot().getElement('Abstracted_Metadata').getElement('Baselines')
# You can now display all the baselines between all master/slave configurations
master_ids = list(baseline_root_metadata.getElementNames())
for master_id in master_ids:
    slave_ids = list( baseline_root_metadata.getElement(master_id).getElementNames())
    for slave_id in slave_ids:
        print(f'{master_id}, {slave_id}')
        baseline_metadata = baseline_root_metadata.getElement(master_id).getElement(slave_id)
        for baseline in list(baseline_metadata.getAttributeNames()):
            print(f'{baseline}: {baseline_metadata.getAttributeString(baseline)}')
        print('')

The for loop will return something like:

Master: 06Oct2015, Slave: 06Oct2015
Perp Baseline: 0.0
Temp Baseline: 0.0
Modelled Coherence: 1.0
Height of Ambiguity: Infinity
Doppler Difference: 0.0

Master: 06Oct2015, Slave: 18Oct2015
Perp Baseline: 63.730323791503906
Temp Baseline: -12.000000953674316
Modelled Coherence: 0.9332881569862366
Height of Ambiguity: -245.80726623535156
Doppler Difference: -4.754251956939697

Master: 18Oct2015, Slave: 06Oct2015
Perp Baseline: -63.72906494140625
Temp Baseline: 12.000000953674316
Modelled Coherence: 0.933289110660553
Height of Ambiguity: 245.8077392578125
Doppler Difference: 4.754251956939697

Master: 18Oct2015, Slave: 18Oct2015
Perp Baseline: 0.0
Temp Baseline: 0.0
Modelled Coherence: 1.0
Height of Ambiguity: Infinity
Doppler Difference: 0.0

And if you want to get only a specific number:

baseline_root_metadata.getElement('Master: 06Oct2015').getElement('Slave: 18Oct2015').getAttributeDouble('Perp Baseline')
63.730323791503906
4 Likes