skyborn-plot 0.1.0__cp314-cp314-win_amd64.whl
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.
- skyborn_plot-0.1.0.dist-info/METADATA +93 -0
- skyborn_plot-0.1.0.dist-info/RECORD +40 -0
- skyborn_plot-0.1.0.dist-info/WHEEL +5 -0
- skyborn_plot-0.1.0.dist-info/licenses/LICENSE +29 -0
- skyborn_plot-0.1.0.dist-info/top_level.txt +1 -0
- skybornplot/__init__.py +34 -0
- skybornplot/_adapters/__init__.py +1 -0
- skybornplot/_adapters/cartopy_vector.py +144 -0
- skybornplot/_adapters/curly_vector_entry.py +389 -0
- skybornplot/_adapters/dataset_vector.py +191 -0
- skybornplot/_adapters/grid_prepare.py +210 -0
- skybornplot/_artists/__init__.py +1 -0
- skybornplot/_artists/vector_artists.py +299 -0
- skybornplot/_artists/vector_key_artist.py +545 -0
- skybornplot/_core/__init__.py +1 -0
- skybornplot/_core/contour_arrows.py +708 -0
- skybornplot/_core/contour_arrows_core.cp314-win_amd64.dll.a +0 -0
- skybornplot/_core/contour_arrows_core.cp314-win_amd64.pyd +0 -0
- skybornplot/_core/geometry.py +277 -0
- skybornplot/_core/legacy_stream.py +150 -0
- skybornplot/_core/native.py +303 -0
- skybornplot/_core/result.py +105 -0
- skybornplot/_core/scatter_engine.py +564 -0
- skybornplot/_core/thinning.py +132 -0
- skybornplot/_core/vector_engine.py +1154 -0
- skybornplot/_shared/__init__.py +1 -0
- skybornplot/_shared/axes.py +19 -0
- skybornplot/_shared/coords.py +387 -0
- skybornplot/_shared/style.py +215 -0
- skybornplot/_shared/types.py +9 -0
- skybornplot/contour.py +836 -0
- skybornplot/contour_core/__init__.py +7 -0
- skybornplot/contour_core/_contour_core.cp314-win_amd64.dll.a +0 -0
- skybornplot/contour_core/_contour_core.cp314-win_amd64.pyd +0 -0
- skybornplot/nclcurly_core/__init__.py +34 -0
- skybornplot/nclcurly_core/_ncl_curly_core.cp314-win_amd64.dll.a +0 -0
- skybornplot/nclcurly_core/_ncl_curly_core.cp314-win_amd64.pyd +0 -0
- skybornplot/plotting.py +447 -0
- skybornplot/scatter.py +171 -0
- skybornplot/vector.py +1377 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: skyborn-plot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: NCL-style atmospheric and climate vector, contour, and scatter plotting with compiled C kernels
|
|
5
|
+
Author-email: Qianye Su <suqianye2000@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/skyborn-org/skyborn-plot
|
|
8
|
+
Project-URL: Repository, https://github.com/skyborn-org/skyborn-plot
|
|
9
|
+
Project-URL: Documentation, https://skyborn.readthedocs.io/
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/skyborn-org/skyborn-plot/issues
|
|
11
|
+
Keywords: atmospheric-science,meteorology,climate,visualization,matplotlib,curly-vector,ncl
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Operating System :: MacOS
|
|
24
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
25
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: numpy>=1.24.0
|
|
30
|
+
Requires-Dist: matplotlib>=3.6.0
|
|
31
|
+
Provides-Extra: geo
|
|
32
|
+
Requires-Dist: cartopy; extra == "geo"
|
|
33
|
+
Requires-Dist: xarray; extra == "geo"
|
|
34
|
+
Requires-Dist: scipy; extra == "geo"
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
37
|
+
Requires-Dist: xarray; extra == "dev"
|
|
38
|
+
Requires-Dist: scipy; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# skyborn-plot (`skybornplot`)
|
|
42
|
+
|
|
43
|
+
High-performance, NCL-style atmospheric & climate visualization toolkit for Matplotlib and Cartopy, powered by pure C99 native kernels.
|
|
44
|
+
|
|
45
|
+
Part of the [**Skyborn** (`skyborn-org`)](https://github.com/skyborn-org) ecosystem.
|
|
46
|
+
|
|
47
|
+
## Key Features
|
|
48
|
+
|
|
49
|
+
- **`curly_vector` & `curly_vector_key`**: Curved streamline-following vector fields with NCL-faithful thinning, closed-apex open/filled arrowheads, and L-shaped reference vector keys.
|
|
50
|
+
- **`arrow_contour` & `arrow_contour_clabel`**: Streamline-aligned directional contour arrows with automatic label avoidance.
|
|
51
|
+
- **`shadow_contourf`**: Shaded/hatched significance and terrain overlays.
|
|
52
|
+
- **`gradient_fill_between` / `GradientFillBetween`**: Smooth vertical/horizontal gradient fills and figure helpers (`createFigure`, `add_equal_axes`, `add_centered_axes`).
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install skyborn-plot
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Optional geospatial & xarray support:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install "skyborn-plot[geo]"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or install the full Skyborn suite:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install skyborn
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
import matplotlib.pyplot as plt
|
|
76
|
+
import skybornplot as splt
|
|
77
|
+
|
|
78
|
+
fig, ax = plt.subplots(figsize=(8, 4))
|
|
79
|
+
cv = splt.curly_vector(
|
|
80
|
+
ax, lon, lat, u, v,
|
|
81
|
+
density=1.2,
|
|
82
|
+
arrowstyle="->",
|
|
83
|
+
color=speed,
|
|
84
|
+
cmap="viridis",
|
|
85
|
+
)
|
|
86
|
+
splt.curly_vector_key(ax, cv, U=10.0, label="10 m s⁻¹")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Note: `skyborn.plot` in the `skyborn` package seamlessly re-exports `skybornplot`.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
BSD 3-Clause License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
skyborn_plot-0.1.0.dist-info/licenses/LICENSE,sha256=yT0Ziy1H6GMoR_iii8E4cg3h5knMQ_vBxJkUPrSdJrQ,1547
|
|
2
|
+
skybornplot/__init__.py,sha256=GogdWdvZoIsK8oF1om9pulUlvpWUmE4jQalVbqv_Awk,782
|
|
3
|
+
skybornplot/contour.py,sha256=8lewS-Jj12uEA8jCI9fRfc6IESwAb_tMeD51FM4Qiro,30219
|
|
4
|
+
skybornplot/plotting.py,sha256=xik_69q74w2vovScgylCK1rFqtSL8aeTDoQk8RUQXl4,14451
|
|
5
|
+
skybornplot/scatter.py,sha256=D2Bn7-zlPLbjzF_mjOlHW90FlCKF0xIhVaaJLMsXh3E,6927
|
|
6
|
+
skybornplot/vector.py,sha256=kX5YOc9zeOQDRWLECWJChu40fBpHR9wbhTv9kNNk7nk,49935
|
|
7
|
+
skybornplot/_adapters/__init__.py,sha256=uOJiP-MtHPNeMeaI0wiRvgqRMx8ub6KDqVFrg7IWnwk,79
|
|
8
|
+
skybornplot/_adapters/cartopy_vector.py,sha256=QO_wspCb2gEkCvFnqs2cavLb4TSeQbiSlAVSzlMT04o,4470
|
|
9
|
+
skybornplot/_adapters/curly_vector_entry.py,sha256=cs6JgpJxkEVoRwfN17WPQgYtJUOD2Sm3Y1abC6CY3Vo,11452
|
|
10
|
+
skybornplot/_adapters/dataset_vector.py,sha256=Cb4tZUoHOsVETh-wDHiE1mOn1vPKnV1HO559pqRSZVM,6782
|
|
11
|
+
skybornplot/_adapters/grid_prepare.py,sha256=-xlLv98z6NnhkRHLbB88KnrUrq64cWWXWoY2qk6Cbd0,7158
|
|
12
|
+
skybornplot/_artists/__init__.py,sha256=f52_phCOLFyvzeK0AHwCM71Rz_-RJWEeJI5pOfh6y1I,65
|
|
13
|
+
skybornplot/_artists/vector_artists.py,sha256=jHph0ubQkF0pkaM5jaDYTSFQtGrrVzleFNggVURKCSM,10824
|
|
14
|
+
skybornplot/_artists/vector_key_artist.py,sha256=bDcWPN7re3wzcMh76XoNrvYCfqiTI0RccTY-rzFQq9g,20433
|
|
15
|
+
skybornplot/_core/__init__.py,sha256=WN0UxleO0JcoOJ8bNx5p1h7kVWspWDkyZI0W0fmPcHw,62
|
|
16
|
+
skybornplot/_core/contour_arrows.py,sha256=4t0DjN30LnWIARUeH5U22XeYNV9csG7Z0X2u5Fpc0TA,25613
|
|
17
|
+
skybornplot/_core/contour_arrows_core.cp314-win_amd64.dll.a,sha256=shlBFZcFqsbmzPSOA4T6OjzaNXd0cR4ktG0PUE1ZOnA,1902
|
|
18
|
+
skybornplot/_core/contour_arrows_core.cp314-win_amd64.pyd,sha256=eLi0MFxK4qsszt_pwgv3s6rwX2RVlxK6fijqZ9uBozc,67976
|
|
19
|
+
skybornplot/_core/geometry.py,sha256=nk2I-0uCr5h1BkuqsAbqh52x804vjSQ7XqGra6vPSDA,9022
|
|
20
|
+
skybornplot/_core/legacy_stream.py,sha256=JczyyYI7YnzN7qwMJc4y_Reda-wdKwSfhSPMRIzuBFQ,4957
|
|
21
|
+
skybornplot/_core/native.py,sha256=GTYyBX4gYYq_5_1V2AQqqrxli99OxEq1Oy7QypREqWM,9052
|
|
22
|
+
skybornplot/_core/result.py,sha256=jMAvjFyxuzWfMq95nC27f24GnnVK88_V7iKiMiJgUes,3440
|
|
23
|
+
skybornplot/_core/scatter_engine.py,sha256=6zns9SXv_dszvIV_zCcjkrp2YRg32mjX4nWyItKATRE,19729
|
|
24
|
+
skybornplot/_core/thinning.py,sha256=TNhoUGJsgn6wJfcN94hbsZlHLKW_9l7at_0cErDreYg,4731
|
|
25
|
+
skybornplot/_core/vector_engine.py,sha256=BxZqihni1C1NU3ykjRL4B80l-9eyzOdEUMqzXy6DqYE,37976
|
|
26
|
+
skybornplot/_shared/__init__.py,sha256=gYO69JRW4inYxBpwj-a--ULVSL2uCUa5LO-Fmx0FqZw,61
|
|
27
|
+
skybornplot/_shared/axes.py,sha256=E7QZmLTET1RfxRhPldSwjH9gee7rfduCnjMzJQIEAG4,634
|
|
28
|
+
skybornplot/_shared/coords.py,sha256=2EkzlC6Dx2Lbl2F9umS8JSgM8DeHnFcGp3sYzFSjYX0,14008
|
|
29
|
+
skybornplot/_shared/style.py,sha256=LoVqqla7iJtyuVOHnIoZit91mQ_JvWQ8HW7gM5lNEaI,7378
|
|
30
|
+
skybornplot/_shared/types.py,sha256=ulyBJhcg2ZlDx3dm7Ql2hcDnv3a0J8ifL5HSA4g5B4c,261
|
|
31
|
+
skybornplot/contour_core/__init__.py,sha256=dxdrShCHKZ7W69-xiW1SfGD0HytxOUO32gNeyekFu_I,183
|
|
32
|
+
skybornplot/contour_core/_contour_core.cp314-win_amd64.dll.a,sha256=1JYhPB_tvFQWrqnzV-zZ4SVdmV-vdDa-v0-oOxEUsRw,1812
|
|
33
|
+
skybornplot/contour_core/_contour_core.cp314-win_amd64.pyd,sha256=AYwOt5bE58sOy_JM5k63AkgFXVeDRqHnCuYFfUA_Wz4,62119
|
|
34
|
+
skybornplot/nclcurly_core/__init__.py,sha256=F86Jhuv4Hv8xKiTDCIcHKBiSJuaqD-JcavNykESfhQ0,907
|
|
35
|
+
skybornplot/nclcurly_core/_ncl_curly_core.cp314-win_amd64.dll.a,sha256=AGT4S9zDJvpMOBuRzGcHHUHOP1xnQSLy_-CLi8G-bag,1842
|
|
36
|
+
skybornplot/nclcurly_core/_ncl_curly_core.cp314-win_amd64.pyd,sha256=Bf2E3zjf35jZVJnq4A8xUDf1_uLVoOP34UXjAgc-T2A,100859
|
|
37
|
+
skyborn_plot-0.1.0.dist-info/METADATA,sha256=-xJ79geeyw-b0Q-6pjG0BE_qLtvtAuJMtnDpHXUhvQE,3351
|
|
38
|
+
skyborn_plot-0.1.0.dist-info/WHEEL,sha256=GjNoWUKTwVqYOh-GAeOqmWs8K5Mlz_Ym2F39m91XU8Q,101
|
|
39
|
+
skyborn_plot-0.1.0.dist-info/top_level.txt,sha256=rbGSUzD3CFY4k20RalTl2wUTuTCgMxZZF4eX3I-LhNU,12
|
|
40
|
+
skyborn_plot-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Qianye Su
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the [copyright holder] nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
skybornplot
|
skybornplot/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Public Skyborn plotting API.
|
|
2
|
+
|
|
3
|
+
Author: Qianye Su <suqianye2000@gmail.com>
|
|
4
|
+
Copyright (c) 2025-2026 Qianye Su
|
|
5
|
+
Created: 2026-03-01 14:58:56
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .contour import arrow_contour, arrow_contour_clabel, shadow_contourf
|
|
9
|
+
from .plotting import (
|
|
10
|
+
GradientFillBetween,
|
|
11
|
+
add_centered_axes,
|
|
12
|
+
add_equal_axes,
|
|
13
|
+
createFigure,
|
|
14
|
+
gradient_fill_between,
|
|
15
|
+
)
|
|
16
|
+
from .scatter import scatter
|
|
17
|
+
from .vector import curly_vector, curly_vector_key
|
|
18
|
+
|
|
19
|
+
__version__ = "0.1.0"
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"__version__",
|
|
23
|
+
"GradientFillBetween",
|
|
24
|
+
"add_equal_axes",
|
|
25
|
+
"add_centered_axes",
|
|
26
|
+
"arrow_contour",
|
|
27
|
+
"arrow_contour_clabel",
|
|
28
|
+
"createFigure",
|
|
29
|
+
"curly_vector",
|
|
30
|
+
"curly_vector_key",
|
|
31
|
+
"gradient_fill_between",
|
|
32
|
+
"scatter",
|
|
33
|
+
"shadow_contourf",
|
|
34
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Adapter layers that sit between public plot facades and core rendering."""
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""Cartopy transform and projection-regridding helpers for Skyborn plots."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from .grid_prepare import (
|
|
8
|
+
_normalize_regrid_shape,
|
|
9
|
+
_prepare_source_vector_grid,
|
|
10
|
+
_wrap_periodic_grid_queries,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _default_cartopy_target_extent(ax, target_extent):
|
|
15
|
+
if target_extent is not None or not hasattr(ax, "get_extent"):
|
|
16
|
+
return target_extent
|
|
17
|
+
try:
|
|
18
|
+
return ax.get_extent(ax.projection)
|
|
19
|
+
except Exception:
|
|
20
|
+
return target_extent
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _build_projection_target_grid(target_proj, regrid_shape, target_extent):
|
|
24
|
+
if target_extent is None:
|
|
25
|
+
target_extent = target_proj.x_limits + target_proj.y_limits
|
|
26
|
+
nx, ny = _normalize_regrid_shape(regrid_shape)
|
|
27
|
+
x_target = np.linspace(float(target_extent[0]), float(target_extent[1]), nx)
|
|
28
|
+
y_target = np.linspace(float(target_extent[2]), float(target_extent[3]), ny)
|
|
29
|
+
return np.meshgrid(x_target, y_target)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _extract_regular_grid_from_regridded_vectors(
|
|
33
|
+
x_grid,
|
|
34
|
+
y_grid,
|
|
35
|
+
u_grid,
|
|
36
|
+
v_grid,
|
|
37
|
+
scalar_grids,
|
|
38
|
+
):
|
|
39
|
+
x_grid = np.asarray(x_grid)
|
|
40
|
+
y_grid = np.asarray(y_grid)
|
|
41
|
+
u_grid = np.asarray(u_grid)
|
|
42
|
+
v_grid = np.asarray(v_grid)
|
|
43
|
+
|
|
44
|
+
x_1d = np.asarray(x_grid[0, :], dtype=float)
|
|
45
|
+
y_1d = np.asarray(y_grid[:, 0], dtype=float)
|
|
46
|
+
scalar_grids = [np.asarray(s) for s in scalar_grids]
|
|
47
|
+
|
|
48
|
+
if x_1d.size > 1 and x_1d[0] > x_1d[-1]:
|
|
49
|
+
x_1d = x_1d[::-1]
|
|
50
|
+
u_grid = u_grid[:, ::-1]
|
|
51
|
+
v_grid = v_grid[:, ::-1]
|
|
52
|
+
scalar_grids = [s[:, ::-1] for s in scalar_grids]
|
|
53
|
+
|
|
54
|
+
if y_1d.size > 1 and y_1d[0] > y_1d[-1]:
|
|
55
|
+
y_1d = y_1d[::-1]
|
|
56
|
+
u_grid = u_grid[::-1, :]
|
|
57
|
+
v_grid = v_grid[::-1, :]
|
|
58
|
+
scalar_grids = [s[::-1, :] for s in scalar_grids]
|
|
59
|
+
|
|
60
|
+
return x_1d, y_1d, u_grid, v_grid, scalar_grids
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _regrid_cartopy_vectors(
|
|
64
|
+
src_crs,
|
|
65
|
+
target_proj,
|
|
66
|
+
regrid_shape,
|
|
67
|
+
x,
|
|
68
|
+
y,
|
|
69
|
+
u,
|
|
70
|
+
v,
|
|
71
|
+
*scalars,
|
|
72
|
+
target_extent=None,
|
|
73
|
+
):
|
|
74
|
+
try:
|
|
75
|
+
from scipy.interpolate import RegularGridInterpolator
|
|
76
|
+
except ImportError as err:
|
|
77
|
+
raise ImportError(
|
|
78
|
+
"scipy is required for Cartopy projection regridding support."
|
|
79
|
+
) from err
|
|
80
|
+
|
|
81
|
+
x_1d, y_1d, u, v, scalar_list = _prepare_source_vector_grid(
|
|
82
|
+
x, y, u, v, scalars=scalars
|
|
83
|
+
)
|
|
84
|
+
x_target, y_target = _build_projection_target_grid(
|
|
85
|
+
target_proj, regrid_shape, target_extent
|
|
86
|
+
)
|
|
87
|
+
source_points = src_crs.transform_points(target_proj, x_target, y_target)
|
|
88
|
+
x_source = source_points[..., 0]
|
|
89
|
+
y_source = source_points[..., 1]
|
|
90
|
+
valid = np.isfinite(x_source) & np.isfinite(y_source)
|
|
91
|
+
|
|
92
|
+
x_query = _wrap_periodic_grid_queries(x_source, x_1d)
|
|
93
|
+
sample_points = np.column_stack([y_source[valid], x_query[valid]])
|
|
94
|
+
|
|
95
|
+
u_interp = RegularGridInterpolator(
|
|
96
|
+
(y_1d, x_1d),
|
|
97
|
+
u,
|
|
98
|
+
method="linear",
|
|
99
|
+
bounds_error=False,
|
|
100
|
+
fill_value=np.nan,
|
|
101
|
+
)
|
|
102
|
+
v_interp = RegularGridInterpolator(
|
|
103
|
+
(y_1d, x_1d),
|
|
104
|
+
v,
|
|
105
|
+
method="linear",
|
|
106
|
+
bounds_error=False,
|
|
107
|
+
fill_value=np.nan,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
u_sampled = np.full(x_target.shape, np.nan, dtype=float)
|
|
111
|
+
v_sampled = np.full(y_target.shape, np.nan, dtype=float)
|
|
112
|
+
if np.any(valid):
|
|
113
|
+
u_sampled[valid] = u_interp(sample_points)
|
|
114
|
+
v_sampled[valid] = v_interp(sample_points)
|
|
115
|
+
|
|
116
|
+
valid_vectors = valid & np.isfinite(u_sampled) & np.isfinite(v_sampled)
|
|
117
|
+
u_target = np.full_like(u_sampled, np.nan)
|
|
118
|
+
v_target = np.full_like(v_sampled, np.nan)
|
|
119
|
+
if np.any(valid_vectors):
|
|
120
|
+
ut, vt = target_proj.transform_vectors(
|
|
121
|
+
src_crs,
|
|
122
|
+
x_source[valid_vectors],
|
|
123
|
+
y_source[valid_vectors],
|
|
124
|
+
u_sampled[valid_vectors],
|
|
125
|
+
v_sampled[valid_vectors],
|
|
126
|
+
)
|
|
127
|
+
u_target[valid_vectors] = ut
|
|
128
|
+
v_target[valid_vectors] = vt
|
|
129
|
+
|
|
130
|
+
scalar_targets = []
|
|
131
|
+
for scalar in scalar_list:
|
|
132
|
+
scalar_interp = RegularGridInterpolator(
|
|
133
|
+
(y_1d, x_1d),
|
|
134
|
+
scalar,
|
|
135
|
+
method="linear",
|
|
136
|
+
bounds_error=False,
|
|
137
|
+
fill_value=np.nan,
|
|
138
|
+
)
|
|
139
|
+
scalar_target = np.full(x_target.shape, np.nan, dtype=float)
|
|
140
|
+
if np.any(valid):
|
|
141
|
+
scalar_target[valid] = scalar_interp(sample_points)
|
|
142
|
+
scalar_targets.append(scalar_target)
|
|
143
|
+
|
|
144
|
+
return (x_target, y_target, u_target, v_target, *scalar_targets)
|