##// END OF EJS Templates
23/11/2017
23/11/2017

File last commit:

r1123:72ed20327727
r1123:72ed20327727
Show More
jroIO_spectra.py
711 lines | 22.0 KiB | text/x-python | PythonLexer
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 '''
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 Created on Jul 2, 2014
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 @author: roj-idl71
'''
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 import numpy
from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
from schainpy.model.data.jrodata import Spectra
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
class SpectraReader(JRODataReader, ProcessingUnit):
ebocanegra
15/08/2017
r1001
ReceiverData Operation, test PlotData
r889 """
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Esta clase permite leer datos de espectros desde archivos procesados (.pdata). La lectura
ReceiverData Operation, test PlotData
r889 de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 son almacenados en tres buffer's para el Self Spectra, el Cross Spectra y el DC Channel.
paresCanalesIguales * alturas * perfiles (Self Spectra)
paresCanalesDiferentes * alturas * perfiles (Cross Spectra)
canales * alturas (DC Channels)
ebocanegra
15/08/2017
r1001
ReceiverData Operation, test PlotData
r889 Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader,
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 RadarControllerHeader y Spectra. Los tres primeros se usan para almacenar informacion de la
cabecera de datos (metadata), y el cuarto (Spectra) para obtener y almacenar un bloque de
datos desde el "buffer" cada vez que se ejecute el metodo "getData".
ReceiverData Operation, test PlotData
r889
Example:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 dpath = "/home/myuser/data"
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0)
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0)
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 readerObj = SpectraReader()
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 readerObj.setup(dpath, startTime, endTime)
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 while(True):
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 readerObj.getData()
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 print readerObj.data_spc
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 print readerObj.data_cspc
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 print readerObj.data_dc
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if readerObj.flagNoMoreFiles:
break
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
pts2read_SelfSpectra = 0
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 pts2read_CrossSpectra = 0
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 pts2read_DCchannels = 0
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 ext = ".pdata"
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 optchar = "P"
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 dataOut = None
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 nRdChannels = None
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 nRdPairs = None
ReceiverData Operation, test PlotData
r889
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 rdPairList = []
ReceiverData Operation, test PlotData
r889
def __init__(self, **kwargs):
"""
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Inicializador de la clase SpectraReader para la lectura de datos de espectros.
ReceiverData Operation, test PlotData
r889 Inputs:
ebocanegra
first commit
r965
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 dataOut : Objeto de la clase Spectra. Este objeto sera utilizado para
almacenar un perfil de datos cada vez que se haga un requerimiento
(getData). El perfil sera obtenido a partir del buffer de datos,
si el buffer esta vacio se hara un nuevo proceso de lectura de un
bloque de datos.
Si este parametro no es pasado se creara uno internamente.
ReceiverData Operation, test PlotData
r889
ebocanegra
first commit
r965
Affected:
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut
Return : None
"""
ReceiverData Operation, test PlotData
r889
ebocanegra
first commit
r965
#Eliminar de la base la herencia
ebocanegra
15/08/2017
r1001 ProcessingUnit.__init__(self, **kwargs)
ebocanegra
first commit
r965
# self.isConfig = False
self.pts2read_SelfSpectra = 0
self.pts2read_CrossSpectra = 0
self.pts2read_DCchannels = 0
self.datablock = None
self.utc = None
self.ext = ".pdata"
self.optchar = "P"
self.basicHeaderObj = BasicHeader(LOCALTIME)
self.systemHeaderObj = SystemHeader()
self.radarControllerHeaderObj = RadarControllerHeader()
self.processingHeaderObj = ProcessingHeader()
self.online = 0
self.fp = None
self.idFile = None
self.dtype = None
self.fileSizeByHeader = None
self.filenameList = []
self.filename = None
self.fileSize = None
self.firstHeaderSize = 0
self.basicHeaderSize = 24
self.pathList = []
self.lastUTTime = 0
self.maxTimeStep = 30
self.flagNoMoreFiles = 0
self.set = 0
self.path = None
self.delay = 60 #seconds
self.nTries = 3 #quantity tries
self.nFiles = 3 #number of files for searching
self.nReadBlocks = 0
self.flagIsNewFile = 1
self.__isFirstTimeOnline = 1
# self.ippSeconds = 0
self.flagDiscontinuousBlock = 0
self.flagIsNewBlock = 0
self.nTotalBlocks = 0
self.blocksize = 0
self.dataOut = self.createObjByDefault()
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.profileIndex = 1 #Always
def createObjByDefault(self):
ebocanegra
first commit
r965
dataObj = Spectra()
return dataObj
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def __hasNotDataInBuffer(self):
return 1
def getBlockDimension(self):
"""
Obtiene la cantidad de puntos a leer por cada bloque de datos
ebocanegra
first commit
r965
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Affected:
self.nRdChannels
self.nRdPairs
self.pts2read_SelfSpectra
self.pts2read_CrossSpectra
self.pts2read_DCchannels
self.blocksize
self.dataOut.nChannels
self.dataOut.nPairs
Return:
None
"""
self.nRdChannels = 0
self.nRdPairs = 0
self.rdPairList = []
ReceiverData Operation, test PlotData
r889
ebocanegra
first commit
r965 for i in range(0, self.processingHeaderObj.totalSpectra*2, 2):
if self.processingHeaderObj.spectraComb[i] == self.processingHeaderObj.spectraComb[i+1]:
self.nRdChannels = self.nRdChannels + 1 #par de canales iguales
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 else:
self.nRdPairs = self.nRdPairs + 1 #par de canales diferentes
self.rdPairList.append((self.processingHeaderObj.spectraComb[i], self.processingHeaderObj.spectraComb[i+1]))
pts2read = self.processingHeaderObj.nHeights * self.processingHeaderObj.profilesPerBlock
ebocanegra
first commit
r965
self.pts2read_SelfSpectra = int(self.nRdChannels * pts2read)
self.blocksize = self.pts2read_SelfSpectra
if self.processingHeaderObj.flag_cspc:
self.pts2read_CrossSpectra = int(self.nRdPairs * pts2read)
self.blocksize += self.pts2read_CrossSpectra
if self.processingHeaderObj.flag_dc:
self.pts2read_DCchannels = int(self.systemHeaderObj.nChannels * self.processingHeaderObj.nHeights)
self.blocksize += self.pts2read_DCchannels
# self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def readBlock(self):
"""
Lee el bloque de datos desde la posicion actual del puntero del archivo
(self.fp) y actualiza todos los parametros relacionados al bloque de datos
(metadata + data). La data leida es almacenada en el buffer y el contador del buffer
es seteado a 0
ebocanegra
first commit
r965
Return: None
Variables afectadas:
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.flagIsNewFile
self.flagIsNewBlock
self.nTotalBlocks
self.data_spc
self.data_cspc
self.data_dc
ebocanegra
first commit
r965 Exceptions:
Si un bloque leido no es un bloque valido
"""
print ' ======================================================== '
print ' '
print ' '
print self.processingHeaderObj.totalSpectra, 'TotalSpectra', type(self.processingHeaderObj.totalSpectra)
print self.processingHeaderObj.spectraComb, 'SpectraComb', type(self.processingHeaderObj.spectraComb)
print ' '
print ' '
print ' ======================================================== '
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 blockOk_flag = False
fpointer = self.fp.tell()
spc = numpy.fromfile( self.fp, self.dtype[0], self.pts2read_SelfSpectra )
spc = spc.reshape( (self.nRdChannels, self.processingHeaderObj.nHeights, self.processingHeaderObj.profilesPerBlock) ) #transforma a un arreglo 3D
ReceiverData Operation, test PlotData
r889
ebocanegra
first commit
r965 if self.processingHeaderObj.flag_cspc:
cspc = numpy.fromfile( self.fp, self.dtype, self.pts2read_CrossSpectra )
cspc = cspc.reshape( (self.nRdPairs, self.processingHeaderObj.nHeights, self.processingHeaderObj.profilesPerBlock) ) #transforma a un arreglo 3D
if self.processingHeaderObj.flag_dc:
dc = numpy.fromfile( self.fp, self.dtype, self.pts2read_DCchannels ) #int(self.processingHeaderObj.nHeights*self.systemHeaderObj.nChannels) )
dc = dc.reshape( (self.systemHeaderObj.nChannels, self.processingHeaderObj.nHeights) ) #transforma a un arreglo 2D
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not(self.processingHeaderObj.shif_fft):
#desplaza a la derecha en el eje 2 determinadas posiciones
shift = int(self.processingHeaderObj.profilesPerBlock/2)
spc = numpy.roll( spc, shift , axis=2 )
ebocanegra
first commit
r965
if self.processingHeaderObj.flag_cspc:
#desplaza a la derecha en el eje 2 determinadas posiciones
cspc = numpy.roll( cspc, shift, axis=2 )
#Dimensions : nChannels, nProfiles, nSamples
spc = numpy.transpose( spc, (0,2,1) )
self.data_spc = spc
if self.processingHeaderObj.flag_cspc:
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 cspc = numpy.transpose( cspc, (0,2,1) )
self.data_cspc = cspc['real'] + cspc['imag']*1j
else:
self.data_cspc = None
ebocanegra
23/11/2017
r1123 print 'SALE NONE ***********************************************************'
ebocanegra
first commit
r965
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.processingHeaderObj.flag_dc:
self.data_dc = dc['real'] + dc['imag']*1j
else:
self.data_dc = None
self.flagIsNewFile = 0
self.flagIsNewBlock = 1
self.nTotalBlocks += 1
self.nReadBlocks += 1
return 1
ebocanegra
first commit
r965
def getFirstHeader(self):
self.getBasicHeader()
self.dataOut.systemHeaderObj = self.systemHeaderObj.copy()
self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy()
# self.dataOut.ippSeconds = self.ippSeconds
# self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt * self.processingHeaderObj.nIncohInt * self.processingHeaderObj.profilesPerBlock
self.dataOut.dtype = self.dtype
# self.dataOut.nPairs = self.nPairs
self.dataOut.pairsList = self.rdPairList
self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock
self.dataOut.nFFTPoints = self.processingHeaderObj.profilesPerBlock
self.dataOut.nCohInt = self.processingHeaderObj.nCohInt
self.dataOut.nIncohInt = self.processingHeaderObj.nIncohInt
xf = self.processingHeaderObj.firstHeight + self.processingHeaderObj.nHeights*self.processingHeaderObj.deltaHeight
self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight)
self.dataOut.channelList = range(self.systemHeaderObj.nChannels)
self.dataOut.flagShiftFFT = True #Data is always shifted
self.dataOut.flagDecodeData = self.processingHeaderObj.flag_decode #asumo q la data no esta decodificada
self.dataOut.flagDeflipData = self.processingHeaderObj.flag_deflip #asumo q la data esta sin flip
def getData(self):
"""
First method to execute before "RUN" is called.
Copia el buffer de lectura a la clase "Spectra",
con todos los parametros asociados a este (metadata). cuando no hay datos en el buffer de
lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock"
Return:
0 : Si no hay mas archivos disponibles
1 : Si hizo una buena copia del buffer
Affected:
self.dataOut
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.flagIsNewBlock
"""
if self.flagNoMoreFiles:
self.dataOut.flagNoData = True
print 'Process finished'
return 0
ebocanegra
first commit
r965
self.flagDiscontinuousBlock = 0
self.flagIsNewBlock = 0
if self.__hasNotDataInBuffer():
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
if not( self.readNextBlock() ):
self.dataOut.flagNoData = True
return 0
ebocanegra
first commit
r965
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 #data es un numpy array de 3 dmensiones (perfiles, alturas y canales)
Miguel Valdez
Bug fixed:...
r624 if self.data_spc is None:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut.flagNoData = True
return 0
ebocanegra
first commit
r965
self.getBasicHeader()
self.getFirstHeader()
self.dataOut.data_spc = self.data_spc
self.dataOut.data_cspc = self.data_cspc
self.dataOut.data_dc = self.data_dc
self.dataOut.flagNoData = False
self.dataOut.realtime = self.online
return self.dataOut.data_spc
class SpectraWriter(JRODataWriter, Operation):
"""
Esta clase permite escribir datos de espectros a archivos procesados (.pdata). La escritura
de los datos siempre se realiza por bloques.
"""
ext = ".pdata"
optchar = "P"
shape_spc_Buffer = None
shape_cspc_Buffer = None
shape_dc_Buffer = None
data_spc = None
data_cspc = None
data_dc = None
# dataOut = None
ebocanegra
23/11/2017
r1123 def __init__(self, **kwargs):
ebocanegra
first commit
r965 """
Inicializador de la clase SpectraWriter para la escritura de datos de espectros.
Affected:
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut
self.basicHeaderObj
self.systemHeaderObj
self.radarControllerHeaderObj
self.processingHeaderObj
Return: None
"""
ebocanegra
first commit
r965
ebocanegra
23/11/2017
r1123 Operation.__init__(self, **kwargs)
ebocanegra
first commit
r965
self.isConfig = False
self.nTotalBlocks = 0
self.data_spc = None
self.data_cspc = None
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.data_dc = None
self.fp = None
self.flagIsNewFile = 1
ebocanegra
first commit
r965
self.nTotalBlocks = 0
self.flagIsNewBlock = 0
self.setFile = None
self.dtype = None
self.path = None
self.noMoreFiles = 0
self.filename = None
self.basicHeaderObj = BasicHeader(LOCALTIME)
self.systemHeaderObj = SystemHeader()
self.radarControllerHeaderObj = RadarControllerHeader()
self.processingHeaderObj = ProcessingHeader()
def hasAllDataInBuffer(self):
return 1
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def setBlockDimension(self):
"""
Obtiene las formas dimensionales del los subbloques de datos que componen un bloque
Affected:
self.shape_spc_Buffer
self.shape_cspc_Buffer
self.shape_dc_Buffer
Return: None
"""
self.shape_spc_Buffer = (self.dataOut.nChannels,
self.processingHeaderObj.nHeights,
self.processingHeaderObj.profilesPerBlock)
self.shape_cspc_Buffer = (self.dataOut.nPairs,
self.processingHeaderObj.nHeights,
self.processingHeaderObj.profilesPerBlock)
ebocanegra
first commit
r965
self.shape_dc_Buffer = (self.dataOut.nChannels,
self.processingHeaderObj.nHeights)
def writeBlock(self):
ebocanegra
23/11/2017
r1123 """processingHeaderObj
ebocanegra
first commit
r965 Escribe el buffer en el file designado
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Affected:
self.data_spc
self.data_cspc
self.data_dc
self.flagIsNewFile
self.flagIsNewBlock
self.nTotalBlocks
ebocanegra
first commit
r965 self.nWriteBlocks
Return: None
"""
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 spc = numpy.transpose( self.data_spc, (0,2,1) )
if not( self.processingHeaderObj.shif_fft ):
spc = numpy.roll( spc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones
data = spc.reshape((-1))
data = data.astype(self.dtype[0])
data.tofile(self.fp)
Miguel Valdez
-Bug fixed: selecting channels and cross pairs...
r612 if self.data_cspc is not None:
ebocanegra
23/11/2017
r1123
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 cspc = numpy.transpose( self.data_cspc, (0,2,1) )
ebocanegra
23/11/2017
r1123 data = numpy.zeros( numpy.shape(cspc), self.dtype )
print 'data.shape', self.shape_cspc_Buffer
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not( self.processingHeaderObj.shif_fft ):
cspc = numpy.roll( cspc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones
data['real'] = cspc.real
data['imag'] = cspc.imag
data = data.reshape((-1))
data.tofile(self.fp)
ebocanegra
first commit
r965
ebocanegra
15/08/2017
r1001
Miguel Valdez
-Bug fixed: selecting channels and cross pairs...
r612 if self.data_dc is not None:
ebocanegra
23/11/2017
r1123
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 dc = self.data_dc
ebocanegra
23/11/2017
r1123 data = numpy.zeros( numpy.shape(dc), self.dtype )
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 data['real'] = dc.real
data['imag'] = dc.imag
data = data.reshape((-1))
data.tofile(self.fp)
Miguel Valdez
jroIOspectra: Verifying dc from spectra
r781 # self.data_spc.fill(0)
ebocanegra
first commit
r965 #
# if self.data_dc is not None:
# self.data_dc.fill(0)
#
# if self.data_cspc is not None:
# self.data_cspc.fill(0)
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.flagIsNewFile = 0
self.flagIsNewBlock = 1
self.nTotalBlocks += 1
self.nWriteBlocks += 1
self.blockIndex += 1
ebocanegra
first commit
r965
# print "[Writing] Block = %d04" %self.blockIndex
def putData(self):
"""
Setea un bloque de datos y luego los escribe en un file
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Affected:
self.data_spc
self.data_cspc
self.data_dc
ebocanegra
first commit
r965 Return:
0 : Si no hay data o no hay mas files que puedan escribirse
1 : Si se escribio la data de un bloque en un file
"""
if self.dataOut.flagNoData:
return 0
self.flagIsNewBlock = 0
if self.dataOut.flagDiscontinuousBlock:
self.data_spc.fill(0)
self.data_cspc.fill(0)
self.data_dc.fill(0)
self.setNextFile()
if self.flagIsNewFile == 0:
self.setBasicHeader()
self.data_spc = self.dataOut.data_spc.copy()
if self.dataOut.data_cspc is not None:
self.data_cspc = self.dataOut.data_cspc.copy()
if self.dataOut.data_dc is not None:
self.data_dc = self.dataOut.data_dc.copy()
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 # #self.processingHeaderObj.dataBlocksPerFile)
if self.hasAllDataInBuffer():
# self.setFirstHeader()
self.writeNextBlock()
ebocanegra
first commit
r965
return 1
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def __getBlockSize(self):
'''
Este metodos determina el cantidad de bytes para un bloque de datos de tipo Spectra
'''
ebocanegra
first commit
r965
dtype_width = self.getDtypeWidth()
pts2write = self.dataOut.nHeights * self.dataOut.nFFTPoints
pts2write_SelfSpectra = int(self.dataOut.nChannels * pts2write)
blocksize = (pts2write_SelfSpectra*dtype_width)
if self.dataOut.data_cspc is not None:
pts2write_CrossSpectra = int(self.dataOut.nPairs * pts2write)
blocksize += (pts2write_CrossSpectra*dtype_width*2)
if self.dataOut.data_dc is not None:
pts2write_DCchannels = int(self.dataOut.nChannels * self.dataOut.nHeights)
blocksize += (pts2write_DCchannels*dtype_width*2)
# blocksize = blocksize #* datatypeValue * 2 #CORREGIR ESTO
return blocksize
def setFirstHeader(self):
"""
Obtiene una copia del First Header
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Affected:
self.systemHeaderObj
self.radarControllerHeaderObj
self.dtype
ebocanegra
first commit
r965 Return:
None
"""
self.systemHeaderObj = self.dataOut.systemHeaderObj.copy()
self.systemHeaderObj.nChannels = self.dataOut.nChannels
self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy()
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.processingHeaderObj.dtype = 1 # Spectra
self.processingHeaderObj.blockSize = self.__getBlockSize()
self.processingHeaderObj.profilesPerBlock = self.dataOut.nFFTPoints
self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile
self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows
self.processingHeaderObj.nCohInt = self.dataOut.nCohInt# Se requiere para determinar el valor de timeInterval
ebocanegra
first commit
r965 self.processingHeaderObj.nIncohInt = self.dataOut.nIncohInt
self.processingHeaderObj.totalSpectra = self.dataOut.nPairs + self.dataOut.nChannels
self.processingHeaderObj.shif_fft = self.dataOut.flagShiftFFT
ebocanegra
15/08/2017
r1001
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.processingHeaderObj.totalSpectra > 0:
channelList = []
for channel in range(self.dataOut.nChannels):
channelList.append(channel)
channelList.append(channel)
ebocanegra
first commit
r965
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 pairsList = []
if self.dataOut.nPairs > 0:
for pair in self.dataOut.pairsList:
pairsList.append(pair[0])
pairsList.append(pair[1])
ebocanegra
first commit
r965
spectraComb = channelList + pairsList
spectraComb = numpy.array(spectraComb, dtype="u1")
self.processingHeaderObj.spectraComb = spectraComb
Miguel Valdez
Bug fixed:...
r624 if self.dataOut.code is not None:
self.processingHeaderObj.code = self.dataOut.code
self.processingHeaderObj.nCode = self.dataOut.nCode
self.processingHeaderObj.nBaud = self.dataOut.nBaud
ebocanegra
first commit
r965
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.processingHeaderObj.nWindows != 0:
self.processingHeaderObj.firstHeight = self.dataOut.heightList[0]
self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
self.processingHeaderObj.nHeights = self.dataOut.nHeights
self.processingHeaderObj.samplesWin = self.dataOut.nHeights
ebocanegra
first commit
r965
self.processingHeaderObj.processFlags = self.getProcessFlags()
Miguel Valdez
Bug fixed:...
r624 self.setBasicHeader()