##// END OF EJS Templates
merge v2.3
José Chávez -
r1098:831d2c3bd88d merge
parent child
Show More
@@ -15,11 +15,11 from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator
15 from schainpy.model.proc.jroproc_base import Operation
15 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(
19 blu_values = matplotlib.pyplot.get_cmap(
20 "seismic_r", 20)(numpy.arange(20))[10:15]
20 'seismic_r', 20)(numpy.arange(20))[10:15]
21 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
21 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
22 "jro", numpy.vstack((blu_values, jet_values)))
22 'jro', numpy.vstack((blu_values, jet_values)))
23 matplotlib.pyplot.register_cmap(cmap=ncmap)
23 matplotlib.pyplot.register_cmap(cmap=ncmap)
24
24
25 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')]
25 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')]
@@ -49,6 +49,10 class PlotData(Operation, Process):
49 __MAXNUMX = 80
49 __MAXNUMX = 80
50 __missing = 1E30
50 __missing = 1E30
51
51
52 __attrs__ = ['show', 'save', 'xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax',
53 'zlimits', 'xlabel', 'ylabel', 'cb_label', 'title', 'titles', 'colorbar',
54 'bgcolor', 'width', 'height', 'localtime', 'oneFigure', 'showprofile']
55
52 def __init__(self, **kwargs):
56 def __init__(self, **kwargs):
53
57
54 Operation.__init__(self, plot=True, **kwargs)
58 Operation.__init__(self, plot=True, **kwargs)
@@ -91,6 +95,7 class PlotData(Operation, Process):
91 self.colorbar = kwargs.get('colorbar', True)
95 self.colorbar = kwargs.get('colorbar', True)
92 self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1])
96 self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1])
93 self.titles = ['' for __ in range(16)]
97 self.titles = ['' for __ in range(16)]
98 self.polar = False
94
99
95 def __fmtTime(self, x, pos):
100 def __fmtTime(self, x, pos):
96 '''
101 '''
@@ -103,6 +108,10 class PlotData(Operation, Process):
103 Common setup for all figures, here figures and axes are created
108 Common setup for all figures, here figures and axes are created
104 '''
109 '''
105
110
111 if self.CODE not in self.data:
112 raise ValueError(log.error('Missing data for {}'.format(self.CODE),
113 self.name))
114
106 self.setup()
115 self.setup()
107
116
108 self.time_label = 'LT' if self.localtime else 'UTC'
117 self.time_label = 'LT' if self.localtime else 'UTC'
@@ -131,7 +140,8 class PlotData(Operation, Process):
131 facecolor='w')
140 facecolor='w')
132 self.figures.append(fig)
141 self.figures.append(fig)
133 for n in range(self.nplots):
142 for n in range(self.nplots):
134 ax = fig.add_subplot(self.nrows, self.ncols, n + 1)
143 ax = fig.add_subplot(self.nrows, self.ncols,
144 n + 1, polar=self.polar)
135 ax.tick_params(labelsize=8)
145 ax.tick_params(labelsize=8)
136 ax.firsttime = True
146 ax.firsttime = True
137 ax.index = 0
147 ax.index = 0
@@ -148,7 +158,7 class PlotData(Operation, Process):
148 fig = plt.figure(figsize=(self.width, self.height),
158 fig = plt.figure(figsize=(self.width, self.height),
149 edgecolor='k',
159 edgecolor='k',
150 facecolor='w')
160 facecolor='w')
151 ax = fig.add_subplot(1, 1, 1)
161 ax = fig.add_subplot(1, 1, 1, polar=self.polar)
152 ax.tick_params(labelsize=8)
162 ax.tick_params(labelsize=8)
153 ax.firsttime = True
163 ax.firsttime = True
154 ax.index = 0
164 ax.index = 0
@@ -348,7 +358,7 class PlotData(Operation, Process):
348 else:
358 else:
349 if self.xaxis is 'time':
359 if self.xaxis is 'time':
350 dt = self.getDateTime(self.max_time)
360 dt = self.getDateTime(self.max_time)
351 xmax = (dt.replace(hour=int(self.xmax), minute=0, second=0) -
361 xmax = (dt.replace(hour=int(self.xmax), minute=59, second=59) -
352 datetime.datetime(1970, 1, 1)).total_seconds()
362 datetime.datetime(1970, 1, 1)).total_seconds()
353 if self.data.localtime:
363 if self.data.localtime:
354 xmax += time.timezone
364 xmax += time.timezone
@@ -363,8 +373,6 class PlotData(Operation, Process):
363 0][0] < 0 else numpy.where(ymax < Y)[0][0]
373 0][0] < 0 else numpy.where(ymax < Y)[0][0]
364 ystep = Y[i - 1] / 5
374 ystep = Y[i - 1] / 5
365
375
366 ystep = 200 if ymax >= 800 else 100 if ymax >= 400 else 50 if ymax >= 200 else 20
367
368 for n, ax in enumerate(self.axes):
376 for n, ax in enumerate(self.axes):
369 if ax.firsttime:
377 if ax.firsttime:
370 ax.set_facecolor(self.bgcolor)
378 ax.set_facecolor(self.bgcolor)
@@ -384,7 +392,8 class PlotData(Operation, Process):
384 [tick.set_visible(False)
392 [tick.set_visible(False)
385 for tick in self.pf_axes[n].get_yticklabels()]
393 for tick in self.pf_axes[n].get_yticklabels()]
386 if self.colorbar:
394 if self.colorbar:
387 ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10)
395 ax.cbar = plt.colorbar(
396 ax.plt, ax=ax, fraction=0.05, pad=0.02, aspect=10)
388 ax.cbar.ax.tick_params(labelsize=8)
397 ax.cbar.ax.tick_params(labelsize=8)
389 ax.cbar.ax.press = None
398 ax.cbar.ax.press = None
390 if self.cb_label:
399 if self.cb_label:
@@ -394,13 +403,19 class PlotData(Operation, Process):
394 else:
403 else:
395 ax.cbar = None
404 ax.cbar = None
396
405
406 if not self.polar:
407 ax.set_xlim(xmin, xmax)
408 ax.set_ylim(ymin, ymax)
397 ax.set_title('{} - {} {}'.format(
409 ax.set_title('{} - {} {}'.format(
398 self.titles[n],
410 self.titles[n],
399 self.getDateTime(self.max_time).strftime('%H:%M:%S'),
411 self.getDateTime(self.max_time).strftime('%H:%M:%S'),
400 self.time_label),
412 self.time_label),
401 size=8)
413 size=8)
402 ax.set_xlim(xmin, xmax)
414 else:
403 ax.set_ylim(ymin, ymax)
415 ax.set_title('{}'.format(self.titles[n]), size=8)
416 ax.set_ylim(0, 90)
417 ax.set_yticks(numpy.arange(0, 90, 20))
418 ax.yaxis.labelpad = 40
404
419
405 def __plot(self):
420 def __plot(self):
406 '''
421 '''
@@ -413,6 +428,7 class PlotData(Operation, Process):
413 for n, fig in enumerate(self.figures):
428 for n, fig in enumerate(self.figures):
414 if self.nrows == 0 or self.nplots == 0:
429 if self.nrows == 0 or self.nplots == 0:
415 log.warning('No data', self.name)
430 log.warning('No data', self.name)
431 fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center')
416 continue
432 continue
417
433
418 fig.tight_layout()
434 fig.tight_layout()
@@ -437,7 +453,7 class PlotData(Operation, Process):
437 str(self.contador),
453 str(self.contador),
438 )
454 )
439 )
455 )
440 print 'Saving figure: {}'.format(figname)
456 log.log('Saving figure: {}'.format(figname), self.name)
441 fig.savefig(figname)
457 fig.savefig(figname)
442
458
443 def plot(self):
459 def plot(self):
@@ -820,7 +836,7 class PlotSkyMapData(PlotData):
820 Plot for meteors detection data
836 Plot for meteors detection data
821 '''
837 '''
822
838
823 CODE = 'met'
839 CODE = 'param'
824
840
825 def setup(self):
841 def setup(self):
826
842
@@ -828,25 +844,17 class PlotSkyMapData(PlotData):
828 self.nrows = 1
844 self.nrows = 1
829 self.width = 7.2
845 self.width = 7.2
830 self.height = 7.2
846 self.height = 7.2
831
847 self.nplots = 1
832 self.xlabel = 'Zonal Zenith Angle (deg)'
848 self.xlabel = 'Zonal Zenith Angle (deg)'
833 self.ylabel = 'Meridional Zenith Angle (deg)'
849 self.ylabel = 'Meridional Zenith Angle (deg)'
834
850 self.polar = True
835 if self.figure is None:
851 self.ymin = -180
836 self.figure = plt.figure(figsize=(self.width, self.height),
852 self.ymax = 180
837 edgecolor='k',
853 self.colorbar = False
838 facecolor='w')
839 else:
840 self.figure.clf()
841
842 self.ax = plt.subplot2grid(
843 (self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
844 self.ax.firsttime = True
845
854
846 def plot(self):
855 def plot(self):
847
856
848 arrayParameters = numpy.concatenate(
857 arrayParameters = numpy.concatenate(self.data['param'])
849 [self.data['param'][t] for t in self.times])
850 error = arrayParameters[:, -1]
858 error = arrayParameters[:, -1]
851 indValid = numpy.where(error == 0)[0]
859 indValid = numpy.where(error == 0)[0]
852 finalMeteor = arrayParameters[indValid, :]
860 finalMeteor = arrayParameters[indValid, :]
@@ -856,23 +864,19 class PlotSkyMapData(PlotData):
856 x = finalAzimuth * numpy.pi / 180
864 x = finalAzimuth * numpy.pi / 180
857 y = finalZenith
865 y = finalZenith
858
866
859 if self.ax.firsttime:
867 ax = self.axes[0]
860 self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0]
868
861 self.ax.set_ylim(0, 90)
869 if ax.firsttime:
862 self.ax.set_yticks(numpy.arange(0, 90, 20))
870 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
863 self.ax.set_xlabel(self.xlabel)
864 self.ax.set_ylabel(self.ylabel)
865 self.ax.yaxis.labelpad = 40
866 self.ax.firsttime = False
867 else:
871 else:
868 self.ax.plot.set_data(x, y)
872 ax.plot.set_data(x, y)
869
873
870 dt1 = self.getDateTime(self.min_time).strftime('%y/%m/%d %H:%M:%S')
874 dt1 = self.getDateTime(self.min_time).strftime('%y/%m/%d %H:%M:%S')
871 dt2 = self.getDateTime(self.max_time).strftime('%y/%m/%d %H:%M:%S')
875 dt2 = self.getDateTime(self.max_time).strftime('%y/%m/%d %H:%M:%S')
872 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
876 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
873 dt2,
877 dt2,
874 len(x))
878 len(x))
875 self.ax.set_title(title, size=8)
879 self.titles[0] = title
876 self.saveTime = self.max_time
880 self.saveTime = self.max_time
877
881
878
882
@@ -553,6 +553,9 class JRODataIO:
553 return dtype_width
553 return dtype_width
554
554
555 def getAllowedArgs(self):
555 def getAllowedArgs(self):
556 if hasattr(self, '__attrs__'):
557 return self.__attrs__
558 else:
556 return inspect.getargspec(self.run).args
559 return inspect.getargspec(self.run).args
557
560
558
561
@@ -514,9 +514,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa
514 self.profileIndex = 1 # Always
514 self.profileIndex = 1 # Always
515 self.dataOut.flagNoData = False
515 self.dataOut.flagNoData = False
516 self.dataOut.nRdPairs = 0
516 self.dataOut.nRdPairs = 0
517 self.dataOut.pairsList = []
518 self.dataOut.data_spc = None
517 self.dataOut.data_spc = None
519 self.dataOut.noise = []
520 self.dataOut.velocityX = []
518 self.dataOut.velocityX = []
521 self.dataOut.velocityY = []
519 self.dataOut.velocityY = []
522 self.dataOut.velocityV = []
520 self.dataOut.velocityV = []
@@ -495,16 +495,13 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
495 self.profileIndex = 1 # Always
495 self.profileIndex = 1 # Always
496 self.dataOut.flagNoData = False
496 self.dataOut.flagNoData = False
497 self.dataOut.nRdPairs = 0
497 self.dataOut.nRdPairs = 0
498 self.dataOut.pairsList = []
499 self.dataOut.data_spc = None
498 self.dataOut.data_spc = None
500
501 self.dataOut.normFactor = 1
502 self.nextfileflag = True
499 self.nextfileflag = True
503 self.dataOut.RadarConst = 0
500 self.dataOut.RadarConst = 0
504 self.dataOut.HSDV = []
501 self.dataOut.HSDV = []
505 self.dataOut.NPW = []
502 self.dataOut.NPW = []
506 self.dataOut.COFA = []
503 self.dataOut.COFA = []
507 self.dataOut.noise = 0
504 # self.dataOut.noise = 0
508
505
509 def Files2Read(self, fp):
506 def Files2Read(self, fp):
510 '''
507 '''
@@ -588,6 +585,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
588 self.dataOut.noise = self.dataOut.getNoise()
585 self.dataOut.noise = self.dataOut.getNoise()
589 # print 'ACAAAAAA', self.dataOut.noise
586 # print 'ACAAAAAA', self.dataOut.noise
590 self.dataOut.data_spc = self.dataOut.data_spc + self.dataOut.noise
587 self.dataOut.data_spc = self.dataOut.data_spc + self.dataOut.noise
588 self.dataOut.normFactor = 1
591 # print 'self.dataOut.noise',self.dataOut.noise
589 # print 'self.dataOut.noise',self.dataOut.noise
592
590
593 return self.dataOut.data_spc
591 return self.dataOut.data_spc
@@ -64,9 +64,16 class ProcessingUnit(object):
64
64
65 self.args = args
65 self.args = args
66 self.kwargs = kwargs
66 self.kwargs = kwargs
67
68 if not hasattr(self, 'name'):
69 self.name = self.__class__.__name__
70
67 checkKwargs(self.run, kwargs)
71 checkKwargs(self.run, kwargs)
68
72
69 def getAllowedArgs(self):
73 def getAllowedArgs(self):
74 if hasattr(self, '__attrs__'):
75 return self.__attrs__
76 else:
70 return inspect.getargspec(self.run).args
77 return inspect.getargspec(self.run).args
71
78
72 def addOperationKwargs(self, objId, **kwargs):
79 def addOperationKwargs(self, objId, **kwargs):
@@ -309,9 +316,14 class Operation(object):
309 self.__buffer = None
316 self.__buffer = None
310 self.isConfig = False
317 self.isConfig = False
311 self.kwargs = kwargs
318 self.kwargs = kwargs
319 if not hasattr(self, 'name'):
320 self.name = self.__class__.__name__
312 checkKwargs(self.run, kwargs)
321 checkKwargs(self.run, kwargs)
313
322
314 def getAllowedArgs(self):
323 def getAllowedArgs(self):
324 if hasattr(self, '__attrs__'):
325 return self.__attrs__
326 else:
315 return inspect.getargspec(self.run).args
327 return inspect.getargspec(self.run).args
316
328
317 def setup(self):
329 def setup(self):
@@ -1408,18 +1408,18 class SpectralMoments(Operation):
1408 def __calculateMoments(self, oldspec, oldfreq, n0,
1408 def __calculateMoments(self, oldspec, oldfreq, n0,
1409 nicoh = None, graph = None, smooth = None, type1 = None, fwindow = None, snrth = None, dc = None, aliasing = None, oldfd = None, wwauto = None):
1409 nicoh = None, graph = None, smooth = None, type1 = None, fwindow = None, snrth = None, dc = None, aliasing = None, oldfd = None, wwauto = None):
1410
1410
1411 if (nicoh == None): nicoh = 1
1411 if (nicoh is None): nicoh = 1
1412 if (graph == None): graph = 0
1412 if (graph is None): graph = 0
1413 if (smooth == None): smooth = 0
1413 if (smooth is None): smooth = 0
1414 elif (self.smooth < 3): smooth = 0
1414 elif (self.smooth < 3): smooth = 0
1415
1415
1416 if (type1 == None): type1 = 0
1416 if (type1 is None): type1 = 0
1417 if (fwindow == None): fwindow = numpy.zeros(oldfreq.size) + 1
1417 if (fwindow is None): fwindow = numpy.zeros(oldfreq.size) + 1
1418 if (snrth == None): snrth = -3
1418 if (snrth is None): snrth = -3
1419 if (dc == None): dc = 0
1419 if (dc is None): dc = 0
1420 if (aliasing == None): aliasing = 0
1420 if (aliasing is None): aliasing = 0
1421 if (oldfd == None): oldfd = 0
1421 if (oldfd is None): oldfd = 0
1422 if (wwauto == None): wwauto = 0
1422 if (wwauto is None): wwauto = 0
1423
1423
1424 if (n0 < 1.e-20): n0 = 1.e-20
1424 if (n0 < 1.e-20): n0 = 1.e-20
1425
1425
@@ -1719,7 +1719,7 class SpectralFitting(Operation):
1719 error1 = p0*numpy.nan
1719 error1 = p0*numpy.nan
1720
1720
1721 #Save
1721 #Save
1722 if self.dataOut.data_param == None:
1722 if self.dataOut.data_param is None:
1723 self.dataOut.data_param = numpy.zeros((nGroups, p0.size, nHeights))*numpy.nan
1723 self.dataOut.data_param = numpy.zeros((nGroups, p0.size, nHeights))*numpy.nan
1724 self.dataOut.data_error = numpy.zeros((nGroups, p0.size + 1, nHeights))*numpy.nan
1724 self.dataOut.data_error = numpy.zeros((nGroups, p0.size + 1, nHeights))*numpy.nan
1725
1725
@@ -2382,7 +2382,7 class WindProfiler(Operation):
2382
2382
2383 self.__isConfig = True
2383 self.__isConfig = True
2384
2384
2385 if self.__buffer == None:
2385 if self.__buffer is None:
2386 self.__buffer = dataOut.data_param
2386 self.__buffer = dataOut.data_param
2387 self.__firstdata = copy.copy(dataOut)
2387 self.__firstdata = copy.copy(dataOut)
2388
2388
@@ -2424,7 +2424,7 class WindProfiler(Operation):
2424 else: mode = 'SA'
2424 else: mode = 'SA'
2425
2425
2426 #Borrar luego esto
2426 #Borrar luego esto
2427 if dataOut.groupList == None:
2427 if dataOut.groupList is None:
2428 dataOut.groupList = [(0,1),(0,2),(1,2)]
2428 dataOut.groupList = [(0,1),(0,2),(1,2)]
2429 groupList = dataOut.groupList
2429 groupList = dataOut.groupList
2430 C = 3e8
2430 C = 3e8
@@ -2446,7 +2446,7 class WindProfiler(Operation):
2446
2446
2447 self.__isConfig = True
2447 self.__isConfig = True
2448
2448
2449 if self.__buffer == None:
2449 if self.__buffer is None:
2450 self.__buffer = dataOut.data_param
2450 self.__buffer = dataOut.data_param
2451 self.__firstdata = copy.copy(dataOut)
2451 self.__firstdata = copy.copy(dataOut)
2452
2452
@@ -2808,7 +2808,7 class SMDetection(Operation):
2808
2808
2809
2809
2810 #Getting Pairslist
2810 #Getting Pairslist
2811 if channelPositions == None:
2811 if channelPositions is None:
2812 # channelPositions = [(2.5,0), (0,2.5), (0,0), (0,4.5), (-2,0)] #T
2812 # channelPositions = [(2.5,0), (0,2.5), (0,0), (0,4.5), (-2,0)] #T
2813 channelPositions = [(4.5,2), (2,4.5), (2,2), (2,0), (0,2)] #Estrella
2813 channelPositions = [(4.5,2), (2,4.5), (2,2), (2,0), (0,2)] #Estrella
2814 meteorOps = SMOperations()
2814 meteorOps = SMOperations()
@@ -2939,7 +2939,7 class SMDetection(Operation):
2939 # arrayFinal = arrayParameters.reshape((1,arrayParameters.shape[0],arrayParameters.shape[1]))
2939 # arrayFinal = arrayParameters.reshape((1,arrayParameters.shape[0],arrayParameters.shape[1]))
2940 dataOut.data_param = arrayParameters
2940 dataOut.data_param = arrayParameters
2941
2941
2942 if arrayParameters == None:
2942 if arrayParameters is None:
2943 dataOut.flagNoData = True
2943 dataOut.flagNoData = True
2944 else:
2944 else:
2945 dataOut.flagNoData = True
2945 dataOut.flagNoData = True
@@ -3475,7 +3475,7 class CorrectSMPhases(Operation):
3475 arrayParameters[:,8:12] = numpy.angle(numpy.exp(1j*(arrayParameters[:,8:12] + phaseOffsets)))
3475 arrayParameters[:,8:12] = numpy.angle(numpy.exp(1j*(arrayParameters[:,8:12] + phaseOffsets)))
3476
3476
3477 meteorOps = SMOperations()
3477 meteorOps = SMOperations()
3478 if channelPositions == None:
3478 if channelPositions is None:
3479 # channelPositions = [(2.5,0), (0,2.5), (0,0), (0,4.5), (-2,0)] #T
3479 # channelPositions = [(2.5,0), (0,2.5), (0,0), (0,4.5), (-2,0)] #T
3480 channelPositions = [(4.5,2), (2,4.5), (2,2), (2,0), (0,2)] #Estrella
3480 channelPositions = [(4.5,2), (2,4.5), (2,2), (2,0), (0,2)] #Estrella
3481
3481
@@ -3652,7 +3652,7 class SMPhaseCalibration(Operation):
3652
3652
3653 self.__isConfig = True
3653 self.__isConfig = True
3654
3654
3655 if self.__buffer == None:
3655 if self.__buffer is None:
3656 self.__buffer = dataOut.data_param.copy()
3656 self.__buffer = dataOut.data_param.copy()
3657
3657
3658 else:
3658 else:
@@ -60,6 +60,11 class throttle(object):
60 def __call__(self, fn):
60 def __call__(self, fn):
61 @wraps(fn)
61 @wraps(fn)
62 def wrapper(*args, **kwargs):
62 def wrapper(*args, **kwargs):
63 coerce = kwargs.pop('coerce', None)
64 if coerce:
65 self.time_of_last_call = datetime.datetime.now()
66 return fn(*args, **kwargs)
67 else:
63 now = datetime.datetime.now()
68 now = datetime.datetime.now()
64 time_since_last_call = now - self.time_of_last_call
69 time_since_last_call = now - self.time_of_last_call
65 time_left = self.throttle_period - time_since_last_call
70 time_left = self.throttle_period - time_since_last_call
@@ -104,6 +109,9 class Data(object):
104 ret = numpy.swapaxes(ret, 0, 1)
109 ret = numpy.swapaxes(ret, 0, 1)
105 return ret
110 return ret
106
111
112 def __contains__(self, key):
113 return key in self.data
114
107 def setup(self):
115 def setup(self):
108 '''
116 '''
109 Configure object
117 Configure object
@@ -242,6 +250,8 class PublishData(Operation):
242 Operation to send data over zmq.
250 Operation to send data over zmq.
243 '''
251 '''
244
252
253 __attrs__ = ['host', 'port', 'delay', 'zeromq', 'mqtt', 'verbose']
254
245 def __init__(self, **kwargs):
255 def __init__(self, **kwargs):
246 """Inicio."""
256 """Inicio."""
247 Operation.__init__(self, **kwargs)
257 Operation.__init__(self, **kwargs)
@@ -426,6 +436,8 class PublishData(Operation):
426
436
427 class ReceiverData(ProcessingUnit):
437 class ReceiverData(ProcessingUnit):
428
438
439 __attrs__ = ['server']
440
429 def __init__(self, **kwargs):
441 def __init__(self, **kwargs):
430
442
431 ProcessingUnit.__init__(self, **kwargs)
443 ProcessingUnit.__init__(self, **kwargs)
@@ -464,6 +476,7 class ReceiverData(ProcessingUnit):
464 class PlotterReceiver(ProcessingUnit, Process):
476 class PlotterReceiver(ProcessingUnit, Process):
465
477
466 throttle_value = 5
478 throttle_value = 5
479 __attrs__ = ['server', 'plottypes', 'realtime', 'localtime', 'throttle']
467
480
468 def __init__(self, **kwargs):
481 def __init__(self, **kwargs):
469
482
@@ -564,6 +577,10 class PlotterReceiver(ProcessingUnit, Process):
564
577
565 while True:
578 while True:
566 dataOut = self.receiver.recv_pyobj()
579 dataOut = self.receiver.recv_pyobj()
580 if not dataOut.flagNoData:
581 if dataOut.type == 'Parameters':
582 tm = dataOut.utctimeInit
583 else:
567 tm = dataOut.utctime
584 tm = dataOut.utctime
568 if dataOut.useLocalTime:
585 if dataOut.useLocalTime:
569 if not self.localtime:
586 if not self.localtime:
@@ -573,12 +590,12 class PlotterReceiver(ProcessingUnit, Process):
573 if self.localtime:
590 if self.localtime:
574 tm -= time.timezone
591 tm -= time.timezone
575 dt = datetime.datetime.utcfromtimestamp(tm).date()
592 dt = datetime.datetime.utcfromtimestamp(tm).date()
576 sended = False
593 coerce = False
577 if dt not in self.dates:
594 if dt not in self.dates:
578 if self.data:
595 if self.data:
579 self.data.ended = True
596 self.data.ended = True
580 self.send(self.data)
597 self.send(self.data)
581 sended = True
598 coerce = True
582 self.data.setup()
599 self.data.setup()
583 self.dates.append(dt)
600 self.dates.append(dt)
584
601
@@ -595,8 +612,8 class PlotterReceiver(ProcessingUnit, Process):
595 self.send(self.data)
612 self.send(self.data)
596 # self.sender_web.send_string(self.data.jsonify())
613 # self.sender_web.send_string(self.data.jsonify())
597 else:
614 else:
598 if not sended:
615 self.sendData(self.send, self.data, coerce=coerce)
599 self.sendData(self.send, self.data)
616 coerce = False
600
617
601 return
618 return
602
619
@@ -1,6 +1,5
1 import schainpy
1 import schainpy
2 from schainpy.model import Operation, ProcessingUnit
2 from schainpy.model import Operation, ProcessingUnit
3 from importlib import import_module
4 from pydoc import locate
3 from pydoc import locate
5
4
6 def clean_modules(module):
5 def clean_modules(module):
@@ -21,7 +20,7 def check_module(possible, instance):
21
20
22
21
23 def getProcs():
22 def getProcs():
24 module = dir(import_module('schainpy.model'))
23 module = dir(schainpy.model)
25 procs = check_module(module, ProcessingUnit)
24 procs = check_module(module, ProcessingUnit)
26 try:
25 try:
27 procs.remove('ProcessingUnit')
26 procs.remove('ProcessingUnit')
@@ -30,7 +29,7 def getProcs():
30 return procs
29 return procs
31
30
32 def getOperations():
31 def getOperations():
33 module = dir(import_module('schainpy.model'))
32 module = dir(schainpy.model)
34 noProcs = [x for x in module if not x.endswith('Proc')]
33 noProcs = [x for x in module if not x.endswith('Proc')]
35 operations = check_module(noProcs, Operation)
34 operations = check_module(noProcs, Operation)
36 try:
35 try:
@@ -53,7 +52,7 def getArgs(op):
53 return args
52 return args
54
53
55 def getAll():
54 def getAll():
56 allModules = dir(import_module('schainpy.model'))
55 allModules = dir(schainpy.model)
57 modules = check_module(allModules, Operation)
56 modules = check_module(allModules, Operation)
58 modules.extend(check_module(allModules, ProcessingUnit))
57 modules.extend(check_module(allModules, ProcessingUnit))
59 return modules
58 return modules
General Comments 0
You need to be logged in to leave comments. Login now