diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index b862970..164984d 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -1216,7 +1216,10 @@ class Parameters(Spectra): def getTimeInterval(self): - return self.timeInterval1 + if hasattr(self, 'timeInterval1'): + return self.timeInterval1 + else: + return self.paramInterval def getNoise(self): diff --git a/schainpy/model/graphics/jroplot_data.py b/schainpy/model/graphics/jroplot_data.py index 72074c7..b9661b3 100644 --- a/schainpy/model/graphics/jroplot_data.py +++ b/schainpy/model/graphics/jroplot_data.py @@ -92,13 +92,12 @@ class PlotData(Operation, Process): print 'plotting...{}'.format(self.CODE) if self.show: - print 'showing' self.figure.show() self.plot() plt.tight_layout() - self.figure.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(), - datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) + self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), + datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) if self.save: figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, @@ -116,11 +115,15 @@ class PlotData(Operation, Process): def run(self): print '[Starting] {}'.format(self.name) + context = zmq.Context() receiver = context.socket(zmq.SUB) receiver.setsockopt(zmq.SUBSCRIBE, '') receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) - receiver.connect("ipc:///tmp/zmq.plots") + if 'server' in self.kwargs['parent']: + receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) + else: + receiver.connect("ipc:///tmp/zmq.plots") while True: try: @@ -594,6 +597,7 @@ class PlotNoiseData(PlotData): class PlotWindProfilerData(PlotRTIData): + CODE = 'wind' colormap = 'seismic' @@ -603,7 +607,7 @@ class PlotWindProfilerData(PlotRTIData): self.width = 10 self.height = 2.2*self.nrows self.ylabel = 'Height [Km]' - self.titles = ['Zonal' ,'Meridional', 'Vertical'] + self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind'] self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] self.windFactor = [1, 1, 100] @@ -627,13 +631,13 @@ class PlotWindProfilerData(PlotRTIData): self.z = [] for ch in range(self.nrows): - self.z.append([self.data[self.CODE][t][ch] for t in self.times]) + self.z.append([self.data['output'][t][ch] for t in self.times]) self.z = np.array(self.z) self.z = numpy.ma.masked_invalid(self.z) cmap=plt.get_cmap(self.colormap) - cmap.set_bad('white', 1.) + cmap.set_bad('black', 1.) for n, ax in enumerate(self.axes): x, y, z = self.fill_gaps(*self.decimate()) @@ -652,9 +656,9 @@ class PlotWindProfilerData(PlotRTIData): ) divider = make_axes_locatable(ax) cax = divider.new_horizontal(size='2%', pad=0.05) - cax.set_ylabel(self.clabels[n]) self.figure.add_axes(cax) - plt.colorbar(plot, cax) + cb = plt.colorbar(plot, cax) + cb.set_label(self.clabels[n]) ax.set_ylim(self.ymin, self.ymax) ax.xaxis.set_major_formatter(FuncFormatter(func)) @@ -691,3 +695,62 @@ class PlotDOPData(PlotRTIData): class PlotPHASEData(PlotCOHData): CODE = 'phase' colormap = 'seismic' + + +class PlotSkyMapData(PlotData): + + CODE = 'met' + + def setup(self): + + self.ncols = 1 + self.nrows = 1 + self.width = 7.2 + self.height = 7.2 + + self.xlabel = 'Zonal Zenith Angle (deg)' + self.ylabel = 'Meridional Zenith Angle (deg)' + + if self.figure is None: + self.figure = plt.figure(figsize=(self.width, self.height), + edgecolor='k', + facecolor='w') + else: + self.figure.clf() + + self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True) + self.ax.firsttime = True + + + def plot(self): + + arrayParameters = np.concatenate([self.data['param'][t] for t in self.times]) + error = arrayParameters[:,-1] + indValid = numpy.where(error == 0)[0] + finalMeteor = arrayParameters[indValid,:] + finalAzimuth = finalMeteor[:,3] + finalZenith = finalMeteor[:,4] + + x = finalAzimuth*numpy.pi/180 + y = finalZenith + + if self.ax.firsttime: + self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] + self.ax.set_ylim(0,90) + self.ax.set_yticks(numpy.arange(0,90,20)) + self.ax.set_xlabel(self.xlabel) + self.ax.set_ylabel(self.ylabel) + self.ax.yaxis.labelpad = 40 + self.ax.firsttime = False + else: + self.ax.plot.set_data(x, y) + + + dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') + dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') + title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, + dt2, + len(x)) + self.ax.set_title(title, size=8) + + self.saveTime = self.max_time diff --git a/schainpy/model/proc/jroproc_base.py b/schainpy/model/proc/jroproc_base.py index 08e6beb..6ec501c 100644 --- a/schainpy/model/proc/jroproc_base.py +++ b/schainpy/model/proc/jroproc_base.py @@ -121,12 +121,13 @@ class ProcessingUnit(object): if self.mp is False: self.mp = True self.start() - else: + else: + self.operationKwargs[opId]['parent'] = self.kwargs methodToCall(**self.operationKwargs[opId]) else: if name=='run': methodToCall(**self.kwargs) - else: + else: methodToCall(**self.operationKwargs[opId]) if self.dataOut is None: @@ -160,12 +161,14 @@ class ProcessingUnit(object): if hasattr(externalProcObj, 'mp'): if externalProcObj.mp is False: + externalProcObj.kwargs['parent'] = self.kwargs self.operationKwargs[objId] = externalProcObj.kwargs externalProcObj.mp = True externalProcObj.start() else: externalProcObj.run(self.dataOut, **externalProcObj.kwargs) self.operationKwargs[objId] = externalProcObj.kwargs + return True diff --git a/schainpy/model/utils/jroutils_publish.py b/schainpy/model/utils/jroutils_publish.py index b9a5d70..f33d6f9 100644 --- a/schainpy/model/utils/jroutils_publish.py +++ b/schainpy/model/utils/jroutils_publish.py @@ -367,8 +367,10 @@ class ReceiverData(ProcessingUnit, Process): self.data[plottype][t] = self.dataOut.getCoherence() if plottype == 'phase': self.data[plottype][t] = self.dataOut.getCoherence(phase=True) - if plottype == 'wind': + if plottype == 'output': self.data[plottype][t] = self.dataOut.data_output + if plottype == 'param': + self.data[plottype][t] = self.dataOut.data_param if self.realtime: self.data_web['timestamp'] = t if plottype == 'spc': @@ -396,7 +398,10 @@ class ReceiverData(ProcessingUnit, Process): self.sender_web = self.context.socket(zmq.PUB) self.sender_web.connect(self.plot_address) time.sleep(1) - self.sender.bind("ipc:///tmp/zmq.plots") + if 'server' in self.kwargs: + self.sender.bind("ipc:///tmp/{}.plots".format(self.kwargs['server'])) + else: + self.sender.bind("ipc:///tmp/zmq.plots") t = Thread(target=self.event_monitor, args=(monitor,)) t.start()