##// END OF EJS Templates
Los campos de Author y Id fueron agregados a todos los modulos
Miguel Valdez -
r18:bff21c9ea6b8
parent child
Show More
@@ -1,234 +1,234
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 8 import numpy
9 9 import plplot
10 10
11 from BasicGraph import *
11 from BaseGraph import *
12 12
13 13 class Spectrum:
14 14
15 15 graphObjDict = {}
16 16 showColorbar = False
17 17 showPowerProfile = True
18 18
19 19 __szchar = 0.7
20 20 __xrange = None
21 21 __yrange = None
22 22 __zrange = None
23 specObj = BasicGraph()
23 baseObj = BaseGraph()
24 24
25 25
26 26 def __init__(self):
27 27
28 28 key = "spec"
29 29
30 specObj = BasicGraph()
31 specObj.setName(key)
30 baseObj = BaseGraph()
31 baseObj.setName(key)
32 32
33 self.graphObjDict[key] = specObj
33 self.graphObjDict[key] = baseObj
34 34
35 35
36 36 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False):
37 37 """
38 38 """
39 39
40 40 xi = 0.12; xw = 0.78; xf = xi + xw
41 41 yi = 0.14; yw = 0.80; yf = yi + yw
42 42
43 43 xcmapi = xcmapf = 0.; xpowi = xpowf = 0.
44 44
45 45 key = "spec"
46 specObj = self.graphObjDict[key]
47 specObj.setSubpage(subpage)
48 specObj.setSzchar(self.__szchar)
49 specObj.setOpt("bcnts","bcnts")
50 specObj.setup(title,
46 baseObj = self.graphObjDict[key]
47 baseObj.setSubpage(subpage)
48 baseObj.setSzchar(self.__szchar)
49 baseObj.setOpt("bcnts","bcnts")
50 baseObj.setup(title,
51 51 xlabel,
52 52 ylabel,
53 53 colormap)
54 54
55 55 if showColorbar:
56 56 key = "colorbar"
57 57
58 cmapObj = BasicGraph()
58 cmapObj = BaseGraph()
59 59 cmapObj.setName(key)
60 60 cmapObj.setSubpage(subpage)
61 61 cmapObj.setSzchar(self.__szchar)
62 62 cmapObj.setOpt("bc","bcmt")
63 63 cmapObj.setup(title="dBs",
64 64 xlabel="",
65 65 ylabel="",
66 66 colormap=colormap)
67 67
68 68 self.graphObjDict[key] = cmapObj
69 69
70 70 xcmapi = 0.
71 71 xcmapw = 0.05
72 72 xw -= xcmapw
73 73
74 74 if showPowerProfile:
75 75 key = "powerprof"
76 76
77 powObj = BasicGraph()
77 powObj = BaseGraph()
78 78 powObj.setName(key)
79 79 powObj.setSubpage(subpage)
80 80 powObj.setSzchar(self.__szchar)
81 81 plplot.pllsty(2)
82 82 powObj.setOpt("bcntg","bc")
83 83 plplot.pllsty(1)
84 84 powObj.setup(title="Power Profile",
85 85 xlabel="dBs",
86 86 ylabel="")
87 87
88 88 self.graphObjDict[key] = powObj
89 89
90 90 xpowi = 0.
91 91 xpoww = 0.24
92 92 xw -= xpoww
93 93
94 94 xf = xi + xw
95 95 yf = yi + yw
96 96 xcmapf = xf
97 97
98 specObj.setScreenPos([xi, xf], [yi, yf])
98 baseObj.setScreenPos([xi, xf], [yi, yf])
99 99
100 100 if showColorbar:
101 101 xcmapi = xf + 0.02
102 102 xcmapf = xcmapi + xcmapw
103 103 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
104 104
105 105 if showPowerProfile:
106 106 xpowi = xcmapf + 0.06
107 107 xpowf = xpowi + xpoww
108 108 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
109 109
110 110
111 # specObj.initSubpage()
111 # baseObj.initSubpage()
112 112 #
113 113 # if showColorbar:
114 114 # cmapObj.initPlot()
115 115 #
116 116 # if showPowerProfile:
117 117 # powObj.initPlot()
118 118
119 119 self.showColorbar = showColorbar
120 120 self.showPowerProfile = showPowerProfile
121 121
122 122 def setRanges(self, xrange, yrange, zrange):
123 123
124 124 key = "spec"
125 specObj = self.graphObjDict[key]
126 specObj.setRanges(xrange, yrange, zrange)
125 baseObj = self.graphObjDict[key]
126 baseObj.setRanges(xrange, yrange, zrange)
127 127
128 128 keyList = self.graphObjDict.keys()
129 129
130 130 key = "colorbar"
131 131 if key in keyList:
132 132 cmapObj = self.graphObjDict[key]
133 133 cmapObj.setRanges([0., 1.], zrange)
134 134
135 135 key = "powerprof"
136 136 if key in keyList:
137 137 powObj = self.graphObjDict[key]
138 138 powObj.setRanges(zrange, yrange)
139 139
140 140 def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
141 141
142 142 key = "spec"
143 specObj = self.graphObjDict[key]
144 specObj.initSubpage()
143 baseObj = self.graphObjDict[key]
144 baseObj.initSubpage()
145 145
146 146 if xmin == None:
147 147 xmin = 0.
148 148
149 149 if xmax == None:
150 150 xmax = 1.
151 151
152 152 if ymin == None:
153 153 ymin = 0.
154 154
155 155 if ymax == None:
156 156 ymax = 1.
157 157
158 158 if zmin == None:
159 159 zmin = numpy.nanmin(data)
160 160
161 161 if zmax == None:
162 162 zmax = numpy.nanmax(data)
163 163
164 if not(specObj.hasRange):
164 if not(baseObj.hasRange):
165 165 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
166 166
167 specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1])
167 baseObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, baseObj.zrange[0], baseObj.zrange[1])
168 168
169 169 if self.showColorbar:
170 170 key = "colorbar"
171 171 cmapObj = self.graphObjDict[key]
172 172 cmapObj.colorbarPlot()
173 173
174 174 if self.showPowerProfile:
175 175 power = numpy.average(data, axis=1)
176 176
177 177 step = (ymax - ymin)/(power.shape[0]-1)
178 178 heis = numpy.arange(ymin, ymax + step, step)
179 179
180 180 key = "powerprof"
181 181 powObj = self.graphObjDict[key]
182 182 powObj.basicXYPlot(power, heis)
183 183
184 184 class CrossSpectrum:
185 185 graphObjDict = {}
186 186 showColorbar = False
187 187 showPowerProfile = True
188 188
189 189 __szchar = 0.7
190 190 __showPhase = False
191 191 __xrange = None
192 192 __yrange = None
193 193 __zrange = None
194 m_BasicGraph= BasicGraph()
194 m_BaseGraph= BaseGraph()
195 195
196 196 def __init__(self):
197 197 pass
198 198
199 199 def setup(self, subpage, title, xlabel, ylabel, colormap, showColorbar, showPowerProfile):
200 200 pass
201 201
202 202 def setRanges(self, xrange, yrange, zrange):
203 203 pass
204 204
205 205 def plotData(self, data, xmin, xmax, ymin, ymax, zmin, zmax):
206 206 pass
207 207
208 208 if __name__ == '__main__':
209 209
210 210 import numpy
211 211 plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2))
212 212 plplot.plsdev("xcairo")
213 213 plplot.plscolbg(255,255,255)
214 214 plplot.plscol0(1,0,0,0)
215 215 plplot.plinit()
216 216 plplot.plssub(2, 2)
217 217
218 218 nx = 64
219 219 ny = 100
220 220
221 221 data = numpy.random.uniform(-50,50,(nx,ny))
222 222
223 specObj = Spectrum()
224 specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
225 specObj.plotData(data)
223 baseObj = ColorPlot()
224 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
225 baseObj.plotData(data)
226 226
227 227 data = numpy.random.uniform(-50,50,(nx,ny))
228 228
229 spec2Obj = Spectrum()
229 spec2Obj = ColorPlot()
230 230 spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
231 231 spec2Obj.plotData(data)
232 232
233 233 plplot.plend()
234 234 exit(0) No newline at end of file
@@ -1,18 +1,96
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 import os, sys
8 import numpy
9 import plplot
10
11 path = os.path.split(os.getcwd())[0]
12 sys.path.append(path)
13
14 from Graphics.BasicGraph import *
15 from Model.Voltage import Voltage
16
17 class Osciloscope():
18
19 graphObjDict = {}
20 showPower = True
21
22 __szchar = 0.7
23 __xrange = None
24 __yrange = None
25 __zrange = None
26
27 def __init__(self):
28 key = "osc"
29
30 baseObj = BasicGraph()
31 baseObj.setName(key)
32
33 self.graphObjDict[key] = baseObj
34
35
36 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False):
37 pass
38
39 def setRanges(self, xrange, yrange, zrange):
40 pass
41
42 def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
43 pass
44
45
7 46
8 47 class VoltagePlot(object):
9 48 '''
10 49 classdocs
11 50 '''
12 51
52 __m_Voltage = None
13 53
14 def __init__(self):
54 def __init__(self, m_Voltage):
15 55 '''
16 56 Constructor
17 57 '''
58 self.__m_Voltage = m_Voltage
59
60 def setup(self):
61 pass
62
63 def addGraph(self, type, xrange=None, yrange=None, zrange=None):
64 pass
65
66 def plotData(self):
18 67 pass
68
69 if __name__ == '__main__':
70
71 import numpy
72
73 plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
74 plplot.plsdev("xcairo")
75 plplot.plscolbg(255,255,255)
76 plplot.plscol0(1,0,0,0)
77 plplot.plinit()
78 plplot.plssub(1, 2)
79
80 nx = 64
81 ny = 100
82
83 data = numpy.random.uniform(-50,50,(nx,ny))
84
85 baseObj = RTI()
86 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
87 baseObj.plotData(data)
88
89 data = numpy.random.uniform(-50,50,(nx,ny))
90
91 base2Obj = RTI()
92 base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
93 base2Obj.plotData(data)
94
95 plplot.plend()
96 exit(0) No newline at end of file
@@ -1,459 +1,460
1 1 '''
2 2 Created on 23/01/2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 8 import os, sys
9 9 import numpy
10 10 import glob
11 11 import fnmatch
12 12 import time
13 13 import datetime
14 14
15 path = os.path.split(os.getcwd())[0]
16 sys.path.append(path)
17
15 18 from IO.Header import *
16 19 from IO.Data import DataReader
17 20 from IO.Data import DataWriter
18 21
19 path = os.path.split(os.getcwd())[0]
20 sys.path.append(path)
21
22 22 from Model.Voltage import Voltage
23 23
24 24 class VoltageReader(DataReader):
25 25
26 26 __idFile = None
27 27
28 28 __fp = None
29 29
30 30 __startDateTime = None
31 31
32 32 __endDateTime = None
33 33
34 34 __dataType = None
35 35
36 36 __fileSizeByHeader = 0
37 37
38 38 __pathList = []
39 39
40 40 filenameList = []
41 41
42 42 __lastUTTime = 0
43 43
44 44 __maxTimeStep = 5
45 45
46 46 __flagIsNewFile = 0
47 47
48 48 __ippSeconds = 0
49 49
50 50 flagResetProcessing = 0
51 51
52 52 flagIsNewBlock = 0
53 53
54 54 noMoreFiles = 0
55 55
56 56 nReadBlocks = 0
57 57
58 58 online = 0
59 59
60 60 filename = None
61 61
62 62 fileSize = None
63 63
64 64 firstHeaderSize = 0
65 65
66 66 basicHeaderSize = 24
67 67
68 68 m_BasicHeader = BasicHeader()
69 69
70 70 m_SystemHeader = SystemHeader()
71 71
72 72 m_RadarControllerHeader = RadarControllerHeader()
73 73
74 74 m_ProcessingHeader = ProcessingHeader()
75 75
76 76 m_Voltage = None
77 77
78 78 __buffer = 0
79 79
80 80 __buffer_id = 9999
81 81
82 82 def __init__(self, m_Voltage = None):
83 83
84 84 if m_Voltage == None:
85 85 m_Voltage = Voltage()
86 86
87 87 self.m_Voltage = m_Voltage
88 88
89 89 def __rdSystemHeader(self,fp=None):
90 90 if fp == None:
91 91 fp = self.__fp
92 92
93 93 self.m_SystemHeader.read(fp)
94 94
95 95 def __rdRadarControllerHeader(self,fp=None):
96 96 if fp == None:
97 97 fp = self.__fp
98 98
99 99 self.m_RadarControllerHeader.read(fp)
100 100
101 101 def __rdProcessingHeader(self,fp=None):
102 102 if fp == None:
103 103 fp = self.__fp
104 104
105 105 self.m_ProcessingHeader.read(fp)
106 106
107 107 def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r"):
108 108
109 109 print "Searching files ..."
110 110
111 111 startUtSeconds = time.mktime(startDateTime.timetuple())
112 112 endUtSeconds = time.mktime(endDateTime.timetuple())
113 113
114 114 # startYear = startDateTime.timetuple().tm_year
115 115 # endYear = endDateTime.timetuple().tm_year
116 116 #
117 117 # startDoy = startDateTime.timetuple().tm_yday
118 118 # endDoy = endDateTime.timetuple().tm_yday
119 119 #
120 120 # yearRange = range(startYear,endYear+1)
121 121 #
122 122 # doyDoubleList = []
123 123 # if startYear == endYear:
124 124 # doyList = range(startDoy,endDoy+1)
125 125 # else:
126 126 # for year in yearRange:
127 127 # if (year == startYear):
128 128 # doyDoubleList.append(range(startDoy,365+1))
129 129 # elif (year == endYear):
130 130 # doyDoubleList.append(range(1,endDoy+1))
131 131 # else:
132 132 # doyDoubleList.append(range(1,365+1))
133 133 # doyList = []
134 134 # for list in doyDoubleList:
135 135 # doyList = doyList + list
136 136 #
137 137 # dirList = []
138 138 # for thisPath in os.listdir(path):
139 139 # if os.path.isdir(os.path.join(path,thisPath)):
140 140 # #dirList.append(os.path.join(path,thisPath))
141 141 # dirList.append(thisPath)
142 142 #
143 143 # pathList = []
144 144 # pathDict = {}
145 145 # for year in yearRange:
146 146 # for doy in doyList:
147 147 # match = fnmatch.filter(dirList, 'D' + '%4.4d%3.3d' % (year,doy))
148 148 # if len(match) == 0:
149 149 # match = fnmatch.filter(dirList, 'd' + '%4.4d%3.3d' % (year,doy))
150 150 # if len(match) == 0: continue
151 151 # if expLabel == '':
152 152 # pathList.append(os.path.join(path,match[0]))
153 153 # pathDict.setdefault(os.path.join(path,match[0]))
154 154 # pathDict[os.path.join(path,match[0])] = []
155 155 # else:
156 156 # pathList.append(os.path.join(path,os.path.join(match[0],expLabel)))
157 157 # pathDict.setdefault(os.path.join(path,os.path.join(match[0],expLabel)))
158 158 # pathDict[os.path.join(path,os.path.join(match[0],expLabel))] = []
159 159
160 160
161 161 dirList = []
162 162 for thisPath in os.listdir(path):
163 163 if os.path.isdir(os.path.join(path,thisPath)):
164 164 dirList.append(thisPath)
165 165
166 166 pathList = []
167 167
168 168 thisDateTime = startDateTime
169 169
170 170 while(thisDateTime <= endDateTime):
171 171 year = thisDateTime.timetuple().tm_year
172 172 doy = thisDateTime.timetuple().tm_yday
173 173
174 174 match = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy))
175 175 if len(match) == 0:
176 176 thisDateTime += datetime.timedelta(1)
177 177 continue
178 178
179 179 pathList.append(os.path.join(path,match[0],expLabel))
180 180 thisDateTime += datetime.timedelta(1)
181 181
182 182 filenameList = []
183 183 for thisPath in pathList:
184 184 fileList = glob.glob1(thisPath, "*%s" %ext)
185 185 #pathDict[thisPath].append(fileList)
186 186 fileList.sort()
187 187 for file in fileList:
188 188 filename = os.path.join(thisPath,file)
189 189 if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds):
190 190 filenameList.append(filename)
191 191
192 192 self.filenameList = filenameList
193 193
194 194 return pathList, filenameList
195 195
196 196 def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None):
197 197
198 198 try:
199 199 fp = open(filename,'rb')
200 200 except:
201 201 raise IOError, "The file %s can't be opened" %(filename)
202 202
203 203 if startUTSeconds==None:
204 204 startUTSeconds = self.startUTCSeconds
205 205
206 206 if endUTSeconds==None:
207 207 endUTSeconds = self.endUTCSeconds
208 208
209 209 m_BasicHeader = BasicHeader()
210 210
211 211 if not(m_BasicHeader.read(fp)):
212 212 return 0
213 213
214 214 fp.close()
215 215
216 216 if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)):
217 217 return 0
218 218
219 219 return 1
220 220
221 221 def __readBasicHeader(self, fp=None):
222 222
223 223 if fp == None:
224 224 fp = self.__fp
225 225
226 226 self.m_BasicHeader.read(fp)
227 227
228 228 def __readFirstHeader(self):
229 229
230 230 self.__readBasicHeader()
231 231 self.__rdSystemHeader()
232 232 self.__rdRadarControllerHeader()
233 233 self.__rdProcessingHeader()
234 234 self.firstHeaderSize = self.m_BasicHeader.size
235 235
236 236 data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR))
237 237 if data_type == 0:
238 238 tmp=numpy.dtype([('real','<i1'),('imag','<i1')])
239 239 elif data_type == 1:
240 240 tmp=numpy.dtype([('real','<i2'),('imag','<i2')])
241 241 elif data_type == 2:
242 242 tmp=numpy.dtype([('real','<i4'),('imag','<i4')])
243 243 elif data_type == 3:
244 244 tmp=numpy.dtype([('real','<i8'),('imag','<i8')])
245 245 elif data_type == 4:
246 246 tmp=numpy.dtype([('real','<f4'),('imag','<f4')])
247 247 elif data_type == 5:
248 248 tmp=numpy.dtype([('real','<f8'),('imag','<f8')])
249 249 else:
250 250 raise ValueError, 'Data type was not defined'
251 251
252 252 self.__dataType = tmp
253 253 self.__fileSizeByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1)
254 254 c=3E8
255 255 self.__ippSeconds = 2*1000*self.m_RadarControllerHeader.ipp/c
256 256
257 257 def __setNextFileOnline(self):
258 258 return 0
259 259
260 260 def __setNextFileOffline(self):
261 261
262 262 idFile = self.__idFile
263 263 while(True):
264 264
265 265 idFile += 1
266 266
267 267 if not(idFile < len(self.filenameList)):
268 268 self.noMoreFiles = 1
269 269 return 0
270 270
271 271 filename = self.filenameList[idFile]
272 272 fileSize = os.path.getsize(filename)
273 273 fp = open(filename,'rb')
274 274
275 275 currentSize = fileSize - fp.tell()
276 276 neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize
277 277
278 278 if (currentSize < neededSize):
279 279 continue
280 280
281 281 break
282 282
283 283 self.__flagIsNewFile = 1
284 284 self.__idFile = idFile
285 285 self.filename = filename
286 286 self.fileSize = fileSize
287 287 self.__fp = fp
288 288
289 289 print 'Setting the file: %s'%self.filename
290 290
291 291 return 1
292 292
293 293 def __setNextFile(self):
294 294
295 295 if self.online:
296 296 return self.__setNextFileOnline()
297 297 else:
298 298 return self.__setNextFileOffline()
299 299
300 300 def __setNewBlock(self):
301 301
302 302 if self.__fp == None:
303 303 return 0
304 304
305 305 if self.__flagIsNewFile:
306 306 return 1
307 307
308 308 currentSize = self.fileSize - self.__fp.tell()
309 309 neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize
310 310
311 311 # Bloque Completo
312 312 if (currentSize >= neededSize):
313 313 self.__readBasicHeader()
314 314 return 1
315 315
316 316 if not(self.__setNextFile()):
317 317 return 0
318 318
319 319 self.__readFirstHeader()
320 320
321 321 deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this
322 322
323 323 self.flagResetProcessing = 0
324 324 if deltaTime > self.__maxTimeStep:
325 325 self.flagResetProcessing = 1
326 326 self.nReadBlocks = 0
327 327
328 328 return 1
329 329
330 330 def __readBlock(self):
331 331 """Lee el bloque de datos desde la posicion actual del puntero del archivo y
332 332 actualiza todos los parametros relacionados al bloque de datos (data, time,
333 333 etc). La data leida es almacenada en el buffer y el contador de datos leidos es
334 334 seteado a 0
335 335 """
336 336
337 337 pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels
338 338
339 339 data = numpy.fromfile(self.__fp,self.__dataType,pts2read)
340 340
341 341 data = data.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels))
342 342
343 343 self.__flagIsNewFile = 0
344 344
345 345 self.flagIsNewBlock = 1
346 346
347 347 self.nReadBlocks += 1
348 348
349 349 self.__buffer = data
350 350
351 351 self.__buffer_id = 0
352 352
353 353 def readNextBlock(self):
354 354
355 355 if not(self.__setNewBlock()):
356 356 return 0
357 357
358 358 self.__readBlock()
359 359
360 360 self.__lastUTTime = self.m_BasicHeader.utc
361 361
362 362 return 1
363 363
364 364 def __hasNotDataInBuffer(self):
365 365 if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock:
366 366 return 1
367 367
368 368 return 0
369 369
370 370 def getData(self):
371 371 """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Voltage"
372 372 con todos los parametros asociados a este. cuando no hay datos en el buffer de
373 373 lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock"
374 374 """
375 375 self.flagResetProcessing = 0
376 376 self.flagIsNewBlock = 0
377 377
378 378 if self.__hasNotDataInBuffer():
379 379 self.readNextBlock()
380 380
381 381 if self.noMoreFiles == 1:
382 382 print 'Process finished'
383 383 return None
384 384
385 #data es un numpy array de 3 dmensiones (perfiles, alturas y canales)
385 386 data = self.__buffer[self.__buffer_id,:,:]
386 387
387 388 time = self.m_BasicHeader.utc + self.__buffer_id*self.__ippSeconds
388 389
389 390 self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy()
390 391 self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy()
391 392 self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy()
392 393 self.m_Voltage.m_SystemHeader = self.m_SystemHeader.copy()
393 394 self.m_Voltage.m_BasicHeader.utc = time
394 395 self.m_Voltage.data = data
395 396
396 397 self.__buffer_id += 1
397 398
398 399 #call setData - to Data Object
399 400
400 401 return data
401 402
402 403
403 404 def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0):
404 405
405 406 if online == 0:
406 407 pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext)
407 408
408 409 if len(filenameList) == 0:
409 410 self.__fp = None
410 411 self.noMoreFiles = 1
411 412 print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime())
412 413 return 0
413 414
414 415 # for thisFile in filenameList:
415 416 # print thisFile
416 417
417 418 self.__idFile = -1
418 419
419 420 if not(self.__setNextFile()):
420 421 print "No more files"
421 422 return 0
422 423
423 424 self.__readFirstHeader()
424 425
425 426 self.startUTCSeconds = time.mktime(startDateTime.timetuple())
426 427 self.endUTCSeconds = time.mktime(endDateTime.timetuple())
427 428
428 429 self.startYear = startDateTime.timetuple().tm_year
429 430 self.endYear = endDateTime.timetuple().tm_year
430 431
431 432 self.startDoy = startDateTime.timetuple().tm_yday
432 433 self.endDoy = endDateTime.timetuple().tm_yday
433 434 #call fillHeaderValues() - to Data Object
434 435
435 436 self.__pathList = pathList
436 437 self.filenameList = filenameList
437 438 self.online = online
438 439
439 440 class VoltageWriter(DataWriter):
440 441
441 442 m_BasicHeader= BasicHeader()
442 443
443 444
444 445 m_SystemHeader = SystemHeader()
445 446
446 447
447 448 m_RadarControllerHeader = RadarControllerHeader()
448 449
449 450
450 451 m_ProcessingHeader = ProcessingHeader()
451 452
452 453 m_Voltage = None
453 454
454 455 def __init__(self, m_Voltage):
455 456
456 457 self.m_Voltage = m_Voltage
457 458
458 459
459 460 No newline at end of file
@@ -1,48 +1,49
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7 import os, sys
8 8
9 9 path = os.path.split(os.getcwd())[0]
10 10 sys.path.append(path)
11 11
12 12 from Model.Data import Data
13 13 from IO.Header import *
14 14
15 15 class Voltage(Data):
16 16 '''
17 17 classdocs
18 18 '''
19 19
20 20
21 21 m_RadarControllerHeader= RadarControllerHeader()
22 22
23 23 m_ProcessingHeader= ProcessingHeader()
24 24
25 25 m_SystemHeader= SystemHeader()
26 26
27 27 m_BasicHeader= BasicHeader()
28 28
29 #data es un numpy array de 3 dmensiones (perfiles, alturas y canales)
29 30 data = None
30 31
31 32 noData = True
32 33
33 34
34 35 def __init__(self):
35 36 '''
36 37 Constructor
37 38 '''
38 39 pass
39 40
40 41 def copy(self):
41 42 obj = Voltage()
42 43 obj.m_BasicHeader = self.m_BasicHeader.copy()
43 44 obj.m_SystemHeader = self.m_SystemHeader.copy()
44 45 obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy()
45 46 obj.m_ProcessingHeader = self.m_ProcessingHeader.copy()
46 47
47 48 return obj
48 49 No newline at end of file
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now