@@ -1136,7 +1136,7 class Correlation(JROData): | |||||
1136 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1136 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
1137 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") |
|
1137 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") | |
1138 |
|
1138 | |||
1139 |
class Parameters( |
|
1139 | class Parameters(Spectra): | |
1140 |
|
1140 | |||
1141 | experimentInfo = None #Information about the experiment |
|
1141 | experimentInfo = None #Information about the experiment | |
1142 |
|
1142 | |||
@@ -1146,7 +1146,7 class Parameters(JROData): | |||||
1146 |
|
1146 | |||
1147 | operation = None #Type of operation to parametrize |
|
1147 | operation = None #Type of operation to parametrize | |
1148 |
|
1148 | |||
1149 | normFactor = None #Normalization Factor |
|
1149 | #normFactor = None #Normalization Factor | |
1150 |
|
1150 | |||
1151 | groupList = None #List of Pairs, Groups, etc |
|
1151 | groupList = None #List of Pairs, Groups, etc | |
1152 |
|
1152 | |||
@@ -1162,7 +1162,7 class Parameters(JROData): | |||||
1162 |
|
1162 | |||
1163 | abscissaList = None #Abscissa, can be velocities, lags or time |
|
1163 | abscissaList = None #Abscissa, can be velocities, lags or time | |
1164 |
|
1164 | |||
1165 | noise = None #Noise Potency |
|
1165 | #noise = None #Noise Potency | |
1166 |
|
1166 | |||
1167 | utctimeInit = None #Initial UTC time |
|
1167 | utctimeInit = None #Initial UTC time | |
1168 |
|
1168 | |||
@@ -1186,6 +1186,8 class Parameters(JROData): | |||||
1186 |
|
1186 | |||
1187 | nAvg = None |
|
1187 | nAvg = None | |
1188 |
|
1188 | |||
|
1189 | noise_estimation = None | |||
|
1190 | ||||
1189 |
|
1191 | |||
1190 | def __init__(self): |
|
1192 | def __init__(self): | |
1191 | ''' |
|
1193 | ''' | |
@@ -1213,4 +1215,4 class Parameters(JROData): | |||||
1213 |
|
1215 | |||
1214 | datatime = numpy.array(datatime) |
|
1216 | datatime = numpy.array(datatime) | |
1215 |
|
1217 | |||
1216 |
return datatime |
|
1218 | return datatime |
@@ -14,14 +14,14 from schainpy.model.proc.jroproc_base import Operation | |||||
14 |
|
14 | |||
15 | #plt.ion() |
|
15 | #plt.ion() | |
16 |
|
16 | |||
17 |
func = lambda x, pos: ('%s') %(datetime.datetime. |
|
17 | func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) | |
18 |
|
18 | |||
19 | d1970 = datetime.datetime(1970,1,1) |
|
19 | d1970 = datetime.datetime(1970,1,1) | |
20 |
|
20 | |||
21 | class PlotData(Operation, Process): |
|
21 | class PlotData(Operation, Process): | |
22 |
|
22 | |||
23 | CODE = 'Figure' |
|
23 | CODE = 'Figure' | |
24 |
colormap = 'j |
|
24 | colormap = 'jro' | |
25 | CONFLATE = True |
|
25 | CONFLATE = True | |
26 | __MAXNUMX = 80 |
|
26 | __MAXNUMX = 80 | |
27 | __MAXNUMY = 80 |
|
27 | __MAXNUMY = 80 | |
@@ -41,9 +41,11 class PlotData(Operation, Process): | |||||
41 | self.show = kwargs.get('show', True) |
|
41 | self.show = kwargs.get('show', True) | |
42 | self.save = kwargs.get('save', False) |
|
42 | self.save = kwargs.get('save', False) | |
43 | self.colormap = kwargs.get('colormap', self.colormap) |
|
43 | self.colormap = kwargs.get('colormap', self.colormap) | |
|
44 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') | |||
|
45 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') | |||
44 | self.showprofile = kwargs.get('showprofile', True) |
|
46 | self.showprofile = kwargs.get('showprofile', True) | |
45 | self.title = kwargs.get('wintitle', '') |
|
47 | self.title = kwargs.get('wintitle', '') | |
46 |
self.xaxis = kwargs.get('xaxis', ' |
|
48 | self.xaxis = kwargs.get('xaxis', 'frequency') | |
47 | self.zmin = kwargs.get('zmin', None) |
|
49 | self.zmin = kwargs.get('zmin', None) | |
48 | self.zmax = kwargs.get('zmax', None) |
|
50 | self.zmax = kwargs.get('zmax', None) | |
49 | self.xmin = kwargs.get('xmin', None) |
|
51 | self.xmin = kwargs.get('xmin', None) | |
@@ -52,6 +54,7 class PlotData(Operation, Process): | |||||
52 | self.ymin = kwargs.get('ymin', None) |
|
54 | self.ymin = kwargs.get('ymin', None) | |
53 | self.ymax = kwargs.get('ymax', None) |
|
55 | self.ymax = kwargs.get('ymax', None) | |
54 | self.throttle_value = 5 |
|
56 | self.throttle_value = 5 | |
|
57 | ||||
55 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
58 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): | |
56 |
|
59 | |||
57 | if x_buffer.shape[0] < 2: |
|
60 | if x_buffer.shape[0] < 2: | |
@@ -90,12 +93,13 class PlotData(Operation, Process): | |||||
90 | self.figure.show() |
|
93 | self.figure.show() | |
91 |
|
94 | |||
92 | self.plot() |
|
95 | self.plot() | |
93 | self.figure.suptitle('{} {} - Date:{}'.format(self.title, self.CODE.upper(), |
|
96 | plt.tight_layout() | |
94 | datetime.datetime.utcfromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) |
|
97 | self.figure.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(), | |
|
98 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) | |||
95 |
|
99 | |||
96 | if self.save: |
|
100 | if self.save: | |
97 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, |
|
101 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
98 |
datetime.datetime. |
|
102 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
99 | print 'Saving figure: {}'.format(figname) |
|
103 | print 'Saving figure: {}'.format(figname) | |
100 | self.figure.savefig(figname) |
|
104 | self.figure.savefig(figname) | |
101 |
|
105 | |||
@@ -117,7 +121,6 class PlotData(Operation, Process): | |||||
117 |
|
121 | |||
118 | while True: |
|
122 | while True: | |
119 | try: |
|
123 | try: | |
120 | #if True: |
|
|||
121 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK) |
|
124 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK) | |
122 | self.dataOut = self.data['dataOut'] |
|
125 | self.dataOut = self.data['dataOut'] | |
123 | self.times = self.data['times'] |
|
126 | self.times = self.data['times'] | |
@@ -132,17 +135,15 class PlotData(Operation, Process): | |||||
132 | self.__plot() |
|
135 | self.__plot() | |
133 |
|
136 | |||
134 | if self.data['ENDED'] is True: |
|
137 | if self.data['ENDED'] is True: | |
135 | # self.__plot() |
|
|||
136 | self.isConfig = False |
|
138 | self.isConfig = False | |
137 |
|
139 | |||
138 | except zmq.Again as e: |
|
140 | except zmq.Again as e: | |
139 | print 'Waiting for data...' |
|
141 | print 'Waiting for data...' | |
140 | plt.pause(self.throttle_value) |
|
142 | plt.pause(self.throttle_value) | |
141 | # time.sleep(3) |
|
|||
142 |
|
143 | |||
143 | def close(self): |
|
144 | def close(self): | |
144 | if self.dataOut: |
|
145 | if self.dataOut: | |
145 | self._plot() |
|
146 | self.__plot() | |
146 |
|
147 | |||
147 |
|
148 | |||
148 | class PlotSpectraData(PlotData): |
|
149 | class PlotSpectraData(PlotData): | |
@@ -150,6 +151,7 class PlotSpectraData(PlotData): | |||||
150 | CODE = 'spc' |
|
151 | CODE = 'spc' | |
151 | colormap = 'jro' |
|
152 | colormap = 'jro' | |
152 | CONFLATE = False |
|
153 | CONFLATE = False | |
|
154 | ||||
153 | def setup(self): |
|
155 | def setup(self): | |
154 |
|
156 | |||
155 | ncolspan = 1 |
|
157 | ncolspan = 1 | |
@@ -186,8 +188,6 class PlotSpectraData(PlotData): | |||||
186 | self.axes.append(ax) |
|
188 | self.axes.append(ax) | |
187 | n += 1 |
|
189 | n += 1 | |
188 |
|
190 | |||
189 | self.figure.subplots_adjust(left=0.1, right=0.95, bottom=0.15, top=0.85, wspace=0.9, hspace=0.5) |
|
|||
190 |
|
||||
191 | def plot(self): |
|
191 | def plot(self): | |
192 |
|
192 | |||
193 | if self.xaxis == "frequency": |
|
193 | if self.xaxis == "frequency": | |
@@ -225,9 +225,6 class PlotSpectraData(PlotData): | |||||
225 | ax.set_xlim(self.xmin, self.xmax) |
|
225 | ax.set_xlim(self.xmin, self.xmax) | |
226 | ax.set_ylim(self.ymin, self.ymax) |
|
226 | ax.set_ylim(self.ymin, self.ymax) | |
227 |
|
227 | |||
228 | ax.xaxis.set_major_locator(LinearLocator(5)) |
|
|||
229 | #ax.yaxis.set_major_locator(LinearLocator(4)) |
|
|||
230 |
|
||||
231 | ax.set_ylabel(self.ylabel) |
|
228 | ax.set_ylabel(self.ylabel) | |
232 | ax.set_xlabel(xlabel) |
|
229 | ax.set_xlabel(xlabel) | |
233 |
|
230 | |||
@@ -250,6 +247,185 class PlotSpectraData(PlotData): | |||||
250 |
|
247 | |||
251 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), |
|
248 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), | |
252 | size=8) |
|
249 | size=8) | |
|
250 | self.saveTime = self.max_time | |||
|
251 | ||||
|
252 | ||||
|
253 | class PlotCrossSpectraData(PlotData): | |||
|
254 | ||||
|
255 | CODE = 'cspc' | |||
|
256 | zmin_coh = None | |||
|
257 | zmax_coh = None | |||
|
258 | zmin_phase = None | |||
|
259 | zmax_phase = None | |||
|
260 | CONFLATE = False | |||
|
261 | ||||
|
262 | def setup(self): | |||
|
263 | ||||
|
264 | ncolspan = 1 | |||
|
265 | colspan = 1 | |||
|
266 | self.ncols = 2 | |||
|
267 | self.nrows = self.dataOut.nPairs | |||
|
268 | self.width = 3.6*self.ncols | |||
|
269 | self.height = 3.2*self.nrows | |||
|
270 | ||||
|
271 | self.ylabel = 'Range [Km]' | |||
|
272 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] | |||
|
273 | ||||
|
274 | if self.figure is None: | |||
|
275 | self.figure = plt.figure(figsize=(self.width, self.height), | |||
|
276 | edgecolor='k', | |||
|
277 | facecolor='w') | |||
|
278 | else: | |||
|
279 | self.figure.clf() | |||
|
280 | ||||
|
281 | for y in range(self.nrows): | |||
|
282 | for x in range(self.ncols): | |||
|
283 | ax = plt.subplot2grid((self.nrows, self.ncols), (y, x), 1, 1) | |||
|
284 | ax.firsttime = True | |||
|
285 | self.axes.append(ax) | |||
|
286 | ||||
|
287 | def plot(self): | |||
|
288 | ||||
|
289 | if self.xaxis == "frequency": | |||
|
290 | x = self.dataOut.getFreqRange(1)/1000. | |||
|
291 | xlabel = "Frequency (kHz)" | |||
|
292 | elif self.xaxis == "time": | |||
|
293 | x = self.dataOut.getAcfRange(1) | |||
|
294 | xlabel = "Time (ms)" | |||
|
295 | else: | |||
|
296 | x = self.dataOut.getVelRange(1) | |||
|
297 | xlabel = "Velocity (m/s)" | |||
|
298 | ||||
|
299 | y = self.dataOut.getHeiRange() | |||
|
300 | z_coh = self.data['cspc_coh'] | |||
|
301 | z_phase = self.data['cspc_phase'] | |||
|
302 | ||||
|
303 | for n in range(self.nrows): | |||
|
304 | ax = self.axes[2*n] | |||
|
305 | ax1 = self.axes[2*n+1] | |||
|
306 | if ax.firsttime: | |||
|
307 | self.xmax = self.xmax if self.xmax else np.nanmax(x) | |||
|
308 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
309 | self.ymin = self.ymin if self.ymin else np.nanmin(y) | |||
|
310 | self.ymax = self.ymax if self.ymax else np.nanmax(y) | |||
|
311 | self.zmin_coh = self.zmin_coh if self.zmin_coh else 0.0 | |||
|
312 | self.zmax_coh = self.zmax_coh if self.zmax_coh else 1.0 | |||
|
313 | self.zmin_phase = self.zmin_phase if self.zmin_phase else -180 | |||
|
314 | self.zmax_phase = self.zmax_phase if self.zmax_phase else 180 | |||
|
315 | ||||
|
316 | ax.plot = ax.pcolormesh(x, y, z_coh[n].T, | |||
|
317 | vmin=self.zmin_coh, | |||
|
318 | vmax=self.zmax_coh, | |||
|
319 | cmap=plt.get_cmap(self.colormap_coh) | |||
|
320 | ) | |||
|
321 | divider = make_axes_locatable(ax) | |||
|
322 | cax = divider.new_horizontal(size='3%', pad=0.05) | |||
|
323 | self.figure.add_axes(cax) | |||
|
324 | plt.colorbar(ax.plot, cax) | |||
|
325 | ||||
|
326 | ax.set_xlim(self.xmin, self.xmax) | |||
|
327 | ax.set_ylim(self.ymin, self.ymax) | |||
|
328 | ||||
|
329 | ax.set_ylabel(self.ylabel) | |||
|
330 | ax.set_xlabel(xlabel) | |||
|
331 | ax.firsttime = False | |||
|
332 | ||||
|
333 | ax1.plot = ax1.pcolormesh(x, y, z_phase[n].T, | |||
|
334 | vmin=self.zmin_phase, | |||
|
335 | vmax=self.zmax_phase, | |||
|
336 | cmap=plt.get_cmap(self.colormap_phase) | |||
|
337 | ) | |||
|
338 | divider = make_axes_locatable(ax1) | |||
|
339 | cax = divider.new_horizontal(size='3%', pad=0.05) | |||
|
340 | self.figure.add_axes(cax) | |||
|
341 | plt.colorbar(ax1.plot, cax) | |||
|
342 | ||||
|
343 | ax1.set_xlim(self.xmin, self.xmax) | |||
|
344 | ax1.set_ylim(self.ymin, self.ymax) | |||
|
345 | ||||
|
346 | ax1.set_ylabel(self.ylabel) | |||
|
347 | ax1.set_xlabel(xlabel) | |||
|
348 | ax1.firsttime = False | |||
|
349 | else: | |||
|
350 | ax.plot.set_array(z_coh[n].T.ravel()) | |||
|
351 | ax1.plot.set_array(z_phase[n].T.ravel()) | |||
|
352 | ||||
|
353 | ax.set_title('Coherence Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8) | |||
|
354 | ax1.set_title('Phase Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8) | |||
|
355 | self.saveTime = self.max_time | |||
|
356 | ||||
|
357 | ||||
|
358 | class PlotSpectraMeanData(PlotSpectraData): | |||
|
359 | ||||
|
360 | CODE = 'spc_mean' | |||
|
361 | colormap = 'jet' | |||
|
362 | ||||
|
363 | def plot(self): | |||
|
364 | ||||
|
365 | if self.xaxis == "frequency": | |||
|
366 | x = self.dataOut.getFreqRange(1)/1000. | |||
|
367 | xlabel = "Frequency (kHz)" | |||
|
368 | elif self.xaxis == "time": | |||
|
369 | x = self.dataOut.getAcfRange(1) | |||
|
370 | xlabel = "Time (ms)" | |||
|
371 | else: | |||
|
372 | x = self.dataOut.getVelRange(1) | |||
|
373 | xlabel = "Velocity (m/s)" | |||
|
374 | ||||
|
375 | y = self.dataOut.getHeiRange() | |||
|
376 | z = self.data['spc'] | |||
|
377 | mean = self.data['mean'][self.max_time] | |||
|
378 | ||||
|
379 | for n, ax in enumerate(self.axes): | |||
|
380 | ||||
|
381 | if ax.firsttime: | |||
|
382 | self.xmax = self.xmax if self.xmax else np.nanmax(x) | |||
|
383 | self.xmin = self.xmin if self.xmin else -self.xmax | |||
|
384 | self.ymin = self.ymin if self.ymin else np.nanmin(y) | |||
|
385 | self.ymax = self.ymax if self.ymax else np.nanmax(y) | |||
|
386 | self.zmin = self.zmin if self.zmin else np.nanmin(z) | |||
|
387 | self.zmax = self.zmax if self.zmax else np.nanmax(z) | |||
|
388 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |||
|
389 | vmin=self.zmin, | |||
|
390 | vmax=self.zmax, | |||
|
391 | cmap=plt.get_cmap(self.colormap) | |||
|
392 | ) | |||
|
393 | ax.plt_dop = ax.plot(mean[n], y, | |||
|
394 | color='k')[0] | |||
|
395 | ||||
|
396 | divider = make_axes_locatable(ax) | |||
|
397 | cax = divider.new_horizontal(size='3%', pad=0.05) | |||
|
398 | self.figure.add_axes(cax) | |||
|
399 | plt.colorbar(ax.plt, cax) | |||
|
400 | ||||
|
401 | ax.set_xlim(self.xmin, self.xmax) | |||
|
402 | ax.set_ylim(self.ymin, self.ymax) | |||
|
403 | ||||
|
404 | ax.set_ylabel(self.ylabel) | |||
|
405 | ax.set_xlabel(xlabel) | |||
|
406 | ||||
|
407 | ax.firsttime = False | |||
|
408 | ||||
|
409 | if self.showprofile: | |||
|
410 | ax.plt_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0] | |||
|
411 | ax.ax_profile.set_xlim(self.zmin, self.zmax) | |||
|
412 | ax.ax_profile.set_ylim(self.ymin, self.ymax) | |||
|
413 | ax.ax_profile.set_xlabel('dB') | |||
|
414 | ax.ax_profile.grid(b=True, axis='x') | |||
|
415 | ax.plt_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y, | |||
|
416 | color="k", linestyle="dashed", lw=2)[0] | |||
|
417 | [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()] | |||
|
418 | else: | |||
|
419 | ax.plt.set_array(z[n].T.ravel()) | |||
|
420 | ax.plt_dop.set_data(mean[n], y) | |||
|
421 | if self.showprofile: | |||
|
422 | ax.plt_profile.set_data(self.data['rti'][self.max_time][n], y) | |||
|
423 | ax.plt_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y) | |||
|
424 | ||||
|
425 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), | |||
|
426 | size=8) | |||
|
427 | self.saveTime = self.max_time | |||
|
428 | ||||
253 |
|
429 | |||
254 | class PlotRTIData(PlotData): |
|
430 | class PlotRTIData(PlotData): | |
255 |
|
431 | |||
@@ -260,7 +436,7 class PlotRTIData(PlotData): | |||||
260 | self.ncols = 1 |
|
436 | self.ncols = 1 | |
261 | self.nrows = self.dataOut.nChannels |
|
437 | self.nrows = self.dataOut.nChannels | |
262 | self.width = 10 |
|
438 | self.width = 10 | |
263 | self.height = 2.2*self.nrows |
|
439 | self.height = 2.2*self.nrows if self.nrows<6 else 12 | |
264 | if self.nrows==1: |
|
440 | if self.nrows==1: | |
265 | self.height += 1 |
|
441 | self.height += 1 | |
266 | self.ylabel = 'Range [Km]' |
|
442 | self.ylabel = 'Range [Km]' | |
@@ -278,7 +454,6 class PlotRTIData(PlotData): | |||||
278 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) |
|
454 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
279 | ax.firsttime = True |
|
455 | ax.firsttime = True | |
280 | self.axes.append(ax) |
|
456 | self.axes.append(ax) | |
281 | self.figure.subplots_adjust(hspace=0.5) |
|
|||
282 |
|
457 | |||
283 | def plot(self): |
|
458 | def plot(self): | |
284 |
|
459 | |||
@@ -310,11 +485,9 class PlotRTIData(PlotData): | |||||
310 | self.figure.add_axes(cax) |
|
485 | self.figure.add_axes(cax) | |
311 | plt.colorbar(plot, cax) |
|
486 | plt.colorbar(plot, cax) | |
312 | ax.set_ylim(self.ymin, self.ymax) |
|
487 | ax.set_ylim(self.ymin, self.ymax) | |
313 | if self.xaxis == 'time': |
|
|||
314 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
|||
315 | ax.xaxis.set_major_locator(LinearLocator(6)) |
|
|||
316 |
|
488 | |||
317 |
|
|
489 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
|
490 | ax.xaxis.set_major_locator(LinearLocator(6)) | |||
318 |
|
491 | |||
319 | ax.set_ylabel(self.ylabel) |
|
492 | ax.set_ylabel(self.ylabel) | |
320 |
|
493 | |||
@@ -334,9 +507,11 class PlotRTIData(PlotData): | |||||
334 | vmax=self.zmax, |
|
507 | vmax=self.zmax, | |
335 | cmap=plt.get_cmap(self.colormap) |
|
508 | cmap=plt.get_cmap(self.colormap) | |
336 | ) |
|
509 | ) | |
337 |
|
|
510 | ax.set_title('{} {}'.format(self.titles[n], | |
338 |
|
|
511 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
339 |
|
|
512 | size=8) | |
|
513 | ||||
|
514 | self.saveTime = self.min_time | |||
340 |
|
515 | |||
341 |
|
516 | |||
342 | class PlotCOHData(PlotRTIData): |
|
517 | class PlotCOHData(PlotRTIData): | |
@@ -348,11 +523,11 class PlotCOHData(PlotRTIData): | |||||
348 | self.ncols = 1 |
|
523 | self.ncols = 1 | |
349 | self.nrows = self.dataOut.nPairs |
|
524 | self.nrows = self.dataOut.nPairs | |
350 | self.width = 10 |
|
525 | self.width = 10 | |
351 | self.height = 2.2*self.nrows |
|
526 | self.height = 2.2*self.nrows if self.nrows<6 else 12 | |
352 | if self.nrows==1: |
|
527 | if self.nrows==1: | |
353 | self.height += 1 |
|
528 | self.height += 1 | |
354 | self.ylabel = 'Range [Km]' |
|
529 | self.ylabel = 'Range [Km]' | |
355 |
self.titles = [' |
|
530 | self.titles = ['{} Ch{} * Ch{}'.format(self.CODE.upper(), x[0], x[1]) for x in self.dataOut.pairsList] | |
356 |
|
531 | |||
357 | if self.figure is None: |
|
532 | if self.figure is None: | |
358 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
533 | self.figure = plt.figure(figsize=(self.width, self.height), | |
@@ -367,7 +542,6 class PlotCOHData(PlotRTIData): | |||||
367 | ax.firsttime = True |
|
542 | ax.firsttime = True | |
368 | self.axes.append(ax) |
|
543 | self.axes.append(ax) | |
369 |
|
544 | |||
370 | self.figure.subplots_adjust(hspace=0.5) |
|
|||
371 |
|
545 | |||
372 | class PlotNoiseData(PlotData): |
|
546 | class PlotNoiseData(PlotData): | |
373 | CODE = 'noise' |
|
547 | CODE = 'noise' | |
@@ -413,14 +587,18 class PlotNoiseData(PlotData): | |||||
413 |
|
587 | |||
414 | self.ax.set_xlim(xmin, xmax) |
|
588 | self.ax.set_xlim(xmin, xmax) | |
415 | self.ax.set_ylim(min(y)-5, max(y)+5) |
|
589 | self.ax.set_ylim(min(y)-5, max(y)+5) | |
|
590 | self.saveTime = self.min_time | |||
|
591 | ||||
416 |
|
592 | |||
417 | class PlotSNRData(PlotRTIData): |
|
593 | class PlotSNRData(PlotRTIData): | |
418 | CODE = 'snr' |
|
594 | CODE = 'snr' | |
|
595 | colormap = 'jet' | |||
419 |
|
596 | |||
420 | class PlotDOPData(PlotRTIData): |
|
597 | class PlotDOPData(PlotRTIData): | |
421 | CODE = 'dop' |
|
598 | CODE = 'dop' | |
422 | colormap = 'jet' |
|
599 | colormap = 'jet' | |
423 |
|
600 | |||
|
601 | ||||
424 | class PlotPHASEData(PlotCOHData): |
|
602 | class PlotPHASEData(PlotCOHData): | |
425 | CODE = 'phase' |
|
603 | CODE = 'phase' | |
426 | colormap = 'seismic' |
|
604 | colormap = 'seismic' |
@@ -54,10 +54,10 class ParametersProc(ProcessingUnit): | |||||
54 | # self.dataOut.nIncohInt = 1 |
|
54 | # self.dataOut.nIncohInt = 1 | |
55 | self.dataOut.ippSeconds = self.dataIn.ippSeconds |
|
55 | self.dataOut.ippSeconds = self.dataIn.ippSeconds | |
56 | # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter |
|
56 | # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter | |
57 | self.dataOut.timeInterval = self.dataIn.timeInterval |
|
57 | # self.dataOut.timeInterval = self.dataIn.timeInterval | |
58 | self.dataOut.heightList = self.dataIn.getHeiRange() |
|
58 | self.dataOut.heightList = self.dataIn.getHeiRange() | |
59 | self.dataOut.frequency = self.dataIn.frequency |
|
59 | self.dataOut.frequency = self.dataIn.frequency | |
60 | self.dataOut.noise = self.dataIn.noise |
|
60 | #self.dataOut.noise = self.dataIn.noise | |
61 |
|
61 | |||
62 | def run(self): |
|
62 | def run(self): | |
63 |
|
63 | |||
@@ -76,11 +76,17 class ParametersProc(ProcessingUnit): | |||||
76 |
|
76 | |||
77 | if self.dataIn.type == "Spectra": |
|
77 | if self.dataIn.type == "Spectra": | |
78 |
|
78 | |||
79 | self.dataOut.data_pre = (self.dataIn.data_spc,self.dataIn.data_cspc) |
|
79 | self.dataOut.data_pre = (self.dataIn.data_spc, self.dataIn.data_cspc) | |
80 |
self.dataOut. |
|
80 | self.dataOut.data_spc = self.dataIn.data_spc | |
81 |
|
|
81 | self.dataOut.data_cspc = self.dataIn.data_cspc | |
82 |
self.dataOut.n |
|
82 | self.dataOut.nProfiles = self.dataIn.nProfiles | |
|
83 | self.dataOut.nIncohInt = self.dataIn.nIncohInt | |||
|
84 | self.dataOut.nFFTPoints = self.dataIn.nFFTPoints | |||
|
85 | self.dataOut.ippFactor = self.dataIn.ippFactor | |||
|
86 | #self.dataOut.normFactor = self.dataIn.getNormFactor() | |||
|
87 | self.dataOut.pairsList = self.dataIn.pairsList | |||
83 | self.dataOut.groupList = self.dataIn.pairsList |
|
88 | self.dataOut.groupList = self.dataIn.pairsList | |
|
89 | self.dataOut.abscissaList = self.dataIn.getVelRange(1) | |||
84 | self.dataOut.flagNoData = False |
|
90 | self.dataOut.flagNoData = False | |
85 |
|
91 | |||
86 | #---------------------- Correlation Data --------------------------- |
|
92 | #---------------------- Correlation Data --------------------------- | |
@@ -144,8 +150,8 class SpectralMoments(Operation): | |||||
144 |
|
150 | |||
145 | def run(self, dataOut): |
|
151 | def run(self, dataOut): | |
146 |
|
152 | |||
147 | dataOut.data_pre = dataOut.data_pre[0] |
|
153 | #dataOut.data_pre = dataOut.data_pre[0] | |
148 | data = dataOut.data_pre |
|
154 | data = dataOut.data_pre[0] | |
149 | absc = dataOut.abscissaList[:-1] |
|
155 | absc = dataOut.abscissaList[:-1] | |
150 | noise = dataOut.noise |
|
156 | noise = dataOut.noise | |
151 | nChannel = data.shape[0] |
|
157 | nChannel = data.shape[0] | |
@@ -157,6 +163,8 class SpectralMoments(Operation): | |||||
157 | dataOut.data_param = data_param[:,1:,:] |
|
163 | dataOut.data_param = data_param[:,1:,:] | |
158 | dataOut.data_SNR = data_param[:,0] |
|
164 | dataOut.data_SNR = data_param[:,0] | |
159 | dataOut.data_DOP = data_param[:,1] |
|
165 | dataOut.data_DOP = data_param[:,1] | |
|
166 | dataOut.data_MEAN = data_param[:,2] | |||
|
167 | dataOut.data_STD = data_param[:,3] | |||
160 | return |
|
168 | return | |
161 |
|
169 | |||
162 | def __calculateMoments(self, oldspec, oldfreq, n0, nicoh = None, graph = None, smooth = None, type1 = None, fwindow = None, snrth = None, dc = None, aliasing = None, oldfd = None, wwauto = None): |
|
170 | def __calculateMoments(self, oldspec, oldfreq, n0, nicoh = None, graph = None, smooth = None, type1 = None, fwindow = None, snrth = None, dc = None, aliasing = None, oldfd = None, wwauto = None): | |
@@ -239,8 +247,8 class SpectralMoments(Operation): | |||||
239 | num_pairs = len(pairslist) |
|
247 | num_pairs = len(pairslist) | |
240 |
|
248 | |||
241 | vel = self.dataOut.abscissaList |
|
249 | vel = self.dataOut.abscissaList | |
242 | spectra = self.dataOut.data_pre |
|
250 | spectra = self.dataOut.data_pre[0] | |
243 |
cspectra = self.data |
|
251 | cspectra = self.dataOut.data_pre[1] | |
244 | delta_v = vel[1] - vel[0] |
|
252 | delta_v = vel[1] - vel[0] | |
245 |
|
253 | |||
246 | #Calculating the power spectrum |
|
254 | #Calculating the power spectrum |
@@ -281,7 +281,7 class ReceiverData(ProcessingUnit, Process): | |||||
281 | self.plot_address = plot_address |
|
281 | self.plot_address = plot_address | |
282 | self.plottypes = [s.strip() for s in kwargs.get('plottypes', 'rti').split(',')] |
|
282 | self.plottypes = [s.strip() for s in kwargs.get('plottypes', 'rti').split(',')] | |
283 | self.realtime = kwargs.get('realtime', False) |
|
283 | self.realtime = kwargs.get('realtime', False) | |
284 |
self.throttle_value = kwargs.get('throttle', |
|
284 | self.throttle_value = kwargs.get('throttle', 5) | |
285 | self.sendData = self.initThrottle(self.throttle_value) |
|
285 | self.sendData = self.initThrottle(self.throttle_value) | |
286 | self.setup() |
|
286 | self.setup() | |
287 |
|
287 | |||
@@ -343,21 +343,33 class ReceiverData(ProcessingUnit, Process): | |||||
343 | z = self.dataOut.data_spc/self.dataOut.normFactor |
|
343 | z = self.dataOut.data_spc/self.dataOut.normFactor | |
344 | self.data[plottype] = 10*numpy.log10(z) |
|
344 | self.data[plottype] = 10*numpy.log10(z) | |
345 | self.data['noise'][t] = 10*numpy.log10(self.dataOut.getNoise()/self.dataOut.normFactor) |
|
345 | self.data['noise'][t] = 10*numpy.log10(self.dataOut.getNoise()/self.dataOut.normFactor) | |
|
346 | if plottype == 'cspc': | |||
|
347 | jcoherence = self.dataOut.data_cspc/numpy.sqrt(self.dataOut.data_spc*self.dataOut.data_spc) | |||
|
348 | self.data['cspc_coh'] = numpy.abs(jcoherence) | |||
|
349 | self.data['cspc_phase'] = numpy.arctan2(jcoherence.imag, jcoherence.real)*180/numpy.pi | |||
346 | if plottype == 'rti': |
|
350 | if plottype == 'rti': | |
347 | self.data[plottype][t] = self.dataOut.getPower() |
|
351 | self.data[plottype][t] = self.dataOut.getPower() | |
348 | if plottype == 'snr': |
|
352 | if plottype == 'snr': | |
349 | self.data[plottype][t] = 10*numpy.log10(self.dataOut.data_SNR) |
|
353 | self.data[plottype][t] = 10*numpy.log10(self.dataOut.data_SNR) | |
350 | if plottype == 'dop': |
|
354 | if plottype == 'dop': | |
351 | self.data[plottype][t] = 10*numpy.log10(self.dataOut.data_DOP) |
|
355 | self.data[plottype][t] = 10*numpy.log10(self.dataOut.data_DOP) | |
|
356 | if plottype == 'mean': | |||
|
357 | self.data[plottype][t] = self.dataOut.data_MEAN | |||
|
358 | if plottype == 'std': | |||
|
359 | self.data[plottype][t] = self.dataOut.data_STD | |||
352 | if plottype == 'coh': |
|
360 | if plottype == 'coh': | |
353 | self.data[plottype][t] = self.dataOut.getCoherence() |
|
361 | self.data[plottype][t] = self.dataOut.getCoherence() | |
354 | if plottype == 'phase': |
|
362 | if plottype == 'phase': | |
355 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) |
|
363 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) | |
356 | if self.realtime: |
|
364 | if self.realtime: | |
357 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype][t]).tolist()) |
|
365 | self.data_web['timestamp'] = t | |
358 | self.data_web['timestamp'] = t |
|
|||
359 | if plottype == 'spc': |
|
366 | if plottype == 'spc': | |
360 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist()) |
|
367 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist()) | |
|
368 | elif plottype == 'cspc': | |||
|
369 | self.data_web['cspc_coh'] = roundFloats(decimate(self.data['cspc_coh']).tolist()) | |||
|
370 | self.data_web['cspc_phase'] = roundFloats(decimate(self.data['cspc_phase']).tolist()) | |||
|
371 | elif plottype == 'noise': | |||
|
372 | self.data_web['noise'] = roundFloats(self.data['noise'][t].tolist()) | |||
361 | else: |
|
373 | else: | |
362 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype][t]).tolist()) |
|
374 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype][t]).tolist()) | |
363 | self.data_web['interval'] = self.dataOut.getTimeInterval() |
|
375 | self.data_web['interval'] = self.dataOut.getTimeInterval() |
General Comments 0
You need to be logged in to leave comments.
Login now