oafuncs 0.0.80__tar.gz → 0.0.81__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.80/oafuncs.egg-info → oafuncs-0.0.81}/PKG-INFO +1 -2
- oafuncs-0.0.81/oafuncs/__init__.py +44 -0
- oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_nc.py" → oafuncs-0.0.81/oafuncs/oa_nc.py +40 -5
- {oafuncs-0.0.80 → oafuncs-0.0.81/oafuncs.egg-info}/PKG-INFO +1 -2
- oafuncs-0.0.81/oafuncs.egg-info/SOURCES.txt +28 -0
- oafuncs-0.0.81/oafuncs.egg-info/top_level.txt +1 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/setup.py +2 -3
- oafuncs-0.0.80/oafuncs/__init__.py +0 -29
- oafuncs-0.0.80/oafuncs/oa_down/__init__.py +0 -20
- oafuncs-0.0.80/oafuncs/oa_down/hycom_3hourly.py +0 -1176
- oafuncs-0.0.80/oafuncs/oa_down/literature.py +0 -332
- oafuncs-0.0.80/oafuncs/oa_down/test_ua.py +0 -151
- oafuncs-0.0.80/oafuncs/oa_s/__init__.py +0 -23
- oafuncs-0.0.80/oafuncs/oa_s/oa_cmap.py +0 -163
- oafuncs-0.0.80/oafuncs/oa_s/oa_data.py +0 -187
- oafuncs-0.0.80/oafuncs/oa_s/oa_draw.py +0 -451
- oafuncs-0.0.80/oafuncs/oa_s/oa_file.py +0 -332
- oafuncs-0.0.80/oafuncs/oa_s/oa_help.py +0 -39
- oafuncs-0.0.80/oafuncs/oa_s/oa_nc.py +0 -410
- oafuncs-0.0.80/oafuncs/oa_s/oa_python.py +0 -107
- oafuncs-0.0.80/oafuncs/oa_sign/__init__.py +0 -21
- oafuncs-0.0.80/oafuncs/oa_sign/meteorological.py +0 -168
- oafuncs-0.0.80/oafuncs/oa_sign/ocean.py +0 -158
- oafuncs-0.0.80/oafuncs/oa_sign/scientific.py +0 -139
- oafuncs-0.0.80/oafuncs/oa_tool/__init__.py +0 -18
- oafuncs-0.0.80/oafuncs/oa_tool/email.py +0 -114
- oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/__init__.py" +0 -26
- oafuncs-0.0.80/oafuncs.egg-info/SOURCES.txt +0 -47
- oafuncs-0.0.80/oafuncs.egg-info/top_level.txt +0 -2
- {oafuncs-0.0.80 → oafuncs-0.0.81}/LICENSE.txt +0 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/MANIFEST.in +0 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/README.md +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_cmap.py" → /oafuncs-0.0.81/oafuncs/oa_cmap.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_data.py" → /oafuncs-0.0.81/oafuncs/oa_data.py +0 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/oafuncs/oa_down/User_Agent-list.txt +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_down/__init__.py" → /oafuncs-0.0.81/oafuncs/oa_down/__init__.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_down/hycom_3hourly.py" → /oafuncs-0.0.81/oafuncs/oa_down/hycom_3hourly.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_down/literature.py" → /oafuncs-0.0.81/oafuncs/oa_down/literature.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_down/test_ua.py" → /oafuncs-0.0.81/oafuncs/oa_down/test_ua.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_draw.py" → /oafuncs-0.0.81/oafuncs/oa_draw.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_file.py" → /oafuncs-0.0.81/oafuncs/oa_file.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_help.py" → /oafuncs-0.0.81/oafuncs/oa_help.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_python.py" → /oafuncs-0.0.81/oafuncs/oa_python.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_sign/__init__.py" → /oafuncs-0.0.81/oafuncs/oa_sign/__init__.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_sign/meteorological.py" → /oafuncs-0.0.81/oafuncs/oa_sign/meteorological.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_sign/ocean.py" → /oafuncs-0.0.81/oafuncs/oa_sign/ocean.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_sign/scientific.py" → /oafuncs-0.0.81/oafuncs/oa_sign/scientific.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_tool/__init__.py" → /oafuncs-0.0.81/oafuncs/oa_tool/__init__.py +0 -0
- /oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_tool/email.py" → /oafuncs-0.0.81/oafuncs/oa_tool/email.py +0 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/oafuncs.egg-info/dependency_links.txt +0 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/oafuncs.egg-info/requires.txt +0 -0
- {oafuncs-0.0.80 → oafuncs-0.0.81}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.81
|
4
4
|
Summary: My short description for my project.
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -13,7 +13,6 @@ Classifier: Programming Language :: Python :: 3.9
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
17
16
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
18
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
19
18
|
Requires-Python: >=3.9.0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# coding=utf-8
|
3
|
+
"""
|
4
|
+
Author: Liu Kun && 16031215@qq.com
|
5
|
+
Date: 2024-09-17 16:09:20
|
6
|
+
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
+
LastEditTime: 2024-12-13 12:31:06
|
8
|
+
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_s\\__init__.py
|
9
|
+
Description:
|
10
|
+
EditPlatform: vscode
|
11
|
+
ComputerInfo: XPS 15 9510
|
12
|
+
SystemInfo: Windows 11
|
13
|
+
Python Version: 3.12
|
14
|
+
"""
|
15
|
+
|
16
|
+
|
17
|
+
# 会导致OAFuncs直接导入所有函数,不符合模块化设计
|
18
|
+
# from oafuncs.oa_s.oa_cmap import *
|
19
|
+
# from oafuncs.oa_s.oa_data import *
|
20
|
+
# from oafuncs.oa_s.oa_draw import *
|
21
|
+
# from oafuncs.oa_s.oa_file import *
|
22
|
+
# from oafuncs.oa_s.oa_help import *
|
23
|
+
# from oafuncs.oa_s.oa_nc import *
|
24
|
+
# from oafuncs.oa_s.oa_python import *
|
25
|
+
|
26
|
+
# ------------------- 2024-12-13 12:31:06 -------------------
|
27
|
+
# path: My_Funcs/OAFuncs/oafuncs/
|
28
|
+
from .oa_cmap import *
|
29
|
+
from .oa_data import *
|
30
|
+
from .oa_draw import *
|
31
|
+
from .oa_file import *
|
32
|
+
from .oa_help import *
|
33
|
+
from .oa_nc import *
|
34
|
+
from .oa_python import *
|
35
|
+
# ------------------- 2024-12-13 12:31:06 -------------------
|
36
|
+
# path: My_Funcs/OAFuncs/oafuncs/oa_down/
|
37
|
+
from .oa_down import *
|
38
|
+
# ------------------- 2024-12-13 12:31:06 -------------------
|
39
|
+
# path: My_Funcs/OAFuncs/oafuncs/oa_sign/
|
40
|
+
from .oa_sign import *
|
41
|
+
# ------------------- 2024-12-13 12:31:06 -------------------
|
42
|
+
# path: My_Funcs/OAFuncs/oafuncs/oa_tool/
|
43
|
+
from .oa_tool import *
|
44
|
+
# ------------------- 2024-12-13 12:31:06 -------------------
|
oafuncs-0.0.80/oafuncs - /345/211/257/346/234/254/oa_nc.py" → oafuncs-0.0.81/oafuncs/oa_nc.py
RENAMED
@@ -82,15 +82,27 @@ def _numpy_to_nc_type(numpy_type):
|
|
82
82
|
return numpy_to_nc.get(str(numpy_type), "f4") # 默认使用 'float32'
|
83
83
|
|
84
84
|
|
85
|
-
def
|
85
|
+
def _calculate_scale_and_offset(data, n=16):
|
86
|
+
data_min, data_max = np.nanmin(data), np.nanmax(data)
|
87
|
+
scale_factor = (data_max - data_min) / (2 ** n - 1)
|
88
|
+
add_offset = data_min + 2 ** (n - 1) * scale_factor
|
89
|
+
# S = Q * scale_factor + add_offset
|
90
|
+
return scale_factor, add_offset
|
91
|
+
|
92
|
+
|
93
|
+
def write2nc(file, data, varname=None, coords=None, mode='w', scale_offset_switch=True, compile_switch=True):
|
86
94
|
"""
|
87
95
|
description: 写入数据到nc文件
|
96
|
+
|
88
97
|
参数:
|
89
98
|
file: 文件路径
|
90
99
|
data: 数据
|
91
100
|
varname: 变量名
|
92
101
|
coords: 坐标,字典,键为维度名称,值为坐标数据
|
93
102
|
mode: 写入模式,'w'为写入,'a'为追加
|
103
|
+
scale_offset_switch: 是否使用scale_factor和add_offset,默认为True
|
104
|
+
compile_switch: 是否使用压缩参数,默认为True
|
105
|
+
|
94
106
|
example: write2nc(r'test.nc', data, 'data', {'time': np.linspace(0, 120, 100), 'lev': np.linspace(0, 120, 50)}, 'a')
|
95
107
|
"""
|
96
108
|
# 判断mode是写入还是追加
|
@@ -115,8 +127,8 @@ def write2nc(file, data, varname=None, coords=None, mode='w'):
|
|
115
127
|
if complete:
|
116
128
|
return
|
117
129
|
|
118
|
-
|
119
|
-
kwargs = {"compression": 'zlib', "complevel":
|
130
|
+
kwargs = {'zlib': True, 'complevel': 4} # 压缩参数
|
131
|
+
# kwargs = {"compression": 'zlib', "complevel": 4} # 压缩参数
|
120
132
|
|
121
133
|
# 打开 NetCDF 文件
|
122
134
|
with nc.Dataset(file, mode, format="NETCDF4") as ncfile:
|
@@ -137,7 +149,10 @@ def write2nc(file, data, varname=None, coords=None, mode='w'):
|
|
137
149
|
if add_coords:
|
138
150
|
# 创建新坐标
|
139
151
|
ncfile.createDimension(dim, len(coord_data))
|
140
|
-
|
152
|
+
if compile_switch:
|
153
|
+
ncfile.createVariable(dim, _numpy_to_nc_type(coord_data.dtype), (dim,), **kwargs)
|
154
|
+
else:
|
155
|
+
ncfile.createVariable(dim, _numpy_to_nc_type(coord_data.dtype), (dim,))
|
141
156
|
ncfile.variables[dim][:] = np.array(coord_data)
|
142
157
|
|
143
158
|
if isinstance(coord_data, xr.DataArray):
|
@@ -161,7 +176,25 @@ def write2nc(file, data, varname=None, coords=None, mode='w'):
|
|
161
176
|
if add_var:
|
162
177
|
# 创建变量及其维度
|
163
178
|
dim_names = tuple(coords.keys()) # 使用coords传入的维度名称
|
164
|
-
|
179
|
+
if scale_offset_switch:
|
180
|
+
scale_factor, add_offset = _calculate_scale_and_offset(np.array(data))
|
181
|
+
_FillValue = -32767
|
182
|
+
missing_value = -32767
|
183
|
+
dtype = 'i2' # short类型
|
184
|
+
else:
|
185
|
+
dtype = _numpy_to_nc_type(data.dtype)
|
186
|
+
|
187
|
+
if compile_switch:
|
188
|
+
ncfile.createVariable(varname, dtype, dim_names, **kwargs)
|
189
|
+
else:
|
190
|
+
ncfile.createVariable(varname, dtype, dim_names)
|
191
|
+
|
192
|
+
if scale_offset_switch: # 需要在写入数据之前设置scale_factor和add_offset
|
193
|
+
ncfile.variables[varname].setncattr('scale_factor', scale_factor)
|
194
|
+
ncfile.variables[varname].setncattr('add_offset', add_offset)
|
195
|
+
ncfile.variables[varname].setncattr('_FillValue', _FillValue)
|
196
|
+
ncfile.variables[varname].setncattr('missing_value', missing_value)
|
197
|
+
|
165
198
|
# ncfile.createVariable('data', 'f4', ('time','lev'))
|
166
199
|
|
167
200
|
# 写入数据
|
@@ -175,6 +208,8 @@ def write2nc(file, data, varname=None, coords=None, mode='w'):
|
|
175
208
|
current_var = ncfile.variables[varname]
|
176
209
|
if data.attrs:
|
177
210
|
for key, value in data.attrs.items():
|
211
|
+
if key in ["scale_factor", "add_offset", "_FillValue", "missing_value"] and scale_offset_switch:
|
212
|
+
continue
|
178
213
|
current_var.setncattr(key, value)
|
179
214
|
|
180
215
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.81
|
4
4
|
Summary: My short description for my project.
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -13,7 +13,6 @@ Classifier: Programming Language :: Python :: 3.9
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
17
16
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
18
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
19
18
|
Requires-Python: >=3.9.0
|
@@ -0,0 +1,28 @@
|
|
1
|
+
LICENSE.txt
|
2
|
+
MANIFEST.in
|
3
|
+
README.md
|
4
|
+
setup.py
|
5
|
+
oafuncs/__init__.py
|
6
|
+
oafuncs/oa_cmap.py
|
7
|
+
oafuncs/oa_data.py
|
8
|
+
oafuncs/oa_draw.py
|
9
|
+
oafuncs/oa_file.py
|
10
|
+
oafuncs/oa_help.py
|
11
|
+
oafuncs/oa_nc.py
|
12
|
+
oafuncs/oa_python.py
|
13
|
+
oafuncs.egg-info/PKG-INFO
|
14
|
+
oafuncs.egg-info/SOURCES.txt
|
15
|
+
oafuncs.egg-info/dependency_links.txt
|
16
|
+
oafuncs.egg-info/requires.txt
|
17
|
+
oafuncs.egg-info/top_level.txt
|
18
|
+
oafuncs/oa_down/User_Agent-list.txt
|
19
|
+
oafuncs/oa_down/__init__.py
|
20
|
+
oafuncs/oa_down/hycom_3hourly.py
|
21
|
+
oafuncs/oa_down/literature.py
|
22
|
+
oafuncs/oa_down/test_ua.py
|
23
|
+
oafuncs/oa_sign/__init__.py
|
24
|
+
oafuncs/oa_sign/meteorological.py
|
25
|
+
oafuncs/oa_sign/ocean.py
|
26
|
+
oafuncs/oa_sign/scientific.py
|
27
|
+
oafuncs/oa_tool/__init__.py
|
28
|
+
oafuncs/oa_tool/email.py
|
@@ -0,0 +1 @@
|
|
1
|
+
oafuncs
|
@@ -18,7 +18,7 @@ URL = 'https://github.com/Industry-Pays/OAFuncs'
|
|
18
18
|
EMAIL = 'liukun0312@stu.ouc.edu.cn'
|
19
19
|
AUTHOR = 'Kun Liu'
|
20
20
|
REQUIRES_PYTHON = '>=3.9.0'
|
21
|
-
VERSION = '0.0.
|
21
|
+
VERSION = '0.0.81'
|
22
22
|
|
23
23
|
# What packages are required for this module to be executed?
|
24
24
|
REQUIRED = [
|
@@ -122,7 +122,7 @@ setup(
|
|
122
122
|
python_requires=REQUIRES_PYTHON,
|
123
123
|
url=URL,
|
124
124
|
packages=find_packages(
|
125
|
-
exclude=["
|
125
|
+
exclude=["oa_*", "oa_down", "oa_sign", "oa_tool"]),
|
126
126
|
# packages=find_packages(exclude=["nc", "file", "*.tests.*", "tests.*"]),
|
127
127
|
# If your package is a single module, use this instead of 'packages':
|
128
128
|
# py_modules=['mypackage'],
|
@@ -144,7 +144,6 @@ setup(
|
|
144
144
|
'Programming Language :: Python :: 3.10',
|
145
145
|
'Programming Language :: Python :: 3.11',
|
146
146
|
'Programming Language :: Python :: 3.12',
|
147
|
-
'Programming Language :: Python :: 3.13',
|
148
147
|
'Programming Language :: Python :: Implementation :: CPython',
|
149
148
|
'Programming Language :: Python :: Implementation :: PyPy'
|
150
149
|
],
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# coding=utf-8
|
3
|
-
"""
|
4
|
-
Author: Liu Kun && 16031215@qq.com
|
5
|
-
Date: 2024-09-17 16:09:20
|
6
|
-
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2024-12-13 10:56:43
|
8
|
-
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\__init__.py
|
9
|
-
Description:
|
10
|
-
EditPlatform: vscode
|
11
|
-
ComputerInfo: XPS 15 9510
|
12
|
-
SystemInfo: Windows 11
|
13
|
-
Python Version: 3.11
|
14
|
-
"""
|
15
|
-
|
16
|
-
# 会导致OAFuncs直接导入所有函数,不符合模块化设计
|
17
|
-
from oafuncs.oa_s import (
|
18
|
-
oa_cmap,
|
19
|
-
oa_data,
|
20
|
-
oa_draw,
|
21
|
-
oa_file,
|
22
|
-
oa_help,
|
23
|
-
oa_nc,
|
24
|
-
oa_python,
|
25
|
-
)
|
26
|
-
|
27
|
-
from .oa_down import *
|
28
|
-
from .oa_sign import *
|
29
|
-
from .oa_tool import *
|
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# coding=utf-8
|
3
|
-
'''
|
4
|
-
Author: Liu Kun && 16031215@qq.com
|
5
|
-
Date: 2024-09-17 16:09:20
|
6
|
-
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2024-12-01 19:49:40
|
8
|
-
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_down\\__init__.py
|
9
|
-
Description:
|
10
|
-
EditPlatform: vscode
|
11
|
-
ComputerInfo: XPS 15 9510
|
12
|
-
SystemInfo: Windows 11
|
13
|
-
Python Version: 3.11
|
14
|
-
'''
|
15
|
-
|
16
|
-
# from .love_ocean import sign as love_ocean
|
17
|
-
# from .meteorological_home import sign as meteorological_home
|
18
|
-
|
19
|
-
from .hycom_3hourly import *
|
20
|
-
from .literature import *
|