oafuncs 0.0.94__py2.py3-none-any.whl → 0.0.95__py2.py3-none-any.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.
- oafuncs/data_store/OAFuncs.png +0 -0
- oafuncs/oa_data.py +33 -5
- {oafuncs-0.0.94.dist-info → oafuncs-0.0.95.dist-info}/METADATA +5 -2
- {oafuncs-0.0.94.dist-info → oafuncs-0.0.95.dist-info}/RECORD +7 -7
- {oafuncs-0.0.94.dist-info → oafuncs-0.0.95.dist-info}/LICENSE.txt +0 -0
- {oafuncs-0.0.94.dist-info → oafuncs-0.0.95.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.94.dist-info → oafuncs-0.0.95.dist-info}/top_level.txt +0 -0
oafuncs/data_store/OAFuncs.png
CHANGED
Binary file
|
oafuncs/oa_data.py
CHANGED
@@ -18,10 +18,11 @@ import multiprocessing as mp
|
|
18
18
|
from concurrent.futures import ThreadPoolExecutor
|
19
19
|
|
20
20
|
import numpy as np
|
21
|
+
import xarray as xr
|
21
22
|
from scipy.interpolate import griddata
|
23
|
+
import salem
|
22
24
|
|
23
|
-
|
24
|
-
__all__ = ["interp_2d", "ensure_list"]
|
25
|
+
__all__ = ["interp_2d", "ensure_list", "mask_shapefile"]
|
25
26
|
|
26
27
|
|
27
28
|
def ensure_list(input_data):
|
@@ -44,7 +45,6 @@ def ensure_list(input_data):
|
|
44
45
|
return [str(input_data)]
|
45
46
|
|
46
47
|
|
47
|
-
|
48
48
|
def interp_2d(target_x, target_y, origin_x, origin_y, data, method="linear", parallel=True):
|
49
49
|
"""
|
50
50
|
Perform 2D interpolation on the last two dimensions of a multi-dimensional array.
|
@@ -87,6 +87,8 @@ def interp_2d(target_x, target_y, origin_x, origin_y, data, method="linear", par
|
|
87
87
|
raise ValueError("Shape of data does not match shape of origin_x or origin_y.")
|
88
88
|
|
89
89
|
# 创建网格和展平数据
|
90
|
+
target_x, target_y = np.array(target_x), np.array(target_y)
|
91
|
+
origin_x, origin_y = np.array(origin_x), np.array(origin_y)
|
90
92
|
target_points = np.column_stack((target_y.ravel(), target_x.ravel()))
|
91
93
|
origin_points = np.column_stack((origin_y.ravel(), origin_x.ravel()))
|
92
94
|
|
@@ -109,12 +111,38 @@ def interp_2d(target_x, target_y, origin_x, origin_y, data, method="linear", par
|
|
109
111
|
elif len(data.shape) == 4:
|
110
112
|
interpolated_data = np.stack([np.stack([interp_single(data[i, j], target_points, origin_points, method) for j in range(data.shape[1])]) for i in range(data.shape[0])])
|
111
113
|
|
112
|
-
return np.array(interpolated_data)
|
114
|
+
return np.squeeze(np.array(interpolated_data))
|
115
|
+
|
113
116
|
|
117
|
+
def mask_shapefile(data: np.ndarray, lons: np.ndarray, lats: np.ndarray, shapefile_path: str) -> xr.DataArray:
|
118
|
+
"""
|
119
|
+
Masks a 2D data array using a shapefile.
|
114
120
|
|
121
|
+
Parameters:
|
122
|
+
- data: 2D numpy array of data to be masked.
|
123
|
+
- lons: 1D numpy array of longitudes.
|
124
|
+
- lats: 1D numpy array of latitudes.
|
125
|
+
- shapefile_path: Path to the shapefile used for masking.
|
126
|
+
|
127
|
+
Returns:
|
128
|
+
- Masked xarray DataArray.
|
129
|
+
"""
|
130
|
+
"""
|
131
|
+
https://cloud.tencent.com/developer/article/1701896
|
132
|
+
"""
|
133
|
+
try:
|
134
|
+
# import geopandas as gpd
|
135
|
+
# shp_f = gpd.read_file(shapefile_path)
|
136
|
+
shp_f = salem.read_shapefile(shapefile_path)
|
137
|
+
data_da = xr.DataArray(data, coords=[("latitude", lats), ("longitude", lons)])
|
138
|
+
masked_data = data_da.salem.roi(shape=shp_f)
|
139
|
+
return masked_data
|
140
|
+
except Exception as e:
|
141
|
+
print(f"An error occurred: {e}")
|
142
|
+
return None
|
115
143
|
|
116
|
-
if __name__ == "__main__":
|
117
144
|
|
145
|
+
if __name__ == "__main__":
|
118
146
|
pass
|
119
147
|
""" import time
|
120
148
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.95
|
4
4
|
Summary: Oceanic and Atmospheric Functions
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -27,9 +27,12 @@ Requires-Dist: pathlib
|
|
27
27
|
Requires-Dist: requests
|
28
28
|
Requires-Dist: bs4
|
29
29
|
Requires-Dist: matplotlib
|
30
|
-
Requires-Dist: Cartopy
|
31
30
|
Requires-Dist: netCDF4
|
32
31
|
Requires-Dist: xlrd
|
32
|
+
Requires-Dist: geopandas
|
33
|
+
Requires-Dist: Cartopy
|
34
|
+
Requires-Dist: rasterio
|
35
|
+
Requires-Dist: salem
|
33
36
|
Dynamic: author
|
34
37
|
Dynamic: author-email
|
35
38
|
Dynamic: classifier
|
@@ -1,12 +1,12 @@
|
|
1
1
|
oafuncs/__init__.py,sha256=glcIlhQ9xSK4WtL58dq7Od2S3JPqsuEyhUQ-VWO8hOc,1426
|
2
2
|
oafuncs/oa_cmap.py,sha256=azVg9QR_IlG9lXCCXXVs1LS1kFci8yjxDmb_VA_TdTQ,7408
|
3
|
-
oafuncs/oa_data.py,sha256=
|
3
|
+
oafuncs/oa_data.py,sha256=Skhi70IY7T4lHd_eu3BxcSAfpXMH8SzUURR8gB7bj74,7679
|
4
4
|
oafuncs/oa_draw.py,sha256=QypQp4vJIrbAyFddEVxd9K9Q4d85PRYqYQi9xDUmSZw,11150
|
5
5
|
oafuncs/oa_file.py,sha256=EUL9osp7scZ3JTCwTUlKNfS1d_9xOsFrIkmFxzZAbdg,14233
|
6
6
|
oafuncs/oa_help.py,sha256=loyzTbjU_0VpSIBvAEUA_tqxG8MVsO0xFE_2hgQ3zMw,4188
|
7
7
|
oafuncs/oa_nc.py,sha256=pdc3vEI-5uFYnyzXHAIHNlyeci4MJkeWgKJwjHJ3olI,18343
|
8
8
|
oafuncs/oa_python.py,sha256=Q-6UGGw_dJff7Ef8i87fsLPoGeHV5jBzfb-7HP4THR0,4018
|
9
|
-
oafuncs/data_store/OAFuncs.png,sha256=
|
9
|
+
oafuncs/data_store/OAFuncs.png,sha256=Ekgwb6DNX_jNo3F7EIyIDWPZ0KUAFPEb2njzi_DcD3U,3439715
|
10
10
|
oafuncs/oa_down/User_Agent-list.txt,sha256=pazxSip8_lphEBOPHG902zmIBUg8sBKXgmqp_g6j_E4,661062
|
11
11
|
oafuncs/oa_down/__init__.py,sha256=kRX5eTUCbAiz3zTaQM1501paOYS_3fizDN4Pa0mtNUA,585
|
12
12
|
oafuncs/oa_down/hycom_3hourly.py,sha256=9ge6l8xMB-VBzCd1Fr4pIDZfUY_PbrBkWyvur0V27bs,64941
|
@@ -22,8 +22,8 @@ oafuncs/oa_sign/scientific.py,sha256=a4JxOBgm9vzNZKpJ_GQIQf7cokkraV5nh23HGbmTYKw
|
|
22
22
|
oafuncs/oa_tool/__init__.py,sha256=bNTy9abznDhg3k_Irx0YieXl37r-oDRMtTAxf57Stzs,487
|
23
23
|
oafuncs/oa_tool/email.py,sha256=4lJxV_KUzhxgLYfVwYTqp0qxRugD7fvsZkXDe5WkUKo,3052
|
24
24
|
oafuncs/oa_tool/parallel.py,sha256=kYbiIFDB7EoxasmXGSomaEDVUsg9Rfvdgbw93lBOY7o,3770
|
25
|
-
oafuncs-0.0.
|
26
|
-
oafuncs-0.0.
|
27
|
-
oafuncs-0.0.
|
28
|
-
oafuncs-0.0.
|
29
|
-
oafuncs-0.0.
|
25
|
+
oafuncs-0.0.95.dist-info/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
26
|
+
oafuncs-0.0.95.dist-info/METADATA,sha256=338EOy1HaTm46EOciOekPlYvoqta75nqX65vhvIQVFI,3618
|
27
|
+
oafuncs-0.0.95.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
28
|
+
oafuncs-0.0.95.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
29
|
+
oafuncs-0.0.95.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|