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