##// END OF EJS Templates
Add metadata attribute to data types
jespinoza -
r1338:317db0cd9a09
parent child
Show More
@@ -71,7 +71,8 class AMISR:
71 for key in list(inputObj.__dict__.keys()):
71 for key in list(inputObj.__dict__.keys()):
72 self.__dict__[key] = inputObj.__dict__[key]
72 self.__dict__[key] = inputObj.__dict__[key]
73
73
74 def getNHeights(self):
74 @property
75 def nHeights(self):
75
76
76 return len(self.heightList)
77 return len(self.heightList)
77
78
@@ -80,11 +81,7 class AMISR:
80
81
81 return self.flagNoData
82 return self.flagNoData
82
83
83 def getTimeInterval(self):
84 @property
85 def timeInterval(self):
84
86
85 timeInterval = self.ippSeconds * self.nCohInt
87 return self.ippSeconds * self.nCohInt
86
87 return timeInterval
88
89 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
90 nHeights = property(getNHeights, "I'm the 'nHeights' property.") No newline at end of file
@@ -1,8 +1,14
1 '''
1 # Copyright (c) 2012-2020 Jicamarca Radio Observatory
2 # All rights reserved.
3 #
4 # Distributed under the terms of the BSD 3-clause license.
5 """Definition of diferent Data objects for different types of data
2
6
3 $Author: murco $
7 Here you will find the diferent data objects for the different types
4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
8 of data, this data objects must be used as dataIn or dataOut objects in
5 '''
9 processing units and operations. Currently the supported data objects are:
10 Voltage, Spectra, SpectraHeis, Fits, Correlation and Parameters
11 """
6
12
7 import copy
13 import copy
8 import numpy
14 import numpy
@@ -152,17 +158,10 class GenericData(object):
152
158
153 class JROData(GenericData):
159 class JROData(GenericData):
154
160
155 # m_BasicHeader = BasicHeader()
156 # m_ProcessingHeader = ProcessingHeader()
157
158 systemHeaderObj = SystemHeader()
161 systemHeaderObj = SystemHeader()
159 radarControllerHeaderObj = RadarControllerHeader()
162 radarControllerHeaderObj = RadarControllerHeader()
160 # data = None
161 type = None
163 type = None
162 datatype = None # dtype but in string
164 datatype = None # dtype but in string
163 # dtype = None
164 # nChannels = None
165 # nHeights = None
166 nProfiles = None
165 nProfiles = None
167 heightList = None
166 heightList = None
168 channelList = None
167 channelList = None
@@ -173,18 +172,11 class JROData(GenericData):
173 dstFlag = None
172 dstFlag = None
174 errorCount = None
173 errorCount = None
175 blocksize = None
174 blocksize = None
176 # nCode = None
177 # nBaud = None
178 # code = None
179 flagDecodeData = False # asumo q la data no esta decodificada
175 flagDecodeData = False # asumo q la data no esta decodificada
180 flagDeflipData = False # asumo q la data no esta sin flip
176 flagDeflipData = False # asumo q la data no esta sin flip
181 flagShiftFFT = False
177 flagShiftFFT = False
182 # ippSeconds = None
183 # timeInterval = None
184 nCohInt = None
178 nCohInt = None
185 # noise = None
186 windowOfFilter = 1
179 windowOfFilter = 1
187 # Speed of ligth
188 C = 3e8
180 C = 3e8
189 frequency = 49.92e6
181 frequency = 49.92e6
190 realtime = False
182 realtime = False
@@ -198,50 +190,45 class JROData(GenericData):
198 error = None
190 error = None
199 data = None
191 data = None
200 nmodes = None
192 nmodes = None
193 metadata_list = ['heightList', 'timeZone', 'type']
201
194
202 def __str__(self):
195 def __str__(self):
203
196
204 return '{} - {}'.format(self.type, self.getDatatime())
197 return '{} - {}'.format(self.type, self.datatime())
205
198
206 def getNoise(self):
199 def getNoise(self):
207
200
208 raise NotImplementedError
201 raise NotImplementedError
209
202
210 def getNChannels(self):
203 @property
204 def nChannels(self):
211
205
212 return len(self.channelList)
206 return len(self.channelList)
213
207
214 def getChannelIndexList(self):
208 @property
209 def channelIndexList(self):
215
210
216 return list(range(self.nChannels))
211 return list(range(self.nChannels))
217
212
218 def getNHeights(self):
213 @property
214 def nHeights(self):
219
215
220 return len(self.heightList)
216 return len(self.heightList)
221
217
222 def getHeiRange(self, extrapoints=0):
223
224 heis = self.heightList
225 # deltah = self.heightList[1] - self.heightList[0]
226 #
227 # heis.append(self.heightList[-1])
228
229 return heis
230
231 def getDeltaH(self):
218 def getDeltaH(self):
232
219
233 delta = self.heightList[1] - self.heightList[0]
220 return self.heightList[1] - self.heightList[0]
234
221
235 return delta
222 @property
236
223 def ltctime(self):
237 def getltctime(self):
238
224
239 if self.useLocalTime:
225 if self.useLocalTime:
240 return self.utctime - self.timeZone * 60
226 return self.utctime - self.timeZone * 60
241
227
242 return self.utctime
228 return self.utctime
243
229
244 def getDatatime(self):
230 @property
231 def datatime(self):
245
232
246 datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
233 datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
247 return datatimeValue
234 return datatimeValue
@@ -281,85 +268,76 class JROData(GenericData):
281
268
282 return vmax
269 return vmax
283
270
284 def get_ippSeconds(self):
271 @property
272 def ippSeconds(self):
285 '''
273 '''
286 '''
274 '''
287 return self.radarControllerHeaderObj.ippSeconds
275 return self.radarControllerHeaderObj.ippSeconds
288
276
289 def set_ippSeconds(self, ippSeconds):
277 @ippSeconds.setter
278 def ippSeconds(self, ippSeconds):
290 '''
279 '''
291 '''
280 '''
292
293 self.radarControllerHeaderObj.ippSeconds = ippSeconds
281 self.radarControllerHeaderObj.ippSeconds = ippSeconds
294
282
295 return
283 @property
296
284 def code(self):
297 def get_dtype(self):
298 '''
285 '''
299 '''
286 '''
300 return getNumpyDtype(self.datatype)
287 return self.radarControllerHeaderObj.code
301
288
302 def set_dtype(self, numpyDtype):
289 @code.setter
290 def code(self, code):
303 '''
291 '''
304 '''
292 '''
293 self.radarControllerHeaderObj.code = code
305
294
306 self.datatype = getDataTypeCode(numpyDtype)
295 @property
307
296 def ncode(self):
308 def get_code(self):
309 '''
297 '''
310 '''
298 '''
311 return self.radarControllerHeaderObj.code
299 return self.radarControllerHeaderObj.nCode
312
300
313 def set_code(self, code):
301 @ncode.setter
302 def ncode(self, ncode):
314 '''
303 '''
315 '''
304 '''
316 self.radarControllerHeaderObj.code = code
305 self.radarControllerHeaderObj.nCode = ncode
317
306
318 return
307 @property
319
308 def nbaud(self):
320 def get_ncode(self):
321 '''
309 '''
322 '''
310 '''
323 return self.radarControllerHeaderObj.nCode
311 return self.radarControllerHeaderObj.nBaud
324
312
325 def set_ncode(self, nCode):
313 @nbaud.setter
314 def nbaud(self, nbaud):
326 '''
315 '''
327 '''
316 '''
328 self.radarControllerHeaderObj.nCode = nCode
317 self.radarControllerHeaderObj.nBaud = nbaud
329
318
330 return
319 @property
331
320 def ipp(self):
332 def get_nbaud(self):
333 '''
321 '''
334 '''
322 '''
335 return self.radarControllerHeaderObj.nBaud
323 return self.radarControllerHeaderObj.ipp
336
324
337 def set_nbaud(self, nBaud):
325 @ipp.setter
326 def ipp(self, ipp):
338 '''
327 '''
339 '''
328 '''
340 self.radarControllerHeaderObj.nBaud = nBaud
329 self.radarControllerHeaderObj.ipp = ipp
341
330
342 return
331 @property
332 def metadata(self):
333 '''
334 '''
343
335
344 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
336 return {attr: getattr(self, attr) for attr in self.metadata_list}
345 channelIndexList = property(
346 getChannelIndexList, "I'm the 'channelIndexList' property.")
347 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
348 #noise = property(getNoise, "I'm the 'nHeights' property.")
349 datatime = property(getDatatime, "I'm the 'datatime' property")
350 ltctime = property(getltctime, "I'm the 'ltctime' property")
351 ippSeconds = property(get_ippSeconds, set_ippSeconds)
352 dtype = property(get_dtype, set_dtype)
353 # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
354 code = property(get_code, set_code)
355 nCode = property(get_ncode, set_ncode)
356 nBaud = property(get_nbaud, set_nbaud)
357
337
358
338
359 class Voltage(JROData):
339 class Voltage(JROData):
360
340
361 # data es un numpy array de 2 dmensiones (canales, alturas)
362 data = None
363 dataPP_POW = None
341 dataPP_POW = None
364 dataPP_DOP = None
342 dataPP_DOP = None
365 dataPP_WIDTH = None
343 dataPP_WIDTH = None
@@ -375,13 +353,9 class Voltage(JROData):
375 self.systemHeaderObj = SystemHeader()
353 self.systemHeaderObj = SystemHeader()
376 self.type = "Voltage"
354 self.type = "Voltage"
377 self.data = None
355 self.data = None
378 # self.dtype = None
379 # self.nChannels = 0
380 # self.nHeights = 0
381 self.nProfiles = None
356 self.nProfiles = None
382 self.heightList = None
357 self.heightList = None
383 self.channelList = None
358 self.channelList = None
384 # self.channelIndexList = None
385 self.flagNoData = True
359 self.flagNoData = True
386 self.flagDiscontinuousBlock = False
360 self.flagDiscontinuousBlock = False
387 self.utctime = None
361 self.utctime = None
@@ -396,6 +370,8 class Voltage(JROData):
396 self.flagShiftFFT = False
370 self.flagShiftFFT = False
397 self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil
371 self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil
398 self.profileIndex = 0
372 self.profileIndex = 0
373 self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt',
374 'code', 'ncode', 'nbaud', 'ippSeconds', 'ipp']
399
375
400 def getNoisebyHildebrand(self, channel=None):
376 def getNoisebyHildebrand(self, channel=None):
401 """
377 """
@@ -444,36 +420,16 class Voltage(JROData):
444
420
445 return powerdB
421 return powerdB
446
422
447 def getTimeInterval(self):
423 @property
448
424 def timeInterval(self):
449 timeInterval = self.ippSeconds * self.nCohInt
450
425
451 return timeInterval
426 return self.ippSeconds * self.nCohInt
452
427
453 noise = property(getNoise, "I'm the 'nHeights' property.")
428 noise = property(getNoise, "I'm the 'nHeights' property.")
454 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
455
429
456
430
457 class Spectra(JROData):
431 class Spectra(JROData):
458
432
459 # data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas)
460 data_spc = None
461 # data cspc es un numpy array de 2 dmensiones (canales, pares, alturas)
462 data_cspc = None
463 # data dc es un numpy array de 2 dmensiones (canales, alturas)
464 data_dc = None
465 # data power
466 data_pwr = None
467 nFFTPoints = None
468 # nPairs = None
469 pairsList = None
470 nIncohInt = None
471 wavelength = None # Necesario para cacular el rango de velocidad desde la frecuencia
472 nCohInt = None # se requiere para determinar el valor de timeInterval
473 ippFactor = None
474 profileIndex = 0
475 plotting = "spectra"
476
477 def __init__(self):
433 def __init__(self):
478 '''
434 '''
479 Constructor
435 Constructor
@@ -484,14 +440,9 class Spectra(JROData):
484 self.systemHeaderObj = SystemHeader()
440 self.systemHeaderObj = SystemHeader()
485 self.type = "Spectra"
441 self.type = "Spectra"
486 self.timeZone = 0
442 self.timeZone = 0
487 # self.data = None
488 # self.dtype = None
489 # self.nChannels = 0
490 # self.nHeights = 0
491 self.nProfiles = None
443 self.nProfiles = None
492 self.heightList = None
444 self.heightList = None
493 self.channelList = None
445 self.channelList = None
494 # self.channelIndexList = None
495 self.pairsList = None
446 self.pairsList = None
496 self.flagNoData = True
447 self.flagNoData = True
497 self.flagDiscontinuousBlock = False
448 self.flagDiscontinuousBlock = False
@@ -505,9 +456,10 class Spectra(JROData):
505 self.flagDeflipData = False # asumo q la data no esta sin flip
456 self.flagDeflipData = False # asumo q la data no esta sin flip
506 self.flagShiftFFT = False
457 self.flagShiftFFT = False
507 self.ippFactor = 1
458 self.ippFactor = 1
508 #self.noise = None
509 self.beacon_heiIndexList = []
459 self.beacon_heiIndexList = []
510 self.noise_estimation = None
460 self.noise_estimation = None
461 self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt',
462 'code', 'ncode', 'nbaud', 'ippSeconds', 'ipp','nIncohInt', 'nFFTPoints', 'nProfiles']
511
463
512 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
464 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
513 """
465 """
@@ -567,15 +519,18 class Spectra(JROData):
567 else:
519 else:
568 return velrange
520 return velrange
569
521
570 def getNPairs(self):
522 @property
523 def nPairs(self):
571
524
572 return len(self.pairsList)
525 return len(self.pairsList)
573
526
574 def getPairsIndexList(self):
527 @property
528 def pairsIndexList(self):
575
529
576 return list(range(self.nPairs))
530 return list(range(self.nPairs))
577
531
578 def getNormFactor(self):
532 @property
533 def normFactor(self):
579
534
580 pwcode = 1
535 pwcode = 1
581
536
@@ -586,21 +541,24 class Spectra(JROData):
586
541
587 return normFactor
542 return normFactor
588
543
589 def getFlagCspc(self):
544 @property
545 def flag_cspc(self):
590
546
591 if self.data_cspc is None:
547 if self.data_cspc is None:
592 return True
548 return True
593
549
594 return False
550 return False
595
551
596 def getFlagDc(self):
552 @property
553 def flag_dc(self):
597
554
598 if self.data_dc is None:
555 if self.data_dc is None:
599 return True
556 return True
600
557
601 return False
558 return False
602
559
603 def getTimeInterval(self):
560 @property
561 def timeInterval(self):
604
562
605 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles * self.ippFactor
563 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles * self.ippFactor
606 if self.nmodes:
564 if self.nmodes:
@@ -651,68 +609,29 class Spectra(JROData):
651
609
652 return
610 return
653
611
654 nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.")
655 pairsIndexList = property(
656 getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.")
657 normFactor = property(getNormFactor, setValue,
658 "I'm the 'getNormFactor' property.")
659 flag_cspc = property(getFlagCspc, setValue)
660 flag_dc = property(getFlagDc, setValue)
661 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
612 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
662 timeInterval = property(getTimeInterval, setValue,
663 "I'm the 'timeInterval' property")
664
613
665
614
666 class SpectraHeis(Spectra):
615 class SpectraHeis(Spectra):
667
616
668 data_spc = None
669 data_cspc = None
670 data_dc = None
671 nFFTPoints = None
672 # nPairs = None
673 pairsList = None
674 nCohInt = None
675 nIncohInt = None
676
677 def __init__(self):
617 def __init__(self):
678
618
679 self.radarControllerHeaderObj = RadarControllerHeader()
619 self.radarControllerHeaderObj = RadarControllerHeader()
680
681 self.systemHeaderObj = SystemHeader()
620 self.systemHeaderObj = SystemHeader()
682
683 self.type = "SpectraHeis"
621 self.type = "SpectraHeis"
684
685 # self.dtype = None
686
687 # self.nChannels = 0
688
689 # self.nHeights = 0
690
691 self.nProfiles = None
622 self.nProfiles = None
692
693 self.heightList = None
623 self.heightList = None
694
695 self.channelList = None
624 self.channelList = None
696
697 # self.channelIndexList = None
698
699 self.flagNoData = True
625 self.flagNoData = True
700
701 self.flagDiscontinuousBlock = False
626 self.flagDiscontinuousBlock = False
702
703 # self.nPairs = 0
704
705 self.utctime = None
627 self.utctime = None
706
707 self.blocksize = None
628 self.blocksize = None
708
709 self.profileIndex = 0
629 self.profileIndex = 0
710
711 self.nCohInt = 1
630 self.nCohInt = 1
712
713 self.nIncohInt = 1
631 self.nIncohInt = 1
714
632
715 def getNormFactor(self):
633 @property
634 def normFactor(self):
716 pwcode = 1
635 pwcode = 1
717 if self.flagDecodeData:
636 if self.flagDecodeData:
718 pwcode = numpy.sum(self.code[0]**2)
637 pwcode = numpy.sum(self.code[0]**2)
@@ -721,86 +640,27 class SpectraHeis(Spectra):
721
640
722 return normFactor
641 return normFactor
723
642
724 def getTimeInterval(self):
643 @property
725
644 def timeInterval(self):
726 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
727
728 return timeInterval
729
645
730 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
646 return self.ippSeconds * self.nCohInt * self.nIncohInt
731 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
732
647
733
648
734 class Fits(JROData):
649 class Fits(JROData):
735
650
736 heightList = None
737 channelList = None
738 flagNoData = True
739 flagDiscontinuousBlock = False
740 useLocalTime = False
741 utctime = None
742 # ippSeconds = None
743 # timeInterval = None
744 nCohInt = None
745 nIncohInt = None
746 noise = None
747 windowOfFilter = 1
748 # Speed of ligth
749 C = 3e8
750 frequency = 49.92e6
751 realtime = False
752
753 def __init__(self):
651 def __init__(self):
754
652
755 self.type = "Fits"
653 self.type = "Fits"
756
757 self.nProfiles = None
654 self.nProfiles = None
758
759 self.heightList = None
655 self.heightList = None
760
761 self.channelList = None
656 self.channelList = None
762
763 # self.channelIndexList = None
764
765 self.flagNoData = True
657 self.flagNoData = True
766
767 self.utctime = None
658 self.utctime = None
768
769 self.nCohInt = 1
659 self.nCohInt = 1
770
771 self.nIncohInt = 1
660 self.nIncohInt = 1
772
773 self.useLocalTime = True
661 self.useLocalTime = True
774
775 self.profileIndex = 0
662 self.profileIndex = 0
776
777 # self.utctime = None
778 self.timeZone = 0
663 self.timeZone = 0
779 # self.ltctime = None
780 # self.timeInterval = None
781 # self.header = None
782 # self.data_header = None
783 # self.data = None
784 # self.datatime = None
785 # self.flagNoData = False
786 # self.expName = ''
787 # self.nChannels = None
788 # self.nSamples = None
789 # self.dataBlocksPerFile = None
790 # self.comments = ''
791 #
792
793 def getltctime(self):
794
795 if self.useLocalTime:
796 return self.utctime - self.timeZone * 60
797
798 return self.utctime
799
800 def getDatatime(self):
801
802 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
803 return datatime
804
664
805 def getTimeRange(self):
665 def getTimeRange(self):
806
666
@@ -813,27 +673,12 class Fits(JROData):
813
673
814 return datatime
674 return datatime
815
675
816 def getHeiRange(self):
817
818 heis = self.heightList
819
820 return heis
821
822 def getNHeights(self):
823
824 return len(self.heightList)
825
826 def getNChannels(self):
827
828 return len(self.channelList)
829
830 def getChannelIndexList(self):
676 def getChannelIndexList(self):
831
677
832 return list(range(self.nChannels))
678 return list(range(self.nChannels))
833
679
834 def getNoise(self, type=1):
680 def getNoise(self, type=1):
835
681
836 #noise = numpy.zeros(self.nChannels)
837
682
838 if type == 1:
683 if type == 1:
839 noise = self.getNoisebyHildebrand()
684 noise = self.getNoisebyHildebrand()
@@ -846,87 +691,46 class Fits(JROData):
846
691
847 return noise
692 return noise
848
693
849 def getTimeInterval(self):
694 @property
695 def timeInterval(self):
850
696
851 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
697 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
852
698
853 return timeInterval
699 return timeInterval
854
700
855 def get_ippSeconds(self):
701 @property
702 def ippSeconds(self):
856 '''
703 '''
857 '''
704 '''
858 return self.ipp_sec
705 return self.ipp_sec
859
706
860
861 datatime = property(getDatatime, "I'm the 'datatime' property")
862 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
863 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
864 channelIndexList = property(
865 getChannelIndexList, "I'm the 'channelIndexList' property.")
866 noise = property(getNoise, "I'm the 'nHeights' property.")
707 noise = property(getNoise, "I'm the 'nHeights' property.")
867
708
868 ltctime = property(getltctime, "I'm the 'ltctime' property")
869 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
870 ippSeconds = property(get_ippSeconds, '')
871
709
872 class Correlation(JROData):
710 class Correlation(JROData):
873
711
874 noise = None
875 SNR = None
876 #--------------------------------------------------
877 mode = None
878 split = False
879 data_cf = None
880 lags = None
881 lagRange = None
882 pairsList = None
883 normFactor = None
884 #--------------------------------------------------
885 # calculateVelocity = None
886 nLags = None
887 nPairs = None
888 nAvg = None
889
890 def __init__(self):
712 def __init__(self):
891 '''
713 '''
892 Constructor
714 Constructor
893 '''
715 '''
894 self.radarControllerHeaderObj = RadarControllerHeader()
716 self.radarControllerHeaderObj = RadarControllerHeader()
895
896 self.systemHeaderObj = SystemHeader()
717 self.systemHeaderObj = SystemHeader()
897
898 self.type = "Correlation"
718 self.type = "Correlation"
899
900 self.data = None
719 self.data = None
901
902 self.dtype = None
720 self.dtype = None
903
904 self.nProfiles = None
721 self.nProfiles = None
905
906 self.heightList = None
722 self.heightList = None
907
908 self.channelList = None
723 self.channelList = None
909
910 self.flagNoData = True
724 self.flagNoData = True
911
912 self.flagDiscontinuousBlock = False
725 self.flagDiscontinuousBlock = False
913
914 self.utctime = None
726 self.utctime = None
915
916 self.timeZone = 0
727 self.timeZone = 0
917
918 self.dstFlag = None
728 self.dstFlag = None
919
920 self.errorCount = None
729 self.errorCount = None
921
922 self.blocksize = None
730 self.blocksize = None
923
924 self.flagDecodeData = False # asumo q la data no esta decodificada
731 self.flagDecodeData = False # asumo q la data no esta decodificada
925
926 self.flagDeflipData = False # asumo q la data no esta sin flip
732 self.flagDeflipData = False # asumo q la data no esta sin flip
927
928 self.pairsList = None
733 self.pairsList = None
929
930 self.nPoints = None
734 self.nPoints = None
931
735
932 def getPairsList(self):
736 def getPairsList(self):
@@ -981,11 +785,10 class Correlation(JROData):
981
785
982 return noise
786 return noise
983
787
984 def getTimeInterval(self):
788 @property
789 def timeInterval(self):
985
790
986 timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles
791 return self.ippSeconds * self.nCohInt * self.nProfiles
987
988 return timeInterval
989
792
990 def splitFunctions(self):
793 def splitFunctions(self):
991
794
@@ -1011,7 +814,8 class Correlation(JROData):
1011
814
1012 return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf
815 return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf
1013
816
1014 def getNormFactor(self):
817 @property
818 def normFactor(self):
1015 acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions()
819 acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions()
1016 acf_pairs = numpy.array(acf_pairs)
820 acf_pairs = numpy.array(acf_pairs)
1017 normFactor = numpy.zeros((self.nPairs, self.nHeights))
821 normFactor = numpy.zeros((self.nPairs, self.nHeights))
@@ -1028,25 +832,14 class Correlation(JROData):
1028
832
1029 return normFactor
833 return normFactor
1030
834
1031 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
1032 normFactor = property(getNormFactor, "I'm the 'normFactor property'")
1033
1034
835
1035 class Parameters(Spectra):
836 class Parameters(Spectra):
1036
837
1037 experimentInfo = None # Information about the experiment
1038 # Information from previous data
1039 inputUnit = None # Type of data to be processed
1040 operation = None # Type of operation to parametrize
1041 # normFactor = None #Normalization Factor
1042 groupList = None # List of Pairs, Groups, etc
838 groupList = None # List of Pairs, Groups, etc
1043 # Parameters
1044 data_param = None # Parameters obtained
839 data_param = None # Parameters obtained
1045 data_pre = None # Data Pre Parametrization
840 data_pre = None # Data Pre Parametrization
1046 data_SNR = None # Signal to Noise Ratio
841 data_SNR = None # Signal to Noise Ratio
1047 # heightRange = None #Heights
1048 abscissaList = None # Abscissa, can be velocities, lags or time
842 abscissaList = None # Abscissa, can be velocities, lags or time
1049 # noise = None #Noise Potency
1050 utctimeInit = None # Initial UTC time
843 utctimeInit = None # Initial UTC time
1051 paramInterval = None # Time interval to calculate Parameters in seconds
844 paramInterval = None # Time interval to calculate Parameters in seconds
1052 useLocalTime = True
845 useLocalTime = True
@@ -1085,7 +878,8 class Parameters(Spectra):
1085
878
1086 return datatime
879 return datatime
1087
880
1088 def getTimeInterval(self):
881 @property
882 def timeInterval(self):
1089
883
1090 if hasattr(self, 'timeInterval1'):
884 if hasattr(self, 'timeInterval1'):
1091 return self.timeInterval1
885 return self.timeInterval1
@@ -1102,7 +896,6 class Parameters(Spectra):
1102
896
1103 return self.spc_noise
897 return self.spc_noise
1104
898
1105 timeInterval = property(getTimeInterval)
1106 noise = property(getNoise, setValue, "I'm the 'Noise' property.")
899 noise = property(getNoise, setValue, "I'm the 'Noise' property.")
1107
900
1108
901
@@ -1220,7 +1013,7 class PlotterData(object):
1220 if hasattr(dataOut, 'pairsList'):
1013 if hasattr(dataOut, 'pairsList'):
1221 self.pairs = dataOut.pairsList
1014 self.pairs = dataOut.pairsList
1222
1015
1223 self.interval = dataOut.getTimeInterval()
1016 self.interval = dataOut.timeInterval
1224 if True in ['spc' in ptype for ptype in self.plottypes]:
1017 if True in ['spc' in ptype for ptype in self.plottypes]:
1225 self.xrange = (dataOut.getFreqRange(1)/1000.,
1018 self.xrange = (dataOut.getFreqRange(1)/1000.,
1226 dataOut.getAcfRange(1), dataOut.getVelRange(1))
1019 dataOut.getAcfRange(1), dataOut.getVelRange(1))
@@ -1182,8 +1182,6 class JRODataReader(Reader):
1182
1182
1183 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs
1183 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs
1184
1184
1185 # self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs
1186
1187 def getFirstHeader(self):
1185 def getFirstHeader(self):
1188
1186
1189 raise NotImplementedError
1187 raise NotImplementedError
@@ -115,7 +115,7 class DigitalRFReader(ProcessingUnit):
115
115
116 self.dataOut.channelList = list(range(self.__num_subchannels))
116 self.dataOut.channelList = list(range(self.__num_subchannels))
117
117
118 self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights()
118 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
119
119
120 # self.dataOut.channelIndexList = None
120 # self.dataOut.channelIndexList = None
121
121
@@ -764,7 +764,7 class HFReader(ProcessingUnit):
764
764
765 self.dataOut.nCohInt = 1
765 self.dataOut.nCohInt = 1
766
766
767 self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights()
767 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
768
768
769 self.dataOut.flagDecodeData = False #asumo que la data esta decodificada
769 self.dataOut.flagDecodeData = False #asumo que la data esta decodificada
770
770
@@ -498,7 +498,7 class AMISRReader(ProcessingUnit):
498
498
499 self.dataOut.channelList = self.__channelList
499 self.dataOut.channelList = self.__channelList
500
500
501 self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights()
501 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
502
502
503 # self.dataOut.channelIndexList = None
503 # self.dataOut.channelIndexList = None
504
504
@@ -699,7 +699,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
699 self.dataOut.utctime = dwell
699 self.dataOut.utctime = dwell
700 self.dataOut.timeZone = 0
700 self.dataOut.timeZone = 0
701
701
702 self.dataOut.outputInterval = self.dataOut.getTimeInterval()
702 self.dataOut.outputInterval = self.dataOut.timeInterval
703 self.dataOut.heightList = self.SPARrawGate1 * self.__deltaHeigth + \
703 self.dataOut.heightList = self.SPARrawGate1 * self.__deltaHeigth + \
704 numpy.array(list(range(self.Num_Hei))) * self.__deltaHeigth
704 numpy.array(list(range(self.Num_Hei))) * self.__deltaHeigth
705
705
@@ -335,31 +335,31 class SimulatorReader(JRODataReader, ProcessingUnit):
335 self.datablock = numpy.zeros([channels,prof_gen,Samples],dtype= numpy.complex64)
335 self.datablock = numpy.zeros([channels,prof_gen,Samples],dtype= numpy.complex64)
336 for i in range(channels):
336 for i in range(channels):
337 for k in range(prof_gen):
337 for k in range(prof_gen):
338 #·······················NOISE···············
338 #-----------------------NOISE---------------
339 Noise_r = numpy.random.normal(DC_level,stdev,Samples)
339 Noise_r = numpy.random.normal(DC_level,stdev,Samples)
340 Noise_i = numpy.random.normal(DC_level,stdev,Samples)
340 Noise_i = numpy.random.normal(DC_level,stdev,Samples)
341 Noise = numpy.zeros(Samples,dtype=complex)
341 Noise = numpy.zeros(Samples,dtype=complex)
342 Noise.real = Noise_r
342 Noise.real = Noise_r
343 Noise.imag = Noise_i
343 Noise.imag = Noise_i
344 #·······················PULSOS··············
344 #-----------------------PULSOS--------------
345 Pulso = numpy.zeros(pulse_size,dtype=complex)
345 Pulso = numpy.zeros(pulse_size,dtype=complex)
346 Pulso.real = pulses[k%num_codes]
346 Pulso.real = pulses[k%num_codes]
347 Pulso.imag = pulses[k%num_codes]
347 Pulso.imag = pulses[k%num_codes]
348 #····················· PULSES+NOISE··········
348 #--------------------- PULSES+NOISE----------
349 InBuffer = numpy.zeros(Samples,dtype=complex)
349 InBuffer = numpy.zeros(Samples,dtype=complex)
350 InBuffer[m_nR:m_nR+ps] = Pulso
350 InBuffer[m_nR:m_nR+ps] = Pulso
351 InBuffer = InBuffer+Noise
351 InBuffer = InBuffer+Noise
352 #····················· ANGLE ·······························
352 #--------------------- ANGLE -------------------------------
353 InBuffer.real[m_nR:m_nR+ps] = InBuffer.real[m_nR:m_nR+ps]*(math.cos( self.fAngle)*5)
353 InBuffer.real[m_nR:m_nR+ps] = InBuffer.real[m_nR:m_nR+ps]*(math.cos( self.fAngle)*5)
354 InBuffer.imag[m_nR:m_nR+ps] = InBuffer.imag[m_nR:m_nR+ps]*(math.sin( self.fAngle)*5)
354 InBuffer.imag[m_nR:m_nR+ps] = InBuffer.imag[m_nR:m_nR+ps]*(math.sin( self.fAngle)*5)
355 InBuffer=InBuffer
355 InBuffer=InBuffer
356 self.datablock[i][k]= InBuffer
356 self.datablock[i][k]= InBuffer
357
357
358 #················DOPPLER SIGNAL...............................................
358 #----------------DOPPLER SIGNAL...............................................
359 time_vec = numpy.linspace(0,(prof_gen-1)*ippSec,int(prof_gen))+self.nReadBlocks*ippSec*prof_gen+(self.nReadFiles-1)*ippSec*prof_gen
359 time_vec = numpy.linspace(0,(prof_gen-1)*ippSec,int(prof_gen))+self.nReadBlocks*ippSec*prof_gen+(self.nReadFiles-1)*ippSec*prof_gen
360 fd = Fdoppler #+(600.0/120)*self.nReadBlocks
360 fd = Fdoppler #+(600.0/120)*self.nReadBlocks
361 d_signal = Adoppler*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64)
361 d_signal = Adoppler*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64)
362 #·············Señal con ancho espectral····················
362 #-------------Senal con ancho espectral--------------------
363 if prof_gen%2==0:
363 if prof_gen%2==0:
364 min = int(prof_gen/2.0-1.0)
364 min = int(prof_gen/2.0-1.0)
365 max = int(prof_gen/2.0)
365 max = int(prof_gen/2.0)
@@ -372,11 +372,11 class SimulatorReader(JRODataReader, ProcessingUnit):
372 specw_sig = specw_sig/w
372 specw_sig = specw_sig/w
373 specw_sig = numpy.sinc(specw_sig)
373 specw_sig = numpy.sinc(specw_sig)
374 specw_sig = A*numpy.array(specw_sig,dtype=numpy.complex64)
374 specw_sig = A*numpy.array(specw_sig,dtype=numpy.complex64)
375 #·················· DATABLOCK + DOPPLER····················
375 #------------------ DATABLOCK + DOPPLER--------------------
376 HD=int(Hdoppler/self.AcqDH_0)
376 HD=int(Hdoppler/self.AcqDH_0)
377 for i in range(12):
377 for i in range(12):
378 self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ d_signal# RESULT
378 self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ d_signal# RESULT
379 #·················· DATABLOCK + DOPPLER*Sinc(x)····················
379 #------------------ DATABLOCK + DOPPLER*Sinc(x)--------------------
380 HD=int(Hdoppler/self.AcqDH_0)
380 HD=int(Hdoppler/self.AcqDH_0)
381 HD=int(HD/2)
381 HD=int(HD/2)
382 for i in range(12):
382 for i in range(12):
@@ -90,7 +90,7 class USRPReader(ProcessingUnit):
90
90
91 self.dataOut.channelList = self.__channelList
91 self.dataOut.channelList = self.__channelList
92
92
93 self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights()
93 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
94
94
95 # self.dataOut.channelIndexList = None
95 # self.dataOut.channelIndexList = None
96
96
@@ -136,11 +136,8 class SpectraHeisProc(ProcessingUnit):
136
136
137 for channelIndex in channelIndexList:
137 for channelIndex in channelIndexList:
138 if channelIndex not in self.dataOut.channelIndexList:
138 if channelIndex not in self.dataOut.channelIndexList:
139 print(channelIndexList)
140 raise ValueError("The value %d in channelIndexList is not valid" %channelIndex)
139 raise ValueError("The value %d in channelIndexList is not valid" %channelIndex)
141
140
142 # nChannels = len(channelIndexList)
143
144 data_spc = self.dataOut.data_spc[channelIndexList,:]
141 data_spc = self.dataOut.data_spc[channelIndexList,:]
145
142
146 self.dataOut.data_spc = data_spc
143 self.dataOut.data_spc = data_spc
@@ -78,9 +78,9 class ParametersProc(ProcessingUnit):
78 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
78 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
79 # self.dataOut.nHeights = self.dataIn.nHeights
79 # self.dataOut.nHeights = self.dataIn.nHeights
80 # self.dataOut.nChannels = self.dataIn.nChannels
80 # self.dataOut.nChannels = self.dataIn.nChannels
81 self.dataOut.nBaud = self.dataIn.nBaud
81 # self.dataOut.nBaud = self.dataIn.nBaud
82 self.dataOut.nCode = self.dataIn.nCode
82 # self.dataOut.nCode = self.dataIn.nCode
83 self.dataOut.code = self.dataIn.code
83 # self.dataOut.code = self.dataIn.code
84 # self.dataOut.nProfiles = self.dataOut.nFFTPoints
84 # self.dataOut.nProfiles = self.dataOut.nFFTPoints
85 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
85 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
86 # self.dataOut.utctime = self.firstdatatime
86 # self.dataOut.utctime = self.firstdatatime
@@ -89,10 +89,10 class ParametersProc(ProcessingUnit):
89 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
89 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
90 self.dataOut.nCohInt = self.dataIn.nCohInt
90 self.dataOut.nCohInt = self.dataIn.nCohInt
91 # self.dataOut.nIncohInt = 1
91 # self.dataOut.nIncohInt = 1
92 self.dataOut.ippSeconds = self.dataIn.ippSeconds
92 # self.dataOut.ippSeconds = self.dataIn.ippSeconds
93 # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
93 # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
94 self.dataOut.timeInterval1 = self.dataIn.timeInterval
94 self.dataOut.timeInterval1 = self.dataIn.timeInterval
95 self.dataOut.heightList = self.dataIn.getHeiRange()
95 self.dataOut.heightList = self.dataIn.heightList
96 self.dataOut.frequency = self.dataIn.frequency
96 self.dataOut.frequency = self.dataIn.frequency
97 # self.dataOut.noise = self.dataIn.noise
97 # self.dataOut.noise = self.dataIn.noise
98
98
@@ -2770,7 +2770,7 class SMDetection(Operation):
2770 channelPositions = [(4.5,2), (2,4.5), (2,2), (2,0), (0,2)] #Estrella
2770 channelPositions = [(4.5,2), (2,4.5), (2,2), (2,0), (0,2)] #Estrella
2771 meteorOps = SMOperations()
2771 meteorOps = SMOperations()
2772 pairslist0, distances = meteorOps.getPhasePairs(channelPositions)
2772 pairslist0, distances = meteorOps.getPhasePairs(channelPositions)
2773 heiRang = dataOut.getHeiRange()
2773 heiRang = dataOut.heightList
2774 #Get Beacon signal - No Beacon signal anymore
2774 #Get Beacon signal - No Beacon signal anymore
2775 # newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
2775 # newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
2776 #
2776 #
@@ -2832,7 +2832,7 class SMDetection(Operation):
2832
2832
2833 #************** REMOVE MULTIPLE DETECTIONS (3.5) ***************************
2833 #************** REMOVE MULTIPLE DETECTIONS (3.5) ***************************
2834 #Parameters
2834 #Parameters
2835 heiRange = dataOut.getHeiRange()
2835 heiRange = dataOut.heightList
2836 rangeInterval = heiRange[1] - heiRange[0]
2836 rangeInterval = heiRange[1] - heiRange[0]
2837 rangeLimit = multDet_rangeLimit/rangeInterval
2837 rangeLimit = multDet_rangeLimit/rangeInterval
2838 timeLimit = multDet_timeLimit/dataOut.timeInterval
2838 timeLimit = multDet_timeLimit/dataOut.timeInterval
@@ -1,3 +1,13
1 # Copyright (c) 2012-2020 Jicamarca Radio Observatory
2 # All rights reserved.
3 #
4 # Distributed under the terms of the BSD 3-clause license.
5 """Spectra processing Unit and operations
6
7 Here you will find the processing unit `SpectraProc` and several operations
8 to work with Spectra data type
9 """
10
1 import time
11 import time
2 import itertools
12 import itertools
3
13
@@ -11,7 +21,6 from schainpy.utils import log
11
21
12 class SpectraProc(ProcessingUnit):
22 class SpectraProc(ProcessingUnit):
13
23
14
15 def __init__(self):
24 def __init__(self):
16
25
17 ProcessingUnit.__init__(self)
26 ProcessingUnit.__init__(self)
@@ -35,35 +44,24 class SpectraProc(ProcessingUnit):
35 except:
44 except:
36 pass
45 pass
37 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
46 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
47
38 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
48 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
39 self.dataOut.channelList = self.dataIn.channelList
49 self.dataOut.channelList = self.dataIn.channelList
40 self.dataOut.heightList = self.dataIn.heightList
50 self.dataOut.heightList = self.dataIn.heightList
41 self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
51 self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
42
43 self.dataOut.nBaud = self.dataIn.nBaud
44 self.dataOut.nCode = self.dataIn.nCode
45 self.dataOut.code = self.dataIn.code
46 self.dataOut.nProfiles = self.dataOut.nFFTPoints
52 self.dataOut.nProfiles = self.dataOut.nFFTPoints
47
48 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
53 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
49 self.dataOut.utctime = self.firstdatatime
54 self.dataOut.utctime = self.firstdatatime
50 # asumo q la data esta decodificada
51 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData
55 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData
52 # asumo q la data esta sin flip
53 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData
56 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData
54 self.dataOut.flagShiftFFT = False
57 self.dataOut.flagShiftFFT = False
55
56 self.dataOut.nCohInt = self.dataIn.nCohInt
58 self.dataOut.nCohInt = self.dataIn.nCohInt
57 self.dataOut.nIncohInt = 1
59 self.dataOut.nIncohInt = 1
58
59 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
60 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
60
61 self.dataOut.frequency = self.dataIn.frequency
61 self.dataOut.frequency = self.dataIn.frequency
62 self.dataOut.realtime = self.dataIn.realtime
62 self.dataOut.realtime = self.dataIn.realtime
63
64 self.dataOut.azimuth = self.dataIn.azimuth
63 self.dataOut.azimuth = self.dataIn.azimuth
65 self.dataOut.zenith = self.dataIn.zenith
64 self.dataOut.zenith = self.dataIn.zenith
66
67 self.dataOut.beam.codeList = self.dataIn.beam.codeList
65 self.dataOut.beam.codeList = self.dataIn.beam.codeList
68 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
66 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
69 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
67 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
@@ -120,7 +118,7 class SpectraProc(ProcessingUnit):
120 self.dataOut.blockSize = blocksize
118 self.dataOut.blockSize = blocksize
121 self.dataOut.flagShiftFFT = False
119 self.dataOut.flagShiftFFT = False
122
120
123 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None, shift_fft=False):
121 def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False):
124
122
125 if self.dataIn.type == "Spectra":
123 if self.dataIn.type == "Spectra":
126 self.dataOut.copy(self.dataIn)
124 self.dataOut.copy(self.dataIn)
@@ -133,9 +131,7 class SpectraProc(ProcessingUnit):
133 #desplaza a la derecha en el eje 2 determinadas posiciones
131 #desplaza a la derecha en el eje 2 determinadas posiciones
134 self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1)
132 self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1)
135
133
136 return True
134 elif self.dataIn.type == "Voltage":
137
138 if self.dataIn.type == "Voltage":
139
135
140 self.dataOut.flagNoData = True
136 self.dataOut.flagNoData = True
141
137
@@ -146,12 +142,9 class SpectraProc(ProcessingUnit):
146 nProfiles = nFFTPoints
142 nProfiles = nFFTPoints
147
143
148 if ippFactor == None:
144 if ippFactor == None:
149 ippFactor = 1
145 self.dataOut.ippFactor = 1
150
151 self.dataOut.ippFactor = ippFactor
152
146
153 self.dataOut.nFFTPoints = nFFTPoints
147 self.dataOut.nFFTPoints = nFFTPoints
154 self.dataOut.pairsList = pairsList
155
148
156 if self.buffer is None:
149 if self.buffer is None:
157 self.buffer = numpy.zeros((self.dataIn.nChannels,
150 self.buffer = numpy.zeros((self.dataIn.nChannels,
@@ -181,7 +174,6 class SpectraProc(ProcessingUnit):
181 raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % (
174 raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % (
182 self.dataIn.type, self.dataIn.data.shape[1], nProfiles))
175 self.dataIn.type, self.dataIn.data.shape[1], nProfiles))
183 self.dataOut.flagNoData = True
176 self.dataOut.flagNoData = True
184 return 0
185 else:
177 else:
186 self.buffer[:, self.profIndex, :] = self.dataIn.data.copy()
178 self.buffer[:, self.profIndex, :] = self.dataIn.data.copy()
187 self.profIndex += 1
179 self.profIndex += 1
@@ -191,15 +183,15 class SpectraProc(ProcessingUnit):
191
183
192 if self.profIndex == nProfiles:
184 if self.profIndex == nProfiles:
193 self.__updateSpecFromVoltage()
185 self.__updateSpecFromVoltage()
186 if pairsList == None:
187 self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)]
194 self.__getFft()
188 self.__getFft()
195
189
196 self.dataOut.flagNoData = False
190 self.dataOut.flagNoData = False
197 self.firstdatatime = None
191 self.firstdatatime = None
198 self.profIndex = 0
192 self.profIndex = 0
199
193 else:
200 return True
194 raise ValueError("The type of input object '%s' is not valid".format(
201
202 raise ValueError("The type of input object '%s' is not valid" % (
203 self.dataIn.type))
195 self.dataIn.type))
204
196
205 def __selectPairs(self, pairsList):
197 def __selectPairs(self, pairsList):
@@ -389,6 +389,8 class printAttribute(Operation):
389
389
390 def run(self, dataOut, attributes):
390 def run(self, dataOut, attributes):
391
391
392 if isinstance(attributes, str):
393 attributes = [attributes]
392 for attr in attributes:
394 for attr in attributes:
393 if hasattr(dataOut, attr):
395 if hasattr(dataOut, attr):
394 log.log(getattr(dataOut, attr), attr)
396 log.log(getattr(dataOut, attr), attr)
@@ -1369,17 +1371,17 class PulsePairVoltage(Operation):
1369 Return the PULSEPAIR and the profiles used in the operation
1371 Return the PULSEPAIR and the profiles used in the operation
1370 Affected : self.__profileIndex
1372 Affected : self.__profileIndex
1371 '''
1373 '''
1372 #················· Remove DC···································
1374 #----------------- Remove DC-----------------------------------
1373 if self.removeDC==True:
1375 if self.removeDC==True:
1374 mean = numpy.mean(self.__buffer,1)
1376 mean = numpy.mean(self.__buffer,1)
1375 tmp = mean.reshape(self.__nch,1,self.__nHeis)
1377 tmp = mean.reshape(self.__nch,1,self.__nHeis)
1376 dc= numpy.tile(tmp,[1,self.__nProf,1])
1378 dc= numpy.tile(tmp,[1,self.__nProf,1])
1377 self.__buffer = self.__buffer - dc
1379 self.__buffer = self.__buffer - dc
1378 #··················Calculo de Potencia ························
1380 #------------------Calculo de Potencia ------------------------
1379 pair0 = self.__buffer*numpy.conj(self.__buffer)
1381 pair0 = self.__buffer*numpy.conj(self.__buffer)
1380 pair0 = pair0.real
1382 pair0 = pair0.real
1381 lag_0 = numpy.sum(pair0,1)
1383 lag_0 = numpy.sum(pair0,1)
1382 #··················Calculo de Ruido x canal····················
1384 #------------------Calculo de Ruido x canal--------------------
1383 self.noise = numpy.zeros(self.__nch)
1385 self.noise = numpy.zeros(self.__nch)
1384 for i in range(self.__nch):
1386 for i in range(self.__nch):
1385 daux = numpy.sort(pair0[i,:,:],axis= None)
1387 daux = numpy.sort(pair0[i,:,:],axis= None)
@@ -1389,11 +1391,11 class PulsePairVoltage(Operation):
1389 self.noise = numpy.tile(self.noise,[1,self.__nHeis])
1391 self.noise = numpy.tile(self.noise,[1,self.__nHeis])
1390 noise_buffer = self.noise.reshape(self.__nch,1,self.__nHeis)
1392 noise_buffer = self.noise.reshape(self.__nch,1,self.__nHeis)
1391 noise_buffer = numpy.tile(noise_buffer,[1,self.__nProf,1])
1393 noise_buffer = numpy.tile(noise_buffer,[1,self.__nProf,1])
1392 #·················· Potencia recibida= P , Potencia senal = S , Ruido= N··
1394 #------------------ Potencia recibida= P , Potencia senal = S , Ruido= N--
1393 #·················· P= S+N ,P=lag_0/N ·································
1395 #------------------ P= S+N ,P=lag_0/N ---------------------------------
1394 #···················· Power ··················································
1396 #-------------------- Power --------------------------------------------------
1395 data_power = lag_0/(self.n*self.nCohInt)
1397 data_power = lag_0/(self.n*self.nCohInt)
1396 #------------------ Senal ···················································
1398 #------------------ Senal ---------------------------------------------------
1397 data_intensity = pair0 - noise_buffer
1399 data_intensity = pair0 - noise_buffer
1398 data_intensity = numpy.sum(data_intensity,axis=1)*(self.n*self.nCohInt)#*self.nCohInt)
1400 data_intensity = numpy.sum(data_intensity,axis=1)*(self.n*self.nCohInt)#*self.nCohInt)
1399 #data_intensity = (lag_0-self.noise*self.n)*(self.n*self.nCohInt)
1401 #data_intensity = (lag_0-self.noise*self.n)*(self.n*self.nCohInt)
@@ -1402,28 +1404,28 class PulsePairVoltage(Operation):
1402 if data_intensity[i][j] < 0:
1404 if data_intensity[i][j] < 0:
1403 data_intensity[i][j] = numpy.min(numpy.absolute(data_intensity[i][j]))
1405 data_intensity[i][j] = numpy.min(numpy.absolute(data_intensity[i][j]))
1404
1406
1405 #················· Calculo de Frecuencia y Velocidad doppler········
1407 #----------------- Calculo de Frecuencia y Velocidad doppler--------
1406 pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:])
1408 pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:])
1407 lag_1 = numpy.sum(pair1,1)
1409 lag_1 = numpy.sum(pair1,1)
1408 data_freq = (-1/(2.0*math.pi*self.ippSec*self.nCohInt))*numpy.angle(lag_1)
1410 data_freq = (-1/(2.0*math.pi*self.ippSec*self.nCohInt))*numpy.angle(lag_1)
1409 data_velocity = (self.lambda_/2.0)*data_freq
1411 data_velocity = (self.lambda_/2.0)*data_freq
1410
1412
1411 #················ Potencia promedio estimada de la Senal···········
1413 #---------------- Potencia promedio estimada de la Senal-----------
1412 lag_0 = lag_0/self.n
1414 lag_0 = lag_0/self.n
1413 S = lag_0-self.noise
1415 S = lag_0-self.noise
1414
1416
1415 #················ Frecuencia Doppler promedio ·····················
1417 #---------------- Frecuencia Doppler promedio ---------------------
1416 lag_1 = lag_1/(self.n-1)
1418 lag_1 = lag_1/(self.n-1)
1417 R1 = numpy.abs(lag_1)
1419 R1 = numpy.abs(lag_1)
1418
1420
1419 #················ Calculo del SNR··································
1421 #---------------- Calculo del SNR----------------------------------
1420 data_snrPP = S/self.noise
1422 data_snrPP = S/self.noise
1421 for i in range(self.__nch):
1423 for i in range(self.__nch):
1422 for j in range(self.__nHeis):
1424 for j in range(self.__nHeis):
1423 if data_snrPP[i][j] < 1.e-20:
1425 if data_snrPP[i][j] < 1.e-20:
1424 data_snrPP[i][j] = 1.e-20
1426 data_snrPP[i][j] = 1.e-20
1425
1427
1426 #················· Calculo del ancho espectral ······················
1428 #----------------- Calculo del ancho espectral ----------------------
1427 L = S/R1
1429 L = S/R1
1428 L = numpy.where(L<0,1,L)
1430 L = numpy.where(L<0,1,L)
1429 L = numpy.log(L)
1431 L = numpy.log(L)
General Comments 0
You need to be logged in to leave comments. Login now