shancx 1.9.33.109__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/{Dsalgor → Algo}/__init__.py +37 -1
- shancx/Calmetrics/__init__.py +78 -9
- shancx/Calmetrics/calmetrics.py +14 -0
- shancx/Calmetrics/rmseR2score.py +14 -3
- shancx/{Command.py → Cmd.py} +20 -15
- shancx/Config_.py +26 -0
- shancx/Df/__init__.py +11 -0
- shancx/Df/tool.py +0 -1
- shancx/NN/__init__.py +200 -11
- shancx/{path.py → Path1.py} +2 -3
- shancx/Plot/__init__.py +129 -403
- shancx/Plot/draw_day_CR_PNG.py +4 -21
- shancx/Plot/exam.py +116 -0
- shancx/Plot/plotGlobal.py +325 -0
- shancx/Plot/radarNmc.py +1 -48
- shancx/Plot/single_china_map.py +1 -1
- shancx/Point.py +46 -0
- shancx/QC.py +223 -0
- shancx/Read.py +17 -10
- shancx/Resize.py +79 -0
- shancx/SN/__init__.py +8 -1
- shancx/Time/timeCycle.py +97 -23
- shancx/Train/makelist.py +161 -155
- shancx/__init__.py +79 -232
- shancx/bak.py +78 -53
- shancx/geosProj.py +2 -2
- shancx/wait.py +35 -1
- {shancx-1.9.33.109.dist-info → shancx-1.9.33.218.dist-info}/METADATA +12 -4
- shancx-1.9.33.218.dist-info/RECORD +91 -0
- {shancx-1.9.33.109.dist-info → shancx-1.9.33.218.dist-info}/WHEEL +1 -1
- shancx/Plot/Mip.py +0 -42
- shancx/Plot/border.py +0 -44
- 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/radar_nmc_china_map_compare1.py +0 -50
- shancx/makenetCDFN.py +0 -42
- shancx-1.9.33.109.dist-info/RECORD +0 -91
- /shancx/{3DJU → 3D}/__init__.py +0 -0
- /shancx/{Dsalgor → Algo}/Class.py +0 -0
- /shancx/{Dsalgor → Algo}/CudaPrefetcher1.py +0 -0
- /shancx/{Dsalgor → Algo}/Fake_image.py +0 -0
- /shancx/{Dsalgor → Algo}/Hsml.py +0 -0
- /shancx/{Dsalgor → Algo}/L2Loss.py +0 -0
- /shancx/{Dsalgor → Algo}/MetricTracker.py +0 -0
- /shancx/{Dsalgor → Algo}/Normalize.py +0 -0
- /shancx/{Dsalgor → Algo}/OptimizerWScheduler.py +0 -0
- /shancx/{Dsalgor → Algo}/Rmageresize.py +0 -0
- /shancx/{Dsalgor → Algo}/Savemodel.py +0 -0
- /shancx/{Dsalgor → Algo}/SmoothL1_losses.py +0 -0
- /shancx/{Dsalgor → Algo}/Tqdm.py +0 -0
- /shancx/{Dsalgor → Algo}/checknan.py +0 -0
- /shancx/{Dsalgor → Algo}/dsalgor.py +0 -0
- /shancx/{Dsalgor → Algo}/iouJU.py +0 -0
- /shancx/{Dsalgor → Algo}/mask.py +0 -0
- /shancx/{Dsalgor → Algo}/psnr.py +0 -0
- /shancx/{Dsalgor → Algo}/ssim.py +0 -0
- /shancx/{Dsalgor → Algo}/structural_similarity.py +0 -0
- /shancx/{Dsalgor → Algo}/tool.py +0 -0
- /shancx/Calmetrics/{matrixLib.py → calmetricsmatrixLib.py} +0 -0
- /shancx/{Diffmodel → Diffm}/Psamples.py +0 -0
- /shancx/{Diffmodel → Diffm}/__init__.py +0 -0
- /shancx/{Diffmodel → Diffm}/test.py +0 -0
- /shancx/{Board → tensBoard}/__init__.py +0 -0
- {shancx-1.9.33.109.dist-info → shancx-1.9.33.218.dist-info}/top_level.txt +0 -0
shancx/Train/makelist.py
CHANGED
|
@@ -1,181 +1,187 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
def save_results(results, output_file, mode='w',title="input_path,tar_path"):
|
|
3
|
+
with open(output_file, mode) as f:
|
|
4
|
+
if mode == 'w':
|
|
5
|
+
f.write(f"{title}\n")
|
|
6
|
+
for result in results:
|
|
7
|
+
f.write(f"{result['input_path']},{result['tar_path']}\n")
|
|
8
|
+
"""
|
|
9
|
+
output_file = "rmse_results.txt"
|
|
10
|
+
save_results([], output_file, mode='w')
|
|
11
|
+
result = {
|
|
12
|
+
'input_path': input_path ,
|
|
13
|
+
'tar_path': tar_path
|
|
14
|
+
}
|
|
15
|
+
save_results([result], output_file, mode='a')
|
|
16
|
+
|
|
17
|
+
df = pd.read_csv(csv_file, sep=" ",header=None)
|
|
18
|
+
sample_list = df.values.tolist()
|
|
19
|
+
self.paths = {
|
|
20
|
+
"input_path": [l[0] for l in self.sample_list],
|
|
21
|
+
"gt_path": [l[1] for l in self.sample_list]
|
|
22
|
+
}
|
|
23
|
+
"""
|
|
3
24
|
import os
|
|
4
25
|
import numpy as np
|
|
5
26
|
import pandas as pd
|
|
6
27
|
import glob
|
|
7
28
|
import datetime
|
|
8
|
-
from
|
|
9
|
-
from shancx import
|
|
10
|
-
|
|
11
|
-
# 将 getcheckdata 移到模块顶层
|
|
29
|
+
from shancx import Mul_sub_S,Mul_sub
|
|
30
|
+
from shancx import crDir
|
|
12
31
|
def getcheckdata(conf):
|
|
13
|
-
|
|
32
|
+
satPath = conf[0]
|
|
14
33
|
radar_dir_path = conf[1]
|
|
15
|
-
|
|
16
|
-
sat_imin = conf[3]
|
|
34
|
+
sat_imin = conf[2]
|
|
17
35
|
try:
|
|
18
|
-
satdata = np.load(
|
|
19
|
-
radarpth = glob.glob(f"{radar_dir_path}/{sat_imin[:4]}/{sat_imin[:8]}/CR_{
|
|
36
|
+
satdata = np.load(satPath)
|
|
37
|
+
radarpth = glob.glob(f"{radar_dir_path}/{sat_imin[:4]}/{sat_imin[:8]}/CR_{satPath.split('/')[-1][4:-4]}*.npy")[0]
|
|
20
38
|
radardata = np.load(radarpth)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if radardata.shape != (1, 256, 256) or satdata.shape != (9, 256, 256) or maskdata.shape != (1, 256, 256):
|
|
25
|
-
return None
|
|
26
|
-
df = pd.DataFrame({'sat_path': [iph], 'radar_path': [radarpth], 'mask_path': [maskpath]})
|
|
39
|
+
if radardata.shape != satdata.shape :
|
|
40
|
+
return
|
|
41
|
+
df = pd.DataFrame({'sat_path': [satPath], 'radar_path': [radarpth] })
|
|
27
42
|
return df
|
|
28
43
|
except Exception as e:
|
|
29
|
-
print(f"{
|
|
44
|
+
print(f"{satPath} can not load succeed: {e}")
|
|
30
45
|
return None
|
|
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
|
-
if data :
|
|
62
|
-
df = pd.concat(data)
|
|
63
|
-
dataframes[split_name].append(df)
|
|
64
|
-
else:
|
|
65
|
-
continue
|
|
66
|
-
|
|
67
|
-
train_df = pd.concat(dataframes['train']) if dataframes['train'] else pd.DataFrame()
|
|
68
|
-
test_df = pd.concat(dataframes['test']) if dataframes['test'] else pd.DataFrame()
|
|
69
|
-
valid_df = pd.concat(dataframes['valid']) if dataframes['valid'] else pd.DataFrame()
|
|
70
|
-
mkDir(savepath)
|
|
71
|
-
train_df.to_csv(f"{savepath}/df_train.csv", index=False, sep=',')
|
|
72
|
-
test_df.to_csv(f"{savepath}/df_test.csv", index=False, sep=',')
|
|
73
|
-
valid_df.to_csv(f"{savepath}/df_valid.csv", index=False, sep=',')
|
|
74
|
-
print(f"train_df {len(train_df)} test_df {len(test_df)} valid_df {len(valid_df)}")
|
|
75
|
-
print('complete!!!')
|
|
76
|
-
|
|
77
|
-
if __name__ == "__main__":
|
|
78
|
-
print()
|
|
79
|
-
# 定义路径和参数
|
|
80
|
-
# sat_dir_path = '/mnt/wtx_weather_forecast/scx/dataset/sample/sta2radar_N/AGRI_area_4KM'
|
|
81
|
-
# radar_dir_path = '/mnt/wtx_weather_forecast/scx/dataset/sample/sta2radar_N/radar_selectArea_4KM_256'
|
|
82
|
-
# maskTrainPathm = "/mnt/wtx_weather_forecast/scx/dataset/sample/sta2radar_N/mask_selectArea_4KM"
|
|
83
|
-
# savepath = '/mnt/wtx_weather_forecast/scx/dataset/sample/datalist_vmask_mask_530T'
|
|
84
|
-
# split_time = [datetime.datetime(2025, 2, 27),
|
|
85
|
-
# datetime.datetime(2025, 2, 28),
|
|
86
|
-
# datetime.datetime(2025, 3, 4)]
|
|
87
|
-
|
|
88
|
-
# # 定义时间范围
|
|
89
|
-
# start_time = datetime.datetime(2024,8,3)
|
|
90
|
-
# end_time = datetime.datetime(2025, 3, 5)
|
|
91
|
-
# timelist = pd.date_range(start=start_time, end=end_time, freq='30T').strftime('%Y%m%d%H%M').tolist()
|
|
92
|
-
|
|
93
|
-
# # 调用方法 1.split_time 2. timelist 3. 路径
|
|
94
|
-
# generate_data_list(sat_dir_path, radar_dir_path, maskTrainPathm, savepath, split_time, timelist)
|
|
95
|
-
|
|
96
|
-
|
|
46
|
+
def generateList(conf):
|
|
47
|
+
sat_dir_path, radar_dir_path, sat_imin= conf
|
|
48
|
+
satpath = glob.glob(f"{sat_dir_path}/{sat_imin[:4]}/{sat_imin[:8]}/SAT_{sat_imin}_*.npy")
|
|
49
|
+
satpath.sort()
|
|
50
|
+
if satpath:
|
|
51
|
+
datas = []
|
|
52
|
+
for path in satpath:
|
|
53
|
+
data = getcheckdata( (path,radar_dir_path,sat_imin))
|
|
54
|
+
datas.append(data)
|
|
55
|
+
datass = [i for i in datas if i is not None ]
|
|
56
|
+
if datass :
|
|
57
|
+
df = pd.concat(datass)
|
|
58
|
+
return df
|
|
59
|
+
else:
|
|
60
|
+
return None
|
|
61
|
+
import argparse
|
|
62
|
+
import datetime
|
|
63
|
+
import pandas as pd
|
|
64
|
+
def options():
|
|
65
|
+
parser = argparse.ArgumentParser(description='examdatabasedata')
|
|
66
|
+
parser.add_argument('--times', type=str, default='202502010000,202506220000')
|
|
67
|
+
parser.add_argument('--flag', type=str, default='val')
|
|
68
|
+
config= parser.parse_args()
|
|
69
|
+
print(config)
|
|
70
|
+
config.times = config.times.split(",")
|
|
71
|
+
if len(config.times) == 1:
|
|
72
|
+
config.times = [config.times[0], config.times[0]]
|
|
73
|
+
config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
|
|
74
|
+
datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
|
|
75
|
+
return config
|
|
97
76
|
"""
|
|
77
|
+
if __name__ == '__main__':
|
|
78
|
+
cfg = options()
|
|
79
|
+
sUTC = cfg.times[0]
|
|
80
|
+
eUTC = cfg.times[-1]
|
|
81
|
+
flag = cfg.flag
|
|
82
|
+
sat_dir_path ="./"
|
|
83
|
+
radar_dir_path = f"./"
|
|
84
|
+
timelist = pd.date_range(sUTC, eUTC, t=f"{flag}")
|
|
85
|
+
timeListfliter = timelist[timelist.month.isin([1,4,7,10])&(timelist.day<=15)]
|
|
86
|
+
savepath = f'/mnt/wtx_weather_forecast/SAT/GOES18train_N/0624_1'
|
|
87
|
+
crDir(savepath)
|
|
88
|
+
# 调用方法 1.split_time 2. timelist 3. 路径
|
|
89
|
+
dataL = Mul_sub(generateList,[ [sat_dir_path]
|
|
90
|
+
, [radar_dir_path]
|
|
91
|
+
, timelist
|
|
92
|
+
]
|
|
93
|
+
)
|
|
94
|
+
dataLs = [i for i in dataL if i is not None]
|
|
95
|
+
if flag =="trn":
|
|
96
|
+
train_df = pd.concat(dataLs)
|
|
97
|
+
crDir(savepath)
|
|
98
|
+
train_df.to_csv(f"{savepath}/df_train.csv", index=False, sep=',')
|
|
99
|
+
print(f"train_df {len(train_df)}")
|
|
100
|
+
print('complete!!!')
|
|
101
|
+
print(savepath)
|
|
102
|
+
if flag == "val":
|
|
103
|
+
valid_df = pd.concat(dataLs)
|
|
104
|
+
crDir(savepath)
|
|
105
|
+
valid_df.to_csv(f"{savepath}/df_valid.csv", index=False, sep=',')
|
|
106
|
+
print(f"valid_df {len(valid_df)}")
|
|
107
|
+
print('complete!!!')
|
|
108
|
+
print(savepath)
|
|
109
|
+
|
|
98
110
|
|
|
99
|
-
|
|
111
|
+
"""
|
|
112
|
+
"""
|
|
100
113
|
import os
|
|
101
114
|
import numpy as np
|
|
102
115
|
import pandas as pd
|
|
103
116
|
import glob
|
|
104
117
|
import datetime
|
|
105
|
-
from
|
|
106
|
-
from shancx import
|
|
107
|
-
from shancx.Plot import plotRadar,plotMat
|
|
108
|
-
|
|
109
|
-
# 将 getcheckdata 移到模块顶层
|
|
118
|
+
from shancx import Mul_sub_S,Mul_sub
|
|
119
|
+
from shancx import crDir
|
|
110
120
|
def getcheckdata(conf):
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
sat_imin = conf[3]
|
|
121
|
+
inputPath = conf[0]
|
|
122
|
+
target_dir_path = conf[1]
|
|
123
|
+
imin = conf[2]
|
|
115
124
|
try:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if radardata.shape != (1, 256, 256) or satdata.shape != (9, 256, 256) or maskdata.shape != (1, 256, 256):
|
|
123
|
-
return None
|
|
124
|
-
if np.mean(radardata) > 20 or np.mean(satdata) > 285 :
|
|
125
|
-
plotMat(satdata[0],name=f"satdata_{sat_imin}")
|
|
126
|
-
plotRadar(satdata[0],name=f"radar_{sat_imin}")
|
|
127
|
-
return None
|
|
128
|
-
df = pd.DataFrame({'sat_path': [iph], 'radar_path': [radarpth], 'mask_path': [maskpath]})
|
|
125
|
+
inputdata = np.load(inputPath)
|
|
126
|
+
targetpth = glob.glob(f"{target_dir_path}/{imin[:4]}/{imin[:8]}/analy_{inputPath.split('/')[-1][3:-4]}*.npy")[0]
|
|
127
|
+
targetdata = np.load(targetpth)
|
|
128
|
+
if inputdata.shape != targetdata.shape :
|
|
129
|
+
return
|
|
130
|
+
df = pd.DataFrame({'inputPath': [inputPath], 'targetpth': [targetpth] })
|
|
129
131
|
return df
|
|
130
132
|
except Exception as e:
|
|
131
|
-
print(f"{
|
|
133
|
+
print(f"{inputPath} can not load succeed: {e}")
|
|
132
134
|
return None
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
data =
|
|
142
|
-
data
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
135
|
+
def generateList(conf):
|
|
136
|
+
imin,input_dir_path, target_dir_path= conf
|
|
137
|
+
imin = imin.strftime("%Y%m%d%H%M")
|
|
138
|
+
targetpath = glob.glob(f"{input_dir_path}/{imin[:4]}/{imin[:8]}/EC_{imin}_*.npy")
|
|
139
|
+
targetpath.sort()
|
|
140
|
+
if targetpath:
|
|
141
|
+
datas = []
|
|
142
|
+
for path in targetpath:
|
|
143
|
+
data = getcheckdata( (path,target_dir_path,imin))
|
|
144
|
+
datas.append(data)
|
|
145
|
+
datass = [i for i in datas if i is not None ]
|
|
146
|
+
if datass :
|
|
147
|
+
df = pd.concat(datass)
|
|
148
|
+
return df
|
|
149
|
+
else:
|
|
150
|
+
return None
|
|
151
|
+
import argparse
|
|
152
|
+
import datetime
|
|
153
|
+
import pandas as pd
|
|
154
|
+
def options():
|
|
155
|
+
parser = argparse.ArgumentParser(description='examdatabasedata')
|
|
156
|
+
parser.add_argument('--times', type=str, default='202505210030,202505210130')
|
|
157
|
+
parser.add_argument('--flag', type=str, default='val')
|
|
158
|
+
parser.add_argument('--freq', type=str, default="1h")
|
|
159
|
+
config= parser.parse_args()
|
|
160
|
+
print(config)
|
|
161
|
+
config.times = config.times.split(",")
|
|
162
|
+
if len(config.times) == 1:
|
|
163
|
+
config.times = [config.times[0], config.times[0]]
|
|
164
|
+
config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
|
|
165
|
+
datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
|
|
166
|
+
return config
|
|
167
|
+
if __name__ == '__main__':
|
|
168
|
+
cfg = options()
|
|
169
|
+
sUTC = cfg.times[0]
|
|
170
|
+
eUTC = cfg.times[-1]
|
|
171
|
+
freq = cfg.freq
|
|
172
|
+
input_dir_path ="/mnt/wtx_weather_forecast/scx/smart_grid/train/clip_EC"
|
|
173
|
+
target_dir_path = f"/mnt/wtx_weather_forecast/scx/smart_grid/train/analy_1_256"
|
|
174
|
+
timelist = pd.date_range(sUTC, eUTC, freq=f"{freq}")
|
|
175
|
+
timeListfliter = timelist[timelist.month.isin([1,4,5,7,10])]
|
|
176
|
+
timeListfliter = list(timeListfliter)
|
|
177
|
+
savepath = f'/mnt/wtx_weather_forecast/SAT/downscale/0901'
|
|
178
|
+
crDir(savepath)
|
|
178
179
|
# 调用方法 1.split_time 2. timelist 3. 路径
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
|
|
181
|
+
dataL = Mul_sub(generateList,[ timeListfliter,[input_dir_path] , [target_dir_path]] )
|
|
182
|
+
dataLs = [i for i in dataL if i is not None]
|
|
183
|
+
pd.concat(dataLs).to_csv('train.txt', sep=' ', index=False)
|
|
184
|
+
a = pd.read_csv("./train.txt",sep=" ").values.tolist()
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
|