@@ -1,232 +1,244 | |||
|
1 | 1 | ''' |
|
2 | 2 | |
|
3 | 3 | $Author$ |
|
4 | 4 | $Id$ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | import os, sys |
|
8 | 8 | import copy |
|
9 | 9 | import numpy |
|
10 | 10 | |
|
11 | 11 | path = os.path.split(os.getcwd())[0] |
|
12 | 12 | sys.path.append(path) |
|
13 | 13 | |
|
14 | 14 | from IO.JROHeaderIO import SystemHeader, RadarControllerHeader |
|
15 | 15 | |
|
16 | 16 | class JROData: |
|
17 | 17 | |
|
18 | 18 | # m_BasicHeader = BasicHeader() |
|
19 | 19 | # m_ProcessingHeader = ProcessingHeader() |
|
20 | 20 | |
|
21 | 21 | systemHeaderObj = SystemHeader() |
|
22 | 22 | |
|
23 | 23 | radarControllerHeaderObj = RadarControllerHeader() |
|
24 | 24 | |
|
25 | 25 | # data = None |
|
26 | 26 | |
|
27 | 27 | type = None |
|
28 | 28 | |
|
29 | 29 | dtype = None |
|
30 | 30 | |
|
31 | 31 | nChannels = None |
|
32 | 32 | |
|
33 | 33 | nHeights = None |
|
34 | 34 | |
|
35 | 35 | nProfiles = None |
|
36 | 36 | |
|
37 | 37 | heightList = None |
|
38 | 38 | |
|
39 | 39 | channelList = None |
|
40 | 40 | |
|
41 | 41 | channelIndexList = None |
|
42 | 42 | |
|
43 | 43 | flagNoData = True |
|
44 | 44 | |
|
45 | 45 | flagTimeBlock = False |
|
46 | 46 | |
|
47 | 47 | utctime = None |
|
48 | 48 | |
|
49 | 49 | blocksize = None |
|
50 | 50 | |
|
51 | 51 | nCode = None |
|
52 | 52 | |
|
53 | 53 | nBaud = None |
|
54 | 54 | |
|
55 | 55 | code = None |
|
56 | 56 | |
|
57 | 57 | flagDecodeData = True #asumo q la data esta decodificada |
|
58 | 58 | |
|
59 | 59 | flagDeflipData = True #asumo q la data esta sin flip |
|
60 | 60 | |
|
61 | 61 | flagShiftFFT = False |
|
62 | 62 | |
|
63 | 63 | ippSeconds = None |
|
64 | 64 | |
|
65 | 65 | timeInterval = None |
|
66 | 66 | |
|
67 | 67 | def __init__(self): |
|
68 | 68 | |
|
69 | 69 | raise ValueError, "This class has not been implemented" |
|
70 | 70 | |
|
71 | 71 | def copy(self, inputObj=None): |
|
72 | 72 | |
|
73 | 73 | if inputObj == None: |
|
74 | 74 | return copy.deepcopy(self) |
|
75 | 75 | |
|
76 | 76 | for key in inputObj.__dict__.keys(): |
|
77 | 77 | self.__dict__[key] = inputObj.__dict__[key] |
|
78 | 78 | |
|
79 | 79 | def deepcopy(self): |
|
80 | 80 | |
|
81 | 81 | return copy.deepcopy(self) |
|
82 | 82 | |
|
83 | 83 | class Voltage(JROData): |
|
84 | 84 | |
|
85 | 85 | nCohInt = None |
|
86 | 86 | |
|
87 | 87 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
88 | 88 | data = None |
|
89 | 89 | |
|
90 | 90 | def __init__(self): |
|
91 | 91 | ''' |
|
92 | 92 | Constructor |
|
93 | 93 | ''' |
|
94 | 94 | |
|
95 | 95 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
96 | 96 | |
|
97 | 97 | self.systemHeaderObj = SystemHeader() |
|
98 | 98 | |
|
99 | 99 | self.type = "Voltage" |
|
100 | 100 | |
|
101 | 101 | self.data = None |
|
102 | 102 | |
|
103 | 103 | self.dtype = None |
|
104 | 104 | |
|
105 | 105 | self.nChannels = 0 |
|
106 | 106 | |
|
107 | 107 | self.nHeights = 0 |
|
108 | 108 | |
|
109 | 109 | self.nProfiles = None |
|
110 | 110 | |
|
111 | 111 | self.heightList = None |
|
112 | 112 | |
|
113 | 113 | self.channelList = None |
|
114 | 114 | |
|
115 | 115 | self.channelIndexList = None |
|
116 | 116 | |
|
117 | 117 | self.flagNoData = True |
|
118 | 118 | |
|
119 | 119 | self.flagTimeBlock = False |
|
120 | 120 | |
|
121 | 121 | self.utctime = None |
|
122 | 122 | |
|
123 | 123 | self.nCohInt = None |
|
124 | 124 | |
|
125 | 125 | self.blocksize = None |
|
126 | 126 | |
|
127 | 127 | class Spectra(JROData): |
|
128 | 128 | |
|
129 | 129 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
130 | 130 | data_spc = None |
|
131 | 131 | |
|
132 | 132 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
133 | 133 | data_cspc = None |
|
134 | 134 | |
|
135 | 135 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
136 | 136 | data_dc = None |
|
137 | 137 | |
|
138 | 138 | nFFTPoints = None |
|
139 | 139 | |
|
140 | 140 | nPairs = None |
|
141 | 141 | |
|
142 | 142 | pairsList = None |
|
143 | 143 | |
|
144 | 144 | nIncohInt = None |
|
145 | 145 | |
|
146 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia | |
|
147 | ||
|
146 | 148 | nCohInt = None #se requiere para determinar el valor de timeInterval |
|
147 | 149 | |
|
148 | 150 | def __init__(self): |
|
149 | 151 | ''' |
|
150 | 152 | Constructor |
|
151 | 153 | ''' |
|
152 | 154 | |
|
153 | 155 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
154 | 156 | |
|
155 | 157 | self.systemHeaderObj = SystemHeader() |
|
156 | 158 | |
|
157 | 159 | self.type = "Spectra" |
|
158 | 160 | |
|
159 | 161 | # self.data = None |
|
160 | 162 | |
|
161 | 163 | self.dtype = None |
|
162 | 164 | |
|
163 | 165 | self.nChannels = 0 |
|
164 | 166 | |
|
165 | 167 | self.nHeights = 0 |
|
166 | 168 | |
|
167 | 169 | self.nProfiles = None |
|
168 | 170 | |
|
169 | 171 | self.heightList = None |
|
170 | 172 | |
|
171 | 173 | self.channelList = None |
|
172 | 174 | |
|
173 | 175 | self.channelIndexList = None |
|
174 | 176 | |
|
175 | 177 | self.flagNoData = True |
|
176 | 178 | |
|
177 | 179 | self.flagTimeBlock = False |
|
178 | 180 | |
|
179 | 181 | self.utctime = None |
|
180 | 182 | |
|
181 | 183 | self.nIncohInt = None |
|
182 | 184 | |
|
183 | 185 | self.blocksize = None |
|
184 | 186 | |
|
187 | self.nFFTPoints = None | |
|
188 | ||
|
189 | self.wavelength = None | |
|
190 | ||
|
191 | def getFrequencies(self): | |
|
192 | ||
|
193 | xrange = numpy.arange(self.nFFTPoints) | |
|
194 | xrange = xrange | |
|
195 | return None | |
|
196 | ||
|
185 | 197 | |
|
186 | 198 | class SpectraHeis(JROData): |
|
187 | 199 | |
|
188 | 200 | data_spc = None |
|
189 | 201 | |
|
190 | 202 | data_cspc = None |
|
191 | 203 | |
|
192 | 204 | data_dc = None |
|
193 | 205 | |
|
194 | 206 | nFFTPoints = None |
|
195 | 207 | |
|
196 | 208 | nPairs = None |
|
197 | 209 | |
|
198 | 210 | pairsList = None |
|
199 | 211 | |
|
200 | 212 | nIncohInt = None |
|
201 | 213 | |
|
202 | 214 | def __init__(self): |
|
203 | 215 | |
|
204 | 216 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
205 | 217 | |
|
206 | 218 | self.systemHeaderObj = SystemHeader() |
|
207 | 219 | |
|
208 | 220 | self.type = "SpectraHeis" |
|
209 | 221 | |
|
210 | 222 | self.dtype = None |
|
211 | 223 | |
|
212 | 224 | self.nChannels = 0 |
|
213 | 225 | |
|
214 | 226 | self.nHeights = 0 |
|
215 | 227 | |
|
216 | 228 | self.nProfiles = None |
|
217 | 229 | |
|
218 | 230 | self.heightList = None |
|
219 | 231 | |
|
220 | 232 | self.channelList = None |
|
221 | 233 | |
|
222 | 234 | self.channelIndexList = None |
|
223 | 235 | |
|
224 | 236 | self.flagNoData = True |
|
225 | 237 | |
|
226 | 238 | self.flagTimeBlock = False |
|
227 | 239 | |
|
228 | 240 | self.nPairs = 0 |
|
229 | 241 | |
|
230 | 242 | self.utctime = None |
|
231 | 243 | |
|
232 | 244 | self.blocksize = None |
@@ -1,770 +1,778 | |||
|
1 | 1 | ''' |
|
2 | 2 | |
|
3 | 3 | $Author$ |
|
4 | 4 | $Id$ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | import os, sys |
|
8 | 8 | import numpy |
|
9 | 9 | import time |
|
10 | 10 | import datetime |
|
11 | 11 | path = os.path.split(os.getcwd())[0] |
|
12 | 12 | sys.path.append(path) |
|
13 | 13 | |
|
14 | 14 | from Data.JROData import Spectra, SpectraHeis |
|
15 | 15 | from IO.SpectraIO import SpectraWriter |
|
16 | 16 | from Graphics.schainPlotTypes import ScopeFigure, SpcFigure, RTIFigure |
|
17 | 17 | #from JRONoise import Noise |
|
18 | 18 | |
|
19 | 19 | class SpectraProcessor: |
|
20 | 20 | ''' |
|
21 | 21 | classdocs |
|
22 | 22 | ''' |
|
23 | 23 | |
|
24 | 24 | dataInObj = None |
|
25 | 25 | |
|
26 | 26 | dataOutObj = None |
|
27 | 27 | |
|
28 | 28 | noiseObj = None |
|
29 | 29 | |
|
30 | 30 | integratorObjList = [] |
|
31 | 31 | |
|
32 | 32 | writerObjList = [] |
|
33 | 33 | |
|
34 | 34 | integratorObjIndex = None |
|
35 | 35 | |
|
36 | 36 | writerObjIndex = None |
|
37 | 37 | |
|
38 | 38 | profIndex = 0 # Se emplea cuando el objeto de entrada es un Voltage |
|
39 | 39 | |
|
40 | 40 | firstdatatime = None |
|
41 | 41 | |
|
42 | 42 | def __init__(self): |
|
43 | 43 | ''' |
|
44 | 44 | Constructor |
|
45 | 45 | ''' |
|
46 | 46 | |
|
47 | 47 | self.integratorObjIndex = None |
|
48 | 48 | self.writerObjIndex = None |
|
49 | 49 | self.plotObjIndex = None |
|
50 | 50 | self.integratorOst = [] |
|
51 | 51 | self.plotObjList = [] |
|
52 | 52 | self.noiseObj = [] |
|
53 | 53 | self.writerObjList = [] |
|
54 | 54 | self.buffer = None |
|
55 | 55 | self.firstdatatime = None |
|
56 | 56 | self.profIndex = 0 |
|
57 | 57 | |
|
58 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairsList=None): | |
|
58 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairsList=None, wavelength=6): | |
|
59 | 59 | |
|
60 | 60 | if dataInObj == None: |
|
61 | 61 | raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" |
|
62 | 62 | |
|
63 | 63 | if dataInObj.type == "Voltage": |
|
64 | 64 | if nFFTPoints == None: |
|
65 | 65 | raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable" |
|
66 | 66 | |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | if dataInObj.type == "Spectra": |
|
70 | 70 | if nFFTPoints != None: |
|
71 | 71 | raise ValueError, "The nFFTPoints cannot be selected to this object type" |
|
72 | 72 | |
|
73 | 73 | nFFTPoints = dataInObj.nFFTPoints |
|
74 | 74 | |
|
75 | 75 | if pairsList == None: |
|
76 | 76 | pairsList = dataInObj.pairsList |
|
77 | 77 | |
|
78 | 78 | if pairsList == None: |
|
79 | 79 | nPairs = 0 |
|
80 | 80 | else: |
|
81 | 81 | nPairs = len(pairsList) |
|
82 | 82 | |
|
83 | 83 | self.dataInObj = dataInObj |
|
84 | 84 | |
|
85 | 85 | if dataOutObj == None: |
|
86 | 86 | dataOutObj = Spectra() |
|
87 | 87 | |
|
88 | 88 | self.dataOutObj = dataOutObj |
|
89 | 89 | self.dataOutObj.nFFTPoints = nFFTPoints |
|
90 | 90 | self.dataOutObj.pairsList = pairsList |
|
91 | 91 | self.dataOutObj.nPairs = nPairs |
|
92 | self.dataOutObj.wavelength = wavelength | |
|
92 | 93 | |
|
93 | 94 | return self.dataOutObj |
|
94 | 95 | |
|
95 | 96 | def init(self): |
|
96 | 97 |
|
|
98 | """ | |
|
99 | ||
|
100 | Este metodo reinicia los contadores de los objetos integrator, writer y plotter | |
|
101 | y actualiza los parametros del objeto de salida dataOutObj a partir del objeto de entrada. | |
|
102 | ||
|
103 | """ | |
|
104 | ||
|
97 | 105 | self.dataOutObj.flagNoData = True |
|
98 | 106 | |
|
99 | 107 | if self.dataInObj.flagNoData: |
|
100 | 108 | return 0 |
|
101 | 109 | |
|
102 | 110 | self.integratorObjIndex = 0 |
|
103 | 111 | self.writerObjIndex = 0 |
|
104 | 112 | self.plotObjIndex = 0 |
|
105 | 113 | |
|
106 | 114 | |
|
107 | 115 | if self.dataInObj.type == "Spectra": |
|
108 | 116 | |
|
109 | 117 | self.dataOutObj.copy(self.dataInObj) |
|
110 | 118 | self.dataOutObj.flagNoData = False |
|
111 | 119 | return |
|
112 | 120 | |
|
113 | 121 | if self.dataInObj.type == "Voltage": |
|
114 | 122 | |
|
115 | 123 | if self.buffer == None: |
|
116 | 124 | self.buffer = numpy.zeros((self.dataInObj.nChannels, |
|
117 | 125 | self.dataOutObj.nFFTPoints, |
|
118 | 126 | self.dataInObj.nHeights), |
|
119 | 127 | dtype='complex') |
|
120 | 128 | |
|
121 | 129 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
122 | 130 | self.profIndex += 1 |
|
123 | 131 | |
|
124 | 132 | if self.firstdatatime == None: |
|
125 | 133 | self.firstdatatime = self.dataInObj.utctime |
|
126 | 134 | |
|
127 | 135 | if self.profIndex == self.dataOutObj.nFFTPoints: |
|
128 | 136 | |
|
129 | 137 | self.__updateObjFromInput() |
|
130 | 138 | self.__getFft() |
|
131 | 139 | |
|
132 | 140 | self.dataOutObj.flagNoData = False |
|
133 | 141 | |
|
134 | 142 | self.buffer = None |
|
135 | 143 | self.firstdatatime = None |
|
136 | 144 | self.profIndex = 0 |
|
137 | 145 | |
|
138 | 146 | return |
|
139 | 147 | |
|
140 | 148 | #Other kind of data |
|
141 | 149 | raise ValueError, "The type object %(s) is not valid " %(self.dataOutObj.type) |
|
142 | 150 | |
|
143 | 151 | def __getFft(self): |
|
144 | 152 | """ |
|
145 | 153 | Convierte valores de Voltaje a Spectra |
|
146 | 154 | |
|
147 | 155 | Affected: |
|
148 | 156 | self.dataOutObj.data_spc |
|
149 | 157 | self.dataOutObj.data_cspc |
|
150 | 158 | self.dataOutObj.data_dc |
|
151 | 159 | self.dataOutObj.heightList |
|
152 | 160 | self.dataOutObj.m_BasicHeader |
|
153 | 161 | self.dataOutObj.m_ProcessingHeader |
|
154 | 162 | self.dataOutObj.radarControllerHeaderObj |
|
155 | 163 | self.dataOutObj.systemHeaderObj |
|
156 | 164 | self.profIndex |
|
157 | 165 | self.buffer |
|
158 | 166 | self.dataOutObj.flagNoData |
|
159 | 167 | self.dataOutObj.dtype |
|
160 | 168 | self.dataOutObj.nPairs |
|
161 | 169 | self.dataOutObj.nChannels |
|
162 | 170 | self.dataOutObj.nProfiles |
|
163 | 171 | self.dataOutObj.systemHeaderObj.numChannels |
|
164 | 172 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
165 | 173 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock |
|
166 | 174 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
167 | 175 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
168 | 176 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
169 | 177 | """ |
|
170 | 178 | |
|
171 | 179 | fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
172 | 180 | dc = fft_volt[:,0,:] |
|
173 | 181 | |
|
174 | 182 | #calculo de self-spectra |
|
175 | 183 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
176 | 184 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
177 | 185 | spc = spc.real |
|
178 | 186 | |
|
179 | 187 | blocksize = 0 |
|
180 | 188 | blocksize += dc.size |
|
181 | 189 | blocksize += spc.size |
|
182 | 190 | |
|
183 | 191 | cspc = None |
|
184 | 192 | pairIndex = 0 |
|
185 | 193 | if self.dataOutObj.pairsList != None: |
|
186 | 194 | #calculo de cross-spectra |
|
187 | 195 | cspc = numpy.zeros((self.dataOutObj.nPairs, self.dataOutObj.nFFTPoints, self.dataOutObj.nHeights), dtype='complex') |
|
188 | 196 | for pair in self.dataOutObj.pairsList: |
|
189 | 197 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) |
|
190 | 198 | pairIndex += 1 |
|
191 | 199 | blocksize += cspc.size |
|
192 | 200 | |
|
193 | 201 | self.dataOutObj.data_spc = spc |
|
194 | 202 | self.dataOutObj.data_cspc = cspc |
|
195 | 203 | self.dataOutObj.data_dc = dc |
|
196 | 204 | self.dataOutObj.blockSize = blocksize |
|
197 | 205 | |
|
198 | 206 | # self.getNoise() |
|
199 | 207 | |
|
200 | 208 | def __updateObjFromInput(self): |
|
201 | 209 | |
|
202 | 210 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() |
|
203 | 211 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() |
|
204 | 212 | self.dataOutObj.channelList = self.dataInObj.channelList |
|
205 | 213 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
206 | 214 | self.dataOutObj.dtype = self.dataInObj.dtype |
|
207 | 215 | self.dataOutObj.nHeights = self.dataInObj.nHeights |
|
208 | 216 | self.dataOutObj.nChannels = self.dataInObj.nChannels |
|
209 | 217 | self.dataOutObj.nBaud = self.dataInObj.nBaud |
|
210 | 218 | self.dataOutObj.nCode = self.dataInObj.nCode |
|
211 | 219 | self.dataOutObj.code = self.dataInObj.code |
|
212 | 220 | self.dataOutObj.nProfiles = self.dataOutObj.nFFTPoints |
|
213 | 221 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
214 | 222 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock |
|
215 | 223 | self.dataOutObj.utctime = self.firstdatatime |
|
216 | 224 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada |
|
217 | 225 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip |
|
218 | 226 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT |
|
219 | 227 | self.dataOutObj.nCohInt = self.dataInObj.nCohInt |
|
220 | 228 | self.dataOutObj.nIncohInt = 1 |
|
221 | 229 | self.dataOutObj.ippSeconds = self.dataInObj.ippSeconds |
|
222 | 230 | self.dataOutObj.timeInterval = self.dataInObj.timeInterval*self.dataOutObj.nFFTPoints |
|
223 | 231 | |
|
224 | 232 | def addWriter(self, wrpath, blocksPerFile): |
|
225 | 233 | |
|
226 | 234 | objWriter = SpectraWriter(self.dataOutObj) |
|
227 | 235 | objWriter.setup(wrpath, blocksPerFile) |
|
228 | 236 | self.writerObjList.append(objWriter) |
|
229 | 237 | |
|
230 | 238 | def addIntegrator(self,N,timeInterval): |
|
231 | 239 | |
|
232 | 240 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
233 | 241 | self.integratorObjList.append(objIncohInt) |
|
234 | 242 | |
|
235 | 243 | def addCrossSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
236 | 244 | crossSpcObj = CrossSpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
237 | 245 | self.plotObjList.append(crossSpcObj) |
|
238 | 246 | |
|
239 | 247 | def plotCrossSpc(self, idfigure=None, |
|
240 | 248 | xmin=None, |
|
241 | 249 | xmax=None, |
|
242 | 250 | ymin=None, |
|
243 | 251 | ymax=None, |
|
244 | 252 | minvalue=None, |
|
245 | 253 | maxvalue=None, |
|
246 | 254 | wintitle='', |
|
247 | 255 | driver='plplot', |
|
248 | 256 | colormap='br_green', |
|
249 | 257 | colorbar=True, |
|
250 | 258 | showprofile=False, |
|
251 | 259 | save=False, |
|
252 | 260 | gpath=None, |
|
253 | 261 | pairsList = None): |
|
254 | 262 | |
|
255 | 263 | if self.dataOutObj.flagNoData: |
|
256 | 264 | return 0 |
|
257 | 265 | |
|
258 | 266 | if pairsList == None: |
|
259 | 267 | pairsList = self.dataOutObj.pairsList |
|
260 | 268 | |
|
261 | 269 | nframes = len(pairsList) |
|
262 | 270 | |
|
263 | 271 | x = numpy.arange(self.dataOutObj.nFFTPoints) |
|
264 | 272 | |
|
265 | 273 | y = self.dataOutObj.heightList |
|
266 | 274 | |
|
267 | 275 | data_spc = self.dataOutObj.data_spc |
|
268 | 276 | data_cspc = self.dataOutObj.data_cspc |
|
269 | 277 | |
|
270 | 278 | data = [] |
|
271 | 279 | |
|
272 | 280 | |
|
273 | 281 | if len(self.plotObjList) <= self.plotObjIndex: |
|
274 | 282 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
275 | 283 | |
|
276 | 284 | |
|
277 | 285 | |
|
278 | 286 | |
|
279 | 287 | |
|
280 | 288 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
281 | 289 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
282 | 290 | self.plotObjList.append(rtiObj) |
|
283 | 291 | |
|
284 | 292 | def plotRti(self, idfigure=None, |
|
285 | 293 | starttime=None, |
|
286 | 294 | endtime=None, |
|
287 | 295 | rangemin=None, |
|
288 | 296 | rangemax=None, |
|
289 | 297 | minvalue=None, |
|
290 | 298 | maxvalue=None, |
|
291 | 299 | wintitle='', |
|
292 | 300 | driver='plplot', |
|
293 | 301 | colormap='br_greeen', |
|
294 | 302 | colorbar=True, |
|
295 | 303 | showprofile=False, |
|
296 | 304 | xrangestep=None, |
|
297 | 305 | save=False, |
|
298 | 306 | gpath=None, |
|
299 | 307 | ratio=1, |
|
300 | 308 | channelList=None): |
|
301 | 309 | |
|
302 | 310 | if self.dataOutObj.flagNoData: |
|
303 | 311 | return 0 |
|
304 | 312 | |
|
305 | 313 | if channelList == None: |
|
306 | 314 | channelList = self.dataOutObj.channelList |
|
307 | 315 | |
|
308 | 316 | nframes = len(channelList) |
|
309 | 317 | |
|
310 | 318 | if len(self.plotObjList) <= self.plotObjIndex: |
|
311 | 319 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
312 | 320 | |
|
313 | 321 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) |
|
314 | 322 | |
|
315 | 323 | data = numpy.average(data, axis=1) |
|
316 | 324 | |
|
317 | 325 | currenttime = self.dataOutObj.utctime - time.timezone |
|
318 | 326 | |
|
319 | 327 | range = self.dataOutObj.heightList |
|
320 | 328 | |
|
321 | 329 | |
|
322 | 330 | figuretitle = "RTI Plot for Spectra Data" #+ date |
|
323 | 331 | |
|
324 | 332 | cleardata = False |
|
325 | 333 | |
|
326 | 334 | deltax = self.dataOutObj.timeInterval |
|
327 | 335 | |
|
328 | 336 | plotObj = self.plotObjList[self.plotObjIndex] |
|
329 | 337 | |
|
330 | 338 | plotObj.plotPcolor(data=data, |
|
331 | 339 | x=currenttime, |
|
332 | 340 | y=range, |
|
333 | 341 | channelList=channelList, |
|
334 | 342 | xmin=starttime, |
|
335 | 343 | xmax=endtime, |
|
336 | 344 | ymin=rangemin, |
|
337 | 345 | ymax=rangemax, |
|
338 | 346 | minvalue=minvalue, |
|
339 | 347 | maxvalue=maxvalue, |
|
340 | 348 | figuretitle=figuretitle, |
|
341 | 349 | xrangestep=xrangestep, |
|
342 | 350 | deltax=deltax, |
|
343 | 351 | save=save, |
|
344 | 352 | gpath=gpath, |
|
345 | 353 | ratio=ratio, |
|
346 | 354 | cleardata=cleardata |
|
347 | 355 | ) |
|
348 | 356 | |
|
349 | 357 | |
|
350 | 358 | |
|
351 | 359 | self.plotObjIndex += 1 |
|
352 | 360 | |
|
353 | 361 | |
|
354 | 362 | |
|
355 | 363 | |
|
356 | 364 | |
|
357 | 365 | |
|
358 | 366 | |
|
359 | 367 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
360 | 368 | |
|
361 | 369 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
362 | 370 | self.plotObjList.append(spcObj) |
|
363 | 371 | |
|
364 | 372 | def plotSpc(self, idfigure=None, |
|
365 | 373 | xmin=None, |
|
366 | 374 | xmax=None, |
|
367 | 375 | ymin=None, |
|
368 | 376 | ymax=None, |
|
369 | 377 | minvalue=None, |
|
370 | 378 | maxvalue=None, |
|
371 | 379 | wintitle='', |
|
372 | 380 | driver='plplot', |
|
373 | 381 | colormap='br_green', |
|
374 | 382 | colorbar=True, |
|
375 | 383 | showprofile=False, |
|
376 | 384 | save=False, |
|
377 | 385 | gpath=None, |
|
378 | 386 | ratio=1, |
|
379 | 387 | channelList=None): |
|
380 | 388 | |
|
381 | 389 | if self.dataOutObj.flagNoData: |
|
382 | 390 | return 0 |
|
383 | 391 | |
|
384 | 392 | if channelList == None: |
|
385 | 393 | channelList = self.dataOutObj.channelList |
|
386 | 394 | |
|
387 | 395 | nframes = len(channelList) |
|
388 | 396 | |
|
389 | 397 | if len(self.plotObjList) <= self.plotObjIndex: |
|
390 | 398 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
391 | 399 | |
|
392 | 400 | x = numpy.arange(self.dataOutObj.nFFTPoints) |
|
393 | 401 | |
|
394 | 402 | y = self.dataOutObj.heightList |
|
395 | 403 | |
|
396 | 404 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) |
|
397 | 405 | # noisedB = 10.*numpy.log10(noise) |
|
398 | 406 | noisedB = numpy.arange(len(channelList)+1) |
|
399 | 407 | noisedB = noisedB *1.2 |
|
400 | 408 | titleList = [] |
|
401 | 409 | for i in range(len(noisedB)): |
|
402 | 410 | title = "%.2f"%noisedB[i] |
|
403 | 411 | titleList.append(title) |
|
404 | 412 | |
|
405 | 413 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
406 | 414 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
407 | 415 | figuretitle = "Spc Radar Data: %s"%dateTime |
|
408 | 416 | |
|
409 | 417 | cleardata = True |
|
410 | 418 | |
|
411 | 419 | plotObj = self.plotObjList[self.plotObjIndex] |
|
412 | 420 | |
|
413 | 421 | plotObj.plotPcolor(data=data, |
|
414 | 422 | x=x, |
|
415 | 423 | y=y, |
|
416 | 424 | channelList=channelList, |
|
417 | 425 | xmin=xmin, |
|
418 | 426 | xmax=xmax, |
|
419 | 427 | ymin=ymin, |
|
420 | 428 | ymax=ymax, |
|
421 | 429 | minvalue=minvalue, |
|
422 | 430 | maxvalue=maxvalue, |
|
423 | 431 | figuretitle=figuretitle, |
|
424 | 432 | xrangestep=None, |
|
425 | 433 | deltax=None, |
|
426 | 434 | save=save, |
|
427 | 435 | gpath=gpath, |
|
428 | 436 | cleardata=cleardata |
|
429 | 437 | ) |
|
430 | 438 | |
|
431 | 439 | self.plotObjIndex += 1 |
|
432 | 440 | |
|
433 | 441 | |
|
434 | 442 | def writeData(self, wrpath, blocksPerFile): |
|
435 | 443 | |
|
436 | 444 | if self.dataOutObj.flagNoData: |
|
437 | 445 | return 0 |
|
438 | 446 | |
|
439 | 447 | if len(self.writerObjList) <= self.writerObjIndex: |
|
440 | 448 | self.addWriter(wrpath, blocksPerFile) |
|
441 | 449 | |
|
442 | 450 | self.writerObjList[self.writerObjIndex].putData() |
|
443 | 451 | |
|
444 | 452 | self.writerObjIndex += 1 |
|
445 | 453 | |
|
446 | 454 | def integrator(self, N=None, timeInterval=None): |
|
447 | 455 | |
|
448 | 456 | if self.dataOutObj.flagNoData: |
|
449 | 457 | return 0 |
|
450 | 458 | |
|
451 | 459 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
452 | 460 | self.addIntegrator(N,timeInterval) |
|
453 | 461 | |
|
454 | 462 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
455 | 463 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,datatime=self.dataOutObj.utctime) |
|
456 | 464 | |
|
457 | 465 | if myIncohIntObj.isReady: |
|
458 | 466 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
459 | 467 | self.dataOutObj.timeInterval *= myCohIntObj.nIncohInt |
|
460 | 468 | self.dataOutObj.nIncohInt = myIncohIntObj.navg * self.dataInObj.nIncohInt |
|
461 | 469 | self.dataOutObj.utctime = myIncohIntObj.firstdatatime |
|
462 | 470 | self.dataOutObj.flagNoData = False |
|
463 | 471 | |
|
464 | 472 | """Calcular el ruido""" |
|
465 | 473 | self.getNoise() |
|
466 | 474 | else: |
|
467 | 475 | self.dataOutObj.flagNoData = True |
|
468 | 476 | |
|
469 | 477 | self.integratorObjIndex += 1 |
|
470 | 478 | |
|
471 | 479 | |
|
472 | 480 | class SpectraHeisProcessor: |
|
473 | 481 | |
|
474 | 482 | def __init__(self): |
|
475 | 483 | |
|
476 | 484 | self.integratorObjIndex = None |
|
477 | 485 | self.writerObjIndex = None |
|
478 | 486 | self.plotObjIndex = None |
|
479 | 487 | self.integratorObjList = [] |
|
480 | 488 | self.writerObjList = [] |
|
481 | 489 | self.plotObjList = [] |
|
482 | 490 | #self.noiseObj = Noise() |
|
483 | 491 | |
|
484 | 492 | def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
485 | 493 | |
|
486 | 494 | if nFFTPoints == None: |
|
487 | 495 | nFFTPoints = self.dataInObj.nHeights |
|
488 | 496 | |
|
489 | 497 | self.dataInObj = dataInObj |
|
490 | 498 | |
|
491 | 499 | if dataOutObj == None: |
|
492 | 500 | dataOutObj = SpectraHeis() |
|
493 | 501 | |
|
494 | 502 | self.dataOutObj = dataOutObj |
|
495 | 503 | |
|
496 | 504 | return self.dataOutObj |
|
497 | 505 | |
|
498 | 506 | def init(self): |
|
499 | 507 | |
|
500 | 508 | self.dataOutObj.flagNoData = True |
|
501 | 509 | |
|
502 | 510 | if self.dataInObj.flagNoData: |
|
503 | 511 | return 0 |
|
504 | 512 | |
|
505 | 513 | self.integratorObjIndex = 0 |
|
506 | 514 | self.writerObjIndex = 0 |
|
507 | 515 | self.plotObjIndex = 0 |
|
508 | 516 | |
|
509 | 517 | if self.dataInObj.type == "Voltage": |
|
510 | 518 | self.__updateObjFromInput() |
|
511 | 519 | self.__getFft() |
|
512 | 520 | self.dataOutObj.flagNoData = False |
|
513 | 521 | return |
|
514 | 522 | |
|
515 | 523 | #Other kind of data |
|
516 | 524 | if self.dataInObj.type == "SpectraHeis": |
|
517 | 525 | self.dataOutObj.copy(self.dataInObj) |
|
518 | 526 | self.dataOutObj.flagNoData = False |
|
519 | 527 | return |
|
520 | 528 | |
|
521 | 529 | raise ValueError, "The type is not valid" |
|
522 | 530 | |
|
523 | 531 | def __updateObjFromInput(self): |
|
524 | 532 | |
|
525 | 533 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() |
|
526 | 534 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() |
|
527 | 535 | self.dataOutObj.channelList = self.dataInObj.channelList |
|
528 | 536 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
529 | 537 | self.dataOutObj.dtype = self.dataInObj.dtype |
|
530 | 538 | self.dataOutObj.nHeights = self.dataInObj.nHeights |
|
531 | 539 | self.dataOutObj.nChannels = self.dataInObj.nChannels |
|
532 | 540 | self.dataOutObj.nBaud = self.dataInObj.nBaud |
|
533 | 541 | self.dataOutObj.nCode = self.dataInObj.nCode |
|
534 | 542 | self.dataOutObj.code = self.dataInObj.code |
|
535 | 543 | self.dataOutObj.nProfiles = 1 |
|
536 | 544 | self.dataOutObj.nFFTPoints = self.dataInObj.nHeights |
|
537 | 545 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
538 | 546 | self.dataOutObj.flagNoData = self.dataInObj.flagNoData |
|
539 | 547 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock |
|
540 | 548 | self.dataOutObj.utctime = self.dataInObj.utctime |
|
541 | 549 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada |
|
542 | 550 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip |
|
543 | 551 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT |
|
544 | 552 | self.dataOutObj.nIncohInt = 1 |
|
545 | 553 | self.dataOutObj.ippSeconds= self.dataInObj.ippSeconds |
|
546 | 554 | |
|
547 | 555 | # def addWriter(self,wrpath,blocksPerfile): |
|
548 | 556 | def addWriter(self,wrpath): |
|
549 | 557 | objWriter=SpectraHeisWriter(self.dataOutObj) |
|
550 | 558 | objWriter.setup(wrpath) |
|
551 | 559 | #objWriter.setup(wrpath,blocksPerfile) |
|
552 | 560 | self.writerObjList.append(objWriter) |
|
553 | 561 | |
|
554 | 562 | # def writedata(self,wrpath,blocksPerfile): |
|
555 | 563 | def writedata(self,wrpath): |
|
556 | 564 | if self.dataOutObj.flagNoData: |
|
557 | 565 | return 0 |
|
558 | 566 | |
|
559 | 567 | if len(self.writerObjList) <= self.writerObjIndex: |
|
560 | 568 | #self.addWriter(wrpath, blocksPerFile) |
|
561 | 569 | self.addWriter(wrpath) |
|
562 | 570 | |
|
563 | 571 | self.writerObjList[self.writerObjIndex].putData() |
|
564 | 572 | |
|
565 | 573 | self.writerObjIndex += 1 |
|
566 | 574 | |
|
567 | 575 | def __getFft(self): |
|
568 | 576 | |
|
569 | 577 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) |
|
570 | 578 | #print fft_volt |
|
571 | 579 | #calculo de self-spectra |
|
572 | 580 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
573 | 581 | |
|
574 | 582 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) |
|
575 | 583 | self.dataOutObj.data_spc = spc |
|
576 | 584 | |
|
577 | 585 | def getSpectra(self): |
|
578 | 586 | |
|
579 | 587 | return self.dataOutObj.data_spc |
|
580 | 588 | |
|
581 | 589 | def getFrecuencies(self): |
|
582 | 590 | |
|
583 | 591 | print self.nFFTPoints |
|
584 | 592 | return numpy.arange(int(self.nFFTPoints)) |
|
585 | 593 | |
|
586 | 594 | def addIntegrator(self,N,timeInterval): |
|
587 | 595 | |
|
588 | 596 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
589 | 597 | self.integratorObjList.append(objIncohInt) |
|
590 | 598 | |
|
591 | 599 | def integrator(self, N=None, timeInterval=None): |
|
592 | 600 | |
|
593 | 601 | if self.dataOutObj.flagNoData: |
|
594 | 602 | return 0 |
|
595 | 603 | |
|
596 | 604 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
597 | 605 | self.addIntegrator(N,timeInterval) |
|
598 | 606 | |
|
599 | 607 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
600 | 608 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.utctime) |
|
601 | 609 | |
|
602 | 610 | if myIncohIntObj.isReady: |
|
603 | 611 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
604 | 612 | self.dataOutObj.nIncohInt = self.dataOutObj.nIncohInt*myIncohIntObj.navg |
|
605 | 613 | self.dataOutObj.flagNoData = False |
|
606 | 614 | |
|
607 | 615 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) |
|
608 | 616 | # self.getNoise(type="sort", parm=16) |
|
609 | 617 | |
|
610 | 618 | else: |
|
611 | 619 | self.dataOutObj.flagNoData = True |
|
612 | 620 | |
|
613 | 621 | self.integratorObjIndex += 1 |
|
614 | 622 | |
|
615 | 623 | |
|
616 | 624 | def addScope(self, idfigure, nframes, wintitle, driver): |
|
617 | 625 | |
|
618 | 626 | if idfigure==None: |
|
619 | 627 | idfigure = self.plotObjIndex |
|
620 | 628 | |
|
621 | 629 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) |
|
622 | 630 | self.plotObjList.append(scopeObj) |
|
623 | 631 | |
|
624 | 632 | def plotScope(self, |
|
625 | 633 | idfigure=None, |
|
626 | 634 | minvalue=None, |
|
627 | 635 | maxvalue=None, |
|
628 | 636 | xmin=None, |
|
629 | 637 | xmax=None, |
|
630 | 638 | wintitle='', |
|
631 | 639 | driver='plplot', |
|
632 | 640 | save=False, |
|
633 | 641 | gpath=None, |
|
634 | 642 | titleList=None, |
|
635 | 643 | xlabelList=None, |
|
636 | 644 | ylabelList=None): |
|
637 | 645 | |
|
638 | 646 | if self.dataOutObj.flagNoData: |
|
639 | 647 | return 0 |
|
640 | 648 | |
|
641 | 649 | nframes = len(self.dataOutObj.channelList) |
|
642 | 650 | |
|
643 | 651 | if len(self.plotObjList) <= self.plotObjIndex: |
|
644 | 652 | self.addScope(idfigure, nframes, wintitle, driver) |
|
645 | 653 | |
|
646 | 654 | |
|
647 | 655 | data1D = self.dataOutObj.data_spc |
|
648 | 656 | |
|
649 | 657 | x = numpy.arange(self.dataOutObj.nHeights) |
|
650 | 658 | |
|
651 | 659 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
652 | 660 | |
|
653 | 661 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
654 | 662 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) |
|
655 | 663 | |
|
656 | 664 | figureTitle = "Scope Plot Radar Data: " + date |
|
657 | 665 | |
|
658 | 666 | plotObj = self.plotObjList[self.plotObjIndex] |
|
659 | 667 | |
|
660 | 668 | plotObj.plot1DArray(data1D, |
|
661 | 669 | x, |
|
662 | 670 | self.dataOutObj.channelList, |
|
663 | 671 | xmin, |
|
664 | 672 | xmax, |
|
665 | 673 | minvalue, |
|
666 | 674 | maxvalue, |
|
667 | 675 | figureTitle, |
|
668 | 676 | save, |
|
669 | 677 | gpath) |
|
670 | 678 | |
|
671 | 679 | self.plotObjIndex += 1 |
|
672 | 680 | |
|
673 | 681 | def rti(self): |
|
674 | 682 | if self.dataOutObj.flagNoData: |
|
675 | 683 | return 0 |
|
676 | 684 | |
|
677 | 685 | data=numpy.average(self.dataOutObj.data_spc,axis=1) |
|
678 | 686 | data[0] |
|
679 | 687 | print data[0] |
|
680 | 688 | x = numpy.arange(100000) |
|
681 | 689 | |
|
682 | 690 | print "test" |
|
683 | 691 | #print self.dataOutObj.data_spc.average(axis=1) |
|
684 | 692 | |
|
685 | 693 | class IncoherentIntegration: |
|
686 | 694 | |
|
687 | 695 | integ_counter = None |
|
688 | 696 | data = None |
|
689 | 697 | navg = None |
|
690 | 698 | buffer = None |
|
691 | 699 | nIncohInt = None |
|
692 | 700 | firstdatatime = None |
|
693 | 701 | |
|
694 | 702 | def __init__(self, N = None, timeInterval = None): |
|
695 | 703 | """ |
|
696 | 704 | N |
|
697 | 705 | timeInterval - interval time [min], integer value |
|
698 | 706 | """ |
|
699 | 707 | |
|
700 | 708 | self.data = None |
|
701 | 709 | self.navg = None |
|
702 | 710 | self.buffer = None |
|
703 | 711 | self.timeOut = None |
|
704 | 712 | self.exitCondition = False |
|
705 | 713 | self.isReady = False |
|
706 | 714 | self.nIncohInt = N |
|
707 | 715 | self.integ_counter = 0 |
|
708 | 716 | self.firstdatatime = None |
|
709 | 717 | |
|
710 | 718 | if timeInterval!=None: |
|
711 | 719 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
712 | 720 | |
|
713 | 721 | if ((timeInterval==None) and (N==None)): |
|
714 | 722 | print 'N = None ; timeInterval = None' |
|
715 | 723 | sys.exit(0) |
|
716 | 724 | elif timeInterval == None: |
|
717 | 725 | self.timeFlag = False |
|
718 | 726 | else: |
|
719 | 727 | self.timeFlag = True |
|
720 | 728 | |
|
721 | 729 | |
|
722 | 730 | def exe(self,data,datatime): |
|
723 | 731 | """ |
|
724 | 732 | data |
|
725 | 733 | |
|
726 | 734 | datatime [seconds] |
|
727 | 735 | """ |
|
728 | 736 | if self.firstdatatime == None or self.isReady: |
|
729 | 737 | self.firstdatatime = datatime |
|
730 | 738 | |
|
731 | 739 | if self.timeFlag: |
|
732 | 740 | if self.timeOut == None: |
|
733 | 741 | self.timeOut = datatime + self.timeIntervalInSeconds |
|
734 | 742 | |
|
735 | 743 | if datatime < self.timeOut: |
|
736 | 744 | if self.buffer == None: |
|
737 | 745 | self.buffer = data |
|
738 | 746 | else: |
|
739 | 747 | self.buffer = self.buffer + data |
|
740 | 748 | self.integ_counter += 1 |
|
741 | 749 | else: |
|
742 | 750 | self.exitCondition = True |
|
743 | 751 | |
|
744 | 752 | else: |
|
745 | 753 | if self.integ_counter < self.nIncohInt: |
|
746 | 754 | if self.buffer == None: |
|
747 | 755 | self.buffer = data |
|
748 | 756 | else: |
|
749 | 757 | self.buffer = self.buffer + data |
|
750 | 758 | |
|
751 | 759 | self.integ_counter += 1 |
|
752 | 760 | |
|
753 | 761 | if self.integ_counter == self.nIncohInt: |
|
754 | 762 | self.exitCondition = True |
|
755 | 763 | |
|
756 | 764 | if self.exitCondition: |
|
757 | 765 | self.data = self.buffer |
|
758 | 766 | self.navg = self.integ_counter |
|
759 | 767 | self.isReady = True |
|
760 | 768 | self.buffer = None |
|
761 | 769 | self.timeOut = None |
|
762 | 770 | self.integ_counter = 0 |
|
763 | 771 | self.exitCondition = False |
|
764 | 772 | |
|
765 | 773 | if self.timeFlag: |
|
766 | 774 | self.buffer = data |
|
767 | 775 | self.timeOut = datatime + self.timeIntervalInSeconds |
|
768 | 776 | else: |
|
769 | 777 | self.isReady = False |
|
770 | 778 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now