##// END OF EJS Templates
jroplot_parameters.py jroplot_spectra.py jroIO_digitalRF.py jroproc_parameters.py sophy_proc.py
eynilupu -
r1653:f661d02a9309
parent child
Show More
@@ -528,7 +528,7 class WeatherParamsPlot(Plot):
528 528 self.nplots= 1
529 529 self.ylabel= 'Height [km]'
530 530 self.xlabel= 'Distance from radar [km]'
531
531
532 532 if self.channels is not None:
533 533 self.nplots = len(self.channels)
534 534 self.ncols = len(self.channels)
@@ -577,9 +577,12 class WeatherParamsPlot(Plot):
577 577 if hasattr(dataOut, 'dparam'):
578 578 tmp = getattr(dataOut, 'data_param')
579 579 else:
580
580 #print("-------------------self.attr_data[0]",self.attr_data[0])
581 581 if 'S' in self.attr_data[0]:
582 tmp = 10*numpy.log10(10.0*getattr(dataOut, 'data_param')[:,0,:]/(factor))
582 if self.attr_data[0]=='S':
583 tmp = 10*numpy.log10(10.0*getattr(dataOut, 'data_param')[:,0,:]/(factor))
584 if self.attr_data[0]=='SNR':
585 tmp = 10*numpy.log10(getattr(dataOut, 'data_param')[:,3,:])
583 586 else:
584 587 tmp = getattr(dataOut, 'data_param')[:,vars[self.attr_data[0]],:]
585 588
@@ -610,6 +613,12 class WeatherParamsPlot(Plot):
610 613
611 614 data['azi'] = dataOut.data_azi
612 615 data['ele'] = dataOut.data_ele
616
617 if isinstance(dataOut.mode_op, bytes):
618 try:
619 dataOut.mode_op = dataOut.mode_op.decode()
620 except:
621 dataOut.mode_op = str(dataOut.mode_op, 'utf-8')
613 622 data['mode_op'] = dataOut.mode_op
614 623 self.mode = dataOut.mode_op
615 624
@@ -634,7 +643,7 class WeatherParamsPlot(Plot):
634 643 len_aux = int(data['azi'].shape[0]/4)
635 644 mean = numpy.mean(data['azi'][len_aux:-len_aux])
636 645 x, y = r*numpy.cos(theta), r*numpy.sin(theta)
637 elif data['mode_op'] == 'PPI':
646 elif data['mode_op'] == 'PPI':
638 647 r, theta = numpy.meshgrid(r, -numpy.radians(data['azi'])+numpy.pi/2)
639 648 len_aux = int(data['ele'].shape[0]/4)
640 649 mean = numpy.mean(data['ele'][len_aux:-len_aux])
@@ -654,7 +663,7 class WeatherParamsPlot(Plot):
654 663 norm = cb_tables[self.colormap]['norm']
655 664 else:
656 665 norm = None
657
666
658 667 for i, ax in enumerate(axes):
659 668 if data['mode_op'] == 'PPI':
660 669 ax.set_extent([-75.745893, -74.845893, -12.490436, -11.590436])
@@ -687,6 +696,8 class WeatherParamsPlot(Plot):
687 696 gl.ylabel_style = {'size': 8}
688 697 gl.xlabels_top = False
689 698 gl.ylabels_right = False
699 #self.shapes="/home/soporte/workspace/sirm/volumes/schain/shapes/"
700 #print("self.shapes",self.shapes)
690 701 shape_p = os.path.join(self.shapes,'PER_ADM2/PER_ADM2.shp')
691 702 shape_d = os.path.join(self.shapes,'PER_ADM1/PER_ADM1.shp')
692 703 capitales = os.path.join(self.shapes,'CAPITALES/cap_provincia.shp')
@@ -695,7 +706,7 class WeatherParamsPlot(Plot):
695 706 reader_p = shpreader.BasicReader(shape_d, encoding='latin1')
696 707 reader_c = shpreader.BasicReader(capitales, encoding='latin1')
697 708 reader_v = shpreader.BasicReader(vias, encoding='latin1')
698 caps = [x for x in reader_c.records() if x.attributes["Departa"] in ("JUNIN", "LIMA", "AYACUCHO", "HUANCAVELICA")]
709 caps = [x for x in reader_c.records() if x.attributes["Departa"] in ("JUNIN", "LIMA", "AYACUCHO", "HUANCAVELICA")]
699 710 districts = [x for x in reader_d.records() if x.attributes["Name"] in ("JUNÍN", "CHANCHAMAYO", "CHUPACA", "CONCEPCIÓN", "HUANCAYO", "JAUJA", "SATIPO", "TARMA", "YAUYOS", "HUAROCHIRÍ", "CANTA", "HUANTA", "TAYACAJA")]
700 711 provs = [x for x in reader_p.records() if x.attributes["NAME"] in ("Junín", "Lima")]
701 712 vias = [x for x in reader_v.records() if x.attributes["DEP"] in ("JUNIN", "LIMA")]
@@ -713,13 +724,13 class WeatherParamsPlot(Plot):
713 724 ax.text(cap.attributes['X'], cap.attributes['Y'], cap.attributes['Nombre'].title(), size=7, color='white')
714 725 ax.text(-75.052003, -11.915552, 'Huaytapallana', size=7, color='cyan')
715 726 ax.plot(-75.052003, -11.915552, '*')
716
727
717 728 for R in (10, 20, 30 , 40, 50):
718 729 circle = Circle((-75.295893, -12.040436), km2deg(R), facecolor='none',
719 730 edgecolor='skyblue', linewidth=1, alpha=0.5)
720 731 ax.add_patch(circle)
721 ax.text(km2deg(R)*numpy.cos(numpy.radians(45))-75.295893,
722 km2deg(R)*numpy.sin(numpy.radians(45))-12.040436,
732 ax.text(km2deg(R)*numpy.cos(numpy.radians(45))-75.295893,
733 km2deg(R)*numpy.sin(numpy.radians(45))-12.040436,
723 734 '{}km'.format(R), color='skyblue', size=7)
724 735 elif data['mode_op'] == 'RHI':
725 736 ax.grid(color='grey', alpha=0.5, linestyle='--', linewidth=1)
@@ -43,7 +43,7 class SpectraPlot(Plot):
43 43 data['spc'] = spc
44 44 data['rti'] = dataOut.getPower()
45 45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
46 meta['xrange'] = (dataOut.getFreqRange(0)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(0))
47 47
48 48 if self.CODE == 'spc_moments':
49 49 data['moments'] = dataOut.moments
@@ -26,6 +26,7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecora
26 26
27 27 import pickle
28 28 try:
29 os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
29 30 import digital_rf
30 31 except:
31 32 pass
@@ -267,9 +268,14 class DigitalRFReader(ProcessingUnit):
267 268
268 269 self.getByBlock = getByBlock
269 270 self.nProfileBlocks = nProfileBlocks
271 if online:
272 print('Waiting for RF data..')
273 sleep(40)
274
270 275 if not os.path.isdir(path):
271 276 raise ValueError("[Reading] Directory %s does not exist" % path)
272 277
278 #print("path",path)
273 279 try:
274 280 self.digitalReadObj = digital_rf.DigitalRFReader(
275 281 path, load_all_metadata=True)
@@ -350,29 +356,27 class DigitalRFReader(ProcessingUnit):
350 356 if startDate:
351 357 startDatetime = datetime.datetime.combine(startDate, startTime)
352 358 startUTCSecond = (
353 startDatetime - datetime.datetime(1970, 1, 1)).total_seconds() + self.__timezone
359 startDatetime - datetime.datetime(1970, 1, 1)).total_seconds()# + self.__timezone
354 360
355 361 if endDate:
356 362 endDatetime = datetime.datetime.combine(endDate, endTime)
357 363 endUTCSecond = (endDatetime - datetime.datetime(1970,
358 1, 1)).total_seconds() + self.__timezone
359
360
361 #print(startUTCSecond,endUTCSecond)
362 start_index, end_index = self.digitalReadObj.get_bounds(
363 channelNameList[channelList[0]])
364
365 #print("*****",start_index,end_index)
364 1, 1)).total_seconds()# + self.__timezone
365 start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]])
366 if start_index==None or end_index==None:
367 print("Check error No data, start_index: ",start_index,",end_index: ",end_index)
368 #return 0
366 369 if not startUTCSecond:
367 370 startUTCSecond = start_index / self.__sample_rate
368
369 371 if start_index > startUTCSecond * self.__sample_rate:
370 372 startUTCSecond = start_index / self.__sample_rate
371 373
372 374 if not endUTCSecond:
373 375 endUTCSecond = end_index / self.__sample_rate
376
374 377 if end_index < endUTCSecond * self.__sample_rate:
375 378 endUTCSecond = end_index / self.__sample_rate #Check UTC and LT time
379
376 380 if not nSamples:
377 381 if not ippKm:
378 382 raise ValueError("[Reading] nSamples or ippKm should be defined")
@@ -428,6 +432,7 class DigitalRFReader(ProcessingUnit):
428 432
429 433 #self.__data_buffer = numpy.zeros(
430 434 # (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex)
435 print("samplestoread",self.__samples_to_read)
431 436 self.__data_buffer = numpy.zeros((int(len(channelList)), self.__samples_to_read), dtype=numpy.complex)
432 437
433 438
@@ -442,9 +447,7 class DigitalRFReader(ProcessingUnit):
442 447 ))
443 448
444 449 print("[Reading] Starting process from %s to %s" % (datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone),
445 datetime.datetime.utcfromtimestamp(
446 endUTCSecond - self.__timezone)
447 ))
450 datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone)))
448 451 self.oldAverage = None
449 452 self.count = 0
450 453 self.executionTime = 0
@@ -532,9 +535,11 class DigitalRFReader(ProcessingUnit):
532 535 for indexSubchannel in range(self.__num_subchannels):
533 536 try:
534 537 t0 = time()
538 #print("thisUNixSample",self.__thisUnixSample)
535 539 result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample,
536 540 self.__samples_to_read,
537 541 thisChannelName, sub_channel=indexSubchannel)
542 #print("result--------------",result)
538 543 self.executionTime = time() - t0
539 544 if self.oldAverage is None:
540 545 self.oldAverage = self.executionTime
@@ -546,7 +551,21 class DigitalRFReader(ProcessingUnit):
546 551 # read next profile
547 552 self.__flagDiscontinuousBlock = True
548 553 print("[Reading] %s" % datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e)
549 break
554 bot = 0
555 while(self.__flagDiscontinuousBlock):
556 bot +=1
557 self.__thisUnixSample += self.__sample_rate
558 try:
559 result = result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample,self.__samples_to_read,thisChannelName, sub_channel=indexSubchannel)
560 self.__flagDiscontinuousBlock=False
561 print("Searching.. N°: ",bot,"Success",self.__thisUnixSample)
562 except:
563 print("Searching...N°: ",bot,"Fail", self.__thisUnixSample)
564 if self.__flagDiscontinuousBlock==True:
565 break
566 else:
567 print("New data index found...",self.__thisUnixSample)
568 #break
550 569
551 570 if result.shape[0] != self.__samples_to_read:
552 571 self.__flagDiscontinuousBlock = True
@@ -3950,7 +3950,9 class WeatherRadar(Operation):
3950 3950 self.nHeis = dataOut.nHeights
3951 3951 self.min_index= min_index
3952 3952 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
3953 self.Range = numpy.arange(dataOut.nHeights)*deltaHeight + dataOut.heightList[0]+min_index*deltaHeight
3953 #self.Range = numpy.arange(dataOut.nHeights)*deltaHeight + dataOut.heightList[0]+min_index*deltaHeight
3954 self.Range = dataOut.heightList
3955 print(self.Range, flush=True)
3954 3956 self.Range = self.Range.reshape(1,self.nHeis)
3955 3957 self.Range = numpy.tile(self.Range,[self.nCh,1])
3956 3958 '''-----------1 Constante del Radar----------'''
@@ -214,7 +214,7 def main(args):
214 214
215 215 opObj10 = proc1.addOperation(name="WeatherRadar")
216 216 opObj10.addParameter(name='tauW',value=(1e-6/sample_rate)*len(code[0]))
217 opObj10.addParameter(name='Pt',value=((1e-6/sample_rate)*len(code[0])/ipp)*200)
217 opObj10.addParameter(name='Pt',value=200)
218 218
219 219 op = proc1.addOperation(name='PedestalInformation')
220 220 op.addParameter(name='path', value=path_ped, format='str')
@@ -266,7 +266,7 def main(args):
266 266
267 267 opObj10 = proc2.addOperation(name="WeatherRadar")
268 268 opObj10.addParameter(name='tauW',value=(1e-6/sample_rate)*len(code[0]))
269 opObj10.addParameter(name='Pt',value=((1e-6/sample_rate)*len(code[0])/ipp)*200)
269 opObj10.addParameter(name='Pt',value=200)
270 270
271 271 op = proc2.addOperation(name='PedestalInformation')
272 272 op.addParameter(name='path', value=path_ped, format='str')
General Comments 0
You need to be logged in to leave comments. Login now