@@ -178,6 +178,8 class SpectraReader(JRODataReader): | |||
|
178 | 178 | |
|
179 | 179 | channelList = None |
|
180 | 180 | |
|
181 | self.flag_cspc = False | |
|
182 | ||
|
181 | 183 | |
|
182 | 184 | def __hasNotDataInBuffer(self): |
|
183 | 185 | return 1 |
@@ -211,13 +213,23 class SpectraReader(JRODataReader): | |||
|
211 | 213 | self.nPairs = self.nPairs + 1 #par de canales diferentes |
|
212 | 214 | self.pairList.append( (self.m_ProcessingHeader.spectraComb[i], self.m_ProcessingHeader.spectraComb[i+1]) ) |
|
213 | 215 | |
|
216 | if self.nPairs > 0: | |
|
217 | self.flag_cspc = True | |
|
218 | ||
|
214 | 219 | pts2read = self.m_ProcessingHeader.numHeights * self.m_ProcessingHeader.profilesPerBlock |
|
215 | 220 | |
|
216 | 221 |
self.pts2read_SelfSpectra = int( |
|
222 | self.blocksize = self.pts2read_SelfSpectra | |
|
223 | ||
|
224 | if self.flag_cspc: | |
|
217 | 225 |
self.pts2read_CrossSpectra = int( |
|
226 | self.blocksize += self.pts2read_CrossSpectra | |
|
227 | ||
|
228 | if self.m_ProcessingHeader.flag_dc: | |
|
218 | 229 |
self.pts2read_DCchannels = int( |
|
230 | self.blocksize += self.pts2read_DCchannels | |
|
219 | 231 | |
|
220 | self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels | |
|
232 | # self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels | |
|
221 | 233 | |
|
222 | 234 |
self.channelList = numpy.arange( |
|
223 | 235 | |
@@ -247,39 +259,37 class SpectraReader(JRODataReader): | |||
|
247 | 259 | fpointer = self.fp.tell() |
|
248 | 260 | |
|
249 | 261 | spc = numpy.fromfile( self.fp, self.dataType[0], self.pts2read_SelfSpectra ) |
|
250 | cspc = numpy.fromfile( self.fp, self.dataType, self.pts2read_CrossSpectra ) | |
|
251 | dc = numpy.fromfile( self.fp, self.dataType, self.pts2read_DCchannels ) #int(self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels) ) | |
|
252 | ||
|
253 | try: | |
|
254 | 262 |
|
|
255 | if self.nPairs != 0: | |
|
263 | ||
|
264 | if self.flag_cspc: | |
|
265 | cspc = numpy.fromfile( self.fp, self.dataType, self.pts2read_CrossSpectra ) | |
|
256 | 266 |
|
|
257 |
|
|
|
258 | cspc = None | |
|
267 | ||
|
268 | if self.m_ProcessingHeader.flag_dc: | |
|
269 | dc = numpy.fromfile( self.fp, self.dataType, self.pts2read_DCchannels ) #int(self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels) ) | |
|
259 | 270 | dc = dc.reshape( (self.m_SystemHeader.numChannels, self.m_ProcessingHeader.numHeights) ) #transforma a un arreglo 2D |
|
260 | except: | |
|
261 | print "Data file %s is invalid" % self.filename | |
|
262 | return 0 | |
|
271 | ||
|
263 | 272 | |
|
264 | 273 |
if not( |
|
265 | 274 | spc = numpy.roll( spc, self.m_ProcessingHeader.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones |
|
266 | 275 | |
|
267 |
if cspc |
|
|
276 | if self.flag_cspc: | |
|
268 | 277 | cspc = numpy.roll( cspc, self.m_ProcessingHeader.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones |
|
269 | 278 | |
|
279 | ||
|
270 | 280 | spc = numpy.transpose( spc, (0,2,1) ) |
|
281 | self.data_spc = spc | |
|
271 | 282 | |
|
272 |
if cspc |
|
|
283 | if self.flag_cspc: | |
|
273 | 284 | cspc = numpy.transpose( cspc, (0,2,1) ) |
|
274 | ||
|
275 | ||
|
276 | if cspc != None: | |
|
277 | 285 | self.data_cspc = cspc['real'] + cspc['imag']*1j |
|
278 | 286 | else: |
|
279 | 287 | self.data_cspc = None |
|
280 | 288 | |
|
281 | self.data_spc = spc | |
|
289 | if self.m_ProcessingHeader.flag_dc: | |
|
282 | 290 | self.data_dc = dc['real'] + dc['imag']*1j |
|
291 | else: | |
|
292 | self.data_dc = None | |
|
283 | 293 | |
|
284 | 294 | self.datablockIndex = 0 |
|
285 | 295 | self.flagIsNewFile = 0 |
@@ -342,6 +342,7 class ProcessingHeader(Header): | |||
|
342 | 342 | self.code = 0 |
|
343 | 343 | self.numBaud = 0 |
|
344 | 344 | self.shif_fft = False |
|
345 | self.flag_dc = False | |
|
345 | 346 | |
|
346 | 347 | def read(self, fp): |
|
347 | 348 | try: |
@@ -363,15 +364,18 class ProcessingHeader(Header): | |||
|
363 | 364 | self.samplesWin = self.samplingWindow['nsa'] |
|
364 | 365 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) |
|
365 | 366 | |
|
366 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: | |
|
367 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): | |
|
367 | 368 | self.numCode = numpy.fromfile(fp,'<u4',1) |
|
368 | 369 | self.numBaud = numpy.fromfile(fp,'<u4',1) |
|
369 | 370 | self.code = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) |
|
370 | 371 | |
|
371 | if self.processFlags & PROCFLAG.SHIFT_FFT_DATA == PROCFLAG.SHIFT_FFT_DATA: | |
|
372 | if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA): | |
|
372 | 373 | self.shif_fft = True |
|
373 | 374 | else: |
|
374 | 375 | self.shif_fft = False |
|
376 | ||
|
377 | if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC): | |
|
378 | self.flag_dc = True | |
|
375 | 379 | except: |
|
376 | 380 | return 0 |
|
377 | 381 |
General Comments 0
You need to be logged in to leave comments.
Login now