##// END OF EJS Templates
Correcion de plot eje, graficos centrados, seleccion de ploteo real,imag, abs por defecto, pruebas integrando5 min
avaldez -
r1244:464f48b8a1f9
parent child
Show More
@@ -297,7 +297,6 class JROData(GenericData):
297 297
298 298 def getFmax(self):
299 299 PRF = 1. / (self.ippSeconds * self.nCohInt)
300
301 300 fmax = PRF
302 301 return fmax
303 302
@@ -605,11 +604,9 class Spectra(JROData):
605 604 noise = numpy.zeros(self.nChannels)
606 605
607 606 for channel in range(self.nChannels):
608 #print "confuse",self.data_spc.dtype
609 607 daux = self.data_spc[channel,
610 608 xmin_index:xmax_index, ymin_index:ymax_index]
611 609
612 #print "HI3.0",(daux.dtype),daux.shape
613 610 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
614 611
615 612 return noise
@@ -634,9 +631,7 class Spectra(JROData):
634 631 return freqrange
635 632
636 633 def getAcfRange(self, extrapoints=0):
637 #print "miay",self.ippFactor
638 deltafreq = 10. / (self.getFmax() / (self.nFFTPoints * self.ippFactor))
639 #print deltafreq
634 deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) )
640 635 freqrange = deltafreq * \
641 636 (numpy.arange(self.nFFTPoints + extrapoints) -
642 637 self.nFFTPoints / 2.) - deltafreq / 2
@@ -646,10 +641,11 class Spectra(JROData):
646 641 def getFreqRange(self, extrapoints=0):
647 642
648 643 deltafreq = self.getFmax() / (self.nFFTPoints * self.ippFactor)
644 #print "deltafreq", deltafreq
649 645 freqrange = deltafreq * \
650 646 (numpy.arange(self.nFFTPoints + extrapoints) -
651 647 self.nFFTPoints / 2.) - deltafreq / 2
652
648 #print "freqrange",freqrange
653 649 return freqrange
654 650
655 651 def getVelRange(self, extrapoints=0):
@@ -274,7 +274,6 class ACFPlot(Figure):
274 274 folder=None, username=None, password=None,
275 275 xaxis="frequency"):
276 276
277
278 277 channel0 = channel
279 278 nSamples = nSamples
280 279 resFactor = resolutionFactor
@@ -313,12 +312,6 class ACFPlot(Figure):
313 312 shape = dataOut.data_acf.shape
314 313 hei_index = numpy.arange(shape[2])
315 314 hei_plot = numpy.arange(nSamples)*resFactor
316 #print hei_plot
317 #import matplotlib.pyplot as plt
318 #c=z[0,:,0]*15+15
319 #plt.plot(c)
320 #plt.show()
321 #print "HOLA#
322 315
323 316 if nSampleList is not None:
324 317 for nsample in nSampleList:
@@ -335,18 +328,9 class ACFPlot(Figure):
335 328 #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight
336 329 min = numpy.min(z[0,:,0])
337 330 max =numpy.max(z[0,:,0])
338
339 331 for i in range(shape[0]):
340 332 for j in range(shape[2]):
341 333 z[i,:,j]= (((z[i,:,j]-min)/(max-min))*deltaHeight*resFactor + j*deltaHeight)
342 #z[i,:,j]= (z[i,:,j]+1.0)*deltaHeight*dataOut.step/2.0 + j*deltaHeight*dataOut.step
343
344 #print deltaHeight
345 #print resFactor
346 #print numpy.max(z[0,:,0])
347 #import matplotlib.pyplot as plt
348 #plt.plot((z[0,:,0])*deltaHeight)
349 #plt.show()
350 334
351 335 if xaxis == "frequency":
352 336 x = dataOut.getFreqRange()/1000.
@@ -355,7 +339,8 class ACFPlot(Figure):
355 339 ylabel = "Power (dB)"
356 340
357 341 elif xaxis == "time":
358 x = dataOut.getAcfRange()
342 delta= dataOut.getAcfRange()[1]-dataOut.getAcfRange()[0]
343 x = dataOut.getAcfRange()+delta/2.0
359 344 zdB = z[channel0,:,hei_plot]
360 345 xlabel = "Time (ms)"
361 346 ylabel = "ACF"
@@ -22,20 +22,19 class SpectraProc(ProcessingUnit):
22 22
23 23 def __updateSpecFromVoltage(self):
24 24
25 self.dataOut.timeZone = self.dataIn.timeZone
26 self.dataOut.dstFlag = self.dataIn.dstFlag
27 self.dataOut.errorCount = self.dataIn.errorCount
28 self.dataOut.useLocalTime = self.dataIn.useLocalTime
25 self.dataOut.timeZone = self.dataIn.timeZone
26 self.dataOut.dstFlag = self.dataIn.dstFlag
27 self.dataOut.errorCount = self.dataIn.errorCount
28 self.dataOut.useLocalTime= self.dataIn.useLocalTime
29 29 try:
30 30 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
31 31 except:
32 32 pass
33 33 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
34 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
35 self.dataOut.channelList = self.dataIn.channelList
36 self.dataOut.heightList = self.dataIn.heightList
37 #print self.dataOut.heightList.shape,"spec4"
38 self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
34 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
35 self.dataOut.channelList = self.dataIn.channelList
36 self.dataOut.heightList = self.dataIn.heightList
37 self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
39 38
40 39 self.dataOut.nBaud = self.dataIn.nBaud
41 40 self.dataOut.nCode = self.dataIn.nCode
@@ -65,8 +64,6 class SpectraProc(ProcessingUnit):
65 64 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
66 65 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
67 66
68 self.dataOut.step = self.dataIn.step #
69
70 67 def __getFft(self):
71 68 """
72 69 Convierte valores de Voltaje a Spectra
@@ -125,7 +122,7 class SpectraProc(ProcessingUnit):
125 122
126 123 if self.dataIn.type == "Spectra":
127 124 self.dataOut.copy(self.dataIn)
128 print "hi",self.dataOut.ippSeconds
125
129 126 if shift_fft:
130 127 #desplaza a la derecha en el eje 2 determinadas posiciones
131 128 shift = int(self.dataOut.nFFTPoints/2)
@@ -156,7 +153,7 class SpectraProc(ProcessingUnit):
156 153 if self.buffer is None:
157 154 self.buffer = numpy.zeros((self.dataIn.nChannels,
158 155 nProfiles,
159 self.dataIn.heightList.shape[0]),
156 self.dataIn.heightList.shape[0]),#update heightlist
160 157 dtype='complex')
161 158
162 159
@@ -134,34 +134,27 class SpectraAFCProc(ProcessingUnit):
134 134 self.dataOut.blockSize = blocksize
135 135 self.dataOut.flagShiftFFT = True
136 136
137 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], code=None, nCode=1, nBaud=1):
137 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], code=None, nCode=1, nBaud=1,real= None, imag=None):
138 138
139 139 self.dataOut.flagNoData = True
140 140
141 141 if self.dataIn.type == "Spectra":
142 142 self.dataOut.copy(self.dataIn)
143 #print "hi",self.dataOut.ippSeconds
144
145 spc = self.dataOut.data_spc
146 data = numpy.fft.ifft(spc, axis=1)
147 data = numpy.fft.fftshift(data, axes=(1,))
148 acf = numpy.abs(data) # Autocorrelacion LLAMAR A ESTE VALOR ACF
149 #acf = data.imag
150 shape = acf.shape #nchannels, nprofiles, nsamples
151
152 #import matplotlib.pyplot as plt
153 #plt.plot(acf[0,:,0] / numpy.max(numpy.abs(acf[0,:,0])))
154 #plt.show()
143 spc = self.dataOut.data_spc
144 data = numpy.fft.ifft(spc, axis=1)
145 data = numpy.fft.fftshift(data, axes=(1,))
146 acf = numpy.abs(data) # Autocorrelacion LLAMAR A ESTE VALOR ACF
147 if real:
148 acf = data.real
149 if imag:
150 acf = data.imag
151 shape = acf.shape # nchannels, nprofiles, nsamples
155 152
156 153 # Normalizando
157 154 for i in range(shape[0]):
158 155 for j in range(shape[2]):
159 156 acf[i,:,j]= acf[i,:,j] / numpy.max(numpy.abs(acf[i,:,j]))
160 157
161 #import matplotlib.pyplot as plt
162 #plt.plot(acf[0,:,0])
163 #plt.show()
164
165 158 self.dataOut.data_acf = acf
166 159 return True
167 160
@@ -1186,12 +1186,12 class CombineProfiles(Operation):
1186 1186
1187 1187 class SSheightProfiles(Operation):
1188 1188
1189 step = None
1190 nsamples = None
1191 bufferShape = None
1192 profileShape= None
1193 sshProfiles = None
1194 profileIndex= None
1189 step = None
1190 nsamples = None
1191 bufferShape = None
1192 profileShape = None
1193 sshProfiles = None
1194 profileIndex = None
1195 1195
1196 1196 def __init__(self, **kwargs):
1197 1197
@@ -1203,35 +1203,35 class SSheightProfiles(Operation):
1203 1203 if step == None and nsamples == None:
1204 1204 raise ValueError, "step or nheights should be specified ..."
1205 1205
1206 self.step = step
1207 self.nsamples = nsamples
1208 self.__nChannels = dataOut.nChannels
1209 self.__nProfiles = dataOut.nProfiles
1210 self.__nHeis = dataOut.nHeights
1211 shape = dataOut.data.shape #nchannels, nprofiles, nsamples
1212 #print "shape",shape
1213 #last test
1214 residue = (shape[1] - self.nsamples) % self.step
1206 self.step = step
1207 self.nsamples = nsamples
1208 self.__nChannels = dataOut.nChannels
1209 self.__nProfiles = dataOut.nProfiles
1210 self.__nHeis = dataOut.nHeights
1211 shape = dataOut.data.shape #nchannels, nprofiles, nsamples
1212
1213
1214 residue = (shape[1] - self.nsamples) % self.step
1215 1215 if residue != 0:
1216 1216 print "The residue is %d, step=%d should be multiple of %d to avoid loss of %d samples"%(residue,step,shape[1] - self.nsamples,residue)
1217 1217
1218 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1219 numberProfile = self.nsamples
1220 numberSamples = (shape[1] - self.nsamples)/self.step
1218 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1219 numberProfile = self.nsamples
1220 numberSamples = (shape[1] - self.nsamples)/self.step
1221 1221
1222 1222 print "New number of profile: %d, number of height: %d, Resolution %d Km"%(numberProfile,numberSamples,deltaHeight*self.step)
1223 1223
1224 1224 self.bufferShape = shape[0], numberSamples, numberProfile # nchannels, nsamples , nprofiles
1225 1225 self.profileShape = shape[0], numberProfile, numberSamples # nchannels, nprofiles, nsamples
1226 1226
1227 self.buffer = numpy.zeros(self.bufferShape , dtype=numpy.complex)
1228 self.sshProfiles = numpy.zeros(self.profileShape, dtype=numpy.complex)
1227 self.buffer = numpy.zeros(self.bufferShape , dtype=numpy.complex)
1228 self.sshProfiles = numpy.zeros(self.profileShape, dtype=numpy.complex)
1229 1229
1230 1230 def run(self, dataOut, step, nsamples):
1231 1231
1232 dataOut.flagNoData = True
1233 dataOut.flagDataAsBlock =False
1234 profileIndex = None
1232 dataOut.flagNoData = True
1233 dataOut.flagDataAsBlock = False
1234 profileIndex = None
1235 1235
1236 1236 if not self.isConfig:
1237 1237 self.setup(dataOut, step=step , nsamples=nsamples)
@@ -1244,12 +1244,10 class SSheightProfiles(Operation):
1244 1244 for j in range(self.buffer.shape[0]):
1245 1245 self.sshProfiles[j] = numpy.transpose(self.buffer[j])
1246 1246
1247 profileIndex = self.nsamples
1248 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1249 ippSeconds = (deltaHeight*1.0e-6)/(0.15)
1247 profileIndex = self.nsamples
1248 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1249 ippSeconds = (deltaHeight*1.0e-6)/(0.15)
1250 1250
1251 #print "hi",dataOut.ippSeconds
1252 #print ippSeconds
1253 1251 dataOut.data = self.sshProfiles
1254 1252 dataOut.flagNoData = False
1255 1253 dataOut.heightList = numpy.arange(self.buffer.shape[1]) *self.step*deltaHeight + dataOut.heightList[0]
@@ -1258,7 +1256,6 class SSheightProfiles(Operation):
1258 1256 dataOut.flagDataAsBlock = True
1259 1257 dataOut.ippSeconds = ippSeconds
1260 1258 dataOut.step = self.step
1261 #print dataOut.ippSeconds
1262 1259
1263 1260
1264 1261 # import collections
General Comments 0
You need to be logged in to leave comments. Login now