##// END OF EJS Templates
Merge branch 'schain_mp' of http://jro-dev.igp.gob.pe/rhodecode/schain into schain_mp
José Chávez -
r926:29cb7ad6679f merge
parent child
Show More
@@ -26,7 +26,7 def prettify(elem):
26 26 reparsed = minidom.parseString(rough_string)
27 27 return reparsed.toprettyxml(indent=" ")
28 28
29 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, receiver=None):
29 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False):
30 30 skip = 0
31 31 cursor = 0
32 32 nFiles = None
@@ -38,7 +38,7 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei
38 38 dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d')
39 39 dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d')
40 40 days = (dt2 - dt1).days
41 print days
41
42 42 for day in range(days+1):
43 43 skip = 0
44 44 cursor = 0
@@ -47,6 +47,8 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei
47 47 dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d')
48 48 firstProcess = Process(target=child, args=(cursor, skip, q, dt))
49 49 firstProcess.start()
50 if by_day:
51 continue
50 52 nFiles = q.get()
51 53 firstProcess.terminate()
52 54 skip = int(math.ceil(nFiles/nProcess))
@@ -1162,7 +1162,7 class Parameters(Spectra):
1162 1162
1163 1163 abscissaList = None #Abscissa, can be velocities, lags or time
1164 1164
1165 #noise = None #Noise Potency
1165 # noise = None #Noise Potency
1166 1166
1167 1167 utctimeInit = None #Initial UTC time
1168 1168
@@ -1216,3 +1216,7 class Parameters(Spectra):
1216 1216 datatime = numpy.array(datatime)
1217 1217
1218 1218 return datatime
1219
1220 def getTimeInterval(self):
1221
1222 return self.paramInterval
@@ -325,7 +325,7 class PlotCrossSpectraData(PlotData):
325 325
326 326 ax.set_xlim(self.xmin, self.xmax)
327 327 ax.set_ylim(self.ymin, self.ymax)
328
328
329 329 ax.set_ylabel(self.ylabel)
330 330 ax.set_xlabel(xlabel)
331 331 ax.firsttime = False
@@ -590,6 +590,92 class PlotNoiseData(PlotData):
590 590 self.saveTime = self.min_time
591 591
592 592
593 class PlotWindProfilerData(PlotRTIData):
594 CODE = 'wind'
595 colormap = 'seismic'
596
597 def setup(self):
598 self.ncols = 1
599 self.nrows = self.dataOut.data_output.shape[0]
600 self.width = 10
601 self.height = 2.2*self.nrows
602 self.ylabel = 'Height [Km]'
603 self.titles = ['Zonal' ,'Meridional', 'Vertical']
604 self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
605 self.windFactor = [1, 1, 100]
606
607 if self.figure is None:
608 self.figure = plt.figure(figsize=(self.width, self.height),
609 edgecolor='k',
610 facecolor='w')
611 else:
612 self.figure.clf()
613 self.axes = []
614
615 for n in range(self.nrows):
616 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
617 ax.firsttime = True
618 self.axes.append(ax)
619
620 def plot(self):
621
622 self.x = np.array(self.times)
623 self.y = self.dataOut.heightList
624 self.z = []
625
626 for ch in range(self.nrows):
627 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
628
629 self.z = np.array(self.z)
630 self.z = numpy.ma.masked_invalid(self.z)
631
632 cmap=plt.get_cmap(self.colormap)
633 cmap.set_bad('white', 1.)
634
635 for n, ax in enumerate(self.axes):
636 x, y, z = self.fill_gaps(*self.decimate())
637 xmin = self.min_time
638 xmax = xmin+self.xrange*60*60
639 if ax.firsttime:
640 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
641 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
642 self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :]))
643 self.zmin = self.zmin if self.zmin else -self.zmax
644
645 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
646 vmin=self.zmin,
647 vmax=self.zmax,
648 cmap=cmap
649 )
650 divider = make_axes_locatable(ax)
651 cax = divider.new_horizontal(size='2%', pad=0.05)
652 cax.set_ylabel(self.clabels[n])
653 self.figure.add_axes(cax)
654 plt.colorbar(plot, cax)
655 ax.set_ylim(self.ymin, self.ymax)
656
657 ax.xaxis.set_major_formatter(FuncFormatter(func))
658 ax.xaxis.set_major_locator(LinearLocator(6))
659
660 ax.set_ylabel(self.ylabel)
661
662 ax.set_xlim(xmin, xmax)
663 ax.firsttime = False
664 else:
665 ax.collections.remove(ax.collections[0])
666 ax.set_xlim(xmin, xmax)
667 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
668 vmin=self.zmin,
669 vmax=self.zmax,
670 cmap=plt.get_cmap(self.colormap)
671 )
672 ax.set_title('{} {}'.format(self.titles[n],
673 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
674 size=8)
675
676 self.saveTime = self.min_time
677
678
593 679 class PlotSNRData(PlotRTIData):
594 680 CODE = 'snr'
595 681 colormap = 'jet'
@@ -1043,7 +1043,7 class WindProfiler(Operation):
1043 1043 param = dataOut.data_param
1044 1044 if dataOut.abscissaList != None:
1045 1045 absc = dataOut.abscissaList[:-1]
1046 noise = dataOut.noise
1046 #noise = dataOut.noise
1047 1047 heightList = dataOut.heightList
1048 1048 SNR = dataOut.data_SNR
1049 1049
@@ -245,7 +245,7 class PublishData(Operation):
245 245 def close(self):
246 246 if self.zeromq is 1:
247 247 self.dataOut.finished = True
248 self.zmq_socket.send_pyobj(self.dataOut)
248 # self.zmq_socket.send_pyobj(self.dataOut) CHECK IT!!!
249 249
250 250 if self.client:
251 251 self.client.loop_stop()
@@ -314,7 +314,7 class ReceiverData(ProcessingUnit, Process):
314 314 pass
315 315 if self.connections == 0 and self.started is True:
316 316 self.ended = True
317 # send('ENDED')
317
318 318 evt.update({'description': events[evt['event']]})
319 319
320 320 if evt['event'] == zmq.EVENT_MONITOR_STOPPED:
@@ -335,9 +335,15 class ReceiverData(ProcessingUnit, Process):
335 335 self.sender.send_pyobj(data)
336 336
337 337 def update(self):
338
338 339 t = self.dataOut.utctime
340
341 if t in self.data['times']:
342 return
343
339 344 self.data['times'].append(t)
340 345 self.data['dataOut'] = self.dataOut
346
341 347 for plottype in self.plottypes:
342 348 if plottype == 'spc':
343 349 z = self.dataOut.data_spc/self.dataOut.normFactor
@@ -361,8 +367,10 class ReceiverData(ProcessingUnit, Process):
361 367 self.data[plottype][t] = self.dataOut.getCoherence()
362 368 if plottype == 'phase':
363 369 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
370 if plottype == 'wind':
371 self.data[plottype][t] = self.dataOut.data_output
364 372 if self.realtime:
365 self.data_web['timestamp'] = t
373 self.data_web['timestamp'] = t
366 374 if plottype == 'spc':
367 375 self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist())
368 376 elif plottype == 'cspc':
General Comments 0
You need to be logged in to leave comments. Login now