##// END OF EJS Templates
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos

File last commit:

r158:610e58680afb
r158:610e58680afb
Show More
VoltageProcessor.py
419 lines | 13.0 KiB | text/x-python | PythonLexer
Daniel Valdez
Lectura/Escritura de Rawdata y Pdata operando correctamente, se hicieron pruebas con datos de Drifts,Faraday e Imagenes.
r126 '''
$Author$
$Id$
'''
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 import os
import sys
import numpy
Daniel Valdez
Se agrega el metodo plotScope
r136 import datetime
Daniel Valdez
Se agregó metodos para plotear RTI
r140 import time
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
path = os.path.split(os.getcwd())[0]
sys.path.append(path)
Miguel Valdez
-Agrupamiento de las clases Voltage y Spectra dentro del módulo JROData...
r137 from Data.JROData import Voltage
Daniel Valdez
Realizando cambios para escritura de rawdata
r123 from IO.VoltageIO import VoltageWriter
Daniel Valdez
Se agregó metodos para plotear RTI
r140 from Graphics.schainPlotTypes import ScopeFigure, RTIFigure
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
class VoltageProcessor:
Miguel Valdez
-Agrupamiento de las clases Voltage y Spectra dentro del módulo JROData...
r137
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 dataInObj = None
dataOutObj = None
integratorObjIndex = None
writerObjIndex = None
integratorObjList = None
writerObjList = None
def __init__(self):
self.integratorObjIndex = None
self.writerObjIndex = None
Daniel Valdez
r134 self.plotObjIndex = None
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 self.integratorObjList = []
self.writerObjList = []
Daniel Valdez
r134 self.plotObjList = []
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
def setup(self,dataInObj=None,dataOutObj=None):
self.dataInObj = dataInObj
if self.dataOutObj == None:
dataOutObj = Voltage()
self.dataOutObj = dataOutObj
return self.dataOutObj
def init(self):
self.integratorObjIndex = 0
self.writerObjIndex = 0
Daniel Valdez
r134 self.plotObjIndex = 0
Daniel Valdez
Realizando cambios para escritura de rawdata
r123
if not(self.dataInObj.flagNoData):
self.dataOutObj.copy(self.dataInObj)
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 # No necesita copiar en cada init() los atributos de dataInObj
# la copia deberia hacerse por cada nuevo bloque de datos
Daniel Valdez
Se agregó metodos para plotear RTI
r140
Daniel Valdez
Nueva version para graficos Scope, RTI, Spectra. Se hicieron pruebas con los experimentos EwDRIFTS, MST, IMAGING
r141 def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
Daniel Valdez
Se agregó metodos para plotear RTI
r140 self.plotObjList.append(rtiObj)
def plotRti(self, idfigure=None,
starttime=None,
endtime=None,
rangemin=None,
rangemax=None,
minvalue=None,
maxvalue=None,
wintitle='',
driver='plplot',
Daniel Valdez
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
r156 colormap='br_greeen',
Daniel Valdez
Se agregó metodos para plotear RTI
r140 colorbar=True,
showprofile=False,
xrangestep=None,
save=False,
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158 gpath=None,
ratio=1,
channelList=None):
Daniel Valdez
Se agregó metodos para plotear RTI
r140
if self.dataOutObj.flagNoData:
return 0
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158 if channelList == None:
channelList = self.dataOutObj.channelList
nframes = len(channelList)
Daniel Valdez
Se agregó metodos para plotear RTI
r140
if len(self.plotObjList) <= self.plotObjIndex:
self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile)
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158
data = self.dataOutObj.data[channelList,:] * numpy.conjugate(self.dataOutObj.data[channelList,:])
Daniel Valdez
Se agregó metodos para plotear RTI
r140 data = 10*numpy.log10(data.real)
Miguel Valdez
-Actualización del modulo SpectraProcessor, SchainPlot y schainPlotLib...
r153 currenttime = self.dataOutObj.utctime - time.timezone
Daniel Valdez
Se agregó metodos para plotear RTI
r140
range = self.dataOutObj.heightList
Miguel Valdez
-Actualización del modulo SpectraProcessor, SchainPlot y schainPlotLib...
r153 thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
Daniel Valdez
Se agregó metodos para plotear RTI
r140 dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S"))
date = "%s"%(thisdatetime.strftime("%d-%b-%Y"))
Miguel Valdez
metodo selectChannels agreagado
r157 print thisdatetime
Daniel Valdez
Se agregó metodos para plotear RTI
r140 figuretitle = "RTI Plot Radar Data" #+ date
plotObj = self.plotObjList[self.plotObjIndex]
Daniel Valdez
Nueva version para graficos Scope, RTI, Spectra. Se hicieron pruebas con los experimentos EwDRIFTS, MST, IMAGING
r141 cleardata = False
Daniel Valdez
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
r156 deltax = self.dataOutObj.timeInterval
plotObj.plotPcolor(data=data,
x=currenttime,
y=range,
channelList=channelList,
xmin=starttime,
xmax=endtime,
ymin=rangemin,
ymax=rangemax,
minvalue=minvalue,
maxvalue=maxvalue,
figuretitle=figuretitle,
xrangestep=xrangestep,
deltax=deltax,
save=save,
gpath=gpath,
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158 ratio=ratio,
cleardata=cleardata
)
Daniel Valdez
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
r156
Daniel Valdez
Se agregó metodos para plotear RTI
r140
self.plotObjIndex += 1
Daniel Valdez
r134 def addScope(self, idfigure, nframes, wintitle, driver):
if idfigure==None:
idfigure = self.plotObjIndex
scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver)
self.plotObjList.append(scopeObj)
def plotScope(self,
idfigure=None,
minvalue=None,
maxvalue=None,
xmin=None,
xmax=None,
wintitle='',
driver='plplot',
save=False,
gpath=None,
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158 ratio=1,
Daniel Valdez
r134 type="power"):
if self.dataOutObj.flagNoData:
return 0
nframes = len(self.dataOutObj.channelList)
if len(self.plotObjList) <= self.plotObjIndex:
self.addScope(idfigure, nframes, wintitle, driver)
Daniel Valdez
Se agrega el metodo plotScope
r136
if type=="power":
data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data)
data1D = data1D.real
if type =="iq":
data1D = self.dataOutObj.data
Miguel Valdez
-Actualización del modulo SpectraProcessor, SchainPlot y schainPlotLib...
r153 thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime)
Daniel Valdez
Se agrega el metodo plotScope
r136
dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
date = "%s"%(thisDatetime.strftime("%d-%b-%Y"))
Miguel Valdez
metodo selectChannels agreagado
r157 figuretitle = "Scope Plot Radar Data: " + date
Daniel Valdez
r134
Daniel Valdez
Se agrega el metodo plotScope
r136 plotObj = self.plotObjList[self.plotObjIndex]
Daniel Valdez
r134
Daniel Valdez
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
r156 plotObj.plot1DArray(data1D=data1D,
x=self.dataOutObj.heightList,
channelList=self.dataOutObj.channelList,
xmin=xmin,
xmax=xmax,
minvalue=minvalue,
maxvalue=maxvalue,
Miguel Valdez
metodo selectChannels agreagado
r157 figuretitle=figuretitle,
Daniel Valdez
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
r156 save=save,
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158 gpath=gpath,
ratio=ratio)
Daniel Valdez
Se corrigieron errores en VoltageProcessor.py en el metodo de plotRTI. Se agrego el metodo de plotCrossSpc al modulo SpectraProcessor.py para graficos de Espectros, Coherencia y Fase, de la misma forma se han agregado clases al modulo schainPlotTypes.
r156
Daniel Valdez
Se agrega el metodo plotScope
r136
Daniel Valdez
r134 self.plotObjIndex += 1
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 def addIntegrator(self, *args):
objCohInt = CoherentIntegrator(*args)
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 self.integratorObjList.append(objCohInt)
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 def addWriter(self, *args):
Daniel Valdez
r134 writerObj = VoltageWriter(self.dataOutObj)
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 writerObj.setup(*args)
Daniel Valdez
r134 self.writerObjList.append(writerObj)
Daniel Valdez
Realizando cambios para escritura de rawdata
r123
Daniel Valdez
Lectura/Escritura de Rawdata y Pdata operando correctamente, se hicieron pruebas con datos de Drifts,Faraday e Imagenes.
r126 def writeData(self, wrpath, blocksPerFile, profilesPerBlock):
Daniel Valdez
Realizando cambios para escritura de rawdata
r123
if self.dataOutObj.flagNoData:
return 0
if len(self.writerObjList) <= self.writerObjIndex:
Daniel Valdez
Lectura/Escritura de Rawdata y Pdata operando correctamente, se hicieron pruebas con datos de Drifts,Faraday e Imagenes.
r126 self.addWriter(wrpath, blocksPerFile, profilesPerBlock)
Daniel Valdez
Realizando cambios para escritura de rawdata
r123
self.writerObjList[self.writerObjIndex].putData()
self.writerObjIndex += 1
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 def integrator(self, nCohInt=None, timeInterval=None, overlapping=False):
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 if self.dataOutObj.flagNoData:
return 0
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 if len(self.integratorObjList) <= self.integratorObjIndex:
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 self.addIntegrator(nCohInt, timeInterval, overlapping)
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
myCohIntObj = self.integratorObjList[self.integratorObjIndex]
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 myCohIntObj.exe(data = self.dataOutObj.data, datatime=None)
Miguel Valdez
metodo selectChannels agreagado
r157 self.dataOutObj.timeInterval *= nCohInt
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 self.dataOutObj.flagNoData = True
if myCohIntObj.isReady:
Daniel Valdez
Para graficos se ha habilitado escritura de graficos en disco. Para el caso de RTI el intervalo[xmin,xmax] de ploteo en el eje X esta dado en segundos
r158 self.dataOutObj.timeInterval = myCohIntObj.nCohInt * self.dataOutObj.timeInterval
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 self.dataOutObj.flagNoData = False
Miguel Valdez
metodo selectChannels agreagado
r157
def selectChannels(self, channelList):
Daniel Valdez
r134
Miguel Valdez
metodo selectChannels agreagado
r157 self.selectChannelsByIndex(channelList)
def selectChannelsByIndex(self, channelIndexList):
"""
Selecciona un bloque de datos en base a canales segun el channelIndexList
Input:
channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
Affected:
self.dataOutObj.data
self.dataOutObj.channelIndexList
self.dataOutObj.nChannels
self.dataOutObj.m_ProcessingHeader.totalSpectra
self.dataOutObj.systemHeaderObj.numChannels
self.dataOutObj.m_ProcessingHeader.blockSize
Return:
None
"""
if self.dataOutObj.flagNoData:
return 0
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
Miguel Valdez
metodo selectChannels agreagado
r157 for channel in channelIndexList:
if channel not in self.dataOutObj.channelIndexList:
raise ValueError, "The value %d in channelIndexList is not valid" %channel
nChannels = len(channelIndexList)
data = self.dataOutObj.data[channelIndexList,:]
self.dataOutObj.data = data
self.dataOutObj.channelIndexList = channelIndexList
self.dataOutObj.channelList = [self.dataOutObj.channelList[i] for i in channelIndexList]
self.dataOutObj.nChannels = nChannels
return 1
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
class CoherentIntegrator:
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143
__profIndex = 0
__withOverapping = False
__isByTime = False
__initime = None
__integrationtime = None
__buffer = None
isReady = False
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 nCohInt = None
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143
def __init__(self, nCohInt=None, timeInterval=None, overlapping=False):
"""
Set the parameters of the integration class.
Inputs:
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 nCohInt : Number of coherent integrations
timeInterval : Time of integration. If nCohInt is selected this parameter does not work
overlapping :
"""
self.__buffer = None
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 self.isReady = False
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 if nCohInt == None and timeInterval == None:
raise ValueError, "nCohInt or timeInterval should be specified ..."
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 if nCohInt != None:
self.nCohInt = nCohInt
self.__isByTime = False
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 else:
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
self.__isByTime = True
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 if overlapping:
self.__withOverapping = True
self.__buffer = None
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 else:
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 self.__withOverapping = False
self.__buffer = 0
self.__profIndex = 0
def putData(self, data):
"""
Add a profile to the __buffer and increase in one the __profileIndex
"""
if not self.__withOverapping:
self.__buffer += data
self.__profIndex += 1
return
#Overlapping data
Miguel Valdez
-Actualización de los nombres de los objetos systemHeader y radaraControllerHeader...
r148 nChannels, nHeis = data.shape
data = numpy.reshape(data, (1, nChannels, nHeis))
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143
if self.__buffer == None:
self.__buffer = data
self.__profIndex += 1
return
if self.__profIndex < self.nCohInt:
self.__buffer = numpy.vstack((self.__buffer, data))
self.__profIndex += 1
return
self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
self.__buffer[self.nCohInt-1] = data
#self.__profIndex = self.nCohInt
return
def pushData(self):
"""
Return the sum of the last profiles and the profiles used in the sum.
Affected:
self.__profileIndex
"""
if not self.__withOverapping:
data = self.__buffer
nCohInt = self.__profIndex
self.__buffer = 0
self.__profIndex = 0
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 return data, nCohInt
#Overlapping data
data = numpy.sum(self.__buffer, axis=0)
nCohInt = self.__profIndex
return data, nCohInt
def byProfiles(self, data):
self.isReady = False
avg_data = None
self.putData(data)
if self.__profIndex == self.nCohInt:
avg_data, nCohInt = self.pushData()
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 self.isReady = True
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143
return avg_data
def byTime(self, data, datatime):
self.isReady = False
avg_data = None
if self.__initime == None:
self.__initime = datatime
self.putData(data)
if (datatime - self.__initime) >= self.__integrationtime:
avg_data, nCohInt = self.pushData()
self.nCohInt = nCohInt
self.isReady = True
return avg_data
def exe(self, data, datatime=None):
if not self.__isByTime:
avg_data = self.byProfiles(data)
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122 else:
Miguel Valdez
Se añadio el modulo de integración incluyendo overlapping
r143 avg_data = self.byTime(data, datatime)
self.data = avg_data
return avg_data
Daniel Valdez
En esta version se las funciones de LECTURA de rawdata y pdata operan satisfactoriamente.
r122