forcingkit 0.22.0__tar.gz → 0.22.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.22.0 → forcingkit-0.22.1}/PKG-INFO +1 -1
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/conf.py +1 -1
- {forcingkit-0.22.0 → forcingkit-0.22.1}/pyproject.toml +1 -1
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/routers/view.py +48 -7
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/preview.js +20 -6
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/scene3d.js +16 -12
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_view_store.py +39 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/uv.lock +1 -1
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.agents/forcingkit.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.claude/CLAUDE.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.env.template +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.github/copilot-instructions.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.github/workflows/docs.yml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.github/workflows/publish-client.yml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.github/workflows/publish.yml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.github/workflows/tests.yml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.gitignore +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.markdownlint.yaml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.pre-commit-config.yaml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/.python-version +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/AGENTS.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/CONTRIBUTING.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/Dockerfile +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/LICENSE +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/README.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/LICENSE +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/README.md +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/pyproject.toml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/src/forcingkit_client/__init__.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/src/forcingkit_client/client.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/src/forcingkit_client/schema.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/src/forcingkit_client/store.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/src/forcingkit_client/trajectory.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/tests/conftest.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/tests/test_client.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/tests/test_schema.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/tests/test_trajectory.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/client/uv.lock +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docker-compose.yml +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/Makefile +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/make.bat +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/requirements-docs.txt +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/_extra/CNAME +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/_static/forcingkit-noreaster-wind.gif +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/atmospheric_forcing.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/cache_viewer.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/client.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/doppio.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/fetchers.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/hycom.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/index.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/layered_mesh.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/mesh_frames.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/necofs.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/nyofs.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/rivers.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/roadmap.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/shelf_models.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/sources.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/docs/source/waves.rst +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/main.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/__init__.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/__init__.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/jobs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/main.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/routers/bathymetry.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/routers/removed.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/routers/stores.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/routers/viewer.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/stac.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/forcingkit_serve/view_store.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/service/run_server.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/__init__.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/data/rivers/northeast_us.json +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/dispatcher.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/coastwatch.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/dbofs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/doppio.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/erddap.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hfradar.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hrdps.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hrrr.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hrrr_atmosphere.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hrrr_levels.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hrrr_points.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hycom.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/hydrography.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/ndbc.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/necofs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/noaa.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/nwps.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/nyofs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/usgs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/fetchers/usgs_rivers.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/layered_mesh.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/mesh_frames.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/ramps/currents_lis.csv +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/ramps/currents_lis_dark.csv +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/ramps/currents_lis_deep.csv +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/ramps/currents_lis_haline.csv +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/render.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/settings.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/src/forcingkit/zarr_stream.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/app.js +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/cells_map.js +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/coverage.js +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/favicon.ico +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/favicon.svg +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/index.html +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/logo.svg +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/styles.css +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/static/view_api.js +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/__init__.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_auth.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_erddap_fetch.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_mesh_frames_necofs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_necofs_volume_live.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_nwps_nomads.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_nyofs_obc_fetch.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_obc_offshore_nj.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_ofs_archive_paths.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/integration/test_s3_roms_fetchers.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/scripts/inspect_dem.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/scripts/inspect_grib.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/scripts/inspect_zarr.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/data/doppio_reanalysis_20220811_corner.nc +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_cache_inventory.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_coastwatch.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_dbofs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_dispatcher.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_doppio.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_erddap.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hfradar.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hrdps.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hrrr_atm.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hrrr_idx.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hrrr_levels.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hrrr_points.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_hycom.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_jobs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_layered_mesh.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_main.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_mesh_frames.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_ndbc.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_necofs_hindcast.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_necofs_mesh_cache.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_necofs_parent.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_necofs_volume.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_noaa_currents.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_noaa_datum.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_nwps.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_nyofs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_obc_donor_report.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_obc_pipeline.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_removed_routes.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_settings.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_usgs.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.1}/tests/unit/test_usgs_rivers.py +0 -0
- {forcingkit-0.22.0 → forcingkit-0.22.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.22.
|
|
3
|
+
Version: 0.22.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.22.
|
|
7
|
+
version = "0.22.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"
|
|
@@ -8,6 +8,9 @@ little-endian.
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
10
|
import logging
|
|
11
|
+
import threading
|
|
12
|
+
import time
|
|
13
|
+
from pathlib import Path
|
|
11
14
|
from typing import Any, Callable
|
|
12
15
|
|
|
13
16
|
import numpy as np
|
|
@@ -15,6 +18,7 @@ from fastapi import APIRouter, HTTPException, Query
|
|
|
15
18
|
from fastapi.responses import JSONResponse, Response
|
|
16
19
|
from starlette.concurrency import run_in_threadpool
|
|
17
20
|
|
|
21
|
+
from forcingkit import settings
|
|
18
22
|
from forcingkit_serve import view_store
|
|
19
23
|
from forcingkit_serve.routers.viewer import _crawl_inventory
|
|
20
24
|
|
|
@@ -26,18 +30,55 @@ Detail = Query("2d", pattern="^(2d|3d)$", description="Cell budget: 2d or 3d")
|
|
|
26
30
|
BINARY = "application/octet-stream"
|
|
27
31
|
|
|
28
32
|
|
|
33
|
+
# Crawling the whole cache takes about 0.4 s on a cache of a few hundred stores, far more than
|
|
34
|
+
# drawing a cached record, so the store ids the crawl found are reused for a few seconds.
|
|
35
|
+
# Only ids a crawl listed resolve, and a store whose path is gone is looked up again.
|
|
36
|
+
RESOLVE_TTL_S = 10.0
|
|
37
|
+
_resolved: dict[str, Any] = {"dir": None, "at": 0.0, "stores": {}}
|
|
38
|
+
_resolve_lock = threading.Lock()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _fresh(cache_dir: str) -> bool:
|
|
42
|
+
return (
|
|
43
|
+
_resolved["dir"] == cache_dir
|
|
44
|
+
and time.monotonic() - _resolved["at"] < RESOLVE_TTL_S
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _locate(dataset_id: str) -> tuple[Path, Any] | None:
|
|
49
|
+
"""The store's path and change key (from the inventory), or None."""
|
|
50
|
+
cache_dir = str(settings.cache_dir())
|
|
51
|
+
if _fresh(cache_dir):
|
|
52
|
+
hit = _resolved["stores"].get(dataset_id)
|
|
53
|
+
if hit is not None and hit[0].exists():
|
|
54
|
+
return hit
|
|
55
|
+
with _resolve_lock:
|
|
56
|
+
# Another request may have crawled while this one waited.
|
|
57
|
+
hit = _resolved["stores"].get(dataset_id) if _fresh(cache_dir) else None
|
|
58
|
+
if hit is None or not hit[0].exists():
|
|
59
|
+
items = _crawl_inventory()
|
|
60
|
+
_resolved["stores"] = {
|
|
61
|
+
i.id: (Path(i.path), (i.modified_time, i.size_mb)) for i in items
|
|
62
|
+
}
|
|
63
|
+
_resolved["dir"], _resolved["at"] = cache_dir, time.monotonic()
|
|
64
|
+
return _resolved["stores"].get(dataset_id)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def forget_stores() -> None:
|
|
68
|
+
"""Drop the remembered store ids, so the next request crawls the cache."""
|
|
69
|
+
with _resolve_lock:
|
|
70
|
+
_resolved.update(dir=None, at=0.0, stores={})
|
|
71
|
+
|
|
72
|
+
|
|
29
73
|
def _view(dataset_id: str, detail: str) -> view_store.StoreView:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if path is None:
|
|
74
|
+
found = _locate(dataset_id)
|
|
75
|
+
if found is None:
|
|
33
76
|
raise HTTPException(
|
|
34
77
|
status_code=404, detail=f"No store {dataset_id} in the cache."
|
|
35
78
|
)
|
|
36
|
-
|
|
79
|
+
path, key = found
|
|
37
80
|
try:
|
|
38
|
-
return view_store.get_view(
|
|
39
|
-
dataset_id, path, detail, (item.modified_time, item.size_mb)
|
|
40
|
-
)
|
|
81
|
+
return view_store.get_view(dataset_id, path, detail, key)
|
|
41
82
|
except ValueError as e:
|
|
42
83
|
raise HTTPException(status_code=422, detail=str(e))
|
|
43
84
|
|
|
@@ -221,6 +221,19 @@ async function setMode(mode, quiet) {
|
|
|
221
221
|
|
|
222
222
|
// ---- drawing --------------------------------------------------------------------------------
|
|
223
223
|
|
|
224
|
+
// Sliders fire many times a second. One draw runs at a time; changes that arrive meanwhile are
|
|
225
|
+
// folded into one more draw of the latest state when it finishes, so dragging never queues up
|
|
226
|
+
// records the pointer has already left.
|
|
227
|
+
let drawing = null, drawAgain = false;
|
|
228
|
+
|
|
229
|
+
function requestDraw() {
|
|
230
|
+
if (drawing) { drawAgain = true; return drawing; }
|
|
231
|
+
drawing = (async () => {
|
|
232
|
+
do { drawAgain = false; await draw(); } while (drawAgain);
|
|
233
|
+
})().finally(() => { drawing = null; });
|
|
234
|
+
return drawing;
|
|
235
|
+
}
|
|
236
|
+
|
|
224
237
|
async function draw() {
|
|
225
238
|
if (!S.m) return;
|
|
226
239
|
const token = S.token;
|
|
@@ -238,8 +251,8 @@ async function draw() {
|
|
|
238
251
|
const codes = await api.frame(S.item.id, S.field, f.layered ? S.layer : 0, S.t, "2d");
|
|
239
252
|
if (token !== S.token) return;
|
|
240
253
|
map.setCodes(codes);
|
|
241
|
-
//
|
|
242
|
-
if (nRecords() > 1) api.frame(S.item.id, S.field, f.layered ? S.layer : 0, (S.t + 1) % nRecords(), "2d").catch(() => {});
|
|
254
|
+
// While playing, fetch the next record while this one is on screen.
|
|
255
|
+
if (S.playing && nRecords() > 1) api.frame(S.item.id, S.field, f.layered ? S.layer : 0, (S.t + 1) % nRecords(), "2d").catch(() => {});
|
|
243
256
|
}
|
|
244
257
|
} catch (e) {
|
|
245
258
|
console.error("draw:", e);
|
|
@@ -437,7 +450,7 @@ async function playLoop() {
|
|
|
437
450
|
S.t = (S.t + 1) % nRecords();
|
|
438
451
|
$("timeRange").value = S.t;
|
|
439
452
|
updateTimeLabel();
|
|
440
|
-
await
|
|
453
|
+
await requestDraw();
|
|
441
454
|
if (S.section) loadSection();
|
|
442
455
|
await new Promise((r) => setTimeout(r, Math.max(0, FRAME_MS - (performance.now() - started))));
|
|
443
456
|
}
|
|
@@ -477,14 +490,15 @@ function wire() {
|
|
|
477
490
|
$("layerRange").addEventListener("input", (e) => {
|
|
478
491
|
S.layer = +e.target.value;
|
|
479
492
|
updateLayerControls();
|
|
480
|
-
|
|
493
|
+
requestDraw();
|
|
481
494
|
});
|
|
482
495
|
$("timeRange").addEventListener("input", (e) => {
|
|
483
496
|
S.t = +e.target.value;
|
|
484
497
|
updateTimeLabel();
|
|
485
|
-
|
|
486
|
-
if (S.sectionPts) loadSection();
|
|
498
|
+
requestDraw();
|
|
487
499
|
});
|
|
500
|
+
// A section samples every layer, so it follows the record once the slider is let go.
|
|
501
|
+
$("timeRange").addEventListener("change", () => { if (S.sectionPts) loadSection(); });
|
|
488
502
|
$("playBtn").addEventListener("click", () => {
|
|
489
503
|
if (S.playing) { setPlaying(false); return; }
|
|
490
504
|
setPlaying(true);
|
|
@@ -407,13 +407,19 @@ export class Scene3D {
|
|
|
407
407
|
if (!this.luts.has(field)) this.luts.set(field, lutTexture(api.ramp(f)));
|
|
408
408
|
const lut = this.luts.get(field);
|
|
409
409
|
const levels = f.layered ? this.levels : [];
|
|
410
|
-
|
|
410
|
+
// Everything a record needs is requested at once, not one after another.
|
|
411
|
+
const vec = this.m.vectors[0];
|
|
412
|
+
const wantTracers = this.showTracers && vec;
|
|
413
|
+
const [codes, levelData, tracerData] = await Promise.all([
|
|
411
414
|
api.frame(this.id, field, 0, t, "3d"),
|
|
412
|
-
Promise.all(levels.map(async (k) =>
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
Promise.all(levels.map(async (k) => {
|
|
416
|
+
const [c, z] = await Promise.all([
|
|
417
|
+
api.frame(this.id, field, k, t, "3d"),
|
|
418
|
+
this.nominal ? null : api.heights(this.id, k, t, "3d"),
|
|
419
|
+
]);
|
|
420
|
+
return { k, codes: c, z };
|
|
421
|
+
})),
|
|
422
|
+
wantTracers ? api.tracers(this.id, vec.name, t, "3d") : null,
|
|
417
423
|
]);
|
|
418
424
|
if (token !== this.token) return;
|
|
419
425
|
this._setCodes(this.objects.surface, codes, lut);
|
|
@@ -424,7 +430,7 @@ export class Scene3D {
|
|
|
424
430
|
if (!keep.has(k)) { this.scene.remove(obj); dispose(obj); this.objects.levels.delete(k); }
|
|
425
431
|
}
|
|
426
432
|
for (const { k, codes: c, z } of levelData) this._levelMap(k, c, z, lut);
|
|
427
|
-
|
|
433
|
+
this._tracers(tracerData);
|
|
428
434
|
this._curtain();
|
|
429
435
|
if (this._fitPending) {
|
|
430
436
|
this._fitPending = false;
|
|
@@ -464,11 +470,9 @@ export class Scene3D {
|
|
|
464
470
|
this._setCodes(obj, codes, lut);
|
|
465
471
|
}
|
|
466
472
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (!
|
|
470
|
-
const d = await api.tracers(this.id, vec.name, t, "3d");
|
|
471
|
-
if (token !== this.token) return;
|
|
473
|
+
// Tracers from one record's velocities (null: tracers off or no vector pair).
|
|
474
|
+
_tracers(d) {
|
|
475
|
+
if (!d) { this.tracers.object.visible = false; return; }
|
|
472
476
|
const tri = this.geom.tri, items = [], nl = Math.max(1, this.m.layers.length);
|
|
473
477
|
d.element.forEach((e, c) => {
|
|
474
478
|
const P = [0, 1, 2].map((j) => { const v = tri[3 * e + j]; return [this.mx[v], this.my[v]]; });
|
|
@@ -240,6 +240,45 @@ async def test_api_serves_a_store_in_a_subfolder(tmp_path, monkeypatch):
|
|
|
240
240
|
assert unknown.status_code == 404
|
|
241
241
|
|
|
242
242
|
|
|
243
|
+
@pytest.mark.asyncio
|
|
244
|
+
async def test_api_reuses_the_store_list_between_requests(tmp_path, monkeypatch):
|
|
245
|
+
"""Drawing a record must not crawl the whole cache each time; a removed store is looked up
|
|
246
|
+
again and then reported missing."""
|
|
247
|
+
import shutil
|
|
248
|
+
|
|
249
|
+
from httpx import ASGITransport, AsyncClient
|
|
250
|
+
|
|
251
|
+
from forcingkit_serve.main import app
|
|
252
|
+
from forcingkit_serve.routers import view as view_api
|
|
253
|
+
from forcingkit_serve.routers import viewer
|
|
254
|
+
|
|
255
|
+
path = fvcom_store(tmp_path)
|
|
256
|
+
monkeypatch.setenv("FORCINGKIT_CACHE_DIR", str(tmp_path))
|
|
257
|
+
view_store.clear_views()
|
|
258
|
+
view_api.forget_stores()
|
|
259
|
+
crawls = []
|
|
260
|
+
real = viewer._crawl_inventory
|
|
261
|
+
|
|
262
|
+
def counting():
|
|
263
|
+
crawls.append(1)
|
|
264
|
+
return real()
|
|
265
|
+
|
|
266
|
+
monkeypatch.setattr(view_api, "_crawl_inventory", counting)
|
|
267
|
+
sid = path.stem
|
|
268
|
+
async with AsyncClient(
|
|
269
|
+
transport=ASGITransport(app=app), base_url="http://test"
|
|
270
|
+
) as ac:
|
|
271
|
+
for t in range(4):
|
|
272
|
+
r = await ac.get(f"/api/v1/cache/view/{sid}/frame?field=temp&layer=0&t={t}")
|
|
273
|
+
assert r.status_code == 200
|
|
274
|
+
assert len(crawls) == 1
|
|
275
|
+
shutil.rmtree(path)
|
|
276
|
+
gone = await ac.get(f"/api/v1/cache/view/{sid}/manifest")
|
|
277
|
+
assert gone.status_code == 404
|
|
278
|
+
assert len(crawls) == 2
|
|
279
|
+
view_api.forget_stores()
|
|
280
|
+
|
|
281
|
+
|
|
243
282
|
def test_curvilinear_sigma_store_with_depths_gets_true_heights(tmp_path):
|
|
244
283
|
"""A Doppio-shaped volume: 2-D centers as coordinates, sigma per cell surface first, the water
|
|
245
284
|
depth and a land mask."""
|
|
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.22.0 → forcingkit-0.22.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
|