##// END OF EJS Templates
Desplazamiento automatico de los puntos de FFT en el modulo de lectura de espectros.
Miguel Valdez -
r26:0d3203b6912d
parent child
Show More
@@ -211,7 +211,7 class BaseGraph:
211 self.ylabel = ylabel
211 self.ylabel = ylabel
212 self.__colormap = colormap
212 self.__colormap = colormap
213
213
214 def plotBox(self, xmin, xmax, ymin, ymax):
214 def plotBox(self, xmin, xmax, ymin, ymax, xopt=None, yopt=None):
215 """
215 """
216
216
217 """
217 """
@@ -224,7 +224,12 class BaseGraph:
224 float(ymin),
224 float(ymin),
225 float(ymax)
225 float(ymax)
226 )
226 )
227 plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0)
227
228 if xopt == None: xopt = self.__xopt
229 if yopt == None: yopt = self.__yopt
230
231 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
232
228 plplot.pllab(self.xlabel, self.ylabel, self.title)
233 plplot.pllab(self.xlabel, self.ylabel, self.title)
229
234
230
235
@@ -497,7 +502,7 class ColorPlot():
497 powObj.setName(key)
502 powObj.setName(key)
498 powObj.setOpt("bcntg","bc")
503 powObj.setOpt("bcntg","bc")
499 powObj.setup(title="Power Profile",
504 powObj.setup(title="Power Profile",
500 xlabel="dBs",
505 xlabel="dB",
501 ylabel="")
506 ylabel="")
502
507
503 self.graphObjDict[key] = powObj
508 self.graphObjDict[key] = powObj
@@ -529,7 +534,7 class ColorPlot():
529 def setScreenPos(self, width='small'):
534 def setScreenPos(self, width='small'):
530
535
531 if width == 'small':
536 if width == 'small':
532 xi = 0.12; yi = 0.12; xw = 0.86; yw = 0.70; xcmapw = 0.05; xpoww = 0.26; deltaxcmap = 0.02; deltaxpow = 0.06
537 xi = 0.13; yi = 0.12; xw = 0.86; yw = 0.70; xcmapw = 0.05; xpoww = 0.26; deltaxcmap = 0.02; deltaxpow = 0.05
533
538
534 if width == 'medium':
539 if width == 'medium':
535 xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60; xcmapw = 0.05; xpoww = 0.24; deltaxcmap = 0.02; deltaxpow = 0.06
540 xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60; xcmapw = 0.05; xpoww = 0.24; deltaxcmap = 0.02; deltaxpow = 0.06
@@ -599,7 +604,7 class ColorPlot():
599 cmapObj.colorbarPlot(0., 1., zmin, zmax)
604 cmapObj.colorbarPlot(0., 1., zmin, zmax)
600
605
601 if self.__showPowerProfile:
606 if self.__showPowerProfile:
602 power = numpy.average(data, axis=0)
607 power = numpy.max(data, axis=0)
603
608
604 step = (ymax - ymin)/(nY-1)
609 step = (ymax - ymin)/(nY-1)
605 heis = numpy.arange(ymin, ymax + step, step)
610 heis = numpy.arange(ymin, ymax + step, step)
@@ -610,7 +615,10 class ColorPlot():
610 plplot.pllsty(2)
615 plplot.pllsty(2)
611 powObj.plotBox(zmin, zmax, ymin, ymax)
616 powObj.plotBox(zmin, zmax, ymin, ymax)
612 plplot.pllsty(1)
617 plplot.pllsty(1)
618 powObj.plotBox(zmin, zmax, ymin, ymax, xopt='bc', yopt='bc')
619 plplot.plcol0(9)
613 powObj.basicXYPlot(power, heis)
620 powObj.basicXYPlot(power, heis)
621 plplot.plcol0(1)
614
622
615
623
616 class ColorPlotX():
624 class ColorPlotX():
@@ -59,17 +59,24 class Spectrum():
59 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
59 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
60
60
61 nChan = int(self.m_Spectra.m_SystemHeader.numChannels)
61 nChan = int(self.m_Spectra.m_SystemHeader.numChannels)
62 channels = range(nChan)
62
63
63 myTitle = ""
64 myXlabel = "Radial Velocity (m/s)"
64 myXlabel = ""
65 myYlabel = "Range (km)"
65 myYlabel = ""
66
66
67 for i in range(nChan):
67 for i in channels:
68 if titleList != None:
68 if titleList != None:
69 myTitle = titleList[i]
69 myTitle = titleList[i]
70 myXlabel = xlabelList[i]
70 myXlabel = xlabelList[i]
71 myYlabel = ylabelList[i]
71 myYlabel = ylabelList[i]
72
72
73 if self.m_Spectra.noise != None:
74 noise = '%4.2fdB' %(self.m_Spectra.noise[i])
75 else:
76 noise = '--'
77
78 myTitle = "Channel: %d - Noise: %s" %(i, noise)
79
73 self.__addGraph(i+1,
80 self.__addGraph(i+1,
74 title=myTitle,
81 title=myTitle,
75 xlabel=myXlabel,
82 xlabel=myXlabel,
@@ -86,7 +93,7 class Spectrum():
86 nx = int(numpy.sqrt(self.nGraphs)+1)
93 nx = int(numpy.sqrt(self.nGraphs)+1)
87 #ny = int(self.nGraphs/nx)
94 #ny = int(self.nGraphs/nx)
88
95
89 plplot.plsetopt("geometry", "%dx%d" %(400*nx, 300*nx))
96 plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx))
90 plplot.plsdev("xcairo")
97 plplot.plsdev("xcairo")
91 plplot.plscolbg(255,255,255)
98 plplot.plscolbg(255,255,255)
92 plplot.plscol0(1,0,0,0)
99 plplot.plscol0(1,0,0,0)
@@ -110,7 +117,7 class Spectrum():
110 if not(self.__isPlotIni):
117 if not(self.__isPlotIni):
111 self.iniPlot()
118 self.iniPlot()
112
119
113 data = numpy.log10(self.m_Spectra.data_spc)
120 data = 10.*numpy.log10(self.m_Spectra.data_spc)
114
121
115 nX, nY, nChan = numpy.shape(data)
122 nX, nY, nChan = numpy.shape(data)
116
123
@@ -127,7 +134,7 class Spectrum():
127 plplot.plbop()
134 plplot.plbop()
128 for i in range(self.nGraphs):
135 for i in range(self.nGraphs):
129 self.graphObjList[i].iniSubpage()
136 self.graphObjList[i].iniSubpage()
130 self.graphObjList[i].plotData(data[:,:,i],
137 self.graphObjList[i].plotData(data[i,:,:],
131 x,
138 x,
132 y,
139 y,
133 xmin=xmin,
140 xmin=xmin,
@@ -291,11 +291,17 class ProcessingHeader:
291 self.deltaHeight = self.samplingWindow['dh']
291 self.deltaHeight = self.samplingWindow['dh']
292 self.samplesWin = self.samplingWindow['nsa']
292 self.samplesWin = self.samplingWindow['nsa']
293 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
293 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
294
294 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
295 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
295 self.numCode = numpy.fromfile(fp,'<u4',1)
296 self.numCode = numpy.fromfile(fp,'<u4',1)
296 self.numBaud = numpy.fromfile(fp,'<u4',1)
297 self.numBaud = numpy.fromfile(fp,'<u4',1)
297 self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode)
298 self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode)
298
299
300 if self.processFlags & PROCFLAG.SHIFT_FFT_DATA == PROCFLAG.SHIFT_FFT_DATA:
301 self.shif_fft = True
302 else:
303 self.shif_fft = False
304
299
305
300 return 1
306 return 1
301
307
@@ -322,6 +328,7 class ProcessingHeader:
322 obj.numBaud = self.numBaud
328 obj.numBaud = self.numBaud
323 obj.codes = self.codes
329 obj.codes = self.codes
324
330
331 obj.shif_fft = self.shif_fft
325 return obj
332 return obj
326
333
327 def write(self, fp):
334 def write(self, fp):
@@ -385,9 +385,17 class SpectraReader(DataReader):
385 cspc = numpy.fromfile(self.__fp, self.__dataType, int(pts2read*Npair_CrossSpectra))
385 cspc = numpy.fromfile(self.__fp, self.__dataType, int(pts2read*Npair_CrossSpectra))
386 dc = numpy.fromfile(self.__fp, self.__dataType, int(self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels) )
386 dc = numpy.fromfile(self.__fp, self.__dataType, int(self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels) )
387
387
388 spc = spc.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, Npair_SelfSpectra))
388 spc = spc.reshape((Npair_SelfSpectra, self.m_ProcessingHeader.numHeights, self.m_ProcessingHeader.profilesPerBlock))
389 cspc = cspc.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, Npair_CrossSpectra))
389 cspc = cspc.reshape((Npair_CrossSpectra, self.m_ProcessingHeader.numHeights, self.m_ProcessingHeader.profilesPerBlock))
390 dc = dc.reshape((self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels))
390 dc = dc.reshape((self.m_SystemHeader.numChannels, self.m_ProcessingHeader.numHeights))
391
392 if not(self.m_ProcessingHeader.shif_fft):
393 spc = numpy.roll(spc, self.m_ProcessingHeader.profilesPerBlock/2, axis=2)
394 cspc = numpy.roll(cspc, self.m_ProcessingHeader.profilesPerBlock/2, axis=2)
395
396 spc = numpy.transpose(spc, (0,2,1))
397 cspc = numpy.transpose(cspc, (0,2,1))
398 #dc = numpy.transpose(dc, (0,2,1))
391
399
392 data_spc = spc
400 data_spc = spc
393 data_cspc = cspc['real'] + cspc['imag']*1j
401 data_cspc = cspc['real'] + cspc['imag']*1j
@@ -47,6 +47,8 class Spectra(Data):
47
47
48 self.dataType = None
48 self.dataType = None
49
49
50 self.noise = None
51
50 def copy(self):
52 def copy(self):
51 obj = Spectra()
53 obj = Spectra()
52 obj.m_BasicHeader = self.m_BasicHeader.copy()
54 obj.m_BasicHeader = self.m_BasicHeader.copy()
@@ -63,5 +65,7 class Spectra(Data):
63
65
64 obj.nProfiles = self.nProfiles
66 obj.nProfiles = self.nProfiles
65
67
68 obj.noise = self.noise
69
66 return obj
70 return obj
67 No newline at end of file
71
@@ -45,6 +45,8 class Voltage(Data):
45
45
46 self.flagResetProcessing = False
46 self.flagResetProcessing = False
47
47
48 self.noise = noise
49
48 def copy(self):
50 def copy(self):
49 obj = Voltage()
51 obj = Voltage()
50 obj.m_BasicHeader = self.m_BasicHeader.copy()
52 obj.m_BasicHeader = self.m_BasicHeader.copy()
@@ -61,5 +63,7 class Voltage(Data):
61 obj.dataType = self.dataType
63 obj.dataType = self.dataType
62 obj.flagResetProcessing = self.flagResetProcessing
64 obj.flagResetProcessing = self.flagResetProcessing
63
65
66 obj.noise = self.noise
67
64 return obj
68 return obj
65 No newline at end of file
69
@@ -33,7 +33,7 class TestSChain():
33 #self.path = '/remote/puma/2004_11/DVD/'
33 #self.path = '/remote/puma/2004_11/DVD/'
34
34
35 self.ppath = "/home/roj-idl71/tmp/data"
35 self.ppath = "/home/roj-idl71/tmp/data"
36 self.startDateTime = datetime.datetime(2011,1,1,17,49,0)
36 self.startDateTime = datetime.datetime(2011,1,24,18,20,0)
37 self.endDateTime = datetime.datetime(2011,1,30,18,10,0)
37 self.endDateTime = datetime.datetime(2011,1,30,18,10,0)
38
38
39 def createObjects(self):
39 def createObjects(self):
@@ -54,7 +54,7 class TestSChain():
54 ini = time.time()
54 ini = time.time()
55 while(True):
55 while(True):
56 self.readerObj.getData()
56 self.readerObj.getData()
57 self.plotObj.plotData(showColorbar=False, showPowerProfile=True)
57 self.plotObj.plotData(zmin=40, zmax=140, showColorbar=True, showPowerProfile=True)
58
58
59 # self.writerObj.putData()
59 # self.writerObj.putData()
60
60
General Comments 0
You need to be logged in to leave comments. Login now