forcingkit 0.23.0__tar.gz → 0.23.1__tar.gz

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.
Files changed (161) hide show
  1. {forcingkit-0.23.0 → forcingkit-0.23.1}/PKG-INFO +1 -1
  2. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/conf.py +1 -1
  3. {forcingkit-0.23.0 → forcingkit-0.23.1}/pyproject.toml +1 -1
  4. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/necofs.py +88 -1
  5. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_volume.py +74 -0
  6. {forcingkit-0.23.0 → forcingkit-0.23.1}/uv.lock +1 -1
  7. {forcingkit-0.23.0 → forcingkit-0.23.1}/.agents/forcingkit.md +0 -0
  8. {forcingkit-0.23.0 → forcingkit-0.23.1}/.claude/CLAUDE.md +0 -0
  9. {forcingkit-0.23.0 → forcingkit-0.23.1}/.env.template +0 -0
  10. {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/copilot-instructions.md +0 -0
  11. {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/docs.yml +0 -0
  12. {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/publish-client.yml +0 -0
  13. {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/publish.yml +0 -0
  14. {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/tests.yml +0 -0
  15. {forcingkit-0.23.0 → forcingkit-0.23.1}/.gitignore +0 -0
  16. {forcingkit-0.23.0 → forcingkit-0.23.1}/.markdownlint.yaml +0 -0
  17. {forcingkit-0.23.0 → forcingkit-0.23.1}/.pre-commit-config.yaml +0 -0
  18. {forcingkit-0.23.0 → forcingkit-0.23.1}/.python-version +0 -0
  19. {forcingkit-0.23.0 → forcingkit-0.23.1}/AGENTS.md +0 -0
  20. {forcingkit-0.23.0 → forcingkit-0.23.1}/CONTRIBUTING.md +0 -0
  21. {forcingkit-0.23.0 → forcingkit-0.23.1}/Dockerfile +0 -0
  22. {forcingkit-0.23.0 → forcingkit-0.23.1}/LICENSE +0 -0
  23. {forcingkit-0.23.0 → forcingkit-0.23.1}/README.md +0 -0
  24. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/LICENSE +0 -0
  25. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/README.md +0 -0
  26. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/pyproject.toml +0 -0
  27. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/__init__.py +0 -0
  28. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/client.py +0 -0
  29. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/schema.py +0 -0
  30. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/store.py +0 -0
  31. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/trajectory.py +0 -0
  32. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/conftest.py +0 -0
  33. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/test_client.py +0 -0
  34. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/test_schema.py +0 -0
  35. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/test_trajectory.py +0 -0
  36. {forcingkit-0.23.0 → forcingkit-0.23.1}/client/uv.lock +0 -0
  37. {forcingkit-0.23.0 → forcingkit-0.23.1}/docker-compose.yml +0 -0
  38. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/Makefile +0 -0
  39. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/make.bat +0 -0
  40. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/requirements-docs.txt +0 -0
  41. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/_extra/CNAME +0 -0
  42. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/_static/forcingkit-noreaster-wind.gif +0 -0
  43. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/atmospheric_forcing.rst +0 -0
  44. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/cache_viewer.rst +0 -0
  45. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/client.rst +0 -0
  46. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/doppio.rst +0 -0
  47. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/fetchers.rst +0 -0
  48. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/hycom.rst +0 -0
  49. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/index.rst +0 -0
  50. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/layered_mesh.rst +0 -0
  51. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/mesh_frames.rst +0 -0
  52. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/necofs.rst +0 -0
  53. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/nyofs.rst +0 -0
  54. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/rivers.rst +0 -0
  55. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/roadmap.rst +0 -0
  56. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/shelf_models.rst +0 -0
  57. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/sources.rst +0 -0
  58. {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/waves.rst +0 -0
  59. {forcingkit-0.23.0 → forcingkit-0.23.1}/main.py +0 -0
  60. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/__init__.py +0 -0
  61. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/__init__.py +0 -0
  62. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/jobs.py +0 -0
  63. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/main.py +0 -0
  64. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/bathymetry.py +0 -0
  65. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/removed.py +0 -0
  66. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/stores.py +0 -0
  67. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/view.py +0 -0
  68. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/viewer.py +0 -0
  69. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/stac.py +0 -0
  70. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/view_store.py +0 -0
  71. {forcingkit-0.23.0 → forcingkit-0.23.1}/service/run_server.py +0 -0
  72. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/__init__.py +0 -0
  73. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/data/rivers/northeast_us.json +0 -0
  74. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/dispatcher.py +0 -0
  75. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/coastwatch.py +0 -0
  76. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/dbofs.py +0 -0
  77. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/doppio.py +0 -0
  78. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/erddap.py +0 -0
  79. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hfradar.py +0 -0
  80. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrdps.py +0 -0
  81. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr.py +0 -0
  82. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_atmosphere.py +0 -0
  83. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_levels.py +0 -0
  84. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_points.py +0 -0
  85. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hycom.py +0 -0
  86. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hydrography.py +0 -0
  87. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/ndbc.py +0 -0
  88. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/noaa.py +0 -0
  89. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/nwps.py +0 -0
  90. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/nyofs.py +0 -0
  91. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/usgs.py +0 -0
  92. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/usgs_rivers.py +0 -0
  93. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/layered_mesh.py +0 -0
  94. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/mesh_frames.py +0 -0
  95. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis.csv +0 -0
  96. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_dark.csv +0 -0
  97. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_deep.csv +0 -0
  98. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_haline.csv +0 -0
  99. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_tempo.csv +0 -0
  100. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_tempo_dark.csv +0 -0
  101. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/render.py +0 -0
  102. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/settings.py +0 -0
  103. {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/zarr_stream.py +0 -0
  104. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/app.js +0 -0
  105. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/cells_map.js +0 -0
  106. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/coverage.js +0 -0
  107. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/favicon.ico +0 -0
  108. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/favicon.svg +0 -0
  109. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/index.html +0 -0
  110. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/logo.svg +0 -0
  111. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/preview.js +0 -0
  112. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/scene3d.js +0 -0
  113. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/styles.css +0 -0
  114. {forcingkit-0.23.0 → forcingkit-0.23.1}/static/view_api.js +0 -0
  115. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/__init__.py +0 -0
  116. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_auth.py +0 -0
  117. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_erddap_fetch.py +0 -0
  118. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_mesh_frames_necofs.py +0 -0
  119. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_necofs_volume_live.py +0 -0
  120. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_nwps_nomads.py +0 -0
  121. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_nyofs_obc_fetch.py +0 -0
  122. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_obc_offshore_nj.py +0 -0
  123. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_ofs_archive_paths.py +0 -0
  124. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_s3_roms_fetchers.py +0 -0
  125. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/scripts/inspect_dem.py +0 -0
  126. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/scripts/inspect_grib.py +0 -0
  127. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/scripts/inspect_zarr.py +0 -0
  128. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/data/doppio_reanalysis_20220811_corner.nc +0 -0
  129. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_cache_inventory.py +0 -0
  130. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_coastwatch.py +0 -0
  131. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_dbofs.py +0 -0
  132. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_dispatcher.py +0 -0
  133. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_doppio.py +0 -0
  134. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_erddap.py +0 -0
  135. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hfradar.py +0 -0
  136. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrdps.py +0 -0
  137. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_atm.py +0 -0
  138. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_idx.py +0 -0
  139. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_levels.py +0 -0
  140. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_points.py +0 -0
  141. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hycom.py +0 -0
  142. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_jobs.py +0 -0
  143. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_layered_mesh.py +0 -0
  144. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_main.py +0 -0
  145. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_mesh_frames.py +0 -0
  146. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_ndbc.py +0 -0
  147. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_hindcast.py +0 -0
  148. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_mesh_cache.py +0 -0
  149. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_parent.py +0 -0
  150. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_noaa_currents.py +0 -0
  151. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_noaa_datum.py +0 -0
  152. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_nwps.py +0 -0
  153. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_nyofs.py +0 -0
  154. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_obc_donor_report.py +0 -0
  155. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_obc_pipeline.py +0 -0
  156. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_removed_routes.py +0 -0
  157. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_settings.py +0 -0
  158. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_usgs.py +0 -0
  159. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_usgs_rivers.py +0 -0
  160. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_view_store.py +0 -0
  161. {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_zarr_stream.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: forcingkit
3
- Version: 0.23.0
3
+ Version: 0.23.1
4
4
  Summary: Spatiotemporal forcing for computational Earth-system models: selects, regrids and serves model-ready time series with provenance.
5
5
  Project-URL: Documentation, https://forcingkit.docs.lhzn.io
6
6
  Project-URL: Issues, https://github.com/lhzn-io/forcingkit/issues
@@ -9,7 +9,7 @@ sys.path.insert(0, os.path.abspath("../../src"))
9
9
  project = "forcingkit"
10
10
  copyright = "2026, Long Horizon Observatory"
11
11
  author = "Daniel Fry"
12
- release = "0.23.0"
12
+ release = "0.23.1"
13
13
 
14
14
  extensions = [
15
15
  "sphinx.ext.autodoc",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "forcingkit"
7
- version = "0.23.0"
7
+ version = "0.23.1"
8
8
  description = "Spatiotemporal forcing for computational Earth-system models: selects, regrids and serves model-ready time series with provenance."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -765,6 +765,85 @@ def _derive_mesh(arrays: dict[str, np.ndarray]) -> dict[str, np.ndarray]:
765
765
  return {**arrays, "nbe_all": nbe_all, "boundary_nodes": boundary_nodes}
766
766
 
767
767
 
768
+ # SMAST's files have at times carried all-zero longitudes and latitudes while x, y and nv were right: the rolling
769
+ # forecast on 2026-11-20 and 21, and earlier a monthly archive file. Such a mesh selects no elements in any box. A mesh
770
+ # whose geographic coordinates are unusable takes them from a mesh with the same x, y, xc, yc and nv: one already in the
771
+ # cache, else MESH_REFERENCE_URL, a published monthly archive file on the GOM7 mesh, read once (about 14 MB).
772
+ MESH_REFERENCE_URL = f"{NECOFS_GOM_ARCHIVE_BASE}/2025/necofs_202512.nc"
773
+ _GEOGRAPHIC = ("lon", "lat", "lonc", "latc")
774
+ _PLANAR = ("x", "y", "xc", "yc", "nv")
775
+
776
+
777
+ def _geographic_ok(mesh: dict[str, np.ndarray]) -> bool:
778
+ """Whether lon, lat, lonc and latc are finite, in range and not all one value."""
779
+ for name, limit in (("lon", 180.0), ("lat", 90.0), ("lonc", 180.0), ("latc", 90.0)):
780
+ v = np.asarray(mesh[name], dtype=np.float64)
781
+ if (
782
+ v.size == 0
783
+ or not np.isfinite(v).all()
784
+ or np.abs(v).max() > limit
785
+ or np.ptp(v) == 0
786
+ ):
787
+ return False
788
+ return True
789
+
790
+
791
+ def _same_planar(a: dict[str, np.ndarray], b: dict[str, np.ndarray]) -> bool:
792
+ return all(
793
+ np.asarray(a[k]).shape == np.asarray(b[k]).shape and np.array_equal(a[k], b[k])
794
+ for k in _PLANAR
795
+ )
796
+
797
+
798
+ def _geographic_donor(
799
+ mesh: dict[str, np.ndarray], url: str, cache: Path
800
+ ) -> tuple[dict[str, np.ndarray], str] | None:
801
+ """(arrays, source) of a mesh with usable lon/lat and the same planar mesh as `mesh`, or None."""
802
+ if cache.is_dir():
803
+ for path in sorted(cache.glob("*.npz")):
804
+ if path.name.startswith("."):
805
+ continue # another process's entry being written
806
+ try:
807
+ with np.load(path) as z:
808
+ donor = {k: z[k] for k in _GEOGRAPHIC + _PLANAR}
809
+ except Exception:
810
+ continue
811
+ if _geographic_ok(donor) and _same_planar(mesh, donor):
812
+ return donor, f"the cached mesh {path.name}"
813
+ if url == MESH_REFERENCE_URL:
814
+ return None
815
+ try:
816
+ with warnings.catch_warnings():
817
+ warnings.simplefilter("ignore")
818
+ ref = _open_dap(MESH_REFERENCE_URL)
819
+ donor = {k: np.asarray(ref[k].values) for k in _GEOGRAPHIC + _PLANAR}
820
+ except Exception as exc:
821
+ logger.warning(f"NECOFS mesh reference {MESH_REFERENCE_URL} not read ({exc})")
822
+ return None
823
+ if _geographic_ok(donor) and _same_planar(mesh, donor):
824
+ return donor, MESH_REFERENCE_URL
825
+ return None
826
+
827
+
828
+ def _usable_geographic(
829
+ mesh: dict[str, np.ndarray], url: str, cache: Path
830
+ ) -> dict[str, np.ndarray]:
831
+ """`mesh` itself when its lon/lat are usable; else with lon, lat, lonc and latc from a mesh with the same x, y,
832
+ xc, yc and nv (_geographic_donor). Raises when there is none, rather than letting a box select nothing."""
833
+ if _geographic_ok(mesh):
834
+ return mesh
835
+ found = _geographic_donor(mesh, url, cache)
836
+ if found is None:
837
+ raise ValueError(
838
+ f"NECOFS file {url} has no usable longitudes and latitudes, and no mesh with the same x, y and nv was found"
839
+ )
840
+ donor, source = found
841
+ logger.warning(
842
+ f"NECOFS file {url} has no usable longitudes and latitudes; taking them from {source}, which has the same x, y and nv"
843
+ )
844
+ return {**mesh, **{k: np.asarray(donor[k]) for k in _GEOGRAPHIC}}
845
+
846
+
768
847
  def _whole_mesh(ds: xr.Dataset, url: str) -> dict[str, np.ndarray]:
769
848
  """The file's MESH_VARIABLES as stored, with `nbe_all` and `boundary_nodes`; for a remote file from the cache when
770
849
  its mesh has been read before. Safe from several threads or processes: an entry is written under a temporary name
@@ -776,13 +855,16 @@ def _whole_mesh(ds: xr.Dataset, url: str) -> dict[str, np.ndarray]:
776
855
  )
777
856
 
778
857
  if not str(url).startswith(("http://", "https://")):
779
- return read()
858
+ return _usable_geographic(
859
+ read(), url, Path(settings.cache_dir("necofs", "mesh"))
860
+ )
780
861
  family, key = _mesh_key(ds, url)
781
862
  with _MESH_LOCK:
782
863
  if key in _MESHES:
783
864
  return _MESHES[key]
784
865
  path = Path(settings.cache_dir("necofs", "mesh", f"{key}.npz"))
785
866
  mesh = None
867
+ store = False # write the entry: read afresh, or a cached entry given usable coordinates
786
868
  if path.is_file():
787
869
  try:
788
870
  with np.load(path) as z:
@@ -802,6 +884,11 @@ def _whole_mesh(ds: xr.Dataset, url: str) -> dict[str, np.ndarray]:
802
884
  f"NECOFS {family} mesh differs from the cached {others}; reading the new mesh from {url}"
803
885
  )
804
886
  mesh = read()
887
+ store = True
888
+ repaired = _usable_geographic(mesh, url, path.parent)
889
+ store = store or repaired is not mesh
890
+ mesh = repaired
891
+ if store:
805
892
  path.parent.mkdir(parents=True, exist_ok=True)
806
893
  tmp = path.with_name(
807
894
  f".{path.stem}.{os.getpid()}.{threading.get_ident()}.tmp.npz"
@@ -475,3 +475,77 @@ def test_volume_passes_a_selection_to_each_file_and_caches_it_apart(archive):
475
475
  reader=selecting,
476
476
  variables=["speed"],
477
477
  )
478
+
479
+
480
+ def zeroed_coordinates(ds: xr.Dataset) -> xr.Dataset:
481
+ """The file as SMAST served it on 2026-11-20: x, y and nv right, longitudes and latitudes all zero."""
482
+ return ds.assign({k: ds[k] * 0 for k in ("lon", "lat", "lonc", "latc")})
483
+
484
+
485
+ @pytest.fixture
486
+ def mesh_cache(monkeypatch, tmp_path):
487
+ monkeypatch.setenv("FORCINGKIT_CACHE_DIR", str(tmp_path))
488
+ monkeypatch.setattr(necofs, "_MESHES", {})
489
+ return tmp_path
490
+
491
+
492
+ def test_zeroed_coordinates_are_taken_from_a_cached_mesh_with_the_same_planar_mesh(
493
+ mesh_cache, monkeypatch, caplog
494
+ ):
495
+ good = fvcom_file(day_file_times("2026-04-02"))
496
+ necofs._whole_mesh(good, "https://example.org/a.nc")
497
+ necofs._MESHES.clear()
498
+ monkeypatch.setattr(
499
+ necofs, "_open_dap", lambda url: pytest.fail("the reference is not needed")
500
+ )
501
+ mesh = necofs._whole_mesh(zeroed_coordinates(good), "https://example.org/b.nc")
502
+ for k in ("lon", "lat", "lonc", "latc"):
503
+ np.testing.assert_array_equal(mesh[k], good[k].values)
504
+ assert "no usable longitudes" in caplog.text
505
+ # the repaired mesh is cached under the broken file's own key
506
+ necofs._MESHES.clear()
507
+ again = necofs._whole_mesh(zeroed_coordinates(good), "https://example.org/b.nc")
508
+ np.testing.assert_array_equal(again["lonc"], good["lonc"].values)
509
+
510
+
511
+ def test_without_a_cached_match_the_reference_file_supplies_them(
512
+ mesh_cache, monkeypatch
513
+ ):
514
+ good = fvcom_file(day_file_times("2026-04-02"))
515
+ opened = []
516
+ monkeypatch.setattr(necofs, "_open_dap", lambda url: opened.append(url) or good)
517
+ mesh = necofs._whole_mesh(zeroed_coordinates(good), "https://example.org/b.nc")
518
+ assert opened == [necofs.MESH_REFERENCE_URL]
519
+ np.testing.assert_array_equal(mesh["lat"], good["lat"].values)
520
+ box = necofs._subset_volume(
521
+ zeroed_coordinates(good),
522
+ day_file_times("2026-04-02"),
523
+ INNER,
524
+ day_file_times("2026-04-02")[:2],
525
+ "https://example.org/b.nc",
526
+ )
527
+ assert box.sizes["element"] > 0
528
+
529
+
530
+ def test_a_different_planar_mesh_is_no_donor_and_none_raises(mesh_cache, monkeypatch):
531
+ good = fvcom_file(day_file_times("2026-04-02"))
532
+ moved = good.assign(x=good["x"] + 1.0)
533
+ # cached and usable, but not the same mesh
534
+ necofs._whole_mesh(moved, "https://example.org/a.nc")
535
+ necofs._MESHES.clear()
536
+
537
+ def unreachable(url):
538
+ raise OSError("server down")
539
+
540
+ monkeypatch.setattr(necofs, "_open_dap", unreachable)
541
+ with pytest.raises(ValueError, match="no usable longitudes"):
542
+ necofs._whole_mesh(zeroed_coordinates(good), "https://example.org/b.nc")
543
+
544
+
545
+ def test_a_usable_mesh_is_left_alone(mesh_cache, monkeypatch):
546
+ good = fvcom_file(day_file_times("2026-04-02"))
547
+ monkeypatch.setattr(
548
+ necofs, "_open_dap", lambda url: pytest.fail("no fallback for a usable mesh")
549
+ )
550
+ mesh = necofs._whole_mesh(good, "https://example.org/a.nc")
551
+ np.testing.assert_array_equal(mesh["lon"], good["lon"].values)
@@ -1000,7 +1000,7 @@ wheels = [
1000
1000
 
1001
1001
  [[package]]
1002
1002
  name = "forcingkit"
1003
- version = "0.23.0"
1003
+ version = "0.23.1"
1004
1004
  source = { editable = "." }
1005
1005
  dependencies = [
1006
1006
  { name = "bottleneck" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes