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