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.
Files changed (166) hide show
  1. shancx/3D/__init__.py +25 -0
  2. shancx/Algo/Class.py +11 -0
  3. shancx/Algo/CudaPrefetcher1.py +112 -0
  4. shancx/Algo/Fake_image.py +24 -0
  5. shancx/Algo/Hsml.py +391 -0
  6. shancx/Algo/L2Loss.py +10 -0
  7. shancx/Algo/MetricTracker.py +132 -0
  8. shancx/Algo/Normalize.py +66 -0
  9. shancx/Algo/OptimizerWScheduler.py +38 -0
  10. shancx/Algo/Rmageresize.py +79 -0
  11. shancx/Algo/Savemodel.py +33 -0
  12. shancx/Algo/SmoothL1_losses.py +27 -0
  13. shancx/Algo/Tqdm.py +62 -0
  14. shancx/Algo/__init__.py +121 -0
  15. shancx/Algo/checknan.py +28 -0
  16. shancx/Algo/iouJU.py +83 -0
  17. shancx/Algo/mask.py +25 -0
  18. shancx/Algo/psnr.py +9 -0
  19. shancx/Algo/ssim.py +70 -0
  20. shancx/Algo/structural_similarity.py +308 -0
  21. shancx/Algo/tool.py +704 -0
  22. shancx/Calmetrics/__init__.py +97 -0
  23. shancx/Calmetrics/calmetrics.py +14 -0
  24. shancx/Calmetrics/calmetricsmatrixLib.py +147 -0
  25. shancx/Calmetrics/rmseR2score.py +35 -0
  26. shancx/Clip/__init__.py +50 -0
  27. shancx/Cmd.py +126 -0
  28. shancx/Config_.py +26 -0
  29. shancx/Df/DataFrame.py +11 -2
  30. shancx/Df/__init__.py +17 -0
  31. shancx/Df/tool.py +0 -0
  32. shancx/Diffm/Psamples.py +18 -0
  33. shancx/Diffm/__init__.py +0 -0
  34. shancx/Diffm/test.py +207 -0
  35. shancx/Doc/__init__.py +214 -0
  36. shancx/E/__init__.py +178 -152
  37. shancx/Fillmiss/__init__.py +0 -0
  38. shancx/Fillmiss/imgidwJU.py +46 -0
  39. shancx/Fillmiss/imgidwLatLonJU.py +82 -0
  40. shancx/Gpu/__init__.py +55 -0
  41. shancx/H9/__init__.py +126 -0
  42. shancx/H9/ahi_read_hsd.py +877 -0
  43. shancx/H9/ahisearchtable.py +298 -0
  44. shancx/H9/geometry.py +2439 -0
  45. shancx/Hug/__init__.py +81 -0
  46. shancx/Inst.py +22 -0
  47. shancx/Lib.py +31 -0
  48. shancx/Mos/__init__.py +37 -0
  49. shancx/NN/__init__.py +235 -106
  50. shancx/Path1.py +161 -0
  51. shancx/Plot/GlobMap.py +276 -116
  52. shancx/Plot/__init__.py +491 -1
  53. shancx/Plot/draw_day_CR_PNG.py +4 -21
  54. shancx/Plot/exam.py +116 -0
  55. shancx/Plot/plotGlobal.py +325 -0
  56. shancx/{radar_nmc.py → Plot/radarNmc.py} +4 -34
  57. shancx/{subplots_single_china_map.py → Plot/single_china_map.py} +1 -1
  58. shancx/Point.py +46 -0
  59. shancx/QC.py +223 -0
  60. shancx/RdPzl/__init__.py +32 -0
  61. shancx/Read.py +72 -0
  62. shancx/Resize.py +79 -0
  63. shancx/SN/__init__.py +62 -123
  64. shancx/Time/GetTime.py +9 -3
  65. shancx/Time/__init__.py +66 -1
  66. shancx/Time/timeCycle.py +302 -0
  67. shancx/Time/tool.py +0 -0
  68. shancx/Train/__init__.py +74 -0
  69. shancx/Train/makelist.py +187 -0
  70. shancx/Train/multiGpu.py +27 -0
  71. shancx/Train/prepare.py +161 -0
  72. shancx/Train/renet50.py +157 -0
  73. shancx/ZR.py +12 -0
  74. shancx/__init__.py +333 -262
  75. shancx/args.py +27 -0
  76. shancx/bak.py +768 -0
  77. shancx/df2database.py +62 -2
  78. shancx/geosProj.py +80 -0
  79. shancx/info.py +38 -0
  80. shancx/netdfJU.py +231 -0
  81. shancx/sendM.py +59 -0
  82. shancx/tensBoard/__init__.py +28 -0
  83. shancx/wait.py +246 -0
  84. {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/METADATA +15 -5
  85. shancx-1.9.33.218.dist-info/RECORD +91 -0
  86. {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/WHEEL +1 -1
  87. my_timer_decorator/__init__.py +0 -10
  88. shancx/Dsalgor/__init__.py +0 -19
  89. shancx/E/DFGRRIB.py +0 -30
  90. shancx/EN/DFGRRIB.py +0 -30
  91. shancx/EN/__init__.py +0 -148
  92. shancx/FileRead.py +0 -44
  93. shancx/Gray2RGB.py +0 -86
  94. shancx/M/__init__.py +0 -137
  95. shancx/MN/__init__.py +0 -133
  96. shancx/N/__init__.py +0 -131
  97. shancx/Plot/draw_day_CR_PNGUS.py +0 -206
  98. shancx/Plot/draw_day_CR_SVG.py +0 -275
  99. shancx/Plot/draw_day_pre_PNGUS.py +0 -205
  100. shancx/Plot/glob_nation_map.py +0 -116
  101. shancx/Plot/radar_nmc.py +0 -61
  102. shancx/Plot/radar_nmc_china_map_compare1.py +0 -50
  103. shancx/Plot/radar_nmc_china_map_f.py +0 -121
  104. shancx/Plot/radar_nmc_us_map_f.py +0 -128
  105. shancx/Plot/subplots_compare_devlop.py +0 -36
  106. shancx/Plot/subplots_single_china_map.py +0 -45
  107. shancx/S/__init__.py +0 -138
  108. shancx/W/__init__.py +0 -132
  109. shancx/WN/__init__.py +0 -132
  110. shancx/code.py +0 -331
  111. shancx/draw_day_CR_PNG.py +0 -200
  112. shancx/draw_day_CR_PNGUS.py +0 -206
  113. shancx/draw_day_CR_SVG.py +0 -275
  114. shancx/draw_day_pre_PNGUS.py +0 -205
  115. shancx/makenetCDFN.py +0 -42
  116. shancx/mkIMGSCX.py +0 -92
  117. shancx/netCDF.py +0 -130
  118. shancx/radar_nmc_china_map_compare1.py +0 -50
  119. shancx/radar_nmc_china_map_f.py +0 -125
  120. shancx/radar_nmc_us_map_f.py +0 -67
  121. shancx/subplots_compare_devlop.py +0 -36
  122. shancx/tool.py +0 -18
  123. shancx/user/H8mess.py +0 -317
  124. shancx/user/__init__.py +0 -137
  125. shancx/user/cinradHJN.py +0 -496
  126. shancx/user/examMeso.py +0 -293
  127. shancx/user/hjnDAAS.py +0 -26
  128. shancx/user/hjnFTP.py +0 -81
  129. shancx/user/hjnGIS.py +0 -320
  130. shancx/user/hjnGPU.py +0 -21
  131. shancx/user/hjnIDW.py +0 -68
  132. shancx/user/hjnKDTree.py +0 -75
  133. shancx/user/hjnLAPSTransform.py +0 -47
  134. shancx/user/hjnMiscellaneous.py +0 -182
  135. shancx/user/hjnProj.py +0 -162
  136. shancx/user/inotify.py +0 -41
  137. shancx/user/matplotlibMess.py +0 -87
  138. shancx/user/mkNCHJN.py +0 -623
  139. shancx/user/newTypeRadar.py +0 -492
  140. shancx/user/test.py +0 -6
  141. shancx/user/tlogP.py +0 -129
  142. shancx/util_log.py +0 -33
  143. shancx/wtx/H8mess.py +0 -315
  144. shancx/wtx/__init__.py +0 -151
  145. shancx/wtx/cinradHJN.py +0 -496
  146. shancx/wtx/colormap.py +0 -64
  147. shancx/wtx/examMeso.py +0 -298
  148. shancx/wtx/hjnDAAS.py +0 -26
  149. shancx/wtx/hjnFTP.py +0 -81
  150. shancx/wtx/hjnGIS.py +0 -330
  151. shancx/wtx/hjnGPU.py +0 -21
  152. shancx/wtx/hjnIDW.py +0 -68
  153. shancx/wtx/hjnKDTree.py +0 -75
  154. shancx/wtx/hjnLAPSTransform.py +0 -47
  155. shancx/wtx/hjnLog.py +0 -78
  156. shancx/wtx/hjnMiscellaneous.py +0 -201
  157. shancx/wtx/hjnProj.py +0 -161
  158. shancx/wtx/inotify.py +0 -41
  159. shancx/wtx/matplotlibMess.py +0 -87
  160. shancx/wtx/mkNCHJN.py +0 -613
  161. shancx/wtx/newTypeRadar.py +0 -492
  162. shancx/wtx/test.py +0 -6
  163. shancx/wtx/tlogP.py +0 -129
  164. shancx-1.8.92.dist-info/RECORD +0 -99
  165. /shancx/{Dsalgor → Algo}/dsalgor.py +0 -0
  166. {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/top_level.txt +0 -0
shancx/wtx/examMeso.py DELETED
@@ -1,298 +0,0 @@
1
-
2
- import numpy as np
3
- import copy
4
- import os
5
- import datetime
6
- from sklearn.metrics import accuracy_score, confusion_matrix, classification_report
7
- import pandas as pd
8
-
9
- def bilinear(y, x, yul, xul, vul,yur, xur, vur, ydl, xdl, vdl, ydr, xdr,vdr):
10
- u = linear(x, xul, vul, xur, vur)
11
- yu = linear(x, xul, yul, xur, yur)
12
- b = linear(x, xdl, vdl, xdr, vdr)
13
- yb = linear(x, xdl, ydl, xdr, ydr)
14
- v = linear(y, yu, u, yb, b)
15
- return v
16
-
17
-
18
- def linear(x, xl, vl0, xr, vr0):
19
- vl=vl0
20
- vr=vr0
21
- if vl == vr:
22
- v=vl
23
- else:
24
- dxl = x - xl
25
- drl = xr - xl
26
- v = dxl * (vr - vl) / drl + vl
27
- return v
28
-
29
- def getPoint3D(pre,df,lat0,lon0,resolution,decimal=1):
30
-
31
- latIdx = ((lat0 - df["Lat"]) / resolution + 0.5).astype(np.int64)
32
- lonIdx = ((df["Lon"] - lon0) / resolution + 0.5).astype(np.int64)
33
- return pre[:, latIdx, lonIdx].round(decimals=decimal)
34
-
35
-
36
- def getPoint2D(pre, df, lat0, lon0, resolution, decimal=1):
37
- latIdx = ((lat0 - df["Lat"]) / resolution + 0.5).astype(np.int64)
38
- lonIdx = ((df["Lon"] - lon0) / resolution + 0.5).astype(np.int64)
39
- return pre[latIdx, lonIdx].round(decimals=decimal)
40
-
41
- def getPoint(pre, df, lat0, lon0, resolution, decimal=1):
42
- latIdx = ((lat0 - df["Lat"]) / resolution + 0.5).astype(np.int64)
43
- lonIdx = ((df["Lon"] - lon0) / resolution + 0.5).astype(np.int64)
44
- return pre[...,latIdx, lonIdx].round(decimals=decimal)
45
-
46
- def getPointIdx(df, lat0, lon0, resolution):
47
- latIdx = ((lat0 - df["Lat"]) / resolution + 0.5).astype(np.int64)
48
- lonIdx = ((df["Lon"] - lon0) / resolution + 0.5).astype(np.int64)
49
- return latIdx, lonIdx
50
-
51
- def getPointBilinear3D(preData,df1,latArr,lonArr,decimal=2):
52
- df=copy.copy(df1)
53
- resolution=np.abs((latArr[0]-latArr[-1])/(len(latArr)-1))
54
- latIdxN = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)
55
- lonIdxW = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)
56
-
57
- latIdxS = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)+1
58
- lonIdxE = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)+1
59
-
60
- df["LatN"] = latArr[latIdxN]
61
- df["LonW"] = lonArr[lonIdxW]
62
- df["valNW"] = preData[:, latIdxN, lonIdxW]
63
-
64
- df["LatS"] = latArr[latIdxS]
65
- df["LonE"] = lonArr[lonIdxE]
66
- df["valSE"] = preData[:, latIdxS, lonIdxE]
67
- df["valNE"] = preData[:, latIdxN, lonIdxE]
68
- df["valSW"] = preData[:, latIdxS, lonIdxW]
69
- return df.apply(
70
- lambda x:np.round(bilinear(x["Lat"], x["Lon"], x["LatN"], x["LonW"], x["valNW"], x["LatN"], x["LonE"], x["valNE"], x["LatS"],
71
- x["LonW"], x["valSW"], x["LatS"], x["LonE"], x["valSE"]),decimals=decimal), axis=1)
72
-
73
-
74
- def getPointBilinear2D(preData,df1,latArr,lonArr,decimal=2):
75
- df=copy.copy(df1)
76
- resolution=np.abs((latArr[0]-latArr[-1])/(len(latArr)-1))
77
- latIdxN = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)
78
- lonIdxW = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)
79
-
80
- latIdxS = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)+1
81
- lonIdxE = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)+1
82
-
83
- df["LatN"] = latArr[latIdxN]
84
- df["LonW"] = lonArr[lonIdxW]
85
- df["valNW"] = preData[latIdxN, lonIdxW]
86
-
87
- df["LatS"] = latArr[latIdxS]
88
- df["LonE"] = lonArr[lonIdxE]
89
- df["valSE"] = preData[ latIdxS, lonIdxE]
90
- df["valNE"] = preData[ latIdxN, lonIdxE]
91
- df["valSW"] = preData[ latIdxS, lonIdxW]
92
- return df.apply(
93
- lambda x:np.round(bilinear(x["Lat"], x["Lon"], x["LatN"], x["LonW"], x["valNW"], x["LatN"], x["LonE"], x["valNE"], x["LatS"],
94
- x["LonW"], x["valSW"], x["LatS"], x["LonE"], x["valSE"]),decimals=decimal), axis=1)
95
- def getPointBilinear(preData,df1,latArr,lonArr,decimal=2):
96
- df=copy.copy(df1)
97
- resolution=np.abs((latArr[0]-latArr[-1])/(len(latArr)-1))
98
- latIdxN = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)
99
- lonIdxW = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)
100
-
101
- latIdxS = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)+1
102
- lonIdxE = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)+1
103
-
104
- df["LatN"] = latArr[latIdxN]
105
- df["LonW"] = lonArr[lonIdxW]
106
- df["valNW"] = preData[..., latIdxN, lonIdxW]
107
-
108
- df["LatS"] = latArr[latIdxS]
109
- df["LonE"] = lonArr[lonIdxE]
110
- df["valSE"] = preData[..., latIdxS, lonIdxE]
111
- df["valNE"] = preData[..., latIdxN, lonIdxE]
112
- df["valSW"] = preData[..., latIdxS, lonIdxW]
113
- return df.apply(
114
- lambda x:np.round(bilinear(x["Lat"], x["Lon"], x["LatN"], x["LonW"], x["valNW"], x["LatN"], x["LonE"], x["valNE"], x["LatS"],
115
- x["LonW"], x["valSW"], x["LatS"], x["LonE"], x["valSE"]),decimals=decimal), axis=1)
116
-
117
-
118
-
119
- def classify10min(pre0):
120
- pre = copy.deepcopy(pre0)
121
- pre[pre0 < 0.1] = 0
122
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 0.5)] = 1
123
- pre[np.logical_and(pre0 > 0.5, pre0 <= 1)] = 2
124
- pre[np.logical_and(pre0 > 1, pre0 <= 2)] = 3
125
- pre[np.logical_and(pre0 > 2, pre0 <= 9990)] = 4
126
- pre[pre0 > 9990] = -1
127
- pre[np.isnan(pre0)] = -1
128
- return pre
129
-
130
- def classify30min(pre0):
131
- pre = copy.deepcopy(pre0)
132
- pre[pre0 < 0.1] = 0
133
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 2)] = 1
134
- pre[np.logical_and(pre0 > 2, pre0 <= 4)] = 2
135
- pre[np.logical_and(pre0 > 4, pre0 <= 10)] = 3
136
- pre[np.logical_and(pre0 > 10, pre0 <= 9990)] = 4
137
- pre[pre0 > 9990] = -1
138
- pre[np.isnan(pre0)] = -1
139
- return pre
140
-
141
- def classify1h(pre0):
142
- pre = copy.deepcopy(pre0)
143
- pre[pre0 < 0.1] = 0
144
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 2.5)] = 1
145
- pre[np.logical_and(pre0 > 2.5, pre0 <= 8)] = 2
146
- pre[np.logical_and(pre0 > 8, pre0 <= 16)] = 3
147
- pre[np.logical_and(pre0 > 16, pre0 <= 9990)] = 4
148
- pre[pre0 > 9990] = -1
149
- pre[np.isnan(pre0)] = -1
150
- return pre
151
-
152
- # classify 3h
153
- def classify3h(pre0):
154
- pre = copy.deepcopy(pre0)
155
- pre[pre0 < 0.1] = 0
156
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 3)] = 1
157
- pre[np.logical_and(pre0 > 3, pre0 <= 10)] = 2
158
- pre[np.logical_and(pre0 > 10, pre0 <= 20)] = 3
159
- pre[np.logical_and(pre0 > 20, pre0 <= 9990)] = 4
160
- pre[pre0 > 9990] = -1
161
- pre[np.isnan(pre0)] = -1
162
- return pre
163
-
164
- def degMinSectoDeg(a):
165
- deg = int(a.split("°")[0])
166
- sec = int(a.split("'")[-1][:-1])
167
- min = int(a.replace(f"{deg}°","").replace(f"'{sec}\"",""))
168
- return deg+min/60+sec/3600
169
-
170
- def normal(data, min=None, max=None):
171
- if max is None:
172
- max = np.max(data)
173
- if min is None:
174
- min = np.min(data)
175
- rangeLat = max-min
176
- dataB = (data - min) / rangeLat
177
- return dataB
178
-
179
- def mkDir(path):
180
- if "." in path:
181
- os.makedirs(os.path.dirname(path),exist_ok=True)
182
- else:
183
- os.makedirs(path, exist_ok=True)
184
-
185
- def options():
186
- import argparse
187
- parser = argparse.ArgumentParser(description='hjn')
188
- parser.add_argument('--times', type=str, default='2018060700,2018060700')
189
- parser.add_argument('--isDebug',action='store_true',default=False)
190
- config= parser.parse_args()
191
- config.times = config.times.split(",")
192
- if len(config.times) == 1:
193
- config.times = [config.times[0], config.times[0]]
194
- config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
195
- datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
196
-
197
- return config
198
-
199
- class Evaluate():
200
- def __init__(self,num_class):
201
- self.num_class = num_class
202
- self.confusion_matrix = np.zeros((self.num_class,)*2)
203
-
204
- def Mean_Intersection_over_Union(self):
205
- MIoU = np.diag(self.confusion_matrix) / (
206
- np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) -
207
- np.diag(self.confusion_matrix))
208
- MIoU = np.nanmean(MIoU)
209
- return MIoU
210
-
211
- def _generate_matrix(self, gt_image, pre_image):
212
- mask = (gt_image >= 0) & (gt_image < self.num_class)
213
- label = self.num_class * gt_image[mask].astype('int') + pre_image[mask]
214
- count = np.bincount(label, minlength=self.num_class**2)
215
- confusion_matrix = count.reshape(self.num_class, self.num_class)
216
- return confusion_matrix
217
-
218
- def add_batch(self, gt_image, pre_image):
219
- assert gt_image.shape == pre_image.shape
220
- self.confusion_matrix += self._generate_matrix(gt_image, pre_image)
221
-
222
- class exam_report():
223
- def __init__(self,mat):
224
- self.mat=mat
225
- self.TS=None
226
- self.PC=None
227
- self.PO = None
228
- self.FAR = None
229
- self.RMSE = None
230
- self.MSE = None
231
- self.MAE = None
232
-
233
- def __str__(self):
234
- return "小:%.4f 中:%.4f 大:%.4f 暴:%.4f PC:%.4f PO:%.4f FAR:%.4f RMSE:%.4f MSE:%.4f MAE:%.4f"%(self.TS[0],self.TS[1],self.TS[2],self.TS[3],self.PC,self.PO,self.FAR,self.RMSE,self.MSE,self.MAE)
235
-
236
- # calculate PC PO FAR TS,check CMA word
237
- def calcuTSFARPOS(self,rmse=np.nan,mse=np.nan,mae=np.nan):
238
- tsList = []
239
- for i in range(1, 5):
240
- ts = self.mat[i, i] / (np.sum(self.mat[:i, i])+np.sum(self.mat[i, :i+1]))
241
- tsList.append(ts)
242
- self.TS = tsList
243
- # print("TS", np.round(tsList,4))
244
- matIsRain = self.addRainMatrix(self.mat)
245
- self.PC = (matIsRain[1, 1]) / (np.sum(matIsRain)-matIsRain[0, 0])
246
- self.POsm = self.mat[1,:1].sum() / self.mat[1,:2].sum()
247
- self.POm = self.mat[2,:2].sum() / self.mat[2,:3].sum()
248
- self.POh = self.mat[3,:3].sum() / self.mat[3,:4].sum()
249
- self.POs = self.mat[4,:4].sum() /self.mat[4,:5].sum()
250
- self.PO = matIsRain[1, 0] / (matIsRain[1, 0] + matIsRain[0, 0])
251
- self.FARsm = self.mat[:1,1].sum() / self.mat[:2,1].sum()
252
- self.FARm = self.mat[:2,2].sum() / self.mat[:3,2].sum()
253
- self.FARh = self.mat[:3,3].sum() / self.mat[:4,3].sum()
254
- self.FARs = self.mat[:4,4].sum() / self.mat[:5,4].sum()
255
- self.FAR = matIsRain[0, 1] / (matIsRain[0, 1] + matIsRain[0, 0])
256
- self.RMSE = rmse
257
- self.MSE = mse
258
- self.MAE = mae
259
-
260
- return {"TS":self.TS,"PC":self.PC,"PO":self.PO, "FAR":self.FAR,"RMSE":rmse,"MSE":mse,"MAE":mae,
261
- "FARsm":self.FARsm,"FARm":self.FARm,"FARh":self.FARh,"FARs":self.FARs,"POsm":self.POsm,"POm":self.POm,
262
- "POh":self.POh,"POs":self.POs}
263
-
264
- # in oder to calculate PC PO FAR ,add up all rain case
265
- def addRainMatrix(self,mat):
266
- noRainRow = mat[0, :]
267
- RainRow = mat[1:, :]
268
- RainRow = np.sum(RainRow, axis=0)
269
- matIsRain = np.asarray([[np.sum(RainRow[1:]), np.sum(noRainRow[1:])], [RainRow[0], noRainRow[0]]])
270
- return matIsRain
271
-
272
- # inorder to speed up exam,i calculate score in mat
273
- def printPRFS(self,mat):
274
- print(mat)
275
- resultDF = pd.DataFrame(columns=["precision", "recall", "f1-score", "support"])
276
- for i in range(5):
277
- precision = mat[i, i] / np.sum(mat[:, i] + 1e-100)
278
- recall = mat[i, i] / np.sum(mat[i, :] + 1e-100)
279
- accuracy = (np.sum(mat) - np.sum(mat[i, :]) - np.sum(mat[:, i]) + 2 * mat[i, i]) / (np.sum(mat) + 1e-100)
280
- F1_Score = 2 * precision * recall / (precision + recall + 1e-100)
281
- support = np.sum(mat[i, :])
282
- tmpDF = pd.DataFrame(np.asarray([[precision, recall, F1_Score, support]]),
283
- columns=["precision", "recall", "f1-score", "support"], index=[i + 1])
284
- # print(tmpDF)
285
- resultDF = pd.concat([resultDF, tmpDF], axis=0)
286
-
287
- # resultDF=pd.concat([resultDF,tmpDF],axis=0)
288
- # resultDF
289
- print(resultDF)
290
-
291
- # 输出结果
292
- def printResult(self,label_test,predict_results):
293
- print("准确率", accuracy_score(label_test,predict_results))
294
- conf_mat = confusion_matrix(label_test,predict_results)
295
- print(conf_mat)
296
- print(classification_report(label_test,predict_results))
297
- return conf_mat[-5:, -5:]
298
-
shancx/wtx/hjnDAAS.py DELETED
@@ -1,26 +0,0 @@
1
- import hashlib
2
- import time
3
- def DAA_example(userId,pwd,params):
4
- t = time.time()
5
- para = f"serviceNodeId=NMIC_MUSIC_CMADAAS&userId={userId}&{params}"
6
- timeStep = "timestamp=%s000"%int(t)
7
- noncemd5 = hashlib.md5()
8
- noncemd5.update(timeStep.encode('utf-8'))
9
- nonce="nonce=%s"%(noncemd5.hexdigest().upper())
10
- pwd = f"pwd={pwd}"
11
- paraSK = "&".join([timeStep,nonce,pwd])
12
- allPara = para+"&"+paraSK
13
- list= allPara.split("&")
14
- list.sort()
15
- paramSort = "&".join(list)
16
- md5 = hashlib.md5()
17
- md5.update(paramSort.encode('utf-8'))
18
- sign ="sign="+md5.hexdigest().upper()
19
- prefix = "http://10.40.17.54/music-ws/api?"
20
- url = prefix + para + "&"+"&".join([timeStep,nonce,sign])
21
- return url
22
-
23
- if __name__ == '__main__':
24
- print(DAA_example("a","b","c=1&d=1"))
25
-
26
-
shancx/wtx/hjnFTP.py DELETED
@@ -1,81 +0,0 @@
1
- import os
2
- from ftplib import FTP
3
- import traceback
4
-
5
- class MyFtp:
6
-
7
- ftp = FTP()
8
-
9
- def __init__(self,host,port=21,debugLevel=2):
10
- self.ftp.connect(host,port)
11
- self.ftp.set_debuglevel(debugLevel) # 打开调试级别2,显示详细信息
12
-
13
- def login(self,username,pwd):
14
-
15
- self.ftp.login(username,pwd)
16
- # print(self.ftp.welcome)
17
-
18
- def downloadFile(self,localpath,remotepath,filename,isOverwrite=True):
19
- dstPath = os.path.join(localpath, filename)
20
- if os.path.exists(dstPath):
21
- if not isOverwrite:
22
- print(dstPath, "exists")
23
- else:
24
- self.ftp.cwd(remotepath)
25
- if filename in self.ftp.nlst():
26
- file_handle = open(dstPath,"wb").write
27
- self.ftp.retrbinary('RETR %s' % os.path.basename(filename),file_handle,blocksize=1024)
28
- else:
29
- print("%s in ftp missing"%filename)
30
- else:
31
- self.ftp.cwd(remotepath)
32
- if filename in self.ftp.nlst():
33
- file_handle = open(dstPath, "wb").write # 以写模式在本地打开文件
34
- self.ftp.retrbinary('RETR %s' % os.path.basename(filename), file_handle, blocksize=1024)
35
- else:
36
- print("%s in ftp missing" % filename)
37
-
38
- def upload_file(self,src_file, des_file):
39
- try:
40
- des_dirs = self.get_dirs(des_file)
41
- print(des_dirs)
42
- for d in des_dirs:
43
- if d not in self.ftp.nlst():
44
- self.ftp.mkd(d)
45
- self.ftp.cwd(d)
46
- bufsize = 1024
47
- f = open(src_file, 'rb')
48
- des_file_name = os.path.basename(des_file)
49
- self.ftp.storbinary('STOR '+des_file_name, f, bufsize)
50
- print('upload %s success! '% des_file)
51
- except Exception as e:
52
- print('upload %s failed! ' % des_file)
53
- print(traceback.format_exc())
54
- def upload_fileTQW(self,src_file, des_path,fileName,reletive_path=""):
55
- try:
56
- self.ftp.cwd(des_path)
57
- for d in reletive_path.split(os.path.sep):
58
- if d not in self.ftp.nlst():
59
- self.ftp.mkd(d)
60
- self.ftp.cwd(d)
61
- bufsize = 1024
62
- f = open(src_file, 'rb')
63
- des_file_name = os.path.basename(fileName)
64
- self.ftp.storbinary('STOR '+des_file_name, f, bufsize)
65
- print('upload %s success! '% des_file_name)
66
- except Exception as e:
67
- print('upload %s failed! ' % des_file_name)
68
- print(traceback.format_exc())
69
-
70
- def get_dirs(self,filepath, isFile=True):
71
-
72
- dirs = filepath.strip("/").split(os.path.sep)
73
- if isFile:
74
- return dirs[:-1]
75
- else:
76
- return dirs
77
-
78
- def close(self):
79
- self.ftp.set_debuglevel(0) # 关闭调试
80
- self.ftp.quit()
81
-