esa-snap-s1tbx-gptNOTEBOOKS
Jupyter usage

Run SNAP workflows
from notebooks.

The notebook kernel must run inside the conda environment where esa-snap-s1tbx-gpt is installed. From there, drive SNAP through gpt or through pyroSAR.

subprocess pyroSAR graph XML

Create a notebook environment

mamba create -n snap-notebook -c sarforge -c conda-forge \
  esa-snap-s1tbx-gpt=13.0.0 python ipykernel pyrosar
conda activate snap-notebook
python -m ipykernel install --user --name snap-notebook --display-name "Python (SNAP GPT)"

Then select Python (SNAP GPT) as the notebook kernel.

Check GPT from a notebook

import shutil
import subprocess

print(shutil.which("gpt"))
subprocess.run(["gpt", "-h"], check=True)

Run a GPT graph

from pathlib import Path
import subprocess

graph = Path("calibration.xml")
source = Path("S1_scene.zip")
target = Path("calibrated.dim")

subprocess.run(
    [
        "gpt",
        str(graph),
        f"-Pinput={source}",
        f"-Poutput={target}",
    ],
    check=True,
)

Exact graph parameters depend on the XML graph you are running.

pyroSAR

pyroSAR can call SNAP through gpt after it detects the installation:

from pyroSAR.examine import ExamineSnap

snap = ExamineSnap()
print(snap.gpt)

For full pyroSAR geocoding workflows, install any additional external tools you need, such as snaphu for phase unwrapping:

mamba install -c conda-forge snaphu

What this does not provide

This package does not provide SNAP's old snappy/jpy Python-Java bridge. In notebooks, use one of these patterns instead:

  • call gpt with subprocess;
  • use pyroSAR, which drives SNAP through gpt;
  • generate graph XML programmatically and execute it with gpt.
That separation is intentional: this package is a reliable headless GPT runtime, not a Python binding for SNAP's internal Java API.