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/user/examMeso.py DELETED
@@ -1,293 +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 getPointBilinear3D(preData,df1,latArr,lonArr,decimal=2):
47
- df=copy.copy(df1)
48
- resolution=np.abs((latArr[0]-latArr[-1])/(len(latArr)-1))
49
- latIdxN = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)
50
- lonIdxW = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)
51
-
52
- latIdxS = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)+1
53
- lonIdxE = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)+1
54
-
55
- df["LatN"] = latArr[latIdxN]
56
- df["LonW"] = lonArr[lonIdxW]
57
- df["valNW"] = preData[:, latIdxN, lonIdxW]
58
-
59
- df["LatS"] = latArr[latIdxS]
60
- df["LonE"] = lonArr[lonIdxE]
61
- df["valSE"] = preData[:, latIdxS, lonIdxE]
62
- df["valNE"] = preData[:, latIdxN, lonIdxE]
63
- df["valSW"] = preData[:, latIdxS, lonIdxW]
64
- return df.apply(
65
- lambda x:np.round(bilinear(x["Lat"], x["Lon"], x["LatN"], x["LonW"], x["valNW"], x["LatN"], x["LonE"], x["valNE"], x["LatS"],
66
- x["LonW"], x["valSW"], x["LatS"], x["LonE"], x["valSE"]),decimals=decimal), axis=1)
67
-
68
-
69
- def getPointBilinear2D(preData,df1,latArr,lonArr,decimal=2):
70
- df=copy.copy(df1)
71
- resolution=np.abs((latArr[0]-latArr[-1])/(len(latArr)-1))
72
- latIdxN = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)
73
- lonIdxW = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)
74
-
75
- latIdxS = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)+1
76
- lonIdxE = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)+1
77
-
78
- df["LatN"] = latArr[latIdxN]
79
- df["LonW"] = lonArr[lonIdxW]
80
- df["valNW"] = preData[latIdxN, lonIdxW]
81
-
82
- df["LatS"] = latArr[latIdxS]
83
- df["LonE"] = lonArr[lonIdxE]
84
- df["valSE"] = preData[ latIdxS, lonIdxE]
85
- df["valNE"] = preData[ latIdxN, lonIdxE]
86
- df["valSW"] = preData[ latIdxS, lonIdxW]
87
- return df.apply(
88
- lambda x:np.round(bilinear(x["Lat"], x["Lon"], x["LatN"], x["LonW"], x["valNW"], x["LatN"], x["LonE"], x["valNE"], x["LatS"],
89
- x["LonW"], x["valSW"], x["LatS"], x["LonE"], x["valSE"]),decimals=decimal), axis=1)
90
- def getPointBilinear(preData,df1,latArr,lonArr,decimal=2):
91
- df=copy.copy(df1)
92
- resolution=np.abs((latArr[0]-latArr[-1])/(len(latArr)-1))
93
- latIdxN = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)
94
- lonIdxW = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)
95
-
96
- latIdxS = ((latArr[0] - df["Lat"]) / resolution).astype(np.int64)+1
97
- lonIdxE = ((df["Lon"] - lonArr[0]) / resolution).astype(np.int64)+1
98
-
99
- df["LatN"] = latArr[latIdxN]
100
- df["LonW"] = lonArr[lonIdxW]
101
- df["valNW"] = preData[..., latIdxN, lonIdxW]
102
-
103
- df["LatS"] = latArr[latIdxS]
104
- df["LonE"] = lonArr[lonIdxE]
105
- df["valSE"] = preData[..., latIdxS, lonIdxE]
106
- df["valNE"] = preData[..., latIdxN, lonIdxE]
107
- df["valSW"] = preData[..., latIdxS, lonIdxW]
108
- return df.apply(
109
- lambda x:np.round(bilinear(x["Lat"], x["Lon"], x["LatN"], x["LonW"], x["valNW"], x["LatN"], x["LonE"], x["valNE"], x["LatS"],
110
- x["LonW"], x["valSW"], x["LatS"], x["LonE"], x["valSE"]),decimals=decimal), axis=1)
111
-
112
-
113
-
114
- def classify10min(pre0):
115
- pre = copy.deepcopy(pre0)
116
- pre[pre0 < 0.1] = 0
117
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 0.5)] = 1
118
- pre[np.logical_and(pre0 > 0.5, pre0 <= 1)] = 2
119
- pre[np.logical_and(pre0 > 1, pre0 <= 2)] = 3
120
- pre[np.logical_and(pre0 > 2, pre0 <= 9990)] = 4
121
- pre[pre0 > 9990] = -1
122
- pre[np.isnan(pre0)] = -1
123
- return pre
124
-
125
- def classify30min(pre0):
126
- pre = copy.deepcopy(pre0)
127
- pre[pre0 < 0.1] = 0
128
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 2)] = 1
129
- pre[np.logical_and(pre0 > 2, pre0 <= 4)] = 2
130
- pre[np.logical_and(pre0 > 4, pre0 <= 10)] = 3
131
- pre[np.logical_and(pre0 > 10, pre0 <= 9990)] = 4
132
- pre[pre0 > 9990] = -1
133
- pre[np.isnan(pre0)] = -1
134
- return pre
135
-
136
- def classify1h(pre0):
137
- pre = copy.deepcopy(pre0)
138
- pre[pre0 < 0.1] = 0
139
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 2.5)] = 1
140
- pre[np.logical_and(pre0 > 2.5, pre0 <= 8)] = 2
141
- pre[np.logical_and(pre0 > 8, pre0 <= 16)] = 3
142
- pre[np.logical_and(pre0 > 16, pre0 <= 9990)] = 4
143
- pre[pre0 > 9990] = -1
144
- pre[np.isnan(pre0)] = -1
145
- return pre
146
-
147
- # classify 3h
148
- def classify3h(pre0):
149
- pre = copy.deepcopy(pre0)
150
- pre[pre0 < 0.1] = 0
151
- pre[np.logical_and(pre0 >= 0.1, pre0 <= 3)] = 1
152
- pre[np.logical_and(pre0 > 3, pre0 <= 10)] = 2
153
- pre[np.logical_and(pre0 > 10, pre0 <= 20)] = 3
154
- pre[np.logical_and(pre0 > 20, pre0 <= 9990)] = 4
155
- pre[pre0 > 9990] = -1
156
- pre[np.isnan(pre0)] = -1
157
- return pre
158
-
159
- def degMinSectoDeg(a):
160
- deg = int(a.split("°")[0])
161
- sec = int(a.split("'")[-1][:-1])
162
- min = int(a.replace(f"{deg}°","").replace(f"'{sec}\"",""))
163
- return deg+min/60+sec/3600
164
-
165
- def normal(data, min=None, max=None):
166
- if max is None:
167
- max = np.max(data)
168
- if min is None:
169
- min = np.min(data)
170
- rangeLat = max-min
171
- dataB = (data - min) / rangeLat
172
- return dataB
173
-
174
- def mkDir(path):
175
- if "." in path:
176
- os.makedirs(os.path.dirname(path),exist_ok=True)
177
- else:
178
- os.makedirs(path, exist_ok=True)
179
-
180
- def options():
181
- import argparse
182
- parser = argparse.ArgumentParser(description='hjn')
183
- parser.add_argument('--times', type=str, default='2018060700,2018060700')
184
- parser.add_argument('--isDebug',action='store_true',default=False)
185
- config= parser.parse_args()
186
- config.times = config.times.split(",")
187
- if len(config.times) == 1:
188
- config.times = [config.times[0], config.times[0]]
189
- config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
190
- datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
191
-
192
- return config
193
-
194
- class Evaluate():
195
- def __init__(self,num_class):
196
- self.num_class = num_class
197
- self.confusion_matrix = np.zeros((self.num_class,)*2)
198
-
199
- def Mean_Intersection_over_Union(self):
200
- MIoU = np.diag(self.confusion_matrix) / (
201
- np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) -
202
- np.diag(self.confusion_matrix))
203
- MIoU = np.nanmean(MIoU)
204
- return MIoU
205
-
206
- def _generate_matrix(self, gt_image, pre_image):
207
- mask = (gt_image >= 0) & (gt_image < self.num_class)
208
- label = self.num_class * gt_image[mask].astype('int') + pre_image[mask]
209
- count = np.bincount(label, minlength=self.num_class**2)
210
- confusion_matrix = count.reshape(self.num_class, self.num_class)
211
- return confusion_matrix
212
-
213
- def add_batch(self, gt_image, pre_image):
214
- assert gt_image.shape == pre_image.shape
215
- self.confusion_matrix += self._generate_matrix(gt_image, pre_image)
216
-
217
- class exam_report():
218
- def __init__(self,mat):
219
- self.mat=mat
220
- self.TS=None
221
- self.PC=None
222
- self.PO = None
223
- self.FAR = None
224
- self.RMSE = None
225
- self.MSE = None
226
- self.MAE = None
227
-
228
- def __str__(self):
229
- 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)
230
-
231
- # calculate PC PO FAR TS,check CMA word
232
- def calcuTSFARPOS(self,rmse=np.nan,mse=np.nan,mae=np.nan):
233
- tsList = []
234
- for i in range(1, 5):
235
- ts = self.mat[i, i] / (np.sum(self.mat[:i, i])+np.sum(self.mat[i, :i+1]))
236
- tsList.append(ts)
237
- self.TS = tsList
238
- # print("TS", np.round(tsList,4))
239
- matIsRain = self.addRainMatrix(self.mat)
240
- self.PC = (matIsRain[1, 1]) / (np.sum(matIsRain)-matIsRain[0, 0])
241
- self.POsm = self.mat[1,:1].sum() / self.mat[1,:2].sum()
242
- self.POm = self.mat[2,:2].sum() / self.mat[2,:3].sum()
243
- self.POh = self.mat[3,:3].sum() / self.mat[3,:4].sum()
244
- self.POs = self.mat[4,:4].sum() /self.mat[4,:5].sum()
245
- self.PO = matIsRain[1, 0] / (matIsRain[1, 0] + matIsRain[0, 0])
246
- self.FARsm = self.mat[:1,1].sum() / self.mat[:2,1].sum()
247
- self.FARm = self.mat[:2,2].sum() / self.mat[:3,2].sum()
248
- self.FARh = self.mat[:3,3].sum() / self.mat[:4,3].sum()
249
- self.FARs = self.mat[:4,4].sum() / self.mat[:5,4].sum()
250
- self.FAR = matIsRain[0, 1] / (matIsRain[0, 1] + matIsRain[0, 0])
251
- self.RMSE = rmse
252
- self.MSE = mse
253
- self.MAE = mae
254
-
255
- return {"TS":self.TS,"PC":self.PC,"PO":self.PO, "FAR":self.FAR,"RMSE":rmse,"MSE":mse,"MAE":mae,
256
- "FARsm":self.FARsm,"FARm":self.FARm,"FARh":self.FARh,"FARs":self.FARs,"POsm":self.POsm,"POm":self.POm,
257
- "POh":self.POh,"POs":self.POs}
258
-
259
- # in oder to calculate PC PO FAR ,add up all rain case
260
- def addRainMatrix(self,mat):
261
- noRainRow = mat[0, :]
262
- RainRow = mat[1:, :]
263
- RainRow = np.sum(RainRow, axis=0)
264
- matIsRain = np.asarray([[np.sum(RainRow[1:]), np.sum(noRainRow[1:])], [RainRow[0], noRainRow[0]]])
265
- return matIsRain
266
-
267
- # inorder to speed up exam,i calculate score in mat
268
- def printPRFS(self,mat):
269
- print(mat)
270
- resultDF = pd.DataFrame(columns=["precision", "recall", "f1-score", "support"])
271
- for i in range(5):
272
- precision = mat[i, i] / np.sum(mat[:, i] + 1e-100)
273
- recall = mat[i, i] / np.sum(mat[i, :] + 1e-100)
274
- accuracy = (np.sum(mat) - np.sum(mat[i, :]) - np.sum(mat[:, i]) + 2 * mat[i, i]) / (np.sum(mat) + 1e-100)
275
- F1_Score = 2 * precision * recall / (precision + recall + 1e-100)
276
- support = np.sum(mat[i, :])
277
- tmpDF = pd.DataFrame(np.asarray([[precision, recall, F1_Score, support]]),
278
- columns=["precision", "recall", "f1-score", "support"], index=[i + 1])
279
- # print(tmpDF)
280
- resultDF = pd.concat([resultDF, tmpDF], axis=0)
281
-
282
- # resultDF=pd.concat([resultDF,tmpDF],axis=0)
283
- # resultDF
284
- print(resultDF)
285
-
286
- # 输出结果
287
- def printResult(self,label_test,predict_results):
288
- print("准确率", accuracy_score(label_test,predict_results))
289
- conf_mat = confusion_matrix(label_test,predict_results)
290
- print(conf_mat)
291
- print(classification_report(label_test,predict_results))
292
- return conf_mat[-5:, -5:]
293
-
shancx/user/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/user/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
-