PyGeoFetch 2.7.0.2__py3-none-any.whl → 2.7.0.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.7.0.2.4"
33
+ __version__ = "2.7.0.3.4"
34
34
  __author__ = "PyGeoFetch Contributors"
35
35
  __license__ = "MIT"
36
36
 
@@ -615,7 +615,7 @@ class InterferogramGenerator:
615
615
  self._tops_ctx = None
616
616
  # Part of every pair fingerprint: results saved before TOPS deramping (0) or before resampling onto the
617
617
  # reference grid (1) are not reused.
618
- self._tops_deramp_version = 3
618
+ self._tops_deramp_version = 4
619
619
  # Automatic by default (None): on when the inputs exist, explicit
620
620
  # True/False always respected. It used to be opt-in and silent, which
621
621
  # left a full-width range ramp in every interferogram unless the caller
@@ -1437,6 +1437,16 @@ class InterferogramGenerator:
1437
1437
  except Exception as exc: # noqa: BLE001
1438
1438
  metadata["esd_residual_after_correction_px"] = None
1439
1439
  logger.warning("ESD residual re-estimation failed: %s", exc)
1440
+ # Resolve ESD's whole-ambiguity blind spot (TOPS pairs only).
1441
+ if getattr(self, "_tops_ctx", None) is not None:
1442
+ try:
1443
+ _amb = 1.0 / ((_df if _df else 5200.0) * azimuth_time_interval_s)
1444
+ sec_complex, _amb_info = self._resolve_esd_ambiguity(ref_complex, sec_complex, _amb)
1445
+ if _amb_info is not None:
1446
+ metadata["esd_ambiguity"] = _amb_info
1447
+ metadata["esd_total_shift_px"] = esd_shift_px + _amb_info["k"] * _amb
1448
+ except Exception as exc: # noqa: BLE001
1449
+ logger.warning("ESD ambiguity scan failed: %s", exc)
1440
1450
  else:
1441
1451
  logger.info(
1442
1452
  "Real per-burst-overlap ESD found no usable burst "
@@ -2588,6 +2598,8 @@ class InterferogramGenerator:
2588
2598
  "burst_timing_steps_px": coreg_metadata.get("burst_timing_steps_px"),
2589
2599
  "coreg_rms_px": coreg_metadata.get("rms_mean_px"),
2590
2600
  "esd_delta_f_ovl_hz": burst_metadata.get("esd_delta_f_ovl_hz"),
2601
+ "esd_ambiguity": burst_metadata.get("esd_ambiguity"),
2602
+ "esd_total_shift_px": burst_metadata.get("esd_total_shift_px"),
2591
2603
  "esd_residual_after_correction_px": burst_metadata.get("esd_residual_after_correction_px"),
2592
2604
  "quality": quality.to_dict(),
2593
2605
  "quality_grade": quality.grade,
@@ -3287,6 +3299,74 @@ class InterferogramGenerator:
3287
3299
  shift_px = diff_phase / (2 * np.pi) * 0.01 # conservative scaling
3288
3300
  return float(np.clip(shift_px, -0.5, 0.5))
3289
3301
 
3302
+ def _tops_content_phase(self, ctx, col_offset: float = 0.0):
3303
+ """Ramp phase carried by the resampled (and possibly already shifted) secondary at local (row, col)."""
3304
+ np = self._np()
3305
+ sec_ramp, row_fn, col_fn = ctx["sec_ramp"], ctx["row_fn"], ctx["col_fn"]
3306
+ r_off, c_off = ctx["ref_row_off"], ctx["ref_col_off"] + col_offset
3307
+ applied = ctx.get("applied_shift_px", 0.0)
3308
+
3309
+ def content_phase(rows, cols):
3310
+ rg = np.asarray(rows, dtype=np.float64) - applied + r_off
3311
+ cg = np.asarray(cols, dtype=np.float64) + c_off
3312
+ return sec_ramp.phase(rg + np.asarray(row_fn(rg, cg), dtype=np.float64),
3313
+ cg + np.asarray(col_fn(rg, cg), dtype=np.float64))
3314
+
3315
+ return content_phase
3316
+
3317
+ def _resolve_esd_ambiguity(self, ref_complex, sec_complex, ambiguity_px: float, k_max: int = 4,
3318
+ max_cols: int = 1536):
3319
+ """Pick the whole number of ESD ambiguities to add to the azimuth shift, by coherence.
3320
+
3321
+ ESD measures the azimuth misregistration only modulo ``1 / (delta_f_ovl * dt_az)`` (about 0.1 px for IW):
3322
+ a first-stage coregistration error of a few tenths of a pixel leaves an error that ESD cannot see but that
3323
+ ramps the TOPS phase through every burst (about 3 rad/km per pixel) and steps it at burst edges. The
3324
+ interferometric coherence of a TOPS pair peaks at zero misregistration (the burst spectra overlap best),
3325
+ so the secondary is shifted by k ambiguities, k = -k_max..k_max, on a central block of columns, and the
3326
+ k with the highest coherence is kept. Returns the (possibly shifted) secondary and the scan.
3327
+ """
3328
+ np = self._np()
3329
+ ctx = getattr(self, "_tops_ctx", None)
3330
+ if ctx is None or not (ambiguity_px > 0) or not np.isfinite(ambiguity_px):
3331
+ return sec_complex, None
3332
+ from pygeofetch.insar.tops import shift_azimuth_tops
3333
+
3334
+ h, w = sec_complex.shape
3335
+ c0 = max(0, (w - max_cols) // 2)
3336
+ c1 = min(w, c0 + max_cols)
3337
+ ref_s = np.asarray(ref_complex[:, c0:c1])
3338
+ sec_s = np.asarray(sec_complex[:, c0:c1], dtype=np.complex64)
3339
+ content_phase = self._tops_content_phase(ctx, col_offset=c0)
3340
+ lpb, r_off = ctx["ref_ramp"].lines_per_burst, ctx["ref_row_off"]
3341
+
3342
+ def coherence(a, b, la=4, lr=16):
3343
+ n_r, n_c = (a.shape[0] // la) * la, (a.shape[1] // lr) * lr
3344
+ a, b = a[:n_r, :n_c].astype(np.complex128), b[:n_r, :n_c].astype(np.complex128)
3345
+ shp = (n_r // la, la, n_c // lr, lr)
3346
+ num = np.abs((a * np.conj(b)).reshape(shp).sum(axis=(1, 3)))
3347
+ den = np.sqrt((np.abs(a) ** 2).reshape(shp).sum(axis=(1, 3)) * (np.abs(b) ** 2).reshape(shp).sum(axis=(1, 3)))
3348
+ ok = den > 0
3349
+ return float(np.mean(num[ok] / den[ok])) if ok.any() else float("nan")
3350
+
3351
+ ks = list(range(-k_max, k_max + 1))
3352
+ scores = []
3353
+ for k in ks:
3354
+ shifted = sec_s if k == 0 else shift_azimuth_tops(sec_s.copy(), k * ambiguity_px, content_phase, lpb, r_off)
3355
+ scores.append(coherence(ref_s, shifted))
3356
+ best = int(np.nanargmax(scores))
3357
+ k_best = ks[best]
3358
+ info = {"ambiguity_px": float(ambiguity_px), "k": int(k_best),
3359
+ "coherence_scan": [round(float(v), 5) for v in scores],
3360
+ "at_scan_edge": best in (0, len(ks) - 1)}
3361
+ logger.info("ESD ambiguity scan (coherence for k = %d..%d ambiguities of %.4f px): %s -> k = %+d",
3362
+ ks[0], ks[-1], ambiguity_px, ", ".join(f"{v:.4f}" for v in scores), k_best)
3363
+ if info["at_scan_edge"]:
3364
+ logger.warning("ESD ambiguity scan peaks at the edge of the scan (k = %+d): the first-stage "
3365
+ "coregistration is off by more than %d ambiguities", k_best, k_max)
3366
+ if k_best != 0:
3367
+ sec_complex = self._apply_azimuth_shift(sec_complex, k_best * ambiguity_px)
3368
+ return sec_complex, info
3369
+
3290
3370
  def _apply_azimuth_shift(self, data, shift_px: float):
3291
3371
  """Apply a sub-pixel azimuth (row) shift via Fourier phase ramp.
3292
3372
 
@@ -3304,17 +3384,12 @@ class InterferogramGenerator:
3304
3384
  # every burst.
3305
3385
  from pygeofetch.insar.tops import shift_azimuth_tops
3306
3386
 
3307
- sec_ramp, row_fn, col_fn = ctx["sec_ramp"], ctx["row_fn"], ctx["col_fn"]
3308
- r_off, c_off = ctx["ref_row_off"], ctx["ref_col_off"]
3309
-
3310
- def content_phase(rows, cols):
3311
- rg = np.asarray(rows, dtype=np.float64) + r_off
3312
- cg = np.asarray(cols, dtype=np.float64) + c_off
3313
- return sec_ramp.phase(rg + np.asarray(row_fn(rg, cg), dtype=np.float64),
3314
- cg + np.asarray(col_fn(rg, cg), dtype=np.float64))
3315
-
3316
- return shift_azimuth_tops(np.asarray(data), float(shift_px), content_phase,
3317
- ctx["ref_ramp"].lines_per_burst, r_off)
3387
+ content_phase = self._tops_content_phase(ctx)
3388
+ out = shift_azimuth_tops(np.asarray(data), float(shift_px), content_phase,
3389
+ ctx["ref_ramp"].lines_per_burst, ctx["ref_row_off"])
3390
+ # The data now carry the ramp of the positions r - shift; a later shift must start from there.
3391
+ ctx["applied_shift_px"] = ctx.get("applied_shift_px", 0.0) + float(shift_px)
3392
+ return out
3318
3393
  h, w = data.shape
3319
3394
  freq = np.fft.fftfreq(h).reshape(-1, 1)
3320
3395
  ramp = np.exp(-2j * np.pi * freq * shift_px)
pygeofetch/meta.yaml CHANGED
@@ -1,4 +1,4 @@
1
- {% set version = "2.7.0.2.4" %}
1
+ {% set version = "2.7.0.3.4" %}
2
2
 
3
3
  package:
4
4
  name: pygeofetch
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygeofetch
3
- Version: 2.7.0.2
3
+ Version: 2.7.0.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.7.0.2.1},
374
+ version = {2.7.0.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=yw--nHUD7CZQ7AlYaW8RiOZ3oJNcuFbBvC1uoWWbO60,2107
2
- pygeofetch/meta.yaml,sha256=lwGyebWDOMyzffGLAszbgdavw5h4lUgdjpwAuSrvPbY,1284
1
+ pygeofetch/__init__.py,sha256=Fem0OJ0xQQGtpm5lEITEzBDmRdylNC2V8qnN41bRblc,2107
2
+ pygeofetch/meta.yaml,sha256=24phHRh8swIoZ3adMfJMmQYndJ_MOLDIz8ZAzJT8JaA,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
@@ -55,7 +55,7 @@ pygeofetch/insar/flatearth.py,sha256=gSUdDcHlxs3P2TrUkKFkIwq7GftKVOit0A47CaBKIvc
55
55
  pygeofetch/insar/geolocation.py,sha256=7T84uNHIXGmuOCvru9CJkFrnet4HX3t-thXXro2peRk,34163
56
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=NTlledvr-6Jkqr5h3s5VWEveV_S2QeBMoUbrIGVyBZs,173797
58
+ pygeofetch/insar/interferogram.py,sha256=UQb_l3oOhxR_Dy-f1Uc3YoqlzFz6SPCTz89EiuKn-U0,178492
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/logs.py,sha256=lQliMDJmt15NTz8Xgqg1EzENA3WUFY48u2xRqvSoB1U,2453
@@ -170,9 +170,15 @@ pygeofetch/viz/__init__.py,sha256=bSgK_f_goAHVQOfYu2nbPFVushvsy2hVKBvIBoGonyk,53
170
170
  pygeofetch/viz/insar.py,sha256=SaHBsbmvxAF4dLYptePX3wvKWV8Y2Sxqn8pFDjvyXuk,56742
171
171
  pygeofetch/viz/map.py,sha256=f8whny5mnz7gDsStNdgtVSpqTNHSDhSZoRT2Qs-Lvos,16403
172
172
  pygeofetch/viz/plot.py,sha256=JybD4qElJBOTvWCu7VllL5DqkKFYf5ttJdFfsgApfLE,56601
173
- pygeofetch-2.7.0.2.dist-info/licenses/LICENSE,sha256=zavMyhODD6NvZTmmKFEtATrngwY4CU_NEtY7lhjxGnI,1075
174
- pygeofetch-2.7.0.2.dist-info/METADATA,sha256=COvD4SEQzrmhyKxz5gMhfhF9UQQqePG_obQvujR6bPQ,25014
175
- pygeofetch-2.7.0.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
176
- pygeofetch-2.7.0.2.dist-info/entry_points.txt,sha256=dHiUXLF5xNJ8vgtXZoUQNleEMQUeDPZiKQOE1tW8SDY,55
177
- pygeofetch-2.7.0.2.dist-info/top_level.txt,sha256=rOmnZargIfNk99fwVOqt6OJyJvpSTBBAYO5HU37yhHk,11
178
- pygeofetch-2.7.0.2.dist-info/RECORD,,
173
+ pygeofetch-2.7.0.3.dist-info/licenses/LICENSE,sha256=zavMyhODD6NvZTmmKFEtATrngwY4CU_NEtY7lhjxGnI,1075
174
+ pygeofetch_tops_fix_part4/files/pygeofetch/insar/coregister.py,sha256=bmM4tcAZiMDaqqwiPFyrGUFTJm_u5oDbOni6jOzPa0Q,74225
175
+ pygeofetch_tops_fix_part4/files/pygeofetch/insar/interferogram.py,sha256=UQb_l3oOhxR_Dy-f1Uc3YoqlzFz6SPCTz89EiuKn-U0,178492
176
+ pygeofetch_tops_fix_part4/files/pygeofetch/insar/tops.py,sha256=-yIthiWED20u7t10m8M3AHEBaa8PDS_rvS-oDnYevgM,18459
177
+ pygeofetch_tops_fix_part4/files/tests/insar/_fake_safe.py,sha256=-ntqxg2Ln-8ZHxC3Waq1qTbVNAj5Iwj40Bc49Q9kD_A,3356
178
+ pygeofetch_tops_fix_part4/files/tests/insar/_tops_sim.py,sha256=t6-ahcc9unf2aLqFTmdMWMeN9gGgU7bFG2ddWS5ZVzY,4776
179
+ pygeofetch_tops_fix_part4/files/tests/insar/test_tops_deramp.py,sha256=oqiRB6__-jhcG56D3ATMGiVhoiIpooFQA6UsRGC8A2k,9355
180
+ pygeofetch-2.7.0.3.dist-info/METADATA,sha256=yGKULRvSIcheQvJbHh-tSWE_8GAKKAX-XzSR4uBjAvc,25014
181
+ pygeofetch-2.7.0.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
182
+ pygeofetch-2.7.0.3.dist-info/entry_points.txt,sha256=dHiUXLF5xNJ8vgtXZoUQNleEMQUeDPZiKQOE1tW8SDY,55
183
+ pygeofetch-2.7.0.3.dist-info/top_level.txt,sha256=zTWa3p-2jFCZxSdZz4QmEuGaRK4oVksDIRi63lz5tOo,37
184
+ pygeofetch-2.7.0.3.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ pygeofetch
2
+ pygeofetch_tops_fix_part4