''' $Author: murco $ $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $ ''' import sys import numpy import copy import datetime class Header: def __init__(self): raise def copy(self): return copy.deepcopy(self) def read(): pass def write(): pass def printInfo(self): print "#"*100 print self.__class__.__name__.upper() print "#"*100 for key in self.__dict__.keys(): print "%s = %s" %(key, self.__dict__[key]) class BasicHeader(Header): size = None version = None dataBlock = None utc = None ltc = None miliSecond = None timeZone = None dstFlag = None errorCount = None struct = None datatime = None __LOCALTIME = None def __init__(self, useLocalTime=True): self.size = 0 self.version = 0 self.dataBlock = 0 self.utc = 0 self.miliSecond = 0 self.timeZone = 0 self.dstFlag = 0 self.errorCount = 0 self.struct = numpy.dtype([ ('nSize',' 0: fp.seek(jumpFp) except Exception, e: print "RadarControllerHeader: " + e return 0 return 1 def write(self, fp): headerTuple = (self.size, self.expType, self.nTx, self.ipp, self.txA, self.txB, self.nWindows, self.numTaus, self.codeType, self.line6Function, self.line5Function, self.fClock, self.prePulseBefore, self.prePulserAfter, self.rangeIpp, self.rangeTxA, self.rangeTxB) header = numpy.array(headerTuple,self.struct) header.tofile(fp) dynamic = self.dynamic dynamic.tofile(fp) return 1 class ProcessingHeader(Header): size = None dtype = None blockSize = None profilesPerBlock = None dataBlocksPerFile = None nWindows = None processFlags = None nCohInt = None nIncohInt = None totalSpectra = None struct = None flag_dc = None flag_cspc = None def __init__(self): self.size = 0 self.dtype = 0 self.blockSize = 0 self.profilesPerBlock = 0 self.dataBlocksPerFile = 0 self.nWindows = 0 self.processFlags = 0 self.nCohInt = 0 self.nIncohInt = 0 self.totalSpectra = 0 self.struct = numpy.dtype([ ('nSize',' 0: self.flag_cspc = True # except Exception, e: # print "Error ProcessingHeader: " # return 0 return 1 def write(self, fp): headerTuple = (self.size, self.dtype, self.blockSize, self.profilesPerBlock, self.dataBlocksPerFile, self.nWindows, self.processFlags, self.nCohInt, self.nIncohInt, self.totalSpectra) header = numpy.array(headerTuple,self.struct) header.tofile(fp) if self.nWindows != 0: sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) samplingWindow = numpy.array(sampleWindowTuple,self.structSamplingWindow) samplingWindow.tofile(fp) if self.totalSpectra != 0: spectraComb = numpy.array([],numpy.dtype('u1')) spectraComb = self.spectraComb spectraComb.tofile(fp) # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: # nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba # nCode.tofile(fp) # # nBaud = numpy.array([self.nBaud], numpy.dtype('u4')) # nBaud.tofile(fp) # # code = self.code.reshape(self.nCode*self.nBaud) # code = code.astype(numpy.dtype('