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