Skip to content

Fix Fetchez shift-grid integration - #160

Open
camante wants to merge 1 commit into
mainfrom
fix/tnm-fetchez-shift-grid
Open

Fix Fetchez shift-grid integration#160
camante wants to merge 1 commit into
mainfrom
fix/tnm-fetchez-shift-grid

Conversation

@camante

@camante camante commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

Summary

Fix the Transformez Fetchez extension so shift-grid generation uses the current Transformez implementation and preserves the requested destination datum and output epoch.

This fixes the integration path needed by the updated TNM workflow without changing the underlying shift-grid algorithm.

Depends on continuous-dems/fetchez#385.

What changed

  • Update the Fetchez extension to import the current shift-grid implementation.
  • Forward the requested destination datum to the shift-grid module.
  • Forward the requested output epoch instead of dropping it.
  • Add a focused regression test for the Fetchez extension.

The change is limited to:

  • src/transformez/fetchez/modules/modules.py
  • tests/test_fetchez_module.py

Validation

Repository tests and pre-commit checks pass.

The integration test reproduces the existing failure on the base revision. With this candidate, the same workflow succeeds repeatedly and produces the expected identity shift grid while preserving:

  • destination datum EPSG:5703;
  • output epoch 2020.0;
  • zero-valued identity corrections.

The candidate was run twice successfully with equivalent output.

python -c 'from pathlib import Path
import json
import numpy as np
import rasterio
from fetchez.spatial import Region
from transformez.fetchez.modules.modules import TransformezMod

out = Path.cwd()
module = TransformezMod(
    src_region=Region(-67.001, -67.0, 44.9, 44.901),
    src_datum="EPSG:5703",
    dst_datum="EPSG:5703",
    increment="1s",
    epoch_in="2020.0",
    epoch_out="2020.0",
    outdir=str(out),
)
module.run()
grid_path = Path(module.dst_fn).resolve()
output_root = out.resolve()
try:
    grid_relative_path = grid_path.relative_to(output_root)
except ValueError as exc:
    raise SystemExit(f"Generated shift grid escaped output tree: {grid_path}") from exc
if not grid_path.is_file():
    raise SystemExit(f"Generated shift grid is missing: {grid_path}")
with rasterio.open(grid_path) as dataset:
    values = dataset.read(1)
    payload = {
        "grid": str(grid_relative_path),
        "shape": list(values.shape),
        "all_zero": bool(np.allclose(values, 0.0, atol=1e-6)),
        "min": float(np.nanmin(values)),
        "max": float(np.nanmax(values)),
        "src_datum": module.results[0]["meta"]["src_datum"],
        "dst_datum": module.results[0]["meta"]["dst_datum"],
        "epoch_in": module.epoch_in,
        "epoch_out": module.epoch_out,
    }
if not payload["all_zero"]:
    raise SystemExit("Identity shift grid contains nonzero values")
if payload["dst_datum"] != "EPSG:5703":
    raise SystemExit("Destination datum metadata was not preserved")
if payload["epoch_out"] != "2020.0":
    raise SystemExit("Output epoch was not preserved")
(out / "result.json").write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n")
print(json.dumps(payload, sort_keys=True))
'

Reproducibility

  • Base: origin/main @ 16c193763a866266a977cd3623cfd6c8dcca0a8a
  • Candidate: 977b6f9810e9bb8d9254330927bca8b136259a7e
  • Pre-commit: PASS
  • Repository validation: PASS
  • Base failure reproduced: PASS
  • Candidate repeatability: PASS

Supporting evidence

The attached evidence bundle contains the exact candidate patch, revision identities, validation reports, resolved command, and supporting artifacts generated by dem-devel for this reviewed candidate.
evidence_bundle.zip


Checklist

  • PR title is descriptive
  • PR body contains links to related and resolved issues (e.g. closes #1)
  • If needed, CHANGELOG.md updated
  • If needed, docs and/or README.md updated
  • If needed, unit tests added
  • All checks passing
  • At least one approval

🔍 Docs preview: https://transformez--160.org.readthedocs.build/en/160/

@matth-love

matth-love commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks! We actually submitted the same changes to the fetchez module at the same time here and I've also been re-arranging some of the file structure. See #161 . So we can probably close this one as it makes the same fixes to the variables and typos in modules.py (as well as hooks.py). Though I like this test you made, if you just update the import to be transformez.integrations.fetchez.modules.modules instead I think we should merge that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants