##// END OF EJS Templates
Se agrega el metodo plotScope
Daniel Valdez -
r136:281987d46ec5
parent child
Show More
@@ -1,200 +1,219
1 1 '''
2 2
3 3 $Author$
4 4 $Id$
5 5 '''
6 6
7 7 import os
8 8 import sys
9 9 import numpy
10 import datetime
10 11
11 12 path = os.path.split(os.getcwd())[0]
12 13 sys.path.append(path)
13 14
14 15 from Data.Voltage import Voltage
15 16 from IO.VoltageIO import VoltageWriter
16 from Graphics.schainPlotTypes import ScopeFigure
17 from Graphics2.schainPlotTypes import ScopeFigure
17 18
18 19 class VoltageProcessor:
19 20 dataInObj = None
20 21 dataOutObj = None
21 22 integratorObjIndex = None
22 23 writerObjIndex = None
23 24 integratorObjList = None
24 25 writerObjList = None
25 26
26 27 def __init__(self):
27 28 self.integratorObjIndex = None
28 29 self.writerObjIndex = None
29 30 self.plotObjIndex = None
30 31 self.integratorObjList = []
31 32 self.writerObjList = []
32 33 self.plotObjList = []
33 34
34 35 def setup(self,dataInObj=None,dataOutObj=None):
35 36 self.dataInObj = dataInObj
36 37
37 38 if self.dataOutObj == None:
38 39 dataOutObj = Voltage()
39 40
40 41 self.dataOutObj = dataOutObj
41 42
42 43 return self.dataOutObj
43 44
44 45 def init(self):
45 46 self.integratorObjIndex = 0
46 47 self.writerObjIndex = 0
47 48 self.plotObjIndex = 0
48 49
49 50 if not(self.dataInObj.flagNoData):
50 51 self.dataOutObj.copy(self.dataInObj)
51 52 # No necesita copiar en cada init() los atributos de dataInObj
52 53 # la copia deberia hacerse por cada nuevo bloque de datos
53 54
54 55 def addScope(self, idfigure, nframes, wintitle, driver):
55 56 if idfigure==None:
56 57 idfigure = self.plotObjIndex
57 58
58 59 scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver)
59 60 self.plotObjList.append(scopeObj)
60 61
61 62 def plotScope(self,
62 63 idfigure=None,
63 64 minvalue=None,
64 65 maxvalue=None,
65 66 xmin=None,
66 67 xmax=None,
67 68 wintitle='',
68 69 driver='plplot',
69 70 save=False,
70 71 gpath=None,
71 72 titleList=None,
72 73 xlabelList=None,
73 74 ylabelList=None,
74 75 type="power"):
75 76
76 77 if self.dataOutObj.flagNoData:
77 78 return 0
78 79
79 80 nframes = len(self.dataOutObj.channelList)
80 81
81 82 if len(self.plotObjList) <= self.plotObjIndex:
82 83 self.addScope(idfigure, nframes, wintitle, driver)
84
85
86 if type=="power":
87 data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data)
88 data1D = data1D.real
89
90 if type =="iq":
91 data1D = self.dataOutObj.data
92
93 thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime)
83 94
84 self.plotObjList[self.plotObjIndex].plot1DArray(data1D=self.dataOutObj.data,
85 x=self.dataOutObj.heightList,
86 channelList=self.dataOutObj.channelList,
87 xmin=xmin,
88 xmax=xmax,
89 minvalue=minvalue,
90 maxvlaue=maxvalue,
91 save=save,
92 gpath=gpath)
95 dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
96 date = "%s"%(thisDatetime.strftime("%d-%b-%Y"))
93 97
98 figureTitle = "Scope Plot Radar Data: " + date
99
100 plotObj = self.plotObjList[self.plotObjIndex]
101
102 plotObj.plot1DArray(data1D,
103 self.dataOutObj.heightList,
104 self.dataOutObj.channelList,
105 xmin,
106 xmax,
107 minvalue,
108 maxvalue,
109 figureTitle,
110 save,
111 gpath)
112
94 113 self.plotObjIndex += 1
95 114
96 115
97 116 def addIntegrator(self,N,timeInterval):
98 117 objCohInt = CoherentIntegrator(N,timeInterval)
99 118 self.integratorObjList.append(objCohInt)
100 119
101 120 def addWriter(self, wrpath, blocksPerFile, profilesPerBlock):
102 121 writerObj = VoltageWriter(self.dataOutObj)
103 122 writerObj.setup(wrpath,blocksPerFile,profilesPerBlock)
104 123 self.writerObjList.append(writerObj)
105 124
106 125 def writeData(self, wrpath, blocksPerFile, profilesPerBlock):
107 126
108 127 if self.dataOutObj.flagNoData:
109 128 return 0
110 129
111 130 if len(self.writerObjList) <= self.writerObjIndex:
112 131 self.addWriter(wrpath, blocksPerFile, profilesPerBlock)
113 132
114 133 self.writerObjList[self.writerObjIndex].putData()
115 134
116 135 self.writerObjIndex += 1
117 136
118 137 def integrator(self, N=None, timeInterval=None):
119 138 if self.dataOutObj.flagNoData:
120 139 return 0
121 140 if len(self.integratorObjList) <= self.integratorObjIndex:
122 141 self.addIntegrator(N,timeInterval)
123 142
124 143 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
125 144 myCohIntObj.exe(data=self.dataOutObj.data,timeOfData=None)
126 145
127 146
128 147
129 148 class CoherentIntegrator:
130 149
131 150 integ_counter = None
132 151 data = None
133 152 navg = None
134 153 buffer = None
135 154 nCohInt = None
136 155
137 156 def __init__(self, N=None,timeInterval=None):
138 157
139 158 self.data = None
140 159 self.navg = None
141 160 self.buffer = None
142 161 self.timeOut = None
143 162 self.exitCondition = False
144 163 self.isReady = False
145 164 self.nCohInt = N
146 165 self.integ_counter = 0
147 166 if timeInterval!=None:
148 167 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
149 168
150 169 if ((timeInterval==None) and (N==None)):
151 170 raise ValueError, "N = None ; timeInterval = None"
152 171
153 172 if timeInterval == None:
154 173 self.timeFlag = False
155 174 else:
156 175 self.timeFlag = True
157 176
158 177 def exe(self, data, timeOfData):
159 178
160 179 if self.timeFlag:
161 180 if self.timeOut == None:
162 181 self.timeOut = timeOfData + self.timeIntervalInSeconds
163 182
164 183 if timeOfData < self.timeOut:
165 184 if self.buffer == None:
166 185 self.buffer = data
167 186 else:
168 187 self.buffer = self.buffer + data
169 188 self.integ_counter += 1
170 189 else:
171 190 self.exitCondition = True
172 191
173 192 else:
174 193 if self.integ_counter < self.nCohInt:
175 194 if self.buffer == None:
176 195 self.buffer = data
177 196 else:
178 197 self.buffer = self.buffer + data
179 198
180 199 self.integ_counter += 1
181 200
182 201 if self.integ_counter == self.nCohInt:
183 202 self.exitCondition = True
184 203
185 204 if self.exitCondition:
186 205 self.data = self.buffer
187 206 self.navg = self.integ_counter
188 207 self.isReady = True
189 208 self.buffer = None
190 209 self.timeOut = None
191 210 self.integ_counter = 0
192 211 self.exitCondition = False
193 212
194 213 if self.timeFlag:
195 214 self.buffer = data
196 215 self.timeOut = timeOfData + self.timeIntervalInSeconds
197 216 else:
198 217 self.isReady = False
199 218
200 219
General Comments 0
You need to be logged in to leave comments. Login now