forcingkit 0.22.2__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.22.2 → forcingkit-0.23.1}/PKG-INFO +1 -1
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/cache_viewer.rst +3 -2
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/conf.py +1 -1
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/mesh_frames.rst +9 -2
- {forcingkit-0.22.2 → forcingkit-0.23.1}/pyproject.toml +1 -1
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/view_store.py +18 -8
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/necofs.py +88 -1
- forcingkit-0.23.1/src/forcingkit/ramps/currents_tempo.csv +69 -0
- forcingkit-0.23.1/src/forcingkit/ramps/currents_tempo_dark.csv +69 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/render.py +25 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_mesh_frames.py +37 -1
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_necofs_volume.py +74 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_view_store.py +3 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/uv.lock +1 -1
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.agents/forcingkit.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.claude/CLAUDE.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.env.template +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.github/copilot-instructions.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.github/workflows/docs.yml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.github/workflows/publish-client.yml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.github/workflows/publish.yml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.github/workflows/tests.yml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.gitignore +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.markdownlint.yaml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.pre-commit-config.yaml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/.python-version +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/AGENTS.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/CONTRIBUTING.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/Dockerfile +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/LICENSE +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/README.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/LICENSE +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/README.md +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/pyproject.toml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/src/forcingkit_client/__init__.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/src/forcingkit_client/client.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/src/forcingkit_client/schema.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/src/forcingkit_client/store.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/src/forcingkit_client/trajectory.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/tests/conftest.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/tests/test_client.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/tests/test_schema.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/tests/test_trajectory.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/client/uv.lock +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docker-compose.yml +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/Makefile +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/make.bat +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/requirements-docs.txt +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/_extra/CNAME +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/_static/forcingkit-noreaster-wind.gif +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/atmospheric_forcing.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/client.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/doppio.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/fetchers.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/hycom.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/index.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/layered_mesh.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/necofs.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/nyofs.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/rivers.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/roadmap.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/shelf_models.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/sources.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/docs/source/waves.rst +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/main.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/__init__.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/__init__.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/jobs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/main.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/routers/bathymetry.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/routers/removed.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/routers/stores.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/routers/view.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/routers/viewer.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/forcingkit_serve/stac.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/service/run_server.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/__init__.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/data/rivers/northeast_us.json +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/dispatcher.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/coastwatch.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/dbofs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/doppio.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/erddap.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hfradar.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrdps.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_atmosphere.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_levels.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hrrr_points.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hycom.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/hydrography.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/ndbc.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/noaa.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/nwps.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/nyofs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/usgs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/fetchers/usgs_rivers.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/layered_mesh.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/mesh_frames.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis.csv +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_dark.csv +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_deep.csv +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/ramps/currents_lis_haline.csv +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/settings.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/src/forcingkit/zarr_stream.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/app.js +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/cells_map.js +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/coverage.js +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/favicon.ico +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/favicon.svg +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/index.html +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/logo.svg +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/preview.js +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/scene3d.js +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/styles.css +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/static/view_api.js +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/__init__.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_auth.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_erddap_fetch.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_mesh_frames_necofs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_necofs_volume_live.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_nwps_nomads.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_nyofs_obc_fetch.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_obc_offshore_nj.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_ofs_archive_paths.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/integration/test_s3_roms_fetchers.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/scripts/inspect_dem.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/scripts/inspect_grib.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/scripts/inspect_zarr.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/data/doppio_reanalysis_20220811_corner.nc +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_cache_inventory.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_coastwatch.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_dbofs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_dispatcher.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_doppio.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_erddap.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hfradar.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hrdps.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hrrr_atm.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hrrr_idx.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hrrr_levels.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hrrr_points.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_hycom.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_jobs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_layered_mesh.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_main.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_ndbc.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_necofs_hindcast.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_necofs_mesh_cache.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_necofs_parent.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_noaa_currents.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_noaa_datum.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_nwps.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_nyofs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_obc_donor_report.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_obc_pipeline.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_removed_routes.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_settings.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_usgs.py +0 -0
- {forcingkit-0.22.2 → forcingkit-0.23.1}/tests/unit/test_usgs_rivers.py +0 -0
- {forcingkit-0.22.2 → 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.
|
|
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
|
|
@@ -57,8 +57,9 @@ The preview draws what the store holds and nothing more:
|
|
|
57
57
|
- **Fixed scales.** A field's scale is set once per store from the 1st to the 99th percentile of
|
|
58
58
|
its values weighted by cell area (symmetric about zero, at the 99.5th percentile of the
|
|
59
59
|
magnitude, for signed fields), so a color means the same value in every record and layer.
|
|
60
|
-
Water speed uses the packaged ``
|
|
61
|
-
a log axis), so different stores compare directly.
|
|
60
|
+
Water speed uses the packaged ``currents_tempo_dark`` ramp at its own speeds (0.02 to 3.1 m/s on
|
|
61
|
+
a log axis), so different stores compare directly. Temperature is drawn on cmocean "thermal" and
|
|
62
|
+
salinity on "haline", the maps oceanographers know for them.
|
|
62
63
|
- **True heights.** Layers run from the surface down and are labeled with their mean depth:
|
|
63
64
|
fixed levels from the store's vertical coordinate, sigma layers from ``siglay`` and the water
|
|
64
65
|
depth ``h``, atmosphere levels from their heights. Sigma layers in a store without ``h`` are
|
|
@@ -38,7 +38,8 @@ Colour
|
|
|
38
38
|
|
|
39
39
|
- ``default_color``: viridis, linear over 0 to 1.5 m/s;
|
|
40
40
|
- ``named_color(name, vmin, vmax, log=False, floor=None)``: a built-in ramp (``viridis``,
|
|
41
|
-
``greys``) over a chosen
|
|
41
|
+
``greys``, and cmocean's ``thermal`` for temperature and ``haline`` for salinity) over a chosen
|
|
42
|
+
range;
|
|
42
43
|
- ``lut_color(rows, log=False, floor=None)``: a lookup table of ``(value, r, g, b[, a])`` rows.
|
|
43
44
|
Values below the first row, or below ``floor``, take the first colour; between rows each channel
|
|
44
45
|
is interpolated linearly in the value, or in log(value) when ``log`` is true; values above the
|
|
@@ -56,7 +57,13 @@ Colour
|
|
|
56
57
|
teal and navy to deep purple) and "haline" (dark backgrounds: indigo through blue and green to
|
|
57
58
|
pale yellow). They separate speeds more strongly than the single-hue pair, but they are not
|
|
58
59
|
mirror images: purple is fast in one and slow in the other. Use them for a field shown alone
|
|
59
|
-
with its legend, not beside other colour-mapped layers.
|
|
60
|
+
with its legend, not beside other colour-mapped layers. Haline is cmocean's salinity map, so a
|
|
61
|
+
reader may take it for salinity;
|
|
62
|
+
- ``packaged_color("currents_tempo")`` and ``packaged_color("currents_tempo_dark")``: after cmocean
|
|
63
|
+
"tempo" on the same speeds, near white at slack through teal-green to deep teal on a light
|
|
64
|
+
basemap, and the reverse on a dark one, so the pair swaps by theme alone. This is the currents
|
|
65
|
+
ramp the Long Horizon Observatory's sites and viewers share; temperature takes cmocean
|
|
66
|
+
"thermal" and salinity "haline".
|
|
60
67
|
|
|
61
68
|
Python
|
|
62
69
|
------
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "forcingkit"
|
|
7
|
-
version = "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"
|
|
@@ -39,7 +39,7 @@ from forcingkit.layered_mesh import (
|
|
|
39
39
|
to_local,
|
|
40
40
|
weighted_percentile,
|
|
41
41
|
)
|
|
42
|
-
from forcingkit.render import PACKAGED_RAMPS, lut_color, packaged_ramp_rows
|
|
42
|
+
from forcingkit.render import PACKAGED_RAMPS, RAMPS, lut_color, packaged_ramp_rows
|
|
43
43
|
|
|
44
44
|
logger = logging.getLogger(__name__)
|
|
45
45
|
|
|
@@ -52,7 +52,7 @@ SCALE_LAYERS = 8
|
|
|
52
52
|
VOLUME_CACHE_BYTES = 256 * 2**20
|
|
53
53
|
# Water speed is drawn on the packaged currents ramp at its own speeds, so maps of different
|
|
54
54
|
# stores compare directly.
|
|
55
|
-
WATER_SPEED_RAMP = "
|
|
55
|
+
WATER_SPEED_RAMP = "currents_tempo_dark"
|
|
56
56
|
|
|
57
57
|
_TIME_DIMS = ("time", "ocean_time", "valid_time")
|
|
58
58
|
_VERTICAL_DIMS = ("z", "depth", "level", "s_rho", "siglay", "sigma", "lev")
|
|
@@ -141,13 +141,14 @@ _UNITS = {
|
|
|
141
141
|
"m3 s-1": "m³/s",
|
|
142
142
|
}
|
|
143
143
|
_SYMMETRIC = {"u", "v", "w", "ww", "water_u", "water_v", "u10", "v10", "zeta"}
|
|
144
|
+
# cmocean's maps for temperature and salinity (forcingkit.render.RAMPS), as the community reads them.
|
|
144
145
|
_RAMPS = {
|
|
145
|
-
"temp": "
|
|
146
|
-
"temperature": "
|
|
147
|
-
"t2m": "
|
|
148
|
-
"t": "
|
|
149
|
-
"salt": "
|
|
150
|
-
"salinity": "
|
|
146
|
+
"temp": "thermal",
|
|
147
|
+
"temperature": "thermal",
|
|
148
|
+
"t2m": "thermal",
|
|
149
|
+
"t": "thermal",
|
|
150
|
+
"salt": "haline",
|
|
151
|
+
"salinity": "haline",
|
|
151
152
|
"h": "cividis",
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -219,6 +220,15 @@ def _ramp_rgba(meta: FieldMeta, ramp: str) -> bytes:
|
|
|
219
220
|
if ramp in PACKAGED_RAMPS:
|
|
220
221
|
color = lut_color(packaged_ramp_rows(ramp), **PACKAGED_RAMPS[ramp])
|
|
221
222
|
rgba[1:] = color(meta.decode(codes[1:]))
|
|
223
|
+
elif ramp in RAMPS:
|
|
224
|
+
knots = np.array(RAMPS[ramp], dtype=float)
|
|
225
|
+
f = (codes[1:] - 1) / 254.0
|
|
226
|
+
rgba[1:, :3] = np.rint(
|
|
227
|
+
np.stack(
|
|
228
|
+
[np.interp(f, knots[:, 0], knots[:, k]) for k in (1, 2, 3)], axis=1
|
|
229
|
+
)
|
|
230
|
+
).astype(np.uint8)
|
|
231
|
+
rgba[1:, 3] = 255
|
|
222
232
|
else:
|
|
223
233
|
from matplotlib import colormaps
|
|
224
234
|
|
|
@@ -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"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Currents speed ramp after cmocean "tempo" (Thyng et al. 2016; cmocean is MIT licensed), for a light
|
|
2
|
+
# basemap: speed_m_s,r,g,b (sRGB), on the same speeds as currents_lis. Interpolate in log(speed); speeds below
|
|
3
|
+
# the first row take its colour (floor 0.02 m/s) and speeds above the last row (3.1 m/s) clamp to it.
|
|
4
|
+
# Near white at slack through sage and teal to navy, lightness falling with speed. Colormap
|
|
5
|
+
# position is piecewise linear in log(speed): 0.02 -> 0, 0.494 -> 0.29, 2.418 -> 0.80, 3.097 -> 1.0.
|
|
6
|
+
# Knots from 2026 NOAA CO-OPS current predictions (MAX_SLACK), Long Island Sound and Block Island
|
|
7
|
+
# Sound: regional median daily maximum 0.494 m/s; ACT2611 Little Gull Island median daily maximum
|
|
8
|
+
# 2.418 m/s, 95th percentile 2.964 m/s, annual maximum 3.097 m/s.
|
|
9
|
+
speed_m_s,r,g,b
|
|
10
|
+
0.0200,255,246,244
|
|
11
|
+
0.0221,252,244,241
|
|
12
|
+
0.0244,249,242,238
|
|
13
|
+
0.0270,247,240,235
|
|
14
|
+
0.0299,242,237,231
|
|
15
|
+
0.0330,240,235,228
|
|
16
|
+
0.0365,237,234,225
|
|
17
|
+
0.0403,233,231,221
|
|
18
|
+
0.0446,230,229,218
|
|
19
|
+
0.0493,227,227,215
|
|
20
|
+
0.0545,223,225,211
|
|
21
|
+
0.0602,220,223,208
|
|
22
|
+
0.0666,217,221,205
|
|
23
|
+
0.0736,213,219,201
|
|
24
|
+
0.0813,210,217,199
|
|
25
|
+
0.0899,207,216,196
|
|
26
|
+
0.0994,203,213,192
|
|
27
|
+
0.1099,200,212,190
|
|
28
|
+
0.1215,197,210,187
|
|
29
|
+
0.1343,192,208,183
|
|
30
|
+
0.1484,189,206,181
|
|
31
|
+
0.1641,186,205,179
|
|
32
|
+
0.1813,182,203,175
|
|
33
|
+
0.2005,179,201,173
|
|
34
|
+
0.2216,176,200,171
|
|
35
|
+
0.2449,172,198,169
|
|
36
|
+
0.2708,168,196,165
|
|
37
|
+
0.2993,164,195,163
|
|
38
|
+
0.3309,161,193,161
|
|
39
|
+
0.3657,156,191,159
|
|
40
|
+
0.4043,153,190,157
|
|
41
|
+
0.4469,150,188,155
|
|
42
|
+
0.4940,145,186,152
|
|
43
|
+
0.5348,134,182,147
|
|
44
|
+
0.5790,122,177,142
|
|
45
|
+
0.6269,111,173,139
|
|
46
|
+
0.6787,97,169,135
|
|
47
|
+
0.7348,86,164,133
|
|
48
|
+
0.7955,71,159,130
|
|
49
|
+
0.8613,59,155,129
|
|
50
|
+
0.9324,46,149,128
|
|
51
|
+
1.0095,36,144,127
|
|
52
|
+
1.0929,26,138,125
|
|
53
|
+
1.1833,19,132,123
|
|
54
|
+
1.2810,17,126,122
|
|
55
|
+
1.3869,17,119,119
|
|
56
|
+
1.5015,19,114,117
|
|
57
|
+
1.6256,22,107,114
|
|
58
|
+
1.7600,24,101,111
|
|
59
|
+
1.9054,26,95,107
|
|
60
|
+
2.0629,27,89,104
|
|
61
|
+
2.2334,28,83,100
|
|
62
|
+
2.4180,28,77,97
|
|
63
|
+
2.5198,28,69,91
|
|
64
|
+
2.6259,27,62,87
|
|
65
|
+
2.7365,26,54,81
|
|
66
|
+
2.8518,25,46,77
|
|
67
|
+
2.9719,23,37,72
|
|
68
|
+
3.0970,21,29,68
|
|
69
|
+
3.1000,21,29,68
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Currents speed ramp after cmocean "tempo", reversed, for a dark basemap (Thyng et al. 2016; cmocean is MIT
|
|
2
|
+
# licensed): speed_m_s,r,g,b (sRGB), on the same speeds as currents_tempo, so the two swap by theme alone.
|
|
3
|
+
# Interpolate in log(speed); speeds below the first row take its colour (floor 0.02 m/s) and speeds above the
|
|
4
|
+
# last row (3.1 m/s) clamp to it. Navy at slack through teal and sage to near white, lightness rising with
|
|
5
|
+
# speed. Colormap position is 1 minus currents_tempo's, piecewise linear in log(speed) through the same knots.
|
|
6
|
+
# Knots from 2026 NOAA CO-OPS current predictions (MAX_SLACK), Long Island Sound and Block Island
|
|
7
|
+
# Sound: regional median daily maximum 0.494 m/s; ACT2611 Little Gull Island median daily maximum
|
|
8
|
+
# 2.418 m/s, 95th percentile 2.964 m/s, annual maximum 3.097 m/s.
|
|
9
|
+
speed_m_s,r,g,b
|
|
10
|
+
0.0200,21,29,68
|
|
11
|
+
0.0221,21,31,69
|
|
12
|
+
0.0244,22,33,70
|
|
13
|
+
0.0270,22,35,71
|
|
14
|
+
0.0299,23,38,72
|
|
15
|
+
0.0330,23,40,74
|
|
16
|
+
0.0365,24,42,75
|
|
17
|
+
0.0403,24,45,76
|
|
18
|
+
0.0446,25,47,77
|
|
19
|
+
0.0493,25,49,79
|
|
20
|
+
0.0545,26,52,80
|
|
21
|
+
0.0602,26,54,81
|
|
22
|
+
0.0666,26,55,83
|
|
23
|
+
0.0736,27,58,84
|
|
24
|
+
0.0813,27,60,86
|
|
25
|
+
0.0899,27,62,87
|
|
26
|
+
0.0994,28,65,88
|
|
27
|
+
0.1099,28,66,90
|
|
28
|
+
0.1215,28,68,91
|
|
29
|
+
0.1343,28,71,93
|
|
30
|
+
0.1484,28,73,94
|
|
31
|
+
0.1641,28,75,95
|
|
32
|
+
0.1813,28,77,97
|
|
33
|
+
0.2005,28,79,98
|
|
34
|
+
0.2216,28,81,99
|
|
35
|
+
0.2449,28,83,100
|
|
36
|
+
0.2708,27,86,102
|
|
37
|
+
0.2993,27,88,103
|
|
38
|
+
0.3309,27,89,104
|
|
39
|
+
0.3657,26,92,106
|
|
40
|
+
0.4043,26,94,107
|
|
41
|
+
0.4469,25,96,108
|
|
42
|
+
0.4940,25,99,109
|
|
43
|
+
0.5348,23,104,112
|
|
44
|
+
0.5790,20,111,115
|
|
45
|
+
0.6269,18,117,118
|
|
46
|
+
0.6787,17,123,121
|
|
47
|
+
0.7348,18,129,123
|
|
48
|
+
0.7955,22,135,124
|
|
49
|
+
0.8613,30,141,126
|
|
50
|
+
0.9324,41,147,127
|
|
51
|
+
1.0095,52,152,128
|
|
52
|
+
1.0929,65,157,130
|
|
53
|
+
1.1833,80,162,132
|
|
54
|
+
1.2810,91,166,134
|
|
55
|
+
1.3869,105,171,137
|
|
56
|
+
1.5015,116,175,141
|
|
57
|
+
1.6256,129,180,145
|
|
58
|
+
1.7600,139,184,150
|
|
59
|
+
1.9054,151,189,156
|
|
60
|
+
2.0629,161,193,161
|
|
61
|
+
2.2334,172,198,169
|
|
62
|
+
2.4180,182,203,175
|
|
63
|
+
2.5198,195,209,186
|
|
64
|
+
2.6259,207,216,196
|
|
65
|
+
2.7365,220,223,208
|
|
66
|
+
2.8518,231,230,219
|
|
67
|
+
2.9719,244,238,232
|
|
68
|
+
3.0970,255,246,244
|
|
69
|
+
3.1000,255,246,244
|
|
@@ -47,6 +47,26 @@ RAMPS: dict[str, list[tuple[float, int, int, int]]] = {
|
|
|
47
47
|
(1.00, 253, 231, 37),
|
|
48
48
|
],
|
|
49
49
|
"greys": [(0.0, 240, 240, 240), (1.0, 30, 30, 30)],
|
|
50
|
+
# Seven samples each of cmocean "thermal" (temperature) and "haline" (salinity), Thyng et al. 2016
|
|
51
|
+
# (cmocean is MIT licensed): the community's maps for those variables, low to high.
|
|
52
|
+
"thermal": [
|
|
53
|
+
(0 / 6, 4, 35, 51),
|
|
54
|
+
(1 / 6, 44, 51, 149),
|
|
55
|
+
(2 / 6, 116, 73, 146),
|
|
56
|
+
(3 / 6, 177, 95, 130),
|
|
57
|
+
(4 / 6, 235, 118, 85),
|
|
58
|
+
(5 / 6, 251, 180, 61),
|
|
59
|
+
(6 / 6, 232, 250, 91),
|
|
60
|
+
],
|
|
61
|
+
"haline": [
|
|
62
|
+
(0 / 6, 42, 24, 108),
|
|
63
|
+
(1 / 6, 20, 67, 156),
|
|
64
|
+
(2 / 6, 32, 110, 139),
|
|
65
|
+
(3 / 6, 60, 147, 135),
|
|
66
|
+
(4 / 6, 90, 185, 120),
|
|
67
|
+
(5 / 6, 170, 216, 92),
|
|
68
|
+
(6 / 6, 253, 239, 154),
|
|
69
|
+
],
|
|
50
70
|
}
|
|
51
71
|
DEFAULT_RAMP = "viridis"
|
|
52
72
|
DEFAULT_VMAX = 1.5 # m/s
|
|
@@ -150,6 +170,11 @@ PACKAGED_RAMPS: dict[str, dict] = {
|
|
|
150
170
|
# falling) and "haline" (dark; rising), for a field shown alone with its legend.
|
|
151
171
|
"currents_lis_deep": {"log": True, "floor": 0.02},
|
|
152
172
|
"currents_lis_haline": {"log": True, "floor": 0.02},
|
|
173
|
+
# After cmocean "tempo" on the same speeds: near white through sage and teal to navy (light
|
|
174
|
+
# basemaps, lightness falling) and its reverse (dark basemaps, rising), so the pair swaps by theme.
|
|
175
|
+
# The currents ramp shared by the Long Horizon Observatory's products; "haline" stays salinity.
|
|
176
|
+
"currents_tempo": {"log": True, "floor": 0.02},
|
|
177
|
+
"currents_tempo_dark": {"log": True, "floor": 0.02},
|
|
153
178
|
}
|
|
154
179
|
|
|
155
180
|
|
|
@@ -386,9 +386,45 @@ def test_multi_hue_currents_ramps_share_the_axis(name, falling):
|
|
|
386
386
|
assert not np.any((chroma > 10) & ((hue < 80) | (hue > 340))), hue
|
|
387
387
|
|
|
388
388
|
|
|
389
|
+
@pytest.mark.parametrize(
|
|
390
|
+
("name", "falling"), [("currents_tempo", True), ("currents_tempo_dark", False)]
|
|
391
|
+
)
|
|
392
|
+
def test_tempo_currents_ramps_share_the_axis_and_swap_by_theme(name, falling):
|
|
393
|
+
light = np.array(render.packaged_ramp_rows("currents_lis"))
|
|
394
|
+
rows = np.array(render.packaged_ramp_rows(name))
|
|
395
|
+
np.testing.assert_array_equal(rows[:, 0], light[:, 0])
|
|
396
|
+
L = _lightness(rows[:, 1:])
|
|
397
|
+
assert np.all(np.diff(L) <= 0) if falling else np.all(np.diff(L) >= 0), (
|
|
398
|
+
"lightness must be monotone"
|
|
399
|
+
)
|
|
400
|
+
# Slack recedes into the basemap and fast water stands out on either: near white or near the dark ground.
|
|
401
|
+
assert (L[0] > 95 and L[-1] < 15) if falling else (L[0] < 15 and L[-1] > 95)
|
|
402
|
+
lab = _lab(rows[:, 1:])
|
|
403
|
+
hue = np.degrees(np.arctan2(lab[:, 2], lab[:, 1])) % 360
|
|
404
|
+
chroma = np.hypot(lab[:, 1], lab[:, 2])
|
|
405
|
+
assert not np.any((chroma > 10) & ((hue < 80) | (hue > 340))), hue
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def test_tempo_pair_mirrors():
|
|
409
|
+
light = np.array(render.packaged_ramp_rows("currents_tempo"))
|
|
410
|
+
dark = np.array(render.packaged_ramp_rows("currents_tempo_dark"))
|
|
411
|
+
np.testing.assert_array_equal(dark[:, 0], light[:, 0])
|
|
412
|
+
np.testing.assert_array_equal(
|
|
413
|
+
dark[0, 1:], light[-1, 1:]
|
|
414
|
+
) # the dark ramp's slack is the light ramp's fastest
|
|
415
|
+
np.testing.assert_array_equal(dark[-1, 1:], light[0, 1:])
|
|
416
|
+
|
|
417
|
+
|
|
389
418
|
@pytest.mark.parametrize(
|
|
390
419
|
"name",
|
|
391
|
-
[
|
|
420
|
+
[
|
|
421
|
+
"currents_lis",
|
|
422
|
+
"currents_lis_dark",
|
|
423
|
+
"currents_lis_deep",
|
|
424
|
+
"currents_lis_haline",
|
|
425
|
+
"currents_tempo",
|
|
426
|
+
"currents_tempo_dark",
|
|
427
|
+
],
|
|
392
428
|
)
|
|
393
429
|
def test_currents_ramp_floor_log_axis_and_clamp(name):
|
|
394
430
|
rows = render.packaged_ramp_rows(name)
|
|
@@ -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)
|
|
@@ -207,6 +207,9 @@ def test_ramp_has_transparent_no_value_and_one_entry_per_code(tmp_path):
|
|
|
207
207
|
temp = next(f for f in view.manifest()["fields"] if f["name"] == "temp")
|
|
208
208
|
rgba = np.frombuffer(base64.b64decode(temp["ramp_rgba"]), np.uint8).reshape(256, 4)
|
|
209
209
|
assert rgba[0, 3] == 0 and np.all(rgba[1:, 3] == 255)
|
|
210
|
+
# Temperature on cmocean thermal: its first and last knots at the ends of the codes.
|
|
211
|
+
assert tuple(rgba[1, :3]) == (4, 35, 51) and tuple(rgba[255, :3]) == (232, 250, 91)
|
|
212
|
+
assert temp["ramp"] == "thermal"
|
|
210
213
|
|
|
211
214
|
|
|
212
215
|
@pytest.mark.asyncio
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
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.2 → 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
|