##// END OF EJS Templates
jroproc_spectra module modified:...
Miguel Valdez -
r623:926e0eaac812
parent child
Show More
@@ -18,7 +18,7 class SpectraProc(ProcessingUnit):
18 18 self.id_min = None
19 19 self.id_max = None
20 20
21 def __updateObjFromInput(self):
21 def __updateSpecFromVoltage(self):
22 22
23 23 self.dataOut.timeZone = self.dataIn.timeZone
24 24 self.dataOut.dstFlag = self.dataIn.dstFlag
@@ -30,24 +30,23 class SpectraProc(ProcessingUnit):
30 30 self.dataOut.channelList = self.dataIn.channelList
31 31 self.dataOut.heightList = self.dataIn.heightList
32 32 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
33 # self.dataOut.nHeights = self.dataIn.nHeights
34 # self.dataOut.nChannels = self.dataIn.nChannels
33
35 34 self.dataOut.nBaud = self.dataIn.nBaud
36 35 self.dataOut.nCode = self.dataIn.nCode
37 36 self.dataOut.code = self.dataIn.code
38 37 self.dataOut.nProfiles = self.dataOut.nFFTPoints
39 # self.dataOut.channelIndexList = self.dataIn.channelIndexList
38
40 39 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
41 40 self.dataOut.utctime = self.firstdatatime
42 41 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada
43 42 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
44 # self.dataOut.flagShiftFFT = self.dataIn.flagShiftFFT
43 self.dataOut.flagShiftFFT = False
44
45 45 self.dataOut.nCohInt = self.dataIn.nCohInt
46 46 self.dataOut.nIncohInt = 1
47 # self.dataOut.ippSeconds = self.dataIn.ippSeconds
47
48 48 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
49 49
50 # self.dataOut.timeInterval = self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nIncohInt
51 50 self.dataOut.frequency = self.dataIn.frequency
52 51 self.dataOut.realtime = self.dataIn.realtime
53 52
@@ -103,7 +102,7 class SpectraProc(ProcessingUnit):
103 102 self.dataOut.data_cspc = cspc
104 103 self.dataOut.data_dc = dc
105 104 self.dataOut.blockSize = blocksize
106 self.dataOut.flagShiftFFT = False
105 self.dataOut.flagShiftFFT = True
107 106
108 107 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None):
109 108
@@ -122,9 +121,9 class SpectraProc(ProcessingUnit):
122 121 nProfiles = nFFTPoints
123 122 # raise ValueError, "This SpectraProc.run() need nProfiles input variable"
124 123
125
126 124 if ippFactor == None:
127 125 ippFactor = 1
126
128 127 self.dataOut.ippFactor = ippFactor
129 128
130 129 self.dataOut.nFFTPoints = nFFTPoints
@@ -135,37 +134,39 class SpectraProc(ProcessingUnit):
135 134 nProfiles,
136 135 self.dataIn.nHeights),
137 136 dtype='complex')
138 self.id_min = 0
139 self.id_max = self.dataIn.data.shape[1]
140 137
141 if len(self.dataIn.data.shape) == 2:
142 self.buffer[:,self.profIndex,:] = self.dataIn.data.copy()
143 self.profIndex += 1
144 else:
145 if self.dataIn.data.shape[1] == nProfiles:
138 if self.dataIn.flagDataAsBlock:
139
140 if self.dataIn.nProfiles == nProfiles:
146 141 self.buffer = self.dataIn.data.copy()
147 142 self.profIndex = nProfiles
148 elif self.dataIn.data.shape[1] < nProfiles:
143
144 elif self.dataIn.nProfiles < nProfiles:
145
146 if self.profIndex == 0:
147 self.id_min = 0
148 self.id_max = self.dataIn.nProfiles
149
149 150 self.buffer[:,self.id_min:self.id_max,:] = self.dataIn.data
150 self.profIndex += self.dataIn.data.shape[1]
151 self.profIndex += self.dataIn.nProfiles
151 152 self.id_min += self.dataIn.data.shape[1]
152 153 self.id_max += self.dataIn.data.shape[1]
153 154 else:
154 155 raise ValueError, "The type object %s has %d profiles, it should be equal to %d profiles"%(self.dataIn.type,self.dataIn.data.shape[1],nProfiles)
155 156 self.dataOut.flagNoData = True
156 157 return 0
157
158 else:
159 self.buffer[:,self.profIndex,:] = self.dataIn.data.copy()
160 self.profIndex += 1
158 161
159 162 if self.firstdatatime == None:
160 163 self.firstdatatime = self.dataIn.utctime
161 164
162 165 if self.profIndex == nProfiles:
163 self.__updateObjFromInput()
166 self.__updateSpecFromVoltage()
164 167 self.__getFft()
165 168
166 169 self.dataOut.flagNoData = False
167
168 self.buffer = None
169 170 self.firstdatatime = None
170 171 self.profIndex = 0
171 172
@@ -739,32 +740,24 class IncohInt(Operation):
739 740
740 741 self.__initime = None
741 742 self.__lastdatatime = 0
742 self.__buffer_spc = None
743 self.__buffer_cspc = None
744 self.__buffer_dc = None
745 self.__dataReady = False
746
747
748 if n == None and timeInterval == None:
749 raise ValueError, "n or timeInterval should be specified ..."
750
751 if n != None:
752 self.n = n
753 self.__byTime = False
754 else:
755 self.__integrationtime = timeInterval #if (type(timeInterval)!=integer) -> change this line
756 self.n = 9999
757 self.__byTime = True
758 743
759 if overlapping:
760 self.__withOverapping = True
761 else:
762 self.__withOverapping = False
763 744 self.__buffer_spc = 0
764 745 self.__buffer_cspc = 0
765 746 self.__buffer_dc = 0
766 747
767 748 self.__profIndex = 0
749 self.__dataReady = False
750 self.__byTime = False
751
752 if n is None and timeInterval is None:
753 raise ValueError, "n or timeInterval should be specified ..."
754
755 if n is not None:
756 self.n = int(n)
757 else:
758 self.__integrationtime = int(timeInterval) #if (type(timeInterval)!=integer) -> change this line
759 self.n = None
760 self.__byTime = True
768 761
769 762 def putData(self, data_spc, data_cspc, data_dc):
770 763
@@ -773,7 +766,6 class IncohInt(Operation):
773 766
774 767 """
775 768
776 if not self.__withOverapping:
777 769 self.__buffer_spc += data_spc
778 770
779 771 if data_cspc is None:
@@ -787,62 +779,9 class IncohInt(Operation):
787 779 self.__buffer_dc += data_dc
788 780
789 781 self.__profIndex += 1
790 return
791
792 #Overlapping data
793 nChannels, nFFTPoints, nHeis = data_spc.shape
794 data_spc = numpy.reshape(data_spc, (1, nChannels, nFFTPoints, nHeis))
795 if data_cspc is not None:
796 data_cspc = numpy.reshape(data_cspc, (1, -1, nFFTPoints, nHeis))
797 if data_dc is not None:
798 data_dc = numpy.reshape(data_dc, (1, -1, nHeis))
799
800 #If the buffer is empty then it takes the data value
801 if self.__buffer_spc is None:
802 self.__buffer_spc = data_spc
803 782
804 if data_cspc is None:
805 self.__buffer_cspc = None
806 else:
807 self.__buffer_cspc += data_cspc
808
809 if data_dc is None:
810 self.__buffer_dc = None
811 else:
812 self.__buffer_dc += data_dc
813
814 self.__profIndex += 1
815 783 return
816 784
817 #If the buffer length is lower than n then stakcing the data value
818 if self.__profIndex < self.n:
819 self.__buffer_spc = numpy.vstack((self.__buffer_spc, data_spc))
820
821 if data_cspc is not None:
822 self.__buffer_cspc = numpy.vstack((self.__buffer_cspc, data_cspc))
823
824 if data_dc is not None:
825 self.__buffer_dc = numpy.vstack((self.__buffer_dc, data_dc))
826
827 self.__profIndex += 1
828 return
829
830 #If the buffer length is equal to n then replacing the last buffer value with the data value
831 self.__buffer_spc = numpy.roll(self.__buffer_spc, -1, axis=0)
832 self.__buffer_spc[self.n-1] = data_spc
833
834 if data_cspc is not None:
835 self.__buffer_cspc = numpy.roll(self.__buffer_cspc, -1, axis=0)
836 self.__buffer_cspc[self.n-1] = data_cspc
837
838 if data_dc is not None:
839 self.__buffer_dc = numpy.roll(self.__buffer_dc, -1, axis=0)
840 self.__buffer_dc[self.n-1] = data_dc
841
842 self.__profIndex = self.n
843 return
844
845
846 785 def pushData(self):
847 786 """
848 787 Return the sum of the last profiles and the profiles used in the sum.
@@ -852,15 +791,10 class IncohInt(Operation):
852 791 self.__profileIndex
853 792
854 793 """
855 data_spc = None
856 data_cspc = None
857 data_dc = None
858 794
859 if not self.__withOverapping:
860 795 data_spc = self.__buffer_spc
861 796 data_cspc = self.__buffer_cspc
862 797 data_dc = self.__buffer_dc
863
864 798 n = self.__profIndex
865 799
866 800 self.__buffer_spc = 0
@@ -870,32 +804,16 class IncohInt(Operation):
870 804
871 805 return data_spc, data_cspc, data_dc, n
872 806
873 #Integration with Overlapping
874 data_spc = numpy.sum(self.__buffer_spc, axis=0)
875
876 if self.__buffer_cspc is not None:
877 data_cspc = numpy.sum(self.__buffer_cspc, axis=0)
878
879 if self.__buffer_dc is not None:
880 data_dc = numpy.sum(self.__buffer_dc, axis=0)
881
882 n = self.__profIndex
883
884 return data_spc, data_cspc, data_dc, n
885
886 807 def byProfiles(self, *args):
887 808
888 809 self.__dataReady = False
889 avgdata_spc = None
890 avgdata_cspc = None
891 avgdata_dc = None
892 # n = None
893 810
894 811 self.putData(*args)
895 812
896 813 if self.__profIndex == self.n:
897 814
898 815 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
816 self.n = n
899 817 self.__dataReady = True
900 818
901 819 return avgdata_spc, avgdata_cspc, avgdata_dc
@@ -903,10 +821,6 class IncohInt(Operation):
903 821 def byTime(self, datatime, *args):
904 822
905 823 self.__dataReady = False
906 avgdata_spc = None
907 avgdata_cspc = None
908 avgdata_dc = None
909 n = None
910 824
911 825 self.putData(*args)
912 826
@@ -919,7 +833,7 class IncohInt(Operation):
919 833
920 834 def integrate(self, datatime, *args):
921 835
922 if self.__initime == None:
836 if self.__profIndex == 0:
923 837 self.__initime = datatime
924 838
925 839 if self.__byTime:
@@ -927,32 +841,18 class IncohInt(Operation):
927 841 else:
928 842 avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args)
929 843
930 self.__lastdatatime = datatime
931
932 if avgdata_spc is None:
844 if not self.__dataReady:
933 845 return None, None, None, None
934 846
935 avgdatatime = self.__initime
936 try:
937 self.__timeInterval = (self.__lastdatatime - self.__initime)/(self.n - 1)
938 except:
939 self.__timeInterval = self.__lastdatatime - self.__initime
940
941 deltatime = datatime -self.__lastdatatime
942
943 if not self.__withOverapping:
944 self.__initime = datatime
945 else:
946 self.__initime += deltatime
947
948 return avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc
847 return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc
949 848
950 849 def run(self, dataOut, n=None, timeInterval=None, overlapping=False):
951 850
952 851 if n==1:
953 dataOut.flagNoData = False
954 852 return
955 853
854 dataOut.flagNoData = True
855
956 856 if not self.isConfig:
957 857 self.setup(n, timeInterval, overlapping)
958 858 self.isConfig = True
@@ -962,9 +862,6 class IncohInt(Operation):
962 862 dataOut.data_cspc,
963 863 dataOut.data_dc)
964 864
965 # dataOut.timeInterval *= n
966 dataOut.flagNoData = True
967
968 865 if self.__dataReady:
969 866
970 867 dataOut.data_spc = avgdata_spc
@@ -973,6 +870,4 class IncohInt(Operation):
973 870
974 871 dataOut.nIncohInt *= self.n
975 872 dataOut.utctime = avgdatatime
976 #dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints
977 # dataOut.timeInterval = self.__timeInterval*self.n
978 873 dataOut.flagNoData = False
General Comments 0
You need to be logged in to leave comments. Login now