diff --git a/schainpy/controller.py b/schainpy/controller.py index 1d4530a..3cf2b23 100644 --- a/schainpy/controller.py +++ b/schainpy/controller.py @@ -26,7 +26,7 @@ def prettify(elem): reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=" ") -def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, receiver=None): +def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False): skip = 0 cursor = 0 nFiles = None @@ -35,7 +35,7 @@ def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d') dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d') days = (dt2 - dt1).days - print days + for day in range(days+1): skip = 0 cursor = 0 @@ -44,6 +44,8 @@ def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d') firstProcess = Process(target=child, args=(cursor, skip, q, dt)) firstProcess.start() + if by_day: + continue nFiles = q.get() firstProcess.terminate() skip = int(math.ceil(nFiles/nProcess)) @@ -438,8 +440,8 @@ class OperationConf(): def createObject(self, plotter_queue=None): - - if self.type == 'self': + + if self.type == 'self': raise ValueError, "This operation type cannot be created" if self.type == 'plotter': @@ -450,10 +452,10 @@ class OperationConf(): opObj = Plotter(self.name, plotter_queue) if self.type == 'external' or self.type == 'other': - + className = eval(self.name) kwargs = self.getKwargs() - + opObj = className(**kwargs) return opObj @@ -672,18 +674,18 @@ class ProcUnitConf(): kwargs = self.getKwargs() procUnitObj = className(**kwargs) - for opConfObj in self.opConfObjList: - + for opConfObj in self.opConfObjList: + if opConfObj.type=='self' and self.name=='run': continue - elif opConfObj.type=='self': + elif opConfObj.type=='self': procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs()) continue opObj = opConfObj.createObject(plotter_queue) self.opObjDict[opConfObj.id] = opObj - + procUnitObj.addOperation(opObj, opConfObj.id) self.procUnitObj = procUnitObj diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index cbc1d99..e936f6b 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -1162,7 +1162,7 @@ class Parameters(Spectra): abscissaList = None #Abscissa, can be velocities, lags or time - #noise = None #Noise Potency +# noise = None #Noise Potency utctimeInit = None #Initial UTC time @@ -1216,3 +1216,7 @@ class Parameters(Spectra): datatime = numpy.array(datatime) return datatime + + def getTimeInterval(self): + + return self.paramInterval diff --git a/schainpy/model/graphics/jroplot_data.py b/schainpy/model/graphics/jroplot_data.py index b5663d6..8cfbde5 100644 --- a/schainpy/model/graphics/jroplot_data.py +++ b/schainpy/model/graphics/jroplot_data.py @@ -325,7 +325,7 @@ class PlotCrossSpectraData(PlotData): ax.set_xlim(self.xmin, self.xmax) ax.set_ylim(self.ymin, self.ymax) - + ax.set_ylabel(self.ylabel) ax.set_xlabel(xlabel) ax.firsttime = False @@ -590,6 +590,92 @@ class PlotNoiseData(PlotData): self.saveTime = self.min_time +class PlotWindProfilerData(PlotRTIData): + CODE = 'wind' + colormap = 'seismic' + + def setup(self): + self.ncols = 1 + self.nrows = self.dataOut.data_output.shape[0] + self.width = 10 + self.height = 2.2*self.nrows + self.ylabel = 'Height [Km]' + self.titles = ['Zonal' ,'Meridional', 'Vertical'] + self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] + self.windFactor = [1, 1, 100] + + if self.figure is None: + self.figure = plt.figure(figsize=(self.width, self.height), + edgecolor='k', + facecolor='w') + else: + self.figure.clf() + self.axes = [] + + for n in range(self.nrows): + ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) + ax.firsttime = True + self.axes.append(ax) + + def plot(self): + + self.x = np.array(self.times) + self.y = self.dataOut.heightList + self.z = [] + + for ch in range(self.nrows): + self.z.append([self.data[self.CODE][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.) + + for n, ax in enumerate(self.axes): + x, y, z = self.fill_gaps(*self.decimate()) + xmin = self.min_time + xmax = xmin+self.xrange*60*60 + if ax.firsttime: + self.ymin = self.ymin if self.ymin else np.nanmin(self.y) + self.ymax = self.ymax if self.ymax else np.nanmax(self.y) + self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :])) + self.zmin = self.zmin if self.zmin else -self.zmax + + plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n], + vmin=self.zmin, + vmax=self.zmax, + cmap=cmap + ) + 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) + ax.set_ylim(self.ymin, self.ymax) + + ax.xaxis.set_major_formatter(FuncFormatter(func)) + ax.xaxis.set_major_locator(LinearLocator(6)) + + ax.set_ylabel(self.ylabel) + + ax.set_xlim(xmin, xmax) + ax.firsttime = False + else: + ax.collections.remove(ax.collections[0]) + ax.set_xlim(xmin, xmax) + plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n], + vmin=self.zmin, + vmax=self.zmax, + cmap=plt.get_cmap(self.colormap) + ) + ax.set_title('{} {}'.format(self.titles[n], + datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), + size=8) + + self.saveTime = self.min_time + + class PlotSNRData(PlotRTIData): CODE = 'snr' colormap = 'jet' diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index be91dc7..2bd7970 100644 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -1043,7 +1043,7 @@ class WindProfiler(Operation): param = dataOut.data_param if dataOut.abscissaList != None: absc = dataOut.abscissaList[:-1] - noise = dataOut.noise + #noise = dataOut.noise heightList = dataOut.heightList SNR = dataOut.data_SNR diff --git a/schainpy/model/utils/jroutils_publish.py b/schainpy/model/utils/jroutils_publish.py index aeef17c..68620aa 100644 --- a/schainpy/model/utils/jroutils_publish.py +++ b/schainpy/model/utils/jroutils_publish.py @@ -245,7 +245,7 @@ class PublishData(Operation): def close(self): if self.zeromq is 1: self.dataOut.finished = True - self.zmq_socket.send_pyobj(self.dataOut) + # self.zmq_socket.send_pyobj(self.dataOut) CHECK IT!!! if self.client: self.client.loop_stop() @@ -314,7 +314,7 @@ class ReceiverData(ProcessingUnit, Process): pass if self.connections == 0 and self.started is True: self.ended = True - # send('ENDED') + evt.update({'description': events[evt['event']]}) if evt['event'] == zmq.EVENT_MONITOR_STOPPED: @@ -335,9 +335,15 @@ class ReceiverData(ProcessingUnit, Process): self.sender.send_pyobj(data) def update(self): + t = self.dataOut.utctime + + if t in self.data['times']: + return + self.data['times'].append(t) self.data['dataOut'] = self.dataOut + for plottype in self.plottypes: if plottype == 'spc': z = self.dataOut.data_spc/self.dataOut.normFactor @@ -361,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': + self.data[plottype][t] = self.dataOut.data_output if self.realtime: - self.data_web['timestamp'] = t + self.data_web['timestamp'] = t if plottype == 'spc': self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist()) elif plottype == 'cspc':