@@ -0,0 +1,98 | |||
|
1 | # Byte-compiled / optimized / DLL files | |
|
2 | __pycache__/ | |
|
3 | *.py[cod] | |
|
4 | *$py.class | |
|
5 | ||
|
6 | # C extensions | |
|
7 | *.so | |
|
8 | ||
|
9 | # Distribution / packaging | |
|
10 | .Python | |
|
11 | env/ | |
|
12 | build/ | |
|
13 | develop-eggs/ | |
|
14 | dist/ | |
|
15 | downloads/ | |
|
16 | eggs/ | |
|
17 | .eggs/ | |
|
18 | lib/ | |
|
19 | lib64/ | |
|
20 | parts/ | |
|
21 | sdist/ | |
|
22 | var/ | |
|
23 | wheels/ | |
|
24 | *.egg-info/ | |
|
25 | .installed.cfg | |
|
26 | *.egg | |
|
27 | ||
|
28 | # PyInstaller | |
|
29 | # Usually these files are written by a python script from a template | |
|
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. | |
|
31 | *.manifest | |
|
32 | *.spec | |
|
33 | ||
|
34 | # Installer logs | |
|
35 | pip-log.txt | |
|
36 | pip-delete-this-directory.txt | |
|
37 | ||
|
38 | # Unit test / coverage reports | |
|
39 | htmlcov/ | |
|
40 | .tox/ | |
|
41 | .coverage | |
|
42 | .coverage.* | |
|
43 | .cache | |
|
44 | nosetests.xml | |
|
45 | coverage.xml | |
|
46 | *,cover | |
|
47 | .hypothesis/ | |
|
48 | ||
|
49 | # Translations | |
|
50 | *.mo | |
|
51 | *.pot | |
|
52 | ||
|
53 | # Django stuff: | |
|
54 | *.log | |
|
55 | local_settings.py | |
|
56 | ||
|
57 | # Flask stuff: | |
|
58 | instance/ | |
|
59 | .webassets-cache | |
|
60 | ||
|
61 | # Scrapy stuff: | |
|
62 | .scrapy | |
|
63 | ||
|
64 | # Sphinx documentation | |
|
65 | docs/_build/ | |
|
66 | ||
|
67 | # PyBuilder | |
|
68 | target/ | |
|
69 | ||
|
70 | # Jupyter Notebook | |
|
71 | .ipynb_checkpoints | |
|
72 | ||
|
73 | # pyenv | |
|
74 | .python-version | |
|
75 | ||
|
76 | # celery beat schedule file | |
|
77 | celerybeat-schedule | |
|
78 | ||
|
79 | # SageMath parsed files | |
|
80 | *.sage.py | |
|
81 | ||
|
82 | # dotenv | |
|
83 | .env | |
|
84 | ||
|
85 | # virtualenv | |
|
86 | .venv | |
|
87 | venv/ | |
|
88 | ENV/ | |
|
89 | ||
|
90 | # Spyder project settings | |
|
91 | .spyderproject | |
|
92 | .spyproject | |
|
93 | ||
|
94 | # Rope project settings | |
|
95 | .ropeproject | |
|
96 | ||
|
97 | # mkdocs documentation | |
|
98 | /site |
@@ -0,0 +1,42 | |||
|
1 | #!/usr/bin/env python | |
|
2 | ''' | |
|
3 | Created on Jul 7, 2014 | |
|
4 | ||
|
5 | @author: roj-idl71 | |
|
6 | ''' | |
|
7 | import os, sys | |
|
8 | ||
|
9 | from schainpy.controller import Project | |
|
10 | ||
|
11 | if __name__ == '__main__': | |
|
12 | desc = "Segundo Test" | |
|
13 | ||
|
14 | controllerObj = Project() | |
|
15 | controllerObj.setup(id = '191', name='test01', description=desc) | |
|
16 | ||
|
17 | proc1 = controllerObj.addProcUnit(name='ReceiverData') | |
|
18 | # proc1.addParameter(name='server', value='tcp://10.10.10.87:3000', format='str') | |
|
19 | proc1.addParameter(name='realtime', value='1', format='bool') | |
|
20 | proc1.addParameter(name='plottypes', value='rti,spc', format='str') | |
|
21 | ||
|
22 | op1 = proc1.addOperation(name='PlotRTIData', optype='other') | |
|
23 | op1.addParameter(name='wintitle', value='Julia 150Km', format='str') | |
|
24 | ||
|
25 | op2 = proc1.addOperation(name='PlotSpectraData', optype='other') | |
|
26 | op2.addParameter(name='wintitle', value='Julia 150Km', format='str') | |
|
27 | op2.addParameter(name='xaxis', value='velocity', format='str') | |
|
28 | op2.addParameter(name='showprofile', value='1', format='bool') | |
|
29 | #op2.addParameter(name='xmin', value='-0.1', format='float') | |
|
30 | #op2.addParameter(name='xmax', value='0.1', format='float') | |
|
31 | ||
|
32 | # op1 = proc1.addOperation(name='PlotPHASEData', optype='other') | |
|
33 | # op1.addParameter(name='wintitle', value='Julia 150Km', format='str') | |
|
34 | ||
|
35 | ||
|
36 | # proc1 = controllerObj.addProcUnit(name='ReceiverData') | |
|
37 | # proc1.addParameter(name='server', value='pipe2', format='str') | |
|
38 | # proc1.addParameter(name='mode', value='buffer', format='str') | |
|
39 | # proc1.addParameter(name='plottypes', value='snr', format='str') | |
|
40 | ||
|
41 | ||
|
42 | controllerObj.start() |
@@ -283,6 +283,19 class OperationConf(): | |||
|
283 | 283 | |
|
284 | 284 | return value |
|
285 | 285 | |
|
286 | ||
|
287 | def getKwargs(self): | |
|
288 | ||
|
289 | kwargs = {} | |
|
290 | ||
|
291 | for parmConfObj in self.parmConfObjList: | |
|
292 | if self.name == 'run' and parmConfObj.name == 'datatype': | |
|
293 | continue | |
|
294 | ||
|
295 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
|
296 | ||
|
297 | return kwargs | |
|
298 | ||
|
286 | 299 | def setup(self, id, name, priority, type): |
|
287 | 300 | |
|
288 | 301 | self.id = str(id) |
@@ -383,10 +396,12 class OperationConf(): | |||
|
383 | 396 | |
|
384 | 397 | if self.type == 'external' or self.type == 'other': |
|
385 | 398 | className = eval(self.name) |
|
386 | opObj = className() | |
|
399 | kwargs = self.getKwargs() | |
|
400 | opObj = className(**kwargs) | |
|
387 | 401 | |
|
388 | 402 | return opObj |
|
389 | 403 | |
|
404 | ||
|
390 | 405 | class ProcUnitConf(): |
|
391 | 406 | |
|
392 | 407 | id = None |
@@ -586,10 +601,19 class ProcUnitConf(): | |||
|
586 | 601 | for opConfObj in self.opConfObjList: |
|
587 | 602 | opConfObj.printattr() |
|
588 | 603 | |
|
604 | ||
|
605 | def getKwargs(self): | |
|
606 | ||
|
607 | opObj = self.opConfObjList[0] | |
|
608 | kwargs = opObj.getKwargs() | |
|
609 | ||
|
610 | return kwargs | |
|
611 | ||
|
589 | 612 | def createObjects(self, plotter_queue=None): |
|
590 | 613 | |
|
591 | 614 | className = eval(self.name) |
|
592 | procUnitObj = className() | |
|
615 | kwargs = self.getKwargs() | |
|
616 | procUnitObj = className(**kwargs) | |
|
593 | 617 | |
|
594 | 618 | for opConfObj in self.opConfObjList: |
|
595 | 619 | |
@@ -624,7 +648,7 class ProcUnitConf(): | |||
|
624 | 648 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
625 | 649 | opName = opConfObj.name, |
|
626 | 650 | opId = opConfObj.id, |
|
627 |
|
|
|
651 | ) | |
|
628 | 652 | |
|
629 | 653 | # total_time = time.time() - ini |
|
630 | 654 | # |
@@ -1232,63 +1256,6 class Project(): | |||
|
1232 | 1256 | def start(self): |
|
1233 | 1257 | |
|
1234 | 1258 | self.writeXml() |
|
1235 | ||
|
1236 | 1259 | self.createObjects() |
|
1237 | 1260 | self.connectObjects() |
|
1238 | 1261 | self.run() |
|
1239 | ||
|
1240 | if __name__ == '__main__': | |
|
1241 | ||
|
1242 | desc = "Segundo Test" | |
|
1243 | filename = "schain.xml" | |
|
1244 | ||
|
1245 | controllerObj = Project() | |
|
1246 | ||
|
1247 | controllerObj.setup(id = '191', name='test01', description=desc) | |
|
1248 | ||
|
1249 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
|
1250 | path='data/rawdata/', | |
|
1251 | startDate='2011/01/01', | |
|
1252 | endDate='2012/12/31', | |
|
1253 | startTime='00:00:00', | |
|
1254 | endTime='23:59:59', | |
|
1255 | online=1, | |
|
1256 | walk=1) | |
|
1257 | ||
|
1258 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
|
1259 | ||
|
1260 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
|
1261 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
|
1262 | ||
|
1263 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
|
1264 | opObj10.addParameter(name='minHei', value='90', format='float') | |
|
1265 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
|
1266 | ||
|
1267 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
|
1268 | opObj12.addParameter(name='n', value='10', format='int') | |
|
1269 | ||
|
1270 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
|
1271 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
|
1272 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') | |
|
1273 | ||
|
1274 | ||
|
1275 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
|
1276 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
|
1277 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
|
1278 | opObj11.addParameter(name='zmin', value='40', format='int') | |
|
1279 | opObj11.addParameter(name='zmax', value='90', format='int') | |
|
1280 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
|
1281 | ||
|
1282 | print "Escribiendo el archivo XML" | |
|
1283 | ||
|
1284 | controllerObj.writeXml(filename) | |
|
1285 | ||
|
1286 | print "Leyendo el archivo XML" | |
|
1287 | controllerObj.readXml(filename) | |
|
1288 | #controllerObj.printattr() | |
|
1289 | ||
|
1290 | controllerObj.createObjects() | |
|
1291 | controllerObj.connectObjects() | |
|
1292 | controllerObj.run() | |
|
1293 | ||
|
1294 | No newline at end of file |
@@ -698,6 +698,33 class Spectra(JROData): | |||
|
698 | 698 | |
|
699 | 699 | return 10*numpy.log10(avg) |
|
700 | 700 | |
|
701 | def getCoherence(self, pairsList=None, phase=False): | |
|
702 | ||
|
703 | z = [] | |
|
704 | if pairsList is None: | |
|
705 | pairsIndexList = self.pairsIndexList | |
|
706 | else: | |
|
707 | pairsIndexList = [] | |
|
708 | for pair in pairsList: | |
|
709 | if pair not in self.pairsList: | |
|
710 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
|
711 | pairsIndexList.append(self.pairsList.index(pair)) | |
|
712 | for i in range(len(pairsIndexList)): | |
|
713 | pair = self.pairsList[pairsIndexList[i]] | |
|
714 | ccf = numpy.average(self.data_cspc[pairsIndexList[i], :, :], axis=0) | |
|
715 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) | |
|
716 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) | |
|
717 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
|
718 | if phase: | |
|
719 | data = numpy.arctan2(avgcoherenceComplex.imag, | |
|
720 | avgcoherenceComplex.real)*180/numpy.pi | |
|
721 | else: | |
|
722 | data = numpy.abs(avgcoherenceComplex) | |
|
723 | ||
|
724 | z.append(data) | |
|
725 | ||
|
726 | return numpy.array(z) | |
|
727 | ||
|
701 | 728 | def setValue(self, value): |
|
702 | 729 | |
|
703 | 730 | print "This property should not be initialized" |
@@ -1,5 +1,6 | |||
|
1 | 1 | |
|
2 | 2 | import os |
|
3 | import zmq | |
|
3 | 4 | import time |
|
4 | 5 | import numpy |
|
5 | 6 | import datetime |
@@ -7,80 +8,48 import numpy as np | |||
|
7 | 8 | import matplotlib.pyplot as plt |
|
8 | 9 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
9 | 10 | from matplotlib.ticker import FuncFormatter, LinearLocator |
|
11 | from multiprocessing import Process | |
|
10 | 12 | |
|
11 | 13 | from schainpy.model.proc.jroproc_base import Operation |
|
12 | 14 | |
|
15 | #plt.ion() | |
|
16 | ||
|
13 | 17 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime('%H:%M')) |
|
14 | 18 | |
|
15 | 19 | d1970 = datetime.datetime(1970,1,1) |
|
16 | 20 | |
|
21 | class PlotData(Operation, Process): | |
|
17 | 22 | |
|
18 | class PlotData(Operation): | |
|
19 | ||
|
20 | __code = 'Figure' | |
|
23 | CODE = 'Figure' | |
|
24 | colormap = 'jet' | |
|
21 | 25 | __MAXNUMX = 80 |
|
22 | 26 | __MAXNUMY = 80 |
|
23 | 27 | __missing = 1E30 |
|
24 | 28 | |
|
25 | def __init__(self): | |
|
29 | def __init__(self, **kwargs): | |
|
26 | 30 | |
|
27 | 31 | Operation.__init__(self) |
|
28 | self.xmin = None | |
|
29 |
self. |
|
|
30 | self.newdataOut = None | |
|
32 | Process.__init__(self) | |
|
33 | self.mp = False | |
|
31 | 34 | self.dataOut = None |
|
32 | 35 | self.isConfig = False |
|
33 | 36 | self.figure = None |
|
34 | self.width = 6 | |
|
35 | self.height = 4 | |
|
36 | ||
|
37 | def setup(self, dataOut, **kwargs): | |
|
38 | ||
|
39 | self.first = True | |
|
40 | self.localtime = kwargs.pop('localtime', True) | |
|
41 | self.show = kwargs.pop('show', True) | |
|
42 | self.save = kwargs.pop('save', False) | |
|
43 | self.pause = kwargs.pop('pause', False) | |
|
44 | self.time = [] | |
|
45 | self.nblock = 0 | |
|
46 | self.z = [] | |
|
47 | self.data = [{} for __ in dataOut.channelList] | |
|
48 | 37 |
self.axes = [] |
|
49 |
self. |
|
|
38 | self.localtime = kwargs.pop('localtime', True) | |
|
39 | self.show = kwargs.get('show', True) | |
|
40 | self.save = kwargs.get('save', False) | |
|
41 | self.colormap = kwargs.get('colormap', self.colormap) | |
|
42 | self.showprofile = kwargs.get('showprofile', False) | |
|
50 | 43 | self.title = kwargs.get('wintitle', '') |
|
51 |
self.xaxis = kwargs.get('xaxis', |
|
|
44 | self.xaxis = kwargs.get('xaxis', 'time') | |
|
52 | 45 | self.zmin = kwargs.get('zmin', None) |
|
53 | 46 | self.zmax = kwargs.get('zmax', None) |
|
54 | ||
|
55 |
|
|
|
56 |
|
|
|
57 | ||
|
58 | dt = dataOut.datatime.date() | |
|
59 | dtmin = datetime.datetime.combine(dt, datetime.time(xmin, 0, 0)) | |
|
60 | dtmax = datetime.datetime.combine(dt, datetime.time(xmax, 59, 59)) | |
|
61 | ||
|
62 | self.xmin = (dtmin-d1970).total_seconds() | |
|
63 | self.xmax = (dtmax-d1970).total_seconds() | |
|
64 | ||
|
47 | self.xmin = kwargs.get('xmin', None) | |
|
48 | self.xmax = kwargs.get('xmax', None) | |
|
49 | self.xrange = kwargs.get('xrange', 24) | |
|
65 | 50 | self.ymin = kwargs.get('ymin', None) |
|
66 | 51 | self.ymax = kwargs.get('ymax', None) |
|
67 | 52 | |
|
68 | if self.figure is None: | |
|
69 | self.figure = plt.figure() | |
|
70 | else: | |
|
71 | self.figure.clf() | |
|
72 | ||
|
73 | self.setup_fig() | |
|
74 | ||
|
75 | for n in range(dataOut.nChannels): | |
|
76 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
|
77 | ax.firsttime = True | |
|
78 | self.axes.append(ax) | |
|
79 | ||
|
80 | self.setup_fig() | |
|
81 | ||
|
82 | self.figure.set_size_inches (self.width, self.height) | |
|
83 | ||
|
84 | 53 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
85 | 54 | |
|
86 | 55 | if x_buffer.shape[0] < 2: |
@@ -110,43 +79,60 class PlotData(Operation): | |||
|
110 | 79 | |
|
111 | 80 | return x, y, z |
|
112 | 81 | |
|
113 | def _plot(self): | |
|
82 | def __plot(self): | |
|
114 | 83 | |
|
115 | self.plot() | |
|
84 | print 'plotting...{}'.format(self.CODE) | |
|
116 | 85 | |
|
117 | self.figure.suptitle(self.title+self.__code) | |
|
86 | self.plot() | |
|
87 | self.figure.suptitle('{} {}'.format(self.title, self.CODE.upper())) | |
|
118 | 88 | |
|
119 | 89 | if self.save: |
|
120 |
figname = os.path.join(self.save, '{}_{}.png'.format(self. |
|
|
121 |
self. |
|
|
90 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
|
91 | datetime.datetime.utcfromtimestamp(self.times[-1]).strftime('%y%m%d_%H%M%S'))) | |
|
122 | 92 | print 'Saving figure: {}'.format(figname) |
|
123 | 93 | self.figure.savefig(figname) |
|
124 | 94 | |
|
125 | 95 | self.figure.canvas.draw() |
|
126 | if self.show: | |
|
127 | self.figure.show() | |
|
128 | if self.pause: | |
|
129 | raw_input('Press <ENTER> to continue') | |
|
130 | ||
|
131 | 96 | |
|
132 |
def |
|
|
133 | ||
|
134 | pass | |
|
135 | ||
|
136 | def run(self, dataOut, **kwargs): | |
|
137 | ||
|
138 | self.dataOut = dataOut | |
|
97 | def plot(self): | |
|
139 | 98 | |
|
140 | if not self.isConfig: | |
|
141 | self.setup(dataOut, **kwargs) | |
|
99 | print 'plotting...{}'.format(self.CODE.upper()) | |
|
100 | return | |
|
101 | ||
|
102 | def run(self): | |
|
103 | ||
|
104 | print '[Starting] {}'.format(self.name) | |
|
105 | context = zmq.Context() | |
|
106 | receiver = context.socket(zmq.SUB) | |
|
107 | receiver.setsockopt(zmq.SUBSCRIBE, '') | |
|
108 | receiver.setsockopt(zmq.CONFLATE, True) | |
|
109 | receiver.connect("ipc:///tmp/zmq.plots") | |
|
110 | ||
|
111 | while True: | |
|
112 | try: | |
|
113 | #if True: | |
|
114 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK) | |
|
115 | self.dataOut = self.data['dataOut'] | |
|
116 | self.times = self.data['times'] | |
|
117 | self.times.sort() | |
|
118 | self.min_time = self.times[0] | |
|
119 | self.max_time = self.times[-1] | |
|
120 | ||
|
121 | if self.isConfig is False: | |
|
122 | self.setup() | |
|
142 | 123 | self.isConfig = True |
|
143 | 124 | |
|
144 | self.nblock += 1 | |
|
145 | self.update() | |
|
125 | self.__plot() | |
|
146 | 126 | |
|
147 | if dataOut.ltctime>=self.xmax: | |
|
148 | self._plot() | |
|
149 | self.isConfig = False | |
|
127 | if 'ENDED' in self.data: | |
|
128 | #self.setup() | |
|
129 | #self.__plot() | |
|
130 | pass | |
|
131 | ||
|
132 | except zmq.Again as e: | |
|
133 | print 'Waiting for data...' | |
|
134 | plt.pause(5) | |
|
135 | #time.sleep(3) | |
|
150 | 136 | |
|
151 | 137 | def close(self): |
|
152 | 138 | if self.dataOut: |
@@ -155,56 +141,170 class PlotData(Operation): | |||
|
155 | 141 | |
|
156 | 142 | class PlotSpectraData(PlotData): |
|
157 | 143 | |
|
158 | __code = 'Spectra' | |
|
144 | CODE = 'spc' | |
|
145 | colormap = 'jro' | |
|
159 | 146 | |
|
160 |
def setup |
|
|
161 | pass | |
|
147 | def setup(self): | |
|
148 | ||
|
149 | ncolspan = 1 | |
|
150 | colspan = 1 | |
|
151 | self.ncols = int(numpy.sqrt(self.dataOut.nChannels)+0.9) | |
|
152 | self.nrows = int(self.dataOut.nChannels*1./self.ncols + 0.9) | |
|
153 | self.width = 3.6*self.ncols | |
|
154 | self.height = 3.2*self.nrows | |
|
155 | if self.showprofile: | |
|
156 | ncolspan = 3 | |
|
157 | colspan = 2 | |
|
158 | self.width += 1.2*self.ncols | |
|
159 | ||
|
160 | self.ylabel = 'Range [Km]' | |
|
161 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] | |
|
162 | 162 | |
|
163 | def update(self): | |
|
163 | if self.figure is None: | |
|
164 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
165 | edgecolor='k', | |
|
166 | facecolor='w') | |
|
167 | else: | |
|
168 | self.figure.clf() | |
|
169 | ||
|
170 | n = 0 | |
|
171 | for y in range(self.nrows): | |
|
172 | for x in range(self.ncols): | |
|
173 | if n>=self.dataOut.nChannels: | |
|
174 | break | |
|
175 | ax = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan), 1, colspan) | |
|
176 | if self.showprofile: | |
|
177 | ax.ax_profile = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan+colspan), 1, 1) | |
|
164 | 178 | |
|
165 | for ch in self.dataOut.channelList: | |
|
166 | self.data[ch] = self.dataOut.data_spc[ch] | |
|
179 | ax.firsttime = True | |
|
180 | self.axes.append(ax) | |
|
181 | n += 1 | |
|
182 | ||
|
183 | self.figure.subplots_adjust(wspace=0.9, hspace=0.5) | |
|
184 | self.figure.show() | |
|
167 | 185 | |
|
168 | 186 | def plot(self): |
|
169 | pass | |
|
187 | ||
|
188 | if self.xaxis == "frequency": | |
|
189 | x = self.dataOut.getFreqRange(1)/1000. | |
|
190 | xlabel = "Frequency (kHz)" | |
|
191 | elif self.xaxis == "time": | |
|
192 | x = self.dataOut.getAcfRange(1) | |
|
193 | xlabel = "Time (ms)" | |
|
194 | else: | |
|
195 | x = self.dataOut.getVelRange(1) | |
|
196 | xlabel = "Velocity (m/s)" | |
|
197 | ||
|
198 | y = self.dataOut.getHeiRange() | |
|
199 | z = self.data[self.CODE] | |
|
200 | ||
|
201 | for n, ax in enumerate(self.axes): | |
|
202 | ||
|
203 | if ax.firsttime: | |
|
204 | self.xmax = self.xmax if self.xmax else np.nanmax(x) | |
|
205 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
206 | self.ymin = self.ymin if self.ymin else np.nanmin(y) | |
|
207 | self.ymax = self.ymax if self.ymax else np.nanmax(y) | |
|
208 | self.zmin = self.zmin if self.zmin else np.nanmin(z) | |
|
209 | self.zmax = self.zmax if self.zmax else np.nanmax(z) | |
|
210 | ax.plot = ax.pcolormesh(x, y, z[n].T, | |
|
211 | vmin=self.zmin, | |
|
212 | vmax=self.zmax, | |
|
213 | cmap=plt.get_cmap(self.colormap) | |
|
214 | ) | |
|
215 | divider = make_axes_locatable(ax) | |
|
216 | cax = divider.new_horizontal(size='3%', pad=0.05) | |
|
217 | self.figure.add_axes(cax) | |
|
218 | plt.colorbar(ax.plot, cax) | |
|
219 | ||
|
220 | ax.set_xlim(self.xmin, self.xmax) | |
|
221 | ax.set_ylim(self.ymin, self.ymax) | |
|
222 | ||
|
223 | ax.xaxis.set_major_locator(LinearLocator(5)) | |
|
224 | #ax.yaxis.set_major_locator(LinearLocator(4)) | |
|
225 | ||
|
226 | ax.set_ylabel(self.ylabel) | |
|
227 | ax.set_xlabel(xlabel) | |
|
228 | ||
|
229 | ax.firsttime = False | |
|
230 | ||
|
231 | if self.showprofile: | |
|
232 | ax.plot_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0] | |
|
233 | ax.ax_profile.set_xlim(self.zmin, self.zmax) | |
|
234 | ax.ax_profile.set_ylim(self.ymin, self.ymax) | |
|
235 | ax.ax_profile.set_xlabel('dB') | |
|
236 | ax.ax_profile.grid(b=True, axis='x') | |
|
237 | [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()] | |
|
238 | noise = 10*numpy.log10(self.data['rti'][self.max_time][n]/self.dataOut.normFactor) | |
|
239 | ax.ax_profile.vlines(noise, self.ymin, self.ymax, colors="k", linestyle="dashed", lw=2) | |
|
240 | else: | |
|
241 | ax.plot.set_array(z[n].T.ravel()) | |
|
242 | ax.set_title('{} {}'.format(self.titles[n], | |
|
243 | datetime.datetime.utcfromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
|
244 | size=8) | |
|
245 | if self.showprofile: | |
|
246 | ax.plot_profile.set_data(self.data['rti'][self.max_time][n], y) | |
|
170 | 247 | |
|
171 | 248 | |
|
172 | 249 | class PlotRTIData(PlotData): |
|
173 | 250 | |
|
174 | __code = 'RTI' | |
|
251 | CODE = 'rti' | |
|
252 | colormap = 'jro' | |
|
175 | 253 | |
|
176 |
def setup |
|
|
254 | def setup(self): | |
|
177 | 255 | |
|
178 | 256 | self.ncols = 1 |
|
179 | 257 | self.nrows = self.dataOut.nChannels |
|
180 |
self.width = |
|
|
258 | self.width = 10 | |
|
181 | 259 | self.height = 2.2*self.nrows |
|
182 | 260 | self.ylabel = 'Range [Km]' |
|
261 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] | |
|
183 | 262 | |
|
184 | def update(self): | |
|
263 | if self.figure is None: | |
|
264 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
265 | edgecolor='k', | |
|
266 | facecolor='w') | |
|
267 | else: | |
|
268 | self.figure.clf() | |
|
185 | 269 | |
|
186 | self.time.append(self.dataOut.ltctime) | |
|
270 | for n in range(self.nrows): | |
|
271 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
|
272 | ax.firsttime = True | |
|
273 | self.axes.append(ax) | |
|
187 | 274 | |
|
188 | for ch in self.dataOut.channelList: | |
|
189 | self.data[ch][self.dataOut.ltctime] = self.dataOut.getPower()[ch] | |
|
275 | self.figure.subplots_adjust(hspace=0.5) | |
|
276 | self.figure.show() | |
|
190 | 277 | |
|
191 | 278 | def plot(self): |
|
192 | 279 | |
|
193 | self.plot_dt = datetime.datetime.utcfromtimestamp(self.time[-2]) | |
|
194 | ||
|
195 | self.time.sort() | |
|
196 | self.x = self.time | |
|
280 | self.x = np.array(self.times) | |
|
197 | 281 | self.y = self.dataOut.getHeiRange() |
|
198 | 282 | self.z = [] |
|
199 | 283 | |
|
200 |
for ch in self. |
|
|
201 |
self.z.append([self.data[ |
|
|
284 | for ch in range(self.nrows): | |
|
285 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |
|
202 | 286 | |
|
203 | self.x = np.array(self.x) | |
|
204 | 287 |
self.z = np.array(self.z) |
|
205 | 288 | |
|
206 | 289 |
for n, ax in enumerate(self.axes): |
|
207 | 290 | |
|
291 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
292 | ||
|
293 | if ax.firsttime: | |
|
294 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
|
295 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
|
296 | self.zmin = self.zmin if self.zmin else np.nanmin(self.z) | |
|
297 | zmax = self.zmax if self.zmax else np.nanmax(self.z) | |
|
298 | plot = ax.pcolormesh(x, y, z[n].T, | |
|
299 | vmin=self.zmin, | |
|
300 | vmax=self.zmax, | |
|
301 | cmap=plt.get_cmap(self.colormap) | |
|
302 | ) | |
|
303 | divider = make_axes_locatable(ax) | |
|
304 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
|
305 | self.figure.add_axes(cax) | |
|
306 | plt.colorbar(plot, cax) | |
|
307 | ax.set_ylim(self.ymin, self.ymax) | |
|
208 | 308 | if self.xaxis=='time': |
|
209 | 309 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
210 | 310 | ax.xaxis.set_major_locator(LinearLocator(6)) |
@@ -213,47 +313,64 class PlotRTIData(PlotData): | |||
|
213 | 313 | |
|
214 | 314 | ax.set_ylabel(self.ylabel) |
|
215 | 315 | |
|
216 |
|
|
|
217 | ||
|
218 | ax.set_title('Channel {} {}'.format(self.dataOut.channelList[n], | |
|
219 | self.plot_dt.strftime('%y/%m/%d %H:%M:%S')), | |
|
220 | size=8) | |
|
221 | ||
|
222 | self.decimate() | |
|
316 | if self.xmin is None: | |
|
317 | print 'is none' | |
|
318 | xmin = self.min_time | |
|
319 | else: | |
|
223 | 320 | |
|
224 | for n, ax in enumerate(self.axes): | |
|
321 | xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |
|
322 | datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |
|
225 | 323 | |
|
226 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
324 | xmax = xmin+self.xrange*60*60 | |
|
227 | 325 | |
|
228 | if ax.firsttime: | |
|
229 | ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
|
230 | ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
|
231 | zmin = self.zmin if self.zmin else np.nanmin(self.z) | |
|
232 | zmax = self.zmax if self.zmax else np.nanmax(self.z) | |
|
326 | ax.set_xlim(xmin, xmax) | |
|
327 | ax.firsttime = False | |
|
328 | else: | |
|
329 | ax.collections.remove(ax.collections[0]) | |
|
233 | 330 | plot = ax.pcolormesh(x, y, z[n].T, |
|
234 | vmin=zmin, | |
|
235 | vmax=zmax, | |
|
331 | vmin=self.zmin, | |
|
332 | vmax=self.zmax, | |
|
236 | 333 | cmap=plt.get_cmap(self.colormap) |
|
237 | 334 | ) |
|
238 | divider = make_axes_locatable(ax) | |
|
239 | cax = divider.new_horizontal(size='3%', pad=0.05) | |
|
240 | self.figure.add_axes(cax) | |
|
241 | plt.colorbar(plot, cax) | |
|
242 | ax.set_ylim(self.ymin, self.ymax) | |
|
243 | ax.firsttime = False | |
|
335 | ax.set_title('{} {}'.format(self.titles[n], | |
|
336 | datetime.datetime.utcfromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
|
337 | size=8) | |
|
338 | ||
|
339 | ||
|
340 | class PlotCOHData(PlotRTIData): | |
|
341 | ||
|
342 | CODE = 'coh' | |
|
343 | ||
|
344 | def setup(self): | |
|
345 | ||
|
346 | self.ncols = 1 | |
|
347 | self.nrows = self.dataOut.nPairs | |
|
348 | self.width = 10 | |
|
349 | self.height = 2.2*self.nrows | |
|
350 | self.ylabel = 'Range [Km]' | |
|
351 | self.titles = ['Channels {}'.format(x) for x in self.dataOut.pairsList] | |
|
352 | ||
|
353 | if self.figure is None: | |
|
354 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
355 | edgecolor='k', | |
|
356 | facecolor='w') | |
|
244 | 357 | else: |
|
245 | plot = ax.pcolormesh(x, y, z[n].T) | |
|
358 | self.figure.clf() | |
|
246 | 359 | |
|
247 | self.figure.subplots_adjust(wspace=None, hspace=0.5) | |
|
360 | for n in range(self.nrows): | |
|
361 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
|
362 | ax.firsttime = True | |
|
363 | self.axes.append(ax) | |
|
248 | 364 | |
|
365 | self.figure.subplots_adjust(hspace=0.5) | |
|
366 | self.figure.show() | |
|
249 | 367 | |
|
250 | 368 | class PlotSNRData(PlotRTIData): |
|
251 | 369 | |
|
252 | __code = 'SNR' | |
|
370 | CODE = 'coh' | |
|
253 | 371 | |
|
254 | def update(self): | |
|
255 | 372 | |
|
256 | self.time.append(self.dataOut.ltctime) | |
|
373 | class PlotPHASEData(PlotCOHData): | |
|
257 | 374 | |
|
258 | for ch in self.dataOut.channelList: | |
|
259 | self.data[ch][self.dataOut.ltctime] = 10*np.log10(self.dataOut.data_SNR[ch]) No newline at end of file | |
|
375 | CODE = 'phase' | |
|
376 | colormap = 'seismic' |
@@ -69,7 +69,7 class SpectraReader(JRODataReader, ProcessingUnit): | |||
|
69 | 69 | |
|
70 | 70 | rdPairList = [] |
|
71 | 71 | |
|
72 | def __init__(self): | |
|
72 | def __init__(self, **kwargs): | |
|
73 | 73 |
""" |
|
74 | 74 | Inicializador de la clase SpectraReader para la lectura de datos de espectros. |
|
75 | 75 | |
@@ -88,7 +88,7 class SpectraReader(JRODataReader, ProcessingUnit): | |||
|
88 | 88 | """ |
|
89 | 89 | |
|
90 | 90 | #Eliminar de la base la herencia |
|
91 | ProcessingUnit.__init__(self) | |
|
91 | ProcessingUnit.__init__(self, **kwargs) | |
|
92 | 92 | |
|
93 | 93 | # self.isConfig = False |
|
94 | 94 |
@@ -27,7 +27,7 class ProcessingUnit(object): | |||
|
27 | 27 | isConfig = False |
|
28 | 28 | |
|
29 | 29 | |
|
30 | def __init__(self): | |
|
30 | def __init__(self, *args, **kwargs): | |
|
31 | 31 | |
|
32 | 32 | self.dataIn = None |
|
33 | 33 | self.dataInList = [] |
@@ -38,6 +38,9 class ProcessingUnit(object): | |||
|
38 | 38 | |
|
39 | 39 | self.isConfig = False |
|
40 | 40 | |
|
41 | self.args = args | |
|
42 | self.kwargs = kwargs | |
|
43 | ||
|
41 | 44 | def addOperation(self, opObj, objId): |
|
42 | 45 | |
|
43 | 46 | """ |
@@ -104,17 +107,13 class ProcessingUnit(object): | |||
|
104 | 107 | methodToCall = getattr(self, name) |
|
105 | 108 | |
|
106 | 109 | #Executing the self method |
|
107 | methodToCall(**kwargs) | |
|
108 | 110 | |
|
109 | #Checkin the outputs | |
|
110 | ||
|
111 | # if name == 'run': | |
|
112 |
|
|
|
113 |
|
|
|
114 | # pass | |
|
115 | # | |
|
116 | # if name != 'run': | |
|
117 | # return True | |
|
111 | if hasattr(self, 'mp'): | |
|
112 | if self.mp is False: | |
|
113 | self.mp = True | |
|
114 | self.start() | |
|
115 | else: | |
|
116 | methodToCall(**kwargs) | |
|
118 | 117 | |
|
119 | 118 | if self.dataOut is None: |
|
120 | 119 | return False |
@@ -124,7 +123,7 class ProcessingUnit(object): | |||
|
124 | 123 | |
|
125 | 124 | return True |
|
126 | 125 | |
|
127 |
def callObject(self, objId |
|
|
126 | def callObject(self, objId): | |
|
128 | 127 | |
|
129 | 128 | """ |
|
130 | 129 | Ejecuta la operacion asociada al identificador del objeto "objId" |
@@ -140,16 +139,21 class ProcessingUnit(object): | |||
|
140 | 139 | None |
|
141 | 140 | """ |
|
142 | 141 | |
|
143 | if self.dataOut.isEmpty(): | |
|
142 | if self.dataOut is not None and self.dataOut.isEmpty(): | |
|
144 | 143 | return False |
|
145 | 144 | |
|
146 | 145 | externalProcObj = self.operations2RunDict[objId] |
|
147 | 146 | |
|
148 | externalProcObj.run(self.dataOut, **kwargs) | |
|
147 | if hasattr(externalProcObj, 'mp'): | |
|
148 | if externalProcObj.mp is False: | |
|
149 | externalProcObj.mp = True | |
|
150 | externalProcObj.start() | |
|
151 | else: | |
|
152 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) | |
|
149 | 153 | |
|
150 | 154 | return True |
|
151 | 155 | |
|
152 |
def call(self, opType, opName=None, opId=None |
|
|
156 | def call(self, opType, opName=None, opId=None): | |
|
153 | 157 | |
|
154 | 158 | """ |
|
155 | 159 | Return True si ejecuta la operacion interna nombrada "opName" o la operacion externa |
@@ -194,7 +198,7 class ProcessingUnit(object): | |||
|
194 | 198 | if not opName: |
|
195 | 199 | raise ValueError, "opName parameter should be defined" |
|
196 | 200 | |
|
197 | sts = self.callMethod(opName, **kwargs) | |
|
201 | sts = self.callMethod(opName, **self.kwargs) | |
|
198 | 202 | |
|
199 | 203 | elif opType == 'other' or opType == 'external' or opType == 'plotter': |
|
200 | 204 | |
@@ -204,7 +208,7 class ProcessingUnit(object): | |||
|
204 | 208 | if opId not in self.operations2RunDict.keys(): |
|
205 | 209 | raise ValueError, "Any operation with id=%s has been added" %str(opId) |
|
206 | 210 | |
|
207 |
sts = self.callObject(opId |
|
|
211 | sts = self.callObject(opId) | |
|
208 | 212 | |
|
209 | 213 | else: |
|
210 | 214 | raise ValueError, "opType should be 'self', 'external' or 'plotter'; and not '%s'" %opType |
@@ -255,10 +259,11 class Operation(object): | |||
|
255 | 259 | __buffer = None |
|
256 | 260 | isConfig = False |
|
257 | 261 | |
|
258 | def __init__(self): | |
|
262 | def __init__(self, **kwargs): | |
|
259 | 263 | |
|
260 | 264 | self.__buffer = None |
|
261 | 265 | self.isConfig = False |
|
266 | self.kwargs = kwargs | |
|
262 | 267 | |
|
263 | 268 | def setup(self): |
|
264 | 269 |
@@ -16,6 +16,8 from multiprocessing import Process | |||
|
16 | 16 | |
|
17 | 17 | from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit |
|
18 | 18 | |
|
19 | MAXNUMX = 100 | |
|
20 | MAXNUMY = 100 | |
|
19 | 21 | throttle_value = 5 |
|
20 | 22 | |
|
21 | 23 | class PrettyFloat(float): |
@@ -28,14 +30,6 def roundFloats(obj): | |||
|
28 | 30 | elif isinstance(obj, float): |
|
29 | 31 | return round(obj, 2) |
|
30 | 32 | |
|
31 | def pretty_floats(obj): | |
|
32 | if isinstance(obj, float): | |
|
33 | return PrettyFloat(obj) | |
|
34 | elif isinstance(obj, dict): | |
|
35 | return dict((k, pretty_floats(v)) for k, v in obj.items()) | |
|
36 | elif isinstance(obj, (list, tuple)): | |
|
37 | return map(pretty_floats, obj) | |
|
38 | return obj | |
|
39 | 33 | |
|
40 | 34 | class throttle(object): |
|
41 | 35 | """Decorator that prevents a function from being called more than once every |
@@ -76,9 +70,6 class throttle(object): | |||
|
76 | 70 | class PublishData(Operation): |
|
77 | 71 | """Clase publish.""" |
|
78 | 72 | |
|
79 | __MAXNUMX = 100 | |
|
80 | __MAXNUMY = 100 | |
|
81 | ||
|
82 | 73 | def __init__(self, **kwargs): |
|
83 | 74 | """Inicio.""" |
|
84 | 75 | Operation.__init__(self, **kwargs) |
@@ -166,8 +157,8 class PublishData(Operation): | |||
|
166 | 157 | z = data/self.dataOut.normFactor |
|
167 | 158 | zdB = 10*numpy.log10(z) |
|
168 | 159 | xlen, ylen = zdB[0].shape |
|
169 |
dx = |
|
|
170 |
dy = |
|
|
160 | dx = int(xlen/MAXNUMX) + 1 | |
|
161 | dy = int(ylen/MAXNUMY) + 1 | |
|
171 | 162 | Z = [0 for i in self.dataOut.channelList] |
|
172 | 163 | for i in self.dataOut.channelList: |
|
173 | 164 | Z[i] = zdB[i][::dx, ::dy].tolist() |
@@ -257,3 +248,131 class PublishData(Operation): | |||
|
257 | 248 | if self.client: |
|
258 | 249 | self.client.loop_stop() |
|
259 | 250 | self.client.disconnect() |
|
251 | ||
|
252 | ||
|
253 | class ReceiverData(ProcessingUnit, Process): | |
|
254 | ||
|
255 | def __init__(self, **kwargs): | |
|
256 | ||
|
257 | ProcessingUnit.__init__(self, **kwargs) | |
|
258 | Process.__init__(self) | |
|
259 | self.mp = False | |
|
260 | self.isConfig = False | |
|
261 | self.plottypes =[] | |
|
262 | self.connections = 0 | |
|
263 | server = kwargs.get('server', 'zmq.pipe') | |
|
264 | if 'tcp://' in server: | |
|
265 | address = server | |
|
266 | else: | |
|
267 | address = 'ipc:///tmp/%s' % server | |
|
268 | ||
|
269 | self.address = address | |
|
270 | self.plottypes = [s.strip() for s in kwargs.get('plottypes', 'rti').split(',')] | |
|
271 | self.realtime = kwargs.get('realtime', False) | |
|
272 | global throttle_value | |
|
273 | throttle_value = kwargs.get('throttle', 10) | |
|
274 | self.setup() | |
|
275 | ||
|
276 | def setup(self): | |
|
277 | ||
|
278 | self.data = {} | |
|
279 | self.data['times'] = [] | |
|
280 | for plottype in self.plottypes: | |
|
281 | self.data[plottype] = {} | |
|
282 | ||
|
283 | self.isConfig = True | |
|
284 | ||
|
285 | def event_monitor(self, monitor): | |
|
286 | ||
|
287 | events = {} | |
|
288 | ||
|
289 | for name in dir(zmq): | |
|
290 | if name.startswith('EVENT_'): | |
|
291 | value = getattr(zmq, name) | |
|
292 | events[value] = name | |
|
293 | ||
|
294 | while monitor.poll(): | |
|
295 | evt = recv_monitor_message(monitor) | |
|
296 | if evt['event'] == 32: | |
|
297 | self.connections += 1 | |
|
298 | if evt['event'] == 512: | |
|
299 | pass | |
|
300 | if self.connections == 0 and self.started is True: | |
|
301 | self.ended = True | |
|
302 | # send('ENDED') | |
|
303 | evt.update({'description': events[evt['event']]}) | |
|
304 | ||
|
305 | if evt['event'] == zmq.EVENT_MONITOR_STOPPED: | |
|
306 | break | |
|
307 | monitor.close() | |
|
308 | print("event monitor thread done!") | |
|
309 | ||
|
310 | @throttle(seconds=throttle_value) | |
|
311 | def sendData(self, data): | |
|
312 | self.send(data) | |
|
313 | ||
|
314 | def send(self, data): | |
|
315 | print '[sending] data=%s size=%s' % (data.keys(), len(data['times'])) | |
|
316 | self.sender.send_pyobj(data) | |
|
317 | ||
|
318 | def update(self): | |
|
319 | ||
|
320 | t = self.dataOut.ltctime | |
|
321 | self.data['times'].append(t) | |
|
322 | self.data['dataOut'] = self.dataOut | |
|
323 | ||
|
324 | for plottype in self.plottypes: | |
|
325 | ||
|
326 | if plottype == 'spc': | |
|
327 | z = self.dataOut.data_spc/self.dataOut.normFactor | |
|
328 | zdB = 10*numpy.log10(z) | |
|
329 | self.data[plottype] = zdB | |
|
330 | if plottype == 'rti': | |
|
331 | self.data[plottype][t] = self.dataOut.getPower() | |
|
332 | if plottype == 'snr': | |
|
333 | self.data[plottype][t] = 10*numpy.log10(self.dataOut.data_SNR) | |
|
334 | if plottype == 'dop': | |
|
335 | self.data[plottype][t] = 10*numpy.log10(self.dataOut.data_DOP) | |
|
336 | if plottype == 'coh': | |
|
337 | self.data[plottype][t] = self.dataOut.getCoherence() | |
|
338 | if plottype == 'phase': | |
|
339 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) | |
|
340 | ||
|
341 | def run(self): | |
|
342 | ||
|
343 | print '[Starting] {} from {}'.format(self.name, self.address) | |
|
344 | ||
|
345 | self.context = zmq.Context() | |
|
346 | self.receiver = self.context.socket(zmq.PULL) | |
|
347 | self.receiver.bind(self.address) | |
|
348 | monitor = self.receiver.get_monitor_socket() | |
|
349 | self.sender = self.context.socket(zmq.PUB) | |
|
350 | ||
|
351 | self.sender.bind("ipc:///tmp/zmq.plots") | |
|
352 | ||
|
353 | t = Thread(target=self.event_monitor, args=(monitor,)) | |
|
354 | t.start() | |
|
355 | ||
|
356 | while True: | |
|
357 | self.dataOut = self.receiver.recv_pyobj() | |
|
358 | print '[Receiving] {} - {}'.format(self.dataOut.type, | |
|
359 | self.dataOut.datatime.ctime()) | |
|
360 | ||
|
361 | self.update() | |
|
362 | ||
|
363 | if self.dataOut.finished is True: | |
|
364 | self.send(self.data) | |
|
365 | self.connections -= 1 | |
|
366 | if self.connections==0 and self.started: | |
|
367 | self.ended = True | |
|
368 | self.data['ENDED'] = True | |
|
369 | self.send(self.data) | |
|
370 | self.setup() | |
|
371 | else: | |
|
372 | if self.realtime: | |
|
373 | self.send(self.data) | |
|
374 | else: | |
|
375 | self.sendData(self.data) | |
|
376 | self.started = True | |
|
377 | ||
|
378 | return |
General Comments 0
You need to be logged in to leave comments.
Login now