@@ -254,6 +254,7 class Plot(Operation): | |||||
254 | self.data = PlotterData(self.CODE, self.exp_code, self.localtime) |
|
254 | self.data = PlotterData(self.CODE, self.exp_code, self.localtime) | |
255 | self.ang_min = kwargs.get('ang_min', None) |
|
255 | self.ang_min = kwargs.get('ang_min', None) | |
256 | self.ang_max = kwargs.get('ang_max', None) |
|
256 | self.ang_max = kwargs.get('ang_max', None) | |
|
257 | self.mode = kwargs.get('mode', None) | |||
257 |
|
258 | |||
258 |
|
259 | |||
259 | if self.server: |
|
260 | if self.server: | |
@@ -434,9 +435,15 class Plot(Operation): | |||||
434 | self.time_label), |
|
435 | self.time_label), | |
435 | size=8) |
|
436 | size=8) | |
436 | else: |
|
437 | else: | |
437 | ax.set_title('{}'.format(self.titles[n]), size=8) |
|
438 | #ax.set_title('{}'.format(self.titles[n]), size=8) | |
438 |
ax.set_ |
|
439 | ax.set_title('{} {} {}'.format( | |
439 | ax.set_yticks(numpy.arange(0, 90, 20)) |
|
440 | self.titles[n], | |
|
441 | self.getDateTime(self.data.max_time).strftime( | |||
|
442 | '%Y-%m-%d %H:%M:%S'), | |||
|
443 | self.time_label), | |||
|
444 | size=8) | |||
|
445 | ax.set_ylim(0, self.ymax) | |||
|
446 | #ax.set_yticks(numpy.arange(0, self.ymax, 20)) | |||
440 | ax.yaxis.labelpad = 40 |
|
447 | ax.yaxis.labelpad = 40 | |
441 |
|
448 | |||
442 | if self.firsttime: |
|
449 | if self.firsttime: |
@@ -2376,3 +2376,147 class WeatherRHI_vRF3_Plot(Plot): | |||||
2376 | plt.text(1.0, 1.05, 'Elevacion '+str(thisDatetime)+" Step "+str(self.ini)+ " Azi: "+str(round(self.res_azi,2)), transform=caax.transAxes, va='bottom',ha='right') |
|
2376 | plt.text(1.0, 1.05, 'Elevacion '+str(thisDatetime)+" Step "+str(self.ini)+ " Azi: "+str(round(self.res_azi,2)), transform=caax.transAxes, va='bottom',ha='right') | |
2377 | print("***************************self.ini****************************",self.ini) |
|
2377 | print("***************************self.ini****************************",self.ini) | |
2378 | self.ini= self.ini+1 |
|
2378 | self.ini= self.ini+1 | |
|
2379 | ||||
|
2380 | class WeatherRHI_vRF4_Plot(Plot): | |||
|
2381 | CODE = 'weather' | |||
|
2382 | plot_name = 'weather' | |||
|
2383 | #plot_type = 'rhistyle' | |||
|
2384 | buffering = False | |||
|
2385 | data_ele_tmp = None | |||
|
2386 | ||||
|
2387 | def setup(self): | |||
|
2388 | ||||
|
2389 | self.ncols = 1 | |||
|
2390 | self.nrows = 1 | |||
|
2391 | self.nplots= 1 | |||
|
2392 | self.ylabel= 'Range [Km]' | |||
|
2393 | self.titles= ['Weather'] | |||
|
2394 | self.polar = True | |||
|
2395 | if self.channels is not None: | |||
|
2396 | self.nplots = len(self.channels) | |||
|
2397 | self.nrows = len(self.channels) | |||
|
2398 | else: | |||
|
2399 | self.nplots = self.data.shape(self.CODE)[0] | |||
|
2400 | self.nrows = self.nplots | |||
|
2401 | self.channels = list(range(self.nplots)) | |||
|
2402 | #print("JERE") | |||
|
2403 | #exit(1) | |||
|
2404 | #print("channels",self.channels) | |||
|
2405 | #print("que saldra", self.data.shape(self.CODE)[0]) | |||
|
2406 | #self.titles = ['{} Channel {}'.format(self.CODE.upper(), x) for x in range(self.nrows)] | |||
|
2407 | ||||
|
2408 | #print("self.titles",self.titles) | |||
|
2409 | if self.CODE == 'Power': | |||
|
2410 | self.cb_label = r'Power (dB)' | |||
|
2411 | elif self.CODE == 'Doppler': | |||
|
2412 | self.cb_label = r'Velocity (m/s)' | |||
|
2413 | self.colorbar=True | |||
|
2414 | self.width =8 | |||
|
2415 | self.height =8 | |||
|
2416 | self.ini =0 | |||
|
2417 | self.len_azi =0 | |||
|
2418 | self.buffer_ini = None | |||
|
2419 | self.buffer_ele = None | |||
|
2420 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) | |||
|
2421 | self.flag =0 | |||
|
2422 | self.indicador= 0 | |||
|
2423 | self.last_data_ele = None | |||
|
2424 | self.val_mean = None | |||
|
2425 | ||||
|
2426 | def update(self, dataOut): | |||
|
2427 | ||||
|
2428 | if self.mode == 'Power': | |||
|
2429 | self.CODE = 'Power' | |||
|
2430 | elif self.mode == 'Doppler': | |||
|
2431 | self.CODE = 'Doppler' | |||
|
2432 | ||||
|
2433 | data = {} | |||
|
2434 | meta = {} | |||
|
2435 | if hasattr(dataOut, 'dataPP_POWER'): | |||
|
2436 | factor = 1 | |||
|
2437 | if hasattr(dataOut, 'nFFTPoints'): | |||
|
2438 | factor = dataOut.normFactor | |||
|
2439 | ||||
|
2440 | if self.CODE == 'Power': | |||
|
2441 | data[self.CODE] = 10*numpy.log10(dataOut.data_360_Power/(factor)) | |||
|
2442 | elif self.CODE == 'Doppler': | |||
|
2443 | data[self.CODE] = dataOut.data_360_Velocity/(factor) | |||
|
2444 | ||||
|
2445 | data['azi'] = dataOut.data_azi | |||
|
2446 | data['ele'] = dataOut.data_ele | |||
|
2447 | ||||
|
2448 | return data, meta | |||
|
2449 | ||||
|
2450 | def plot(self): | |||
|
2451 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S') | |||
|
2452 | data = self.data[-1] | |||
|
2453 | r = self.data.yrange | |||
|
2454 | delta_height = r[1]-r[0] | |||
|
2455 | r_mask = numpy.where(r>=0)[0] | |||
|
2456 | self.r_mask =r_mask | |||
|
2457 | r = numpy.arange(len(r_mask))*delta_height | |||
|
2458 | self.y = 2*r | |||
|
2459 | res = 1 | |||
|
2460 | ang_max = self.ang_max | |||
|
2461 | ang_min = self.ang_min | |||
|
2462 | var_ang =ang_max - ang_min | |||
|
2463 | step = (int(var_ang)/(res*data[self.CODE].shape[0])) | |||
|
2464 | ||||
|
2465 | z = data[self.CODE][self.channels[0]][:,r_mask] | |||
|
2466 | ||||
|
2467 | #print(z[2,:]) | |||
|
2468 | self.titles = [] | |||
|
2469 | ||||
|
2470 | #exit(1) | |||
|
2471 | ||||
|
2472 | if self.CODE == 'Power': | |||
|
2473 | cmap = 'jet' | |||
|
2474 | elif self.CODE == 'Doppler': | |||
|
2475 | cmap = 'RdBu' | |||
|
2476 | ||||
|
2477 | self.ymax = self.ymax if self.ymax else numpy.nanmax(r) | |||
|
2478 | self.ymin = self.ymin if self.ymin else numpy.nanmin(r) | |||
|
2479 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |||
|
2480 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |||
|
2481 | ||||
|
2482 | #plt.clf() | |||
|
2483 | subplots = [121, 122] | |||
|
2484 | ||||
|
2485 | r, theta = numpy.meshgrid(r, numpy.radians(data['ele']) ) | |||
|
2486 | ||||
|
2487 | points_cb = 200 | |||
|
2488 | mylevs_cbar = list(numpy.linspace(self.zmin,self.zmax,points_cb)) #niveles de la barra de colores | |||
|
2489 | ||||
|
2490 | for i,ax in enumerate(self.axes): | |||
|
2491 | ||||
|
2492 | if ax.firsttime: | |||
|
2493 | ax.set_xlim(numpy.radians(self.ang_min),numpy.radians(self.ang_max)) | |||
|
2494 | ax.plt = ax.contourf(theta, r, z, points_cb, cmap=cmap, vmin=self.zmin, vmax=self.zmax, levels=mylevs_cbar) | |||
|
2495 | #print(ax.plt) | |||
|
2496 | #exit(1) | |||
|
2497 | ''' | |||
|
2498 | self.figures[-1].colorbar(plt, orientation="vertical", fraction=0.025, pad=0.07) | |||
|
2499 | print(self.figures[0]) | |||
|
2500 | print(self.figures) | |||
|
2501 | print(plt) | |||
|
2502 | print(ax) | |||
|
2503 | exit(1) | |||
|
2504 | ''' | |||
|
2505 | ||||
|
2506 | else: | |||
|
2507 | ax.set_xlim(numpy.radians(self.ang_min),numpy.radians(self.ang_max)) | |||
|
2508 | ax.plt = ax.contourf(theta, r, z, points_cb, cmap=cmap, vmin=self.zmin, vmax=self.zmax, levels=mylevs_cbar) | |||
|
2509 | #self.figures[0].colorbar(plt, orientation="vertical", fraction=0.025, pad=0.07) | |||
|
2510 | ||||
|
2511 | #print(self.titles) | |||
|
2512 | if len(self.channels) !=1: | |||
|
2513 | self.titles = ['{} Azi: {} Channel {}'.format(self.CODE.upper(), str(round(numpy.mean(data['azi']),2)), x) for x in range(self.nrows)] | |||
|
2514 | else: | |||
|
2515 | self.titles = ['{} Azi: {} Channel {}'.format(self.CODE.upper(), str(round(numpy.mean(data['azi']),2)), self.channels[0])] | |||
|
2516 | #self.titles.append('Azi: {}'.format(str(round(numpy.mean(data['azi']),2)))) | |||
|
2517 | #self.titles.append(str(round(numpy.mean(data['azi']),2))) | |||
|
2518 | #print(self.titles) | |||
|
2519 | #plt.text(1.0, 1.05, str(thisDatetime)+ " Azi: "+str(round(numpy.mean(data['azi']),2)), transform=caax.transAxes, va='bottom',ha='right') | |||
|
2520 | #print("***************************self.ini****************************",self.ini) | |||
|
2521 | #self.figures[-1].colorbar(plt, orientation="vertical", fraction=0.025, pad=0.07) | |||
|
2522 | #self.ini= self.ini+1 |
@@ -394,11 +394,22 class HDFWriter(Operation): | |||||
394 | flag = True |
|
394 | flag = True | |
395 | return flag |
|
395 | return flag | |
396 |
|
396 | |||
|
397 | def generalFlag_vRF(self): | |||
|
398 | ####rint("GENERALFLAG") | |||
|
399 | ||||
|
400 | try: | |||
|
401 | self.dataOut.flagBlock360Done | |||
|
402 | return self.dataOut.flagBlock360Done | |||
|
403 | except: | |||
|
404 | return 0 | |||
|
405 | ||||
|
406 | ||||
397 | def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None,type_data=None,**kwargs): |
|
407 | def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None,type_data=None,**kwargs): | |
398 | self.path = path |
|
408 | self.path = path | |
399 | self.blocksPerFile = blocksPerFile |
|
409 | self.blocksPerFile = blocksPerFile | |
400 | self.metadataList = metadataList |
|
410 | self.metadataList = metadataList | |
401 | self.dataList = [s.strip() for s in dataList] |
|
411 | self.dataList = [s.strip() for s in dataList] | |
|
412 | self.setType = setType | |||
402 | if self.mode == "weather": |
|
413 | if self.mode == "weather": | |
403 | self.setType = "weather" |
|
414 | self.setType = "weather" | |
404 | #---------------------------------------- |
|
415 | #---------------------------------------- | |
@@ -624,7 +635,7 class HDFWriter(Operation): | |||||
624 | return |
|
635 | return | |
625 |
|
636 | |||
626 | def writeData(self, fp): |
|
637 | def writeData(self, fp): | |
627 |
|
638 | print("writing data") | ||
628 | if self.description: |
|
639 | if self.description: | |
629 | if 'Data' in self.description: |
|
640 | if 'Data' in self.description: | |
630 | grp = fp.create_group('Data') |
|
641 | grp = fp.create_group('Data') | |
@@ -671,7 +682,7 class HDFWriter(Operation): | |||||
671 |
|
682 | |||
672 | def putData(self): |
|
683 | def putData(self): | |
673 | ###print("**************************PUT DATA***************************************************") |
|
684 | ###print("**************************PUT DATA***************************************************") | |
674 |
if (self.blockIndex == self.blocksPerFile) or self.timeFlag() |
|
685 | if (self.blockIndex == self.blocksPerFile) or self.timeFlag():# or self.generalFlag_vRF(): | |
675 | self.closeFile() |
|
686 | self.closeFile() | |
676 | self.setNextFile() |
|
687 | self.setNextFile() | |
677 |
|
688 |
@@ -4,6 +4,7 must be used in plotting and writing operations to allow to run as an | |||||
4 | external process. |
|
4 | external process. | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
|
7 | import os | |||
7 | import inspect |
|
8 | import inspect | |
8 | import zmq |
|
9 | import zmq | |
9 | import time |
|
10 | import time | |
@@ -13,6 +14,7 from threading import Thread | |||||
13 | from multiprocessing import Process, Queue |
|
14 | from multiprocessing import Process, Queue | |
14 | from schainpy.utils import log |
|
15 | from schainpy.utils import log | |
15 |
|
16 | |||
|
17 | QUEUE_SIZE = int(os.environ.get('QUEUE_MAX_SIZE', '10')) | |||
16 |
|
18 | |||
17 | class ProcessingUnit(object): |
|
19 | class ProcessingUnit(object): | |
18 | ''' |
|
20 | ''' | |
@@ -178,7 +180,7 def MPDecorator(BaseClass): | |||||
178 |
|
180 | |||
179 | self.start_time = time.time() |
|
181 | self.start_time = time.time() | |
180 | self.err_queue = args[3] |
|
182 | self.err_queue = args[3] | |
181 |
self.queue = Queue(maxsize= |
|
183 | self.queue = Queue(maxsize=QUEUE_SIZE) | |
182 | self.myrun = BaseClass.run |
|
184 | self.myrun = BaseClass.run | |
183 |
|
185 | |||
184 | def run(self): |
|
186 | def run(self): |
@@ -4054,7 +4054,7 class PedestalInformation(Operation): | |||||
4054 |
|
4054 | |||
4055 | dt = datetime.datetime.utcfromtimestamp(timestamp) |
|
4055 | dt = datetime.datetime.utcfromtimestamp(timestamp) | |
4056 | path = os.path.join(self.path, dt.strftime('%Y-%m-%dT%H-00-00')) |
|
4056 | path = os.path.join(self.path, dt.strftime('%Y-%m-%dT%H-00-00')) | |
4057 |
|
4057 | |||
4058 | if not os.path.exists(path): |
|
4058 | if not os.path.exists(path): | |
4059 | return False, False |
|
4059 | return False, False | |
4060 | fileList = glob.glob(os.path.join(path, '*.h5')) |
|
4060 | fileList = glob.glob(os.path.join(path, '*.h5')) | |
@@ -4069,7 +4069,7 class PedestalInformation(Operation): | |||||
4069 | def find_next_file(self): |
|
4069 | def find_next_file(self): | |
4070 |
|
4070 | |||
4071 | while True: |
|
4071 | while True: | |
4072 |
file_size = len(self.fp['Data']['utc']) |
|
4072 | file_size = len(self.fp['Data']['utc']) | |
4073 | if self.utctime < self.utcfile+file_size*self.interval: |
|
4073 | if self.utctime < self.utcfile+file_size*self.interval: | |
4074 | break |
|
4074 | break | |
4075 | self.utcfile += file_size*self.interval |
|
4075 | self.utcfile += file_size*self.interval | |
@@ -4078,14 +4078,14 class PedestalInformation(Operation): | |||||
4078 | self.filename = os.path.join(path, 'pos@{}.000.h5'.format(int(self.utcfile))) |
|
4078 | self.filename = os.path.join(path, 'pos@{}.000.h5'.format(int(self.utcfile))) | |
4079 | if not os.path.exists(self.filename): |
|
4079 | if not os.path.exists(self.filename): | |
4080 | log.warning('Waiting for position files...', self.name) |
|
4080 | log.warning('Waiting for position files...', self.name) | |
4081 |
|
4081 | |||
4082 | if not os.path.exists(self.filename): |
|
4082 | if not os.path.exists(self.filename): | |
4083 |
|
4083 | |||
4084 | raise IOError('No new position files found in {}'.format(path)) |
|
4084 | raise IOError('No new position files found in {}'.format(path)) | |
4085 | self.fp.close() |
|
4085 | self.fp.close() | |
4086 | self.fp = h5py.File(self.filename, 'r') |
|
4086 | self.fp = h5py.File(self.filename, 'r') | |
4087 | log.log('Opening file: {}'.format(self.filename), self.name) |
|
4087 | log.log('Opening file: {}'.format(self.filename), self.name) | |
4088 |
|
4088 | |||
4089 | def get_values(self): |
|
4089 | def get_values(self): | |
4090 |
|
4090 | |||
4091 | index = int((self.utctime-self.utcfile)/self.interval) |
|
4091 | index = int((self.utctime-self.utcfile)/self.interval) | |
@@ -4098,7 +4098,7 class PedestalInformation(Operation): | |||||
4098 | self.samples = samples |
|
4098 | self.samples = samples | |
4099 | self.interval = interval |
|
4099 | self.interval = interval | |
4100 | self.utcfile, self.filename = self.find_file(dataOut.utctime) |
|
4100 | self.utcfile, self.filename = self.find_file(dataOut.utctime) | |
4101 |
|
4101 | |||
4102 | if not self.filename: |
|
4102 | if not self.filename: | |
4103 | log.error('No position files found in {}'.format(path), self.name) |
|
4103 | log.error('No position files found in {}'.format(path), self.name) | |
4104 | raise IOError('No position files found in {}'.format(path)) |
|
4104 | raise IOError('No position files found in {}'.format(path)) | |
@@ -4107,15 +4107,15 class PedestalInformation(Operation): | |||||
4107 | self.fp = h5py.File(self.filename, 'r') |
|
4107 | self.fp = h5py.File(self.filename, 'r') | |
4108 |
|
4108 | |||
4109 | def run(self, dataOut, path, conf=None, samples=1500, interval=0.04, wr_exp=None): |
|
4109 | def run(self, dataOut, path, conf=None, samples=1500, interval=0.04, wr_exp=None): | |
4110 |
|
4110 | |||
4111 | if not self.isConfig: |
|
4111 | if not self.isConfig: | |
4112 | self.setup(dataOut, path, conf, samples, interval, wr_exp) |
|
4112 | self.setup(dataOut, path, conf, samples, interval, wr_exp) | |
4113 | self.isConfig = True |
|
4113 | self.isConfig = True | |
4114 |
|
4114 | |||
4115 | self.utctime = dataOut.utctime |
|
4115 | self.utctime = dataOut.utctime | |
4116 |
|
4116 | |||
4117 | self.find_next_file() |
|
4117 | self.find_next_file() | |
4118 |
|
4118 | |||
4119 | az, el = self.get_values() |
|
4119 | az, el = self.get_values() | |
4120 | dataOut.flagNoData = False |
|
4120 | dataOut.flagNoData = False | |
4121 |
|
4121 | |||
@@ -4509,7 +4509,7 class Block360_vRF2(Operation): | |||||
4509 | __nch = 0 |
|
4509 | __nch = 0 | |
4510 | __nHeis = 0 |
|
4510 | __nHeis = 0 | |
4511 | index = 0 |
|
4511 | index = 0 | |
4512 |
mode = |
|
4512 | mode = None | |
4513 |
|
4513 | |||
4514 | def __init__(self,**kwargs): |
|
4514 | def __init__(self,**kwargs): | |
4515 | Operation.__init__(self,**kwargs) |
|
4515 | Operation.__init__(self,**kwargs) | |
@@ -4534,28 +4534,24 class Block360_vRF2(Operation): | |||||
4534 | self.__buffer = [] |
|
4534 | self.__buffer = [] | |
4535 | self.__buffer2 = [] |
|
4535 | self.__buffer2 = [] | |
4536 | self.__buffer3 = [] |
|
4536 | self.__buffer3 = [] | |
|
4537 | self.__buffer4 = [] | |||
4537 |
|
4538 | |||
4538 | def putData(self,data,mode): |
|
4539 | def putData(self,data,mode): | |
4539 | ''' |
|
4540 | ''' | |
4540 | Add a profile to he __buffer and increase in one the __profiel Index |
|
4541 | Add a profile to he __buffer and increase in one the __profiel Index | |
4541 | ''' |
|
4542 | ''' | |
4542 | #print("line 4049",data.dataPP_POW.shape,data.dataPP_POW[:10]) |
|
4543 | ||
4543 | #print("line 4049",data.azimuth.shape,data.azimuth) |
|
|||
4544 | if self.mode==0: |
|
4544 | if self.mode==0: | |
4545 | self.__buffer.append(data.dataPP_POWER)# PRIMER MOMENTO |
|
4545 | self.__buffer.append(data.dataPP_POWER)# PRIMER MOMENTO | |
4546 | if self.mode==1: |
|
4546 | if self.mode==1: | |
4547 | self.__buffer.append(data.data_pow) |
|
4547 | self.__buffer.append(data.data_pow) | |
4548 | #print("me casi",self.index,data.azimuth[self.index]) |
|
|||
4549 | #print(self.__profIndex, self.index , data.azimuth[self.index] ) |
|
|||
4550 | #print("magic",data.profileIndex) |
|
|||
4551 | #print(data.azimuth[self.index]) |
|
|||
4552 | #print("index",self.index) |
|
|||
4553 |
|
4548 | |||
4554 | #####self.__buffer2[self.__profIndex] = data.azimuth[self.index] |
|
4549 | self.__buffer4.append(data.dataPP_DOP) | |
|
4550 | ||||
4555 | self.__buffer2.append(data.azimuth) |
|
4551 | self.__buffer2.append(data.azimuth) | |
4556 | self.__buffer3.append(data.elevation) |
|
4552 | self.__buffer3.append(data.elevation) | |
4557 | self.__profIndex += 1 |
|
4553 | self.__profIndex += 1 | |
4558 | #print("q pasa") |
|
4554 | ||
4559 | return numpy.array(self.__buffer3) #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Remove DCΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
4555 | return numpy.array(self.__buffer3) #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Remove DCΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
4560 |
|
4556 | |||
4561 | def pushData(self,data): |
|
4557 | def pushData(self,data): | |
@@ -4563,98 +4559,233 class Block360_vRF2(Operation): | |||||
4563 | Return the PULSEPAIR and the profiles used in the operation |
|
4559 | Return the PULSEPAIR and the profiles used in the operation | |
4564 | Affected : self.__profileIndex |
|
4560 | Affected : self.__profileIndex | |
4565 | ''' |
|
4561 | ''' | |
4566 | #print("pushData") |
|
|||
4567 |
|
4562 | |||
4568 | data_360 = numpy.array(self.__buffer).transpose(1,0,2) |
|
4563 | data_360_Power = numpy.array(self.__buffer).transpose(1,0,2) | |
|
4564 | data_360_Velocity = numpy.array(self.__buffer4).transpose(1,0,2) | |||
4569 | data_p = numpy.array(self.__buffer2) |
|
4565 | data_p = numpy.array(self.__buffer2) | |
4570 | data_e = numpy.array(self.__buffer3) |
|
4566 | data_e = numpy.array(self.__buffer3) | |
4571 | n = self.__profIndex |
|
4567 | n = self.__profIndex | |
4572 |
|
4568 | |||
4573 |
self.__buffer |
|
4569 | self.__buffer = [] | |
|
4570 | self.__buffer4 = [] | |||
4574 | self.__buffer2 = [] |
|
4571 | self.__buffer2 = [] | |
4575 | self.__buffer3 = [] |
|
4572 | self.__buffer3 = [] | |
4576 | self.__profIndex = 0 |
|
4573 | self.__profIndex = 0 | |
4577 | #print("pushData") |
|
4574 | return data_360_Power,data_360_Velocity,n,data_p,data_e | |
4578 | return data_360,n,data_p,data_e |
|
|||
4579 |
|
4575 | |||
4580 |
|
4576 | |||
4581 | def byProfiles(self,dataOut): |
|
4577 | def byProfiles(self,dataOut): | |
4582 |
|
4578 | |||
4583 | self.__dataReady = False |
|
4579 | self.__dataReady = False | |
4584 |
data_360 = |
|
4580 | data_360_Power = [] | |
|
4581 | data_360_Velocity = [] | |||
4585 | data_p = None |
|
4582 | data_p = None | |
4586 | data_e = None |
|
4583 | data_e = None | |
4587 | #print("dataOu",dataOut.dataPP_POW) |
|
|||
4588 |
|
4584 | |||
4589 | elevations = self.putData(data=dataOut,mode = self.mode) |
|
4585 | elevations = self.putData(data=dataOut,mode = self.mode) | |
4590 | ##### print("profIndex",self.__profIndex) |
|
|||
4591 |
|
||||
4592 |
|
4586 | |||
4593 | if self.__profIndex > 1: |
|
4587 | if self.__profIndex > 1: | |
4594 | case_flag = self.checkcase(elevations) |
|
4588 | case_flag = self.checkcase(elevations) | |
4595 |
|
4589 | |||
4596 | if case_flag == 0: #Subida |
|
4590 | if case_flag == 0: #Subida | |
4597 | #Se borra el dato anterior para liberar buffer y comparar el dato actual con el siguiente |
|
4591 | ||
4598 | if len(self.__buffer) == 2: #Cuando estΓ‘ de subida |
|
4592 | if len(self.__buffer) == 2: #Cuando estΓ‘ de subida | |
|
4593 | #Se borra el dato anterior para liberar buffer y comparar el dato actual con el siguiente | |||
4599 | self.__buffer.pop(0) #Erase first data |
|
4594 | self.__buffer.pop(0) #Erase first data | |
4600 | self.__buffer2.pop(0) |
|
4595 | self.__buffer2.pop(0) | |
4601 | self.__buffer3.pop(0) |
|
4596 | self.__buffer3.pop(0) | |
|
4597 | self.__buffer4.pop(0) | |||
4602 | self.__profIndex -= 1 |
|
4598 | self.__profIndex -= 1 | |
4603 | else: #Cuando ha estado de bajada y ha vuelto a subir |
|
4599 | else: #Cuando ha estado de bajada y ha vuelto a subir | |
4604 | #print("else",self.__buffer3) |
|
4600 | #Se borra el ΓΊltimo dato | |
4605 | self.__buffer.pop() #Erase last data |
|
4601 | self.__buffer.pop() #Erase last data | |
4606 | self.__buffer2.pop() |
|
4602 | self.__buffer2.pop() | |
4607 | self.__buffer3.pop() |
|
4603 | self.__buffer3.pop() | |
4608 | data_360,n,data_p,data_e = self.pushData(data=dataOut) |
|
4604 | self.__buffer4.pop() | |
4609 | #print(data_360.shape) |
|
4605 | data_360_Power,data_360_Velocity,n,data_p,data_e = self.pushData(data=dataOut) | |
4610 | #print(data_e.shape) |
|
4606 | ||
4611 | #exit(1) |
|
|||
4612 | self.__dataReady = True |
|
4607 | self.__dataReady = True | |
4613 | ''' |
|
4608 | ||
4614 | elif elevations[-1]<0.: |
|
4609 | return data_360_Power,data_360_Velocity,data_p,data_e | |
4615 | if len(self.__buffer) == 2: |
|
4610 | ||
|
4611 | ||||
|
4612 | def blockOp(self, dataOut, datatime= None): | |||
|
4613 | if self.__initime == None: | |||
|
4614 | self.__initime = datatime | |||
|
4615 | data_360_Power,data_360_Velocity,data_p,data_e = self.byProfiles(dataOut) | |||
|
4616 | self.__lastdatatime = datatime | |||
|
4617 | ||||
|
4618 | avgdatatime = self.__initime | |||
|
4619 | if self.n==1: | |||
|
4620 | avgdatatime = datatime | |||
|
4621 | deltatime = datatime - self.__lastdatatime | |||
|
4622 | self.__initime = datatime | |||
|
4623 | return data_360_Power,data_360_Velocity,avgdatatime,data_p,data_e | |||
|
4624 | ||||
|
4625 | def checkcase(self,data_ele): | |||
|
4626 | #print(data_ele) | |||
|
4627 | start = data_ele[-2] | |||
|
4628 | end = data_ele[-1] | |||
|
4629 | diff_angle = (end-start) | |||
|
4630 | len_ang=len(data_ele) | |||
|
4631 | ||||
|
4632 | if diff_angle > 0: #Subida | |||
|
4633 | return 0 | |||
|
4634 | ||||
|
4635 | def run(self, dataOut,mode='Power',**kwargs): | |||
|
4636 | #print("BLOCK 360 HERE WE GO MOMENTOS") | |||
|
4637 | #print("Block 360") | |||
|
4638 | dataOut.mode = mode | |||
|
4639 | ||||
|
4640 | if not self.isConfig: | |||
|
4641 | self.setup(dataOut = dataOut ,mode= mode ,**kwargs) | |||
|
4642 | self.isConfig = True | |||
|
4643 | ||||
|
4644 | ||||
|
4645 | data_360_Power, data_360_Velocity, avgdatatime,data_p,data_e = self.blockOp(dataOut, dataOut.utctime) | |||
|
4646 | ||||
|
4647 | ||||
|
4648 | dataOut.flagNoData = True | |||
|
4649 | ||||
|
4650 | ||||
|
4651 | if self.__dataReady: | |||
|
4652 | dataOut.data_360_Power = data_360_Power # S | |||
|
4653 | dataOut.data_360_Velocity = data_360_Velocity | |||
|
4654 | dataOut.data_azi = data_p | |||
|
4655 | dataOut.data_ele = data_e | |||
|
4656 | dataOut.utctime = avgdatatime | |||
|
4657 | dataOut.flagNoData = False | |||
|
4658 | ||||
|
4659 | return dataOut | |||
|
4660 | ||||
|
4661 | class Block360_vRF3(Operation): | |||
|
4662 | ''' | |||
|
4663 | ''' | |||
|
4664 | isConfig = False | |||
|
4665 | __profIndex = 0 | |||
|
4666 | __initime = None | |||
|
4667 | __lastdatatime = None | |||
|
4668 | __buffer = None | |||
|
4669 | __dataReady = False | |||
|
4670 | n = None | |||
|
4671 | __nch = 0 | |||
|
4672 | __nHeis = 0 | |||
|
4673 | index = 0 | |||
|
4674 | mode = None | |||
|
4675 | ||||
|
4676 | def __init__(self,**kwargs): | |||
|
4677 | Operation.__init__(self,**kwargs) | |||
|
4678 | ||||
|
4679 | def setup(self, dataOut, n = None, mode = None): | |||
|
4680 | ''' | |||
|
4681 | n= Numero de PRF's de entrada | |||
|
4682 | ''' | |||
|
4683 | self.__initime = None | |||
|
4684 | self.__lastdatatime = 0 | |||
|
4685 | self.__dataReady = False | |||
|
4686 | self.__buffer = 0 | |||
|
4687 | self.__buffer_1D = 0 | |||
|
4688 | #self.__profIndex = 0 | |||
|
4689 | self.index = 0 | |||
|
4690 | self.__nch = dataOut.nChannels | |||
|
4691 | self.__nHeis = dataOut.nHeights | |||
|
4692 | ||||
|
4693 | self.mode = mode | |||
|
4694 | #print("self.mode",self.mode) | |||
|
4695 | #print("nHeights") | |||
|
4696 | self.__buffer = [] | |||
|
4697 | self.__buffer2 = [] | |||
|
4698 | self.__buffer3 = [] | |||
|
4699 | self.__buffer4 = [] | |||
|
4700 | ||||
|
4701 | def putData(self,data,mode): | |||
|
4702 | ''' | |||
|
4703 | Add a profile to he __buffer and increase in one the __profiel Index | |||
|
4704 | ''' | |||
|
4705 | ||||
|
4706 | if self.mode==0: | |||
|
4707 | self.__buffer.append(data.dataPP_POWER)# PRIMER MOMENTO | |||
|
4708 | if self.mode==1: | |||
|
4709 | self.__buffer.append(data.data_pow) | |||
|
4710 | ||||
|
4711 | self.__buffer4.append(data.dataPP_DOP) | |||
|
4712 | ||||
|
4713 | self.__buffer2.append(data.azimuth) | |||
|
4714 | self.__buffer3.append(data.elevation) | |||
|
4715 | self.__profIndex += 1 | |||
|
4716 | ||||
|
4717 | return numpy.array(self.__buffer3) #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Remove DCΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
4718 | ||||
|
4719 | def pushData(self,data): | |||
|
4720 | ''' | |||
|
4721 | Return the PULSEPAIR and the profiles used in the operation | |||
|
4722 | Affected : self.__profileIndex | |||
|
4723 | ''' | |||
|
4724 | ||||
|
4725 | data_360_Power = numpy.array(self.__buffer).transpose(1,0,2) | |||
|
4726 | data_360_Velocity = numpy.array(self.__buffer4).transpose(1,0,2) | |||
|
4727 | data_p = numpy.array(self.__buffer2) | |||
|
4728 | data_e = numpy.array(self.__buffer3) | |||
|
4729 | n = self.__profIndex | |||
|
4730 | ||||
|
4731 | self.__buffer = [] | |||
|
4732 | self.__buffer4 = [] | |||
|
4733 | self.__buffer2 = [] | |||
|
4734 | self.__buffer3 = [] | |||
|
4735 | self.__profIndex = 0 | |||
|
4736 | return data_360_Power,data_360_Velocity,n,data_p,data_e | |||
|
4737 | ||||
|
4738 | ||||
|
4739 | def byProfiles(self,dataOut): | |||
|
4740 | ||||
|
4741 | self.__dataReady = False | |||
|
4742 | data_360_Power = [] | |||
|
4743 | data_360_Velocity = [] | |||
|
4744 | data_p = None | |||
|
4745 | data_e = None | |||
|
4746 | ||||
|
4747 | elevations = self.putData(data=dataOut,mode = self.mode) | |||
|
4748 | ||||
|
4749 | if self.__profIndex > 1: | |||
|
4750 | case_flag = self.checkcase(elevations) | |||
|
4751 | ||||
|
4752 | if case_flag == 0: #Subida | |||
|
4753 | ||||
|
4754 | if len(self.__buffer) == 2: #Cuando estΓ‘ de subida | |||
|
4755 | #Se borra el dato anterior para liberar buffer y comparar el dato actual con el siguiente | |||
4616 | self.__buffer.pop(0) #Erase first data |
|
4756 | self.__buffer.pop(0) #Erase first data | |
4617 | self.__buffer2.pop(0) |
|
4757 | self.__buffer2.pop(0) | |
4618 | self.__buffer3.pop(0) |
|
4758 | self.__buffer3.pop(0) | |
|
4759 | self.__buffer4.pop(0) | |||
4619 | self.__profIndex -= 1 |
|
4760 | self.__profIndex -= 1 | |
4620 | else: |
|
4761 | else: #Cuando ha estado de bajada y ha vuelto a subir | |
|
4762 | #Se borra el ΓΊltimo dato | |||
4621 | self.__buffer.pop() #Erase last data |
|
4763 | self.__buffer.pop() #Erase last data | |
4622 | self.__buffer2.pop() |
|
4764 | self.__buffer2.pop() | |
4623 | self.__buffer3.pop() |
|
4765 | self.__buffer3.pop() | |
4624 | data_360,n,data_p,data_e = self.pushData(data=dataOut) |
|
4766 | self.__buffer4.pop() | |
4625 | self.__dataReady = True |
|
4767 | data_360_Power,data_360_Velocity,n,data_p,data_e = self.pushData(data=dataOut) | |
4626 | ''' |
|
|||
4627 |
|
||||
4628 |
|
4768 | |||
4629 | ''' |
|
4769 | self.__dataReady = True | |
4630 | if self.__profIndex == self.n: |
|
|||
4631 | data_360,n,data_p,data_e = self.pushData(data=dataOut) |
|
|||
4632 | self.__dataReady = True |
|
|||
4633 | ''' |
|
|||
4634 |
|
4770 | |||
4635 | return data_360,data_p,data_e |
|
4771 | return data_360_Power,data_360_Velocity,data_p,data_e | |
4636 |
|
4772 | |||
4637 |
|
4773 | |||
4638 | def blockOp(self, dataOut, datatime= None): |
|
4774 | def blockOp(self, dataOut, datatime= None): | |
4639 | if self.__initime == None: |
|
4775 | if self.__initime == None: | |
4640 | self.__initime = datatime |
|
4776 | self.__initime = datatime | |
4641 | data_360,data_p,data_e = self.byProfiles(dataOut) |
|
4777 | data_360_Power,data_360_Velocity,data_p,data_e = self.byProfiles(dataOut) | |
4642 | self.__lastdatatime = datatime |
|
4778 | self.__lastdatatime = datatime | |
4643 |
|
4779 | |||
4644 | if data_360 is None: |
|
|||
4645 | return None, None,None,None |
|
|||
4646 |
|
||||
4647 |
|
||||
4648 | avgdatatime = self.__initime |
|
4780 | avgdatatime = self.__initime | |
4649 | if self.n==1: |
|
4781 | if self.n==1: | |
4650 | avgdatatime = datatime |
|
4782 | avgdatatime = datatime | |
4651 | deltatime = datatime - self.__lastdatatime |
|
4783 | deltatime = datatime - self.__lastdatatime | |
4652 | self.__initime = datatime |
|
4784 | self.__initime = datatime | |
4653 |
|
|
4785 | return data_360_Power,data_360_Velocity,avgdatatime,data_p,data_e | |
4654 | return data_360,avgdatatime,data_p,data_e |
|
|||
4655 |
|
4786 | |||
4656 | def checkcase(self,data_ele): |
|
4787 | def checkcase(self,data_ele): | |
4657 | print(data_ele) |
|
4788 | #print(data_ele) | |
4658 | start = data_ele[-2] |
|
4789 | start = data_ele[-2] | |
4659 | end = data_ele[-1] |
|
4790 | end = data_ele[-1] | |
4660 | diff_angle = (end-start) |
|
4791 | diff_angle = (end-start) | |
@@ -4663,46 +4794,28 class Block360_vRF2(Operation): | |||||
4663 | if diff_angle > 0: #Subida |
|
4794 | if diff_angle > 0: #Subida | |
4664 | return 0 |
|
4795 | return 0 | |
4665 |
|
4796 | |||
4666 |
def run(self, dataOut, |
|
4797 | def run(self, dataOut,mode='Power',**kwargs): | |
4667 | #print("BLOCK 360 HERE WE GO MOMENTOS") |
|
4798 | #print("BLOCK 360 HERE WE GO MOMENTOS") | |
4668 | print("Block 360") |
|
4799 | #print("Block 360") | |
|
4800 | dataOut.mode = mode | |||
4669 |
|
4801 | |||
4670 | #exit(1) |
|
|||
4671 | if not self.isConfig: |
|
4802 | if not self.isConfig: | |
4672 |
|
||||
4673 | print(n) |
|
|||
4674 | self.setup(dataOut = dataOut ,mode= mode ,**kwargs) |
|
4803 | self.setup(dataOut = dataOut ,mode= mode ,**kwargs) | |
4675 | ####self.index = 0 |
|
|||
4676 | #print("comova",self.isConfig) |
|
|||
4677 | self.isConfig = True |
|
4804 | self.isConfig = True | |
4678 | ####if self.index==dataOut.azimuth.shape[0]: |
|
|||
4679 | #### self.index=0 |
|
|||
4680 |
|
||||
4681 | data_360, avgdatatime,data_p,data_e = self.blockOp(dataOut, dataOut.utctime) |
|
|||
4682 |
|
4805 | |||
4683 |
|
4806 | |||
|
4807 | data_360_Power, data_360_Velocity, avgdatatime,data_p,data_e = self.blockOp(dataOut, dataOut.utctime) | |||
4684 |
|
4808 | |||
4685 |
|
4809 | |||
4686 | dataOut.flagNoData = True |
|
4810 | dataOut.flagNoData = True | |
4687 |
|
4811 | |||
|
4812 | ||||
4688 | if self.__dataReady: |
|
4813 | if self.__dataReady: | |
4689 | dataOut.data_360 = data_360 # S |
|
4814 | dataOut.data_360_Power = data_360_Power # S | |
4690 | #print("DATA 360") |
|
4815 | dataOut.data_360_Velocity = data_360_Velocity | |
4691 | #print(dataOut.data_360) |
|
|||
4692 | #print("---------------------------------------------------------------------------------") |
|
|||
4693 | print("---------------------------DATAREADY---------------------------------------------") |
|
|||
4694 | #print("---------------------------------------------------------------------------------") |
|
|||
4695 | #print("data_360",dataOut.data_360.shape) |
|
|||
4696 | print(data_e) |
|
|||
4697 | #exit(1) |
|
|||
4698 | dataOut.data_azi = data_p |
|
4816 | dataOut.data_azi = data_p | |
4699 | dataOut.data_ele = data_e |
|
4817 | dataOut.data_ele = data_e | |
4700 | ###print("azi: ",dataOut.data_azi) |
|
|||
4701 | #print("ele: ",dataOut.data_ele) |
|
|||
4702 | #print("jroproc_parameters",data_p[0],data_p[-1])#,data_360.shape,avgdatatime) |
|
|||
4703 | dataOut.utctime = avgdatatime |
|
4818 | dataOut.utctime = avgdatatime | |
4704 |
|
||||
4705 |
|
||||
4706 |
|
||||
4707 | dataOut.flagNoData = False |
|
4819 | dataOut.flagNoData = False | |
|
4820 | ||||
4708 | return dataOut |
|
4821 | return dataOut |
General Comments 0
You need to be logged in to leave comments.
Login now