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