oafuncs 0.0.59__tar.gz → 0.0.61__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.
- {oafuncs-0.0.59 → oafuncs-0.0.61}/PKG-INFO +4 -4
- {oafuncs-0.0.59 → oafuncs-0.0.61}/README.md +2 -2
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_cmap.py +8 -14
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_data.py +23 -41
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_down/hycom_3hourly.py +57 -118
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_down/refs_pdf.py +14 -25
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_draw.py +23 -47
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_file.py +34 -35
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_help.py +6 -7
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_nc.py +18 -34
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_python.py +6 -5
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_sign/meteorological.py +7 -14
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_sign/ocean.py +7 -12
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs.egg-info/PKG-INFO +4 -4
- {oafuncs-0.0.59 → oafuncs-0.0.61}/setup.py +2 -2
- {oafuncs-0.0.59 → oafuncs-0.0.61}/LICENSE.txt +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/__init__.py +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_down/__init__.py +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_sign/__init__.py +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_sign/scientific.py +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_tool/__init__.py +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs/oa_tool/email.py +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs.egg-info/SOURCES.txt +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs.egg-info/dependency_links.txt +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs.egg-info/requires.txt +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/oafuncs.egg-info/top_level.txt +0 -0
- {oafuncs-0.0.59 → oafuncs-0.0.61}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.61
|
4
4
|
Summary: My short description for my project.
|
5
|
-
Home-page: https://github.com/Industry-Pays/
|
5
|
+
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
7
7
|
Author-email: liukun0312@stu.ouc.edu.cn
|
8
8
|
License: MIT
|
@@ -48,12 +48,12 @@ Python Function
|
|
48
48
|
|
49
49
|
<mark>注</mark>:若有需求,可邮件至`liukun0312@stu.ouc.edu.cn`,能力范围内可考虑实现
|
50
50
|
|
51
|
-
**精力有限,部分函数使用说明文档未能及时更新/添加,可参考`结构`部分简述,再使用`
|
51
|
+
**精力有限,部分函数使用说明文档未能及时更新/添加,可参考`结构`部分简述,再使用`oafuncs.oa_help.use('func_name')`函数调取函数本身说明**
|
52
52
|
|
53
53
|
## PyPI
|
54
54
|
|
55
55
|
```html
|
56
|
-
https://pypi.org/project/
|
56
|
+
https://pypi.org/project/oafuncs
|
57
57
|
```
|
58
58
|
|
59
59
|
## Github
|
@@ -14,12 +14,12 @@ Python Function
|
|
14
14
|
|
15
15
|
<mark>注</mark>:若有需求,可邮件至`liukun0312@stu.ouc.edu.cn`,能力范围内可考虑实现
|
16
16
|
|
17
|
-
**精力有限,部分函数使用说明文档未能及时更新/添加,可参考`结构`部分简述,再使用`
|
17
|
+
**精力有限,部分函数使用说明文档未能及时更新/添加,可参考`结构`部分简述,再使用`oafuncs.oa_help.use('func_name')`函数调取函数本身说明**
|
18
18
|
|
19
19
|
## PyPI
|
20
20
|
|
21
21
|
```html
|
22
|
-
https://pypi.org/project/
|
22
|
+
https://pypi.org/project/oafuncs
|
23
23
|
```
|
24
24
|
|
25
25
|
## Github
|
@@ -4,8 +4,8 @@
|
|
4
4
|
Author: Liu Kun && 16031215@qq.com
|
5
5
|
Date: 2024-09-17 16:55:11
|
6
6
|
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2024-
|
8
|
-
FilePath: \\Python\\My_Funcs\\OAFuncs\\
|
7
|
+
LastEditTime: 2024-11-21 13:14:24
|
8
|
+
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_cmap.py
|
9
9
|
Description:
|
10
10
|
EditPlatform: vscode
|
11
11
|
ComputerInfo: XPS 15 9510
|
@@ -18,8 +18,7 @@ import matplotlib as mpl
|
|
18
18
|
import matplotlib.pyplot as plt
|
19
19
|
import numpy as np
|
20
20
|
|
21
|
-
__all__ = ['show', 'extract_colors', 'create_custom',
|
22
|
-
'create_diverging', 'create_5rgb_txt']
|
21
|
+
__all__ = ['show', 'extract_colors', 'create_custom', 'create_diverging', 'create_5rgb_txt']
|
23
22
|
|
24
23
|
# ** 将cmap用填色图可视化(官网摘抄函数)
|
25
24
|
|
@@ -34,8 +33,7 @@ def show(colormaps: list):
|
|
34
33
|
np.random.seed(19680801)
|
35
34
|
data = np.random.randn(30, 30)
|
36
35
|
n = len(colormaps)
|
37
|
-
fig, axs = plt.subplots(1, n, figsize=(n * 2 + 2, 3),
|
38
|
-
constrained_layout=True, squeeze=False)
|
36
|
+
fig, axs = plt.subplots(1, n, figsize=(n * 2 + 2, 3), constrained_layout=True, squeeze=False)
|
39
37
|
for [ax, cmap] in zip(axs.flat, colormaps):
|
40
38
|
psm = ax.pcolormesh(data, cmap=cmap, rasterized=True, vmin=-4, vmax=4)
|
41
39
|
fig.colorbar(psm, ax=ax)
|
@@ -67,11 +65,9 @@ def create_custom(colors: list, nodes=None): # 利用颜色快速配色
|
|
67
65
|
c_map = mk_cmap(['aliceblue','skyblue','deepskyblue'],[0.0,0.5,1.0])
|
68
66
|
'''
|
69
67
|
if nodes is None: # 采取自动分配比例
|
70
|
-
cmap_color = mpl.colors.LinearSegmentedColormap.from_list(
|
71
|
-
'mycmap', colors)
|
68
|
+
cmap_color = mpl.colors.LinearSegmentedColormap.from_list('mycmap', colors)
|
72
69
|
else: # 按照提供比例分配
|
73
|
-
cmap_color = mpl.colors.LinearSegmentedColormap.from_list(
|
74
|
-
"mycmap", list(zip(nodes, colors)))
|
70
|
+
cmap_color = mpl.colors.LinearSegmentedColormap.from_list("mycmap", list(zip(nodes, colors)))
|
75
71
|
return cmap_color
|
76
72
|
|
77
73
|
# ** 自制diverging型cmap,默认中间为白色
|
@@ -91,8 +87,7 @@ def create_diverging(colors: list):
|
|
91
87
|
newcolors = colors
|
92
88
|
if n % 2 == 0:
|
93
89
|
newcolors.insert(int(n / 2), '#ffffff') # 偶数个颜色,中间为白色
|
94
|
-
cmap_color = mpl.colors.LinearSegmentedColormap.from_list(
|
95
|
-
"mycmap", list(zip(nodes, newcolors)))
|
90
|
+
cmap_color = mpl.colors.LinearSegmentedColormap.from_list("mycmap", list(zip(nodes, newcolors)))
|
96
91
|
return cmap_color
|
97
92
|
|
98
93
|
# ** 根据RGB的txt文档制作色卡(利用Grads调色盘)
|
@@ -129,8 +124,7 @@ if __name__ == '__main__':
|
|
129
124
|
show([c_map])
|
130
125
|
|
131
126
|
# ** 测试自制diverging型cmap
|
132
|
-
diverging_cmap = create_diverging(["#4e00b3", "#0000FF", "#00c0ff",
|
133
|
-
"#a1d3ff", "#DCDCDC", "#FFD39B", "#FF8247", "#FF0000", "#FF5F9E"])
|
127
|
+
diverging_cmap = create_diverging(["#4e00b3", "#0000FF", "#00c0ff", "#a1d3ff", "#DCDCDC", "#FFD39B", "#FF8247", "#FF0000", "#FF5F9E"])
|
134
128
|
show([diverging_cmap])
|
135
129
|
|
136
130
|
# ** 测试根据RGB的txt文档制作色卡
|
@@ -4,8 +4,8 @@
|
|
4
4
|
Author: Liu Kun && 16031215@qq.com
|
5
5
|
Date: 2024-09-17 17:12:47
|
6
6
|
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2024-
|
8
|
-
FilePath: \\Python\\My_Funcs\\OAFuncs\\
|
7
|
+
LastEditTime: 2024-11-21 13:13:20
|
8
|
+
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_data.py
|
9
9
|
Description:
|
10
10
|
EditPlatform: vscode
|
11
11
|
ComputerInfo: XPS 15 9510
|
@@ -14,7 +14,6 @@ Python Version: 3.11
|
|
14
14
|
'''
|
15
15
|
|
16
16
|
|
17
|
-
|
18
17
|
import multiprocessing as mp
|
19
18
|
from concurrent.futures import ThreadPoolExecutor
|
20
19
|
|
@@ -24,6 +23,8 @@ from scipy.interpolate import griddata
|
|
24
23
|
__all__ = ['interp_2d', 'interp_2d_parallel']
|
25
24
|
|
26
25
|
# ** 高维插值函数,插值最后两个维度
|
26
|
+
|
27
|
+
|
27
28
|
def interp_2d(target_x, target_y, origin_x, origin_y, data, method='linear'):
|
28
29
|
"""
|
29
30
|
高维插值函数,默认插值最后两个维度,传输数据前请确保数据的维度正确
|
@@ -51,8 +52,7 @@ def interp_2d(target_x, target_y, origin_x, origin_y, data, method='linear'):
|
|
51
52
|
|
52
53
|
if origin_x.shape != dims[-2:] or origin_y.shape != dims[-2:]:
|
53
54
|
print(origin_x.shape, dims[-2:])
|
54
|
-
raise ValueError(
|
55
|
-
'Shape of data does not match shape of origin_x or origin_y.')
|
55
|
+
raise ValueError('Shape of data does not match shape of origin_x or origin_y.')
|
56
56
|
|
57
57
|
# 将目标网格展平成一维数组
|
58
58
|
target_points = np.column_stack((np.ravel(target_y), np.ravel(target_x)))
|
@@ -62,14 +62,12 @@ def interp_2d(target_x, target_y, origin_x, origin_y, data, method='linear'):
|
|
62
62
|
|
63
63
|
# 进行插值
|
64
64
|
if len_dims == 2:
|
65
|
-
interpolated_data = griddata(origin_points, np.ravel(
|
66
|
-
data), target_points, method=method)
|
65
|
+
interpolated_data = griddata(origin_points, np.ravel(data), target_points, method=method)
|
67
66
|
interpolated_data = np.reshape(interpolated_data, target_y.shape)
|
68
67
|
elif len_dims == 3:
|
69
68
|
interpolated_data = []
|
70
69
|
for i in range(dims[0]):
|
71
|
-
dt = griddata(origin_points, np.ravel(
|
72
|
-
data[i, :, :]), target_points, method=method)
|
70
|
+
dt = griddata(origin_points, np.ravel(data[i, :, :]), target_points, method=method)
|
73
71
|
interpolated_data.append(np.reshape(dt, target_y.shape))
|
74
72
|
print(f'Interpolating {i+1}/{dims[0]}...')
|
75
73
|
interpolated_data = np.array(interpolated_data)
|
@@ -78,11 +76,9 @@ def interp_2d(target_x, target_y, origin_x, origin_y, data, method='linear'):
|
|
78
76
|
for i in range(dims[0]):
|
79
77
|
interpolated_data.append([])
|
80
78
|
for j in range(dims[1]):
|
81
|
-
dt = griddata(origin_points, np.ravel(
|
82
|
-
data[i, j, :, :]), target_points, method=method)
|
79
|
+
dt = griddata(origin_points, np.ravel(data[i, j, :, :]), target_points, method=method)
|
83
80
|
interpolated_data[i].append(np.reshape(dt, target_y.shape))
|
84
|
-
print(
|
85
|
-
f'\rInterpolating {i*dims[1]+j+1}/{dims[0]*dims[1]}...', end='')
|
81
|
+
print(f'\rInterpolating {i*dims[1]+j+1}/{dims[0]*dims[1]}...', end='')
|
86
82
|
print('\n')
|
87
83
|
interpolated_data = np.array(interpolated_data)
|
88
84
|
|
@@ -104,33 +100,24 @@ def interp_2d_parallel(target_x, target_y, origin_x, origin_y, data, method='lin
|
|
104
100
|
example : interpolated_data = interp_2d_parallel(target_x, target_y, origin_x, origin_y, data, method='linear')
|
105
101
|
'''
|
106
102
|
def interp_single2d(target_y, target_x, origin_y, origin_x, data, method='linear'):
|
107
|
-
target_points = np.column_stack(
|
108
|
-
|
109
|
-
origin_points = np.column_stack(
|
110
|
-
(np.ravel(origin_y), np.ravel(origin_x)))
|
103
|
+
target_points = np.column_stack((np.ravel(target_y), np.ravel(target_x)))
|
104
|
+
origin_points = np.column_stack((np.ravel(origin_y), np.ravel(origin_x)))
|
111
105
|
|
112
|
-
dt = griddata(origin_points, np.ravel(
|
113
|
-
data[:, :]), target_points, method=method)
|
106
|
+
dt = griddata(origin_points, np.ravel(data[:, :]), target_points, method=method)
|
114
107
|
return np.reshape(dt, target_y.shape)
|
115
108
|
|
116
109
|
def interp_single3d(i, target_y, target_x, origin_y, origin_x, data, method='linear'):
|
117
|
-
target_points = np.column_stack(
|
118
|
-
|
119
|
-
origin_points = np.column_stack(
|
120
|
-
(np.ravel(origin_y), np.ravel(origin_x)))
|
110
|
+
target_points = np.column_stack((np.ravel(target_y), np.ravel(target_x)))
|
111
|
+
origin_points = np.column_stack((np.ravel(origin_y), np.ravel(origin_x)))
|
121
112
|
|
122
|
-
dt = griddata(origin_points, np.ravel(
|
123
|
-
data[i, :, :]), target_points, method=method)
|
113
|
+
dt = griddata(origin_points, np.ravel(data[i, :, :]), target_points, method=method)
|
124
114
|
return np.reshape(dt, target_y.shape)
|
125
115
|
|
126
116
|
def interp_single4d(i, j, target_y, target_x, origin_y, origin_x, data, method='linear'):
|
127
|
-
target_points = np.column_stack(
|
128
|
-
|
129
|
-
origin_points = np.column_stack(
|
130
|
-
(np.ravel(origin_y), np.ravel(origin_x)))
|
117
|
+
target_points = np.column_stack((np.ravel(target_y), np.ravel(target_x)))
|
118
|
+
origin_points = np.column_stack((np.ravel(origin_y), np.ravel(origin_x)))
|
131
119
|
|
132
|
-
dt = griddata(origin_points, np.ravel(
|
133
|
-
data[i, j, :, :]), target_points, method=method)
|
120
|
+
dt = griddata(origin_points, np.ravel(data[i, j, :, :]), target_points, method=method)
|
134
121
|
return np.reshape(dt, target_y.shape)
|
135
122
|
|
136
123
|
if len(target_y.shape) == 1:
|
@@ -150,16 +137,12 @@ def interp_2d_parallel(target_x, target_y, origin_x, origin_y, data, method='lin
|
|
150
137
|
with ThreadPoolExecutor(max_workers=mp.cpu_count()-2) as executor:
|
151
138
|
print(f'Using {mp.cpu_count()-2} threads...')
|
152
139
|
if len_dims == 2:
|
153
|
-
interpolated_data = list(executor.map(interp_single2d, [target_y], [
|
154
|
-
target_x], [origin_y], [origin_x], [data], [method]))
|
140
|
+
interpolated_data = list(executor.map(interp_single2d, [target_y], [target_x], [origin_y], [origin_x], [data], [method]))
|
155
141
|
elif len_dims == 3:
|
156
|
-
interpolated_data = list(executor.map(interp_single3d, [i for i in range(dims[0])], [
|
157
|
-
target_y]*dims[0], [target_x]*dims[0], [origin_y]*dims[0], [origin_x]*dims[0], [data]*dims[0], [method]*dims[0]))
|
142
|
+
interpolated_data = list(executor.map(interp_single3d, [i for i in range(dims[0])], [target_y]*dims[0], [target_x]*dims[0], [origin_y]*dims[0], [origin_x]*dims[0], [data]*dims[0], [method]*dims[0]))
|
158
143
|
elif len_dims == 4:
|
159
|
-
interpolated_data = list(executor.map(interp_single4d, [i for i in range(dims[0]) for j in range(dims[1])], [j for i in range(dims[0]) for j in range(dims[1])], [
|
160
|
-
|
161
|
-
interpolated_data = np.array(interpolated_data).reshape(
|
162
|
-
dims[0], dims[1], target_y.shape[0], target_x.shape[1])
|
144
|
+
interpolated_data = list(executor.map(interp_single4d, [i for i in range(dims[0]) for j in range(dims[1])], [j for i in range(dims[0]) for j in range(dims[1])], [target_y]*dims[0]*dims[1], [target_x]*dims[0]*dims[1], [origin_y]*dims[0]*dims[1], [origin_x]*dims[0]*dims[1], [data]*dims[0]*dims[1], [method]*dims[0]*dims[1]))
|
145
|
+
interpolated_data = np.array(interpolated_data).reshape(dims[0], dims[1], target_y.shape[0], target_x.shape[1])
|
163
146
|
|
164
147
|
interpolated_data = np.array(interpolated_data)
|
165
148
|
|
@@ -193,8 +176,7 @@ if __name__ == '__main__':
|
|
193
176
|
|
194
177
|
# 高维插值多线程
|
195
178
|
start = time.time()
|
196
|
-
interpolated_data = interp_2d_parallel(
|
197
|
-
target_x, target_y, origin_x, origin_y, data)
|
179
|
+
interpolated_data = interp_2d_parallel(target_x, target_y, origin_x, origin_y, data)
|
198
180
|
print(f'Interpolation time: {time.time()-start:.2f}s')
|
199
181
|
|
200
182
|
print(interpolated_data.shape)
|