PyGeoFetch 2.6.9.2__py3-none-any.whl → 2.6.9.4__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 +1 -1
- pygeofetch/insar/__init__.py +5 -1
- pygeofetch/insar/coregister.py +8 -6
- pygeofetch/insar/gpu.py +76 -29
- pygeofetch/insar/interferogram.py +280 -18
- pygeofetch/insar/logs.py +62 -0
- pygeofetch/insar/topo.py +19 -3
- pygeofetch/meta.yaml +1 -1
- pygeofetch/viz/insar.py +3 -3
- {pygeofetch-2.6.9.2.dist-info → pygeofetch-2.6.9.4.dist-info}/METADATA +2 -2
- {pygeofetch-2.6.9.2.dist-info → pygeofetch-2.6.9.4.dist-info}/RECORD +15 -14
- {pygeofetch-2.6.9.2.dist-info → pygeofetch-2.6.9.4.dist-info}/WHEEL +0 -0
- {pygeofetch-2.6.9.2.dist-info → pygeofetch-2.6.9.4.dist-info}/entry_points.txt +0 -0
- {pygeofetch-2.6.9.2.dist-info → pygeofetch-2.6.9.4.dist-info}/licenses/LICENSE +0 -0
- {pygeofetch-2.6.9.2.dist-info → pygeofetch-2.6.9.4.dist-info}/top_level.txt +0 -0
pygeofetch/__init__.py
CHANGED
pygeofetch/insar/__init__.py
CHANGED
|
@@ -144,7 +144,8 @@ 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
|
+
from pygeofetch.insar.logs import set_verbosity, current_verbosity
|
|
148
149
|
from pygeofetch.insar.errors import (
|
|
149
150
|
BurstProcessingError, CoregistrationError, CropError, FlatEarthError, InputError, ProcessingError,
|
|
150
151
|
QualityRecord, TopographicPhaseError, AtmosphereError, GeometryProcessingError,
|
|
@@ -299,6 +300,9 @@ __all__ = [
|
|
|
299
300
|
"ValidationResult",
|
|
300
301
|
"PairClassification",
|
|
301
302
|
"gpu_available",
|
|
303
|
+
"gpu_info",
|
|
304
|
+
"set_verbosity",
|
|
305
|
+
"current_verbosity",
|
|
302
306
|
"visualize_interferogram",
|
|
303
307
|
"visualize_unwrapped",
|
|
304
308
|
"visualize_timeseries",
|
pygeofetch/insar/coregister.py
CHANGED
|
@@ -1187,7 +1187,7 @@ def fit_offset_polynomial_robust(
|
|
|
1187
1187
|
iterations_used=iterations_used,
|
|
1188
1188
|
degree=degree,
|
|
1189
1189
|
)
|
|
1190
|
-
quality.log_summary()
|
|
1190
|
+
quality.log_summary(logging.DEBUG) # the caller logs the one summary line that includes the coherence
|
|
1191
1191
|
return row_fn, col_fn, quality
|
|
1192
1192
|
|
|
1193
1193
|
|
|
@@ -1397,8 +1397,9 @@ def resample_with_offset_field(
|
|
|
1397
1397
|
# one row-block regardless of total crop size.
|
|
1398
1398
|
|
|
1399
1399
|
h, w = data.shape
|
|
1400
|
-
|
|
1401
|
-
|
|
1400
|
+
# One complex64 output filled tile by tile. The previous version built two float32 planes and then
|
|
1401
|
+
# (out_real + 1j * out_imag).astype(complex64), which held about four extra full-size arrays at the end.
|
|
1402
|
+
out = np.empty((h, w), dtype=np.complex64)
|
|
1402
1403
|
data_real = data.real
|
|
1403
1404
|
data_imag = data.imag
|
|
1404
1405
|
|
|
@@ -1432,14 +1433,15 @@ def resample_with_offset_field(
|
|
|
1432
1433
|
sample_cols, (r_end - r_start, c_end - c_start)
|
|
1433
1434
|
)
|
|
1434
1435
|
|
|
1435
|
-
|
|
1436
|
+
tile = out[r_start:r_end, c_start:c_end]
|
|
1437
|
+
tile.real = map_coordinates(
|
|
1436
1438
|
data_real,
|
|
1437
1439
|
[sample_rows_2d, sample_cols_2d],
|
|
1438
1440
|
order=1,
|
|
1439
1441
|
mode="constant",
|
|
1440
1442
|
cval=0.0,
|
|
1441
1443
|
)
|
|
1442
|
-
|
|
1444
|
+
tile.imag = map_coordinates(
|
|
1443
1445
|
data_imag,
|
|
1444
1446
|
[sample_rows_2d, sample_cols_2d],
|
|
1445
1447
|
order=1,
|
|
@@ -1449,7 +1451,7 @@ def resample_with_offset_field(
|
|
|
1449
1451
|
|
|
1450
1452
|
del sample_rows_2d, sample_cols_2d, offset_row, offset_col
|
|
1451
1453
|
|
|
1452
|
-
return
|
|
1454
|
+
return out
|
|
1453
1455
|
# chunk_rows = max(1, min(h, 2000))
|
|
1454
1456
|
# for row_start in range(0, h, chunk_rows):
|
|
1455
1457
|
# row_end = min(row_start + chunk_rows, h)
|
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
|
|
48
|
-
"""
|
|
49
|
-
|
|
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
|
|
53
|
+
return
|
|
58
54
|
_gpu_checked = True
|
|
59
55
|
try:
|
|
60
56
|
import cupy as cp
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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,98 @@ 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 stand-in for one input. Archives and orbit files by name (it carries the acquisition id);
|
|
166
|
+
GeoTIFFs by name and raster shape (a re-extracted or re-clipped copy of the same data is the same input, whereas
|
|
167
|
+
byte size and timestamps change when a file is merely rewritten); everything else by value."""
|
|
168
|
+
if isinstance(v, (str, Path)):
|
|
169
|
+
pth = Path(str(v))
|
|
170
|
+
try:
|
|
171
|
+
if pth.is_file():
|
|
172
|
+
if pth.suffix.lower() in (".tif", ".tiff"):
|
|
173
|
+
try:
|
|
174
|
+
import rasterio
|
|
175
|
+
|
|
176
|
+
with rasterio.open(pth) as src:
|
|
177
|
+
return f"raster:{pth.name}:{src.count}x{src.height}x{src.width}:{src.dtypes[0]}"
|
|
178
|
+
except Exception:
|
|
179
|
+
return f"file:{pth.name}"
|
|
180
|
+
return f"file:{pth.name}"
|
|
181
|
+
except OSError:
|
|
182
|
+
pass
|
|
183
|
+
return str(v)
|
|
184
|
+
if isinstance(v, (bool, int, float)) or v is None:
|
|
185
|
+
return v
|
|
186
|
+
if isinstance(v, (list, tuple)):
|
|
187
|
+
return [_fingerprint_value(x) for x in v]
|
|
188
|
+
return repr(v)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def make_fingerprint(arguments: Dict[str, Any], settings: Dict[str, Any]) -> Dict[str, Any]:
|
|
192
|
+
"""What a saved result depends on: the pipeline version, the generator settings and the process_pair inputs."""
|
|
193
|
+
import hashlib
|
|
194
|
+
import json
|
|
195
|
+
|
|
196
|
+
body = {
|
|
197
|
+
"pipeline_version": PIPELINE_VERSION,
|
|
198
|
+
"settings": {k: _fingerprint_value(v) for k, v in sorted(settings.items())},
|
|
199
|
+
"arguments": {k: _fingerprint_value(v) for k, v in sorted(arguments.items())},
|
|
200
|
+
}
|
|
201
|
+
body["hash"] = hashlib.sha256(json.dumps(body, sort_keys=True, default=str).encode()).hexdigest()
|
|
202
|
+
return body
|
|
203
|
+
|
|
204
|
+
|
|
113
205
|
@dataclass
|
|
114
206
|
class InterferogramResult:
|
|
115
207
|
"""Result of interferogram formation for one SLC pair."""
|
|
@@ -195,6 +287,34 @@ class InterferogramResult:
|
|
|
195
287
|
dst.write(self.amplitude.astype(np.float32)[np.newaxis])
|
|
196
288
|
paths["amplitude"] = amp_path
|
|
197
289
|
|
|
290
|
+
# Everything needed to rebuild this result exactly (the GeoTIFFs hold phase only, no complex values,
|
|
291
|
+
# baselines, metadata or geometry). result.json is written LAST: its presence means the save finished.
|
|
292
|
+
import json
|
|
293
|
+
import pickle
|
|
294
|
+
|
|
295
|
+
np.save(out_dir / "interferogram_complex.npy", np.asarray(self.interferogram, dtype=np.complex64))
|
|
296
|
+
has_geometry = self.geometry is not None
|
|
297
|
+
if has_geometry:
|
|
298
|
+
with open(out_dir / "geometry.pkl", "wb") as fh:
|
|
299
|
+
pickle.dump(self.geometry, fh, protocol=4)
|
|
300
|
+
sidecar = {
|
|
301
|
+
"format": _SAVE_FORMAT,
|
|
302
|
+
"pipeline_version": PIPELINE_VERSION,
|
|
303
|
+
"reference_date": self.reference_date,
|
|
304
|
+
"secondary_date": self.secondary_date,
|
|
305
|
+
"perpendicular_baseline_m": self.perpendicular_baseline_m,
|
|
306
|
+
"temporal_baseline_days": self.temporal_baseline_days,
|
|
307
|
+
"esd_azimuth_shift_px": self.esd_azimuth_shift_px,
|
|
308
|
+
"has_geometry": has_geometry,
|
|
309
|
+
"fingerprint": self.metadata.get("resume_fingerprint"),
|
|
310
|
+
"profile": _jsonable(self.profile),
|
|
311
|
+
"metadata": _jsonable(self.metadata),
|
|
312
|
+
}
|
|
313
|
+
tmp = out_dir / (_RESULT_JSON + ".tmp")
|
|
314
|
+
tmp.write_text(json.dumps(sidecar))
|
|
315
|
+
tmp.replace(out_dir / _RESULT_JSON)
|
|
316
|
+
paths["result"] = out_dir / _RESULT_JSON
|
|
317
|
+
|
|
198
318
|
logger.info("Interferogram products saved → %s", out_dir)
|
|
199
319
|
|
|
200
320
|
if auto_visualize:
|
|
@@ -210,6 +330,58 @@ class InterferogramResult:
|
|
|
210
330
|
|
|
211
331
|
return paths
|
|
212
332
|
|
|
333
|
+
@staticmethod
|
|
334
|
+
def saved_fingerprint(directory: Union[str, Path]) -> Optional[Dict[str, Any]]:
|
|
335
|
+
"""The fingerprint stored with a completed save, or None if the directory holds no complete save
|
|
336
|
+
(no result.json: never finished, or written by a version that did not store everything)."""
|
|
337
|
+
import json
|
|
338
|
+
|
|
339
|
+
f = Path(directory) / _RESULT_JSON
|
|
340
|
+
if not f.is_file():
|
|
341
|
+
return None
|
|
342
|
+
try:
|
|
343
|
+
return json.loads(f.read_text()).get("fingerprint") or {}
|
|
344
|
+
except (OSError, ValueError):
|
|
345
|
+
return None
|
|
346
|
+
|
|
347
|
+
@classmethod
|
|
348
|
+
def load(cls, directory: Union[str, Path]) -> "InterferogramResult":
|
|
349
|
+
"""Rebuild a result written by save(). Raises FileNotFoundError when the save is incomplete.
|
|
350
|
+
|
|
351
|
+
geometry.pkl is read with pickle: only load directories that this pipeline wrote on your own machine."""
|
|
352
|
+
import json
|
|
353
|
+
import pickle
|
|
354
|
+
|
|
355
|
+
import numpy as np
|
|
356
|
+
|
|
357
|
+
d = Path(directory)
|
|
358
|
+
f = d / _RESULT_JSON
|
|
359
|
+
if not f.is_file():
|
|
360
|
+
raise FileNotFoundError(f"{d} holds no complete saved interferogram ({_RESULT_JSON} is missing)")
|
|
361
|
+
side = json.loads(f.read_text())
|
|
362
|
+
try:
|
|
363
|
+
import rasterio
|
|
364
|
+
except ImportError:
|
|
365
|
+
raise ImportError('rasterio required: pip install "pygeofetch[geo]"')
|
|
366
|
+
with rasterio.open(d / "coherence.tif") as src:
|
|
367
|
+
coherence = src.read(1)
|
|
368
|
+
with rasterio.open(d / "amplitude.tif") as src:
|
|
369
|
+
amplitude = src.read(1)
|
|
370
|
+
interferogram = np.load(d / "interferogram_complex.npy")
|
|
371
|
+
geometry = None
|
|
372
|
+
if side.get("has_geometry"):
|
|
373
|
+
with open(d / "geometry.pkl", "rb") as fh:
|
|
374
|
+
geometry = pickle.load(fh)
|
|
375
|
+
return cls(
|
|
376
|
+
interferogram=interferogram, coherence=coherence, amplitude=amplitude,
|
|
377
|
+
profile=_restore(side.get("profile") or {}),
|
|
378
|
+
reference_date=side.get("reference_date"), secondary_date=side.get("secondary_date"),
|
|
379
|
+
perpendicular_baseline_m=side.get("perpendicular_baseline_m"),
|
|
380
|
+
temporal_baseline_days=side.get("temporal_baseline_days"),
|
|
381
|
+
esd_azimuth_shift_px=side.get("esd_azimuth_shift_px"),
|
|
382
|
+
metadata=_restore(side.get("metadata") or {}), geometry=geometry,
|
|
383
|
+
)
|
|
384
|
+
|
|
213
385
|
def show_on_map(
|
|
214
386
|
self,
|
|
215
387
|
colormap: str = "hsv",
|
|
@@ -338,6 +510,9 @@ class InterferogramGenerator:
|
|
|
338
510
|
meaningful for burst-mode (TOPS) SLC pairs;
|
|
339
511
|
has no effect on already-deburst/stripmap data.
|
|
340
512
|
use_gpu: Use CuPy GPU acceleration if available.
|
|
513
|
+
verbosity: None leaves logging alone. "quiet" | "normal" | "full" | "debug": how much the InSAR
|
|
514
|
+
modules log (see pygeofetch.insar.logs). "normal" drops the per-pair repeats of the
|
|
515
|
+
"Parsed real SLC geometry", "Parsed orbit state vectors" and "Plot saved" lines.
|
|
341
516
|
use_real_burst_processing: Use real per-burst-overlap ESD and
|
|
342
517
|
real deburst (requires SAFE zips).
|
|
343
518
|
remove_flat_earth_phase: Remove the geometric orbital/flat-earth
|
|
@@ -380,6 +555,7 @@ class InterferogramGenerator:
|
|
|
380
555
|
coherence_window: Optional[int] = None,
|
|
381
556
|
esd_enabled: bool = True,
|
|
382
557
|
use_gpu: bool = False,
|
|
558
|
+
verbosity: Optional[str] = None,
|
|
383
559
|
use_real_burst_processing: bool = False,
|
|
384
560
|
remove_flat_earth_phase: Optional[bool] = None,
|
|
385
561
|
chunk_size: Optional[int] = None,
|
|
@@ -408,6 +584,14 @@ class InterferogramGenerator:
|
|
|
408
584
|
self._coh_window_explicit = coherence_window
|
|
409
585
|
self._esd_enabled = esd_enabled
|
|
410
586
|
self._use_gpu = use_gpu
|
|
587
|
+
if verbosity is not None:
|
|
588
|
+
from pygeofetch.insar.logs import set_verbosity
|
|
589
|
+
|
|
590
|
+
set_verbosity(verbosity)
|
|
591
|
+
if use_gpu:
|
|
592
|
+
# fail loudly at construction, with the reason, rather than quietly on CPU
|
|
593
|
+
from pygeofetch.insar.gpu import get_array_module as _gam
|
|
594
|
+
_gam(prefer_gpu=True)
|
|
411
595
|
# Opt-in, off by default -- preserves exact existing behaviour
|
|
412
596
|
# for current callers. When True and both SAFE zips are
|
|
413
597
|
# supplied to process_pair(), uses real per-burst-overlap ESD
|
|
@@ -722,7 +906,11 @@ class InterferogramGenerator:
|
|
|
722
906
|
Coherence array (float32).
|
|
723
907
|
"""
|
|
724
908
|
np = self._np()
|
|
725
|
-
from
|
|
909
|
+
from pygeofetch.insar.gpu import get_array_module, to_numpy
|
|
910
|
+
|
|
911
|
+
# numpy/scipy on CPU, or cupy/cupyx on the GPU when use_gpu=True and one works.
|
|
912
|
+
xp, ndi, _on_gpu = get_array_module(prefer_gpu=self._use_gpu)
|
|
913
|
+
self._coherence_backend = "gpu" if _on_gpu else "cpu"
|
|
726
914
|
|
|
727
915
|
h, w = ref.shape
|
|
728
916
|
coherence = np.empty((h, w), dtype=np.float32)
|
|
@@ -737,21 +925,21 @@ class InterferogramGenerator:
|
|
|
737
925
|
ext_start = max(0, row_start - half_win)
|
|
738
926
|
ext_end = min(h, row_end + half_win)
|
|
739
927
|
|
|
740
|
-
ref_chunk = ref[ext_start:ext_end]
|
|
741
|
-
sec_chunk = sec[ext_start:ext_end]
|
|
928
|
+
ref_chunk = xp.asarray(ref[ext_start:ext_end])
|
|
929
|
+
sec_chunk = xp.asarray(sec[ext_start:ext_end])
|
|
742
930
|
|
|
743
931
|
# Compute coherence for this chunk
|
|
744
|
-
inter = ref_chunk *
|
|
745
|
-
num =
|
|
746
|
-
uniform_filter(inter.real, size=window)
|
|
747
|
-
+ 1j * uniform_filter(inter.imag, size=window)
|
|
932
|
+
inter = ref_chunk * xp.conj(sec_chunk)
|
|
933
|
+
num = xp.abs(
|
|
934
|
+
ndi.uniform_filter(inter.real, size=window)
|
|
935
|
+
+ 1j * ndi.uniform_filter(inter.imag, size=window)
|
|
748
936
|
)
|
|
749
|
-
denom =
|
|
750
|
-
uniform_filter(
|
|
751
|
-
* uniform_filter(
|
|
937
|
+
denom = xp.sqrt(
|
|
938
|
+
ndi.uniform_filter(xp.abs(ref_chunk) ** 2, size=window)
|
|
939
|
+
* ndi.uniform_filter(xp.abs(sec_chunk) ** 2, size=window)
|
|
752
940
|
+ 1e-10
|
|
753
941
|
)
|
|
754
|
-
coh_chunk =
|
|
942
|
+
coh_chunk = to_numpy(xp.clip(num / denom, 0.0, 1.0).astype(xp.float32))
|
|
755
943
|
|
|
756
944
|
# Extract the valid portion (remove the extended boundaries)
|
|
757
945
|
valid_start = row_start - ext_start
|
|
@@ -1379,6 +1567,9 @@ class InterferogramGenerator:
|
|
|
1379
1567
|
min_coreg_gcps: Optional[int] = None,
|
|
1380
1568
|
max_coreg_rms_px: Optional[float] = None,
|
|
1381
1569
|
max_burst_sync_ms: Optional[float] = None,
|
|
1570
|
+
output_dir: Optional[Union[str, Path]] = None,
|
|
1571
|
+
resume: bool = False,
|
|
1572
|
+
save_visualizations: bool = True,
|
|
1382
1573
|
) -> InterferogramResult:
|
|
1383
1574
|
"""
|
|
1384
1575
|
Process an SLC pair into an interferogram with topographic phase removed.
|
|
@@ -1486,6 +1677,15 @@ class InterferogramGenerator:
|
|
|
1486
1677
|
max_burst_sync_ms: Hard limit on the burst-timing offset of the pair (ESA requires under
|
|
1487
1678
|
5 ms for TOPS interferometry). When set and exceeded the pair is rejected with
|
|
1488
1679
|
BurstProcessingError; when None it is reported and flagged only.
|
|
1680
|
+
output_dir: Parent folder. The pair is saved to ``output_dir/<reference_date>_<secondary_date>``
|
|
1681
|
+
(GeoTIFFs, PNGs and everything needed to reload it) as soon as it is computed.
|
|
1682
|
+
Needs reference_date and secondary_date.
|
|
1683
|
+
resume: With output_dir, load the pair from disk instead of recomputing it, but only when the saved
|
|
1684
|
+
result carries the same fingerprint (pipeline version, generator settings, inputs and
|
|
1685
|
+
process_pair arguments). A folder with no complete save, or from a different pipeline
|
|
1686
|
+
version or settings, is recomputed and overwritten. Results saved before this feature
|
|
1687
|
+
existed are never reused.
|
|
1688
|
+
save_visualizations: With output_dir, also write the PNG plots.
|
|
1489
1689
|
|
|
1490
1690
|
Returns:
|
|
1491
1691
|
InterferogramResult with wrapped phase, coherence, and amplitude. ``metadata["quality"]``
|
|
@@ -1496,6 +1696,44 @@ class InterferogramGenerator:
|
|
|
1496
1696
|
ProcessingError subclasses (all ValueError) when a step that was asked for fails, unless the
|
|
1497
1697
|
generator was built with ``on_error="degrade"``.
|
|
1498
1698
|
"""
|
|
1699
|
+
# What this result depends on, taken before anything else is assigned. Used to decide on resume
|
|
1700
|
+
# whether a saved result was made by the same pipeline with the same inputs and settings.
|
|
1701
|
+
_not_inputs = {"self", "chunk_rows", "use_chunked_processing", "output_dir", "resume",
|
|
1702
|
+
"save_visualizations", "min_coreg_gcps", "max_coreg_rms_px", "max_burst_sync_ms"}
|
|
1703
|
+
_arguments = {k: v for k, v in locals().items() if k not in _not_inputs and not k.startswith("_")}
|
|
1704
|
+
_settings = {k: v for k, v in vars(self).items()
|
|
1705
|
+
if isinstance(v, (bool, int, float, str, type(None)))
|
|
1706
|
+
and k not in ("_use_gpu", "_chunk_size", "_on_error", "_coherence_backend")}
|
|
1707
|
+
_fingerprint = make_fingerprint(_arguments, _settings)
|
|
1708
|
+
_pair_dir = None
|
|
1709
|
+
_resume_note = "resume not requested" if not resume else "no output_dir"
|
|
1710
|
+
if output_dir is not None:
|
|
1711
|
+
if not (reference_date and secondary_date):
|
|
1712
|
+
raise InputError("input", "output_dir needs reference_date and secondary_date to name the pair folder")
|
|
1713
|
+
_pair_dir = Path(output_dir) / f"{reference_date}_{secondary_date}"
|
|
1714
|
+
if resume:
|
|
1715
|
+
_saved = InterferogramResult.saved_fingerprint(_pair_dir)
|
|
1716
|
+
if _saved is None:
|
|
1717
|
+
_resume_note = "computed: no complete saved result in the folder"
|
|
1718
|
+
logger.info("resume: %s_%s has no complete saved result; computing it", reference_date, secondary_date)
|
|
1719
|
+
elif _saved.get("hash") == _fingerprint["hash"]:
|
|
1720
|
+
logger.info("resume: %s_%s already generated with the same inputs and settings; loaded from disk",
|
|
1721
|
+
reference_date, secondary_date)
|
|
1722
|
+
_loaded = InterferogramResult.load(_pair_dir)
|
|
1723
|
+
_loaded.metadata["resumed_from_disk"] = True
|
|
1724
|
+
_loaded.metadata["resume_status"] = "loaded from disk"
|
|
1725
|
+
return _loaded
|
|
1726
|
+
else:
|
|
1727
|
+
_changed = [f"{grp}.{k}" for grp in ("settings", "arguments")
|
|
1728
|
+
for k in sorted(set(_saved.get(grp, {})) | set(_fingerprint[grp]))
|
|
1729
|
+
if _saved.get(grp, {}).get(k) != _fingerprint[grp].get(k)]
|
|
1730
|
+
if _saved.get("pipeline_version") != PIPELINE_VERSION:
|
|
1731
|
+
_changed.insert(0, f"pipeline_version ({_saved.get('pipeline_version')} -> {PIPELINE_VERSION})")
|
|
1732
|
+
_resume_note = "computed: saved result differs in " + (", ".join(_changed) or "unknown")
|
|
1733
|
+
logger.warning("resume: %s_%s was saved with different inputs, settings or pipeline version "
|
|
1734
|
+
"(changed: %s); recomputing it", reference_date, secondary_date,
|
|
1735
|
+
", ".join(_changed) or "unknown")
|
|
1736
|
+
|
|
1499
1737
|
quality = QualityRecord(on_error=self._on_error)
|
|
1500
1738
|
|
|
1501
1739
|
# Resolve chunk size: explicit param > instance default > None (full)
|
|
@@ -1887,8 +2125,14 @@ class InterferogramGenerator:
|
|
|
1887
2125
|
"Multilook %dx%d (azimuth x range) of the interferogram: %s -> %s",
|
|
1888
2126
|
looks_azimuth, looks_range, ref_complex.shape, out_shape,
|
|
1889
2127
|
)
|
|
1890
|
-
|
|
1891
|
-
|
|
2128
|
+
# Row blocks into one complex64 array. The one-line form built a conjugated copy, the product and a
|
|
2129
|
+
# third astype() copy of the whole scene; this holds only the result and one block.
|
|
2130
|
+
_np_ = self._np()
|
|
2131
|
+
interferogram = _np_.empty((_h_full, _w_full), dtype=_np_.complex64)
|
|
2132
|
+
_rb = max(16, 4_000_000 // _w_full)
|
|
2133
|
+
for _r0 in range(0, _h_full, _rb):
|
|
2134
|
+
_r1 = min(_h_full, _r0 + _rb)
|
|
2135
|
+
interferogram[_r0:_r1] = ref_complex[_r0:_r1, :_w_full] * _np_.conj(sec_complex[_r0:_r1, :_w_full])
|
|
1892
2136
|
|
|
1893
2137
|
# amplitude of the reference (dB): the root-mean-square over the look window. For one look this is 20*log10|ref|.
|
|
1894
2138
|
if _ml:
|
|
@@ -2011,7 +2255,7 @@ class InterferogramGenerator:
|
|
|
2011
2255
|
interferogram, geo_info = apply_geometric_phase(
|
|
2012
2256
|
interferogram, geometry_nodes, dem, remove_flat=bool(_fe_requested),
|
|
2013
2257
|
remove_topo=dem is not None, geoid_offset_m=self._dem_geoid_offset_m,
|
|
2014
|
-
looks=(looks_azimuth, looks_range))
|
|
2258
|
+
looks=(looks_azimuth, looks_range), inplace=True)
|
|
2015
2259
|
except Exception as exc: # noqa: BLE001
|
|
2016
2260
|
_cls = TopographicPhaseError if dem is not None else FlatEarthError
|
|
2017
2261
|
if self._on_error == "raise":
|
|
@@ -2125,7 +2369,7 @@ class InterferogramGenerator:
|
|
|
2125
2369
|
# amplitude was already computed above (Step 4), before
|
|
2126
2370
|
# ref_complex was freed -- not recomputed here.
|
|
2127
2371
|
|
|
2128
|
-
|
|
2372
|
+
result = InterferogramResult(
|
|
2129
2373
|
interferogram=interferogram,
|
|
2130
2374
|
coherence=coherence,
|
|
2131
2375
|
amplitude=amplitude,
|
|
@@ -2180,6 +2424,7 @@ class InterferogramGenerator:
|
|
|
2180
2424
|
),
|
|
2181
2425
|
"crop_after_deburst_applied": crop_info is not None,
|
|
2182
2426
|
"crop_info": crop_info,
|
|
2427
|
+
"coherence_backend": getattr(self, "_coherence_backend", "cpu"),
|
|
2183
2428
|
"chunked_processing": use_chunked_processing
|
|
2184
2429
|
and effective_chunk is not None,
|
|
2185
2430
|
"chunk_rows": effective_chunk,
|
|
@@ -2188,8 +2433,13 @@ class InterferogramGenerator:
|
|
|
2188
2433
|
"esd_residual_after_correction_px": burst_metadata.get("esd_residual_after_correction_px"),
|
|
2189
2434
|
"quality": quality.to_dict(),
|
|
2190
2435
|
"quality_grade": quality.grade,
|
|
2436
|
+
"resume_fingerprint": _fingerprint,
|
|
2191
2437
|
},
|
|
2192
2438
|
)
|
|
2439
|
+
result.metadata["resume_status"] = _resume_note
|
|
2440
|
+
if _pair_dir is not None:
|
|
2441
|
+
result.save(_pair_dir, auto_visualize=save_visualizations)
|
|
2442
|
+
return result
|
|
2193
2443
|
|
|
2194
2444
|
# ══════════════════════════════════════════════════════════════════
|
|
2195
2445
|
# INTERNAL HELPERS
|
|
@@ -2810,13 +3060,24 @@ class InterferogramGenerator:
|
|
|
2810
3060
|
return float(np.clip(shift_px, -0.5, 0.5))
|
|
2811
3061
|
|
|
2812
3062
|
def _apply_azimuth_shift(self, data, shift_px: float):
|
|
2813
|
-
"""Apply a sub-pixel azimuth (row) shift via Fourier phase ramp.
|
|
3063
|
+
"""Apply a sub-pixel azimuth (row) shift via Fourier phase ramp.
|
|
3064
|
+
|
|
3065
|
+
The transform runs along the rows of each column independently, so it is done in column blocks: the
|
|
3066
|
+
double-precision FFT, ramp product and inverse FFT then exist for one block instead of the whole scene
|
|
3067
|
+
(three full-size complex128 arrays, about 4 GB on a 4500 x 18000 crop). The block results are identical to
|
|
3068
|
+
the whole-array ones. Written into ``data`` when that is a plain writable complex64 array of its own
|
|
3069
|
+
(every caller replaces its variable with the return value); otherwise into a new array."""
|
|
2814
3070
|
np = self._np()
|
|
2815
3071
|
h, w = data.shape
|
|
2816
3072
|
freq = np.fft.fftfreq(h).reshape(-1, 1)
|
|
2817
3073
|
ramp = np.exp(-2j * np.pi * freq * shift_px)
|
|
2818
|
-
|
|
2819
|
-
|
|
3074
|
+
in_place = data.dtype == np.complex64 and data.flags.writeable and data.flags.owndata
|
|
3075
|
+
out = data if in_place else np.empty((h, w), dtype=np.complex64)
|
|
3076
|
+
cb = max(16, 4_000_000 // max(h, 1))
|
|
3077
|
+
for c0 in range(0, w, cb):
|
|
3078
|
+
c1 = min(w, c0 + cb)
|
|
3079
|
+
out[:, c0:c1] = np.fft.ifft(np.fft.fft(data[:, c0:c1], axis=0) * ramp, axis=0)
|
|
3080
|
+
return out
|
|
2820
3081
|
|
|
2821
3082
|
def _remove_topographic_phase(self, interferogram, dem_path: Path, profile) -> Any:
|
|
2822
3083
|
"""
|
|
@@ -2981,6 +3242,7 @@ class InterferogramGenerator:
|
|
|
2981
3242
|
from pygeofetch.insar.gpu import get_array_module, to_numpy
|
|
2982
3243
|
|
|
2983
3244
|
xp, ndi, using_gpu = get_array_module(prefer_gpu=self._use_gpu)
|
|
3245
|
+
self._coherence_backend = "gpu" if using_gpu else "cpu"
|
|
2984
3246
|
|
|
2985
3247
|
ref_x = xp.asarray(ref)
|
|
2986
3248
|
sec_x = xp.asarray(sec)
|
pygeofetch/insar/logs.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""How much the InSAR modules say while they run.
|
|
2
|
+
|
|
3
|
+
from pygeofetch.insar import set_verbosity
|
|
4
|
+
set_verbosity("normal") # or InterferogramGenerator(..., verbosity="normal")
|
|
5
|
+
|
|
6
|
+
Levels:
|
|
7
|
+
quiet warnings and errors only (a notebook that prints its own one-line summary per pair needs nothing else)
|
|
8
|
+
normal the lines that carry numbers: coregistration, ESD, crop, multilook, filter, save; not the per-pair
|
|
9
|
+
repeats of "Parsed real SLC geometry" / "Parsed orbit state vectors" / "Plot saved"
|
|
10
|
+
full everything the modules log at INFO
|
|
11
|
+
debug everything, including per-step detail
|
|
12
|
+
|
|
13
|
+
This sets logger levels only; it does not add handlers. Warnings are never hidden by quiet/normal/full.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import logging
|
|
19
|
+
from typing import Optional
|
|
20
|
+
|
|
21
|
+
_ROOTS = ("pygeofetch.insar", "pygeofetch.viz")
|
|
22
|
+
# The loggers that repeat for every pair without carrying a result.
|
|
23
|
+
_REPEATING = (
|
|
24
|
+
"pygeofetch.insar.annotation",
|
|
25
|
+
"pygeofetch.insar.geolocation",
|
|
26
|
+
"pygeofetch.insar.visualize",
|
|
27
|
+
"pygeofetch.viz",
|
|
28
|
+
)
|
|
29
|
+
LEVELS = ("quiet", "normal", "full", "debug")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _children(prefix: str):
|
|
33
|
+
for name in list(logging.root.manager.loggerDict):
|
|
34
|
+
if name.startswith(prefix + "."):
|
|
35
|
+
yield name
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def set_verbosity(level: str = "normal") -> str:
|
|
39
|
+
"""Apply a verbosity level to the pygeofetch.insar and pygeofetch.viz loggers. Returns the level applied."""
|
|
40
|
+
if level not in LEVELS:
|
|
41
|
+
raise ValueError(f"verbosity must be one of {LEVELS}, got {level!r}")
|
|
42
|
+
base = {"quiet": logging.WARNING, "normal": logging.INFO, "full": logging.INFO, "debug": logging.DEBUG}[level]
|
|
43
|
+
for root in _ROOTS:
|
|
44
|
+
logging.getLogger(root).setLevel(base)
|
|
45
|
+
for name in _children(root):
|
|
46
|
+
logging.getLogger(name).setLevel(logging.NOTSET) # inherit: undo any earlier setting
|
|
47
|
+
if level == "normal":
|
|
48
|
+
for name in _REPEATING:
|
|
49
|
+
logging.getLogger(name).setLevel(logging.WARNING)
|
|
50
|
+
# the repeating loggers exist before their modules are imported; make sure the level sticks for late imports
|
|
51
|
+
return level
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def current_verbosity() -> Optional[str]:
|
|
55
|
+
lv = logging.getLogger("pygeofetch.insar").level
|
|
56
|
+
if lv == logging.WARNING:
|
|
57
|
+
return "quiet"
|
|
58
|
+
if lv == logging.DEBUG:
|
|
59
|
+
return "debug"
|
|
60
|
+
if lv == logging.INFO:
|
|
61
|
+
return "normal" if logging.getLogger("pygeofetch.insar.annotation").level == logging.WARNING else "full"
|
|
62
|
+
return None
|
pygeofetch/insar/topo.py
CHANGED
|
@@ -138,6 +138,11 @@ def terrain_heights(
|
|
|
138
138
|
h_new = dem.sample(lon0 + dlon * hh, lat0 + dlat * hh)
|
|
139
139
|
converged = np.isfinite(h) & np.isfinite(h_new) & (np.abs(h_new - h) < tolerance_m)
|
|
140
140
|
h = h_new
|
|
141
|
+
# Stop when every pixel that has a height has settled to the tolerance. The loop used to run all
|
|
142
|
+
# n_iter passes even when the first two had already converged; each pass samples the DEM at every pixel.
|
|
143
|
+
n_fin = int(np.isfinite(h).sum())
|
|
144
|
+
if n_fin and int(converged.sum()) >= n_fin:
|
|
145
|
+
break
|
|
141
146
|
return h, converged
|
|
142
147
|
|
|
143
148
|
|
|
@@ -164,8 +169,9 @@ def apply_geometric_phase(
|
|
|
164
169
|
remove_topo: bool = True,
|
|
165
170
|
geoid_offset_m: float = 0.0,
|
|
166
171
|
looks: Tuple[int, int] = (1, 1),
|
|
167
|
-
row_block: int =
|
|
172
|
+
row_block: Optional[int] = None,
|
|
168
173
|
return_phase: bool = False,
|
|
174
|
+
inplace: bool = False,
|
|
169
175
|
) -> Tuple[np.ndarray, Dict[str, Any]]:
|
|
170
176
|
"""Remove the flat-earth and the simulated topographic phase from ``interferogram`` (a complex array, new array returned).
|
|
171
177
|
|
|
@@ -174,6 +180,11 @@ def apply_geometric_phase(
|
|
|
174
180
|
values that still carry it would decorrelate them). ``nodes`` are defined on the multilooked output grid; ``looks`` is
|
|
175
181
|
the multilook factor that will be applied afterwards.
|
|
176
182
|
|
|
183
|
+
``row_block`` is the number of full-resolution rows handled at a time (None: sized so that one float64 field holds about
|
|
184
|
+
2.5 million pixels, whatever the scene width, since a dozen such fields are alive per block). ``inplace=True`` writes
|
|
185
|
+
the corrected values into ``interferogram`` itself and returns it, saving one full-size complex array; the caller must
|
|
186
|
+
not need the uncorrected values afterwards.
|
|
187
|
+
|
|
177
188
|
Returns ``(corrected, info)``. ``info`` holds the fraction of pixels with a DEM height, the layover/shadow fraction, the
|
|
178
189
|
height and topographic-phase ranges and, with ``return_phase=True``, the removed ``phase`` array and the ``terrain_valid`` mask.
|
|
179
190
|
"""
|
|
@@ -192,7 +203,12 @@ def apply_geometric_phase(
|
|
|
192
203
|
else:
|
|
193
204
|
sampler = DemSampler(dem, geoid_offset_m)
|
|
194
205
|
own = True
|
|
195
|
-
|
|
206
|
+
if row_block is None:
|
|
207
|
+
row_block = max(16, int(2_500_000 // max(w, 1)))
|
|
208
|
+
if inplace and interferogram.dtype == np.complex64 and interferogram.flags.writeable:
|
|
209
|
+
out = interferogram
|
|
210
|
+
else:
|
|
211
|
+
out = np.empty_like(interferogram, dtype=np.complex64)
|
|
196
212
|
phase_all = np.empty((h, w), dtype=np.float32) if return_phase else None
|
|
197
213
|
valid_all = np.zeros((h, w), dtype=bool)
|
|
198
214
|
layover_all = np.zeros((h, w), dtype=bool)
|
|
@@ -277,4 +293,4 @@ def heights_on_output_grid(
|
|
|
277
293
|
finally:
|
|
278
294
|
if own:
|
|
279
295
|
sampler.close()
|
|
280
|
-
return out, ok
|
|
296
|
+
return out, ok
|
pygeofetch/meta.yaml
CHANGED
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 ``
|
|
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 = "
|
|
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.
|
|
3
|
+
Version: 2.6.9.4
|
|
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.
|
|
374
|
+
version = {2.6.9.4.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=
|
|
2
|
-
pygeofetch/meta.yaml,sha256=
|
|
1
|
+
pygeofetch/__init__.py,sha256=2ERgIh0h0kVVol771oMZiH0s8QjXVLxKN5ItwfYfGU4,2107
|
|
2
|
+
pygeofetch/meta.yaml,sha256=5TeXJe0GWDXra-Vmf_oMfWuFvdsdjiqF-7bXJyYkWWk,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,14 +38,14 @@ 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=
|
|
41
|
+
pygeofetch/insar/__init__.py,sha256=FxymkJmeqe_YSKIMWeUNeZsexZwdGMHnBFC0DGBkK1o,14761
|
|
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
|
|
45
45
|
pygeofetch/insar/atmosphere.py,sha256=frOTzYxIz33L4vPxbCQ4fVSkY2c_BZqHwIUoi4grK2Y,23032
|
|
46
46
|
pygeofetch/insar/atmosphere_core.py,sha256=enrcd-wCpc9uZgKIeYa2Wp5ZRpd6IhwkPUbbyOkeXGk,20880
|
|
47
47
|
pygeofetch/insar/auto_fallback.py,sha256=zBZuFpfn4FCHmW9GZ_D5YbVEvA-yjFLCT4gizuSI_OE,14612
|
|
48
|
-
pygeofetch/insar/coregister.py,sha256=
|
|
48
|
+
pygeofetch/insar/coregister.py,sha256=rGun3KDsuC4TP57T8oNDYZdMjyChWnvbK9HOmqYcHTs,66002
|
|
49
49
|
pygeofetch/insar/deburst.py,sha256=liWkKoP-UYYRRXxVYjsm2dpNCnIamL0RfH9JAe-660w,6456
|
|
50
50
|
pygeofetch/insar/errors.py,sha256=KTgmnGS05kgjZJdFAB3frPZC_eGrOE3xqZq-ORwOsd0,6625
|
|
51
51
|
pygeofetch/insar/esd.py,sha256=FR0k7TwIUGInDA1u9cW4zrrX0HGTY5MuclfeDcShL9k,26177
|
|
@@ -53,11 +53,12 @@ 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=
|
|
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=
|
|
58
|
+
pygeofetch/insar/interferogram.py,sha256=COh0tJSRESE92MIjXupk-ylWdh91lYnYVEfatvsUMMo,158104
|
|
59
59
|
pygeofetch/insar/ionosphere.py,sha256=erfzXKGxWLcLvNZznBCx42t6V05oO3M9q-nbrGzrKyc,30987
|
|
60
60
|
pygeofetch/insar/learned_unwrap.py,sha256=lSX_u-2U5mm8lRKhO0xBMk1dVYcR3wDh6pFWcPdR350,45950
|
|
61
|
+
pygeofetch/insar/logs.py,sha256=lQliMDJmt15NTz8Xgqg1EzENA3WUFY48u2xRqvSoB1U,2453
|
|
61
62
|
pygeofetch/insar/network_thinning.py,sha256=2cuTn_fmSWqvORWz7gH2roYqABnIVe0hZ7BDvIe2Cwc,9826
|
|
62
63
|
pygeofetch/insar/offset_geometry.py,sha256=dH73EpmAqgzuUiJBUTE4HpQnCVYyDq5ciES1wLTt7JA,8617
|
|
63
64
|
pygeofetch/insar/offset_tracking.py,sha256=OD4HKFoNsInOf3i4K56tak3HfH7veSNrF0Si7eI-OoQ,18312
|
|
@@ -72,7 +73,7 @@ pygeofetch/insar/splitspectrum_diagnostic.py,sha256=PTdBXkYsRNC6m0xuhi853OWC4Odw
|
|
|
72
73
|
pygeofetch/insar/stack_selection.py,sha256=T0QQsiw7TZcc2PZMZXYliAv50UkLUALKUeC0VlA95B4,40078
|
|
73
74
|
pygeofetch/insar/synthetic.py,sha256=QBHDPp3c8HFvYw4Tt1usGhMZ7D9VD3MT4USbQ7rZ5Sk,16595
|
|
74
75
|
pygeofetch/insar/timeseries.py,sha256=ArKDu5nYHQmue-n-YUweAU_MPIUoNF26TCitFCjC5MQ,75898
|
|
75
|
-
pygeofetch/insar/topo.py,sha256=
|
|
76
|
+
pygeofetch/insar/topo.py,sha256=LyfUVRyrUEgjoRJPripinyhudz3R0Mg1NMBrNn6a4qs,14349
|
|
76
77
|
pygeofetch/insar/unwrap.py,sha256=kQWASRas74vFgj4HPX9Yoq6DXPFLJMLifJFkMDatMpk,36241
|
|
77
78
|
pygeofetch/insar/validate.py,sha256=guIt70yzOGGmNGFRZwzg7t0usu2zqc6xIAq4fPvM9JY,15096
|
|
78
79
|
pygeofetch/insar/visualize.py,sha256=47V22sbLwhinFSPPMs2wdACyAurSO12vlYwXi7zCGv4,8422
|
|
@@ -163,12 +164,12 @@ pygeofetch/utils/validators.py,sha256=f-k3mGFP4byjimyDymhPEdsz5I16jZacx1HSnwrARj
|
|
|
163
164
|
pygeofetch/validation/__init__.py,sha256=39P7zn2qaQDCRFa8l-vFPbGmcf5g458zqWwHpiakaIA,658
|
|
164
165
|
pygeofetch/validation/optical_validator.py,sha256=S0D361GibQwA2vvGb9_H8_6mxvaFKDjNPGCduvLeiAw,37702
|
|
165
166
|
pygeofetch/viz/__init__.py,sha256=bSgK_f_goAHVQOfYu2nbPFVushvsy2hVKBvIBoGonyk,539
|
|
166
|
-
pygeofetch/viz/insar.py,sha256=
|
|
167
|
+
pygeofetch/viz/insar.py,sha256=SaHBsbmvxAF4dLYptePX3wvKWV8Y2Sxqn8pFDjvyXuk,56742
|
|
167
168
|
pygeofetch/viz/map.py,sha256=f8whny5mnz7gDsStNdgtVSpqTNHSDhSZoRT2Qs-Lvos,16403
|
|
168
169
|
pygeofetch/viz/plot.py,sha256=JybD4qElJBOTvWCu7VllL5DqkKFYf5ttJdFfsgApfLE,56601
|
|
169
|
-
pygeofetch-2.6.9.
|
|
170
|
-
pygeofetch-2.6.9.
|
|
171
|
-
pygeofetch-2.6.9.
|
|
172
|
-
pygeofetch-2.6.9.
|
|
173
|
-
pygeofetch-2.6.9.
|
|
174
|
-
pygeofetch-2.6.9.
|
|
170
|
+
pygeofetch-2.6.9.4.dist-info/licenses/LICENSE,sha256=zavMyhODD6NvZTmmKFEtATrngwY4CU_NEtY7lhjxGnI,1075
|
|
171
|
+
pygeofetch-2.6.9.4.dist-info/METADATA,sha256=bESRebTTZpSbKN0UDBF_Ak-VmO0-CdrlhJE5kHsYiIM,25014
|
|
172
|
+
pygeofetch-2.6.9.4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
173
|
+
pygeofetch-2.6.9.4.dist-info/entry_points.txt,sha256=dHiUXLF5xNJ8vgtXZoUQNleEMQUeDPZiKQOE1tW8SDY,55
|
|
174
|
+
pygeofetch-2.6.9.4.dist-info/top_level.txt,sha256=rOmnZargIfNk99fwVOqt6OJyJvpSTBBAYO5HU37yhHk,11
|
|
175
|
+
pygeofetch-2.6.9.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|