shancx 1.60__tar.gz → 1.70__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shancx
3
- Version: 1.60
3
+ Version: 1.70
4
4
  Summary: A simple timer decorator
5
5
  Home-page: https://gitee.com/shancx
6
6
  Author: Your Name
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
 
5
5
  setup(
6
6
  name='shancx',
7
- version='1.60',
7
+ version='1.70',
8
8
  packages=find_packages(),
9
9
  description='A simple timer decorator',
10
10
  long_description=open('README.md').read(),
@@ -19,3 +19,4 @@ setup(
19
19
  ],
20
20
  python_requires='>=3.6',
21
21
  )
22
+
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ # @Time : 2023/09/27 下午8:52
4
+ # @Author : shanchangxi
5
+ # @File : util_log.py
6
+ import time
7
+ import logging # 引入logging模块
8
+ from logging import handlers
9
+ # from util.util_dir import *
10
+
11
+ # 第一步,创建一个logger
12
+ loggers = logging.getLogger()
13
+ loggers.setLevel(logging.INFO) # Log等级开关
14
+
15
+ # 第二步,创建一个handler,用于写入日志文件
16
+ log_name = 'project_tim_tor.log'
17
+ logfile = log_name
18
+
19
+ time_rotating_file_handler = handlers.TimedRotatingFileHandler(filename=logfile, when='D', encoding='utf-8')
20
+ time_rotating_file_handler.setLevel(logging.INFO) # 输出到file的log等级的开关
21
+
22
+ # 第三步,定义handler的输出格式
23
+ formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s")
24
+ time_rotating_file_handler.setFormatter(formatter)
25
+
26
+ # 第四步,将handler添加到logger里面
27
+ loggers.addHandler(time_rotating_file_handler)
28
+
29
+ # 如果需要同時需要在終端上輸出,定義一個streamHandler
30
+ print_handler = logging.StreamHandler() # 往屏幕上输出
31
+ print_handler.setFormatter(formatter) # 设置屏幕上显示的格式
32
+ loggers.addHandler(print_handler)
33
+
34
+
35
+ def Tim_Tor(func):
36
+ def wrapper(*args, **kwargs):
37
+ start_time = time.time()
38
+ result = func(*args, **kwargs)
39
+ end_time = time.time()
40
+ print(f"{func.__name__} took {end_time - start_time:.4f} seconds")
41
+ loggers.info(f"{func.__name__} took {end_time - start_time:.4f} seconds")
42
+ return result
43
+ return wrapper
44
+
45
+
46
+
47
+
48
+
49
+ from itertools import product
50
+ from multiprocessing import Pool
51
+ def Mul_Ess(map_fun,tuple_list):
52
+ with Pool(31) as p:
53
+ P_data = p.map(map_fun, tuple_list)
54
+ return P_data
55
+
56
+
57
+ import numpy as np
58
+ from matplotlib.colors import ListedColormap
59
+ import matplotlib.pyplot as plt
60
+ import datetime
61
+ cmp_hjnwtx={}
62
+
63
+ newcolorsNMC = np.array([
64
+ [68,157,237, 255],
65
+ [98,230,234, 255],
66
+ [104,249,82, 255],
67
+ [0,215,46, 255],
68
+ [0,143,27, 255],
69
+ [254,254,63, 255],
70
+ [231,192,48, 255],
71
+ [255,154,41, 255],
72
+ [255,19,27, 255],
73
+ [215,14,21, 255],
74
+ [193,11,18, 255],
75
+ [255,28,236, 255],
76
+ [152,15,177, 255],
77
+ [175,145,237, 255]])/255
78
+ cmp_hjnwtx["radar_nmc"] = ListedColormap(newcolorsNMC)
79
+
80
+ newcolorsNMC = np.array([
81
+ [68,157,237, 255],
82
+ [98,230,234, 255],
83
+ [104,249,82, 255],
84
+ [0,215,46, 255],
85
+ [0,143,27, 255],
86
+ [254,254,63, 255],
87
+ [231,192,48, 255],
88
+ [255,154,41, 255],
89
+ [255,19,27, 255],
90
+ [215,14,21, 255],
91
+ [193,11,18, 255],
92
+ [255,28,236, 255],
93
+ [152,15,177, 255],
94
+ [175,145,237, 255]])/255
95
+ cmp_hjnwtx["radar_moc"] = ListedColormap(newcolorsNMC)
96
+
97
+
98
+ newcolorsPRE = np.array([
99
+ [128, 255, 255, 255],
100
+ [35, 182, 254, 255],
101
+ [0, 120, 180, 255],
102
+ [0, 82, 202, 255],
103
+ [0, 16, 220, 255],
104
+ [150, 2, 244, 255],
105
+ [110, 0, 182, 255],
106
+ [77, 0, 130, 255]])/255
107
+ cmp_hjnwtx["pre_tqw"] = ListedColormap(newcolorsPRE)
108
+
109
+ newcolorsWS = np.array([
110
+ [75, 140, 244, 255],
111
+ [0, 89, 235, 255],
112
+ [36, 173, 0, 255],
113
+ [18, 129, 1, 255],
114
+ [3, 64, 4, 255],
115
+ [218, 183, 5, 255],
116
+ [179, 125, 1, 255],
117
+ [155, 70, 16, 255],
118
+ [253, 3, 127, 255],
119
+ [255, 0, 55, 255],
120
+ [233, 0, 3, 255]])/255
121
+ cmp_hjnwtx["ws_nmic"] = ListedColormap(newcolorsWS)
122
+
123
+ import os
124
+ def mkDir(path):
125
+ if "." in path:
126
+ os.makedirs(os.path.dirname(path),exist_ok=True)
127
+ else:
128
+ os.makedirs(path, exist_ok=True)
129
+
130
+ def Radar_Nmc(array_dt,temp = "850"):
131
+ now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
132
+ if len(array_dt.shape)==3:
133
+ for i , img_ch_nel in enumerate(array_dt):
134
+ plt.imshow(img_ch_nel,vmin=0,vmax=100,cmap=cmp_hjnwtx["radar_nmc"])
135
+ plt.colorbar()
136
+ outpath = f"./radar_nmc/{temp}_{now_str}.png"
137
+ mkDir(outpath)
138
+ plt.savefig(outpath)
139
+ plt.close()
140
+ if len(array_dt.shape)==2:
141
+ plt.imshow(array_dt,vmin=0,vmax=100,cmap=cmp_hjnwtx["radar_nmc"])
142
+ plt.colorbar()
143
+ outpath = f"./radar_nmc/{temp}_{now_str}.png"
144
+ mkDir(outpath)
145
+ plt.savefig(outpath)
146
+ plt.close()
147
+
@@ -0,0 +1,92 @@
1
+
2
+ import numpy as np
3
+ from matplotlib.colors import ListedColormap
4
+ import matplotlib.pyplot as plt
5
+ import datetime
6
+ cmp_hjnwtx={}
7
+
8
+ newcolorsNMC = np.array([
9
+ [68,157,237, 255],
10
+ [98,230,234, 255],
11
+ [104,249,82, 255],
12
+ [0,215,46, 255],
13
+ [0,143,27, 255],
14
+ [254,254,63, 255],
15
+ [231,192,48, 255],
16
+ [255,154,41, 255],
17
+ [255,19,27, 255],
18
+ [215,14,21, 255],
19
+ [193,11,18, 255],
20
+ [255,28,236, 255],
21
+ [152,15,177, 255],
22
+ [175,145,237, 255]])/255
23
+ cmp_hjnwtx["radar_nmc"] = ListedColormap(newcolorsNMC)
24
+
25
+ newcolorsNMC = np.array([
26
+ [68,157,237, 255],
27
+ [98,230,234, 255],
28
+ [104,249,82, 255],
29
+ [0,215,46, 255],
30
+ [0,143,27, 255],
31
+ [254,254,63, 255],
32
+ [231,192,48, 255],
33
+ [255,154,41, 255],
34
+ [255,19,27, 255],
35
+ [215,14,21, 255],
36
+ [193,11,18, 255],
37
+ [255,28,236, 255],
38
+ [152,15,177, 255],
39
+ [175,145,237, 255]])/255
40
+ cmp_hjnwtx["radar_moc"] = ListedColormap(newcolorsNMC)
41
+
42
+
43
+ newcolorsPRE = np.array([
44
+ [128, 255, 255, 255],
45
+ [35, 182, 254, 255],
46
+ [0, 120, 180, 255],
47
+ [0, 82, 202, 255],
48
+ [0, 16, 220, 255],
49
+ [150, 2, 244, 255],
50
+ [110, 0, 182, 255],
51
+ [77, 0, 130, 255]])/255
52
+ cmp_hjnwtx["pre_tqw"] = ListedColormap(newcolorsPRE)
53
+
54
+ newcolorsWS = np.array([
55
+ [75, 140, 244, 255],
56
+ [0, 89, 235, 255],
57
+ [36, 173, 0, 255],
58
+ [18, 129, 1, 255],
59
+ [3, 64, 4, 255],
60
+ [218, 183, 5, 255],
61
+ [179, 125, 1, 255],
62
+ [155, 70, 16, 255],
63
+ [253, 3, 127, 255],
64
+ [255, 0, 55, 255],
65
+ [233, 0, 3, 255]])/255
66
+ cmp_hjnwtx["ws_nmic"] = ListedColormap(newcolorsWS)
67
+
68
+ import os
69
+ def mkDir(path):
70
+ if "." in path:
71
+ os.makedirs(os.path.dirname(path),exist_ok=True)
72
+ else:
73
+ os.makedirs(path, exist_ok=True)
74
+
75
+ def Radar_Nmc(array_dt,temp = "850"):
76
+ now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
77
+ if len(array_dt.shape)==3:
78
+ for i , img_ch_nel in enumerate(array_dt):
79
+ plt.imshow(img_ch_nel,vmin=0,vmax=100,cmap=cmp_hjnwtx["radar_nmc"])
80
+ plt.colorbar()
81
+ outpath = f"./radar_nmc/{temp}_{now_str}.png"
82
+ mkDir(outpath)
83
+ plt.savefig(outpath)
84
+ plt.close()
85
+ if len(array_dt.shape)==2:
86
+ plt.imshow(array_dt,vmin=0,vmax=100,cmap=cmp_hjnwtx["radar_nmc"])
87
+ plt.colorbar()
88
+ outpath = f"./radar_nmc/{temp}_{now_str}.png"
89
+ mkDir(outpath)
90
+ plt.savefig(outpath)
91
+ plt.close()
92
+
@@ -0,0 +1,55 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ import datetime
4
+ from hjnwtx.colormap import cmp_hjnwtx # 假设这是您的自定义颜色映射库
5
+ import cartopy.crs as ccrs
6
+ import cartopy.feature as cfeature
7
+ import cartopy.io.shapereader as shpreader
8
+
9
+ def big_value_fun(array_dt,array_dt1,name="temp"):
10
+ now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
11
+ outpath = f"./radar_nmc/{name}_{now_str}.png"
12
+ mkDir(outpath)
13
+
14
+ # 创建绘图和设置坐标系
15
+ fig = plt.figure(figsize=(10, 8))
16
+ ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
17
+
18
+ # 设置图像显示的范围
19
+ ax.set_extent([73, 135, 18, 54], ccrs.PlateCarree()) # 根据需要调整
20
+
21
+ # 添加中国地图的边界和特征,包括省份轮廓
22
+ add_china_map(ax)
23
+
24
+ # 添加数据层
25
+ if len(array_dt.shape) == 3:
26
+ for i, img_ch_nel in enumerate(array_dt):
27
+ ax.imshow(img_ch_nel, vmin=50, vmax=500, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2])
28
+ plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
29
+ plt.savefig(f"{outpath}_layer_{i}.png")
30
+ plt.clf() # 清除图形以绘制下一个通道图像
31
+ elif len(array_dt.shape) == 2:
32
+ ax.imshow(array_dt, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2], alpha=1)
33
+ ax.imshow(array_dt1, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2], alpha=0.3)
34
+ plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
35
+ plt.savefig(outpath)
36
+ plt.close(fig)
37
+
38
+ def add_china_map(ax):
39
+ # 在地图上添加地形特征
40
+ ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
41
+ ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
42
+ ax.add_feature(cfeature.LAKES, alpha=0.8)
43
+ # 添加省份轮廓
44
+ provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces')
45
+ provinces_features = shpreader.Reader(provinces).geometries()
46
+ ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
47
+
48
+ def mkDir(path):
49
+ # 处理目录创建
50
+ import os
51
+ directory = os.path.dirname(path)
52
+ if not os.path.exists(directory):
53
+ os.makedirs(directory)
54
+
55
+ # 示例用法
@@ -0,0 +1,54 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ import datetime
4
+ from hjnwtx.colormap import cmp_hjnwtx # 假设这是您的自定义颜色映射库
5
+ import cartopy.crs as ccrs
6
+ import cartopy.feature as cfeature
7
+ import cartopy.io.shapereader as shpreader
8
+
9
+ def big_value_fun(array_dt):
10
+ now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
11
+ outpath = f"./radar_nmc/{now_str}.png"
12
+ mkDir(outpath)
13
+
14
+ # 创建绘图和设置坐标系
15
+ fig = plt.figure(figsize=(10, 8))
16
+ ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
17
+
18
+ # 设置图像显示的范围
19
+ ax.set_extent([73, 135, 18, 54], ccrs.PlateCarree()) # 根据需要调整
20
+
21
+ # 添加中国地图的边界和特征,包括省份轮廓
22
+ add_china_map(ax)
23
+
24
+ # 添加数据层
25
+ if len(array_dt.shape) == 3:
26
+ for i, img_ch_nel in enumerate(array_dt):
27
+ ax.imshow(img_ch_nel, vmin=50, vmax=500, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2])
28
+ plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
29
+ plt.savefig(f"{outpath}_layer_{i}.png")
30
+ plt.clf() # 清除图形以绘制下一个通道图像
31
+ elif len(array_dt.shape) == 2:
32
+ ax.imshow(array_dt, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2])
33
+ plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
34
+ plt.savefig(outpath)
35
+ plt.close(fig)
36
+
37
+ def add_china_map(ax):
38
+ # 在地图上添加地形特征
39
+ ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
40
+ ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
41
+ ax.add_feature(cfeature.LAKES, alpha=0.8)
42
+ # 添加省份轮廓
43
+ provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces')
44
+ provinces_features = shpreader.Reader(provinces).geometries()
45
+ ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
46
+
47
+ def mkDir(path):
48
+ # 处理目录创建
49
+ import os
50
+ directory = os.path.dirname(path)
51
+ if not os.path.exists(directory):
52
+ os.makedirs(directory)
53
+
54
+ # 示例用法
@@ -0,0 +1,36 @@
1
+
2
+ import glob
3
+ import numpy as np
4
+ from hjnwtx.colormap import cmp_hjnwtx
5
+ PathList = glob.glob("/mnt/wtx_weather_forecast/scx/testDBscan/2024_p/20240312/*")
6
+ path = PathList[0]
7
+ print(path)
8
+
9
+ import numpy as np
10
+ import matplotlib.pyplot as plt
11
+ x = np.load(path)
12
+ # for i in range(35):
13
+ # plt.imshow(x[i])
14
+ # plt.savefig(f"./image/a{str(i)}.png")
15
+ # plt.show()
16
+
17
+
18
+ from hjnwtx.colormap import cmp_hjnwtx
19
+ import matplotlib.pyplot as plt
20
+ import datetime
21
+ def drawpic(base_up,base_down,shape_len, name="temp"):
22
+ now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
23
+ Count = shape_len
24
+ data_all = np.concatenate([base_up,base_down], axis=0)
25
+ fig, axs = plt.subplots(2, Count, figsize=(10*shape_len, 10))
26
+ # data_all = data_all * 70
27
+ for i in range(2):
28
+ for j in range(Count):
29
+ index = i * Count + j
30
+ axs[i, j].imshow(data_all[index, :, :],vmax=70,vmin=0,cmap=cmp_hjnwtx["radar_nmc"])
31
+ axs[i, j].axis('off')
32
+ plt.tight_layout()
33
+ plt.savefig(name +now_str + '.png')
34
+ plt.close()
35
+ #drawpic(x,x,35)
36
+ print("done")
@@ -0,0 +1,40 @@
1
+ import matplotlib.pyplot as plt
2
+ import cartopy.crs as ccrs
3
+ import cartopy.feature as cfeature
4
+ import cartopy.io.shapereader as shpreader
5
+ import datetime
6
+ import os
7
+
8
+ def add_china_map(ax):
9
+ ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
10
+ ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
11
+ ax.add_feature(cfeature.LAKES, alpha=0.8)
12
+ provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces')
13
+ provinces_features = shpreader.Reader(provinces).geometries()
14
+ ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
15
+
16
+ def mkDir(filepath):
17
+ directory = os.path.dirname(filepath)
18
+ if not os.path.exists(directory):
19
+ os.makedirs(directory)
20
+
21
+ def draw_radar_images(data, num_images, output_name="temp"):
22
+ # Validate input
23
+ if not data.shape[0] >= num_images:
24
+ raise ValueError("Data does not contain enough entries for the number of images specified.")
25
+
26
+ # Setup figure dimensions based on the number of images
27
+ fig, axs = plt.subplots(1, num_images, figsize=(10 * num_images, 10), subplot_kw={'projection': ccrs.PlateCarree()})
28
+
29
+ for i in range(num_images):
30
+ axs[i].imshow(data[i, :, :], vmax=70, vmin=0, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 135, 18, 54])
31
+ add_china_map(axs[i])
32
+ axs[i].axis('off')
33
+
34
+ # Save the figure
35
+ now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
36
+ outpath = f"./aplot_image/{output_name}_{now_str}.png"
37
+ mkDir(outpath)
38
+ fig.tight_layout()
39
+ fig.savefig(outpath, dpi=300)
40
+ plt.close(fig)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shancx
3
- Version: 1.60
3
+ Version: 1.70
4
4
  Summary: A simple timer decorator
5
5
  Home-page: https://gitee.com/shancx
6
6
  Author: Your Name
@@ -0,0 +1,12 @@
1
+ README.md
2
+ setup.py
3
+ shancx/__init__.py
4
+ shancx/mkIMGSCX.py
5
+ shancx/radar_nmc_china_map_compare1.py
6
+ shancx/radar_nmc_china_map_f.py
7
+ shancx/subplots_compare_devlop.py
8
+ shancx/subplots_single_china_map.py
9
+ shancx.egg-info/PKG-INFO
10
+ shancx.egg-info/SOURCES.txt
11
+ shancx.egg-info/dependency_links.txt
12
+ shancx.egg-info/top_level.txt
@@ -1,54 +0,0 @@
1
- #!/usr/bin/python
2
- # -*- coding: utf-8 -*-
3
- # @Time : 2023/09/27 下午8:52
4
- # @Author : shanchangxi
5
- # @File : util_log.py
6
- import time
7
- import logging # 引入logging模块
8
- from logging import handlers
9
- # from util.util_dir import *
10
-
11
- # 第一步,创建一个logger
12
- loggers = logging.getLogger()
13
- loggers.setLevel(logging.INFO) # Log等级开关
14
-
15
- # 第二步,创建一个handler,用于写入日志文件
16
- log_name = 'project_tim_tor.log'
17
- logfile = log_name
18
-
19
- time_rotating_file_handler = handlers.TimedRotatingFileHandler(filename=logfile, when='D', encoding='utf-8')
20
- time_rotating_file_handler.setLevel(logging.INFO) # 输出到file的log等级的开关
21
-
22
- # 第三步,定义handler的输出格式
23
- formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s")
24
- time_rotating_file_handler.setFormatter(formatter)
25
-
26
- # 第四步,将handler添加到logger里面
27
- loggers.addHandler(time_rotating_file_handler)
28
-
29
- # 如果需要同時需要在終端上輸出,定義一個streamHandler
30
- print_handler = logging.StreamHandler() # 往屏幕上输出
31
- print_handler.setFormatter(formatter) # 设置屏幕上显示的格式
32
- loggers.addHandler(print_handler)
33
-
34
-
35
- def Tim_Tor(func):
36
- def wrapper(*args, **kwargs):
37
- start_time = time.time()
38
- result = func(*args, **kwargs)
39
- end_time = time.time()
40
- print(f"{func.__name__} took {end_time - start_time:.4f} seconds")
41
- loggers.info(f"{func.__name__} took {end_time - start_time:.4f} seconds")
42
- return result
43
- return wrapper
44
-
45
-
46
-
47
-
48
-
49
- from itertools import product
50
- from multiprocessing import Pool
51
- def Mul_Ess(map_fun,tuple_list):
52
- with Pool(31) as p:
53
- P_data = p.map(map_fun, tuple_list)
54
- return P_data
@@ -1,7 +0,0 @@
1
- README.md
2
- setup.py
3
- shancx/__init__.py
4
- shancx.egg-info/PKG-INFO
5
- shancx.egg-info/SOURCES.txt
6
- shancx.egg-info/dependency_links.txt
7
- shancx.egg-info/top_level.txt
File without changes
File without changes