oafuncs 0.0.98.38__py3-none-any.whl → 0.0.98.39__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/oa_cmap.py +1 -0
- oafuncs/oa_draw.py +40 -50
- {oafuncs-0.0.98.38.dist-info → oafuncs-0.0.98.39.dist-info}/METADATA +1 -1
- {oafuncs-0.0.98.38.dist-info → oafuncs-0.0.98.39.dist-info}/RECORD +7 -7
- {oafuncs-0.0.98.38.dist-info → oafuncs-0.0.98.39.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.98.38.dist-info → oafuncs-0.0.98.39.dist-info}/licenses/LICENSE.txt +0 -0
- {oafuncs-0.0.98.38.dist-info → oafuncs-0.0.98.39.dist-info}/top_level.txt +0 -0
oafuncs/oa_cmap.py
CHANGED
oafuncs/oa_draw.py
CHANGED
@@ -6,7 +6,7 @@ import matplotlib.pyplot as plt
|
|
6
6
|
import numpy as np
|
7
7
|
from rich import print
|
8
8
|
|
9
|
-
__all__ = ["fig_minus", "gif", "movie", "setup_map", "
|
9
|
+
__all__ = ["fig_minus", "gif", "movie", "setup_map", "ticks_symmetric"]
|
10
10
|
|
11
11
|
warnings.filterwarnings("ignore")
|
12
12
|
|
@@ -314,57 +314,47 @@ def setup_map(
|
|
314
314
|
return axes
|
315
315
|
|
316
316
|
|
317
|
-
|
318
|
-
"""Custom normalization class to center a specific value.
|
319
|
-
|
320
|
-
Args:
|
321
|
-
vmin (float, optional): Minimum data value. Defaults to None.
|
322
|
-
vmax (float, optional): Maximum data value. Defaults to None.
|
323
|
-
vcenter (float, optional): Center value for normalization. Defaults to 0.
|
324
|
-
clip (bool, optional): Whether to clip data outside the range. Defaults to False.
|
325
|
-
|
326
|
-
Example:
|
327
|
-
>>> norm = MidpointNormalize(vmin=-2, vmax=1, vcenter=0)
|
317
|
+
def ticks_symmetric(vmin: float, vcenter: float, vmax: float, num: int = 7) -> np.ndarray:
|
328
318
|
"""
|
329
|
-
|
330
|
-
def __init__(self, vmin: float = None, vmax: float = None, vcenter: float = 0, clip: bool = False) -> None:
|
331
|
-
self.vcenter = vcenter
|
332
|
-
super().__init__(vmin, vmax, clip)
|
333
|
-
|
334
|
-
def __call__(self, value: np.ndarray, clip: bool = None) -> np.ma.MaskedArray:
|
335
|
-
# Use the clip parameter from initialization if not provided
|
336
|
-
if clip is None:
|
337
|
-
clip = self.clip
|
338
|
-
|
339
|
-
x, y = [self.vmin, self.vcenter, self.vmax], [0, 0.5, 1.0]
|
340
|
-
result = np.interp(value, x, y)
|
341
|
-
|
342
|
-
# Apply clipping if requested
|
343
|
-
if clip:
|
344
|
-
result = np.clip(result, 0, 1)
|
345
|
-
|
346
|
-
return np.ma.masked_array(result)
|
319
|
+
生成以指定中心点对称分布的刻度值
|
347
320
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
321
|
+
参数:
|
322
|
+
vmin (float): 最小值
|
323
|
+
vcenter (float): 中心值
|
324
|
+
vmax (float): 最大值
|
325
|
+
num (int, optional): 期望的刻度数量(必须是奇数)。默认为7
|
326
|
+
|
327
|
+
返回:
|
328
|
+
np.ndarray: 对称分布的刻度值数组
|
329
|
+
|
330
|
+
异常:
|
331
|
+
ValueError: 如果输入值无效
|
332
|
+
|
333
|
+
示例:
|
334
|
+
>>> ticks_symmetric(vmin=-10, vcenter=0, vmax=10, num=5)
|
335
|
+
array([-10., -5., 0., 5., 10.])
|
336
|
+
"""
|
337
|
+
# 验证输入参数
|
338
|
+
if vmin >= vcenter:
|
339
|
+
raise ValueError(f"vmin ({vmin}) must be less than vcenter ({vcenter})")
|
340
|
+
if vcenter >= vmax:
|
341
|
+
raise ValueError(f"vcenter ({vcenter}) must be less than vmax ({vmax})")
|
342
|
+
|
343
|
+
# 确保刻度数量是奇数
|
344
|
+
if num % 2 == 0:
|
345
|
+
num += 1
|
346
|
+
|
347
|
+
# 计算每侧的点数(包括中心点)
|
348
|
+
side_points = (num - 1) // 2 + 1
|
349
|
+
|
350
|
+
# 生成左侧刻度(从最小值到中心值)
|
351
|
+
left_ticks = np.linspace(vmin, vcenter, side_points)[:-1]
|
352
|
+
|
353
|
+
# 生成右侧刻度(从中心值到最大值)
|
354
|
+
right_ticks = np.linspace(vcenter, vmax, side_points)[1:]
|
355
|
+
|
356
|
+
# 组合所有刻度
|
357
|
+
return np.concatenate([left_ticks, [vcenter], right_ticks])
|
368
358
|
|
369
359
|
|
370
360
|
if __name__ == "__main__":
|
@@ -1,8 +1,8 @@
|
|
1
1
|
oafuncs/__init__.py,sha256=T_-VtnWWllV3Q91twT5Yt2sUapeA051QbPNnBxmg9nw,1456
|
2
|
-
oafuncs/oa_cmap.py,sha256=
|
2
|
+
oafuncs/oa_cmap.py,sha256=JwZMJ36uNwiCnzXqEtH2_PpeLtEaRaXP9YeGSl0PJSU,13886
|
3
3
|
oafuncs/oa_data.py,sha256=u4H1ZazQf2jmGx3IAiaGxLjQHY9cQEMizRIaTQW4UiE,8075
|
4
4
|
oafuncs/oa_date.py,sha256=aU2wVIWXyWoRiSQ9dg8sHvShFTxw86RrgbV3Q6tDjD4,6841
|
5
|
-
oafuncs/oa_draw.py,sha256=
|
5
|
+
oafuncs/oa_draw.py,sha256=zxwxmTsS6-s6YFvrVJTr06_O39y0ykVxtOrShgDM4Qg,13754
|
6
6
|
oafuncs/oa_file.py,sha256=fLb0gRhq2AiPl-5ASDHMrx6Z267FmhqNcTV7CdCxTdI,16934
|
7
7
|
oafuncs/oa_help.py,sha256=0J5VaZX-cB0c090KxgmktQJBc0o00FsY-4wB8l5y00k,4178
|
8
8
|
oafuncs/oa_nc.py,sha256=mKNxQ9jPxfRH7xINyrX7tBhitG5gmOKm6Dn7stk5mdw,15279
|
@@ -37,8 +37,8 @@ oafuncs/oa_sign/__init__.py,sha256=JSx1fcWpmNhQBvX_Bmq3xysfSkkFMrjbJASxV_V6aqE,1
|
|
37
37
|
oafuncs/oa_sign/meteorological.py,sha256=3MSjy7HTcvz2zsITkjUMr_0Y027Gas1LFE9pk99990k,6110
|
38
38
|
oafuncs/oa_sign/ocean.py,sha256=3uYEzaq-27yVy23IQoqy-clhWu1I_fhPFBAQyT-OF4M,5562
|
39
39
|
oafuncs/oa_sign/scientific.py,sha256=moIl2MEY4uitbXoD596JmXookXGQtQsS-8_1NBBTx84,4689
|
40
|
-
oafuncs-0.0.98.
|
41
|
-
oafuncs-0.0.98.
|
42
|
-
oafuncs-0.0.98.
|
43
|
-
oafuncs-0.0.98.
|
44
|
-
oafuncs-0.0.98.
|
40
|
+
oafuncs-0.0.98.39.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
41
|
+
oafuncs-0.0.98.39.dist-info/METADATA,sha256=2hppaUc6XZv609HGI_ZRS8GRPARn1Q9MI8xgb4JBfhs,4326
|
42
|
+
oafuncs-0.0.98.39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
43
|
+
oafuncs-0.0.98.39.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
44
|
+
oafuncs-0.0.98.39.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|