@@ -0,0 +1,293 | |||||
|
1 | import os.path | |||
|
2 | import ftplib | |||
|
3 | ||||
|
4 | ||||
|
5 | class Ftp(): | |||
|
6 | """ | |||
|
7 | Ftp is a public class used to define custom File Transfer Protocol from "ftplib" python module | |||
|
8 | ||||
|
9 | Non-standard Python modules used: None | |||
|
10 | ||||
|
11 | Written by "Daniel Suarez":mailto:daniel.suarez@jro.igp.gob.pe Oct. 26, 2010 | |||
|
12 | """ | |||
|
13 | ||||
|
14 | def __init__(self,host = None, username=None, passw=None, remotefolder=None): | |||
|
15 | """ | |||
|
16 | This method is used to setting parameters for FTP and establishing connection to remote host | |||
|
17 | ||||
|
18 | Inputs: | |||
|
19 | host - remote host IP Address | |||
|
20 | ||||
|
21 | username - remote host Username | |||
|
22 | ||||
|
23 | passw - remote host Passw | |||
|
24 | ||||
|
25 | remotefolder - remote host current working directory | |||
|
26 | ||||
|
27 | Return: void | |||
|
28 | ||||
|
29 | Affects: | |||
|
30 | self.status - in Error Case or Connection Failed this parameter is set to 1 else 0 | |||
|
31 | ||||
|
32 | self.folderList - sub-folder list of remote folder | |||
|
33 | ||||
|
34 | self.fileList - file list of remote folder | |||
|
35 | ||||
|
36 | ||||
|
37 | """ | |||
|
38 | ||||
|
39 | if ((host == None) and (username==None) and (passw==None) and (remotefolder==None)): | |||
|
40 | host, username, passw, remotefolder = self.parmsByDefault() | |||
|
41 | ||||
|
42 | self.host = host | |||
|
43 | self.username = username | |||
|
44 | self.passw = passw | |||
|
45 | self.remotefolder = remotefolder | |||
|
46 | self.file = None | |||
|
47 | self.ftp = None | |||
|
48 | self.status = 0 | |||
|
49 | ||||
|
50 | try: | |||
|
51 | self.ftp = ftplib.FTP(self.host) | |||
|
52 | self.ftp.login(self.username,self.passw) | |||
|
53 | self.ftp.cwd(self.remotefolder) | |||
|
54 | # print 'Connect to FTP Server: Successfully' | |||
|
55 | ||||
|
56 | except ftplib.all_errors: | |||
|
57 | print 'Error FTP Service' | |||
|
58 | self.status = 1 | |||
|
59 | return | |||
|
60 | ||||
|
61 | ||||
|
62 | ||||
|
63 | self.dirList = [] | |||
|
64 | ||||
|
65 | try: | |||
|
66 | self.dirList = self.ftp.nlst() | |||
|
67 | ||||
|
68 | except ftplib.error_perm, resp: | |||
|
69 | if str(resp) == "550 No files found": | |||
|
70 | print "no files in this directory" | |||
|
71 | self.status = 1 | |||
|
72 | return | |||
|
73 | ||||
|
74 | except ftplib.all_errors: | |||
|
75 | print 'Error Displaying Dir-Files' | |||
|
76 | self.status = 1 | |||
|
77 | return | |||
|
78 | ||||
|
79 | self.fileList = [] | |||
|
80 | self.folderList = [] | |||
|
81 | #only for test | |||
|
82 | for f in self.dirList: | |||
|
83 | name, ext = os.path.splitext(f) | |||
|
84 | if ext != '': | |||
|
85 | self.fileList.append(f) | |||
|
86 | # print 'filename: %s - size: %d'%(f,self.ftp.size(f)) | |||
|
87 | ||||
|
88 | def parmsByDefault(self): | |||
|
89 | host = 'jro.igp.gob.pe' | |||
|
90 | username = 'operaciones' | |||
|
91 | passw = 'mst98vhf' | |||
|
92 | remotefolder = '/users/database/on-line/' | |||
|
93 | ||||
|
94 | return host, username, passw, remotefolder | |||
|
95 | ||||
|
96 | ||||
|
97 | def mkd(self,dirname): | |||
|
98 | """ | |||
|
99 | mkd is used to make directory in remote host | |||
|
100 | ||||
|
101 | Input: | |||
|
102 | dirname - directory name | |||
|
103 | ||||
|
104 | Return: | |||
|
105 | 1 in error case else 0 | |||
|
106 | """ | |||
|
107 | try: | |||
|
108 | self.ftp.mkd(dirname) | |||
|
109 | except: | |||
|
110 | print 'Error creating remote folder:%s'%dirname | |||
|
111 | return 1 | |||
|
112 | ||||
|
113 | return 0 | |||
|
114 | ||||
|
115 | ||||
|
116 | def delete(self,filename): | |||
|
117 | """ | |||
|
118 | delete is used to delete file in current working directory of remote host | |||
|
119 | ||||
|
120 | Input: | |||
|
121 | filename - filename to delete in remote folder | |||
|
122 | ||||
|
123 | Return: | |||
|
124 | 1 in error case else 0 | |||
|
125 | """ | |||
|
126 | ||||
|
127 | try: | |||
|
128 | self.ftp.delete(filename) | |||
|
129 | except: | |||
|
130 | print 'Error deleting remote file:%s'%filename | |||
|
131 | return 1 | |||
|
132 | ||||
|
133 | return 0 | |||
|
134 | ||||
|
135 | def download(self,filename,localfolder): | |||
|
136 | """ | |||
|
137 | download is used to downloading file from remote folder into local folder | |||
|
138 | ||||
|
139 | Inputs: | |||
|
140 | filename - filename to donwload | |||
|
141 | ||||
|
142 | localfolder - directory local to store filename | |||
|
143 | ||||
|
144 | Returns: | |||
|
145 | self.status - 1 in error case else 0 | |||
|
146 | """ | |||
|
147 | ||||
|
148 | self.status = 0 | |||
|
149 | ||||
|
150 | ||||
|
151 | if not(filename in self.fileList): | |||
|
152 | print 'filename:%s not exists'%filename | |||
|
153 | self.status = 1 | |||
|
154 | return self.status | |||
|
155 | ||||
|
156 | newfilename = os.path.join(localfolder,filename) | |||
|
157 | ||||
|
158 | self.file = open(newfilename, 'wb') | |||
|
159 | ||||
|
160 | try: | |||
|
161 | print 'Download: ' + filename | |||
|
162 | self.ftp.retrbinary('RETR ' + filename, self.__handleDownload) | |||
|
163 | print 'Download Complete' | |||
|
164 | except ftplib.all_errors: | |||
|
165 | print 'Error Downloading ' + filename | |||
|
166 | self.status = 1 | |||
|
167 | return self.status | |||
|
168 | ||||
|
169 | self.file.close() | |||
|
170 | ||||
|
171 | return self.status | |||
|
172 | ||||
|
173 | ||||
|
174 | def __handleDownload(self,block): | |||
|
175 | """ | |||
|
176 | __handleDownload is used to handle writing file | |||
|
177 | """ | |||
|
178 | self.file.write(block) | |||
|
179 | ||||
|
180 | ||||
|
181 | def upload(self,filename,remotefolder=None): | |||
|
182 | """ | |||
|
183 | upload is used to uploading local file to remote directory | |||
|
184 | ||||
|
185 | Inputs: | |||
|
186 | filename - full path name of local file to store in remote directory | |||
|
187 | ||||
|
188 | remotefolder - remote directory | |||
|
189 | ||||
|
190 | Returns: | |||
|
191 | self.status - 1 in error case else 0 | |||
|
192 | """ | |||
|
193 | ||||
|
194 | if remotefolder == None: | |||
|
195 | remotefolder = self.remotefolder | |||
|
196 | ||||
|
197 | self.status = 0 | |||
|
198 | ||||
|
199 | try: | |||
|
200 | self.ftp.cwd(remotefolder) | |||
|
201 | ||||
|
202 | self.file = open(filename, 'rb') | |||
|
203 | ||||
|
204 | (head, tail) = os.path.split(filename) | |||
|
205 | ||||
|
206 | command = "STOR " + tail | |||
|
207 | ||||
|
208 | print 'Uploading: ' + tail | |||
|
209 | self.ftp.storbinary(command, self.file) | |||
|
210 | print 'Upload Completed' | |||
|
211 | ||||
|
212 | except ftplib.all_errors: | |||
|
213 | print 'Error Uploading ' + tail | |||
|
214 | self.status = 1 | |||
|
215 | return self.status | |||
|
216 | ||||
|
217 | self.file.close() | |||
|
218 | ||||
|
219 | #back to initial directory in __init__() | |||
|
220 | self.ftp.cwd(self.remotefolder) | |||
|
221 | ||||
|
222 | return self.status | |||
|
223 | ||||
|
224 | ||||
|
225 | def dir(self,remotefolder): | |||
|
226 | """ | |||
|
227 | dir is used to change working directory of remote host and get folder and file list | |||
|
228 | ||||
|
229 | Input: | |||
|
230 | remotefolder - current working directory | |||
|
231 | ||||
|
232 | Affects: | |||
|
233 | self.fileList - file list of working directory | |||
|
234 | ||||
|
235 | Return: | |||
|
236 | infoList - list with filenames and size of file in bytes | |||
|
237 | ||||
|
238 | self.folderList - folder list | |||
|
239 | """ | |||
|
240 | ||||
|
241 | self.remotefolder = remotefolder | |||
|
242 | print 'Change to ' + self.remotefolder | |||
|
243 | try: | |||
|
244 | self.ftp.cwd(remotefolder) | |||
|
245 | except ftplib.all_errors: | |||
|
246 | print 'Error Change to ' + self.remotefolder | |||
|
247 | infoList = None | |||
|
248 | self.folderList = None | |||
|
249 | return infoList,self.folderList | |||
|
250 | ||||
|
251 | self.dirList = [] | |||
|
252 | ||||
|
253 | try: | |||
|
254 | self.dirList = self.ftp.nlst() | |||
|
255 | ||||
|
256 | except ftplib.error_perm, resp: | |||
|
257 | if str(resp) == "550 No files found": | |||
|
258 | print "no files in this directory" | |||
|
259 | infoList = None | |||
|
260 | self.folderList = None | |||
|
261 | return infoList,self.folderList | |||
|
262 | except ftplib.all_errors: | |||
|
263 | print 'Error Displaying Dir-Files' | |||
|
264 | infoList = None | |||
|
265 | self.folderList = None | |||
|
266 | return infoList,self.folderList | |||
|
267 | ||||
|
268 | infoList = [] | |||
|
269 | self.fileList = [] | |||
|
270 | self.folderList = [] | |||
|
271 | for f in self.dirList: | |||
|
272 | name,ext = os.path.splitext(f) | |||
|
273 | if ext != '': | |||
|
274 | self.fileList.append(f) | |||
|
275 | value = (f,self.ftp.size(f)) | |||
|
276 | infoList.append(value) | |||
|
277 | ||||
|
278 | if ext == '': | |||
|
279 | self.folderList.append(f) | |||
|
280 | ||||
|
281 | return infoList,self.folderList | |||
|
282 | ||||
|
283 | ||||
|
284 | def close(self): | |||
|
285 | """ | |||
|
286 | close is used to close and end FTP connection | |||
|
287 | ||||
|
288 | Inputs: None | |||
|
289 | ||||
|
290 | Return: void | |||
|
291 | ||||
|
292 | """ | |||
|
293 | self.ftp.close() No newline at end of file |
@@ -1,408 +1,414 | |||||
1 | import os |
|
1 | import os | |
2 | import numpy |
|
2 | import numpy | |
3 | import time, datetime |
|
3 | import time, datetime | |
4 | import mpldriver |
|
4 | import mpldriver | |
5 |
|
5 | from customftp import * | ||
6 |
|
6 | |||
7 | class Figure: |
|
7 | class Figure: | |
8 |
|
8 | |||
9 | __driver = mpldriver |
|
9 | __driver = mpldriver | |
10 | fig = None |
|
10 | fig = None | |
11 |
|
11 | |||
12 | idfigure = None |
|
12 | idfigure = None | |
13 | wintitle = None |
|
13 | wintitle = None | |
14 | width = None |
|
14 | width = None | |
15 | height = None |
|
15 | height = None | |
16 | nplots = None |
|
16 | nplots = None | |
17 | timerange = None |
|
17 | timerange = None | |
18 |
|
18 | |||
19 | axesObjList = [] |
|
19 | axesObjList = [] | |
20 |
|
20 | |||
21 | WIDTH = None |
|
21 | WIDTH = None | |
22 | HEIGHT = None |
|
22 | HEIGHT = None | |
23 | PREFIX = 'fig' |
|
23 | PREFIX = 'fig' | |
24 |
|
24 | |||
25 | def __init__(self): |
|
25 | def __init__(self): | |
26 |
|
26 | |||
27 | raise ValueError, "This method is not implemented" |
|
27 | raise ValueError, "This method is not implemented" | |
28 |
|
28 | |||
29 | def __del__(self): |
|
29 | def __del__(self): | |
30 |
|
30 | |||
31 | self.__driver.closeFigure() |
|
31 | self.__driver.closeFigure() | |
32 |
|
32 | |||
33 | def getFilename(self, name, ext='.png'): |
|
33 | def getFilename(self, name, ext='.png'): | |
34 |
|
34 | |||
35 | path = '%s%03d' %(self.PREFIX, self.idfigure) |
|
35 | path = '%s%03d' %(self.PREFIX, self.idfigure) | |
36 | filename = '%s_%s%s' %(self.PREFIX, name, ext) |
|
36 | filename = '%s_%s%s' %(self.PREFIX, name, ext) | |
37 |
|
37 | |||
38 | return os.path.join(path, filename) |
|
38 | return os.path.join(path, filename) | |
39 |
|
39 | |||
40 | def getAxesObjList(self): |
|
40 | def getAxesObjList(self): | |
41 |
|
41 | |||
42 | return self.axesObjList |
|
42 | return self.axesObjList | |
43 |
|
43 | |||
44 | def getSubplots(self): |
|
44 | def getSubplots(self): | |
45 |
|
45 | |||
46 | raise ValueError, "Abstract method: This method should be defined" |
|
46 | raise ValueError, "Abstract method: This method should be defined" | |
47 |
|
47 | |||
48 | def getScreenDim(self, widthplot, heightplot): |
|
48 | def getScreenDim(self, widthplot, heightplot): | |
49 |
|
49 | |||
50 | nrow, ncol = self.getSubplots() |
|
50 | nrow, ncol = self.getSubplots() | |
51 |
|
51 | |||
52 | widthscreen = widthplot*ncol |
|
52 | widthscreen = widthplot*ncol | |
53 | heightscreen = heightplot*nrow |
|
53 | heightscreen = heightplot*nrow | |
54 |
|
54 | |||
55 | return widthscreen, heightscreen |
|
55 | return widthscreen, heightscreen | |
56 |
|
56 | |||
57 | def getTimeLim(self, x, xmin, xmax): |
|
57 | def getTimeLim(self, x, xmin, xmax): | |
58 |
|
58 | |||
59 | thisdatetime = datetime.datetime.utcfromtimestamp(numpy.min(x)) |
|
59 | thisdatetime = datetime.datetime.utcfromtimestamp(numpy.min(x)) | |
60 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
60 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) | |
61 |
|
61 | |||
62 | #################################################### |
|
62 | #################################################### | |
63 | #If the x is out of xrange |
|
63 | #If the x is out of xrange | |
64 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
64 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): | |
65 | xmin = None |
|
65 | xmin = None | |
66 | xmax = None |
|
66 | xmax = None | |
67 |
|
67 | |||
68 | if xmin == None: |
|
68 | if xmin == None: | |
69 | td = thisdatetime - thisdate |
|
69 | td = thisdatetime - thisdate | |
70 | xmin = td.seconds/(60*60.) |
|
70 | xmin = td.seconds/(60*60.) | |
71 |
|
71 | |||
72 | if xmax == None: |
|
72 | if xmax == None: | |
73 | xmax = xmin + self.timerange/(60*60.) |
|
73 | xmax = xmin + self.timerange/(60*60.) | |
74 |
|
74 | |||
75 | mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) |
|
75 | mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) | |
76 | tmin = time.mktime(mindt.timetuple()) |
|
76 | tmin = time.mktime(mindt.timetuple()) | |
77 |
|
77 | |||
78 | maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) |
|
78 | maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) | |
79 | tmax = time.mktime(maxdt.timetuple()) |
|
79 | tmax = time.mktime(maxdt.timetuple()) | |
80 |
|
80 | |||
81 | self.timerange = tmax - tmin |
|
81 | self.timerange = tmax - tmin | |
82 |
|
82 | |||
83 | return tmin, tmax |
|
83 | return tmin, tmax | |
84 |
|
84 | |||
85 | def init(self, idfigure, nplots, wintitle): |
|
85 | def init(self, idfigure, nplots, wintitle): | |
86 |
|
86 | |||
87 | raise ValueError, "This method has been replaced with createFigure" |
|
87 | raise ValueError, "This method has been replaced with createFigure" | |
88 |
|
88 | |||
89 | def createFigure(self, idfigure, wintitle, widthplot=None, heightplot=None): |
|
89 | def createFigure(self, idfigure, wintitle, widthplot=None, heightplot=None): | |
90 |
|
90 | |||
91 | """ |
|
91 | """ | |
92 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. |
|
92 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. | |
93 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH |
|
93 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH | |
94 | y self.HEIGHT y el numero de subplots (nrow, ncol) |
|
94 | y self.HEIGHT y el numero de subplots (nrow, ncol) | |
95 |
|
95 | |||
96 | Input: |
|
96 | Input: | |
97 | idfigure : Los parametros necesarios son |
|
97 | idfigure : Los parametros necesarios son | |
98 | wintitle : |
|
98 | wintitle : | |
99 |
|
99 | |||
100 | """ |
|
100 | """ | |
101 |
|
101 | |||
102 | if widthplot == None: |
|
102 | if widthplot == None: | |
103 | widthplot = self.WIDTH |
|
103 | widthplot = self.WIDTH | |
104 |
|
104 | |||
105 | if heightplot == None: |
|
105 | if heightplot == None: | |
106 | heightplot = self.HEIGHT |
|
106 | heightplot = self.HEIGHT | |
107 |
|
107 | |||
108 | self.idfigure = idfigure |
|
108 | self.idfigure = idfigure | |
109 |
|
109 | |||
110 | self.wintitle = wintitle |
|
110 | self.wintitle = wintitle | |
111 |
|
111 | |||
112 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) |
|
112 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) | |
113 |
|
113 | |||
114 | self.fig = self.__driver.createFigure(self.idfigure, |
|
114 | self.fig = self.__driver.createFigure(self.idfigure, | |
115 | self.wintitle, |
|
115 | self.wintitle, | |
116 | self.widthscreen, |
|
116 | self.widthscreen, | |
117 | self.heightscreen) |
|
117 | self.heightscreen) | |
118 |
|
118 | |||
119 | self.axesObjList = [] |
|
119 | self.axesObjList = [] | |
120 |
|
120 | |||
|
121 | ||||
121 | def setDriver(self, driver=mpldriver): |
|
122 | def setDriver(self, driver=mpldriver): | |
122 |
|
123 | |||
123 | self.__driver = driver |
|
124 | self.__driver = driver | |
124 |
|
125 | |||
125 | def setTitle(self, title): |
|
126 | def setTitle(self, title): | |
126 |
|
127 | |||
127 | self.__driver.setTitle(self.fig, title) |
|
128 | self.__driver.setTitle(self.fig, title) | |
128 |
|
129 | |||
129 | def setWinTitle(self, title): |
|
130 | def setWinTitle(self, title): | |
130 |
|
131 | |||
131 | self.__driver.setWinTitle(self.fig, title=title) |
|
132 | self.__driver.setWinTitle(self.fig, title=title) | |
132 |
|
133 | |||
133 | def setTextFromAxes(self, text): |
|
134 | def setTextFromAxes(self, text): | |
134 |
|
135 | |||
135 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" |
|
136 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" | |
136 |
|
137 | |||
137 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
138 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): | |
138 |
|
139 | |||
139 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" |
|
140 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" | |
140 |
|
141 | |||
141 | def addAxes(self, *args): |
|
142 | def addAxes(self, *args): | |
142 | """ |
|
143 | """ | |
143 |
|
144 | |||
144 | Input: |
|
145 | Input: | |
145 | *args : Los parametros necesarios son |
|
146 | *args : Los parametros necesarios son | |
146 | nrow, ncol, xpos, ypos, colspan, rowspan |
|
147 | nrow, ncol, xpos, ypos, colspan, rowspan | |
147 | """ |
|
148 | """ | |
148 |
|
149 | |||
149 | axesObj = Axes(self.fig, *args) |
|
150 | axesObj = Axes(self.fig, *args) | |
150 | self.axesObjList.append(axesObj) |
|
151 | self.axesObjList.append(axesObj) | |
151 |
|
152 | |||
152 | def saveFigure(self, figpath, figfile, *args): |
|
153 | def saveFigure(self, figpath, figfile, *args): | |
153 |
|
154 | |||
154 | filename = os.path.join(figpath, figfile) |
|
155 | filename = os.path.join(figpath, figfile) | |
155 |
|
156 | |||
156 | fullpath = os.path.split(filename)[0] |
|
157 | fullpath = os.path.split(filename)[0] | |
157 |
|
158 | |||
158 | if not os.path.exists(fullpath): |
|
159 | if not os.path.exists(fullpath): | |
159 | os.mkdir(fullpath) |
|
160 | os.mkdir(fullpath) | |
160 |
|
161 | |||
161 | self.__driver.saveFigure(self.fig, filename, *args) |
|
162 | self.__driver.saveFigure(self.fig, filename, *args) | |
162 |
|
163 | |||
|
164 | def sendByFTP(self, figfilename): | |||
|
165 | ftpObj = Ftp() | |||
|
166 | ftpObj.upload(figfilename) | |||
|
167 | ftpObj.close() | |||
|
168 | ||||
163 | def draw(self): |
|
169 | def draw(self): | |
164 |
|
170 | |||
165 | self.__driver.draw(self.fig) |
|
171 | self.__driver.draw(self.fig) | |
166 |
|
172 | |||
167 | def run(self): |
|
173 | def run(self): | |
168 |
|
174 | |||
169 | raise ValueError, "This method is not implemented" |
|
175 | raise ValueError, "This method is not implemented" | |
170 |
|
176 | |||
171 | axesList = property(getAxesObjList) |
|
177 | axesList = property(getAxesObjList) | |
172 |
|
178 | |||
173 |
|
179 | |||
174 | class Axes: |
|
180 | class Axes: | |
175 |
|
181 | |||
176 | __driver = mpldriver |
|
182 | __driver = mpldriver | |
177 | fig = None |
|
183 | fig = None | |
178 | ax = None |
|
184 | ax = None | |
179 | plot = None |
|
185 | plot = None | |
180 |
|
186 | |||
181 | __firsttime = None |
|
187 | __firsttime = None | |
182 |
|
188 | |||
183 | __showprofile = False |
|
189 | __showprofile = False | |
184 |
|
190 | |||
185 | xmin = None |
|
191 | xmin = None | |
186 | xmax = None |
|
192 | xmax = None | |
187 | ymin = None |
|
193 | ymin = None | |
188 | ymax = None |
|
194 | ymax = None | |
189 | zmin = None |
|
195 | zmin = None | |
190 | zmax = None |
|
196 | zmax = None | |
191 |
|
197 | |||
192 | def __init__(self, *args): |
|
198 | def __init__(self, *args): | |
193 |
|
199 | |||
194 | """ |
|
200 | """ | |
195 |
|
201 | |||
196 | Input: |
|
202 | Input: | |
197 | *args : Los parametros necesarios son |
|
203 | *args : Los parametros necesarios son | |
198 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
204 | fig, nrow, ncol, xpos, ypos, colspan, rowspan | |
199 | """ |
|
205 | """ | |
200 |
|
206 | |||
201 | ax = self.__driver.createAxes(*args) |
|
207 | ax = self.__driver.createAxes(*args) | |
202 | self.fig = args[0] |
|
208 | self.fig = args[0] | |
203 | self.ax = ax |
|
209 | self.ax = ax | |
204 | self.plot = None |
|
210 | self.plot = None | |
205 |
|
211 | |||
206 | self.__firsttime = True |
|
212 | self.__firsttime = True | |
207 | self.idlineList = [] |
|
213 | self.idlineList = [] | |
208 |
|
214 | |||
209 | def setText(self, text): |
|
215 | def setText(self, text): | |
210 |
|
216 | |||
211 | self.__driver.setAxesText(self.ax, text) |
|
217 | self.__driver.setAxesText(self.ax, text) | |
212 |
|
218 | |||
213 | def setXAxisAsTime(self): |
|
219 | def setXAxisAsTime(self): | |
214 | pass |
|
220 | pass | |
215 |
|
221 | |||
216 | def pline(self, x, y, |
|
222 | def pline(self, x, y, | |
217 | xmin=None, xmax=None, |
|
223 | xmin=None, xmax=None, | |
218 | ymin=None, ymax=None, |
|
224 | ymin=None, ymax=None, | |
219 | xlabel='', ylabel='', |
|
225 | xlabel='', ylabel='', | |
220 | title='', |
|
226 | title='', | |
221 | **kwargs): |
|
227 | **kwargs): | |
222 |
|
228 | |||
223 | """ |
|
229 | """ | |
224 |
|
230 | |||
225 | Input: |
|
231 | Input: | |
226 | x : |
|
232 | x : | |
227 | y : |
|
233 | y : | |
228 | xmin : |
|
234 | xmin : | |
229 | xmax : |
|
235 | xmax : | |
230 | ymin : |
|
236 | ymin : | |
231 | ymax : |
|
237 | ymax : | |
232 | xlabel : |
|
238 | xlabel : | |
233 | ylabel : |
|
239 | ylabel : | |
234 | title : |
|
240 | title : | |
235 | **kwargs : Los parametros aceptados son |
|
241 | **kwargs : Los parametros aceptados son | |
236 |
|
242 | |||
237 | ticksize |
|
243 | ticksize | |
238 | ytick_visible |
|
244 | ytick_visible | |
239 | """ |
|
245 | """ | |
240 |
|
246 | |||
241 | if self.__firsttime: |
|
247 | if self.__firsttime: | |
242 |
|
248 | |||
243 | if xmin == None: xmin = numpy.nanmin(x) |
|
249 | if xmin == None: xmin = numpy.nanmin(x) | |
244 | if xmax == None: xmax = numpy.nanmax(x) |
|
250 | if xmax == None: xmax = numpy.nanmax(x) | |
245 | if ymin == None: ymin = numpy.nanmin(y) |
|
251 | if ymin == None: ymin = numpy.nanmin(y) | |
246 | if ymax == None: ymax = numpy.nanmax(y) |
|
252 | if ymax == None: ymax = numpy.nanmax(y) | |
247 |
|
253 | |||
248 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
254 | self.plot = self.__driver.createPline(self.ax, x, y, | |
249 | xmin, xmax, |
|
255 | xmin, xmax, | |
250 | ymin, ymax, |
|
256 | ymin, ymax, | |
251 | xlabel=xlabel, |
|
257 | xlabel=xlabel, | |
252 | ylabel=ylabel, |
|
258 | ylabel=ylabel, | |
253 | title=title, |
|
259 | title=title, | |
254 | **kwargs) |
|
260 | **kwargs) | |
255 |
|
261 | |||
256 | self.idlineList.append(0) |
|
262 | self.idlineList.append(0) | |
257 | self.__firsttime = False |
|
263 | self.__firsttime = False | |
258 | return |
|
264 | return | |
259 |
|
265 | |||
260 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
266 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, | |
261 | ylabel=ylabel, |
|
267 | ylabel=ylabel, | |
262 | title=title) |
|
268 | title=title) | |
263 |
|
269 | |||
264 | def addpline(self, x, y, idline, **kwargs): |
|
270 | def addpline(self, x, y, idline, **kwargs): | |
265 | lines = self.ax.lines |
|
271 | lines = self.ax.lines | |
266 |
|
272 | |||
267 | if idline in self.idlineList: |
|
273 | if idline in self.idlineList: | |
268 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
274 | self.__driver.set_linedata(self.ax, x, y, idline) | |
269 |
|
275 | |||
270 | if idline not in(self.idlineList): |
|
276 | if idline not in(self.idlineList): | |
271 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
277 | self.__driver.addpline(self.ax, x, y, **kwargs) | |
272 | self.idlineList.append(idline) |
|
278 | self.idlineList.append(idline) | |
273 |
|
279 | |||
274 | return |
|
280 | return | |
275 |
|
281 | |||
276 | def pmultiline(self, x, y, |
|
282 | def pmultiline(self, x, y, | |
277 | xmin=None, xmax=None, |
|
283 | xmin=None, xmax=None, | |
278 | ymin=None, ymax=None, |
|
284 | ymin=None, ymax=None, | |
279 | xlabel='', ylabel='', |
|
285 | xlabel='', ylabel='', | |
280 | title='', |
|
286 | title='', | |
281 | **kwargs): |
|
287 | **kwargs): | |
282 |
|
288 | |||
283 | if self.__firsttime: |
|
289 | if self.__firsttime: | |
284 |
|
290 | |||
285 | if xmin == None: xmin = numpy.nanmin(x) |
|
291 | if xmin == None: xmin = numpy.nanmin(x) | |
286 | if xmax == None: xmax = numpy.nanmax(x) |
|
292 | if xmax == None: xmax = numpy.nanmax(x) | |
287 | if ymin == None: ymin = numpy.nanmin(y) |
|
293 | if ymin == None: ymin = numpy.nanmin(y) | |
288 | if ymax == None: ymax = numpy.nanmax(y) |
|
294 | if ymax == None: ymax = numpy.nanmax(y) | |
289 |
|
295 | |||
290 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
296 | self.plot = self.__driver.createPmultiline(self.ax, x, y, | |
291 | xmin, xmax, |
|
297 | xmin, xmax, | |
292 | ymin, ymax, |
|
298 | ymin, ymax, | |
293 | xlabel=xlabel, |
|
299 | xlabel=xlabel, | |
294 | ylabel=ylabel, |
|
300 | ylabel=ylabel, | |
295 | title=title, |
|
301 | title=title, | |
296 | **kwargs) |
|
302 | **kwargs) | |
297 | self.__firsttime = False |
|
303 | self.__firsttime = False | |
298 | return |
|
304 | return | |
299 |
|
305 | |||
300 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
306 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, | |
301 | ylabel=ylabel, |
|
307 | ylabel=ylabel, | |
302 | title=title) |
|
308 | title=title) | |
303 |
|
309 | |||
304 | def pmultilineyaxis(self, x, y, |
|
310 | def pmultilineyaxis(self, x, y, | |
305 | xmin=None, xmax=None, |
|
311 | xmin=None, xmax=None, | |
306 | ymin=None, ymax=None, |
|
312 | ymin=None, ymax=None, | |
307 | xlabel='', ylabel='', |
|
313 | xlabel='', ylabel='', | |
308 | title='', |
|
314 | title='', | |
309 | **kwargs): |
|
315 | **kwargs): | |
310 |
|
316 | |||
311 | if self.__firsttime: |
|
317 | if self.__firsttime: | |
312 |
|
318 | |||
313 | if xmin == None: xmin = numpy.nanmin(x) |
|
319 | if xmin == None: xmin = numpy.nanmin(x) | |
314 | if xmax == None: xmax = numpy.nanmax(x) |
|
320 | if xmax == None: xmax = numpy.nanmax(x) | |
315 | if ymin == None: ymin = numpy.nanmin(y) |
|
321 | if ymin == None: ymin = numpy.nanmin(y) | |
316 | if ymax == None: ymax = numpy.nanmax(y) |
|
322 | if ymax == None: ymax = numpy.nanmax(y) | |
317 |
|
323 | |||
318 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, |
|
324 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, | |
319 | xmin, xmax, |
|
325 | xmin, xmax, | |
320 | ymin, ymax, |
|
326 | ymin, ymax, | |
321 | xlabel=xlabel, |
|
327 | xlabel=xlabel, | |
322 | ylabel=ylabel, |
|
328 | ylabel=ylabel, | |
323 | title=title, |
|
329 | title=title, | |
324 | **kwargs) |
|
330 | **kwargs) | |
325 | if self.xmin == None: self.xmin = xmin |
|
331 | if self.xmin == None: self.xmin = xmin | |
326 | if self.xmax == None: self.xmax = xmax |
|
332 | if self.xmax == None: self.xmax = xmax | |
327 | if self.ymin == None: self.ymin = ymin |
|
333 | if self.ymin == None: self.ymin = ymin | |
328 | if self.ymax == None: self.ymax = ymax |
|
334 | if self.ymax == None: self.ymax = ymax | |
329 |
|
335 | |||
330 | self.__firsttime = False |
|
336 | self.__firsttime = False | |
331 | return |
|
337 | return | |
332 |
|
338 | |||
333 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, |
|
339 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, | |
334 | ylabel=ylabel, |
|
340 | ylabel=ylabel, | |
335 | title=title) |
|
341 | title=title) | |
336 |
|
342 | |||
337 | def pcolor(self, x, y, z, |
|
343 | def pcolor(self, x, y, z, | |
338 | xmin=None, xmax=None, |
|
344 | xmin=None, xmax=None, | |
339 | ymin=None, ymax=None, |
|
345 | ymin=None, ymax=None, | |
340 | zmin=None, zmax=None, |
|
346 | zmin=None, zmax=None, | |
341 | xlabel='', ylabel='', |
|
347 | xlabel='', ylabel='', | |
342 | title='', rti = False, colormap='jet', |
|
348 | title='', rti = False, colormap='jet', | |
343 | **kwargs): |
|
349 | **kwargs): | |
344 |
|
350 | |||
345 | """ |
|
351 | """ | |
346 | Input: |
|
352 | Input: | |
347 | x : |
|
353 | x : | |
348 | y : |
|
354 | y : | |
349 | x : |
|
355 | x : | |
350 | xmin : |
|
356 | xmin : | |
351 | xmax : |
|
357 | xmax : | |
352 | ymin : |
|
358 | ymin : | |
353 | ymax : |
|
359 | ymax : | |
354 | zmin : |
|
360 | zmin : | |
355 | zmax : |
|
361 | zmax : | |
356 | xlabel : |
|
362 | xlabel : | |
357 | ylabel : |
|
363 | ylabel : | |
358 | title : |
|
364 | title : | |
359 | **kwargs : Los parametros aceptados son |
|
365 | **kwargs : Los parametros aceptados son | |
360 | ticksize=9, |
|
366 | ticksize=9, | |
361 | cblabel='' |
|
367 | cblabel='' | |
362 | rti = True or False |
|
368 | rti = True or False | |
363 | """ |
|
369 | """ | |
364 |
|
370 | |||
365 | if self.__firsttime: |
|
371 | if self.__firsttime: | |
366 |
|
372 | |||
367 | if xmin == None: xmin = numpy.nanmin(x) |
|
373 | if xmin == None: xmin = numpy.nanmin(x) | |
368 | if xmax == None: xmax = numpy.nanmax(x) |
|
374 | if xmax == None: xmax = numpy.nanmax(x) | |
369 | if ymin == None: ymin = numpy.nanmin(y) |
|
375 | if ymin == None: ymin = numpy.nanmin(y) | |
370 | if ymax == None: ymax = numpy.nanmax(y) |
|
376 | if ymax == None: ymax = numpy.nanmax(y) | |
371 | if zmin == None: zmin = numpy.nanmin(z) |
|
377 | if zmin == None: zmin = numpy.nanmin(z) | |
372 | if zmax == None: zmax = numpy.nanmax(z) |
|
378 | if zmax == None: zmax = numpy.nanmax(z) | |
373 |
|
379 | |||
374 |
|
380 | |||
375 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
381 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, | |
376 | xmin, xmax, |
|
382 | xmin, xmax, | |
377 | ymin, ymax, |
|
383 | ymin, ymax, | |
378 | zmin, zmax, |
|
384 | zmin, zmax, | |
379 | xlabel=xlabel, |
|
385 | xlabel=xlabel, | |
380 | ylabel=ylabel, |
|
386 | ylabel=ylabel, | |
381 | title=title, |
|
387 | title=title, | |
382 | colormap=colormap, |
|
388 | colormap=colormap, | |
383 | **kwargs) |
|
389 | **kwargs) | |
384 |
|
390 | |||
385 | if self.xmin == None: self.xmin = xmin |
|
391 | if self.xmin == None: self.xmin = xmin | |
386 | if self.xmax == None: self.xmax = xmax |
|
392 | if self.xmax == None: self.xmax = xmax | |
387 | if self.ymin == None: self.ymin = ymin |
|
393 | if self.ymin == None: self.ymin = ymin | |
388 | if self.ymax == None: self.ymax = ymax |
|
394 | if self.ymax == None: self.ymax = ymax | |
389 | if self.zmin == None: self.zmin = zmin |
|
395 | if self.zmin == None: self.zmin = zmin | |
390 | if self.zmax == None: self.zmax = zmax |
|
396 | if self.zmax == None: self.zmax = zmax | |
391 |
|
397 | |||
392 | self.__firsttime = False |
|
398 | self.__firsttime = False | |
393 | return |
|
399 | return | |
394 |
|
400 | |||
395 | if rti: |
|
401 | if rti: | |
396 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
402 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, | |
397 | xlabel=xlabel, |
|
403 | xlabel=xlabel, | |
398 | ylabel=ylabel, |
|
404 | ylabel=ylabel, | |
399 | title=title, |
|
405 | title=title, | |
400 | colormap=colormap) |
|
406 | colormap=colormap) | |
401 | return |
|
407 | return | |
402 |
|
408 | |||
403 | self.__driver.pcolor(self.plot, z, |
|
409 | self.__driver.pcolor(self.plot, z, | |
404 | xlabel=xlabel, |
|
410 | xlabel=xlabel, | |
405 | ylabel=ylabel, |
|
411 | ylabel=ylabel, | |
406 | title=title) |
|
412 | title=title) | |
407 |
|
413 | |||
408 | No newline at end of file |
|
414 |
@@ -1,990 +1,1004 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime |
|
2 | import time, datetime, os | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 |
|
4 | |||
5 | class CrossSpectraPlot(Figure): |
|
5 | class CrossSpectraPlot(Figure): | |
6 |
|
6 | |||
7 | __isConfig = None |
|
7 | __isConfig = None | |
8 | __nsubplots = None |
|
8 | __nsubplots = None | |
9 |
|
9 | |||
10 | WIDTH = None |
|
10 | WIDTH = None | |
11 | HEIGHT = None |
|
11 | HEIGHT = None | |
12 | WIDTHPROF = None |
|
12 | WIDTHPROF = None | |
13 | HEIGHTPROF = None |
|
13 | HEIGHTPROF = None | |
14 | PREFIX = 'cspc' |
|
14 | PREFIX = 'cspc' | |
15 |
|
15 | |||
16 | def __init__(self): |
|
16 | def __init__(self): | |
17 |
|
17 | |||
18 | self.__isConfig = False |
|
18 | self.__isConfig = False | |
19 | self.__nsubplots = 4 |
|
19 | self.__nsubplots = 4 | |
20 |
|
20 | |||
21 | self.WIDTH = 250 |
|
21 | self.WIDTH = 250 | |
22 | self.HEIGHT = 250 |
|
22 | self.HEIGHT = 250 | |
23 | self.WIDTHPROF = 0 |
|
23 | self.WIDTHPROF = 0 | |
24 | self.HEIGHTPROF = 0 |
|
24 | self.HEIGHTPROF = 0 | |
25 |
|
25 | |||
26 | def getSubplots(self): |
|
26 | def getSubplots(self): | |
27 |
|
27 | |||
28 | ncol = 4 |
|
28 | ncol = 4 | |
29 | nrow = self.nplots |
|
29 | nrow = self.nplots | |
30 |
|
30 | |||
31 | return nrow, ncol |
|
31 | return nrow, ncol | |
32 |
|
32 | |||
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
34 |
|
34 | |||
35 | self.__showprofile = showprofile |
|
35 | self.__showprofile = showprofile | |
36 | self.nplots = nplots |
|
36 | self.nplots = nplots | |
37 |
|
37 | |||
38 | ncolspan = 1 |
|
38 | ncolspan = 1 | |
39 | colspan = 1 |
|
39 | colspan = 1 | |
40 |
|
40 | |||
41 | self.createFigure(idfigure = idfigure, |
|
41 | self.createFigure(idfigure = idfigure, | |
42 | wintitle = wintitle, |
|
42 | wintitle = wintitle, | |
43 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
43 | widthplot = self.WIDTH + self.WIDTHPROF, | |
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
45 |
|
45 | |||
46 | nrow, ncol = self.getSubplots() |
|
46 | nrow, ncol = self.getSubplots() | |
47 |
|
47 | |||
48 | counter = 0 |
|
48 | counter = 0 | |
49 | for y in range(nrow): |
|
49 | for y in range(nrow): | |
50 | for x in range(ncol): |
|
50 | for x in range(ncol): | |
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
52 |
|
52 | |||
53 | counter += 1 |
|
53 | counter += 1 | |
54 |
|
54 | |||
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
57 | save=False, figpath='./', figfile=None, |
|
57 | save=False, figpath='./', figfile=None, | |
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): | |
59 |
|
59 | |||
60 | """ |
|
60 | """ | |
61 |
|
61 | |||
62 | Input: |
|
62 | Input: | |
63 | dataOut : |
|
63 | dataOut : | |
64 | idfigure : |
|
64 | idfigure : | |
65 | wintitle : |
|
65 | wintitle : | |
66 | channelList : |
|
66 | channelList : | |
67 | showProfile : |
|
67 | showProfile : | |
68 | xmin : None, |
|
68 | xmin : None, | |
69 | xmax : None, |
|
69 | xmax : None, | |
70 | ymin : None, |
|
70 | ymin : None, | |
71 | ymax : None, |
|
71 | ymax : None, | |
72 | zmin : None, |
|
72 | zmin : None, | |
73 | zmax : None |
|
73 | zmax : None | |
74 | """ |
|
74 | """ | |
75 |
|
75 | |||
76 | if pairsList == None: |
|
76 | if pairsList == None: | |
77 | pairsIndexList = dataOut.pairsIndexList |
|
77 | pairsIndexList = dataOut.pairsIndexList | |
78 | else: |
|
78 | else: | |
79 | pairsIndexList = [] |
|
79 | pairsIndexList = [] | |
80 | for pair in pairsList: |
|
80 | for pair in pairsList: | |
81 | if pair not in dataOut.pairsList: |
|
81 | if pair not in dataOut.pairsList: | |
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
84 |
|
84 | |||
85 | if pairsIndexList == []: |
|
85 | if pairsIndexList == []: | |
86 | return |
|
86 | return | |
87 |
|
87 | |||
88 | if len(pairsIndexList) > 4: |
|
88 | if len(pairsIndexList) > 4: | |
89 | pairsIndexList = pairsIndexList[0:4] |
|
89 | pairsIndexList = pairsIndexList[0:4] | |
90 | factor = dataOut.normFactor |
|
90 | factor = dataOut.normFactor | |
91 | x = dataOut.getVelRange(1) |
|
91 | x = dataOut.getVelRange(1) | |
92 | y = dataOut.getHeiRange() |
|
92 | y = dataOut.getHeiRange() | |
93 | z = dataOut.data_spc[:,:,:]/factor |
|
93 | z = dataOut.data_spc[:,:,:]/factor | |
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
95 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
95 | avg = numpy.abs(numpy.average(z, axis=1)) | |
96 | noise = dataOut.getNoise()/factor |
|
96 | noise = dataOut.getNoise()/factor | |
97 |
|
97 | |||
98 | zdB = 10*numpy.log10(z) |
|
98 | zdB = 10*numpy.log10(z) | |
99 | avgdB = 10*numpy.log10(avg) |
|
99 | avgdB = 10*numpy.log10(avg) | |
100 | noisedB = 10*numpy.log10(noise) |
|
100 | noisedB = 10*numpy.log10(noise) | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | thisDatetime = dataOut.datatime |
|
103 | thisDatetime = dataOut.datatime | |
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
105 | xlabel = "Velocity (m/s)" |
|
105 | xlabel = "Velocity (m/s)" | |
106 | ylabel = "Range (Km)" |
|
106 | ylabel = "Range (Km)" | |
107 |
|
107 | |||
108 | if not self.__isConfig: |
|
108 | if not self.__isConfig: | |
109 |
|
109 | |||
110 | nplots = len(pairsIndexList) |
|
110 | nplots = len(pairsIndexList) | |
111 |
|
111 | |||
112 | self.setup(idfigure=idfigure, |
|
112 | self.setup(idfigure=idfigure, | |
113 | nplots=nplots, |
|
113 | nplots=nplots, | |
114 | wintitle=wintitle, |
|
114 | wintitle=wintitle, | |
115 | showprofile=showprofile) |
|
115 | showprofile=showprofile) | |
116 |
|
116 | |||
117 | if xmin == None: xmin = numpy.nanmin(x) |
|
117 | if xmin == None: xmin = numpy.nanmin(x) | |
118 | if xmax == None: xmax = numpy.nanmax(x) |
|
118 | if xmax == None: xmax = numpy.nanmax(x) | |
119 | if ymin == None: ymin = numpy.nanmin(y) |
|
119 | if ymin == None: ymin = numpy.nanmin(y) | |
120 | if ymax == None: ymax = numpy.nanmax(y) |
|
120 | if ymax == None: ymax = numpy.nanmax(y) | |
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
123 |
|
123 | |||
124 | self.__isConfig = True |
|
124 | self.__isConfig = True | |
125 |
|
125 | |||
126 | self.setWinTitle(title) |
|
126 | self.setWinTitle(title) | |
127 |
|
127 | |||
128 | for i in range(self.nplots): |
|
128 | for i in range(self.nplots): | |
129 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
129 | pair = dataOut.pairsList[pairsIndexList[i]] | |
130 |
|
130 | |||
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) |
|
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) | |
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) | |
133 | axes0 = self.axesList[i*self.__nsubplots] |
|
133 | axes0 = self.axesList[i*self.__nsubplots] | |
134 | axes0.pcolor(x, y, zdB, |
|
134 | axes0.pcolor(x, y, zdB, | |
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
136 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
136 | xlabel=xlabel, ylabel=ylabel, title=title, | |
137 | ticksize=9, colormap=power_cmap, cblabel='') |
|
137 | ticksize=9, colormap=power_cmap, cblabel='') | |
138 |
|
138 | |||
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) |
|
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) | |
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) | |
141 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
141 | axes0 = self.axesList[i*self.__nsubplots+1] | |
142 | axes0.pcolor(x, y, zdB, |
|
142 | axes0.pcolor(x, y, zdB, | |
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
144 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
144 | xlabel=xlabel, ylabel=ylabel, title=title, | |
145 | ticksize=9, colormap=power_cmap, cblabel='') |
|
145 | ticksize=9, colormap=power_cmap, cblabel='') | |
146 |
|
146 | |||
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
148 | coherence = numpy.abs(coherenceComplex) |
|
148 | coherence = numpy.abs(coherenceComplex) | |
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
151 |
|
151 | |||
152 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
152 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
153 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
153 | axes0 = self.axesList[i*self.__nsubplots+2] | |
154 | axes0.pcolor(x, y, coherence, |
|
154 | axes0.pcolor(x, y, coherence, | |
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
156 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
156 | xlabel=xlabel, ylabel=ylabel, title=title, | |
157 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
157 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
158 |
|
158 | |||
159 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
159 | title = "Phase %d%d" %(pair[0], pair[1]) | |
160 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
160 | axes0 = self.axesList[i*self.__nsubplots+3] | |
161 | axes0.pcolor(x, y, phase, |
|
161 | axes0.pcolor(x, y, phase, | |
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
163 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
163 | xlabel=xlabel, ylabel=ylabel, title=title, | |
164 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
164 | ticksize=9, colormap=phase_cmap, cblabel='') | |
165 |
|
165 | |||
166 |
|
166 | |||
167 |
|
167 | |||
168 | self.draw() |
|
168 | self.draw() | |
169 |
|
169 | |||
170 | if save: |
|
170 | if save: | |
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
172 | if figfile == None: |
|
172 | if figfile == None: | |
173 | figfile = self.getFilename(name = date) |
|
173 | figfile = self.getFilename(name = date) | |
174 |
|
174 | |||
175 | self.saveFigure(figpath, figfile) |
|
175 | self.saveFigure(figpath, figfile) | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | class RTIPlot(Figure): |
|
178 | class RTIPlot(Figure): | |
179 |
|
179 | |||
180 | __isConfig = None |
|
180 | __isConfig = None | |
181 | __nsubplots = None |
|
181 | __nsubplots = None | |
182 |
|
182 | |||
183 | WIDTHPROF = None |
|
183 | WIDTHPROF = None | |
184 | HEIGHTPROF = None |
|
184 | HEIGHTPROF = None | |
185 | PREFIX = 'rti' |
|
185 | PREFIX = 'rti' | |
186 |
|
186 | |||
187 | def __init__(self): |
|
187 | def __init__(self): | |
188 |
|
188 | |||
189 | self.timerange = 2*60*60 |
|
189 | self.timerange = 2*60*60 | |
190 | self.__isConfig = False |
|
190 | self.__isConfig = False | |
191 | self.__nsubplots = 1 |
|
191 | self.__nsubplots = 1 | |
192 |
|
192 | |||
193 | self.WIDTH = 800 |
|
193 | self.WIDTH = 800 | |
194 | self.HEIGHT = 150 |
|
194 | self.HEIGHT = 150 | |
195 | self.WIDTHPROF = 120 |
|
195 | self.WIDTHPROF = 120 | |
196 | self.HEIGHTPROF = 0 |
|
196 | self.HEIGHTPROF = 0 | |
|
197 | self.counterftp = 0 | |||
197 |
|
198 | |||
198 | def getSubplots(self): |
|
199 | def getSubplots(self): | |
199 |
|
200 | |||
200 | ncol = 1 |
|
201 | ncol = 1 | |
201 | nrow = self.nplots |
|
202 | nrow = self.nplots | |
202 |
|
203 | |||
203 | return nrow, ncol |
|
204 | return nrow, ncol | |
204 |
|
205 | |||
205 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
206 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
206 |
|
207 | |||
207 | self.__showprofile = showprofile |
|
208 | self.__showprofile = showprofile | |
208 | self.nplots = nplots |
|
209 | self.nplots = nplots | |
209 |
|
210 | |||
210 | ncolspan = 1 |
|
211 | ncolspan = 1 | |
211 | colspan = 1 |
|
212 | colspan = 1 | |
212 | if showprofile: |
|
213 | if showprofile: | |
213 | ncolspan = 7 |
|
214 | ncolspan = 7 | |
214 | colspan = 6 |
|
215 | colspan = 6 | |
215 | self.__nsubplots = 2 |
|
216 | self.__nsubplots = 2 | |
216 |
|
217 | |||
217 | self.createFigure(idfigure = idfigure, |
|
218 | self.createFigure(idfigure = idfigure, | |
218 | wintitle = wintitle, |
|
219 | wintitle = wintitle, | |
219 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
220 | widthplot = self.WIDTH + self.WIDTHPROF, | |
220 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
221 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
221 |
|
222 | |||
222 | nrow, ncol = self.getSubplots() |
|
223 | nrow, ncol = self.getSubplots() | |
223 |
|
224 | |||
224 | counter = 0 |
|
225 | counter = 0 | |
225 | for y in range(nrow): |
|
226 | for y in range(nrow): | |
226 | for x in range(ncol): |
|
227 | for x in range(ncol): | |
227 |
|
228 | |||
228 | if counter >= self.nplots: |
|
229 | if counter >= self.nplots: | |
229 | break |
|
230 | break | |
230 |
|
231 | |||
231 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
232 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
232 |
|
233 | |||
233 | if showprofile: |
|
234 | if showprofile: | |
234 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
235 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
235 |
|
236 | |||
236 | counter += 1 |
|
237 | counter += 1 | |
237 |
|
238 | |||
238 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
239 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
239 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
240 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
240 | timerange=None, |
|
241 | timerange=None, | |
241 | save=False, figpath='./', figfile=None): |
|
242 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1): | |
242 |
|
243 | |||
243 | """ |
|
244 | """ | |
244 |
|
245 | |||
245 | Input: |
|
246 | Input: | |
246 | dataOut : |
|
247 | dataOut : | |
247 | idfigure : |
|
248 | idfigure : | |
248 | wintitle : |
|
249 | wintitle : | |
249 | channelList : |
|
250 | channelList : | |
250 | showProfile : |
|
251 | showProfile : | |
251 | xmin : None, |
|
252 | xmin : None, | |
252 | xmax : None, |
|
253 | xmax : None, | |
253 | ymin : None, |
|
254 | ymin : None, | |
254 | ymax : None, |
|
255 | ymax : None, | |
255 | zmin : None, |
|
256 | zmin : None, | |
256 | zmax : None |
|
257 | zmax : None | |
257 | """ |
|
258 | """ | |
258 |
|
259 | |||
259 | if channelList == None: |
|
260 | if channelList == None: | |
260 | channelIndexList = dataOut.channelIndexList |
|
261 | channelIndexList = dataOut.channelIndexList | |
261 | else: |
|
262 | else: | |
262 | channelIndexList = [] |
|
263 | channelIndexList = [] | |
263 | for channel in channelList: |
|
264 | for channel in channelList: | |
264 | if channel not in dataOut.channelList: |
|
265 | if channel not in dataOut.channelList: | |
265 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
266 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
266 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
267 | channelIndexList.append(dataOut.channelList.index(channel)) | |
267 |
|
268 | |||
268 | if timerange != None: |
|
269 | if timerange != None: | |
269 | self.timerange = timerange |
|
270 | self.timerange = timerange | |
270 |
|
271 | |||
271 | tmin = None |
|
272 | tmin = None | |
272 | tmax = None |
|
273 | tmax = None | |
273 | factor = dataOut.normFactor |
|
274 | factor = dataOut.normFactor | |
274 | x = dataOut.getTimeRange() |
|
275 | x = dataOut.getTimeRange() | |
275 | y = dataOut.getHeiRange() |
|
276 | y = dataOut.getHeiRange() | |
276 |
|
277 | |||
277 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
278 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
278 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
279 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
279 | avg = numpy.average(z, axis=1) |
|
280 | avg = numpy.average(z, axis=1) | |
280 |
|
281 | |||
281 | avgdB = 10.*numpy.log10(avg) |
|
282 | avgdB = 10.*numpy.log10(avg) | |
282 |
|
283 | |||
283 |
|
284 | |||
284 | thisDatetime = dataOut.datatime |
|
285 | thisDatetime = dataOut.datatime | |
285 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
286 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
286 | xlabel = "" |
|
287 | xlabel = "" | |
287 | ylabel = "Range (Km)" |
|
288 | ylabel = "Range (Km)" | |
288 |
|
289 | |||
289 | if not self.__isConfig: |
|
290 | if not self.__isConfig: | |
290 |
|
291 | |||
291 | nplots = len(channelIndexList) |
|
292 | nplots = len(channelIndexList) | |
292 |
|
293 | |||
293 | self.setup(idfigure=idfigure, |
|
294 | self.setup(idfigure=idfigure, | |
294 | nplots=nplots, |
|
295 | nplots=nplots, | |
295 | wintitle=wintitle, |
|
296 | wintitle=wintitle, | |
296 | showprofile=showprofile) |
|
297 | showprofile=showprofile) | |
297 |
|
298 | |||
298 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
299 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
299 | if ymin == None: ymin = numpy.nanmin(y) |
|
300 | if ymin == None: ymin = numpy.nanmin(y) | |
300 | if ymax == None: ymax = numpy.nanmax(y) |
|
301 | if ymax == None: ymax = numpy.nanmax(y) | |
301 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
302 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
302 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
303 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
303 |
|
304 | |||
304 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
305 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
305 | self.__isConfig = True |
|
306 | self.__isConfig = True | |
306 |
|
307 | |||
307 |
|
308 | |||
308 | self.setWinTitle(title) |
|
309 | self.setWinTitle(title) | |
309 |
|
310 | |||
310 | for i in range(self.nplots): |
|
311 | for i in range(self.nplots): | |
311 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
312 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
312 | axes = self.axesList[i*self.__nsubplots] |
|
313 | axes = self.axesList[i*self.__nsubplots] | |
313 | zdB = avgdB[i].reshape((1,-1)) |
|
314 | zdB = avgdB[i].reshape((1,-1)) | |
314 | axes.pcolor(x, y, zdB, |
|
315 | axes.pcolor(x, y, zdB, | |
315 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
316 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
316 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
317 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
317 | ticksize=9, cblabel='', cbsize="1%") |
|
318 | ticksize=9, cblabel='', cbsize="1%") | |
318 |
|
319 | |||
319 | if self.__showprofile: |
|
320 | if self.__showprofile: | |
320 | axes = self.axesList[i*self.__nsubplots +1] |
|
321 | axes = self.axesList[i*self.__nsubplots +1] | |
321 | axes.pline(avgdB[i], y, |
|
322 | axes.pline(avgdB[i], y, | |
322 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
323 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
323 | xlabel='dB', ylabel='', title='', |
|
324 | xlabel='dB', ylabel='', title='', | |
324 | ytick_visible=False, |
|
325 | ytick_visible=False, | |
325 | grid='x') |
|
326 | grid='x') | |
326 |
|
327 | |||
327 | self.draw() |
|
328 | self.draw() | |
328 |
|
329 | |||
329 | if save: |
|
330 | if save: | |
330 |
|
331 | |||
331 | if figfile == None: |
|
332 | if figfile == None: | |
332 | figfile = self.getFilename(name = self.name) |
|
333 | figfile = self.getFilename(name = self.name) | |
333 |
|
334 | |||
334 | self.saveFigure(figpath, figfile) |
|
335 | self.saveFigure(figpath, figfile) | |
335 |
|
336 | |||
|
337 | self.counterftp += 1 | |||
|
338 | if (ftp and (self.counterftp==ftpratio)): | |||
|
339 | figfilename = os.path.join(figpath,figfile) | |||
|
340 | self.sendByFTP(figfilename) | |||
|
341 | self.counterftp = 0 | |||
|
342 | ||||
336 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
343 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
337 | self.__isConfig = False |
|
344 | self.__isConfig = False | |
338 |
|
345 | |||
339 | class SpectraPlot(Figure): |
|
346 | class SpectraPlot(Figure): | |
340 |
|
347 | |||
341 | __isConfig = None |
|
348 | __isConfig = None | |
342 | __nsubplots = None |
|
349 | __nsubplots = None | |
343 |
|
350 | |||
344 | WIDTHPROF = None |
|
351 | WIDTHPROF = None | |
345 | HEIGHTPROF = None |
|
352 | HEIGHTPROF = None | |
346 | PREFIX = 'spc' |
|
353 | PREFIX = 'spc' | |
347 |
|
354 | |||
348 | def __init__(self): |
|
355 | def __init__(self): | |
349 |
|
356 | |||
350 | self.__isConfig = False |
|
357 | self.__isConfig = False | |
351 | self.__nsubplots = 1 |
|
358 | self.__nsubplots = 1 | |
352 |
|
359 | |||
353 | self.WIDTH = 230 |
|
360 | self.WIDTH = 230 | |
354 | self.HEIGHT = 250 |
|
361 | self.HEIGHT = 250 | |
355 | self.WIDTHPROF = 120 |
|
362 | self.WIDTHPROF = 120 | |
356 | self.HEIGHTPROF = 0 |
|
363 | self.HEIGHTPROF = 0 | |
357 |
|
364 | |||
358 | def getSubplots(self): |
|
365 | def getSubplots(self): | |
359 |
|
366 | |||
360 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
367 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
361 | nrow = int(self.nplots*1./ncol + 0.9) |
|
368 | nrow = int(self.nplots*1./ncol + 0.9) | |
362 |
|
369 | |||
363 | return nrow, ncol |
|
370 | return nrow, ncol | |
364 |
|
371 | |||
365 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
372 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
366 |
|
373 | |||
367 | self.__showprofile = showprofile |
|
374 | self.__showprofile = showprofile | |
368 | self.nplots = nplots |
|
375 | self.nplots = nplots | |
369 |
|
376 | |||
370 | ncolspan = 1 |
|
377 | ncolspan = 1 | |
371 | colspan = 1 |
|
378 | colspan = 1 | |
372 | if showprofile: |
|
379 | if showprofile: | |
373 | ncolspan = 3 |
|
380 | ncolspan = 3 | |
374 | colspan = 2 |
|
381 | colspan = 2 | |
375 | self.__nsubplots = 2 |
|
382 | self.__nsubplots = 2 | |
376 |
|
383 | |||
377 | self.createFigure(idfigure = idfigure, |
|
384 | self.createFigure(idfigure = idfigure, | |
378 | wintitle = wintitle, |
|
385 | wintitle = wintitle, | |
379 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
386 | widthplot = self.WIDTH + self.WIDTHPROF, | |
380 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
387 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
381 |
|
388 | |||
382 | nrow, ncol = self.getSubplots() |
|
389 | nrow, ncol = self.getSubplots() | |
383 |
|
390 | |||
384 | counter = 0 |
|
391 | counter = 0 | |
385 | for y in range(nrow): |
|
392 | for y in range(nrow): | |
386 | for x in range(ncol): |
|
393 | for x in range(ncol): | |
387 |
|
394 | |||
388 | if counter >= self.nplots: |
|
395 | if counter >= self.nplots: | |
389 | break |
|
396 | break | |
390 |
|
397 | |||
391 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
398 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
392 |
|
399 | |||
393 | if showprofile: |
|
400 | if showprofile: | |
394 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
401 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
395 |
|
402 | |||
396 | counter += 1 |
|
403 | counter += 1 | |
397 |
|
404 | |||
398 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
405 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
399 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
406 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
400 | save=False, figpath='./', figfile=None): |
|
407 | save=False, figpath='./', figfile=None): | |
401 |
|
408 | |||
402 | """ |
|
409 | """ | |
403 |
|
410 | |||
404 | Input: |
|
411 | Input: | |
405 | dataOut : |
|
412 | dataOut : | |
406 | idfigure : |
|
413 | idfigure : | |
407 | wintitle : |
|
414 | wintitle : | |
408 | channelList : |
|
415 | channelList : | |
409 | showProfile : |
|
416 | showProfile : | |
410 | xmin : None, |
|
417 | xmin : None, | |
411 | xmax : None, |
|
418 | xmax : None, | |
412 | ymin : None, |
|
419 | ymin : None, | |
413 | ymax : None, |
|
420 | ymax : None, | |
414 | zmin : None, |
|
421 | zmin : None, | |
415 | zmax : None |
|
422 | zmax : None | |
416 | """ |
|
423 | """ | |
417 |
|
424 | |||
418 | if channelList == None: |
|
425 | if channelList == None: | |
419 | channelIndexList = dataOut.channelIndexList |
|
426 | channelIndexList = dataOut.channelIndexList | |
420 | else: |
|
427 | else: | |
421 | channelIndexList = [] |
|
428 | channelIndexList = [] | |
422 | for channel in channelList: |
|
429 | for channel in channelList: | |
423 | if channel not in dataOut.channelList: |
|
430 | if channel not in dataOut.channelList: | |
424 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
431 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
425 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
432 | channelIndexList.append(dataOut.channelList.index(channel)) | |
426 | factor = dataOut.normFactor |
|
433 | factor = dataOut.normFactor | |
427 | x = dataOut.getVelRange(1) |
|
434 | x = dataOut.getVelRange(1) | |
428 | y = dataOut.getHeiRange() |
|
435 | y = dataOut.getHeiRange() | |
429 |
|
436 | |||
430 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
437 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
431 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
438 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
432 | avg = numpy.average(z, axis=1) |
|
439 | avg = numpy.average(z, axis=1) | |
433 | noise = dataOut.getNoise()/factor |
|
440 | noise = dataOut.getNoise()/factor | |
434 |
|
441 | |||
435 | zdB = 10*numpy.log10(z) |
|
442 | zdB = 10*numpy.log10(z) | |
436 | avgdB = 10*numpy.log10(avg) |
|
443 | avgdB = 10*numpy.log10(avg) | |
437 | noisedB = 10*numpy.log10(noise) |
|
444 | noisedB = 10*numpy.log10(noise) | |
438 |
|
445 | |||
439 | thisDatetime = dataOut.datatime |
|
446 | thisDatetime = dataOut.datatime | |
440 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
447 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
441 | xlabel = "Velocity (m/s)" |
|
448 | xlabel = "Velocity (m/s)" | |
442 | ylabel = "Range (Km)" |
|
449 | ylabel = "Range (Km)" | |
443 |
|
450 | |||
444 | if not self.__isConfig: |
|
451 | if not self.__isConfig: | |
445 |
|
452 | |||
446 | nplots = len(channelIndexList) |
|
453 | nplots = len(channelIndexList) | |
447 |
|
454 | |||
448 | self.setup(idfigure=idfigure, |
|
455 | self.setup(idfigure=idfigure, | |
449 | nplots=nplots, |
|
456 | nplots=nplots, | |
450 | wintitle=wintitle, |
|
457 | wintitle=wintitle, | |
451 | showprofile=showprofile) |
|
458 | showprofile=showprofile) | |
452 |
|
459 | |||
453 | if xmin == None: xmin = numpy.nanmin(x) |
|
460 | if xmin == None: xmin = numpy.nanmin(x) | |
454 | if xmax == None: xmax = numpy.nanmax(x) |
|
461 | if xmax == None: xmax = numpy.nanmax(x) | |
455 | if ymin == None: ymin = numpy.nanmin(y) |
|
462 | if ymin == None: ymin = numpy.nanmin(y) | |
456 | if ymax == None: ymax = numpy.nanmax(y) |
|
463 | if ymax == None: ymax = numpy.nanmax(y) | |
457 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
464 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
458 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
465 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
459 |
|
466 | |||
460 | self.__isConfig = True |
|
467 | self.__isConfig = True | |
461 |
|
468 | |||
462 | self.setWinTitle(title) |
|
469 | self.setWinTitle(title) | |
463 |
|
470 | |||
464 | for i in range(self.nplots): |
|
471 | for i in range(self.nplots): | |
465 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) |
|
472 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) | |
466 | axes = self.axesList[i*self.__nsubplots] |
|
473 | axes = self.axesList[i*self.__nsubplots] | |
467 | axes.pcolor(x, y, zdB[i,:,:], |
|
474 | axes.pcolor(x, y, zdB[i,:,:], | |
468 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
475 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
469 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
476 | xlabel=xlabel, ylabel=ylabel, title=title, | |
470 | ticksize=9, cblabel='') |
|
477 | ticksize=9, cblabel='') | |
471 |
|
478 | |||
472 | if self.__showprofile: |
|
479 | if self.__showprofile: | |
473 | axes = self.axesList[i*self.__nsubplots +1] |
|
480 | axes = self.axesList[i*self.__nsubplots +1] | |
474 | axes.pline(avgdB[i], y, |
|
481 | axes.pline(avgdB[i], y, | |
475 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
482 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
476 | xlabel='dB', ylabel='', title='', |
|
483 | xlabel='dB', ylabel='', title='', | |
477 | ytick_visible=False, |
|
484 | ytick_visible=False, | |
478 | grid='x') |
|
485 | grid='x') | |
479 |
|
486 | |||
480 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
487 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
481 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
488 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
482 |
|
489 | |||
483 | self.draw() |
|
490 | self.draw() | |
484 |
|
491 | |||
485 | if save: |
|
492 | if save: | |
486 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
493 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
487 | if figfile == None: |
|
494 | if figfile == None: | |
488 | figfile = self.getFilename(name = date) |
|
495 | figfile = self.getFilename(name = date) | |
489 |
|
496 | |||
490 | self.saveFigure(figpath, figfile) |
|
497 | self.saveFigure(figpath, figfile) | |
491 |
|
498 | |||
492 | class Scope(Figure): |
|
499 | class Scope(Figure): | |
493 |
|
500 | |||
494 | __isConfig = None |
|
501 | __isConfig = None | |
495 |
|
502 | |||
496 | def __init__(self): |
|
503 | def __init__(self): | |
497 |
|
504 | |||
498 | self.__isConfig = False |
|
505 | self.__isConfig = False | |
499 | self.WIDTH = 600 |
|
506 | self.WIDTH = 600 | |
500 | self.HEIGHT = 200 |
|
507 | self.HEIGHT = 200 | |
501 |
|
508 | |||
502 | def getSubplots(self): |
|
509 | def getSubplots(self): | |
503 |
|
510 | |||
504 | nrow = self.nplots |
|
511 | nrow = self.nplots | |
505 | ncol = 3 |
|
512 | ncol = 3 | |
506 | return nrow, ncol |
|
513 | return nrow, ncol | |
507 |
|
514 | |||
508 | def setup(self, idfigure, nplots, wintitle): |
|
515 | def setup(self, idfigure, nplots, wintitle): | |
509 |
|
516 | |||
510 | self.nplots = nplots |
|
517 | self.nplots = nplots | |
511 |
|
518 | |||
512 | self.createFigure(idfigure, wintitle) |
|
519 | self.createFigure(idfigure, wintitle) | |
513 |
|
520 | |||
514 | nrow,ncol = self.getSubplots() |
|
521 | nrow,ncol = self.getSubplots() | |
515 | colspan = 3 |
|
522 | colspan = 3 | |
516 | rowspan = 1 |
|
523 | rowspan = 1 | |
517 |
|
524 | |||
518 | for i in range(nplots): |
|
525 | for i in range(nplots): | |
519 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
526 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
520 |
|
527 | |||
521 |
|
528 | |||
522 |
|
529 | |||
523 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
530 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
524 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
531 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
525 | figpath='./', figfile=None): |
|
532 | figpath='./', figfile=None): | |
526 |
|
533 | |||
527 | """ |
|
534 | """ | |
528 |
|
535 | |||
529 | Input: |
|
536 | Input: | |
530 | dataOut : |
|
537 | dataOut : | |
531 | idfigure : |
|
538 | idfigure : | |
532 | wintitle : |
|
539 | wintitle : | |
533 | channelList : |
|
540 | channelList : | |
534 | xmin : None, |
|
541 | xmin : None, | |
535 | xmax : None, |
|
542 | xmax : None, | |
536 | ymin : None, |
|
543 | ymin : None, | |
537 | ymax : None, |
|
544 | ymax : None, | |
538 | """ |
|
545 | """ | |
539 |
|
546 | |||
540 | if channelList == None: |
|
547 | if channelList == None: | |
541 | channelIndexList = dataOut.channelIndexList |
|
548 | channelIndexList = dataOut.channelIndexList | |
542 | else: |
|
549 | else: | |
543 | channelIndexList = [] |
|
550 | channelIndexList = [] | |
544 | for channel in channelList: |
|
551 | for channel in channelList: | |
545 | if channel not in dataOut.channelList: |
|
552 | if channel not in dataOut.channelList: | |
546 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
553 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
547 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
554 | channelIndexList.append(dataOut.channelList.index(channel)) | |
548 |
|
555 | |||
549 | x = dataOut.heightList |
|
556 | x = dataOut.heightList | |
550 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
557 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
551 | y = y.real |
|
558 | y = y.real | |
552 |
|
559 | |||
553 | thisDatetime = dataOut.datatime |
|
560 | thisDatetime = dataOut.datatime | |
554 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
561 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
555 | xlabel = "Range (Km)" |
|
562 | xlabel = "Range (Km)" | |
556 | ylabel = "Intensity" |
|
563 | ylabel = "Intensity" | |
557 |
|
564 | |||
558 | if not self.__isConfig: |
|
565 | if not self.__isConfig: | |
559 | nplots = len(channelIndexList) |
|
566 | nplots = len(channelIndexList) | |
560 |
|
567 | |||
561 | self.setup(idfigure=idfigure, |
|
568 | self.setup(idfigure=idfigure, | |
562 | nplots=nplots, |
|
569 | nplots=nplots, | |
563 | wintitle=wintitle) |
|
570 | wintitle=wintitle) | |
564 |
|
571 | |||
565 | if xmin == None: xmin = numpy.nanmin(x) |
|
572 | if xmin == None: xmin = numpy.nanmin(x) | |
566 | if xmax == None: xmax = numpy.nanmax(x) |
|
573 | if xmax == None: xmax = numpy.nanmax(x) | |
567 | if ymin == None: ymin = numpy.nanmin(y) |
|
574 | if ymin == None: ymin = numpy.nanmin(y) | |
568 | if ymax == None: ymax = numpy.nanmax(y) |
|
575 | if ymax == None: ymax = numpy.nanmax(y) | |
569 |
|
576 | |||
570 | self.__isConfig = True |
|
577 | self.__isConfig = True | |
571 |
|
578 | |||
572 | self.setWinTitle(title) |
|
579 | self.setWinTitle(title) | |
573 |
|
580 | |||
574 | for i in range(len(self.axesList)): |
|
581 | for i in range(len(self.axesList)): | |
575 | title = "Channel %d" %(i) |
|
582 | title = "Channel %d" %(i) | |
576 | axes = self.axesList[i] |
|
583 | axes = self.axesList[i] | |
577 | ychannel = y[i,:] |
|
584 | ychannel = y[i,:] | |
578 | axes.pline(x, ychannel, |
|
585 | axes.pline(x, ychannel, | |
579 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
586 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
580 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
587 | xlabel=xlabel, ylabel=ylabel, title=title) | |
581 |
|
588 | |||
582 | self.draw() |
|
589 | self.draw() | |
583 |
|
590 | |||
584 | if save: |
|
591 | if save: | |
585 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
592 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
586 | if figfile == None: |
|
593 | if figfile == None: | |
587 | figfile = self.getFilename(name = date) |
|
594 | figfile = self.getFilename(name = date) | |
588 |
|
595 | |||
589 | self.saveFigure(figpath, figfile) |
|
596 | self.saveFigure(figpath, figfile) | |
590 |
|
597 | |||
591 | class ProfilePlot(Figure): |
|
598 | class ProfilePlot(Figure): | |
592 | __isConfig = None |
|
599 | __isConfig = None | |
593 | __nsubplots = None |
|
600 | __nsubplots = None | |
594 |
|
601 | |||
595 | WIDTHPROF = None |
|
602 | WIDTHPROF = None | |
596 | HEIGHTPROF = None |
|
603 | HEIGHTPROF = None | |
597 | PREFIX = 'spcprofile' |
|
604 | PREFIX = 'spcprofile' | |
598 |
|
605 | |||
599 | def __init__(self): |
|
606 | def __init__(self): | |
600 | self.__isConfig = False |
|
607 | self.__isConfig = False | |
601 | self.__nsubplots = 1 |
|
608 | self.__nsubplots = 1 | |
602 |
|
609 | |||
603 | self.WIDTH = 300 |
|
610 | self.WIDTH = 300 | |
604 | self.HEIGHT = 500 |
|
611 | self.HEIGHT = 500 | |
605 |
|
612 | |||
606 | def getSubplots(self): |
|
613 | def getSubplots(self): | |
607 | ncol = 1 |
|
614 | ncol = 1 | |
608 | nrow = 1 |
|
615 | nrow = 1 | |
609 |
|
616 | |||
610 | return nrow, ncol |
|
617 | return nrow, ncol | |
611 |
|
618 | |||
612 | def setup(self, idfigure, nplots, wintitle): |
|
619 | def setup(self, idfigure, nplots, wintitle): | |
613 |
|
620 | |||
614 | self.nplots = nplots |
|
621 | self.nplots = nplots | |
615 |
|
622 | |||
616 | ncolspan = 1 |
|
623 | ncolspan = 1 | |
617 | colspan = 1 |
|
624 | colspan = 1 | |
618 |
|
625 | |||
619 | self.createFigure(idfigure = idfigure, |
|
626 | self.createFigure(idfigure = idfigure, | |
620 | wintitle = wintitle, |
|
627 | wintitle = wintitle, | |
621 | widthplot = self.WIDTH, |
|
628 | widthplot = self.WIDTH, | |
622 | heightplot = self.HEIGHT) |
|
629 | heightplot = self.HEIGHT) | |
623 |
|
630 | |||
624 | nrow, ncol = self.getSubplots() |
|
631 | nrow, ncol = self.getSubplots() | |
625 |
|
632 | |||
626 | counter = 0 |
|
633 | counter = 0 | |
627 | for y in range(nrow): |
|
634 | for y in range(nrow): | |
628 | for x in range(ncol): |
|
635 | for x in range(ncol): | |
629 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
636 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
630 |
|
637 | |||
631 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
638 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
632 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
639 | xmin=None, xmax=None, ymin=None, ymax=None, | |
633 | save=False, figpath='./', figfile=None): |
|
640 | save=False, figpath='./', figfile=None): | |
634 |
|
641 | |||
635 | if channelList == None: |
|
642 | if channelList == None: | |
636 | channelIndexList = dataOut.channelIndexList |
|
643 | channelIndexList = dataOut.channelIndexList | |
637 | channelList = dataOut.channelList |
|
644 | channelList = dataOut.channelList | |
638 | else: |
|
645 | else: | |
639 | channelIndexList = [] |
|
646 | channelIndexList = [] | |
640 | for channel in channelList: |
|
647 | for channel in channelList: | |
641 | if channel not in dataOut.channelList: |
|
648 | if channel not in dataOut.channelList: | |
642 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
649 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
643 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
650 | channelIndexList.append(dataOut.channelList.index(channel)) | |
644 |
|
651 | |||
645 | factor = dataOut.normFactor |
|
652 | factor = dataOut.normFactor | |
646 | y = dataOut.getHeiRange() |
|
653 | y = dataOut.getHeiRange() | |
647 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
654 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
648 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
655 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
649 | avg = numpy.average(x, axis=1) |
|
656 | avg = numpy.average(x, axis=1) | |
650 |
|
657 | |||
651 | avgdB = 10*numpy.log10(avg) |
|
658 | avgdB = 10*numpy.log10(avg) | |
652 |
|
659 | |||
653 | thisDatetime = dataOut.datatime |
|
660 | thisDatetime = dataOut.datatime | |
654 | title = "Power Profile" |
|
661 | title = "Power Profile" | |
655 | xlabel = "dB" |
|
662 | xlabel = "dB" | |
656 | ylabel = "Range (Km)" |
|
663 | ylabel = "Range (Km)" | |
657 |
|
664 | |||
658 | if not self.__isConfig: |
|
665 | if not self.__isConfig: | |
659 |
|
666 | |||
660 | nplots = 1 |
|
667 | nplots = 1 | |
661 |
|
668 | |||
662 | self.setup(idfigure=idfigure, |
|
669 | self.setup(idfigure=idfigure, | |
663 | nplots=nplots, |
|
670 | nplots=nplots, | |
664 | wintitle=wintitle) |
|
671 | wintitle=wintitle) | |
665 |
|
672 | |||
666 | if ymin == None: ymin = numpy.nanmin(y) |
|
673 | if ymin == None: ymin = numpy.nanmin(y) | |
667 | if ymax == None: ymax = numpy.nanmax(y) |
|
674 | if ymax == None: ymax = numpy.nanmax(y) | |
668 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 |
|
675 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 | |
669 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 |
|
676 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 | |
670 |
|
677 | |||
671 | self.__isConfig = True |
|
678 | self.__isConfig = True | |
672 |
|
679 | |||
673 | self.setWinTitle(title) |
|
680 | self.setWinTitle(title) | |
674 |
|
681 | |||
675 |
|
682 | |||
676 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
683 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
677 | axes = self.axesList[0] |
|
684 | axes = self.axesList[0] | |
678 |
|
685 | |||
679 | legendlabels = ["channel %d"%x for x in channelList] |
|
686 | legendlabels = ["channel %d"%x for x in channelList] | |
680 | axes.pmultiline(avgdB, y, |
|
687 | axes.pmultiline(avgdB, y, | |
681 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
688 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
682 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
689 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
683 | ytick_visible=True, nxticks=5, |
|
690 | ytick_visible=True, nxticks=5, | |
684 | grid='x') |
|
691 | grid='x') | |
685 |
|
692 | |||
686 | self.draw() |
|
693 | self.draw() | |
687 |
|
694 | |||
688 | if save: |
|
695 | if save: | |
689 | date = thisDatetime.strftime("%Y%m%d") |
|
696 | date = thisDatetime.strftime("%Y%m%d") | |
690 | if figfile == None: |
|
697 | if figfile == None: | |
691 | figfile = self.getFilename(name = date) |
|
698 | figfile = self.getFilename(name = date) | |
692 |
|
699 | |||
693 | self.saveFigure(figpath, figfile) |
|
700 | self.saveFigure(figpath, figfile) | |
694 |
|
701 | |||
695 | class CoherenceMap(Figure): |
|
702 | class CoherenceMap(Figure): | |
696 | __isConfig = None |
|
703 | __isConfig = None | |
697 | __nsubplots = None |
|
704 | __nsubplots = None | |
698 |
|
705 | |||
699 | WIDTHPROF = None |
|
706 | WIDTHPROF = None | |
700 | HEIGHTPROF = None |
|
707 | HEIGHTPROF = None | |
701 | PREFIX = 'cmap' |
|
708 | PREFIX = 'cmap' | |
702 |
|
709 | |||
703 | def __init__(self): |
|
710 | def __init__(self): | |
704 | self.timerange = 2*60*60 |
|
711 | self.timerange = 2*60*60 | |
705 | self.__isConfig = False |
|
712 | self.__isConfig = False | |
706 | self.__nsubplots = 1 |
|
713 | self.__nsubplots = 1 | |
707 |
|
714 | |||
708 | self.WIDTH = 800 |
|
715 | self.WIDTH = 800 | |
709 | self.HEIGHT = 150 |
|
716 | self.HEIGHT = 150 | |
710 | self.WIDTHPROF = 120 |
|
717 | self.WIDTHPROF = 120 | |
711 | self.HEIGHTPROF = 0 |
|
718 | self.HEIGHTPROF = 0 | |
|
719 | self.counterftp = 0 | |||
712 |
|
720 | |||
713 | def getSubplots(self): |
|
721 | def getSubplots(self): | |
714 | ncol = 1 |
|
722 | ncol = 1 | |
715 | nrow = self.nplots*2 |
|
723 | nrow = self.nplots*2 | |
716 |
|
724 | |||
717 | return nrow, ncol |
|
725 | return nrow, ncol | |
718 |
|
726 | |||
719 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
727 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
720 | self.__showprofile = showprofile |
|
728 | self.__showprofile = showprofile | |
721 | self.nplots = nplots |
|
729 | self.nplots = nplots | |
722 |
|
730 | |||
723 | ncolspan = 1 |
|
731 | ncolspan = 1 | |
724 | colspan = 1 |
|
732 | colspan = 1 | |
725 | if showprofile: |
|
733 | if showprofile: | |
726 | ncolspan = 7 |
|
734 | ncolspan = 7 | |
727 | colspan = 6 |
|
735 | colspan = 6 | |
728 | self.__nsubplots = 2 |
|
736 | self.__nsubplots = 2 | |
729 |
|
737 | |||
730 | self.createFigure(idfigure = idfigure, |
|
738 | self.createFigure(idfigure = idfigure, | |
731 | wintitle = wintitle, |
|
739 | wintitle = wintitle, | |
732 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
740 | widthplot = self.WIDTH + self.WIDTHPROF, | |
733 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
741 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
734 |
|
742 | |||
735 | nrow, ncol = self.getSubplots() |
|
743 | nrow, ncol = self.getSubplots() | |
736 |
|
744 | |||
737 | for y in range(nrow): |
|
745 | for y in range(nrow): | |
738 | for x in range(ncol): |
|
746 | for x in range(ncol): | |
739 |
|
747 | |||
740 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
748 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
741 |
|
749 | |||
742 | if showprofile: |
|
750 | if showprofile: | |
743 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
751 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
744 |
|
752 | |||
745 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
753 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
746 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
754 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
747 | timerange=None, |
|
755 | timerange=None, | |
748 | save=False, figpath='./', figfile=None, |
|
756 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, | |
749 | coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
757 | coherence_cmap='jet', phase_cmap='RdBu_r'): | |
750 |
|
758 | |||
751 | if pairsList == None: |
|
759 | if pairsList == None: | |
752 | pairsIndexList = dataOut.pairsIndexList |
|
760 | pairsIndexList = dataOut.pairsIndexList | |
753 | else: |
|
761 | else: | |
754 | pairsIndexList = [] |
|
762 | pairsIndexList = [] | |
755 | for pair in pairsList: |
|
763 | for pair in pairsList: | |
756 | if pair not in dataOut.pairsList: |
|
764 | if pair not in dataOut.pairsList: | |
757 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
765 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
758 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
766 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
759 |
|
767 | |||
760 | if timerange != None: |
|
768 | if timerange != None: | |
761 | self.timerange = timerange |
|
769 | self.timerange = timerange | |
762 |
|
770 | |||
763 | if pairsIndexList == []: |
|
771 | if pairsIndexList == []: | |
764 | return |
|
772 | return | |
765 |
|
773 | |||
766 | if len(pairsIndexList) > 4: |
|
774 | if len(pairsIndexList) > 4: | |
767 | pairsIndexList = pairsIndexList[0:4] |
|
775 | pairsIndexList = pairsIndexList[0:4] | |
768 |
|
776 | |||
769 | tmin = None |
|
777 | tmin = None | |
770 | tmax = None |
|
778 | tmax = None | |
771 | x = dataOut.getTimeRange() |
|
779 | x = dataOut.getTimeRange() | |
772 | y = dataOut.getHeiRange() |
|
780 | y = dataOut.getHeiRange() | |
773 |
|
781 | |||
774 | thisDatetime = dataOut.datatime |
|
782 | thisDatetime = dataOut.datatime | |
775 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
783 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
776 | xlabel = "" |
|
784 | xlabel = "" | |
777 | ylabel = "Range (Km)" |
|
785 | ylabel = "Range (Km)" | |
778 |
|
786 | |||
779 | if not self.__isConfig: |
|
787 | if not self.__isConfig: | |
780 | nplots = len(pairsIndexList) |
|
788 | nplots = len(pairsIndexList) | |
781 | self.setup(idfigure=idfigure, |
|
789 | self.setup(idfigure=idfigure, | |
782 | nplots=nplots, |
|
790 | nplots=nplots, | |
783 | wintitle=wintitle, |
|
791 | wintitle=wintitle, | |
784 | showprofile=showprofile) |
|
792 | showprofile=showprofile) | |
785 |
|
793 | |||
786 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
794 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
787 | if ymin == None: ymin = numpy.nanmin(y) |
|
795 | if ymin == None: ymin = numpy.nanmin(y) | |
788 | if ymax == None: ymax = numpy.nanmax(y) |
|
796 | if ymax == None: ymax = numpy.nanmax(y) | |
789 |
|
797 | |||
790 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
798 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
791 |
|
799 | |||
792 | self.__isConfig = True |
|
800 | self.__isConfig = True | |
793 |
|
801 | |||
794 | self.setWinTitle(title) |
|
802 | self.setWinTitle(title) | |
795 |
|
803 | |||
796 | for i in range(self.nplots): |
|
804 | for i in range(self.nplots): | |
797 |
|
805 | |||
798 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
806 | pair = dataOut.pairsList[pairsIndexList[i]] | |
799 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
807 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
800 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
808 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) | |
801 | coherence = numpy.abs(avgcoherenceComplex) |
|
809 | coherence = numpy.abs(avgcoherenceComplex) | |
802 | # coherence = numpy.abs(coherenceComplex) |
|
810 | # coherence = numpy.abs(coherenceComplex) | |
803 | # avg = numpy.average(coherence, axis=0) |
|
811 | # avg = numpy.average(coherence, axis=0) | |
804 |
|
812 | |||
805 | z = coherence.reshape((1,-1)) |
|
813 | z = coherence.reshape((1,-1)) | |
806 |
|
814 | |||
807 | counter = 0 |
|
815 | counter = 0 | |
808 |
|
816 | |||
809 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
817 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
810 | axes = self.axesList[i*self.__nsubplots*2] |
|
818 | axes = self.axesList[i*self.__nsubplots*2] | |
811 | axes.pcolor(x, y, z, |
|
819 | axes.pcolor(x, y, z, | |
812 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
820 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
813 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
821 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
814 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
822 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
815 |
|
823 | |||
816 | if self.__showprofile: |
|
824 | if self.__showprofile: | |
817 | counter += 1 |
|
825 | counter += 1 | |
818 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
826 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
819 | axes.pline(coherence, y, |
|
827 | axes.pline(coherence, y, | |
820 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
828 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, | |
821 | xlabel='', ylabel='', title='', ticksize=7, |
|
829 | xlabel='', ylabel='', title='', ticksize=7, | |
822 | ytick_visible=False, nxticks=5, |
|
830 | ytick_visible=False, nxticks=5, | |
823 | grid='x') |
|
831 | grid='x') | |
824 |
|
832 | |||
825 | counter += 1 |
|
833 | counter += 1 | |
826 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
834 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
827 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
835 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
828 | # avg = numpy.average(phase, axis=0) |
|
836 | # avg = numpy.average(phase, axis=0) | |
829 | z = phase.reshape((1,-1)) |
|
837 | z = phase.reshape((1,-1)) | |
830 |
|
838 | |||
831 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
839 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
832 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
833 | axes.pcolor(x, y, z, |
|
841 | axes.pcolor(x, y, z, | |
834 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
842 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
835 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
843 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
836 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
844 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
837 |
|
845 | |||
838 | if self.__showprofile: |
|
846 | if self.__showprofile: | |
839 | counter += 1 |
|
847 | counter += 1 | |
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
848 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
841 | axes.pline(phase, y, |
|
849 | axes.pline(phase, y, | |
842 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
850 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
843 | xlabel='', ylabel='', title='', ticksize=7, |
|
851 | xlabel='', ylabel='', title='', ticksize=7, | |
844 | ytick_visible=False, nxticks=4, |
|
852 | ytick_visible=False, nxticks=4, | |
845 | grid='x') |
|
853 | grid='x') | |
846 |
|
854 | |||
847 | self.draw() |
|
855 | self.draw() | |
848 |
|
856 | |||
849 | if save: |
|
857 | if save: | |
850 |
|
858 | |||
851 | if figfile == None: |
|
859 | if figfile == None: | |
852 | figfile = self.getFilename(name = self.name) |
|
860 | figfile = self.getFilename(name = self.name) | |
853 |
|
861 | |||
854 | self.saveFigure(figpath, figfile) |
|
862 | self.saveFigure(figpath, figfile) | |
855 |
|
863 | |||
|
864 | self.counterftp += 1 | |||
|
865 | if (ftp and (self.counterftp==ftpratio)): | |||
|
866 | figfilename = os.path.join(figpath,figfile) | |||
|
867 | self.sendByFTP(figfilename) | |||
|
868 | self.counterftp = 0 | |||
|
869 | ||||
856 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
870 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
857 | self.__isConfig = False |
|
871 | self.__isConfig = False | |
858 |
|
872 | |||
859 | class RTIfromNoise(Figure): |
|
873 | class RTIfromNoise(Figure): | |
860 |
|
874 | |||
861 | __isConfig = None |
|
875 | __isConfig = None | |
862 | __nsubplots = None |
|
876 | __nsubplots = None | |
863 |
|
877 | |||
864 | PREFIX = 'rtinoise' |
|
878 | PREFIX = 'rtinoise' | |
865 |
|
879 | |||
866 | def __init__(self): |
|
880 | def __init__(self): | |
867 |
|
881 | |||
868 | self.timerange = 24*60*60 |
|
882 | self.timerange = 24*60*60 | |
869 | self.__isConfig = False |
|
883 | self.__isConfig = False | |
870 | self.__nsubplots = 1 |
|
884 | self.__nsubplots = 1 | |
871 |
|
885 | |||
872 | self.WIDTH = 820 |
|
886 | self.WIDTH = 820 | |
873 | self.HEIGHT = 200 |
|
887 | self.HEIGHT = 200 | |
874 | self.WIDTHPROF = 120 |
|
888 | self.WIDTHPROF = 120 | |
875 | self.HEIGHTPROF = 0 |
|
889 | self.HEIGHTPROF = 0 | |
876 | self.xdata = None |
|
890 | self.xdata = None | |
877 | self.ydata = None |
|
891 | self.ydata = None | |
878 |
|
892 | |||
879 | def getSubplots(self): |
|
893 | def getSubplots(self): | |
880 |
|
894 | |||
881 | ncol = 1 |
|
895 | ncol = 1 | |
882 | nrow = 1 |
|
896 | nrow = 1 | |
883 |
|
897 | |||
884 | return nrow, ncol |
|
898 | return nrow, ncol | |
885 |
|
899 | |||
886 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
900 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
887 |
|
901 | |||
888 | self.__showprofile = showprofile |
|
902 | self.__showprofile = showprofile | |
889 | self.nplots = nplots |
|
903 | self.nplots = nplots | |
890 |
|
904 | |||
891 | ncolspan = 7 |
|
905 | ncolspan = 7 | |
892 | colspan = 6 |
|
906 | colspan = 6 | |
893 | self.__nsubplots = 2 |
|
907 | self.__nsubplots = 2 | |
894 |
|
908 | |||
895 | self.createFigure(idfigure = idfigure, |
|
909 | self.createFigure(idfigure = idfigure, | |
896 | wintitle = wintitle, |
|
910 | wintitle = wintitle, | |
897 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
911 | widthplot = self.WIDTH+self.WIDTHPROF, | |
898 | heightplot = self.HEIGHT+self.HEIGHTPROF) |
|
912 | heightplot = self.HEIGHT+self.HEIGHTPROF) | |
899 |
|
913 | |||
900 | nrow, ncol = self.getSubplots() |
|
914 | nrow, ncol = self.getSubplots() | |
901 |
|
915 | |||
902 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
916 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
903 |
|
917 | |||
904 |
|
918 | |||
905 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
919 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
906 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
920 | xmin=None, xmax=None, ymin=None, ymax=None, | |
907 | timerange=None, |
|
921 | timerange=None, | |
908 | save=False, figpath='./', figfile=None): |
|
922 | save=False, figpath='./', figfile=None): | |
909 |
|
923 | |||
910 | if channelList == None: |
|
924 | if channelList == None: | |
911 | channelIndexList = dataOut.channelIndexList |
|
925 | channelIndexList = dataOut.channelIndexList | |
912 | channelList = dataOut.channelList |
|
926 | channelList = dataOut.channelList | |
913 | else: |
|
927 | else: | |
914 | channelIndexList = [] |
|
928 | channelIndexList = [] | |
915 | for channel in channelList: |
|
929 | for channel in channelList: | |
916 | if channel not in dataOut.channelList: |
|
930 | if channel not in dataOut.channelList: | |
917 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
931 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
918 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
932 | channelIndexList.append(dataOut.channelList.index(channel)) | |
919 |
|
933 | |||
920 | if timerange != None: |
|
934 | if timerange != None: | |
921 | self.timerange = timerange |
|
935 | self.timerange = timerange | |
922 |
|
936 | |||
923 | tmin = None |
|
937 | tmin = None | |
924 | tmax = None |
|
938 | tmax = None | |
925 | x = dataOut.getTimeRange() |
|
939 | x = dataOut.getTimeRange() | |
926 | y = dataOut.getHeiRange() |
|
940 | y = dataOut.getHeiRange() | |
927 | factor = dataOut.normFactor |
|
941 | factor = dataOut.normFactor | |
928 | noise = dataOut.getNoise()/factor |
|
942 | noise = dataOut.getNoise()/factor | |
929 | noisedB = 10*numpy.log10(noise) |
|
943 | noisedB = 10*numpy.log10(noise) | |
930 |
|
944 | |||
931 | thisDatetime = dataOut.datatime |
|
945 | thisDatetime = dataOut.datatime | |
932 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
946 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
933 | xlabel = "" |
|
947 | xlabel = "" | |
934 | ylabel = "Range (Km)" |
|
948 | ylabel = "Range (Km)" | |
935 |
|
949 | |||
936 | if not self.__isConfig: |
|
950 | if not self.__isConfig: | |
937 |
|
951 | |||
938 | nplots = 1 |
|
952 | nplots = 1 | |
939 |
|
953 | |||
940 | self.setup(idfigure=idfigure, |
|
954 | self.setup(idfigure=idfigure, | |
941 | nplots=nplots, |
|
955 | nplots=nplots, | |
942 | wintitle=wintitle, |
|
956 | wintitle=wintitle, | |
943 | showprofile=showprofile) |
|
957 | showprofile=showprofile) | |
944 |
|
958 | |||
945 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
959 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
946 | if ymin == None: ymin = numpy.nanmin(noisedB) |
|
960 | if ymin == None: ymin = numpy.nanmin(noisedB) | |
947 | if ymax == None: ymax = numpy.nanmax(noisedB) |
|
961 | if ymax == None: ymax = numpy.nanmax(noisedB) | |
948 |
|
962 | |||
949 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
963 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
950 | self.__isConfig = True |
|
964 | self.__isConfig = True | |
951 |
|
965 | |||
952 | self.xdata = numpy.array([]) |
|
966 | self.xdata = numpy.array([]) | |
953 | self.ydata = numpy.array([]) |
|
967 | self.ydata = numpy.array([]) | |
954 |
|
968 | |||
955 | self.setWinTitle(title) |
|
969 | self.setWinTitle(title) | |
956 |
|
970 | |||
957 |
|
971 | |||
958 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
972 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
959 |
|
973 | |||
960 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
974 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
961 | axes = self.axesList[0] |
|
975 | axes = self.axesList[0] | |
962 |
|
976 | |||
963 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
977 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
964 |
|
978 | |||
965 | if len(self.ydata)==0: |
|
979 | if len(self.ydata)==0: | |
966 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
980 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
967 | else: |
|
981 | else: | |
968 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
982 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
969 |
|
983 | |||
970 |
|
984 | |||
971 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
985 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
972 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
986 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
973 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
987 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
974 | XAxisAsTime=True |
|
988 | XAxisAsTime=True | |
975 | ) |
|
989 | ) | |
976 |
|
990 | |||
977 | self.draw() |
|
991 | self.draw() | |
978 |
|
992 | |||
979 | if save: |
|
993 | if save: | |
980 |
|
994 | |||
981 | if figfile == None: |
|
995 | if figfile == None: | |
982 | figfile = self.getFilename(name = self.name) |
|
996 | figfile = self.getFilename(name = self.name) | |
983 |
|
997 | |||
984 | self.saveFigure(figpath, figfile) |
|
998 | self.saveFigure(figpath, figfile) | |
985 |
|
999 | |||
986 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1000 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
987 | self.__isConfig = False |
|
1001 | self.__isConfig = False | |
988 | del self.xdata |
|
1002 | del self.xdata | |
989 | del self.ydata |
|
1003 | del self.ydata | |
990 | No newline at end of file |
|
1004 |
General Comments 0
You need to be logged in to leave comments.
Login now