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.
- {forcingkit-0.23.0 → forcingkit-0.23.1}/PKG-INFO +1 -1
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/conf.py +1 -1
- {forcingkit-0.23.0 → forcingkit-0.23.1}/pyproject.toml +1 -1
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/necofs.py +88 -1
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_volume.py +74 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/uv.lock +1 -1
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.agents/forcingkit.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.claude/CLAUDE.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.env.template +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/copilot-instructions.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/docs.yml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/publish-client.yml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/publish.yml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.github/workflows/tests.yml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.gitignore +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.markdownlint.yaml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.pre-commit-config.yaml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/.python-version +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/AGENTS.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/CONTRIBUTING.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/Dockerfile +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/LICENSE +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/README.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/LICENSE +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/README.md +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/pyproject.toml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/__init__.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/client.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/schema.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/store.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/src/forcingkit_client/trajectory.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/conftest.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/test_client.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/test_schema.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/tests/test_trajectory.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/client/uv.lock +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docker-compose.yml +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/Makefile +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/make.bat +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/requirements-docs.txt +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/_extra/CNAME +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/_static/forcingkit-noreaster-wind.gif +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/atmospheric_forcing.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/cache_viewer.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/client.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/doppio.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/fetchers.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/hycom.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/index.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/layered_mesh.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/mesh_frames.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/necofs.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/nyofs.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/rivers.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/roadmap.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/shelf_models.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/sources.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/docs/source/waves.rst +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/main.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/__init__.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/__init__.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/jobs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/main.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/bathymetry.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/removed.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/stores.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/view.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/routers/viewer.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/stac.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/forcingkit_serve/view_store.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/service/run_server.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/__init__.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/data/rivers/northeast_us.json +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/dispatcher.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/coastwatch.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/dbofs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/doppio.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/erddap.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hfradar.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrdps.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_atmosphere.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_levels.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_points.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hycom.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/hydrography.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/ndbc.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/noaa.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/nwps.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/nyofs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/usgs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/fetchers/usgs_rivers.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/layered_mesh.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/mesh_frames.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis.csv +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_dark.csv +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_deep.csv +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_haline.csv +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_tempo.csv +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_tempo_dark.csv +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/render.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/settings.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/src/forcingkit/zarr_stream.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/app.js +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/cells_map.js +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/coverage.js +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/favicon.ico +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/favicon.svg +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/index.html +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/logo.svg +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/preview.js +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/scene3d.js +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/styles.css +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/static/view_api.js +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/__init__.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_auth.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_erddap_fetch.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_mesh_frames_necofs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_necofs_volume_live.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_nwps_nomads.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_nyofs_obc_fetch.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_obc_offshore_nj.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_ofs_archive_paths.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/integration/test_s3_roms_fetchers.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/scripts/inspect_dem.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/scripts/inspect_grib.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/scripts/inspect_zarr.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/data/doppio_reanalysis_20220811_corner.nc +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_cache_inventory.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_coastwatch.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_dbofs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_dispatcher.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_doppio.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_erddap.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hfradar.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrdps.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_atm.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_idx.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_levels.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hrrr_points.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_hycom.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_jobs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_layered_mesh.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_main.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_mesh_frames.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_ndbc.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_hindcast.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_mesh_cache.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_necofs_parent.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_noaa_currents.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_noaa_datum.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_nwps.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_nyofs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_obc_donor_report.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_obc_pipeline.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_removed_routes.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_settings.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_usgs.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_usgs_rivers.py +0 -0
- {forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/test_view_store.py +0 -0
- {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.
|
|
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
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "forcingkit"
|
|
7
|
-
version = "0.23.
|
|
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
|
|
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)
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
{forcingkit-0.23.0 → forcingkit-0.23.1}/tests/unit/data/doppio_reanalysis_20220811_corner.nc
RENAMED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|