##// END OF EJS Templates
kwargs restantes. Templates y changelog actualizado
José Chávez -
r1080:af3edc5dd0e9
parent child
Show More
@@ -43,12 +43,14 desc = "{desc}"
43 plotter = Project()
43 plotter = Project()
44 plotter.setup(id='100', name='receiver', description=desc)
44 plotter.setup(id='100', name='receiver', description=desc)
45
45
46 receiver_proc = plotter.addProcUnit(name='PlotterReceiver')
46 receiver_plot = plotter.addProcUnit(name='PlotterReceiver')
47 receiver_proc.addParameter(name='throttle', value=20, format='int')
47 receiver_plot.addParameter(name='throttle', value=20, format='int')
48 receiver_plot.addParameter(name='plottypes', value='rti', format='str')
48
49
49 rti = receiver_proc.addOperation(name='PlotRTIData', optype='other')
50 rti = receiver_plot.addOperation(name='PlotRTIData', optype='other')
50 rti.addParameter(name='zmin', value='-40.0', format='float')
51 rti.addParameter(name='zmin', value='-40.0', format='float')
51 rti.addParameter(name='zmax', value='100.0', format='float')
52 rti.addParameter(name='zmax', value='100.0', format='float')
53 rti.addParameter(name='decimation', value='200', format='int')
52 rti.addParameter(name='xmin', value='0.0', format='int')
54 rti.addParameter(name='xmin', value='0.0', format='int')
53 rti.addParameter(name='colormap', value='jet', format='str')
55 rti.addParameter(name='colormap', value='jet', format='str')
54
56
@@ -1,7 +1,7
1 ## CHANGELOG:
1 ## CHANGELOG:
2
2
3 ### 2.3
3 ### 2.3
4 * Added high order function `multiSchain` for multiprocessing scripts.
4 * Added high order function `MPProject` for multiprocessing scripts.
5 * Added two new Processing Units `PublishData` and `ReceiverData` for receiving and sending dataOut through multiple ways (tcp, ipc, inproc).
5 * Added two new Processing Units `PublishData` and `ReceiverData` for receiving and sending dataOut through multiple ways (tcp, ipc, inproc).
6 * Added a new graphics Processing Unit `PlotterReceiver`. It is decoupled from normal processing sequence with support for data generated by multiprocessing scripts.
6 * Added a new graphics Processing Unit `PlotterReceiver`. It is decoupled from normal processing sequence with support for data generated by multiprocessing scripts.
7 * Added support for sending realtime graphic to web server.
7 * Added support for sending realtime graphic to web server.
@@ -16,16 +16,23 from schainpy.model.proc.jroproc_base import Operation
16 from schainpy.utils import log
16 from schainpy.utils import log
17
17
18 jet_values = matplotlib.pyplot.get_cmap("jet", 100)(numpy.arange(100))[10:90]
18 jet_values = matplotlib.pyplot.get_cmap("jet", 100)(numpy.arange(100))[10:90]
19 blu_values = matplotlib.pyplot.get_cmap("seismic_r", 20)(numpy.arange(20))[10:15]
19 blu_values = matplotlib.pyplot.get_cmap(
20 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list("jro", numpy.vstack((blu_values, jet_values)))
20 "seismic_r", 20)(numpy.arange(20))[10:15]
21 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
22 "jro", numpy.vstack((blu_values, jet_values)))
21 matplotlib.pyplot.register_cmap(cmap=ncmap)
23 matplotlib.pyplot.register_cmap(cmap=ncmap)
22
24
23 func = lambda x, pos: '{}'.format(datetime.datetime.fromtimestamp(x).strftime('%H:%M'))
24
25
25 UT1970 = datetime.datetime(1970, 1, 1) - datetime.timedelta(seconds=time.timezone)
26 def func(x, pos): return '{}'.format(
27 datetime.datetime.fromtimestamp(x).strftime('%H:%M'))
28
29
30 UT1970 = datetime.datetime(1970, 1, 1) - \
31 datetime.timedelta(seconds=time.timezone)
26
32
27 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')]
33 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')]
28
34
35
29 class PlotData(Operation, Process):
36 class PlotData(Operation, Process):
30 '''
37 '''
31 Base class for Schain plotting operations
38 Base class for Schain plotting operations
@@ -270,7 +277,8 class PlotData(Operation, Process):
270 self.pf_axes[n].set_xlim(self.zmin, self.zmax)
277 self.pf_axes[n].set_xlim(self.zmin, self.zmax)
271 self.pf_axes[n].set_xlabel('dB')
278 self.pf_axes[n].set_xlabel('dB')
272 self.pf_axes[n].grid(b=True, axis='x')
279 self.pf_axes[n].grid(b=True, axis='x')
273 [tick.set_visible(False) for tick in self.pf_axes[n].get_yticklabels()]
280 [tick.set_visible(False)
281 for tick in self.pf_axes[n].get_yticklabels()]
274 if self.colorbar:
282 if self.colorbar:
275 ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10)
283 ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10)
276 ax.cbar.ax.tick_params(labelsize=8)
284 ax.cbar.ax.tick_params(labelsize=8)
@@ -281,7 +289,8 class PlotData(Operation, Process):
281
289
282 ax.set_title('{} - {} {}'.format(
290 ax.set_title('{} - {} {}'.format(
283 self.titles[n],
291 self.titles[n],
284 datetime.datetime.fromtimestamp(self.max_time).strftime('%H:%M:%S'),
292 datetime.datetime.fromtimestamp(
293 self.max_time).strftime('%H:%M:%S'),
285 self.time_label),
294 self.time_label),
286 size=8)
295 size=8)
287 ax.set_xlim(xmin, xmax)
296 ax.set_xlim(xmin, xmax)
@@ -318,7 +327,8 class PlotData(Operation, Process):
318 '{}{}_{}.png'.format(
327 '{}{}_{}.png'.format(
319 self.CODE,
328 self.CODE,
320 label,
329 label,
321 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')
330 datetime.datetime.fromtimestamp(
331 self.saveTime).strftime('%y%m%d_%H%M%S')
322 )
332 )
323 )
333 )
324 print 'Saving figure: {}'.format(figname)
334 print 'Saving figure: {}'.format(figname)
@@ -339,7 +349,8 class PlotData(Operation, Process):
339 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
349 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
340
350
341 if 'server' in self.kwargs['parent']:
351 if 'server' in self.kwargs['parent']:
342 receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
352 receiver.connect(
353 'ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
343 else:
354 else:
344 receiver.connect("ipc:///tmp/zmq.plots")
355 receiver.connect("ipc:///tmp/zmq.plots")
345
356
@@ -372,6 +383,7 class PlotData(Operation, Process):
372 if self.data:
383 if self.data:
373 self.__plot()
384 self.__plot()
374
385
386
375 class PlotSpectraData(PlotData):
387 class PlotSpectraData(PlotData):
376 '''
388 '''
377 Plot for Spectra data
389 Plot for Spectra data
@@ -429,7 +441,8 class PlotSpectraData(PlotData):
429 )
441 )
430
442
431 if self.showprofile:
443 if self.showprofile:
432 ax.plt_profile= self.pf_axes[n].plot(self.data['rti'][n][-1], y)[0]
444 ax.plt_profile = self.pf_axes[n].plot(
445 self.data['rti'][n][-1], y)[0]
433 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
446 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
434 color="k", linestyle="dashed", lw=1)[0]
447 color="k", linestyle="dashed", lw=1)[0]
435 if self.CODE == 'spc_mean':
448 if self.CODE == 'spc_mean':
@@ -526,7 +539,8 class PlotCrossSpectraData(PlotData):
526 )
539 )
527 else:
540 else:
528 ax.plt.set_array(coh.T.ravel())
541 ax.plt.set_array(coh.T.ravel())
529 self.titles.append('Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
542 self.titles.append(
543 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
530
544
531 ax = self.axes[4*n+3]
545 ax = self.axes[4 * n + 3]
532 if ax.firsttime:
546 if ax.firsttime:
@@ -565,7 +579,8 class PlotRTIData(PlotData):
565 self.nplots = len(self.data.channels)
579 self.nplots = len(self.data.channels)
566 self.ylabel = 'Range [Km]'
580 self.ylabel = 'Range [Km]'
567 self.cb_label = 'dB'
581 self.cb_label = 'dB'
568 self.titles = ['{} Channel {}'.format(self.CODE.upper(), x) for x in range(self.nrows)]
582 self.titles = ['{} Channel {}'.format(
583 self.CODE.upper(), x) for x in range(self.nrows)]
569
584
570 def plot(self):
585 def plot(self):
571 self.x = self.times
586 self.x = self.times
@@ -584,7 +599,8 class PlotRTIData(PlotData):
584 cmap=plt.get_cmap(self.colormap)
599 cmap=plt.get_cmap(self.colormap)
585 )
600 )
586 if self.showprofile:
601 if self.showprofile:
587 ax.plot_profile= self.pf_axes[n].plot(self.data['rti'][n][-1], self.y)[0]
602 ax.plot_profile = self.pf_axes[n].plot(
603 self.data['rti'][n][-1], self.y)[0]
588 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y,
604 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y,
589 color="k", linestyle="dashed", lw=1)[0]
605 color="k", linestyle="dashed", lw=1)[0]
590 else:
606 else:
@@ -596,7 +612,8 class PlotRTIData(PlotData):
596 )
612 )
597 if self.showprofile:
613 if self.showprofile:
598 ax.plot_profile.set_data(self.data['rti'][n][-1], self.y)
614 ax.plot_profile.set_data(self.data['rti'][n][-1], self.y)
599 ax.plot_noise.set_data(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y)
615 ax.plot_noise.set_data(numpy.repeat(
616 self.data['noise'][n][-1], len(self.y)), self.y)
600
617
601 self.saveTime = self.min_time
618 self.saveTime = self.min_time
602
619
@@ -616,10 +633,12 class PlotCOHData(PlotRTIData):
616 self.ylabel = 'Range [Km]'
633 self.ylabel = 'Range [Km]'
617 if self.CODE == 'coh':
634 if self.CODE == 'coh':
618 self.cb_label = ''
635 self.cb_label = ''
619 self.titles = ['Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
636 self.titles = [
637 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
620 else:
638 else:
621 self.cb_label = 'Degrees'
639 self.cb_label = 'Degrees'
622 self.titles = ['Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
640 self.titles = [
641 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
623
642
624
643
625 class PlotPHASEData(PlotCOHData):
644 class PlotPHASEData(PlotCOHData):
@@ -711,13 +730,14 class PlotSkyMapData(PlotData):
711 else:
730 else:
712 self.figure.clf()
731 self.figure.clf()
713
732
714 self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
733 self.ax = plt.subplot2grid(
734 (self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
715 self.ax.firsttime = True
735 self.ax.firsttime = True
716
736
717
718 def plot(self):
737 def plot(self):
719
738
720 arrayParameters = numpy.concatenate([self.data['param'][t] for t in self.times])
739 arrayParameters = numpy.concatenate(
740 [self.data['param'][t] for t in self.times])
721 error = arrayParameters[:,-1]
741 error = arrayParameters[:, -1]
722 indValid = numpy.where(error == 0)[0]
742 indValid = numpy.where(error == 0)[0]
723 finalMeteor = arrayParameters[indValid,:]
743 finalMeteor = arrayParameters[indValid, :]
@@ -738,9 +758,10 class PlotSkyMapData(PlotData):
738 else:
758 else:
739 self.ax.plot.set_data(x, y)
759 self.ax.plot.set_data(x, y)
740
760
741
761 dt1 = datetime.datetime.fromtimestamp(
742 dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S')
762 self.min_time).strftime('%y/%m/%d %H:%M:%S')
743 dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')
763 dt2 = datetime.datetime.fromtimestamp(
764 self.max_time).strftime('%y/%m/%d %H:%M:%S')
744 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
765 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
745 dt2,
766 dt2,
746 len(x))
767 len(x))
@@ -748,6 +769,7 class PlotSkyMapData(PlotData):
748
769
749 self.saveTime = self.max_time
770 self.saveTime = self.max_time
750
771
772
751 class PlotParamData(PlotRTIData):
773 class PlotParamData(PlotRTIData):
752 '''
774 '''
753 Plot for data_param object
775 Plot for data_param object
@@ -791,7 +813,8 class PlotParamData(PlotRTIData):
791 if ax.firsttime:
813 if ax.firsttime:
792 if self.zlimits is not None:
814 if self.zlimits is not None:
793 self.zmin, self.zmax = self.zlimits[n]
815 self.zmin, self.zmax = self.zlimits[n]
794 self.zmax = self.zmax if self.zmax is not None else numpy.nanmax(abs(self.z[:-1, :]))
816 self.zmax = self.zmax if self.zmax is not None else numpy.nanmax(
817 abs(self.z[:-1, :]))
795 self.zmin = self.zmin if self.zmin is not None else -self.zmax
818 self.zmin = self.zmin if self.zmin is not None else -self.zmax
796 ax.plt = ax.pcolormesh(x, y, z[n, :, :].T*self.factors[n],
819 ax.plt = ax.pcolormesh(x, y, z[n, :, :].T * self.factors[n],
797 vmin=self.zmin,
820 vmin=self.zmin,
@@ -810,6 +833,7 class PlotParamData(PlotRTIData):
810
833
811 self.saveTime = self.min_time
834 self.saveTime = self.min_time
812
835
836
813 class PlotOuputData(PlotParamData):
837 class PlotOuputData(PlotParamData):
814 '''
838 '''
815 Plot data_output object
839 Plot data_output object
@@ -6,8 +6,8 from jroproc_base import ProcessingUnit, Operation
6 from schainpy.model.data.jroamisr import AMISR
6 from schainpy.model.data.jroamisr import AMISR
7
7
8 class AMISRProc(ProcessingUnit):
8 class AMISRProc(ProcessingUnit):
9 def __init__(self):
9 def __init__(self, **kwargs):
10 ProcessingUnit.__init__(self)
10 ProcessingUnit.__init__(self, **kwargs)
11 self.objectDict = {}
11 self.objectDict = {}
12 self.dataOut = AMISR()
12 self.dataOut = AMISR()
13
13
@@ -17,7 +17,8 class AMISRProc(ProcessingUnit):
17
17
18
18
19 class PrintInfo(Operation):
19 class PrintInfo(Operation):
20 def __init__(self):
20 def __init__(self, **kwargs):
21 Operation.__init__(self, **kwargs)
21 self.__isPrinted = False
22 self.__isPrinted = False
22
23
23 def run(self, dataOut):
24 def run(self, dataOut):
@@ -42,8 +43,8 class BeamSelector(Operation):
42 profileIndex = None
43 profileIndex = None
43 nProfiles = None
44 nProfiles = None
44
45
45 def __init__(self):
46 def __init__(self, **kwargs):
46
47 Operation.__init__(self, **kwargs)
47 self.profileIndex = 0
48 self.profileIndex = 0
48 self.__isConfig = False
49 self.__isConfig = False
49
50
@@ -98,7 +99,8 class BeamSelector(Operation):
98
99
99 class ProfileToChannels(Operation):
100 class ProfileToChannels(Operation):
100
101
101 def __init__(self):
102 def __init__(self, **kwargs):
103 Operation.__init__(self, **kwargs)
102 self.__isConfig = False
104 self.__isConfig = False
103 self.__counter_chan = 0
105 self.__counter_chan = 0
104 self.buffer = None
106 self.buffer = None
@@ -1765,8 +1765,8 class WindProfiler(Operation):
1765
1765
1766 n = None
1766 n = None
1767
1767
1768 def __init__(self):
1768 def __init__(self, **kwargs):
1769 Operation.__init__(self)
1769 Operation.__init__(self, **kwargs)
1770
1770
1771 def __calculateCosDir(self, elev, azim):
1771 def __calculateCosDir(self, elev, azim):
1772 zen = (90 - elev)*numpy.pi/180
1772 zen = (90 - elev)*numpy.pi/180
@@ -2472,8 +2472,8 class WindProfiler(Operation):
2472
2472
2473 class EWDriftsEstimation(Operation):
2473 class EWDriftsEstimation(Operation):
2474
2474
2475 def __init__(self):
2475 def __init__(self, **kwargs):
2476 Operation.__init__(self)
2476 Operation.__init__(self, **kwargs)
2477
2477
2478 def __correctValues(self, heiRang, phi, velRadial, SNR):
2478 def __correctValues(self, heiRang, phi, velRadial, SNR):
2479 listPhi = phi.tolist()
2479 listPhi = phi.tolist()
General Comments 0
You need to be logged in to leave comments. Login now