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
@@ -1,201 +0,0 @@
1
- import numpy as np
2
- import os
3
- import datetime
4
- import argparse
5
- from hjnwtx.mkNCHJN import LeftTopCornerPairArr
6
- import time
7
- from dateutil.relativedelta import relativedelta
8
- import hashlib
9
-
10
- def degMinSectoDeg(a):
11
- deg = int(a.split("°")[0])
12
- sec = int(a.split("'")[-1][:-1])
13
- min = int(a.replace(f"{deg}°","").replace(f"'{sec}\"",""))
14
- return deg+min/60+sec/3600
15
-
16
- def normal(data, min=None, max=None):
17
- if max is None:
18
- max = np.max(data)
19
- if min is None:
20
- min = np.min(data)
21
- rangeLat = max-min
22
- dataB = (data - min) / rangeLat
23
- return dataB
24
-
25
- def mkDir(path):
26
- if "." in path:
27
- os.makedirs(os.path.dirname(path),exist_ok=True)
28
- else:
29
- os.makedirs(path, exist_ok=True)
30
-
31
- def options():
32
- parser = argparse.ArgumentParser(description='hjn')
33
- parser.add_argument('--times', type=str, default='2018060700,2018060700')
34
- parser.add_argument('--isDebug',action='store_true',default=False)
35
- config= parser.parse_args()
36
- config.times = config.times.split(",")
37
- if len(config.times) == 1:
38
- config.times = [config.times[0], config.times[0]]
39
- config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
40
- datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
41
-
42
- return config
43
-
44
-
45
- def totalTimes(delta,second):
46
- return (delta.days*24*3600+delta.seconds)//second
47
-
48
- def timeSeq(start,end,secInter,endPoint=True):
49
- times=totalTimes((end-start),secInter)
50
- end = 1 if endPoint else 0
51
- return list(map(lambda x:start+relativedelta(seconds=x*secInter),range(times+end)))
52
-
53
- def normalNC(data):
54
- mx=np.nanmax(data)
55
- mn = np.nanmin(data)
56
- rangeV=mx-mn
57
- scale = rangeV/254
58
- offset = (mx+mn)/2
59
- data1=(data - offset)/scale
60
- data1[np.isnan(data1)] = -128
61
- return data1,scale,offset
62
-
63
-
64
- def expend(data,latArr,lonArr,dim=2):
65
- latOffset = int((LeftTopCornerPairArr[0]["evn"].n - latArr[0]) / 0.01)
66
- latOffsetDown = int((latArr[-1] - LeftTopCornerPairArr[3]["evn"].s) / 0.01)
67
- lonOffset = int((lonArr[0] - LeftTopCornerPairArr[6]["evn"].w) / 0.01)
68
- lonOffsetRight = int((LeftTopCornerPairArr[0]["evn"].e - lonArr[-1]) / 0.01)
69
- appendLat = np.asarray(list(map(lambda x: latArr[0] + x * 0.01, range(1, latOffset + 2)))[::-1])
70
- appendLatDown = np.asarray(list(map(lambda x: latArr[-1] - x * 0.01, range(1, latOffsetDown + 2))))
71
- latArr = np.r_[appendLat, latArr]
72
- latArr = np.r_[latArr, appendLatDown]
73
- appendLon = np.asarray(list(map(lambda x: lonArr[0] - x * 0.01, range(1, lonOffset + 2)))[::-1])
74
- appendLonRight = np.asarray(list(map(lambda x: lonArr[-1] + x * 0.01, range(1, lonOffsetRight + 2))))
75
- lonArr = np.r_[appendLon, lonArr]
76
- lonArr = np.r_[lonArr, appendLonRight]
77
-
78
- if latOffset<0:
79
- latOffset=0
80
- if latOffsetDown < 0:
81
- latOffsetDown = 0
82
- if lonOffset < 0:
83
- lonOffset = 0
84
- if lonOffsetRight < 0:
85
- lonOffsetRight = 0
86
-
87
- if dim==2:
88
- data = np.pad(data, ((latOffset+1 , latOffsetDown+1 ), (lonOffset+1 , lonOffsetRight+1)),constant_values=np.nan)
89
- elif dim==3:
90
- data = np.pad(data, ((0, 0), (latOffset+1, latOffsetDown+1), (lonOffset+1, lonOffsetRight+1)), constant_values=np.nan)
91
- elif dim==4:
92
- data = np.pad(data, ((0, 0),(0, 0), (latOffset+1, latOffsetDown+1), (lonOffset+1, lonOffsetRight+1)), constant_values=np.nan)
93
- return data,latArr,lonArr
94
-
95
- def UV2WSWD(U,V):
96
- ws = np.sqrt(np.square(U) + np.square(V))
97
- wd = (np.degrees(np.arctan2(-U, -V))+ 360)%360
98
- return ws,wd
99
-
100
- def WSWD2UV(ws,wd):
101
- u=- ws*np.sin(np.radians(wd))
102
- v=- ws*np.cos(np.radians(wd))
103
- return u,v
104
-
105
- def findAllIPV4(segment="10."):
106
- import psutil
107
- from socket import AddressFamily
108
- local_addrs = ""
109
- for name, info in psutil.net_if_addrs().items():
110
- for addr in info:
111
- if AddressFamily.AF_INET == addr.family:
112
- if segment in addr.address:
113
- local_addrs = addr.address
114
- return local_addrs
115
-
116
- def sendEmail(message,subject = "fail"):
117
- import requests
118
- IP = findAllIPV4()
119
- response = None
120
- try:
121
- response = requests.get("http://10.16.50.218:5004/sendmail?address=408037825@qq.com&subject=%s:%s&message=%s"%(subject,IP,message))
122
- except Exception as e:
123
- print(e)
124
- return response
125
-
126
- def seconds2datetime(seconds):
127
- return datetime.datetime.strptime(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds)), "%Y-%m-%d %H:%M:%S")
128
-
129
- def datetime2seconds(UTC):
130
- return time.mktime(UTC.timetuple())
131
-
132
- def readJulianDateTime(juliandata, hms):
133
- jd = juliandata + 2440587
134
- L = jd + 68569
135
- N = (4 * L) // 146097
136
- L = L - (146097 * N + 3) // 4
137
- I = 4000 * (L + 1) // 1461001
138
- L = L - (1461 * I) // 4 + 31
139
- J = 80 * L // 2447
140
- day = L - 2447 * J // 80
141
- L = int(J // 11)
142
- month = J + 2 - 12 * L
143
- year = 100 * (N - 49) + I + L
144
- seconds = hms // 1000
145
- h = seconds // 3600
146
- m = (seconds - h * 3600) // 60
147
- s = seconds - (60 * h + m) * 60
148
- return datetime.datetime(year, month, day, h, m, s)
149
-
150
- def RGB_to_Hex(tmp):
151
- rgb = tmp.split(',') # 将RGB格式划分开来
152
- strs = '#'
153
- for i in rgb:
154
- num = int(i) # 将str转int
155
- # 将R、G、B分别转化为16进制拼接转换并大写
156
- strs += str(hex(num))[-2:].replace('x', '0').upper()
157
-
158
- return strs
159
-
160
- def genLatLon(evn,resolution,isEndPoint=True):
161
- if isEndPoint:
162
- latArr = np.linspace(evn.n,evn.s,int(((evn.n-evn.s)/resolution+1)))
163
- lonArr = np.linspace(evn.w,evn.e,int(((evn.e-evn.w)/resolution+1)))
164
- else:
165
- evn.s+=resolution
166
- evn.e -= resolution
167
- latArr = np.linspace(evn.n, evn.s, int(((evn.n - evn.s) / resolution + 1)))
168
- lonArr = np.linspace(evn.w, evn.e, int(((evn.e - evn.w) / resolution + 1)))
169
- return latArr,lonArr
170
-
171
-
172
- def calSHA1(path):
173
- encrypt = hashlib.sha1()
174
- with open(path,"rb") as f:
175
- while True:
176
- b = f.read(128000)
177
- encrypt.update(b)
178
- if not b:
179
- break
180
- sha1Result = encrypt.hexdigest()
181
- return sha1Result
182
-
183
- def wait(path,sepSec,timeoutSec,debug=True):
184
- t0 = datetime.datetime.now()
185
- t1 = datetime.datetime.now()
186
- flag= True
187
- while not os.path.exists(path) and flag:
188
- if (t1-t0).total_seconds()>timeoutSec:
189
- flag =False
190
- break
191
- else:
192
- if debug:
193
- print(f"{path} missing wait for {sepSec}s")
194
- time.sleep(sepSec)
195
- t1 = datetime.datetime.now()
196
-
197
- if not flag:
198
- return False
199
- else:
200
- return True
201
-
shancx/wtx/hjnProj.py DELETED
@@ -1,161 +0,0 @@
1
- import numpy as np
2
- import warnings
3
-
4
- class FY4Proj():
5
- def __init__(self,lonD=104.7,resolution=4000):
6
-
7
- self.ea=6378.137
8
- self.eb=6356.7523
9
- self.h=42164
10
- self.lambdaD=np.radians(lonD)
11
-
12
- OFF={500:10991.5,1000:5495.5,2000:2747.5,4000:1373.5}
13
- FAC={500:81865099,1000:40932549,2000:20466274,4000:10233137}
14
-
15
- self.COFF=OFF[resolution]
16
- self.LOFF=OFF[resolution]
17
- self.CFAC=FAC[resolution]
18
- self.LFAC=FAC[resolution]
19
-
20
- def transform(self,latD,lonDe):
21
- lat=np.radians(latD)
22
- lon=np.radians(lonDe)
23
- ba2=np.square(self.eb/self.ea)
24
- phie=np.arctan(ba2*np.tan(lat))
25
- diffLon0=lon-self.lambdaD
26
- re=self.eb/np.sqrt(1-(1-ba2)*np.square(np.cos(phie)))
27
-
28
- r1=self.h-re*np.cos(phie)*np.cos(diffLon0)
29
- r2= -re*np.cos(phie)*np.sin(diffLon0)
30
- r3=re*np.sin(phie)
31
- rn=np.sqrt(np.square(r1)+np.square(r2)+np.square(r3))
32
-
33
-
34
- x= np.degrees(np.arctan(-r2/r1))
35
- y= np.degrees(np.arcsin(-r3/rn))
36
-
37
- c=(self.COFF+x*np.power(2.0,-16)*self.CFAC -0.5).astype(np.int32)
38
- l=(self.LOFF+y*np.power(2.0,-16)*self.LFAC -0.5).astype(np.int32)
39
- return (l,c)
40
-
41
- def transform_inver(self,l,c):
42
- eab2 = (self.ea / self.eb) ** 2
43
- x = np.radians((c - self.COFF) / (np.power(2.0, -16) * self.CFAC))
44
- y = np.radians((l - self.LOFF) / (np.power(2.0, -16) * self.LFAC))
45
- sd = np.sqrt((self.h*np.cos(x)*np.cos(y))**2-(np.cos(y)**2+eab2*np.sin(y)**2)*(self.h**2-self.ea**2))
46
- sn = (self.h*np.cos(x)*np.cos(y)-sd)/(np.cos(y)**2+eab2*np.sin(y)**2)
47
- s1 = self.h-sn*np.cos(x)*np.cos(y)
48
- s2 = sn*np.sin(x)*np.cos(y)
49
- s3 = -sn*np.sin(y)
50
- sxy = np.sqrt(s1**2+s2**2)
51
- lon = np.degrees(np.arctan(s2/s1))+np.degrees(self.lambdaD)
52
-
53
- lon[lon>180] -=360
54
- lat = np.degrees(np.arctan(eab2*s3 / sxy))
55
- return (lat,lon)
56
-
57
-
58
-
59
- def transforMat(self,ltc,step,SNCmat):
60
- _,_,latMat,lonMat = getLatlonMat(ltc,step)
61
- (l,c)=self.transform(latMat,lonMat)
62
- snclatlon=SNCmat[l,c]
63
- return snclatlon
64
-
65
- class H8Proj():
66
- def __init__(self, lonD=140.7, resolution=2000):
67
- self.ea = 6378.137
68
- self.eb = 6356.7523
69
- self.h = 42165.32745491
70
- self.lambdaD = np.radians(lonD)
71
-
72
- OFF = {500: 11000.5, 1000: 5500.5 , 2000: 2750.5}
73
- FAC = {500: 81865099, 1000: 40932549, 2000: 20466275}
74
-
75
- self.COFF = OFF[resolution]
76
- self.LOFF = OFF[resolution]
77
- self.CFAC = FAC[resolution]
78
- self.LFAC = FAC[resolution]
79
-
80
-
81
- def transform(self,latD, lonDe):
82
- lat = np.radians(latD)
83
- lon = np.radians(lonDe)
84
- ba2 = np.square(self.eb / self.ea)
85
- phie = np.arctan(ba2 * np.tan(lat))
86
- diffLon0 = lon - self.lambdaD
87
- re = self.eb / np.sqrt(1 - (1 - ba2) * np.square(np.cos(phie)))
88
-
89
- r1 = self.h - re * np.cos(phie) * np.cos(diffLon0)
90
- r2 = -re * np.cos(phie) * np.sin(diffLon0)
91
- r3 = re * np.sin(phie)
92
- rn = np.sqrt(np.square(r1) + np.square(r2) + np.square(r3))
93
-
94
- x = np.degrees(np.arctan(-r2 / r1))
95
- y = np.degrees(np.arcsin(-r3 / rn))
96
-
97
- c = (self.COFF + x * np.power(float(2), -16) * self.CFAC - 0.5).astype(np.int32)
98
- l = (self.LOFF + y * np.power(float(2), -16) * self.LFAC - 0.5).astype(np.int32)
99
- return (l, c)
100
-
101
- def transforMat(self,ltc,step,SNCmat,loff):
102
- _,_,latMat,lonMat = getLatlonMat(ltc,step)
103
- (l,c)=self.transform(latMat,lonMat)
104
- snclatlon=SNCmat[l-int(loff),c]
105
- return snclatlon
106
-
107
-
108
-
109
- def getLatlonMat(ltc,step,endPoint=True):
110
- end = 1 if endPoint else 0
111
- latArr = np.linspace(ltc.n, ltc.s, int(np.round((ltc.n - ltc.s) / step, 4)) + end)
112
- if ltc.e<ltc.w:
113
- E = ltc.e+360
114
- lonRange = E - ltc.w
115
- lonArr = np.linspace(ltc.w, E, int(np.round(lonRange / step, 4)) + end)
116
- lonArr[lonArr>=180] -=360
117
- else:
118
- lonRange = ltc.e - ltc.w
119
- lonArr = np.linspace(ltc.w, ltc.e, int(np.round(lonRange / step,4)) + end)
120
- latMat = np.dot(latArr.reshape(-1, 1), np.ones([1, len(lonArr)]))
121
- lonMat = np.dot(np.ones([len(latArr), 1]), np.expand_dims(lonArr, axis=0))
122
- return latArr,lonArr,latMat,lonMat
123
-
124
- def getLatlonMat1(ltc,step,endPoint=True):
125
- end = 1 if endPoint else 0
126
- latArr = np.linspace(ltc.n, ltc.s, int((ltc.n - ltc.s) / step) + end)
127
- lonArr = np.linspace(ltc.w, ltc.e, int((ltc.e - ltc.w) / step) + end)
128
- latMat = np.dot(latArr.reshape(-1, 1), np.ones([1, len(lonArr)]))
129
- lonMat = np.dot(np.ones([len(latArr), 1]), np.expand_dims(lonArr, axis=0))
130
- return latArr,lonArr,latMat,lonMat
131
-
132
- def cartesian_to_geographic_aeqd(x, y, lon_0, lat_0, R=6370997.):
133
- x = np.atleast_1d(np.asarray(x))
134
- y = np.atleast_1d(np.asarray(y))
135
-
136
- lat_0_rad = np.deg2rad(lat_0)
137
- lon_0_rad = np.deg2rad(lon_0)
138
-
139
- rho = np.sqrt(x*x + y*y)
140
- c = rho / R
141
-
142
- with warnings.catch_warnings():
143
- # division by zero may occur here but is properly addressed below so
144
- # the warnings can be ignored
145
- warnings.simplefilter("ignore", RuntimeWarning)
146
- lat_rad = np.arcsin(np.cos(c) * np.sin(lat_0_rad) +
147
- y * np.sin(c) * np.cos(lat_0_rad) / rho)
148
- lat_deg = np.rad2deg(lat_rad)
149
- # fix cases where the distance from the center of the projection is zero
150
- lat_deg[rho == 0] = lat_0
151
-
152
- x1 = x * np.sin(c)
153
- x2 = rho*np.cos(lat_0_rad)*np.cos(c) - y*np.sin(lat_0_rad)*np.sin(c)
154
- lon_rad = lon_0_rad + np.arctan2(x1, x2)
155
- lon_deg = np.rad2deg(lon_rad)
156
- # Longitudes should be from -180 to 180 degrees
157
- lon_deg[lon_deg > 180] -= 360.
158
- lon_deg[lon_deg < -180] += 360.
159
-
160
- return lon_deg, lat_deg
161
-
shancx/wtx/inotify.py DELETED
@@ -1,41 +0,0 @@
1
- import os
2
- from pyinotify import WatchManager, Notifier,ProcessEvent,IN_DELETE, IN_CREATE,IN_MODIFY
3
-
4
-
5
- class EventHandler(ProcessEvent):
6
- """事件处理"""
7
- def process_IN_CREATE(self, event):
8
- print("Create file: %s " % os.path.join(event.path,event.name))
9
-
10
- def process_IN_DELETE(self, event):
11
- print("Delete file: %s " % os.path.join(event.path,event.name))
12
-
13
- def process_IN_MODIFY(self, event):
14
- filePath=os.path.join(event.path,event.name)
15
- if "tweet" in event.name:
16
- print("Modify file: %s " % filePath )
17
- print("*"*30)
18
- try:
19
- with open(filePath , 'r') as f:
20
- print (f.read())
21
- except Exception as e:
22
- print(e)
23
-
24
- def FSMonitor(path='.'):
25
- wm = WatchManager()
26
- mask = IN_DELETE | IN_CREATE |IN_MODIFY
27
- notifier = Notifier(wm, EventHandler())
28
- wm.add_watch(path, mask,auto_add=True,rec=True)
29
- print('now starting monitor %s'%(path))
30
- while True:
31
- try:
32
- notifier.process_events()
33
- if notifier.check_events():
34
- notifier.read_events()
35
- except KeyboardInterrupt:
36
- notifier.stop()
37
- break
38
-
39
- if __name__ == "__main__":
40
- FSMonitor('/var/log/shiny-server')
41
-
@@ -1,87 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- @author: Yichen Wang
4
- @date: 06/30/2020
5
- """
6
- import matplotlib.pyplot as plt
7
- from matplotlib import cm, colors
8
- import numpy as np
9
-
10
- def generateCmap(breakPointColors, breakPoints=None, sensitivity=256,
11
- name="userCmap"):
12
- '''
13
- Aimed at generate user customized ListedColormap instance, to be used when
14
- plotting with matplotlib.
15
- Arguments:
16
- ----------
17
- breakPointColors:
18
- An array of color difinitions. Can be "rgba" vector or a string (like
19
- "red") that `matplotlib.colors.to_rgba()` accepts.
20
- breakPoints:
21
- Optional. An array of numbers that defines the border of color
22
- gradients. The values does not necessarily match the border of the
23
- data to plot, but will be reflected as ratio on the plot. Must be of
24
- the same length as `breakPointColors`.
25
- sensitivity:
26
- An integer for how many intrinsic intervals in the colormap. Default
27
- `256`. Should use larger value if there are breakpoints close to each
28
- other.
29
- Return:
30
- ----------
31
- a matplotlib.colors.ListedColormap object, that can be used for "cmap"
32
- argument in matplotlib plotting function.
33
- Example:
34
- ----------
35
- >>> import matplotlib.pyplot as plt
36
- >>> cmap = generateCmap(['blue', 'white', 'red'])
37
- >>> plt.scatter(range(100), range(100), c=range(100), cmap=cmap)
38
- '''
39
- # Input Check
40
- assert len(breakPointColors) >= 2
41
- if breakPoints != None:
42
- assert len(breakPoints) == len(breakPointColors)
43
- assert len(set(breakPoints)) == len(breakPoints), \
44
- "Should not give duplicated value in 'breakPoints'"
45
- else:
46
- breakPoints = list(range(len(breakPointColors)))
47
-
48
- breakPointColors = np.array(breakPointColors)
49
- assert len(breakPointColors.shape) == 1 or \
50
- len(breakPointColors.shape) == 2
51
- if len(breakPointColors.shape) == 1:
52
- assert str(breakPointColors.dtype).startswith('<U'), \
53
- "Color specification dtype not understandable"
54
- elif len(breakPointColors.shape) == 2:
55
- assert breakPointColors.shape[1] in [3, 4] and \
56
- breakPointColors.dtype in ['int32', 'float64'], \
57
- "'rgb(a)' color specification not understandable."
58
-
59
- ## Randomly fetch an ListedColormap object, and modify the colors inside
60
- cmap = cm.get_cmap("viridis", sensitivity)
61
- cmap.name = name
62
-
63
- # Format the input
64
- minBP, maxBP = min(breakPoints), max(breakPoints)
65
- scaledBP = [round((i-minBP)/(maxBP-minBP)*(sensitivity-1)) \
66
- for i in breakPoints]
67
- assert len(set(scaledBP)) == len(breakPoints), \
68
- "Sensitivity too low"
69
- sortedBP = sorted(scaledBP)
70
- sortedBPC = []
71
- for i in sortedBP:
72
- idx = scaledBP.index(i)
73
- sortedBPC.append(breakPointColors[idx])
74
- BPC_rgba = np.array([colors.to_rgba(i) for i in sortedBPC])
75
- # Now replace colors in the Colormap object
76
- for i in range(1, len(sortedBP)):
77
- ## Indices when slicing colormap.colors
78
- start = sortedBP[i-1]
79
- end = sortedBP[i] + 1
80
- n = end - start
81
- ## Color range
82
- startC = BPC_rgba[i-1]
83
- endC = BPC_rgba[i]
84
- for i in range(3):
85
- cmap.colors[start:end, i] = np.linspace(startC[i], endC[i], n)
86
-
87
- return cmap