PyGeoFetch 2.7.0.1__py3-none-any.whl → 2.7.0.2__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.1.4"
33
+ __version__ = "2.7.0.2.4"
34
34
  __author__ = "PyGeoFetch Contributors"
35
35
  __license__ = "MIT"
36
36
 
@@ -1569,4 +1569,80 @@ def _linspace(start, stop, n):
1569
1569
  if n == 1:
1570
1570
  return [start]
1571
1571
  step = (stop - start) / (n - 1)
1572
- return [start + i * step for i in range(n)]
1572
+ return [start + i * step for i in range(n)]
1573
+
1574
+ class BurstTimingMap:
1575
+ """Exact azimuth row mapping between two TOPS SLCs in their bursted (TIFF) layout.
1576
+
1577
+ In the measurement TIFF of an IW/EW SLC, burst ``b`` occupies rows ``b*L ... (b+1)*L-1`` and starts at its own
1578
+ annotated ``azimuthTime``. The secondary row that sees the same ground as reference row ``R`` is therefore a
1579
+ *staircase* in ``R``: within a burst it follows the (smooth) geometric time difference, but from burst to burst it
1580
+ jumps by the change in the two acquisitions' relative burst timing. A single polynomial in ``R`` cannot follow
1581
+ those steps; fitted through them it leaves a misregistration that ramps through every burst and jumps at burst
1582
+ edges -- for TOPS, a phase ramp of about ``2 pi k_t dt_az * error`` along azimuth (~3 rad/km per pixel).
1583
+
1584
+ The map separates the two parts. Offsets are expressed as a time difference ``u`` (in reference rows) between
1585
+ the secondary's and the reference's acquisition of the same ground, which is smooth and can be fitted with a
1586
+ low-order polynomial; the burst bookkeeping is then applied exactly: reference row -> (burst b, time) -> same
1587
+ burst of the secondary (matched by time) -> secondary row.
1588
+ """
1589
+
1590
+ def __init__(self, ref_geometry, sec_geometry):
1591
+ import numpy as np
1592
+
1593
+ for g in (ref_geometry, sec_geometry):
1594
+ if not (getattr(g, "_has_burst_timing", lambda: False)()):
1595
+ raise ValueError("burst timing not available")
1596
+ self._np = np
1597
+ t0 = ref_geometry.burst_azimuth_times[0]
1598
+ self.ref_t = np.array([(t - t0).total_seconds() for t in ref_geometry.burst_azimuth_times])
1599
+ self.sec_t = np.array([(t - t0).total_seconds() for t in sec_geometry.burst_azimuth_times])
1600
+ self.ref_lpb, self.sec_lpb = int(ref_geometry.lines_per_burst), int(sec_geometry.lines_per_burst)
1601
+ self.ref_dt = float(ref_geometry.azimuth_time_interval_s)
1602
+ self.sec_dt = float(sec_geometry.azimuth_time_interval_s)
1603
+ self.match = None
1604
+
1605
+ def _ref_time(self, R):
1606
+ np = self._np
1607
+ R = np.asarray(R, dtype=np.float64)
1608
+ b = np.clip(np.floor(R / self.ref_lpb).astype(np.int64), 0, len(self.ref_t) - 1)
1609
+ return self.ref_t[b] + (R - b * self.ref_lpb) * self.ref_dt, b
1610
+
1611
+ def _sec_time(self, S):
1612
+ np = self._np
1613
+ S = np.asarray(S, dtype=np.float64)
1614
+ b = np.clip(np.floor(S / self.sec_lpb).astype(np.int64), 0, len(self.sec_t) - 1)
1615
+ return self.sec_t[b] + (S - b * self.sec_lpb) * self.sec_dt
1616
+
1617
+ def to_u(self, R, S):
1618
+ """Time difference (in reference rows) between secondary row S and reference row R."""
1619
+ t_ref, _ = self._ref_time(R)
1620
+ return (self._sec_time(S) - t_ref) / self.ref_dt
1621
+
1622
+ def set_matching(self, u_typical: float) -> None:
1623
+ """Pair every reference burst with the secondary burst covering the same ground (nearest centre time)."""
1624
+ np = self._np
1625
+ ref_mid = self.ref_t + 0.5 * self.ref_lpb * self.ref_dt + u_typical * self.ref_dt
1626
+ sec_mid = self.sec_t + 0.5 * self.sec_lpb * self.sec_dt
1627
+ self.match = np.array([int(np.argmin(np.abs(sec_mid - m))) for m in ref_mid])
1628
+
1629
+ def steps_px(self) -> "list[float]":
1630
+ """Relative burst timing (reference minus matched secondary burst start), in rows, per reference burst."""
1631
+ d = (self.ref_t - self.sec_t[self.match]) / self.ref_dt
1632
+ return [float(x) for x in d - self._np.median(d)]
1633
+
1634
+ def wrap(self, u_fn):
1635
+ """Row-offset function (secondary row - reference row) from a smooth time-difference function u(R, C)."""
1636
+ np = self._np
1637
+ if self.match is None:
1638
+ raise RuntimeError("call set_matching() first")
1639
+
1640
+ def row_fn(R, C):
1641
+ R = np.asarray(R, dtype=np.float64)
1642
+ t_ref, b = self._ref_time(R)
1643
+ t = t_ref + np.asarray(u_fn(R, C), dtype=np.float64) * self.ref_dt
1644
+ bs = self.match[b]
1645
+ S = bs * self.sec_lpb + (t - self.sec_t[bs]) / self.sec_dt
1646
+ return (S - R).astype(np.float32)
1647
+
1648
+ return row_fn
@@ -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 = 2
618
+ self._tops_deramp_version = 3
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
@@ -2584,6 +2584,9 @@ class InterferogramGenerator:
2584
2584
  "tops_sign": coreg_metadata.get("tops_sign"),
2585
2585
  "tops_sign_check_secondary": coreg_metadata.get("tops_sign_check_secondary"),
2586
2586
  "tops_doppler_rate_hz_s": coreg_metadata.get("tops_doppler_rate_hz_s"),
2587
+ "burst_exact_azimuth_mapping": coreg_metadata.get("burst_exact_azimuth_mapping", False),
2588
+ "burst_timing_steps_px": coreg_metadata.get("burst_timing_steps_px"),
2589
+ "coreg_rms_px": coreg_metadata.get("rms_mean_px"),
2587
2590
  "esd_delta_f_ovl_hz": burst_metadata.get("esd_delta_f_ovl_hz"),
2588
2591
  "esd_residual_after_correction_px": burst_metadata.get("esd_residual_after_correction_px"),
2589
2592
  "quality": quality.to_dict(),
@@ -2940,6 +2943,31 @@ class InterferogramGenerator:
2940
2943
  exc,
2941
2944
  )
2942
2945
 
2946
+ # TOPS: fit the smooth time difference between the acquisitions, then map rows burst by burst
2947
+ # (BurstTimingMap). A polynomial fitted straight to row offsets cannot follow the steps that the two
2948
+ # acquisitions' burst timing puts between bursts, and leaves a misregistration that ramps through
2949
+ # each burst -- tenths of a pixel, far beyond what ESD (+-0.05 px) can see.
2950
+ timing_map = None
2951
+ if sec_ramp is not None:
2952
+ try:
2953
+ import numpy as _np
2954
+
2955
+ from pygeofetch.insar.coregister import BurstTimingMap
2956
+
2957
+ timing_map = BurstTimingMap(ref_geom, sec_geom)
2958
+ g_r = _np.asarray(geom_rows, dtype=float)
2959
+ geom_off_rows = list(timing_map.to_u(g_r, g_r + _np.asarray(geom_off_rows, dtype=float)))
2960
+ if xc_available:
2961
+ x_r = _np.asarray(grid_rows, dtype=float)
2962
+ off_rows = list(timing_map.to_u(x_r, x_r + _np.asarray(off_rows, dtype=float)))
2963
+ timing_map.set_matching(float(_np.median(geom_off_rows)))
2964
+ steps = timing_map.steps_px()
2965
+ tops_meta["burst_timing_steps_px"] = steps
2966
+ logger.info("Burst-exact azimuth mapping: relative burst timing steps (px) %s",
2967
+ ", ".join(f"{s_:+.3f}" for s_ in steps))
2968
+ except Exception as exc: # noqa: BLE001
2969
+ logger.warning("Burst-exact azimuth mapping unavailable (%s); fitting row offsets directly", exc)
2970
+ timing_map = None
2943
2971
  if fit == "geometry_first":
2944
2972
  if xc_available:
2945
2973
  xc_args = (grid_rows, grid_cols, off_rows, off_cols)
@@ -2963,6 +2991,9 @@ class InterferogramGenerator:
2963
2991
  raise ValueError(
2964
2992
  f"coregistration_fit must be 'geometry_first' or 'polynomial', got {fit!r}"
2965
2993
  )
2994
+ if timing_map is not None:
2995
+ row_fn = timing_map.wrap(row_fn)
2996
+ tops_meta["burst_exact_azimuth_mapping"] = True
2966
2997
  coreg_quality.mean_coherence = mean_coherence
2967
2998
  coreg_quality.log_summary()
2968
2999
 
pygeofetch/meta.yaml CHANGED
@@ -1,4 +1,4 @@
1
- {% set version = "2.7.0.1.4" %}
1
+ {% set version = "2.7.0.2.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.1
3
+ Version: 2.7.0.2
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.1.1},
374
+ version = {2.7.0.2.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=SJk6tXeZ1umzI3nLrMrbJNsOQtBuEJC8a5CfXHu8Z-Q,2107
2
- pygeofetch/meta.yaml,sha256=fMqWc8n1PaN7-X6RXU9beYL_Iwl5qvxQiY7B4xODj0w,1284
1
+ pygeofetch/__init__.py,sha256=yw--nHUD7CZQ7AlYaW8RiOZ3oJNcuFbBvC1uoWWbO60,2107
2
+ pygeofetch/meta.yaml,sha256=lwGyebWDOMyzffGLAszbgdavw5h4lUgdjpwAuSrvPbY,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
@@ -45,7 +45,7 @@ pygeofetch/insar/annotation.py,sha256=hQf_SnvcMpKanCdIaX3yTdygxhd57sJtz_3_L83zRm
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=lZTudKeJaLSyvpDy4fIlY7IdwCKNQEFo3zOARwwBYug,70164
48
+ pygeofetch/insar/coregister.py,sha256=bmM4tcAZiMDaqqwiPFyrGUFTJm_u5oDbOni6jOzPa0Q,74225
49
49
  pygeofetch/insar/deburst.py,sha256=dzdB-jMupkalvUXoNxalLD31HNkMqyyXagpE5XSXT1g,8017
50
50
  pygeofetch/insar/errors.py,sha256=KTgmnGS05kgjZJdFAB3frPZC_eGrOE3xqZq-ORwOsd0,6625
51
51
  pygeofetch/insar/esd.py,sha256=FR0k7TwIUGInDA1u9cW4zrrX0HGTY5MuclfeDcShL9k,26177
@@ -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=XUPNnanpsyYZMXhXfHhh7NpPFFKe8CtS5soRCNkt1Io,171741
58
+ pygeofetch/insar/interferogram.py,sha256=NTlledvr-6Jkqr5h3s5VWEveV_S2QeBMoUbrIGVyBZs,173797
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,9 @@ 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.1.dist-info/licenses/LICENSE,sha256=zavMyhODD6NvZTmmKFEtATrngwY4CU_NEtY7lhjxGnI,1075
174
- pygeofetch-2.7.0.1.dist-info/METADATA,sha256=g5R-IiP4U5zGd5beO3WVCALOPsuD7kt_n7j0zPWH04M,25014
175
- pygeofetch-2.7.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
176
- pygeofetch-2.7.0.1.dist-info/entry_points.txt,sha256=dHiUXLF5xNJ8vgtXZoUQNleEMQUeDPZiKQOE1tW8SDY,55
177
- pygeofetch-2.7.0.1.dist-info/top_level.txt,sha256=rOmnZargIfNk99fwVOqt6OJyJvpSTBBAYO5HU37yhHk,11
178
- pygeofetch-2.7.0.1.dist-info/RECORD,,
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,,