@@ -26,7 +26,7 def prettify(elem): | |||||
26 | reparsed = minidom.parseString(rough_string) |
|
26 | reparsed = minidom.parseString(rough_string) | |
27 | return reparsed.toprettyxml(indent=" ") |
|
27 | return reparsed.toprettyxml(indent=" ") | |
28 |
|
28 | |||
29 |
def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, |
|
29 | def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False): | |
30 | skip = 0 |
|
30 | skip = 0 | |
31 | cursor = 0 |
|
31 | cursor = 0 | |
32 | nFiles = None |
|
32 | nFiles = None | |
@@ -35,7 +35,7 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei | |||||
35 | dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d') |
|
35 | dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d') | |
36 | dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d') |
|
36 | dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d') | |
37 | days = (dt2 - dt1).days |
|
37 | days = (dt2 - dt1).days | |
38 | print days |
|
38 | ||
39 | for day in range(days+1): |
|
39 | for day in range(days+1): | |
40 | skip = 0 |
|
40 | skip = 0 | |
41 | cursor = 0 |
|
41 | cursor = 0 | |
@@ -44,6 +44,8 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei | |||||
44 | dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d') |
|
44 | dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d') | |
45 | firstProcess = Process(target=child, args=(cursor, skip, q, dt)) |
|
45 | firstProcess = Process(target=child, args=(cursor, skip, q, dt)) | |
46 | firstProcess.start() |
|
46 | firstProcess.start() | |
|
47 | if by_day: | |||
|
48 | continue | |||
47 | nFiles = q.get() |
|
49 | nFiles = q.get() | |
48 | firstProcess.terminate() |
|
50 | firstProcess.terminate() | |
49 | skip = int(math.ceil(nFiles/nProcess)) |
|
51 | skip = int(math.ceil(nFiles/nProcess)) | |
@@ -438,8 +440,8 class OperationConf(): | |||||
438 |
|
440 | |||
439 | def createObject(self, plotter_queue=None): |
|
441 | def createObject(self, plotter_queue=None): | |
440 |
|
442 | |||
441 |
|
443 | |||
442 |
if self.type == 'self': |
|
444 | if self.type == 'self': | |
443 | raise ValueError, "This operation type cannot be created" |
|
445 | raise ValueError, "This operation type cannot be created" | |
444 |
|
446 | |||
445 | if self.type == 'plotter': |
|
447 | if self.type == 'plotter': | |
@@ -450,10 +452,10 class OperationConf(): | |||||
450 | opObj = Plotter(self.name, plotter_queue) |
|
452 | opObj = Plotter(self.name, plotter_queue) | |
451 |
|
453 | |||
452 | if self.type == 'external' or self.type == 'other': |
|
454 | if self.type == 'external' or self.type == 'other': | |
453 |
|
455 | |||
454 | className = eval(self.name) |
|
456 | className = eval(self.name) | |
455 | kwargs = self.getKwargs() |
|
457 | kwargs = self.getKwargs() | |
456 |
|
458 | |||
457 | opObj = className(**kwargs) |
|
459 | opObj = className(**kwargs) | |
458 |
|
460 | |||
459 | return opObj |
|
461 | return opObj | |
@@ -672,18 +674,18 class ProcUnitConf(): | |||||
672 | kwargs = self.getKwargs() |
|
674 | kwargs = self.getKwargs() | |
673 | procUnitObj = className(**kwargs) |
|
675 | procUnitObj = className(**kwargs) | |
674 |
|
676 | |||
675 |
for opConfObj in self.opConfObjList: |
|
677 | for opConfObj in self.opConfObjList: | |
676 |
|
678 | |||
677 | if opConfObj.type=='self' and self.name=='run': |
|
679 | if opConfObj.type=='self' and self.name=='run': | |
678 | continue |
|
680 | continue | |
679 |
elif opConfObj.type=='self': |
|
681 | elif opConfObj.type=='self': | |
680 | procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs()) |
|
682 | procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs()) | |
681 | continue |
|
683 | continue | |
682 |
|
684 | |||
683 | opObj = opConfObj.createObject(plotter_queue) |
|
685 | opObj = opConfObj.createObject(plotter_queue) | |
684 |
|
686 | |||
685 | self.opObjDict[opConfObj.id] = opObj |
|
687 | self.opObjDict[opConfObj.id] = opObj | |
686 |
|
688 | |||
687 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
689 | procUnitObj.addOperation(opObj, opConfObj.id) | |
688 |
|
690 | |||
689 | self.procUnitObj = procUnitObj |
|
691 | self.procUnitObj = procUnitObj |
@@ -1162,7 +1162,7 class Parameters(Spectra): | |||||
1162 |
|
1162 | |||
1163 | abscissaList = None #Abscissa, can be velocities, lags or time |
|
1163 | abscissaList = None #Abscissa, can be velocities, lags or time | |
1164 |
|
1164 | |||
1165 |
|
|
1165 | # noise = None #Noise Potency | |
1166 |
|
1166 | |||
1167 | utctimeInit = None #Initial UTC time |
|
1167 | utctimeInit = None #Initial UTC time | |
1168 |
|
1168 | |||
@@ -1216,3 +1216,7 class Parameters(Spectra): | |||||
1216 | datatime = numpy.array(datatime) |
|
1216 | datatime = numpy.array(datatime) | |
1217 |
|
1217 | |||
1218 | return datatime |
|
1218 | return datatime | |
|
1219 | ||||
|
1220 | def getTimeInterval(self): | |||
|
1221 | ||||
|
1222 | return self.paramInterval |
@@ -325,7 +325,7 class PlotCrossSpectraData(PlotData): | |||||
325 |
|
325 | |||
326 | ax.set_xlim(self.xmin, self.xmax) |
|
326 | ax.set_xlim(self.xmin, self.xmax) | |
327 | ax.set_ylim(self.ymin, self.ymax) |
|
327 | ax.set_ylim(self.ymin, self.ymax) | |
328 |
|
328 | |||
329 | ax.set_ylabel(self.ylabel) |
|
329 | ax.set_ylabel(self.ylabel) | |
330 | ax.set_xlabel(xlabel) |
|
330 | ax.set_xlabel(xlabel) | |
331 | ax.firsttime = False |
|
331 | ax.firsttime = False | |
@@ -590,6 +590,92 class PlotNoiseData(PlotData): | |||||
590 | self.saveTime = self.min_time |
|
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 | class PlotSNRData(PlotRTIData): |
|
679 | class PlotSNRData(PlotRTIData): | |
594 | CODE = 'snr' |
|
680 | CODE = 'snr' | |
595 | colormap = 'jet' |
|
681 | colormap = 'jet' |
@@ -1043,7 +1043,7 class WindProfiler(Operation): | |||||
1043 | param = dataOut.data_param |
|
1043 | param = dataOut.data_param | |
1044 | if dataOut.abscissaList != None: |
|
1044 | if dataOut.abscissaList != None: | |
1045 | absc = dataOut.abscissaList[:-1] |
|
1045 | absc = dataOut.abscissaList[:-1] | |
1046 | noise = dataOut.noise |
|
1046 | #noise = dataOut.noise | |
1047 | heightList = dataOut.heightList |
|
1047 | heightList = dataOut.heightList | |
1048 | SNR = dataOut.data_SNR |
|
1048 | SNR = dataOut.data_SNR | |
1049 |
|
1049 |
@@ -245,7 +245,7 class PublishData(Operation): | |||||
245 | def close(self): |
|
245 | def close(self): | |
246 | if self.zeromq is 1: |
|
246 | if self.zeromq is 1: | |
247 | self.dataOut.finished = True |
|
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 | if self.client: |
|
250 | if self.client: | |
251 | self.client.loop_stop() |
|
251 | self.client.loop_stop() | |
@@ -314,7 +314,7 class ReceiverData(ProcessingUnit, Process): | |||||
314 | pass |
|
314 | pass | |
315 | if self.connections == 0 and self.started is True: |
|
315 | if self.connections == 0 and self.started is True: | |
316 | self.ended = True |
|
316 | self.ended = True | |
317 | # send('ENDED') |
|
317 | ||
318 | evt.update({'description': events[evt['event']]}) |
|
318 | evt.update({'description': events[evt['event']]}) | |
319 |
|
319 | |||
320 | if evt['event'] == zmq.EVENT_MONITOR_STOPPED: |
|
320 | if evt['event'] == zmq.EVENT_MONITOR_STOPPED: | |
@@ -335,9 +335,15 class ReceiverData(ProcessingUnit, Process): | |||||
335 | self.sender.send_pyobj(data) |
|
335 | self.sender.send_pyobj(data) | |
336 |
|
336 | |||
337 | def update(self): |
|
337 | def update(self): | |
|
338 | ||||
338 | t = self.dataOut.utctime |
|
339 | t = self.dataOut.utctime | |
|
340 | ||||
|
341 | if t in self.data['times']: | |||
|
342 | return | |||
|
343 | ||||
339 | self.data['times'].append(t) |
|
344 | self.data['times'].append(t) | |
340 | self.data['dataOut'] = self.dataOut |
|
345 | self.data['dataOut'] = self.dataOut | |
|
346 | ||||
341 | for plottype in self.plottypes: |
|
347 | for plottype in self.plottypes: | |
342 | if plottype == 'spc': |
|
348 | if plottype == 'spc': | |
343 | z = self.dataOut.data_spc/self.dataOut.normFactor |
|
349 | z = self.dataOut.data_spc/self.dataOut.normFactor | |
@@ -361,8 +367,10 class ReceiverData(ProcessingUnit, Process): | |||||
361 | self.data[plottype][t] = self.dataOut.getCoherence() |
|
367 | self.data[plottype][t] = self.dataOut.getCoherence() | |
362 | if plottype == 'phase': |
|
368 | if plottype == 'phase': | |
363 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) |
|
369 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) | |
|
370 | if plottype == 'wind': | |||
|
371 | self.data[plottype][t] = self.dataOut.data_output | |||
364 | if self.realtime: |
|
372 | if self.realtime: | |
365 |
self.data_web['timestamp'] = t |
|
373 | self.data_web['timestamp'] = t | |
366 | if plottype == 'spc': |
|
374 | if plottype == 'spc': | |
367 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist()) |
|
375 | self.data_web[plottype] = roundFloats(decimate(self.data[plottype]).tolist()) | |
368 | elif plottype == 'cspc': |
|
376 | elif plottype == 'cspc': |
General Comments 0
You need to be logged in to leave comments.
Login now