shancx 1.8.92__py3-none-any.whl → 1.9.33.218__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.
- shancx/3D/__init__.py +25 -0
- shancx/Algo/Class.py +11 -0
- shancx/Algo/CudaPrefetcher1.py +112 -0
- shancx/Algo/Fake_image.py +24 -0
- shancx/Algo/Hsml.py +391 -0
- shancx/Algo/L2Loss.py +10 -0
- shancx/Algo/MetricTracker.py +132 -0
- shancx/Algo/Normalize.py +66 -0
- shancx/Algo/OptimizerWScheduler.py +38 -0
- shancx/Algo/Rmageresize.py +79 -0
- shancx/Algo/Savemodel.py +33 -0
- shancx/Algo/SmoothL1_losses.py +27 -0
- shancx/Algo/Tqdm.py +62 -0
- shancx/Algo/__init__.py +121 -0
- shancx/Algo/checknan.py +28 -0
- shancx/Algo/iouJU.py +83 -0
- shancx/Algo/mask.py +25 -0
- shancx/Algo/psnr.py +9 -0
- shancx/Algo/ssim.py +70 -0
- shancx/Algo/structural_similarity.py +308 -0
- shancx/Algo/tool.py +704 -0
- shancx/Calmetrics/__init__.py +97 -0
- shancx/Calmetrics/calmetrics.py +14 -0
- shancx/Calmetrics/calmetricsmatrixLib.py +147 -0
- shancx/Calmetrics/rmseR2score.py +35 -0
- shancx/Clip/__init__.py +50 -0
- shancx/Cmd.py +126 -0
- shancx/Config_.py +26 -0
- shancx/Df/DataFrame.py +11 -2
- shancx/Df/__init__.py +17 -0
- shancx/Df/tool.py +0 -0
- shancx/Diffm/Psamples.py +18 -0
- shancx/Diffm/__init__.py +0 -0
- shancx/Diffm/test.py +207 -0
- shancx/Doc/__init__.py +214 -0
- shancx/E/__init__.py +178 -152
- shancx/Fillmiss/__init__.py +0 -0
- shancx/Fillmiss/imgidwJU.py +46 -0
- shancx/Fillmiss/imgidwLatLonJU.py +82 -0
- shancx/Gpu/__init__.py +55 -0
- shancx/H9/__init__.py +126 -0
- shancx/H9/ahi_read_hsd.py +877 -0
- shancx/H9/ahisearchtable.py +298 -0
- shancx/H9/geometry.py +2439 -0
- shancx/Hug/__init__.py +81 -0
- shancx/Inst.py +22 -0
- shancx/Lib.py +31 -0
- shancx/Mos/__init__.py +37 -0
- shancx/NN/__init__.py +235 -106
- shancx/Path1.py +161 -0
- shancx/Plot/GlobMap.py +276 -116
- shancx/Plot/__init__.py +491 -1
- shancx/Plot/draw_day_CR_PNG.py +4 -21
- shancx/Plot/exam.py +116 -0
- shancx/Plot/plotGlobal.py +325 -0
- shancx/{radar_nmc.py → Plot/radarNmc.py} +4 -34
- shancx/{subplots_single_china_map.py → Plot/single_china_map.py} +1 -1
- shancx/Point.py +46 -0
- shancx/QC.py +223 -0
- shancx/RdPzl/__init__.py +32 -0
- shancx/Read.py +72 -0
- shancx/Resize.py +79 -0
- shancx/SN/__init__.py +62 -123
- shancx/Time/GetTime.py +9 -3
- shancx/Time/__init__.py +66 -1
- shancx/Time/timeCycle.py +302 -0
- shancx/Time/tool.py +0 -0
- shancx/Train/__init__.py +74 -0
- shancx/Train/makelist.py +187 -0
- shancx/Train/multiGpu.py +27 -0
- shancx/Train/prepare.py +161 -0
- shancx/Train/renet50.py +157 -0
- shancx/ZR.py +12 -0
- shancx/__init__.py +333 -262
- shancx/args.py +27 -0
- shancx/bak.py +768 -0
- shancx/df2database.py +62 -2
- shancx/geosProj.py +80 -0
- shancx/info.py +38 -0
- shancx/netdfJU.py +231 -0
- shancx/sendM.py +59 -0
- shancx/tensBoard/__init__.py +28 -0
- shancx/wait.py +246 -0
- {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/METADATA +15 -5
- shancx-1.9.33.218.dist-info/RECORD +91 -0
- {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/WHEEL +1 -1
- my_timer_decorator/__init__.py +0 -10
- shancx/Dsalgor/__init__.py +0 -19
- shancx/E/DFGRRIB.py +0 -30
- shancx/EN/DFGRRIB.py +0 -30
- shancx/EN/__init__.py +0 -148
- shancx/FileRead.py +0 -44
- shancx/Gray2RGB.py +0 -86
- shancx/M/__init__.py +0 -137
- shancx/MN/__init__.py +0 -133
- shancx/N/__init__.py +0 -131
- shancx/Plot/draw_day_CR_PNGUS.py +0 -206
- shancx/Plot/draw_day_CR_SVG.py +0 -275
- shancx/Plot/draw_day_pre_PNGUS.py +0 -205
- shancx/Plot/glob_nation_map.py +0 -116
- shancx/Plot/radar_nmc.py +0 -61
- shancx/Plot/radar_nmc_china_map_compare1.py +0 -50
- shancx/Plot/radar_nmc_china_map_f.py +0 -121
- shancx/Plot/radar_nmc_us_map_f.py +0 -128
- shancx/Plot/subplots_compare_devlop.py +0 -36
- shancx/Plot/subplots_single_china_map.py +0 -45
- shancx/S/__init__.py +0 -138
- shancx/W/__init__.py +0 -132
- shancx/WN/__init__.py +0 -132
- shancx/code.py +0 -331
- shancx/draw_day_CR_PNG.py +0 -200
- shancx/draw_day_CR_PNGUS.py +0 -206
- shancx/draw_day_CR_SVG.py +0 -275
- shancx/draw_day_pre_PNGUS.py +0 -205
- shancx/makenetCDFN.py +0 -42
- shancx/mkIMGSCX.py +0 -92
- shancx/netCDF.py +0 -130
- shancx/radar_nmc_china_map_compare1.py +0 -50
- shancx/radar_nmc_china_map_f.py +0 -125
- shancx/radar_nmc_us_map_f.py +0 -67
- shancx/subplots_compare_devlop.py +0 -36
- shancx/tool.py +0 -18
- shancx/user/H8mess.py +0 -317
- shancx/user/__init__.py +0 -137
- shancx/user/cinradHJN.py +0 -496
- shancx/user/examMeso.py +0 -293
- shancx/user/hjnDAAS.py +0 -26
- shancx/user/hjnFTP.py +0 -81
- shancx/user/hjnGIS.py +0 -320
- shancx/user/hjnGPU.py +0 -21
- shancx/user/hjnIDW.py +0 -68
- shancx/user/hjnKDTree.py +0 -75
- shancx/user/hjnLAPSTransform.py +0 -47
- shancx/user/hjnMiscellaneous.py +0 -182
- shancx/user/hjnProj.py +0 -162
- shancx/user/inotify.py +0 -41
- shancx/user/matplotlibMess.py +0 -87
- shancx/user/mkNCHJN.py +0 -623
- shancx/user/newTypeRadar.py +0 -492
- shancx/user/test.py +0 -6
- shancx/user/tlogP.py +0 -129
- shancx/util_log.py +0 -33
- shancx/wtx/H8mess.py +0 -315
- shancx/wtx/__init__.py +0 -151
- shancx/wtx/cinradHJN.py +0 -496
- shancx/wtx/colormap.py +0 -64
- shancx/wtx/examMeso.py +0 -298
- shancx/wtx/hjnDAAS.py +0 -26
- shancx/wtx/hjnFTP.py +0 -81
- shancx/wtx/hjnGIS.py +0 -330
- shancx/wtx/hjnGPU.py +0 -21
- shancx/wtx/hjnIDW.py +0 -68
- shancx/wtx/hjnKDTree.py +0 -75
- shancx/wtx/hjnLAPSTransform.py +0 -47
- shancx/wtx/hjnLog.py +0 -78
- shancx/wtx/hjnMiscellaneous.py +0 -201
- shancx/wtx/hjnProj.py +0 -161
- shancx/wtx/inotify.py +0 -41
- shancx/wtx/matplotlibMess.py +0 -87
- shancx/wtx/mkNCHJN.py +0 -613
- shancx/wtx/newTypeRadar.py +0 -492
- shancx/wtx/test.py +0 -6
- shancx/wtx/tlogP.py +0 -129
- shancx-1.8.92.dist-info/RECORD +0 -99
- /shancx/{Dsalgor → Algo}/dsalgor.py +0 -0
- {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/top_level.txt +0 -0
shancx/__init__.py
CHANGED
|
@@ -1,263 +1,334 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# @Time : 2024/10/17 上午午10:40
|
|
4
|
-
# @Author : shancx
|
|
5
|
-
# @File : __init__.py
|
|
6
|
-
# @email : shanhe12@163.com
|
|
7
|
-
|
|
8
|
-
import os
|
|
9
|
-
def start():
|
|
10
|
-
print("import successful")
|
|
11
|
-
# constants
|
|
12
|
-
import subprocess
|
|
13
|
-
|
|
14
|
-
__author__ = 'shancx'
|
|
15
|
-
|
|
16
|
-
__author_email__ = 'shanhe12@163.com'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# @
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
loggers = logging.getLogger()
|
|
30
|
-
loggers.setLevel(logging.INFO)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
''
|
|
213
|
-
|
|
214
|
-
'''
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
''
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
"""
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2024/10/17 上午午10:40
|
|
4
|
+
# @Author : shancx
|
|
5
|
+
# @File : __init__.py
|
|
6
|
+
# @email : shanhe12@163.com
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
def start():
|
|
10
|
+
print("import successful")
|
|
11
|
+
# constants
|
|
12
|
+
import subprocess
|
|
13
|
+
|
|
14
|
+
__author__ = 'shancx'
|
|
15
|
+
|
|
16
|
+
__author_email__ = 'shanhe12@163.com'
|
|
17
|
+
|
|
18
|
+
# @Time : 2023/09/27 下午8:52
|
|
19
|
+
# @Author : shanchangxi
|
|
20
|
+
# @File : util_log.py
|
|
21
|
+
import time
|
|
22
|
+
import logging
|
|
23
|
+
from logging import handlers
|
|
24
|
+
import inspect
|
|
25
|
+
|
|
26
|
+
import time
|
|
27
|
+
import logging
|
|
28
|
+
from logging import handlers
|
|
29
|
+
loggers = logging.getLogger()
|
|
30
|
+
loggers.setLevel(logging.INFO)
|
|
31
|
+
formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s")
|
|
32
|
+
print_handler = logging.StreamHandler()
|
|
33
|
+
print_handler.setFormatter(formatter)
|
|
34
|
+
loggers.addHandler(print_handler)
|
|
35
|
+
|
|
36
|
+
from pathlib import Path as PathlibPath
|
|
37
|
+
def crDir(path):
|
|
38
|
+
path_obj = PathlibPath(path)
|
|
39
|
+
directory = path_obj.parent if path_obj.suffix else path_obj
|
|
40
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
41
|
+
|
|
42
|
+
def Tim_(func):
|
|
43
|
+
def wrapper(*args, **kwargs):
|
|
44
|
+
start_time = time.time()
|
|
45
|
+
result = func(*args, **kwargs)
|
|
46
|
+
end_time = time.time()
|
|
47
|
+
loggers.info(f"{func.__name__} took {end_time - start_time:.4f} seconds")
|
|
48
|
+
return result
|
|
49
|
+
return wrapper
|
|
50
|
+
|
|
51
|
+
def TimPlus(func):
|
|
52
|
+
def wrapper(*args, **kwargs):
|
|
53
|
+
func_file = inspect.getfile(func)
|
|
54
|
+
func_line = inspect.getsourcelines(func)[1]
|
|
55
|
+
start_time = time.time()
|
|
56
|
+
result = func(*args, **kwargs)
|
|
57
|
+
end_time = time.time()
|
|
58
|
+
elapsed_time = end_time - start_time
|
|
59
|
+
log_message = (
|
|
60
|
+
f"{func.__name__} line {func_line} (Defined at {func_file} ) "
|
|
61
|
+
f"took {elapsed_time:.4f} seconds"
|
|
62
|
+
)
|
|
63
|
+
loggers.info(log_message)
|
|
64
|
+
return result
|
|
65
|
+
return wrapper
|
|
66
|
+
|
|
67
|
+
def validate_param_list(param_list):
|
|
68
|
+
if len(param_list) == 0:
|
|
69
|
+
raise ValueError("param_list cannot be empty.")
|
|
70
|
+
for sublist in param_list:
|
|
71
|
+
if len(sublist) == 0:
|
|
72
|
+
raise ValueError("Sub-lists in param_list cannot be empty.")
|
|
73
|
+
|
|
74
|
+
from itertools import product
|
|
75
|
+
from concurrent.futures import ProcessPoolExecutor as PoolExecutor, as_completed
|
|
76
|
+
import sys
|
|
77
|
+
from tqdm import tqdm
|
|
78
|
+
def Mul_sub(task, param_list, num=6):
|
|
79
|
+
print(f"Pro num {num}")
|
|
80
|
+
validate_param_list(param_list)
|
|
81
|
+
if len(param_list) == 1:
|
|
82
|
+
product_list = [(x,) for x in param_list[0]]
|
|
83
|
+
else:
|
|
84
|
+
product_list = list(product(*param_list))
|
|
85
|
+
results = []
|
|
86
|
+
with PoolExecutor(max_workers=num) as executor:
|
|
87
|
+
try:
|
|
88
|
+
futures = [executor.submit(task, item) for item in product_list]
|
|
89
|
+
for future in tqdm(as_completed(futures), total=len(futures), desc="Processing tasks", unit="task"):
|
|
90
|
+
results.append(future.result())
|
|
91
|
+
except KeyboardInterrupt:
|
|
92
|
+
sys.exit(1)
|
|
93
|
+
return results
|
|
94
|
+
|
|
95
|
+
def Mul_sub_S(task, param_list, num=6):
|
|
96
|
+
print(f"Pro num {num}")
|
|
97
|
+
validate_param_list(param_list)
|
|
98
|
+
if len(param_list) == 1:
|
|
99
|
+
product_list = [(x,) for x in param_list[0]]
|
|
100
|
+
else:
|
|
101
|
+
product_list = list(product(*param_list))
|
|
102
|
+
results = [None] * len(product_list)
|
|
103
|
+
with PoolExecutor(max_workers=num) as executor:
|
|
104
|
+
futures = {executor.submit(task, item): idx for idx, item in enumerate(product_list)}
|
|
105
|
+
try:
|
|
106
|
+
for future in tqdm(as_completed(futures), total=len(futures), desc="Processing", unit="task"):
|
|
107
|
+
idx = futures[future]
|
|
108
|
+
results[idx] = future.result()
|
|
109
|
+
except KeyboardInterrupt:
|
|
110
|
+
sys.exit(1)
|
|
111
|
+
return results
|
|
112
|
+
|
|
113
|
+
from concurrent.futures import ProcessPoolExecutor as PoolExecutor, as_completed
|
|
114
|
+
import sys
|
|
115
|
+
from tqdm import tqdm
|
|
116
|
+
def Mul_subplus(task, param_lists, num=6):
|
|
117
|
+
results = []
|
|
118
|
+
with PoolExecutor(max_workers=num) as executor:
|
|
119
|
+
try:
|
|
120
|
+
futures = [
|
|
121
|
+
executor.submit(task, args)
|
|
122
|
+
for args in zip(*param_lists)
|
|
123
|
+
]
|
|
124
|
+
for future in tqdm(as_completed(futures), total=len(futures), desc="Processing tasks", unit="task"):
|
|
125
|
+
results.append(future.result())
|
|
126
|
+
except KeyboardInterrupt:
|
|
127
|
+
sys.exit(1)
|
|
128
|
+
return results
|
|
129
|
+
|
|
130
|
+
from concurrent.futures import ProcessPoolExecutor as PoolExecutor, as_completed
|
|
131
|
+
import sys
|
|
132
|
+
from tqdm import tqdm
|
|
133
|
+
def Mul_sub_Splus(task, param_lists, num=6):
|
|
134
|
+
if not all(len(lst) == len(param_lists[0]) for lst in param_lists):
|
|
135
|
+
raise ValueError("All parameter lists must have the same length.")
|
|
136
|
+
results = [None] * len(param_lists[0])
|
|
137
|
+
with PoolExecutor(max_workers=num) as executor:
|
|
138
|
+
try:
|
|
139
|
+
futures = {
|
|
140
|
+
executor.submit(task, *args): idx
|
|
141
|
+
for idx, args in enumerate(zip(*param_lists))
|
|
142
|
+
}
|
|
143
|
+
for future in tqdm(as_completed(futures), total=len(futures), desc="Processing tasks", unit="task"):
|
|
144
|
+
idx = futures[future]
|
|
145
|
+
results[idx] = future.result()
|
|
146
|
+
except KeyboardInterrupt:
|
|
147
|
+
sys.exit(1)
|
|
148
|
+
return results
|
|
149
|
+
|
|
150
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
151
|
+
from itertools import product
|
|
152
|
+
def Mul_TH(task, param_list, max_workers=6):
|
|
153
|
+
print(f"Thread num: {max_workers}")
|
|
154
|
+
validate_param_list(param_list)
|
|
155
|
+
task_args = [
|
|
156
|
+
(arg,) if len(param_list) == 1 else arg
|
|
157
|
+
for arg in (
|
|
158
|
+
param_list[0] if len(param_list) == 1
|
|
159
|
+
else product(*param_list)
|
|
160
|
+
)
|
|
161
|
+
]
|
|
162
|
+
with ThreadPoolExecutor(max_workers) as ex:
|
|
163
|
+
try:
|
|
164
|
+
return list(ex.map(task, task_args))
|
|
165
|
+
except KeyboardInterrupt:
|
|
166
|
+
print("\n用户中断操作")
|
|
167
|
+
ex.shutdown(wait=False)
|
|
168
|
+
sys.exit(1)
|
|
169
|
+
|
|
170
|
+
from tqdm import tqdm
|
|
171
|
+
def _tqdm(train_loader,desc="Training Progress",epoch=None):
|
|
172
|
+
epoch = epoch +1 if epoch is not None else None
|
|
173
|
+
descdict = {"val":"Val Progress", "train":"Training Progress"}
|
|
174
|
+
return tqdm(train_loader, desc=f"Epoch {epoch} {descdict.get(desc,'DESC')}", ncols=100)
|
|
175
|
+
|
|
176
|
+
import os
|
|
177
|
+
import datetime
|
|
178
|
+
from pathlib import Path
|
|
179
|
+
def lock_file(lock_file_path):
|
|
180
|
+
if os.path.exists(lock_file_path):
|
|
181
|
+
print(f" {lock_file_path} is existded ")
|
|
182
|
+
return False
|
|
183
|
+
try:
|
|
184
|
+
os.makedirs(os.path.dirname(lock_file_path), exist_ok=True)
|
|
185
|
+
with open(lock_file_path, 'w') as f:
|
|
186
|
+
f.write(f"process_id:{os.getpid()},create_time:{datetime.datetime.now()}")
|
|
187
|
+
return True
|
|
188
|
+
except Exception as e:
|
|
189
|
+
print(f"创建锁文件失败 create lock failed : {e}")
|
|
190
|
+
return False
|
|
191
|
+
"""
|
|
192
|
+
lock_file = f"{output_base_path}{sat_code}/lock_files/MSP2_WTX_AIW_QPF_L88_GLOB_{utc_time_str}.lock"
|
|
193
|
+
if os.path.exists(outpath):
|
|
194
|
+
print(f" 目标文件已存在,跳过处理: {outpath}")
|
|
195
|
+
return True
|
|
196
|
+
if os.path.exists(lock_file):
|
|
197
|
+
print(f"锁文件存在,已有程序在处理时次 {utc_time_str},跳过")
|
|
198
|
+
return False
|
|
199
|
+
"""
|
|
200
|
+
import os
|
|
201
|
+
import time
|
|
202
|
+
def is_process_alive(pid):
|
|
203
|
+
try:
|
|
204
|
+
os.kill(pid, 0)
|
|
205
|
+
return True
|
|
206
|
+
except OSError:
|
|
207
|
+
return False
|
|
208
|
+
def check_lock(lock_file):
|
|
209
|
+
if not os.path.exists(lock_file):
|
|
210
|
+
return False
|
|
211
|
+
try:
|
|
212
|
+
with open(lock_file, 'r') as f:
|
|
213
|
+
content = f.read().strip()
|
|
214
|
+
if 'process_id:' in content and 'create_time:' in content:
|
|
215
|
+
pid_str = content.split('process_id:')[1].split(',')[0]
|
|
216
|
+
pid = int(pid_str)
|
|
217
|
+
if not is_process_alive(pid):
|
|
218
|
+
print(f"进程 {pid} 已消亡,清理锁文件")
|
|
219
|
+
os.remove(lock_file)
|
|
220
|
+
return False
|
|
221
|
+
else:
|
|
222
|
+
print(f"进程 {pid} 仍在运行,跳过执行")
|
|
223
|
+
return True
|
|
224
|
+
except Exception as e:
|
|
225
|
+
print(f"锁文件解析错误,清理: {e}")
|
|
226
|
+
os.remove(lock_file)
|
|
227
|
+
return False
|
|
228
|
+
return False
|
|
229
|
+
"""
|
|
230
|
+
if check_lock(lock_file):
|
|
231
|
+
return False
|
|
232
|
+
"""
|
|
233
|
+
import multiprocessing
|
|
234
|
+
def set_multiprocessing(method="spawn", verbose=True): # 补充缺失的verbose参数定义
|
|
235
|
+
try:
|
|
236
|
+
multiprocessing.set_start_method(method, force=True)
|
|
237
|
+
if verbose:
|
|
238
|
+
print(f"The startup method is: '{method}'")
|
|
239
|
+
return method
|
|
240
|
+
except RuntimeError as e:
|
|
241
|
+
if verbose:
|
|
242
|
+
print(f"Setup failed: {e}")
|
|
243
|
+
return multiprocessing.get_start_method()
|
|
244
|
+
|
|
245
|
+
"""
|
|
246
|
+
current_method = set_multiprocessing_method()
|
|
247
|
+
# 输出:已设置多进程启动方式: 'spawn'
|
|
248
|
+
print("当前启动方式:", current_method) # 输出:当前启动方式:spawn
|
|
249
|
+
"""
|
|
250
|
+
"""
|
|
251
|
+
if __name__ == '__main__':
|
|
252
|
+
set_multiprocessing_method('auto')
|
|
253
|
+
print("当前启动方法:", multiprocessing.get_start_method())
|
|
254
|
+
|
|
255
|
+
"""
|
|
256
|
+
|
|
257
|
+
"""
|
|
258
|
+
zoom插值
|
|
259
|
+
from scipy.ndimage import zoom
|
|
260
|
+
d = zoom(d_clip, [4201/169,6201/249], order=1)[:-1, :-1]
|
|
261
|
+
"""
|
|
262
|
+
"""
|
|
263
|
+
torch.cuda.empty_cache()
|
|
264
|
+
del
|
|
265
|
+
gc.collect()
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
'''
|
|
269
|
+
from multiprocessing import Pool
|
|
270
|
+
'''
|
|
271
|
+
'''
|
|
272
|
+
##定義一個streamHandler
|
|
273
|
+
# print_handler = logging.StreamHandler()
|
|
274
|
+
# print_handler.setFormatter(formatter)
|
|
275
|
+
# loggers.addHandler(print_handler)
|
|
276
|
+
'''
|
|
277
|
+
'''
|
|
278
|
+
# @Time : 2023/09/27 下午8:52
|
|
279
|
+
# @Author : shanchangxi
|
|
280
|
+
# @File : util_log.py
|
|
281
|
+
import time
|
|
282
|
+
import logging
|
|
283
|
+
from logging import handlers
|
|
284
|
+
|
|
285
|
+
logger = logging.getLogger()
|
|
286
|
+
logger.setLevel(logging.INFO)
|
|
287
|
+
log_name = 'project_tim_tor.log'
|
|
288
|
+
logfile = log_name
|
|
289
|
+
time_rotating_file_handler = handlers.TimedRotatingFileHandler(filename=logfile, when='D', encoding='utf-8')
|
|
290
|
+
time_rotating_file_handler.setLevel(logging.INFO)
|
|
291
|
+
formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s")
|
|
292
|
+
time_rotating_file_handler.setFormatter(formatter)
|
|
293
|
+
logger.addHandler(time_rotating_file_handler)
|
|
294
|
+
print_handler = logging.StreamHandler()
|
|
295
|
+
print_handler.setFormatter(formatter)
|
|
296
|
+
logger.addHandler(print_handler)
|
|
297
|
+
'''
|
|
298
|
+
'''
|
|
299
|
+
###解决方法 pip install torch==2.4.0 torchvision torchaudio三个同时安装 python 3.12 解决cuda启动不了的问题
|
|
300
|
+
Res网络
|
|
301
|
+
'''
|
|
302
|
+
|
|
303
|
+
"""
|
|
304
|
+
find /mnt/wtx_weather_forecast/scx/SpiderGLOBPNGSource -type f -name "*.png" -mtime +3 -exec rm {} \;
|
|
305
|
+
-mtime 选项后面的数值代表天数。
|
|
306
|
+
+n 表示“超过 n 天”,即查找最后修改时间在 n 天之前的文件。
|
|
307
|
+
"""
|
|
308
|
+
"""
|
|
309
|
+
from shancx.SN import UserManager,sendMESplus
|
|
310
|
+
from shancx._info import users
|
|
311
|
+
M = UserManager(info=users)
|
|
312
|
+
user_info = M.get_user("003")
|
|
313
|
+
sendMESplus("测试数据",base=user_info)
|
|
314
|
+
"""
|
|
315
|
+
"""
|
|
316
|
+
https://api.map.baidu.com/lbsapi/getpoint/index.html 坐标
|
|
317
|
+
[global]
|
|
318
|
+
index-url = https://pypi.tuna.tsinghua.edu.cn/simple pip.conf
|
|
319
|
+
python setup.py sdist bdist_wheel
|
|
320
|
+
twine upload dist/*
|
|
321
|
+
"""
|
|
322
|
+
""" 与循环搭配使用
|
|
323
|
+
for key,value in dictflag.items():
|
|
324
|
+
try:
|
|
325
|
+
pac = all_df1[all_df1['PAC'].str.startswith(f'{key}')]
|
|
326
|
+
acctoal,acctoalEC,matEC,mat,rate_Lift_ratiotsEC,outpath= metriacfunall(pac)
|
|
327
|
+
if not len(matEC.shape) == (2,2):
|
|
328
|
+
continue
|
|
329
|
+
docdataset = mkdataset2TS(acctoal,acctoalEC,matEC,mat, rate_Lift_ratiotsEC,outpath)
|
|
330
|
+
|
|
331
|
+
except Exception as e:
|
|
332
|
+
print(traceback.format_exc())
|
|
333
|
+
continue
|
|
263
334
|
"""
|
shancx/args.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import datetime
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from dateutil.relativedelta import relativedelta
|
|
5
|
+
|
|
6
|
+
def options():
|
|
7
|
+
parser = argparse.ArgumentParser(description='scx')
|
|
8
|
+
parser.add_argument('--times', type=str, default='202411100000,202411101000')
|
|
9
|
+
parser.add_argument('--pac', type=str, default='100000')
|
|
10
|
+
parser.add_argument('--tag', type=str, default='100000')
|
|
11
|
+
parser.add_argument('--isDebug',action='store_true',default=False)
|
|
12
|
+
config= parser.parse_args()
|
|
13
|
+
print(config)
|
|
14
|
+
config.times = config.times.split(",")
|
|
15
|
+
if len(config.times) == 1:
|
|
16
|
+
config.times = [config.times[0], config.times[0]]
|
|
17
|
+
config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
|
|
18
|
+
datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
|
|
19
|
+
return config
|
|
20
|
+
if __name__ == '__main__':
|
|
21
|
+
cfg = options()
|
|
22
|
+
sCST = cfg.times[0]
|
|
23
|
+
eCST = cfg.times[-1]
|
|
24
|
+
timeList = pd.date_range(sCST, eCST + relativedelta(hours=24), freq="1h", inclusive="left")
|
|
25
|
+
print()
|
|
26
|
+
|
|
27
|
+
|