@@ -1,170 +1,170 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author $Author$ |
|
5 | 5 | @version $Id$ |
|
6 | 6 | ''' |
|
7 | 7 | |
|
8 | 8 | import numpy |
|
9 | 9 | import os |
|
10 | 10 | import sys |
|
11 | 11 | import plplot |
|
12 | 12 | import datetime |
|
13 | 13 | |
|
14 | 14 | path = os.path.split(os.getcwd())[0] |
|
15 | 15 | sys.path.append(path) |
|
16 | 16 | |
|
17 | 17 | from Graphics.BaseGraph import * |
|
18 | 18 | from Model.Spectra import Spectra |
|
19 | 19 | |
|
20 | 20 | class Spectrum: |
|
21 | 21 | colorplotObj = None |
|
22 | 22 | |
|
23 |
def __init__(self, |
|
|
23 | def __init__(self, spectraObj, index): | |
|
24 | 24 | self.__isPlotConfig = False |
|
25 | 25 | self.__isPlotIni = False |
|
26 | 26 | self.__xrange = None |
|
27 | 27 | self.__yrange = None |
|
28 | 28 | self.nsubplots = 0 |
|
29 | 29 | self.indexPlot = index |
|
30 |
self.spectraObj = |
|
|
30 | self.spectraObj = spectraObj | |
|
31 | 31 | |
|
32 | 32 | def setup(self,indexPlot, nsubplots, winTitle='', colormap="br_green", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): |
|
33 | 33 | """ |
|
34 | 34 | Crea un objeto colorPlot con las opciones seleccinoadas |
|
35 | 35 | """ |
|
36 | 36 | |
|
37 | 37 | self.nsubplots = nsubplots |
|
38 | 38 | self.colorplotObj = PcolorPlot(indexPlot, |
|
39 | 39 | nsubplots, |
|
40 | 40 | winTitle, |
|
41 | 41 | colormap, |
|
42 | 42 | showColorbar, |
|
43 | 43 | showPowerProfile, |
|
44 | 44 | XAxisAsTime) |
|
45 | 45 | |
|
46 | 46 | def createObjects(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList): |
|
47 | 47 | """ |
|
48 | 48 | Configura cada subplot con los valores maximos y minimos incluyendo los subtitulos |
|
49 | 49 | """ |
|
50 | 50 | |
|
51 | 51 | for index in range(self.nsubplots): |
|
52 | 52 | title = titleList[index] |
|
53 | 53 | xlabel = xlabelList[index] |
|
54 | 54 | ylabel = ylabelList[index] |
|
55 | 55 | subplot = index |
|
56 | 56 | self.colorplotObj.createObjects(subplot+1,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel) |
|
57 | 57 | |
|
58 | 58 | def initPlot(self): |
|
59 | 59 | """ |
|
60 | 60 | Configura cada subplot con los valores maximos y minimos incluyendo los subtitulos |
|
61 | 61 | """ |
|
62 | 62 | |
|
63 | 63 | |
|
64 | 64 | for index in range(self.nsubplots): |
|
65 | 65 | subplot = index |
|
66 | 66 | self.colorplotObj.iniPlot(subplot+1) |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | def plotData(self, |
|
70 | 70 | xmin=None, |
|
71 | 71 | xmax=None, |
|
72 | 72 | ymin=None, |
|
73 | 73 | ymax=None, |
|
74 | 74 | zmin=None, |
|
75 | 75 | zmax=None, |
|
76 | 76 | titleList=None, |
|
77 | 77 | xlabelList=None, |
|
78 | 78 | ylabelList=None, |
|
79 | 79 | winTitle='', |
|
80 | 80 | colormap = "br_green", |
|
81 | 81 | showColorbar = True, |
|
82 | 82 | showPowerProfile = True, |
|
83 | 83 | XAxisAsTime = False, |
|
84 | 84 | save = False, |
|
85 | 85 | channelList=[]): |
|
86 | 86 | |
|
87 | 87 | if channelList == []: |
|
88 | 88 | channelList = numpy.arange(self.spectraObj.nChannels) |
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | nsubplots = len(channelList) |
|
92 | 92 | nX = self.spectraObj.nFFTPoints |
|
93 | 93 | nY = self.spectraObj.nHeights |
|
94 | 94 | |
|
95 | 95 | if self.spectraObj.noise == None: |
|
96 | 96 | noise = numpy.ones(nsubplots) |
|
97 | 97 | else: |
|
98 | 98 | noise = 10.*numpy.log10(self.spectraObj.noise[channelList]) |
|
99 | 99 | |
|
100 | 100 | datadB = 10.*numpy.log10(self.spectraObj.data_spc[channelList,:,:]) |
|
101 | 101 | noisedB = 10.*numpy.log10(noise) |
|
102 | 102 | |
|
103 | 103 | x = numpy.arange(nX) |
|
104 | 104 | y = self.spectraObj.heightList |
|
105 | 105 | |
|
106 | 106 | indexPlot = self.indexPlot |
|
107 | 107 | |
|
108 | 108 | if not(self.__isPlotConfig): |
|
109 | 109 | self.setup(indexPlot, |
|
110 | 110 | nsubplots, |
|
111 | 111 | winTitle, |
|
112 | 112 | colormap, |
|
113 | 113 | showColorbar, |
|
114 | 114 | showPowerProfile, |
|
115 | 115 | XAxisAsTime) |
|
116 | 116 | |
|
117 | 117 | |
|
118 | 118 | self.__isPlotConfig = True |
|
119 | 119 | |
|
120 | 120 | if not(self.__isPlotIni): |
|
121 | 121 | if titleList == None: |
|
122 | 122 | titleList = [] |
|
123 | 123 | for i in range(nsubplots): |
|
124 | 124 | titleList.append("Channel: %d - Noise: %.2f" %(i, noise[i])) |
|
125 | 125 | |
|
126 | 126 | if xlabelList == None: |
|
127 | 127 | xlabelList = [] |
|
128 | 128 | for i in range(nsubplots): |
|
129 | 129 | xlabelList.append("") |
|
130 | 130 | |
|
131 | 131 | if ylabelList == None: |
|
132 | 132 | ylabelList = [] |
|
133 | 133 | for i in range(nsubplots): |
|
134 | 134 | ylabelList.append("Range (Km)") |
|
135 | 135 | |
|
136 | 136 | if xmin == None: xmin = x[0] |
|
137 | 137 | if xmax == None: xmax = x[-1] |
|
138 | 138 | if ymin == None: ymin = y[0] |
|
139 | 139 | if ymax == None: ymax = y[-1] |
|
140 |
if zmin == None: zmin = |
|
|
141 |
if zmax == None: zmax = |
|
|
140 | if zmin == None: zmin = datadB.min() | |
|
141 | if zmax == None: zmax = datadB.max() | |
|
142 | 142 | |
|
143 | 143 | self.createObjects(xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList) |
|
144 | 144 | self.__isPlotIni = True |
|
145 | 145 | |
|
146 | 146 | thisDatetime = datetime.datetime.fromtimestamp(self.spectraObj.m_BasicHeader.utc) |
|
147 | 147 | pltitle = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
148 | 148 | |
|
149 | 149 | self.colorplotObj.setFigure(indexPlot) |
|
150 | 150 | self.colorplotObj.setNewPage(pltitle) |
|
151 | 151 | self.initPlot() |
|
152 | 152 | |
|
153 | 153 | for channel in range(nsubplots): |
|
154 | 154 | data = datadB[channel,:,:] |
|
155 | 155 | subtitle = "Channel: %d - Noise: %.2f" %(channel, noise[channel]) |
|
156 | 156 | self.colorplotObj.plot(channel+1, x, y, data, subtitle) |
|
157 | 157 | |
|
158 | 158 | self.colorplotObj.refresh() |
|
159 | 159 | |
|
160 | 160 | if save: |
|
161 | 161 | self.colorplotObj.setFigure(indexPlot) |
|
162 | 162 | path = "/home/roj-idl71/tmp/" |
|
163 | 163 | now = datetime.datetime.now().timetuple() |
|
164 | 164 | file = "spc_img%02d_%03d_%02d%02d%02d.png"%(indexPlot,now[7],now[3],now[4],now[5]) |
|
165 | 165 | filename = os.path.join(path,file) |
|
166 | 166 | self.colorplotObj.savePlot(indexPlot, filename) |
|
167 | 167 | |
|
168 | 168 | self.colorplotObj.closePage() |
|
169 | 169 | |
|
170 | 170 |
@@ -1,696 +1,700 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author $Author$ |
|
5 | 5 | @version $Id$ |
|
6 | 6 | ''' |
|
7 | 7 | import os, sys |
|
8 | 8 | import numpy |
|
9 | 9 | import time |
|
10 | 10 | |
|
11 | 11 | path = os.path.split(os.getcwd())[0] |
|
12 | 12 | sys.path.append(path) |
|
13 | 13 | |
|
14 | 14 | from Model.Spectra import Spectra |
|
15 | 15 | from IO.SpectraIO import SpectraWriter |
|
16 | 16 | from Graphics.SpectraPlot import Spectrum |
|
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 | decoderObjList = [] |
|
33 | 33 | |
|
34 | 34 | writerObjList = [] |
|
35 | 35 | |
|
36 | 36 | plotterObjList = [] |
|
37 | 37 | |
|
38 | 38 | integratorObjIndex = None |
|
39 | 39 | |
|
40 | 40 | decoderObjIndex = None |
|
41 | 41 | |
|
42 | 42 | writerObjIndex = None |
|
43 | 43 | |
|
44 | 44 | plotterObjIndex = None |
|
45 | 45 | |
|
46 | 46 | buffer = None |
|
47 | 47 | |
|
48 | 48 | profIndex = 0 |
|
49 | 49 | |
|
50 | 50 | nFFTPoints = None |
|
51 | 51 | |
|
52 | 52 | nChannels = None |
|
53 | 53 | |
|
54 | 54 | nHeights = None |
|
55 | 55 | |
|
56 | 56 | nPairs = None |
|
57 | 57 | |
|
58 | 58 | pairList = None |
|
59 | 59 | |
|
60 | 60 | |
|
61 | 61 | def __init__(self): |
|
62 | 62 | ''' |
|
63 | 63 | Constructor |
|
64 | 64 | ''' |
|
65 | 65 | |
|
66 | 66 | self.integratorObjIndex = None |
|
67 | 67 | self.decoderObjIndex = None |
|
68 | 68 | self.writerObjIndex = None |
|
69 | 69 | self.plotterObjIndex = None |
|
70 | 70 | |
|
71 | 71 | self.integratorObjList = [] |
|
72 | 72 | self.decoderObjList = [] |
|
73 | 73 | self.writerObjList = [] |
|
74 | 74 | self.plotterObjList = [] |
|
75 | 75 | |
|
76 | 76 | self.noiseObj = None |
|
77 | 77 | self.buffer = None |
|
78 | 78 | self.profIndex = 0 |
|
79 | 79 | |
|
80 | 80 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
81 | 81 | |
|
82 | 82 | if dataInObj == None: |
|
83 | 83 | raise ValueError, "" |
|
84 | 84 | |
|
85 | 85 | if nFFTPoints == None: |
|
86 | 86 | raise ValueError, "" |
|
87 | 87 | |
|
88 | 88 | self.dataInObj = dataInObj |
|
89 | 89 | |
|
90 | 90 | if dataOutObj == None: |
|
91 | 91 | dataOutObj = Spectra() |
|
92 | 92 | |
|
93 | 93 | self.dataOutObj = dataOutObj |
|
94 | 94 | self.noiseObj = Noise() |
|
95 | 95 | |
|
96 | 96 | ########################################## |
|
97 | 97 | self.nFFTPoints = nFFTPoints |
|
98 | 98 | self.nChannels = self.dataInObj.nChannels |
|
99 | 99 | self.nHeights = self.dataInObj.nHeights |
|
100 | 100 | self.pairList = pairList |
|
101 | 101 | if pairList != None: |
|
102 | 102 | self.nPairs = len(pairList) |
|
103 | 103 | else: |
|
104 | 104 | self.nPairs = 0 |
|
105 | 105 | |
|
106 | 106 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
107 | 107 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
108 | 108 | self.dataOutObj.m_BasicHeader = self.dataInObj.m_BasicHeader.copy() |
|
109 | 109 | self.dataOutObj.m_ProcessingHeader = self.dataInObj.m_ProcessingHeader.copy() |
|
110 | 110 | self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy() |
|
111 | 111 | self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy() |
|
112 | 112 | |
|
113 | 113 | self.dataOutObj.dataType = self.dataInObj.dataType |
|
114 | 114 | self.dataOutObj.nPairs = self.nPairs |
|
115 | 115 | self.dataOutObj.nChannels = self.nChannels |
|
116 | 116 | self.dataOutObj.nProfiles = self.nFFTPoints |
|
117 | 117 | self.dataOutObj.nHeights = self.nHeights |
|
118 | 118 | self.dataOutObj.nFFTPoints = self.nFFTPoints |
|
119 | 119 | #self.dataOutObj.data = None |
|
120 | 120 | |
|
121 | 121 | self.dataOutObj.m_SystemHeader.numChannels = self.nChannels |
|
122 | 122 | self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints |
|
123 | 123 | |
|
124 | 124 | self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs |
|
125 | 125 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints |
|
126 | 126 | self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights |
|
127 | 127 | self.dataOutObj.m_ProcessingHeader.shif_fft = True |
|
128 | 128 | |
|
129 | 129 | spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1')) |
|
130 | 130 | k = 0 |
|
131 | 131 | for i in range( 0,self.nChannels*2,2 ): |
|
132 | 132 | spectraComb[i] = k |
|
133 | 133 | spectraComb[i+1] = k |
|
134 | 134 | k += 1 |
|
135 | 135 | |
|
136 | 136 | k *= 2 |
|
137 | 137 | |
|
138 | 138 | if self.pairList != None: |
|
139 | 139 | |
|
140 | 140 | for pair in self.pairList: |
|
141 | 141 | spectraComb[k] = pair[0] |
|
142 | 142 | spectraComb[k+1] = pair[1] |
|
143 | 143 | k += 2 |
|
144 | 144 | |
|
145 | 145 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb |
|
146 | 146 | |
|
147 | 147 | return self.dataOutObj |
|
148 | 148 | |
|
149 | 149 | def init(self): |
|
150 | 150 | |
|
151 | self.nHeights = self.dataInObj.nHeights | |
|
152 | self.dataOutObj.nHeights = self.nHeights | |
|
153 | self.dataOutObj.heightList = self.dataInObj.heightList | |
|
154 | ||
|
151 | 155 | self.integratorObjIndex = 0 |
|
152 | 156 | self.decoderObjIndex = 0 |
|
153 | 157 | self.writerObjIndex = 0 |
|
154 | 158 | self.plotterObjIndex = 0 |
|
155 | 159 | |
|
156 | 160 | if self.dataInObj.type == "Voltage": |
|
157 | 161 | |
|
158 | 162 | if self.buffer == None: |
|
159 | 163 | self.buffer = numpy.zeros((self.nChannels, |
|
160 | 164 | self.nFFTPoints, |
|
161 | self.nHeights), | |
|
165 | self.dataInObj.nHeights), | |
|
162 | 166 | dtype='complex') |
|
163 | 167 | |
|
164 | 168 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
165 | 169 | self.profIndex += 1 |
|
166 | 170 | |
|
167 | 171 | if self.profIndex == self.nFFTPoints: |
|
168 | 172 | self.__getFft() |
|
169 | 173 | self.dataOutObj.flagNoData = False |
|
170 | 174 | |
|
171 | 175 | self.buffer = None |
|
172 | 176 | self.profIndex = 0 |
|
173 | 177 | return |
|
174 | 178 | |
|
175 | 179 | self.dataOutObj.flagNoData = True |
|
176 | 180 | |
|
177 | 181 | return |
|
178 | 182 | |
|
179 | 183 | #Other kind of data |
|
180 | 184 | if self.dataInObj.type == "Spectra": |
|
181 | 185 | self.dataOutObj.copy(self.dataInObj) |
|
182 | 186 | self.dataOutObj.flagNoData = False |
|
183 | 187 | return |
|
184 | 188 | |
|
185 | 189 | raise ValueError, "The datatype is not valid" |
|
186 | 190 | |
|
187 | 191 | def __getFft(self): |
|
188 | 192 | """ |
|
189 | 193 | Convierte valores de Voltaje a Spectra |
|
190 | 194 | |
|
191 | 195 | Affected: |
|
192 | 196 | self.dataOutObj.data_spc |
|
193 | 197 | self.dataOutObj.data_cspc |
|
194 | 198 | self.dataOutObj.data_dc |
|
195 | 199 | self.dataOutObj.heightList |
|
196 | 200 | self.dataOutObj.m_BasicHeader |
|
197 | 201 | self.dataOutObj.m_ProcessingHeader |
|
198 | 202 | self.dataOutObj.m_RadarControllerHeader |
|
199 | 203 | self.dataOutObj.m_SystemHeader |
|
200 | 204 | self.profIndex |
|
201 | 205 | self.buffer |
|
202 | 206 | self.dataOutObj.flagNoData |
|
203 | 207 | self.dataOutObj.dataType |
|
204 | 208 | self.dataOutObj.nPairs |
|
205 | 209 | self.dataOutObj.nChannels |
|
206 | 210 | self.dataOutObj.nProfiles |
|
207 | 211 | self.dataOutObj.m_SystemHeader.numChannels |
|
208 | 212 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
209 | 213 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock |
|
210 | 214 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
211 | 215 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
212 | 216 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
213 | 217 | """ |
|
214 | 218 | |
|
215 | 219 | if self.dataInObj.flagNoData: |
|
216 | 220 | return 0 |
|
217 | 221 | |
|
218 | 222 | fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
219 | 223 | dc = fft_volt[:,0,:] |
|
220 | 224 | |
|
221 | 225 | #calculo de self-spectra |
|
222 | 226 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
223 | 227 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
224 | 228 | spc = spc.real |
|
225 | 229 | |
|
226 | 230 | blocksize = 0 |
|
227 | 231 | blocksize += dc.size |
|
228 | 232 | blocksize += spc.size |
|
229 | 233 | |
|
230 | 234 | cspc = None |
|
231 | 235 | pairIndex = 0 |
|
232 | 236 | if self.pairList != None: |
|
233 | 237 | #calculo de cross-spectra |
|
234 | 238 | cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex') |
|
235 | 239 | for pair in self.pairList: |
|
236 | 240 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) |
|
237 | 241 | pairIndex += 1 |
|
238 | 242 | blocksize += cspc.size |
|
239 | 243 | |
|
240 | 244 | self.dataOutObj.data_spc = spc |
|
241 | 245 | self.dataOutObj.data_cspc = cspc |
|
242 | 246 | self.dataOutObj.data_dc = dc |
|
243 | 247 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
244 | 248 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc |
|
245 | 249 | |
|
246 | 250 | # self.getNoise() |
|
247 | 251 | |
|
248 | 252 | def addWriter(self,wrpath): |
|
249 | 253 | objWriter = SpectraWriter(self.dataOutObj) |
|
250 | 254 | objWriter.setup(wrpath) |
|
251 | 255 | self.writerObjList.append(objWriter) |
|
252 | 256 | |
|
253 | 257 | def addPlotter(self,index=None): |
|
254 | 258 | if index==None: |
|
255 | 259 | index = self.plotterObjIndex |
|
256 | 260 | |
|
257 | 261 | plotObj = Spectrum(self.dataOutObj, index) |
|
258 | 262 | self.plotterObjList.append(plotObj) |
|
259 | 263 | |
|
260 | 264 | def addIntegrator(self,N,timeInterval): |
|
261 | 265 | |
|
262 | 266 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
263 | 267 | self.integratorObjList.append(objIncohInt) |
|
264 | 268 | |
|
265 | 269 | def writeData(self, wrpath): |
|
266 | 270 | if self.dataOutObj.flagNoData: |
|
267 | 271 | return 0 |
|
268 | 272 | |
|
269 | 273 | if len(self.writerObjList) <= self.writerObjIndex: |
|
270 | 274 | self.addWriter(wrpath) |
|
271 | 275 | |
|
272 | 276 | self.writerObjList[self.writerObjIndex].putData() |
|
273 | 277 | |
|
274 | 278 | self.writerObjIndex += 1 |
|
275 | 279 | |
|
276 | 280 | def plotData(self, |
|
277 | 281 | xmin=None, |
|
278 | 282 | xmax=None, |
|
279 | 283 | ymin=None, |
|
280 | 284 | ymax=None, |
|
281 | 285 | zmin=None, |
|
282 | 286 | zmax=None, |
|
283 | 287 | titleList=None, |
|
284 | 288 | xlabelList=None, |
|
285 | 289 | ylabelList=None, |
|
286 | 290 | winTitle='', |
|
287 | 291 | colormap="br_green", |
|
288 | 292 | showColorbar=False, |
|
289 | 293 | showPowerProfile=False, |
|
290 | 294 | XAxisAsTime=False, |
|
291 | 295 | save=False, |
|
292 | 296 | index=None, |
|
293 | 297 | channelList=[]): |
|
294 | 298 | |
|
295 | 299 | if self.dataOutObj.flagNoData: |
|
296 | 300 | return 0 |
|
297 | 301 | |
|
298 | 302 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
299 | 303 | self.addPlotter(index) |
|
300 | 304 | |
|
301 | 305 | self.plotterObjList[self.plotterObjIndex].plotData(xmin, |
|
302 | 306 | xmax, |
|
303 | 307 | ymin, |
|
304 | 308 | ymax, |
|
305 | 309 | zmin, |
|
306 | 310 | zmax, |
|
307 | 311 | titleList, |
|
308 | 312 | xlabelList, |
|
309 | 313 | ylabelList, |
|
310 | 314 | winTitle, |
|
311 | 315 | colormap, |
|
312 | 316 | showColorbar, |
|
313 | 317 | showPowerProfile, |
|
314 | 318 | XAxisAsTime, |
|
315 | 319 | save, |
|
316 | 320 | channelList) |
|
317 | 321 | |
|
318 | 322 | self.plotterObjIndex += 1 |
|
319 | 323 | |
|
320 | 324 | def integrator(self, N=None, timeInterval=None): |
|
321 | 325 | |
|
322 | 326 | if self.dataOutObj.flagNoData: |
|
323 | 327 | return 0 |
|
324 | 328 | |
|
325 | 329 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
326 | 330 | self.addIntegrator(N,timeInterval) |
|
327 | 331 | |
|
328 | 332 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
329 | 333 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) |
|
330 | 334 | |
|
331 | 335 | if myIncohIntObj.isReady: |
|
332 | 336 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
333 | 337 | self.dataOutObj.nAvg = myIncohIntObj.navg |
|
334 | 338 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg |
|
335 | 339 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg |
|
336 | 340 | self.dataOutObj.flagNoData = False |
|
337 | 341 | |
|
338 | 342 | """Calcular el ruido""" |
|
339 | 343 | self.getNoise() |
|
340 | 344 | else: |
|
341 | 345 | self.dataOutObj.flagNoData = True |
|
342 | 346 | |
|
343 | 347 | self.integratorObjIndex += 1 |
|
344 | 348 | |
|
345 | 349 | |
|
346 | 350 | |
|
347 | 351 | def removeDC(self, type): |
|
348 | 352 | |
|
349 | 353 | if self.dataOutObj.flagNoData: |
|
350 | 354 | return 0 |
|
351 | 355 | |
|
352 | 356 | def removeInterference(self): |
|
353 | 357 | |
|
354 | 358 | if self.dataOutObj.flagNoData: |
|
355 | 359 | return 0 |
|
356 | 360 | |
|
357 | 361 | def removeSatellites(self): |
|
358 | 362 | |
|
359 | 363 | if self.dataOutObj.flagNoData: |
|
360 | 364 | return 0 |
|
361 | 365 | |
|
362 | 366 | def getNoise(self, type="hildebrand", parm=None): |
|
363 | 367 | |
|
364 | 368 | if parm == None: |
|
365 | 369 | parm =self.dataOutObj.m_ProcessingHeader.incoherentInt |
|
366 | 370 | |
|
367 | 371 | self.noiseObj.setNoise(self.dataOutObj.data_spc) |
|
368 | 372 | |
|
369 | 373 | if type == "hildebrand": |
|
370 | 374 | noise = self.noiseObj.byHildebrand(parm) |
|
371 | 375 | |
|
372 | 376 | if type == "window": |
|
373 | 377 | noise = self.noiseObj.byWindow(parm) |
|
374 | 378 | |
|
375 | 379 | if type == "sort": |
|
376 | 380 | noise = self.noiseObj.bySort(parm) |
|
377 | 381 | |
|
378 | 382 | self.dataOutObj.noise = noise |
|
379 | 383 | # print 10*numpy.log10(noise) |
|
380 | 384 | |
|
381 | 385 | def selectChannels(self, channelList, pairList=[]): |
|
382 | 386 | |
|
383 | 387 | channelIndexList = [] |
|
384 | 388 | |
|
385 | 389 | for channel in channelList: |
|
386 | 390 | if channel in self.dataOutObj.channelList: |
|
387 | 391 | index = self.dataOutObj.channelList.index(channel) |
|
388 | 392 | channelIndexList.append(index) |
|
389 | 393 | |
|
390 | 394 | pairIndexList = [] |
|
391 | 395 | |
|
392 | 396 | for pair in pairList: |
|
393 | 397 | if pair in self.dataOutObj.pairList: |
|
394 | 398 | index = self.dataOutObj.pairList.index(pair) |
|
395 | 399 | pairIndexList.append(index) |
|
396 | 400 | |
|
397 | 401 | self.selectChannelsByIndex(channelIndexList, pairIndexList) |
|
398 | 402 | |
|
399 | 403 | def selectChannelsByIndex(self, channelIndexList, pairIndexList=[]): |
|
400 | 404 | """ |
|
401 | 405 | Selecciona un bloque de datos en base a canales y pares segun el |
|
402 | 406 | channelIndexList y el pairIndexList |
|
403 | 407 | |
|
404 | 408 | Input: |
|
405 | 409 | channelIndexList : lista de indices de los canales a seleccionar por ej. |
|
406 | 410 | |
|
407 | 411 | Si tenemos los canales |
|
408 | 412 | |
|
409 | 413 | self.channelList = (2,3,5,7) |
|
410 | 414 | |
|
411 | 415 | y deseamos escoger los canales (3,7) |
|
412 | 416 | entonces colocaremos el parametro |
|
413 | 417 | |
|
414 | 418 | channelndexList = (1,3) |
|
415 | 419 | |
|
416 | 420 | pairIndexList : tupla de indice depares que se desea selecionar por ej. |
|
417 | 421 | |
|
418 | 422 | Si tenemos los pares : |
|
419 | 423 | |
|
420 | 424 | ( (0,1), (0,2), (1,3), (2,5) ) |
|
421 | 425 | |
|
422 | 426 | y deseamos seleccionar los pares ((0,2), (2,5)) |
|
423 | 427 | entonces colocaremos el parametro |
|
424 | 428 | |
|
425 | 429 | pairIndexList = (1,3) |
|
426 | 430 | |
|
427 | 431 | Affected: |
|
428 | 432 | self.dataOutObj.data_spc |
|
429 | 433 | self.dataOutObj.data_cspc |
|
430 | 434 | self.dataOutObj.data_dc |
|
431 | 435 | self.dataOutObj.nChannels |
|
432 | 436 | self.dataOutObj.nPairs |
|
433 | 437 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
434 | 438 | self.dataOutObj.m_SystemHeader.numChannels |
|
435 | 439 | |
|
436 | 440 | self.dataOutObj.noise |
|
437 | 441 | Return: |
|
438 | 442 | None |
|
439 | 443 | """ |
|
440 | 444 | |
|
441 | 445 | if self.dataOutObj.flagNoData: |
|
442 | 446 | return 0 |
|
443 | 447 | |
|
444 | 448 | if pairIndexList == []: |
|
445 | 449 | pairIndexList = numpy.arange(len(self.dataOutObj.pairList)) |
|
446 | 450 | |
|
447 | 451 | nChannels = len(channelIndexList) |
|
448 | 452 | nPairs = len(pairIndexList) |
|
449 | 453 | |
|
450 | 454 | blocksize = 0 |
|
451 | 455 | #self spectra |
|
452 | 456 | spc = self.dataOutObj.data_spc[channelIndexList,:,:] |
|
453 | 457 | blocksize += spc.size |
|
454 | 458 | |
|
455 | 459 | cspc = None |
|
456 | 460 | if pairIndexList != []: |
|
457 | 461 | cspc = self.dataOutObj.data_cspc[pairIndexList,:,:] |
|
458 | 462 | blocksize += cspc.size |
|
459 | 463 | |
|
460 | 464 | #DC channel |
|
461 | 465 | dc = None |
|
462 | 466 | if self.dataOutObj.m_ProcessingHeader.flag_dc: |
|
463 | 467 | dc = self.dataOutObj.data_dc[channelIndexList,:] |
|
464 | 468 | blocksize += dc.size |
|
465 | 469 | |
|
466 | 470 | #Almacenar las combinaciones de canales y cros espectros |
|
467 | 471 | |
|
468 | 472 | spectraComb = numpy.zeros( (nChannels+nPairs)*2,numpy.dtype('u1')) |
|
469 | 473 | i = 0 |
|
470 | 474 | for spcChannel in channelIndexList: |
|
471 | 475 | spectraComb[i] = spcChannel |
|
472 | 476 | spectraComb[i+1] = spcChannel |
|
473 | 477 | i += 2 |
|
474 | 478 | |
|
475 | 479 | if pairList != None: |
|
476 | 480 | for pair in pairList: |
|
477 | 481 | spectraComb[i] = pair[0] |
|
478 | 482 | spectraComb[i+1] = pair[1] |
|
479 | 483 | i += 2 |
|
480 | 484 | |
|
481 | 485 | ####### |
|
482 | 486 | |
|
483 | 487 | self.dataOutObj.data_spc = spc |
|
484 | 488 | self.dataOutObj.data_cspc = cspc |
|
485 | 489 | self.dataOutObj.data_dc = dc |
|
486 | 490 | self.dataOutObj.nChannels = nChannels |
|
487 | 491 | self.dataOutObj.nPairs = nPairs |
|
488 | 492 | |
|
489 | 493 | self.dataOutObj.channelIndexList = channelIndexList |
|
490 | 494 | |
|
491 | 495 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb |
|
492 | 496 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nChannels + nPairs |
|
493 | 497 | self.dataOutObj.m_SystemHeader.numChannels = nChannels |
|
494 | 498 | self.dataOutObj.nChannels = nChannels |
|
495 | 499 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
496 | 500 | |
|
497 | 501 | if cspc == None: |
|
498 | 502 | self.dataOutObj.m_ProcessingHeader.flag_dc = False |
|
499 | 503 | if dc == None: |
|
500 | 504 | self.dataOutObj.m_ProcessingHeader.flag_cpsc = False |
|
501 | 505 | |
|
502 | 506 | def selectHeightsByValue(self, minHei, maxHei): |
|
503 | 507 | """ |
|
504 | 508 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
505 | 509 | minHei <= height <= maxHei |
|
506 | 510 | |
|
507 | 511 | Input: |
|
508 | 512 | minHei : valor minimo de altura a considerar |
|
509 | 513 | maxHei : valor maximo de altura a considerar |
|
510 | 514 | |
|
511 | 515 | Affected: |
|
512 | 516 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
513 | 517 | |
|
514 | 518 | Return: |
|
515 | 519 | None |
|
516 | 520 | """ |
|
517 | 521 | |
|
518 | 522 | if self.dataOutObj.flagNoData: |
|
519 | 523 | return 0 |
|
520 | 524 | |
|
521 | 525 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): |
|
522 | 526 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
523 | 527 | |
|
524 | 528 | if (maxHei > self.dataOutObj.heightList[-1]): |
|
525 | 529 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
526 | 530 | |
|
527 | 531 | minIndex = 0 |
|
528 | 532 | maxIndex = 0 |
|
529 | 533 | data = self.dataOutObj.heightList |
|
530 | 534 | |
|
531 | 535 | for i,val in enumerate(data): |
|
532 | 536 | if val < minHei: |
|
533 | 537 | continue |
|
534 | 538 | else: |
|
535 | 539 | minIndex = i; |
|
536 | 540 | break |
|
537 | 541 | |
|
538 | 542 | for i,val in enumerate(data): |
|
539 | 543 | if val <= maxHei: |
|
540 | 544 | maxIndex = i; |
|
541 | 545 | else: |
|
542 | 546 | break |
|
543 | 547 | |
|
544 | 548 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
545 | 549 | |
|
546 | 550 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
547 | 551 | """ |
|
548 | 552 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
549 | 553 | minIndex <= index <= maxIndex |
|
550 | 554 | |
|
551 | 555 | Input: |
|
552 | 556 | minIndex : valor minimo de altura a considerar |
|
553 | 557 | maxIndex : valor maximo de altura a considerar |
|
554 | 558 | |
|
555 | 559 | Affected: |
|
556 | 560 | self.dataOutObj.data_spc |
|
557 | 561 | self.dataOutObj.data_cspc |
|
558 | 562 | self.dataOutObj.data_dc |
|
559 | 563 | self.dataOutObj.heightList |
|
560 | 564 | self.dataOutObj.nHeights |
|
561 | 565 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
562 | 566 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
563 | 567 | self.dataOutObj.m_ProcessingHeader.firstHeight |
|
564 | 568 | self.dataOutObj.m_RadarControllerHeader.numHeights |
|
565 | 569 | |
|
566 | 570 | Return: |
|
567 | 571 | None |
|
568 | 572 | """ |
|
569 | 573 | |
|
570 | 574 | if self.dataOutObj.flagNoData: |
|
571 | 575 | return 0 |
|
572 | 576 | |
|
573 | 577 | if (minIndex < 0) or (minIndex > maxIndex): |
|
574 | 578 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
575 | 579 | |
|
576 | 580 | if (maxIndex >= self.dataOutObj.nHeights): |
|
577 | 581 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
578 | 582 | |
|
579 | 583 | nChannels = self.dataOutObj.nChannels |
|
580 | 584 | nPairs = self.dataOutObj.nPairs |
|
581 | 585 | nProfiles = self.dataOutObj.nProfiles |
|
582 | 586 | dataType = self.dataOutObj.dataType |
|
583 | 587 | nHeights = maxIndex - minIndex + 1 |
|
584 | 588 | blockSize = 0 |
|
585 | 589 | |
|
586 | 590 | #self spectra |
|
587 | 591 | spc = self.dataOutObj.data_spc[:,:,minIndex:maxIndex+1] |
|
588 | 592 | blockSize += spc.size |
|
589 | 593 | |
|
590 | 594 | #cross spectra |
|
591 | 595 | cspc = None |
|
592 | 596 | if self.dataOutObj.data_cspc != None: |
|
593 | 597 | cspc = self.dataOutObj.data_cspc[:,:,minIndex:maxIndex+1] |
|
594 | 598 | blockSize += cspc.size |
|
595 | 599 | |
|
596 | 600 | #DC channel |
|
597 | 601 | dc = self.dataOutObj.data_dc[:,minIndex:maxIndex+1] |
|
598 | 602 | blockSize += dc.size |
|
599 | 603 | |
|
600 | 604 | self.dataOutObj.data_spc = spc |
|
601 | 605 | if cspc != None: |
|
602 | 606 | self.dataOutObj.data_cspc = cspc |
|
603 | 607 | self.dataOutObj.data_dc = dc |
|
604 | 608 | |
|
605 | 609 | firstHeight = self.dataOutObj.heightList[minIndex] |
|
606 | 610 | |
|
607 | 611 | self.dataOutObj.nHeights = nHeights |
|
608 | 612 | self.dataOutObj.m_ProcessingHeader.blockSize = blockSize |
|
609 | 613 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights |
|
610 | 614 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight |
|
611 | 615 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights |
|
612 | 616 | |
|
613 | 617 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] |
|
614 | 618 | |
|
615 | 619 | |
|
616 | 620 | class IncoherentIntegration: |
|
617 | 621 | |
|
618 | 622 | integ_counter = None |
|
619 | 623 | data = None |
|
620 | 624 | navg = None |
|
621 | 625 | buffer = None |
|
622 | 626 | nIncohInt = None |
|
623 | 627 | |
|
624 | 628 | def __init__(self, N = None, timeInterval = None): |
|
625 | 629 | """ |
|
626 | 630 | N |
|
627 | 631 | timeInterval - interval time [min], integer value |
|
628 | 632 | """ |
|
629 | 633 | |
|
630 | 634 | self.data = None |
|
631 | 635 | self.navg = None |
|
632 | 636 | self.buffer = None |
|
633 | 637 | self.timeOut = None |
|
634 | 638 | self.exitCondition = False |
|
635 | 639 | self.isReady = False |
|
636 | 640 | self.nIncohInt = N |
|
637 | 641 | self.integ_counter = 0 |
|
638 | 642 | if timeInterval!=None: |
|
639 | 643 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
640 | 644 | |
|
641 | 645 | if ((timeInterval==None) and (N==None)): |
|
642 | 646 | print 'N = None ; timeInterval = None' |
|
643 | 647 | sys.exit(0) |
|
644 | 648 | elif timeInterval == None: |
|
645 | 649 | self.timeFlag = False |
|
646 | 650 | else: |
|
647 | 651 | self.timeFlag = True |
|
648 | 652 | |
|
649 | 653 | |
|
650 | 654 | def exe(self,data,timeOfData): |
|
651 | 655 | """ |
|
652 | 656 | data |
|
653 | 657 | |
|
654 | 658 | timeOfData [seconds] |
|
655 | 659 | """ |
|
656 | 660 | |
|
657 | 661 | if self.timeFlag: |
|
658 | 662 | if self.timeOut == None: |
|
659 | 663 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
660 | 664 | |
|
661 | 665 | if timeOfData < self.timeOut: |
|
662 | 666 | if self.buffer == None: |
|
663 | 667 | self.buffer = data |
|
664 | 668 | else: |
|
665 | 669 | self.buffer = self.buffer + data |
|
666 | 670 | self.integ_counter += 1 |
|
667 | 671 | else: |
|
668 | 672 | self.exitCondition = True |
|
669 | 673 | |
|
670 | 674 | else: |
|
671 | 675 | if self.integ_counter < self.nIncohInt: |
|
672 | 676 | if self.buffer == None: |
|
673 | 677 | self.buffer = data |
|
674 | 678 | else: |
|
675 | 679 | self.buffer = self.buffer + data |
|
676 | 680 | |
|
677 | 681 | self.integ_counter += 1 |
|
678 | 682 | |
|
679 | 683 | if self.integ_counter == self.nIncohInt: |
|
680 | 684 | self.exitCondition = True |
|
681 | 685 | |
|
682 | 686 | if self.exitCondition: |
|
683 | 687 | self.data = self.buffer |
|
684 | 688 | self.navg = self.integ_counter |
|
685 | 689 | self.isReady = True |
|
686 | 690 | self.buffer = None |
|
687 | 691 | self.timeOut = None |
|
688 | 692 | self.integ_counter = 0 |
|
689 | 693 | self.exitCondition = False |
|
690 | 694 | |
|
691 | 695 | if self.timeFlag: |
|
692 | 696 | self.buffer = data |
|
693 | 697 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
694 | 698 | else: |
|
695 | 699 | self.isReady = False |
|
696 | 700 | No newline at end of file |
@@ -1,674 +1,679 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author $Author$ |
|
5 | 5 | @version $Id$ |
|
6 | 6 | ''' |
|
7 | 7 | |
|
8 | 8 | import os, sys |
|
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 Model.Voltage import Voltage |
|
15 | 15 | from IO.VoltageIO import VoltageWriter |
|
16 | 16 | from Graphics.VoltagePlot import Osciloscope |
|
17 | 17 | from Graphics.VoltagePlot import RTI |
|
18 | 18 | |
|
19 | 19 | class VoltageProcessor: |
|
20 | 20 | ''' |
|
21 | 21 | classdocs |
|
22 | 22 | ''' |
|
23 | 23 | |
|
24 | 24 | dataInObj = None |
|
25 | 25 | dataOutObj = None |
|
26 | 26 | |
|
27 | 27 | integratorObjIndex = None |
|
28 | 28 | decoderObjIndex = None |
|
29 | 29 | profSelectorObjIndex = None |
|
30 | 30 | writerObjIndex = None |
|
31 | 31 | plotterObjIndex = None |
|
32 | 32 | flipIndex = None |
|
33 | 33 | |
|
34 | 34 | integratorObjList = [] |
|
35 | 35 | decoderObjList = [] |
|
36 | 36 | profileSelectorObjList = [] |
|
37 | 37 | writerObjList = [] |
|
38 | 38 | plotterObjList = [] |
|
39 | 39 | m_Voltage= Voltage() |
|
40 | 40 | |
|
41 | 41 | def __init__(self): |
|
42 | 42 | ''' |
|
43 | 43 | Constructor |
|
44 | 44 | ''' |
|
45 | 45 | |
|
46 | 46 | self.integratorObjIndex = None |
|
47 | 47 | self.decoderObjIndex = None |
|
48 | 48 | self.profSelectorObjIndex = None |
|
49 | 49 | self.writerObjIndex = None |
|
50 | 50 | self.plotterObjIndex = None |
|
51 | 51 | self.flipIndex = 1 |
|
52 | 52 | self.integratorObjList = [] |
|
53 | 53 | self.decoderObjList = [] |
|
54 | 54 | self.profileSelectorObjList = [] |
|
55 | 55 | self.writerObjList = [] |
|
56 | 56 | self.plotterObjList = [] |
|
57 | 57 | |
|
58 | 58 | def setup(self, dataInObj=None, dataOutObj=None): |
|
59 | 59 | |
|
60 | 60 | self.dataInObj = dataInObj |
|
61 | 61 | |
|
62 | 62 | if dataOutObj == None: |
|
63 | 63 | dataOutObj = Voltage() |
|
64 | 64 | |
|
65 | 65 | dataOutObj.copy(dataInObj) |
|
66 | 66 | |
|
67 | 67 | self.dataOutObj = dataOutObj |
|
68 | 68 | |
|
69 | 69 | return self.dataOutObj |
|
70 | 70 | |
|
71 | 71 | |
|
72 | 72 | def init(self): |
|
73 | 73 | |
|
74 | 74 | self.integratorObjIndex = 0 |
|
75 | 75 | self.decoderObjIndex = 0 |
|
76 | 76 | self.profSelectorObjIndex = 0 |
|
77 | 77 | self.writerObjIndex = 0 |
|
78 | 78 | self.plotterObjIndex = 0 |
|
79 | 79 | self.dataOutObj.copy(self.dataInObj) |
|
80 | 80 | |
|
81 | 81 | if self.profSelectorObjIndex != None: |
|
82 | 82 | for profSelObj in self.profileSelectorObjList: |
|
83 | 83 | profSelObj.incIndex() |
|
84 | 84 | |
|
85 | 85 | def addWriter(self, wrpath): |
|
86 | 86 | objWriter = VoltageWriter(self.dataOutObj) |
|
87 | 87 | objWriter.setup(wrpath) |
|
88 | 88 | self.writerObjList.append(objWriter) |
|
89 | 89 | |
|
90 | 90 | def addRti(self,index=None): |
|
91 | 91 | if index==None: |
|
92 | 92 | index = self.plotterObjIndex |
|
93 | 93 | |
|
94 | 94 | plotObj = RTI(self.dataOutObj, index) |
|
95 | 95 | self.plotterObjList.append(plotObj) |
|
96 | 96 | |
|
97 | 97 | def addPlotter(self, index=None): |
|
98 | 98 | if index==None: |
|
99 | 99 | index = self.plotterObjIndex |
|
100 | 100 | |
|
101 | 101 | plotObj = Osciloscope(self.dataOutObj, index) |
|
102 | 102 | self.plotterObjList.append(plotObj) |
|
103 | 103 | |
|
104 | 104 | def addIntegrator(self, N,timeInterval): |
|
105 | 105 | |
|
106 | 106 | objCohInt = CoherentIntegrator(N,timeInterval) |
|
107 | 107 | self.integratorObjList.append(objCohInt) |
|
108 | 108 | |
|
109 | 109 | def addDecoder(self, code, ncode, nbaud): |
|
110 | 110 | |
|
111 | 111 | objDecoder = Decoder(code,ncode,nbaud) |
|
112 | 112 | self.decoderObjList.append(objDecoder) |
|
113 | 113 | |
|
114 | 114 | def addProfileSelector(self, nProfiles): |
|
115 | 115 | |
|
116 | 116 | objProfSelector = ProfileSelector(nProfiles) |
|
117 | 117 | self.profileSelectorObjList.append(objProfSelector) |
|
118 | 118 | |
|
119 | 119 | def writeData(self,wrpath): |
|
120 | 120 | |
|
121 | 121 | if self.dataOutObj.flagNoData: |
|
122 | 122 | return 0 |
|
123 | 123 | |
|
124 | 124 | if len(self.writerObjList) <= self.writerObjIndex: |
|
125 | 125 | self.addWriter(wrpath) |
|
126 | 126 | |
|
127 | 127 | self.writerObjList[self.writerObjIndex].putData() |
|
128 | 128 | |
|
129 | 129 | self.writerObjIndex += 1 |
|
130 | 130 | |
|
131 | 131 | def addScope(self,index=None): |
|
132 | 132 | if index==None: |
|
133 | 133 | index = self.plotterObjIndex |
|
134 | 134 | |
|
135 | 135 | plotObj = Osciloscope(self.dataOutObj, index) |
|
136 | 136 | self.plotterObjList.append(plotObj) |
|
137 | 137 | |
|
138 | 138 | def plotScope(self, |
|
139 | 139 | xmin=None, |
|
140 | 140 | xmax=None, |
|
141 | 141 | ymin=None, |
|
142 | 142 | ymax=None, |
|
143 | 143 | titleList=None, |
|
144 | 144 | xlabelList=None, |
|
145 | 145 | ylabelList=None, |
|
146 | 146 | winTitle='', |
|
147 | 147 | type="power", |
|
148 | 148 | index=None): |
|
149 | 149 | |
|
150 | 150 | if self.dataOutObj.flagNoData: |
|
151 | 151 | return 0 |
|
152 | 152 | |
|
153 | 153 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
154 | 154 | self.addScope(index) |
|
155 | 155 | |
|
156 | 156 | self.plotterObjList[self.plotterObjIndex].plotData(xmin, |
|
157 | 157 | xmax, |
|
158 | 158 | ymin, |
|
159 | 159 | ymax, |
|
160 | 160 | titleList, |
|
161 | 161 | xlabelList, |
|
162 | 162 | ylabelList, |
|
163 | 163 | winTitle, |
|
164 | 164 | type) |
|
165 | 165 | |
|
166 | 166 | self.plotterObjIndex += 1 |
|
167 | 167 | |
|
168 | 168 | def plotRti(self, |
|
169 | 169 | xmin=None, |
|
170 | 170 | xmax=None, |
|
171 | 171 | ymin=None, |
|
172 | 172 | ymax=None, |
|
173 | 173 | zmin=None, |
|
174 | 174 | zmax=None, |
|
175 | 175 | titleList=None, |
|
176 | 176 | xlabelList=None, |
|
177 | 177 | ylabelList=None, |
|
178 | 178 | winTitle='', |
|
179 | 179 | timezone='lt', |
|
180 | 180 | npoints=1000.0, |
|
181 | 181 | colormap="br_green", |
|
182 | 182 | showColorbar=True, |
|
183 | 183 | showPowerProfile=False, |
|
184 | 184 | XAxisAsTime=True, |
|
185 | 185 | save=False, |
|
186 | 186 | index=None): |
|
187 | 187 | |
|
188 | 188 | if self.dataOutObj.flagNoData: |
|
189 | 189 | return 0 |
|
190 | 190 | |
|
191 | 191 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
192 | 192 | self.addRti(index) |
|
193 | 193 | |
|
194 | 194 | self.plotterObjList[self.plotterObjIndex].plotData(xmin, |
|
195 | 195 | xmax, |
|
196 | 196 | ymin, |
|
197 | 197 | ymax, |
|
198 | 198 | zmin, |
|
199 | 199 | zmax, |
|
200 | 200 | titleList, |
|
201 | 201 | xlabelList, |
|
202 | 202 | ylabelList, |
|
203 | 203 | winTitle, |
|
204 | 204 | timezone, |
|
205 | 205 | npoints, |
|
206 | 206 | colormap, |
|
207 | 207 | showColorbar, |
|
208 | 208 | showPowerProfile, |
|
209 | 209 | XAxisAsTime, |
|
210 | 210 | save) |
|
211 | 211 | |
|
212 | 212 | self.plotterObjIndex += 1 |
|
213 | 213 | |
|
214 | 214 | |
|
215 | 215 | def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, type='iq', winTitle='', index=None): |
|
216 | 216 | if self.dataOutObj.flagNoData: |
|
217 | 217 | return 0 |
|
218 | 218 | |
|
219 | 219 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
220 | 220 | self.addPlotter(index) |
|
221 | 221 | |
|
222 | 222 | self.plotterObjList[self.plotterObjIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,type=type, winTitle=winTitle) |
|
223 | 223 | |
|
224 | 224 | self.plotterObjIndex += 1 |
|
225 | 225 | |
|
226 | 226 | def integrator(self, N=None, timeInterval=None): |
|
227 | 227 | |
|
228 | 228 | if self.dataOutObj.flagNoData: |
|
229 | 229 | return 0 |
|
230 | 230 | |
|
231 | 231 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
232 | 232 | self.addIntegrator(N,timeInterval) |
|
233 | 233 | |
|
234 | 234 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
235 | 235 | myCohIntObj.exe(data=self.dataOutObj.data,timeOfData=self.dataOutObj.m_BasicHeader.utc) |
|
236 | 236 | |
|
237 | 237 | if myCohIntObj.isReady: |
|
238 | 238 | self.dataOutObj.data = myCohIntObj.data |
|
239 | 239 | self.dataOutObj.nAvg = myCohIntObj.navg |
|
240 | 240 | self.dataOutObj.m_ProcessingHeader.coherentInt *= myCohIntObj.navg |
|
241 | 241 | #print "myCohIntObj.navg: ",myCohIntObj.navg |
|
242 | 242 | self.dataOutObj.flagNoData = False |
|
243 | 243 | |
|
244 | 244 | else: |
|
245 | 245 | self.dataOutObj.flagNoData = True |
|
246 | 246 | |
|
247 | 247 | self.integratorObjIndex += 1 |
|
248 | 248 | |
|
249 |
def decoder(self,code=None, |
|
|
249 | def decoder(self,code=None, mode = 0): | |
|
250 | 250 | |
|
251 | 251 | if self.dataOutObj.flagNoData: |
|
252 | 252 | return 0 |
|
253 | 253 | |
|
254 | 254 | if code == None: |
|
255 | 255 | code = self.dataOutObj.m_RadarControllerHeader.code |
|
256 | 256 | ncode, nbaud = code.shape |
|
257 | 257 | |
|
258 | 258 | if len(self.decoderObjList) <= self.decoderObjIndex: |
|
259 | 259 | self.addDecoder(code,ncode,nbaud) |
|
260 | 260 | |
|
261 | 261 | myDecodObj = self.decoderObjList[self.decoderObjIndex] |
|
262 |
myDecodObj.exe(data=self.dataOutObj.data, |
|
|
262 | data, ndata = myDecodObj.exe(data=self.dataOutObj.data,mode=mode) | |
|
263 | 263 | |
|
264 | if myDecodObj.flag: | |
|
265 |
|
|
|
264 | self.dataOutObj.data = data | |
|
265 | self.dataOutObj.nHeights = ndata | |
|
266 | self.dataOutObj.heightList = self.dataInObj.heightList[:ndata] | |
|
266 | 267 |
|
|
267 | else: | |
|
268 | self.dataOutObj.flagNoData = True | |
|
269 | 268 | |
|
270 | 269 | self.decoderObjIndex += 1 |
|
271 | 270 | |
|
272 | 271 | |
|
273 | 272 | def filterByHei(self, window): |
|
274 | 273 | if window == None: |
|
275 | 274 | window = self.dataOutObj.m_RadarControllerHeader.txA / self.dataOutObj.m_ProcessingHeader.deltaHeight[0] |
|
276 | 275 | |
|
277 | 276 | newdelta = self.dataOutObj.m_ProcessingHeader.deltaHeight[0] * window |
|
278 | 277 | dim1 = self.dataOutObj.data.shape[0] |
|
279 | 278 | dim2 = self.dataOutObj.data.shape[1] |
|
280 | 279 | r = dim2 % window |
|
281 | 280 | |
|
282 | 281 | buffer = self.dataOutObj.data[:,0:dim2-r] |
|
283 | 282 | buffer = buffer.reshape(dim1,dim2/window,window) |
|
284 | 283 | buffer = numpy.sum(buffer,2) |
|
285 | 284 | self.dataOutObj.data = buffer |
|
286 | 285 | |
|
287 | 286 | self.dataOutObj.m_ProcessingHeader.deltaHeight = newdelta |
|
288 | 287 | self.dataOutObj.m_ProcessingHeader.numHeights = buffer.shape[1] |
|
289 | 288 | |
|
290 | 289 | self.dataOutObj.nHeights = self.dataOutObj.m_ProcessingHeader.numHeights |
|
291 | 290 | |
|
292 | 291 | #self.dataOutObj.heightList es un numpy.array |
|
293 | 292 | self.dataOutObj.heightList = numpy.arange(self.dataOutObj.m_ProcessingHeader.firstHeight[0],newdelta*self.dataOutObj.nHeights,newdelta) |
|
294 | 293 | |
|
295 | 294 | def deFlip(self): |
|
296 | 295 | self.dataOutObj.data *= self.flipIndex |
|
297 | 296 | self.flipIndex *= -1. |
|
298 | 297 | |
|
299 | 298 | def selectChannels(self, channelList): |
|
300 | 299 | pass |
|
301 | 300 | |
|
302 | 301 | def selectChannelsByIndex(self, channelIndexList): |
|
303 | 302 | """ |
|
304 | 303 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
305 | 304 | |
|
306 | 305 | Input: |
|
307 | 306 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
308 | 307 | |
|
309 | 308 | Affected: |
|
310 | 309 | self.dataOutObj.data |
|
311 | 310 | self.dataOutObj.channelIndexList |
|
312 | 311 | self.dataOutObj.nChannels |
|
313 | 312 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
314 | 313 | self.dataOutObj.m_SystemHeader.numChannels |
|
315 | 314 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
316 | 315 | |
|
317 | 316 | Return: |
|
318 | 317 | None |
|
319 | 318 | """ |
|
320 | 319 | if self.dataOutObj.flagNoData: |
|
321 | 320 | return 0 |
|
322 | 321 | |
|
323 | 322 | for channel in channelIndexList: |
|
324 | 323 | if channel not in self.dataOutObj.channelIndexList: |
|
325 | 324 | raise ValueError, "The value %d in channelIndexList is not valid" %channel |
|
326 | 325 | |
|
327 | 326 | nChannels = len(channelIndexList) |
|
328 | 327 | |
|
329 | 328 | data = self.dataOutObj.data[channelIndexList,:] |
|
330 | 329 | |
|
331 | 330 | self.dataOutObj.data = data |
|
332 | 331 | self.dataOutObj.channelIndexList = channelIndexList |
|
333 | 332 | self.dataOutObj.nChannels = nChannels |
|
334 | 333 | |
|
335 | 334 | self.dataOutObj.m_ProcessingHeader.totalSpectra = 0 |
|
336 | 335 | self.dataOutObj.m_SystemHeader.numChannels = nChannels |
|
337 | 336 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size |
|
338 | 337 | return 1 |
|
339 | 338 | |
|
340 | 339 | |
|
341 | 340 | def selectHeightsByValue(self, minHei, maxHei): |
|
342 | 341 | """ |
|
343 | 342 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
344 | 343 | minHei <= height <= maxHei |
|
345 | 344 | |
|
346 | 345 | Input: |
|
347 | 346 | minHei : valor minimo de altura a considerar |
|
348 | 347 | maxHei : valor maximo de altura a considerar |
|
349 | 348 | |
|
350 | 349 | Affected: |
|
351 | 350 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
352 | 351 | |
|
353 | 352 | Return: |
|
354 | 353 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
355 | 354 | """ |
|
356 | 355 | if self.dataOutObj.flagNoData: |
|
357 | 356 | return 0 |
|
358 | 357 | |
|
359 | 358 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): |
|
360 | 359 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
361 | 360 | |
|
362 | 361 | if (maxHei > self.dataOutObj.heightList[-1]): |
|
363 | 362 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
364 | 363 | |
|
365 | 364 | minIndex = 0 |
|
366 | 365 | maxIndex = 0 |
|
367 | 366 | data = self.dataOutObj.heightList |
|
368 | 367 | |
|
369 | 368 | for i,val in enumerate(data): |
|
370 | 369 | if val < minHei: |
|
371 | 370 | continue |
|
372 | 371 | else: |
|
373 | 372 | minIndex = i; |
|
374 | 373 | break |
|
375 | 374 | |
|
376 | 375 | for i,val in enumerate(data): |
|
377 | 376 | if val <= maxHei: |
|
378 | 377 | maxIndex = i; |
|
379 | 378 | else: |
|
380 | 379 | break |
|
381 | 380 | |
|
382 | 381 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
383 | 382 | return 1 |
|
384 | 383 | |
|
385 | 384 | |
|
386 | 385 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
387 | 386 | """ |
|
388 | 387 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
389 | 388 | minIndex <= index <= maxIndex |
|
390 | 389 | |
|
391 | 390 | Input: |
|
392 | 391 | minIndex : valor de indice minimo de altura a considerar |
|
393 | 392 | maxIndex : valor de indice maximo de altura a considerar |
|
394 | 393 | |
|
395 | 394 | Affected: |
|
396 | 395 | self.dataOutObj.data |
|
397 | 396 | self.dataOutObj.heightList |
|
398 | 397 | self.dataOutObj.nHeights |
|
399 | 398 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
400 | 399 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
401 | 400 | self.dataOutObj.m_ProcessingHeader.firstHeight |
|
402 | 401 | self.dataOutObj.m_RadarControllerHeader |
|
403 | 402 | |
|
404 | 403 | Return: |
|
405 | 404 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
406 | 405 | """ |
|
407 | 406 | if self.dataOutObj.flagNoData: |
|
408 | 407 | return 0 |
|
409 | 408 | |
|
410 | 409 | if (minIndex < 0) or (minIndex > maxIndex): |
|
411 | 410 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
412 | 411 | |
|
413 | 412 | if (maxIndex >= self.dataOutObj.nHeights): |
|
414 | 413 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
415 | 414 | |
|
416 | 415 | nHeights = maxIndex - minIndex + 1 |
|
417 | 416 | |
|
418 | 417 | #voltage |
|
419 | 418 | data = self.dataOutObj.data[:,minIndex:maxIndex+1] |
|
420 | 419 | |
|
421 | 420 | firstHeight = self.dataOutObj.heightList[minIndex] |
|
422 | 421 | |
|
423 | 422 | self.dataOutObj.data = data |
|
424 | 423 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] |
|
425 | 424 | self.dataOutObj.nHeights = nHeights |
|
426 | 425 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size |
|
427 | 426 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights |
|
428 | 427 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight |
|
429 | 428 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights |
|
430 | 429 | return 1 |
|
431 | 430 | |
|
432 | 431 | def selectProfilesByValue(self,indexList, nProfiles): |
|
433 | 432 | if self.dataOutObj.flagNoData: |
|
434 | 433 | return 0 |
|
435 | 434 | |
|
436 | 435 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): |
|
437 | 436 | self.addProfileSelector(nProfiles) |
|
438 | 437 | |
|
439 | 438 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] |
|
440 | 439 | |
|
441 | 440 | if not(profileSelectorObj.isProfileInList(indexList)): |
|
442 | 441 | self.dataOutObj.flagNoData = True |
|
443 | 442 | self.profSelectorObjIndex += 1 |
|
444 | 443 | return 0 |
|
445 | 444 | |
|
446 | 445 | self.dataOutObj.flagNoData = False |
|
447 | 446 | self.profSelectorObjIndex += 1 |
|
448 | 447 | |
|
449 | 448 | return 1 |
|
450 | 449 | |
|
451 | 450 | |
|
452 | 451 | def selectProfilesByIndex(self, minIndex, maxIndex, nProfiles): |
|
453 | 452 | """ |
|
454 | 453 | Selecciona un bloque de datos en base a un grupo indices de perfiles segun el rango |
|
455 | 454 | minIndex <= index <= maxIndex |
|
456 | 455 | |
|
457 | 456 | Input: |
|
458 | 457 | minIndex : valor de indice minimo de perfil a considerar |
|
459 | 458 | maxIndex : valor de indice maximo de perfil a considerar |
|
460 | 459 | nProfiles : numero de profiles |
|
461 | 460 | |
|
462 | 461 | Affected: |
|
463 | 462 | self.dataOutObj.flagNoData |
|
464 | 463 | self.profSelectorObjIndex |
|
465 | 464 | |
|
466 | 465 | Return: |
|
467 | 466 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
468 | 467 | """ |
|
469 | 468 | |
|
470 | 469 | if self.dataOutObj.flagNoData: |
|
471 | 470 | return 0 |
|
472 | 471 | |
|
473 | 472 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): |
|
474 | 473 | self.addProfileSelector(nProfiles) |
|
475 | 474 | |
|
476 | 475 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] |
|
477 | 476 | |
|
478 | 477 | if not(profileSelectorObj.isProfileInRange(minIndex, maxIndex)): |
|
479 | 478 | self.dataOutObj.flagNoData = True |
|
480 | 479 | self.profSelectorObjIndex += 1 |
|
481 | 480 | return 0 |
|
482 | 481 | |
|
483 | 482 | self.dataOutObj.flagNoData = False |
|
484 | 483 | self.profSelectorObjIndex += 1 |
|
485 | 484 | |
|
486 | 485 | return 1 |
|
487 | 486 | |
|
488 | 487 | def selectNtxs(self, ntx): |
|
489 | 488 | pass |
|
490 | 489 | |
|
491 | 490 | |
|
492 | 491 | class Decoder: |
|
493 | 492 | |
|
494 | 493 | data = None |
|
495 | 494 | profCounter = 1 |
|
496 | 495 | nCode = None |
|
497 | 496 | nBaud = None |
|
498 | 497 | codeIndex = 0 |
|
499 | 498 | code = None |
|
500 | 499 | flag = False |
|
501 | 500 | |
|
502 | 501 | def __init__(self,code, ncode, nbaud): |
|
503 | 502 | |
|
504 | 503 | self.data = None |
|
504 | self.ndata = None | |
|
505 | 505 | self.profCounter = 1 |
|
506 | 506 | self.nCode = ncode |
|
507 | 507 | self.nBaud = nbaud |
|
508 | 508 | self.codeIndex = 0 |
|
509 | 509 | self.code = code #this is a List |
|
510 | 510 | self.flag = False |
|
511 | 511 | |
|
512 |
def exe(self, data, ndata=None, |
|
|
512 | def exe(self, data, ndata=None, mode = 0): | |
|
513 | 513 | |
|
514 | 514 | if ndata == None: ndata = data.shape[1] |
|
515 | 515 | |
|
516 |
if |
|
|
516 | if mode == 0: | |
|
517 | 517 | self.convolutionInFreq(data,ndata) |
|
518 | 518 | |
|
519 |
if |
|
|
519 | if mode == 1: | |
|
520 | 520 | self.convolutionInTime(data, ndata) |
|
521 | 521 |
|
|
522 | self.ndata = ndata - self.nBaud + 1 | |
|
523 | ||
|
524 | return self.data, self.ndata | |
|
525 | ||
|
522 | 526 | def convolutionInFreq(self,data, ndata): |
|
523 | 527 | |
|
524 | 528 | newcode = numpy.zeros(ndata) |
|
525 | 529 | newcode[0:self.nBaud] = self.code[self.codeIndex] |
|
526 | 530 | |
|
527 | 531 | self.codeIndex += 1 |
|
528 | 532 | |
|
529 | 533 | fft_data = numpy.fft.fft(data, axis=1) |
|
530 | 534 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
531 | 535 | fft_code = fft_code.reshape(1,len(fft_code)) |
|
532 | 536 | |
|
533 | 537 | conv = fft_data.copy() |
|
534 | 538 | conv.fill(0) |
|
535 | 539 | |
|
536 | 540 | conv = fft_data*fft_code |
|
537 | 541 | |
|
538 |
|
|
|
542 | data = numpy.fft.ifft(conv,axis=1) | |
|
543 | self.data = data[:,:-self.nBaud+1] | |
|
539 | 544 | self.flag = True |
|
540 | 545 | |
|
541 | 546 | if self.profCounter == self.nCode: |
|
542 | 547 | self.profCounter = 0 |
|
543 | 548 | self.codeIndex = 0 |
|
544 | 549 | |
|
545 | 550 | self.profCounter += 1 |
|
546 | 551 | |
|
547 | 552 | def convolutionInTime(self, data, ndata): |
|
548 | 553 | |
|
549 | 554 | nchannel = data.shape[1] |
|
550 | 555 | newcode = self.code[self.codeIndex] |
|
551 | 556 | self.codeIndex += 1 |
|
552 | 557 | conv = data.copy() |
|
553 | 558 | for i in range(nchannel): |
|
554 |
conv[i,:] = numpy.correlate(data[i,:], newcode |
|
|
559 | conv[i,:] = numpy.correlate(data[i,:], newcode) | |
|
555 | 560 | |
|
556 | 561 | self.data = conv |
|
557 | 562 | self.flag = True |
|
558 | 563 | |
|
559 | 564 | if self.profCounter == self.nCode: |
|
560 | 565 | self.profCounter = 0 |
|
561 | 566 | self.codeIndex = 0 |
|
562 | 567 | |
|
563 | 568 | self.profCounter += 1 |
|
564 | 569 | |
|
565 | 570 | |
|
566 | 571 | class CoherentIntegrator: |
|
567 | 572 | |
|
568 | 573 | integ_counter = None |
|
569 | 574 | data = None |
|
570 | 575 | navg = None |
|
571 | 576 | buffer = None |
|
572 | 577 | nCohInt = None |
|
573 | 578 | |
|
574 | 579 | def __init__(self, N=None,timeInterval=None): |
|
575 | 580 | |
|
576 | 581 | self.data = None |
|
577 | 582 | self.navg = None |
|
578 | 583 | self.buffer = None |
|
579 | 584 | self.timeOut = None |
|
580 | 585 | self.exitCondition = False |
|
581 | 586 | self.isReady = False |
|
582 | 587 | self.nCohInt = N |
|
583 | 588 | self.integ_counter = 0 |
|
584 | 589 | if timeInterval!=None: |
|
585 | 590 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
586 | 591 | |
|
587 | 592 | if ((timeInterval==None) and (N==None)): |
|
588 |
|
|
|
589 | sys.exit(0) | |
|
590 |
|
|
|
593 | raise ValueError, "N = None ; timeInterval = None" | |
|
594 | ||
|
595 | if timeInterval == None: | |
|
591 | 596 | self.timeFlag = False |
|
592 | 597 | else: |
|
593 | 598 | self.timeFlag = True |
|
594 | 599 | |
|
595 | 600 | def exe(self, data, timeOfData): |
|
596 | 601 | |
|
597 | 602 | if self.timeFlag: |
|
598 | 603 | if self.timeOut == None: |
|
599 | 604 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
600 | 605 | |
|
601 | 606 | if timeOfData < self.timeOut: |
|
602 | 607 | if self.buffer == None: |
|
603 | 608 | self.buffer = data |
|
604 | 609 | else: |
|
605 | 610 | self.buffer = self.buffer + data |
|
606 | 611 | self.integ_counter += 1 |
|
607 | 612 | else: |
|
608 | 613 | self.exitCondition = True |
|
609 | 614 | |
|
610 | 615 | else: |
|
611 | 616 | if self.integ_counter < self.nCohInt: |
|
612 | 617 | if self.buffer == None: |
|
613 | 618 | self.buffer = data |
|
614 | 619 | else: |
|
615 | 620 | self.buffer = self.buffer + data |
|
616 | 621 | |
|
617 | 622 | self.integ_counter += 1 |
|
618 | 623 | |
|
619 | 624 | if self.integ_counter == self.nCohInt: |
|
620 | 625 | self.exitCondition = True |
|
621 | 626 | |
|
622 | 627 | if self.exitCondition: |
|
623 | 628 | self.data = self.buffer |
|
624 | 629 | self.navg = self.integ_counter |
|
625 | 630 | self.isReady = True |
|
626 | 631 | self.buffer = None |
|
627 | 632 | self.timeOut = None |
|
628 | 633 | self.integ_counter = 0 |
|
629 | 634 | self.exitCondition = False |
|
630 | 635 | |
|
631 | 636 | if self.timeFlag: |
|
632 | 637 | self.buffer = data |
|
633 | 638 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
634 | 639 | else: |
|
635 | 640 | self.isReady = False |
|
636 | 641 | |
|
637 | 642 | |
|
638 | 643 | |
|
639 | 644 | class ProfileSelector: |
|
640 | 645 | |
|
641 | 646 | profileIndex = None |
|
642 | 647 | # Tamanho total de los perfiles |
|
643 | 648 | nProfiles = None |
|
644 | 649 | |
|
645 | 650 | def __init__(self, nProfiles): |
|
646 | 651 | |
|
647 | 652 | self.profileIndex = 0 |
|
648 | 653 | self.nProfiles = nProfiles |
|
649 | 654 | |
|
650 | 655 | def incIndex(self): |
|
651 | 656 | self.profileIndex += 1 |
|
652 | 657 | |
|
653 | 658 | if self.profileIndex >= self.nProfiles: |
|
654 | 659 | self.profileIndex = 0 |
|
655 | 660 | |
|
656 | 661 | def isProfileInRange(self, minIndex, maxIndex): |
|
657 | 662 | |
|
658 | 663 | if self.profileIndex < minIndex: |
|
659 | 664 | return False |
|
660 | 665 | |
|
661 | 666 | if self.profileIndex > maxIndex: |
|
662 | 667 | return False |
|
663 | 668 | |
|
664 | 669 | return True |
|
665 | 670 | |
|
666 | 671 | def isProfileInList(self, profileList): |
|
667 | 672 | |
|
668 | 673 | if self.profileIndex not in profileList: |
|
669 | 674 | return False |
|
670 | 675 | |
|
671 | 676 | return True |
|
672 | 677 | |
|
673 | 678 | |
|
674 | 679 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now