pyPSDS-GAMMA is a production-oriented PS/DS-InSAR processing pipeline for GAMMA-coregistered RSLC stacks. It provides statistically homogeneous pixel (SHP) selection, PS/DS processing, robust Phase Linking, network quality control, phase unwrapping, time-series inversion, optional atmospheric and post-inversion corrections, and final LOS deformation products.
This README is the primary installation and user manual.
Current package version: 1.3.5.
The public workflow is organized into nine logical modules:
data_ps
↓
shp
↓
phase_linking
↓
ps_ds
↓
network_qc
↓
unwrap
↓
timeseries
↓
corrections
↓
products
The module interface is recommended for normal processing. Internal stages are retained for checkpoint recovery, debugging, and advanced control.
List the public modules:
pypsds modulesList the internal stages:
pypsds run \
--config pypsds.yaml \
--list-stagesThe main conventions used by the production pipeline are:
-
Final LOS displacement is positive toward the satellite.
-
LOS conversion is
d_LOS = +lambda / (4*pi) * phase -
Radar wavelength is read from the project GAMMA parameter files.
-
reference_dateis the GAMMA geometric/coregistration reference acquisition. -
phase_linking.temporal_reference_indexis the mathematical temporal phase gauge and is independent ofreference_date. -
The final spatial deformation reference is configured under
reference:. -
Automatic reference selection establishes a relative InSAR datum; it does not prove that the selected area is physically motionless.
-
LOS-to-vertical conversion requires the explicit approximation of negligible horizontal motion.
-
Runtime scheduling parameters control performance only. They must not change the scientific PS/DS/SHP/Phase-Linking definitions.
Recommended environment:
- Linux
- Ubuntu 22.04 or 24.04
- Python 3.11 or newer
- Python 3.12 recommended
- licensed GAMMA installation
- sufficient local RAM and storage for large full-scene arrays
Required GAMMA commands include:
SLC2pt
data2pt
phase_sim_orb_pt
base_calc
base_orbit
They must be executable from the shell used to run pyPSDS-GAMMA.
Check:
which SLC2pt
which data2pt
which phase_sim_orb_pt
which base_calc
which base_orbitIf GAMMA uses a setup script, load it before activating/running pyPSDS-GAMMA.
conda create -n pypsds python=3.12 pip -y
conda activate pypsds
git clone https://github.com/songzwgithub/test-ds.git
cd test-dsCore installation:
python -m pip install .Complete product/export installation:
python -m pip install ".[products]"Development installation:
python -m pip install -e ".[dev,products]"The products extra installs the optional monitoring/export stack including
pandas, pyarrow, geopandas, rasterio, pyproj and pyshp.
python -m pip checkpython - <<'PY'
import importlib.metadata as md
import pypsds
print("runtime version :", pypsds.__version__)
print("metadata version:", md.version("pypsds-gamma"))
print("source :", pypsds.__file__)
PYFor an editable development installation, source should point to the cloned
repository.
pytest -qA typical shell session is:
conda activate pypsds
# Load GAMMA environment if it is not already in PATH.
# Example only; use the actual GAMMA installation on your server.
export GAMMA_HOME=/path/to/GAMMA_SOFTWARE
export PATH="$GAMMA_HOME/IPTA/bin:$GAMMA_HOME/DIFF/bin:$GAMMA_HOME/ISP/bin:$PATH"
which SLC2pt
which data2pt
which phase_sim_orb_ptpypsds doctor will also check required GAMMA commands.
Create a new project:
pypsds init /path/to/projectExample:
mkdir -p ~/insar/ningbo
pypsds init ~/insar/ningbo
cd ~/insar/ningboThis creates:
/path/to/project/pypsds.yaml
pypsds init always reads the currently installed packaged
pypsds/resources/default_config.yaml, so a newly generated project receives
the current configuration template.
To overwrite an existing configuration with the current template:
pypsds init /path/to/project --forceWarning: --force replaces the complete existing pypsds.yaml. Back up
project-specific paths, reference dates, ROI, correction settings and spatial
reference definitions first.
Conventional auto-discovered layout:
project/
├── pypsds.yaml
├── RSLC/
│ ├── YYYYMMDD.rslc
│ ├── YYYYMMDD.rslc.par
│ └── ...
├── RSLC_tab
├── DEM_prep/
├── GACOS/ # optional
└── output/
The project can use different directories by setting explicit paths in
pypsds.yaml.
The input must already be a GAMMA-coregistered RSLC stack.
Sensor-specific raw/SLC preprocessing and coregistration are outside the pyPSDS-GAMMA production pipeline.
RSLC_tab defines the acquisition stack.
Each acquisition must have:
YYYYMMDD.rslc
YYYYMMDD.rslc.par
The stack dates, dimensions, wavelength and other project properties are read from the current project rather than hard-coded.
The processing project requires the GAMMA geometry needed by point-based topographic/orbital phase simulation.
The radar-coordinate height raster must correspond to the processing geometry.
The project-level:
reference_date: YYYYMMDDmust be the actual GAMMA geometric/coregistration reference acquisition and
must exist in RSLC_tab.
GACOS is optional.
When enabled, the correction products are matched by acquisition date. With strict date checking enabled, missing dates stop processing rather than being silently ignored.
Start from the generated pypsds.yaml.
The most important project-specific settings are:
reference_date: YYYYMMDD
paths:
work_dir: .
data_dir: .
rslc_dir: null
rslc_tab: null
output_dir: output
dem_dir: null
gacos_dir: null
processing:
roi:
row0: 0
col0: 0
rows: null
cols: nullnull path values use project auto-discovery.
The production runtime uses hardware-aware scheduling:
runtime:
cpu: auto
memory_fraction: 0.85
io_workers: auto
autotune:
enabled: true
sample_points: 16384
repeats: 2
phase_link_prefetch_tiles: 0Phase-correction runtime defaults:
phase_correction:
enabled: true
backend: gamma_phase_sim_orb_pt
command_timeout_seconds: 300.0
command_retries: 2
retry_backoff_seconds: 1.0
parallel:
spatial_workers: auto
pair_workers: autoThe canonical GAMMA phase cell remains:
128 x 256 pixels
This is part of the validated numerical grouping and should not be enlarged simply for performance.
Only execution scheduling is parallelized. Both automatic and explicit
spatial_workers × pair_workers schedules are hard-capped by the effective
runtime.cpu budget.
On a validated 32-logical-CPU host, the performance fallback is:
6 spatial workers x 3 pair workers
= maximum 18 concurrent GAMMA phase_sim_orb_pt processes
If a parity-validated:
output/processing/canonical_phase_parallel_autotune.json
exists, its validated winner overrides the hardware fallback. The autotune
benchmark uses an independent 1×1 serial GAMMA run as the numerical parity
reference; schedules exceeding runtime.cpu are not eligible. Only a full-stack
benchmark may be installed as the production autotune winner.
With:
runtime:
phase_link_prefetch_tiles: 1the next real-acquisition tile can be streamed/corrected while the current tile performs SHP/coherence/EMI/compression work.
This improves CPU overlap on large scenes.
The production default is synchronous (0). The asynchronous path remains an
opt-in performance mode and uses a fail-fast daemon-worker watchdog (960 s fallback timeout). Enable it
only after real-data stability and wall-time validation on the target machine:
runtime:
phase_link_prefetch_tiles: 1External GAMMA failures are retried in place:
phase_correction:
command_retries: 2
retry_backoff_seconds: 1.0This means:
initial attempt
↓ failure
retry after 1 s
↓ failure
retry after 2 s
A transient phase_sim_orb_pt failure such as Linux return code -11
(SIGSEGV) therefore does not immediately terminate the complete
Phase-Linking stage.
If all retries fail, the final failed temporary tile bundle is preserved under:
output/phase_correction/failed_tiles/
for reproduction and diagnosis.
Typical production settings:
selection:
ps:
amplitude_dispersion_max: 0.25
shp:
method: rayleigh_glrt
alpha: 0.005
half_row: 5
half_col: 11
min_count: 48
exclude_ps: true
policy: solver_aware
rank_guard: true
adaptive_window:
enabled: true
ds:
center_mode: all
temporal_coherence_min: 0.8
pair_coherence_min: 0.0
accept_evd: trueThe exact SHP support cache is reused by sequential Phase Linking.
Typical sequential configuration:
phase_linking:
method: robust_emi
beta: 0.0
gamma_jitter: 1.0e-06
target_eigenvalue: 0.99
evd_fallback: true
temporal_reference_index: 0
temporal:
strategy: sequential
ministack_size: 19
max_num_compressed: 5
state_min_shp: 24
full_scm_fallback: true
fullspan_batch_size: 16384
emi_backend: threshold_cholesky
use_exact_support_cache: trueThe sequential solver is intended for large stacks and large scenes where a full-scene full-SCM representation would be too expensive.
The packaged production template preserves the validated correction chain: GACOS atmosphere correction, StaMPS-style SCLA, and StaMPS-style SCN are enabled by default. Disable an unavailable correction explicitly for projects that do not provide its required inputs.
Example automatic relative reference:
reference:
method: auto
min_points: 100
statistic: medianAn externally validated stable reference should be used when available.
The packaged production default is mode: gacos. Set mode: disabled when GACOS products are intentionally not used.
Disabled:
corrections:
atmosphere:
mode: disabledGACOS:
corrections:
atmosphere:
mode: gacos
backend: gacos
strict_dates: trueExample:
corrections:
scla:
mode: stamps
backend: stamps
scn:
mode: stamps
backend: stamps
temporal_window_days: 365.0
wavelength_m: 100.0
radius_factor: 4.0
cell_size_m: 200.0The products module creates final LOS and point products. Optional product extras enable formats such as GeoTIFF, GeoPackage, Shapefile and Parquet.
For every new project:
pypsds config-check \
--config pypsds.yamlpypsds doctor \
--config pypsds.yamlpypsds plan \
--config pypsds.yamlDry run:
pypsds run \
--config pypsds.yaml \
--dry-runThe doctor output should confirm:
- stack dimensions;
- acquisition count;
- reference date;
- GAMMA geometry;
- available CPU/RAM;
- Phase-Linking runtime schedule;
- required GAMMA executables.
The package can benchmark the numerical Phase-Linking runtime schedule on a bounded real-data sample:
pypsds tune \
--config pypsds.yamlForce recalibration:
pypsds tune \
--config pypsds.yaml \
--forceThe tuned runtime profile is reused when its runtime signature remains valid.
Autotuning is intended to change scheduling only. Numerical parity checks are part of the tuning contract.
pypsds run \
--config pypsds.yamlpypsds run \
--config pypsds.yaml \
--module phase_linkingpypsds run \
--config pypsds.yaml \
--from-module shp \
--to-module productsAdvanced recovery/debugging:
pypsds run \
--config pypsds.yaml \
--from-stage phase_linkingor:
pypsds run \
--config pypsds.yaml \
--from-stage exact_support_cacheDo not mix module selectors and internal-stage selectors in one command.
| Module | Main purpose |
|---|---|
data_ps |
RSLC/phase-source preparation, statistics and PS candidates |
shp |
exact statistically homogeneous pixel support |
phase_linking |
covariance/coherence processing and sequential robust Phase Linking |
ps_ds |
DS selection, PS finalization and PS/DS merge |
network_qc |
temporal/spatial network and quality-control processing |
unwrap |
phase unwrapping and unwrap validation |
timeseries |
geometry, residual-ramp processing and time-series inversion |
corrections |
spatial reference, atmosphere, SCLA and SCN |
products |
final LOS and point/product export |
Use:
pypsds modulesfor the authoritative module list in the installed version.
pyPSDS-GAMMA uses persistent stage/tile checkpoints for large production runs.
Normal restart:
pypsds run \
--config pypsds.yaml \
--from-stage phase_linkingDo not use --force for ordinary recovery.
Do not set:
PYPSDS_FORCE_FRESH_TILES=1unless a deliberate fresh sequential-tile recomputation is required.
Sequential tile markers are published only after the corresponding persistent arrays have been flushed.
Empty state tiles are also checkpointed so that the durable checkpoint prefix remains contiguous.
Older runs may contain empty-tile marker gaps.
Audit:
python tools/repair_empty_sequential_checkpoints.py \
--processing-dir /path/to/output/processing \
--stage 0Apply only after the audit passes:
python tools/repair_empty_sequential_checkpoints.py \
--processing-dir /path/to/output/processing \
--stage 0 \
--applyThe repair tool refuses to manufacture markers for missing non-empty tiles.
When resuming an expensive production run:
- keep the same project configuration;
- keep the same scientific source implementation;
- keep the same canonical numerical phase grouping;
- do not move/replace large checkpoint identity files unless their identity semantics are understood;
- do not use
--forcesimply because a stage failed; - inspect the original failure first;
- preserve
output/processing/sequential; - preserve
output/phase_correction; - preserve K-state/effective-K arrays and exact support caches.
Performance scheduling should be tested independently before changing a running checkpointed production job.
Typical output tree:
output/
├── logs/
├── qa/
├── runtime/
├── phase_correction/
│ ├── geometry_cache/
│ ├── failed_tiles/
│ └── ...
├── processing/
│ ├── ds_statistics/
│ ├── exact_support_cache/
│ ├── sequential/
│ │ ├── checkpoints/
│ │ └── ...
│ ├── network/
│ ├── network_inversion/
│ └── canonical_phase_parallel_autotune.json
└── products/
Exact products depend on enabled modules and optional corrections.
For large scenes, the main performance rules are:
- keep canonical phase grouping at the validated size;
- use spatial parallelism rather than over-parallelizing every temporal pair;
- reuse persistent GAMMA geometry caches;
- reuse exact SHP support;
- use sequential Phase Linking;
- use runtime autotuning;
- enable one-ahead prefetch only after stability testing on the target machine;
- avoid unnecessary full-scene cache regeneration;
- keep checkpoint cadence large enough to avoid excessive memmap flushes;
- keep BLAS/Numba/process oversubscription under control.
On a 32-logical-CPU machine, the validated performance fallback is currently:
Phase source : GAMMA
Canonical cell : 128 x 256
Spatial workers : 6
Pair workers : 3
GAMMA max : 18 processes
PL workers : hardware/runtime tuned
Prefetch : 0 production default; 1 after target-machine validation
Actual optimal settings depend on CPU, RAM, filesystem and stack size.
which phase_sim_orb_ptLoad the GAMMA environment and rerun:
pypsds doctor \
--config pypsds.yamlOn Linux, a negative subprocess return code represents termination by signal.
-11 corresponds to SIGSEGV.
The current performance implementation retries transient GAMMA failures. Persistent failures preserve the final failed tile bundle under:
output/phase_correction/failed_tiles/
Do not immediately delete checkpoints.
Check first whether:
- source code changed;
- configuration changed;
- input/checkpoint file identities changed;
- large files were moved/copied;
- runtime parameters included in the checkpoint fingerprint changed.
Use a fresh sequential recomputation only when intentional.
For legacy runs, first audit:
python tools/repair_empty_sequential_checkpoints.py \
--processing-dir /path/to/output/processing \
--stage 0Check:
runtime.phase_link_prefetch_tiles
runtime autotune profile
canonical spatial/pair workers
PL workers
filesystem throughput
geometry-cache hit rate
A low average load can occur when GAMMA streaming and EMI/SCM are executed serially instead of overlapped.
Large scenes can create very large persistent arrays. Check before a fresh Phase-Linking run:
df -h /path/to/project
du -sh output/*Do not delete checkpoint arrays without understanding their role.
A newly generated config always uses the currently installed default template:
pypsds init /new/projectFor an existing project, --force replaces the complete configuration:
pypsds init /existing/project --forceBack up the existing project configuration first:
cp pypsds.yaml pypsds.yaml.backupThen compare old and new configurations rather than blindly discarding project-specific values.
Install editable development dependencies:
python -m pip install -e ".[dev,products]"Run the complete test suite:
pytest -qRun syntax checks:
python -m py_compile \
pypsds/gamma/phase_correction.py \
pypsds/phase_linking/phase_source.py \
pypsds/phase_linking/sequential_multistage.py \
pypsds/phase_linking/tile_prefetch.pyCheck repository diff:
git diff --check
git status --shortFor a new project:
# 1. install
conda create -n pypsds python=3.12 pip -y
conda activate pypsds
git clone https://github.com/songzwgithub/test-ds.git
cd test-ds
python -m pip install ".[products]"
# 2. initialize
pypsds init /path/to/project
cd /path/to/project
# 3. edit pypsds.yaml
# - reference_date
# - paths if non-standard
# - ROI if required
# - correction/reference settings
# 4. validate
pypsds config-check --config pypsds.yaml
pypsds doctor --config pypsds.yaml
pypsds plan --config pypsds.yaml
# 5. optional runtime tuning
pypsds tune --config pypsds.yaml
# 6. dry run
pypsds run --config pypsds.yaml --dry-run
# 7. production
pypsds run --config pypsds.yamlFor a normal checkpoint restart:
pypsds run \
--config pypsds.yaml \
--from-stage phase_linkingNo --force is required for normal resume.
Apache-2.0.