PyGeoFetch 2.6.9.2__py3-none-any.whl → 2.6.9.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pygeofetch/__init__.py CHANGED
@@ -30,7 +30,7 @@ CLI::
30
30
  pygeofetch doctor
31
31
  """
32
32
 
33
- __version__ = "2.6.9.2.4"
33
+ __version__ = "2.6.9.3.4"
34
34
  __author__ = "PyGeoFetch Contributors"
35
35
  __license__ = "MIT"
36
36
 
@@ -144,7 +144,7 @@ from pygeofetch.insar.geolocation import (
144
144
  parse_orbit_file,
145
145
  range_offset_to_vertical_displacement,
146
146
  )
147
- from pygeofetch.insar.gpu import gpu_available
147
+ from pygeofetch.insar.gpu import gpu_available, gpu_info
148
148
  from pygeofetch.insar.errors import (
149
149
  BurstProcessingError, CoregistrationError, CropError, FlatEarthError, InputError, ProcessingError,
150
150
  QualityRecord, TopographicPhaseError, AtmosphereError, GeometryProcessingError,
@@ -299,6 +299,7 @@ __all__ = [
299
299
  "ValidationResult",
300
300
  "PairClassification",
301
301
  "gpu_available",
302
+ "gpu_info",
302
303
  "visualize_interferogram",
303
304
  "visualize_unwrapped",
304
305
  "visualize_timeseries",
pygeofetch/insar/gpu.py CHANGED
@@ -42,67 +42,114 @@ logger = logging.getLogger("pygeofetch.insar.gpu")
42
42
 
43
43
  _gpu_checked = False
44
44
  _gpu_available = False
45
+ _gpu_reason = ""
46
+ _gpu_name = ""
45
47
 
46
48
 
47
- def gpu_available() -> bool:
48
- """
49
- Check whether a usable CUDA GPU is actually present — not just
50
- whether the cupy package is importable. Confirmed necessary: CuPy
51
- imports successfully even with no GPU or an insufficient driver
52
- present; only cupy.cuda.is_available() reliably detects that case
53
- without raising.
54
- """
55
- global _gpu_checked, _gpu_available
49
+ def _probe() -> None:
50
+ """Run the GPU check once and record WHY it failed, not just that it did."""
51
+ global _gpu_checked, _gpu_available, _gpu_reason, _gpu_name
56
52
  if _gpu_checked:
57
- return _gpu_available
53
+ return
58
54
  _gpu_checked = True
59
55
  try:
60
56
  import cupy as cp
61
-
62
- _gpu_available = bool(cp.cuda.is_available())
63
- except ImportError:
64
- _gpu_available = False
65
- except Exception as exc: # pragma: no cover - defensive, real driver errors vary
66
- logger.debug(
67
- "GPU check failed with an unexpected error, assuming no GPU: %s", exc
57
+ except ImportError as exc:
58
+ _gpu_reason = (
59
+ "the cupy package is not installed in this Python environment "
60
+ f"({exc}). Install the build that matches your CUDA version, e.g. "
61
+ "'pip install cupy-cuda12x' (CUDA 12) or 'pip install cupy-cuda13x' (CUDA 13); "
62
+ "'nvidia-smi' shows your CUDA version. torch having CUDA does not give cupy a GPU."
68
63
  )
64
+ return
65
+ except Exception as exc: # cupy present but broken (wrong CUDA libraries, ...)
66
+ _gpu_reason = f"importing cupy failed: {type(exc).__name__}: {exc}"
67
+ return
68
+ try:
69
+ if not bool(cp.cuda.is_available()):
70
+ _gpu_reason = (
71
+ "cupy is installed but reports no usable CUDA device "
72
+ "(driver missing or too old for this cupy build, or the process cannot see the GPU)."
73
+ )
74
+ return
75
+ n = int(cp.cuda.runtime.getDeviceCount())
76
+ if n < 1:
77
+ _gpu_reason = "cupy found 0 CUDA devices"
78
+ return
79
+ props = cp.cuda.runtime.getDeviceProperties(0)
80
+ name = props.get("name", b"")
81
+ _gpu_name = name.decode() if isinstance(name, bytes) else str(name)
82
+ # Prove it by computing something: is_available() can be True while kernels still fail
83
+ # (for example a cupy build for a different CUDA major version).
84
+ float(cp.asarray([1.0, 2.0]).sum())
85
+ _gpu_available = True
86
+ except Exception as exc:
87
+ _gpu_reason = f"cupy could not run on the GPU: {type(exc).__name__}: {exc}"
69
88
  _gpu_available = False
89
+
90
+
91
+ def gpu_available() -> bool:
92
+ """True only when a CUDA device exists AND a trivial cupy computation runs on it
93
+ (not just whether the cupy package imports, which it does with no GPU present)."""
94
+ _probe()
70
95
  return _gpu_available
71
96
 
72
97
 
98
+ def gpu_info() -> dict:
99
+ """Why the GPU is or is not used: {"available", "device", "reason", "cupy", "torch_cuda"}.
100
+ Call this in a notebook cell when use_gpu=True does not do what you expect."""
101
+ _probe()
102
+ info = {"available": _gpu_available, "device": _gpu_name or None,
103
+ "reason": _gpu_reason or None, "cupy": None, "torch_cuda": None}
104
+ try:
105
+ import cupy as cp
106
+ info["cupy"] = cp.__version__
107
+ except Exception:
108
+ pass
109
+ try:
110
+ import torch
111
+ info["torch_cuda"] = bool(torch.cuda.is_available())
112
+ except Exception:
113
+ pass
114
+ return info
115
+
116
+
73
117
  def get_array_module(prefer_gpu: bool = True) -> Tuple[Any, Any, bool]:
74
118
  """
75
119
  Returns (xp, ndimage_module, using_gpu).
76
120
 
77
- Args:
78
- prefer_gpu: If True (default) and a usable GPU is detected, use
79
- CuPy + cupyx.scipy.ndimage. Otherwise (or if no GPU
80
- is available), use numpy + scipy.ndimage.
81
-
82
- Returns:
83
- xp: cupy or numpy
84
- ndimage_module: cupyx.scipy.ndimage or scipy.ndimage
85
- using_gpu: True if the GPU backend was actually selected
121
+ prefer_gpu=True and a working GPU -> cupy + cupyx.scipy.ndimage; otherwise numpy + scipy.
122
+ When the GPU was asked for but cannot be used, the reason is logged once at WARNING.
86
123
  """
87
124
  if prefer_gpu and gpu_available():
88
125
  import cupy as cp
89
126
  from cupyx.scipy import ndimage as gpu_ndimage
90
127
 
91
- logger.info("GPU acceleration active (CuPy)")
92
128
  return cp, gpu_ndimage, True
93
129
 
94
130
  import numpy as np
95
131
  from scipy import ndimage
96
132
 
97
133
  if prefer_gpu:
98
- logger.info("No usable GPU detected — using CPU (numpy/scipy)")
134
+ _warn_once()
99
135
  return np, ndimage, False
100
136
 
101
137
 
138
+ _warned = False
139
+
140
+
141
+ def _warn_once() -> None:
142
+ global _warned
143
+ if _warned:
144
+ return
145
+ _warned = True
146
+ logger.warning("use_gpu=True but the GPU is not being used: %s", _gpu_reason or "unknown reason")
147
+
148
+
102
149
  def to_numpy(arr: Any) -> Any:
103
150
  """Move an array back to host memory if it's a CuPy array; a no-op
104
151
  for numpy arrays. Use this at the boundary between GPU-accelerated
105
152
  steps and the rest of the pipeline, which is not GPU-aware."""
106
153
  if hasattr(arr, "get"): # cupy.ndarray has .get(), numpy.ndarray does not
107
154
  return arr.get()
108
- return arr
155
+ return arr
@@ -110,6 +110,88 @@ def _s1_platform_and_track(path) -> tuple:
110
110
  return plat, None
111
111
 
112
112
 
113
+ # Bump whenever a change alters the numbers process_pair produces, so results saved by an
114
+ # older version are recomputed on resume instead of being silently reused.
115
+ PIPELINE_VERSION = "2026-10-29.geometry_first"
116
+ _SAVE_FORMAT = 1
117
+ _RESULT_JSON = "result.json"
118
+
119
+
120
+ def _jsonable(obj):
121
+ """Metadata -> JSON, with numpy scalars/arrays, paths, Affine and CRS made explicit so load() can restore them."""
122
+ import numpy as np
123
+
124
+ if isinstance(obj, dict):
125
+ return {str(k): _jsonable(v) for k, v in obj.items()}
126
+ if isinstance(obj, (list, tuple)):
127
+ return [_jsonable(v) for v in obj]
128
+ if isinstance(obj, np.ndarray):
129
+ return obj.tolist()
130
+ if isinstance(obj, np.generic):
131
+ return obj.item()
132
+ if isinstance(obj, Path):
133
+ return str(obj)
134
+ if obj is None or isinstance(obj, (bool, int, float, str)):
135
+ return obj
136
+ try:
137
+ from affine import Affine
138
+
139
+ if isinstance(obj, Affine):
140
+ return {"__affine__": list(obj)[:6]}
141
+ except ImportError:
142
+ pass
143
+ if hasattr(obj, "to_wkt"):
144
+ return {"__crs__": obj.to_wkt()}
145
+ return str(obj)
146
+
147
+
148
+ def _restore(obj):
149
+ if isinstance(obj, dict):
150
+ if set(obj) == {"__affine__"}:
151
+ from affine import Affine
152
+
153
+ return Affine(*obj["__affine__"])
154
+ if set(obj) == {"__crs__"}:
155
+ from rasterio.crs import CRS
156
+
157
+ return CRS.from_wkt(obj["__crs__"])
158
+ return {k: _restore(v) for k, v in obj.items()}
159
+ if isinstance(obj, list):
160
+ return [_restore(v) for v in obj]
161
+ return obj
162
+
163
+
164
+ def _fingerprint_value(v):
165
+ """A stable, comparable stand-in for one input: files by name and size, everything else by value."""
166
+ if isinstance(v, (str, Path)):
167
+ pth = Path(str(v))
168
+ try:
169
+ if pth.exists():
170
+ return f"file:{pth.name}:{pth.stat().st_size}"
171
+ except OSError:
172
+ pass
173
+ return str(v)
174
+ if isinstance(v, (bool, int, float)) or v is None:
175
+ return v
176
+ if isinstance(v, (list, tuple)):
177
+ return [_fingerprint_value(x) for x in v]
178
+ return repr(v)
179
+
180
+
181
+ def make_fingerprint(arguments: Dict[str, Any], settings: Dict[str, Any]) -> Dict[str, Any]:
182
+ """What a saved result depends on: the pipeline version, the generator settings and the process_pair inputs."""
183
+ import hashlib
184
+ import json
185
+
186
+ body = {
187
+ "pipeline_version": PIPELINE_VERSION,
188
+ "settings": {k: _fingerprint_value(v) for k, v in sorted(settings.items())},
189
+ "arguments": {k: _fingerprint_value(v) for k, v in sorted(arguments.items())},
190
+ }
191
+ body["hash"] = hashlib.sha256(json.dumps(body, sort_keys=True, default=str).encode()).hexdigest()
192
+ return body
193
+
194
+
113
195
  @dataclass
114
196
  class InterferogramResult:
115
197
  """Result of interferogram formation for one SLC pair."""
@@ -195,6 +277,34 @@ class InterferogramResult:
195
277
  dst.write(self.amplitude.astype(np.float32)[np.newaxis])
196
278
  paths["amplitude"] = amp_path
197
279
 
280
+ # Everything needed to rebuild this result exactly (the GeoTIFFs hold phase only, no complex values,
281
+ # baselines, metadata or geometry). result.json is written LAST: its presence means the save finished.
282
+ import json
283
+ import pickle
284
+
285
+ np.save(out_dir / "interferogram_complex.npy", np.asarray(self.interferogram, dtype=np.complex64))
286
+ has_geometry = self.geometry is not None
287
+ if has_geometry:
288
+ with open(out_dir / "geometry.pkl", "wb") as fh:
289
+ pickle.dump(self.geometry, fh, protocol=4)
290
+ sidecar = {
291
+ "format": _SAVE_FORMAT,
292
+ "pipeline_version": PIPELINE_VERSION,
293
+ "reference_date": self.reference_date,
294
+ "secondary_date": self.secondary_date,
295
+ "perpendicular_baseline_m": self.perpendicular_baseline_m,
296
+ "temporal_baseline_days": self.temporal_baseline_days,
297
+ "esd_azimuth_shift_px": self.esd_azimuth_shift_px,
298
+ "has_geometry": has_geometry,
299
+ "fingerprint": self.metadata.get("resume_fingerprint"),
300
+ "profile": _jsonable(self.profile),
301
+ "metadata": _jsonable(self.metadata),
302
+ }
303
+ tmp = out_dir / (_RESULT_JSON + ".tmp")
304
+ tmp.write_text(json.dumps(sidecar))
305
+ tmp.replace(out_dir / _RESULT_JSON)
306
+ paths["result"] = out_dir / _RESULT_JSON
307
+
198
308
  logger.info("Interferogram products saved → %s", out_dir)
199
309
 
200
310
  if auto_visualize:
@@ -210,6 +320,58 @@ class InterferogramResult:
210
320
 
211
321
  return paths
212
322
 
323
+ @staticmethod
324
+ def saved_fingerprint(directory: Union[str, Path]) -> Optional[Dict[str, Any]]:
325
+ """The fingerprint stored with a completed save, or None if the directory holds no complete save
326
+ (no result.json: never finished, or written by a version that did not store everything)."""
327
+ import json
328
+
329
+ f = Path(directory) / _RESULT_JSON
330
+ if not f.is_file():
331
+ return None
332
+ try:
333
+ return json.loads(f.read_text()).get("fingerprint") or {}
334
+ except (OSError, ValueError):
335
+ return None
336
+
337
+ @classmethod
338
+ def load(cls, directory: Union[str, Path]) -> "InterferogramResult":
339
+ """Rebuild a result written by save(). Raises FileNotFoundError when the save is incomplete.
340
+
341
+ geometry.pkl is read with pickle: only load directories that this pipeline wrote on your own machine."""
342
+ import json
343
+ import pickle
344
+
345
+ import numpy as np
346
+
347
+ d = Path(directory)
348
+ f = d / _RESULT_JSON
349
+ if not f.is_file():
350
+ raise FileNotFoundError(f"{d} holds no complete saved interferogram ({_RESULT_JSON} is missing)")
351
+ side = json.loads(f.read_text())
352
+ try:
353
+ import rasterio
354
+ except ImportError:
355
+ raise ImportError('rasterio required: pip install "pygeofetch[geo]"')
356
+ with rasterio.open(d / "coherence.tif") as src:
357
+ coherence = src.read(1)
358
+ with rasterio.open(d / "amplitude.tif") as src:
359
+ amplitude = src.read(1)
360
+ interferogram = np.load(d / "interferogram_complex.npy")
361
+ geometry = None
362
+ if side.get("has_geometry"):
363
+ with open(d / "geometry.pkl", "rb") as fh:
364
+ geometry = pickle.load(fh)
365
+ return cls(
366
+ interferogram=interferogram, coherence=coherence, amplitude=amplitude,
367
+ profile=_restore(side.get("profile") or {}),
368
+ reference_date=side.get("reference_date"), secondary_date=side.get("secondary_date"),
369
+ perpendicular_baseline_m=side.get("perpendicular_baseline_m"),
370
+ temporal_baseline_days=side.get("temporal_baseline_days"),
371
+ esd_azimuth_shift_px=side.get("esd_azimuth_shift_px"),
372
+ metadata=_restore(side.get("metadata") or {}), geometry=geometry,
373
+ )
374
+
213
375
  def show_on_map(
214
376
  self,
215
377
  colormap: str = "hsv",
@@ -408,6 +570,10 @@ class InterferogramGenerator:
408
570
  self._coh_window_explicit = coherence_window
409
571
  self._esd_enabled = esd_enabled
410
572
  self._use_gpu = use_gpu
573
+ if use_gpu:
574
+ # fail loudly at construction, with the reason, rather than quietly on CPU
575
+ from pygeofetch.insar.gpu import get_array_module as _gam
576
+ _gam(prefer_gpu=True)
411
577
  # Opt-in, off by default -- preserves exact existing behaviour
412
578
  # for current callers. When True and both SAFE zips are
413
579
  # supplied to process_pair(), uses real per-burst-overlap ESD
@@ -722,7 +888,11 @@ class InterferogramGenerator:
722
888
  Coherence array (float32).
723
889
  """
724
890
  np = self._np()
725
- from scipy.ndimage import uniform_filter
891
+ from pygeofetch.insar.gpu import get_array_module, to_numpy
892
+
893
+ # numpy/scipy on CPU, or cupy/cupyx on the GPU when use_gpu=True and one works.
894
+ xp, ndi, _on_gpu = get_array_module(prefer_gpu=self._use_gpu)
895
+ self._coherence_backend = "gpu" if _on_gpu else "cpu"
726
896
 
727
897
  h, w = ref.shape
728
898
  coherence = np.empty((h, w), dtype=np.float32)
@@ -737,21 +907,21 @@ class InterferogramGenerator:
737
907
  ext_start = max(0, row_start - half_win)
738
908
  ext_end = min(h, row_end + half_win)
739
909
 
740
- ref_chunk = ref[ext_start:ext_end]
741
- sec_chunk = sec[ext_start:ext_end]
910
+ ref_chunk = xp.asarray(ref[ext_start:ext_end])
911
+ sec_chunk = xp.asarray(sec[ext_start:ext_end])
742
912
 
743
913
  # Compute coherence for this chunk
744
- inter = ref_chunk * np.conj(sec_chunk)
745
- num = np.abs(
746
- uniform_filter(inter.real, size=window)
747
- + 1j * uniform_filter(inter.imag, size=window)
914
+ inter = ref_chunk * xp.conj(sec_chunk)
915
+ num = xp.abs(
916
+ ndi.uniform_filter(inter.real, size=window)
917
+ + 1j * ndi.uniform_filter(inter.imag, size=window)
748
918
  )
749
- denom = np.sqrt(
750
- uniform_filter(np.abs(ref_chunk) ** 2, size=window)
751
- * uniform_filter(np.abs(sec_chunk) ** 2, size=window)
919
+ denom = xp.sqrt(
920
+ ndi.uniform_filter(xp.abs(ref_chunk) ** 2, size=window)
921
+ * ndi.uniform_filter(xp.abs(sec_chunk) ** 2, size=window)
752
922
  + 1e-10
753
923
  )
754
- coh_chunk = np.clip(num / denom, 0.0, 1.0).astype(np.float32)
924
+ coh_chunk = to_numpy(xp.clip(num / denom, 0.0, 1.0).astype(xp.float32))
755
925
 
756
926
  # Extract the valid portion (remove the extended boundaries)
757
927
  valid_start = row_start - ext_start
@@ -1379,6 +1549,9 @@ class InterferogramGenerator:
1379
1549
  min_coreg_gcps: Optional[int] = None,
1380
1550
  max_coreg_rms_px: Optional[float] = None,
1381
1551
  max_burst_sync_ms: Optional[float] = None,
1552
+ output_dir: Optional[Union[str, Path]] = None,
1553
+ resume: bool = False,
1554
+ save_visualizations: bool = True,
1382
1555
  ) -> InterferogramResult:
1383
1556
  """
1384
1557
  Process an SLC pair into an interferogram with topographic phase removed.
@@ -1486,6 +1659,15 @@ class InterferogramGenerator:
1486
1659
  max_burst_sync_ms: Hard limit on the burst-timing offset of the pair (ESA requires under
1487
1660
  5 ms for TOPS interferometry). When set and exceeded the pair is rejected with
1488
1661
  BurstProcessingError; when None it is reported and flagged only.
1662
+ output_dir: Parent folder. The pair is saved to ``output_dir/<reference_date>_<secondary_date>``
1663
+ (GeoTIFFs, PNGs and everything needed to reload it) as soon as it is computed.
1664
+ Needs reference_date and secondary_date.
1665
+ resume: With output_dir, load the pair from disk instead of recomputing it, but only when the saved
1666
+ result carries the same fingerprint (pipeline version, generator settings, inputs and
1667
+ process_pair arguments). A folder with no complete save, or from a different pipeline
1668
+ version or settings, is recomputed and overwritten. Results saved before this feature
1669
+ existed are never reused.
1670
+ save_visualizations: With output_dir, also write the PNG plots.
1489
1671
 
1490
1672
  Returns:
1491
1673
  InterferogramResult with wrapped phase, coherence, and amplitude. ``metadata["quality"]``
@@ -1496,6 +1678,40 @@ class InterferogramGenerator:
1496
1678
  ProcessingError subclasses (all ValueError) when a step that was asked for fails, unless the
1497
1679
  generator was built with ``on_error="degrade"``.
1498
1680
  """
1681
+ # What this result depends on, taken before anything else is assigned. Used to decide on resume
1682
+ # whether a saved result was made by the same pipeline with the same inputs and settings.
1683
+ _not_inputs = {"self", "chunk_rows", "use_chunked_processing", "output_dir", "resume",
1684
+ "save_visualizations", "min_coreg_gcps", "max_coreg_rms_px", "max_burst_sync_ms"}
1685
+ _arguments = {k: v for k, v in locals().items() if k not in _not_inputs and not k.startswith("_")}
1686
+ _settings = {k: v for k, v in vars(self).items()
1687
+ if isinstance(v, (bool, int, float, str, type(None)))
1688
+ and k not in ("_use_gpu", "_chunk_size", "_on_error", "_coherence_backend")}
1689
+ _fingerprint = make_fingerprint(_arguments, _settings)
1690
+ _pair_dir = None
1691
+ if output_dir is not None:
1692
+ if not (reference_date and secondary_date):
1693
+ raise InputError("input", "output_dir needs reference_date and secondary_date to name the pair folder")
1694
+ _pair_dir = Path(output_dir) / f"{reference_date}_{secondary_date}"
1695
+ if resume:
1696
+ _saved = InterferogramResult.saved_fingerprint(_pair_dir)
1697
+ if _saved is None:
1698
+ logger.info("resume: %s_%s has no complete saved result; computing it", reference_date, secondary_date)
1699
+ elif _saved.get("hash") == _fingerprint["hash"]:
1700
+ logger.info("resume: %s_%s already generated with the same inputs and settings; loaded from disk",
1701
+ reference_date, secondary_date)
1702
+ _loaded = InterferogramResult.load(_pair_dir)
1703
+ _loaded.metadata["resumed_from_disk"] = True
1704
+ return _loaded
1705
+ else:
1706
+ _changed = [f"{grp}.{k}" for grp in ("settings", "arguments")
1707
+ for k in sorted(set(_saved.get(grp, {})) | set(_fingerprint[grp]))
1708
+ if _saved.get(grp, {}).get(k) != _fingerprint[grp].get(k)]
1709
+ if _saved.get("pipeline_version") != PIPELINE_VERSION:
1710
+ _changed.insert(0, f"pipeline_version ({_saved.get('pipeline_version')} -> {PIPELINE_VERSION})")
1711
+ logger.warning("resume: %s_%s was saved with different inputs, settings or pipeline version "
1712
+ "(changed: %s); recomputing it", reference_date, secondary_date,
1713
+ ", ".join(_changed) or "unknown")
1714
+
1499
1715
  quality = QualityRecord(on_error=self._on_error)
1500
1716
 
1501
1717
  # Resolve chunk size: explicit param > instance default > None (full)
@@ -2125,7 +2341,7 @@ class InterferogramGenerator:
2125
2341
  # amplitude was already computed above (Step 4), before
2126
2342
  # ref_complex was freed -- not recomputed here.
2127
2343
 
2128
- return InterferogramResult(
2344
+ result = InterferogramResult(
2129
2345
  interferogram=interferogram,
2130
2346
  coherence=coherence,
2131
2347
  amplitude=amplitude,
@@ -2180,6 +2396,7 @@ class InterferogramGenerator:
2180
2396
  ),
2181
2397
  "crop_after_deburst_applied": crop_info is not None,
2182
2398
  "crop_info": crop_info,
2399
+ "coherence_backend": getattr(self, "_coherence_backend", "cpu"),
2183
2400
  "chunked_processing": use_chunked_processing
2184
2401
  and effective_chunk is not None,
2185
2402
  "chunk_rows": effective_chunk,
@@ -2188,8 +2405,12 @@ class InterferogramGenerator:
2188
2405
  "esd_residual_after_correction_px": burst_metadata.get("esd_residual_after_correction_px"),
2189
2406
  "quality": quality.to_dict(),
2190
2407
  "quality_grade": quality.grade,
2408
+ "resume_fingerprint": _fingerprint,
2191
2409
  },
2192
2410
  )
2411
+ if _pair_dir is not None:
2412
+ result.save(_pair_dir, auto_visualize=save_visualizations)
2413
+ return result
2193
2414
 
2194
2415
  # ══════════════════════════════════════════════════════════════════
2195
2416
  # INTERNAL HELPERS
@@ -2981,6 +3202,7 @@ class InterferogramGenerator:
2981
3202
  from pygeofetch.insar.gpu import get_array_module, to_numpy
2982
3203
 
2983
3204
  xp, ndi, using_gpu = get_array_module(prefer_gpu=self._use_gpu)
3205
+ self._coherence_backend = "gpu" if using_gpu else "cpu"
2984
3206
 
2985
3207
  ref_x = xp.asarray(ref)
2986
3208
  sec_x = xp.asarray(sec)
pygeofetch/meta.yaml CHANGED
@@ -1,4 +1,4 @@
1
- {% set version = "2.6.9.2.4" %}
1
+ {% set version = "2.6.9.3.4" %}
2
2
 
3
3
  package:
4
4
  name: pygeofetch
pygeofetch/viz/insar.py CHANGED
@@ -17,7 +17,7 @@ Usage::
17
17
  figs.baseline_network(pos, gp, scenes, interferograms=interferograms)
18
18
  figs.pair_sheet(pair, interferograms)
19
19
 
20
- Conventions: axes in kilometres, cyclic ``twilight`` for wrapped phase only,
20
+ Conventions: axes in kilometres, cyclic ``hsv`` (rainbow) for wrapped phase only, the same map the interferogram PNGs use,
21
21
  sequential single-hue for magnitudes, two-hue diverging for signed values.
22
22
  One fringe is half a wavelength of line-of-sight change.
23
23
 
@@ -47,7 +47,7 @@ Pair = Tuple[str, str]
47
47
  INK, INK2, GRID_C, SURF = "#0b0b0b", "#52514e", "#dcdbd6", "#fcfcfb"
48
48
  C_S1A, C_S1B = "#2a78d6", "#eb6834" # satellite identity, same in every figure
49
49
  C_IN, C_OUT, C_UNK = "#1baf7a", "#8a8984", "#52514e" # burst timing: in spec / out of spec / unknown
50
- PHASE_CMAP = "twilight" # cyclic: -pi and +pi look identical
50
+ PHASE_CMAP = "hsv" # cyclic rainbow: -pi and +pi are both red; same map as insar.visualize
51
51
 
52
52
  _RC = {
53
53
  "figure.facecolor": SURF, "axes.facecolor": SURF, "savefig.facecolor": SURF, "text.color": INK,
@@ -1088,4 +1088,4 @@ class InSARFigures:
1088
1088
  return out
1089
1089
 
1090
1090
 
1091
- __all__ = ["InSARFigures", "SarGeometry", "relative_orbit"]
1091
+ __all__ = ["InSARFigures", "SarGeometry", "relative_orbit"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygeofetch
3
- Version: 2.6.9.2
3
+ Version: 2.6.9.3
4
4
  Summary: Universal satellite data pipeline + geospatial processing platform
5
5
  Author-email: Samuel Appiah Kubi <appiahkubis14@gmail.com>
6
6
  License: MIT License
@@ -371,7 +371,7 @@ If you use PyGeoFetch in your research or operational work, please cite it using
371
371
  title = {PyGeoFetch: A Unified Python Framework for Multi-Provider Satellite Data Acquisition, Pre-download Quality Control, and Geospatial Processing},
372
372
  year = {2026},
373
373
  publisher = {Zenodo},
374
- version = {2.6.9.2.1},
374
+ version = {2.6.9.3.1},
375
375
  doi = {10.5281/zenodo.22087230},
376
376
  url = {https://doi.org/10.5281/zenodo.22087230}
377
377
  }
@@ -1,5 +1,5 @@
1
- pygeofetch/__init__.py,sha256=fTgGbEl7ZQ7juESG_PxmNnfudV8eGHoIeKaPfPbgUec,2107
2
- pygeofetch/meta.yaml,sha256=ZFrlvfXLV9GdGr5gXOWMwF3fKNxKAUX5p1yy_hNOg6s,1284
1
+ pygeofetch/__init__.py,sha256=Yx4DWUzdzhCGIu26pH6uOE2xrepSjP14zmCHEiX6UTU,2107
2
+ pygeofetch/meta.yaml,sha256=J2bfb-BvIUmFS29zD4er8Li-fN5-V13sM5lHvLbihBc,1284
3
3
  pygeofetch/cli/__init__.py,sha256=QZMIIHEgmjGFieucqq9fZ5uephxP9-jdu1s8Q4qqw8o,30
4
4
  pygeofetch/cli/auth_commands.py,sha256=OUYbInPaERvAfNZ_NmAF3azHoJm14cGn_ZTQtxjjcs4,7871
5
5
  pygeofetch/cli/classify_commands.py,sha256=0att8QoTKPa-z24NXLTW-iXbpkBWZTxjoZkV1eNwHeU,4739
@@ -38,7 +38,7 @@ pygeofetch/core/data_formats/geoparquet_io.py,sha256=nSzLm4QSUPn1FkYC0DRr2vSKKg5
38
38
  pygeofetch/core/data_formats/zarr_io.py,sha256=vjvg151I9vifWbOeEzzz8fkK571ACCghLVGaWkCHmIs,9034
39
39
  pygeofetch/geotech/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  pygeofetch/geotech/risk_mapper.py,sha256=6WBtUOG-bclyS_6JUDjp2UH3hwZ9tvOm43SPD3M3dk0,12101
41
- pygeofetch/insar/__init__.py,sha256=hbrWnyE2Ue0BRf6Z8bFZvNxquny_kssZwmp_HROVdY0,14622
41
+ pygeofetch/insar/__init__.py,sha256=z-E7WuPWrHXpvTs-GGPVAxgCGPdwk33h2GzLXuXW9EQ,14648
42
42
  pygeofetch/insar/advanced_safeguards.py,sha256=bwq3ZZulDYdK3SWwVQ--3-i_yjOJEEya7YEWpQkHu4k,15427
43
43
  pygeofetch/insar/analysis.py,sha256=GLNNE2OY17Y92p4FJSu7DwitRRp6AFLj1hccSmw3Mqg,35770
44
44
  pygeofetch/insar/annotation.py,sha256=hQf_SnvcMpKanCdIaX3yTdygxhd57sJtz_3_L83zRmY,21767
@@ -53,9 +53,9 @@ pygeofetch/insar/extraction.py,sha256=J6YjszYvHi6lizX5vGq71KuMLHmYqtdG-oDUUb60ad
53
53
  pygeofetch/insar/feasibility.py,sha256=4301EIaqy4jtME1NaNvIwSyqJY7ZH39Hto6Uk0c_M5Q,13371
54
54
  pygeofetch/insar/flatearth.py,sha256=gSUdDcHlxs3P2TrUkKFkIwq7GftKVOit0A47CaBKIvc,13566
55
55
  pygeofetch/insar/geolocation.py,sha256=7T84uNHIXGmuOCvru9CJkFrnet4HX3t-thXXro2peRk,34163
56
- pygeofetch/insar/gpu.py,sha256=hWmIpWcTaVb20wfwCjcz3zsw3w8diy--24XxJAD2_ZQ,3955
56
+ pygeofetch/insar/gpu.py,sha256=tMQSurv6EmmQMFU-e9--ssZo0YRUooPRHyU0V8jamIQ,5726
57
57
  pygeofetch/insar/hybrid_unwrap.py,sha256=PT4G9UPTrMqftaMjFd0i9DkwmtRZXAqN504eLYc22ds,18477
58
- pygeofetch/insar/interferogram.py,sha256=STJeICJYdZJdS7GkiSoOQcMiZIrKoZRITz2fsMIgqmg,144655
58
+ pygeofetch/insar/interferogram.py,sha256=Yw8Sb3TRbJUD3k2gzu4JGNYl16fu75tCzk-7AoY7bHc,155395
59
59
  pygeofetch/insar/ionosphere.py,sha256=erfzXKGxWLcLvNZznBCx42t6V05oO3M9q-nbrGzrKyc,30987
60
60
  pygeofetch/insar/learned_unwrap.py,sha256=lSX_u-2U5mm8lRKhO0xBMk1dVYcR3wDh6pFWcPdR350,45950
61
61
  pygeofetch/insar/network_thinning.py,sha256=2cuTn_fmSWqvORWz7gH2roYqABnIVe0hZ7BDvIe2Cwc,9826
@@ -163,12 +163,12 @@ pygeofetch/utils/validators.py,sha256=f-k3mGFP4byjimyDymhPEdsz5I16jZacx1HSnwrARj
163
163
  pygeofetch/validation/__init__.py,sha256=39P7zn2qaQDCRFa8l-vFPbGmcf5g458zqWwHpiakaIA,658
164
164
  pygeofetch/validation/optical_validator.py,sha256=S0D361GibQwA2vvGb9_H8_6mxvaFKDjNPGCduvLeiAw,37702
165
165
  pygeofetch/viz/__init__.py,sha256=bSgK_f_goAHVQOfYu2nbPFVushvsy2hVKBvIBoGonyk,539
166
- pygeofetch/viz/insar.py,sha256=ECf3k5lIOYmURCKAHNPzcARBOftPCosSuGwt259X0_4,56667
166
+ pygeofetch/viz/insar.py,sha256=SaHBsbmvxAF4dLYptePX3wvKWV8Y2Sxqn8pFDjvyXuk,56742
167
167
  pygeofetch/viz/map.py,sha256=f8whny5mnz7gDsStNdgtVSpqTNHSDhSZoRT2Qs-Lvos,16403
168
168
  pygeofetch/viz/plot.py,sha256=JybD4qElJBOTvWCu7VllL5DqkKFYf5ttJdFfsgApfLE,56601
169
- pygeofetch-2.6.9.2.dist-info/licenses/LICENSE,sha256=zavMyhODD6NvZTmmKFEtATrngwY4CU_NEtY7lhjxGnI,1075
170
- pygeofetch-2.6.9.2.dist-info/METADATA,sha256=paZHheDURcbKlOdExn-As_IqHP3TRffhlpBlGAAO3i8,25014
171
- pygeofetch-2.6.9.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
172
- pygeofetch-2.6.9.2.dist-info/entry_points.txt,sha256=dHiUXLF5xNJ8vgtXZoUQNleEMQUeDPZiKQOE1tW8SDY,55
173
- pygeofetch-2.6.9.2.dist-info/top_level.txt,sha256=rOmnZargIfNk99fwVOqt6OJyJvpSTBBAYO5HU37yhHk,11
174
- pygeofetch-2.6.9.2.dist-info/RECORD,,
169
+ pygeofetch-2.6.9.3.dist-info/licenses/LICENSE,sha256=zavMyhODD6NvZTmmKFEtATrngwY4CU_NEtY7lhjxGnI,1075
170
+ pygeofetch-2.6.9.3.dist-info/METADATA,sha256=owMnDiTrLNs5fc31hMSgZl1zxhoyVWyPNp1jl4H-3ME,25014
171
+ pygeofetch-2.6.9.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
172
+ pygeofetch-2.6.9.3.dist-info/entry_points.txt,sha256=dHiUXLF5xNJ8vgtXZoUQNleEMQUeDPZiKQOE1tW8SDY,55
173
+ pygeofetch-2.6.9.3.dist-info/top_level.txt,sha256=rOmnZargIfNk99fwVOqt6OJyJvpSTBBAYO5HU37yhHk,11
174
+ pygeofetch-2.6.9.3.dist-info/RECORD,,