##// END OF EJS Templates
Restore previous version...
Restore previous version...

File last commit:

r850:5a02664c0d53
r877:f62d4806c545
Show More
jrodata.py
1183 lines | 29.8 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 '''
$Author: murco $
$Id: JROData.py 173 2012-11-20 15:06:21Z murco $
'''
import copy
import numpy
import datetime
from jroheaderIO import SystemHeader, RadarControllerHeader
def getNumpyDtype(dataTypeCode):
if dataTypeCode == 0:
numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')])
elif dataTypeCode == 1:
numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')])
elif dataTypeCode == 2:
numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')])
elif dataTypeCode == 3:
numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')])
elif dataTypeCode == 4:
numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')])
elif dataTypeCode == 5:
numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')])
else:
raise ValueError, 'dataTypeCode was not defined'
return numpyDtype
def getDataTypeCode(numpyDtype):
if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]):
datatype = 0
elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]):
datatype = 1
elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]):
datatype = 2
elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]):
datatype = 3
elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]):
datatype = 4
elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]):
datatype = 5
else:
datatype = None
return datatype
def hildebrand_sekhon(data, navg):
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 """
This method is for the objective determination of the noise level in Doppler spectra. This
implementation technique is based on the fact that the standard deviation of the spectral
densities is equal to the mean spectral density for white Gaussian noise
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 Inputs:
Data : heights
navg : numbers of averages
Return:
-1 : any error
anoise : noise's level
"""
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
sortdata = numpy.sort(data,axis=None)
lenOfData = len(sortdata)
Miguel Valdez
Wrong noise value when data variance is big. Minimum number of data points to estimate noise is 20%
r712 nums_min = lenOfData*0.2
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
Wrong noise value when data variance is big. Minimum number of data points to estimate noise is 20%
r712 if nums_min <= 5:
nums_min = 5
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
sump = 0.
sumq = 0.
j = 0
cont = 1
while((cont==1)and(j<lenOfData)):
sump += sortdata[j]
sumq += sortdata[j]**2
if j > nums_min:
rtest = float(j)/(j-1) + 1.0/navg
if ((sumq*j) > (rtest*sump**2)):
j = j - 1
sump = sump - sortdata[j]
sumq = sumq - sortdata[j]**2
cont = 0
Miguel Valdez
Bug fixed reading voltage data by block....
r605
j += 1
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 lnoise = sump /j
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765 # stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1))
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 return lnoise
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 class Beam:
def __init__(self):
self.codeList = []
self.azimuthList = []
self.zenithList = []
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 GenericData(object):
flagNoData = True
def __init__(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
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 copy(self, inputObj=None):
if inputObj == None:
return copy.deepcopy(self)
for key in inputObj.__dict__.keys():
Miguel Valdez
Bug fixed in jrodata: Error working with more than one branch. When a value is updated in a branch this value is modified in every other branch because variables are references.
r757
attribute = inputObj.__dict__[key]
#If this attribute is a tuple or list
if type(inputObj.__dict__[key]) in (tuple, list):
self.__dict__[key] = attribute[:]
continue
#If this attribute is another object or instance
if hasattr(attribute, '__dict__'):
self.__dict__[key] = attribute.copy()
continue
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.__dict__[key] = inputObj.__dict__[key]
def deepcopy(self):
return copy.deepcopy(self)
def isEmpty(self):
return self.flagNoData
class JROData(GenericData):
# m_BasicHeader = BasicHeader()
# m_ProcessingHeader = ProcessingHeader()
systemHeaderObj = SystemHeader()
radarControllerHeaderObj = RadarControllerHeader()
# data = None
type = None
datatype = None #dtype but in string
# dtype = None
# nChannels = None
# nHeights = None
nProfiles = None
heightList = None
channelList = None
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 flagDiscontinuousBlock = False
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
useLocalTime = False
utctime = None
timeZone = None
dstFlag = None
errorCount = None
blocksize = None
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 # nCode = None
#
# nBaud = None
#
# code = 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
flagDecodeData = False #asumo q la data no esta decodificada
flagDeflipData = False #asumo q la data no esta sin flip
flagShiftFFT = False
# ippSeconds = None
Miguel Valdez
JRODATA: timeInterval is a property now
r526 # timeInterval = 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
nCohInt = None
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 # noise = 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
windowOfFilter = 1
#Speed of ligth
C = 3e8
frequency = 49.92e6
realtime = False
beacon_heiIndexList = None
last_block = None
blocknow = None
Daniel Valdez
Filtering AMISR files for Datetime Range...
r499 azimuth = None
zenith = None
Daniel Valdez
ProfileToChannels this is a new Operation to get data with dimensions [nchannels,nsamples]
r501 beam = Beam()
Miguel Valdez
Affected:...
r534 profileIndex = 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 def __init__(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
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 getNoise(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
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 getNChannels(self):
return len(self.channelList)
def getChannelIndexList(self):
return range(self.nChannels)
def getNHeights(self):
return len(self.heightList)
def getHeiRange(self, extrapoints=0):
heis = self.heightList
# deltah = self.heightList[1] - self.heightList[0]
#
# heis.append(self.heightList[-1])
return heis
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765 def getDeltaH(self):
delta = self.heightList[1] - self.heightList[0]
return delta
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 getltctime(self):
if self.useLocalTime:
return self.utctime - self.timeZone*60
return self.utctime
def getDatatime(self):
datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
return datatimeValue
def getTimeRange(self):
datatime = []
datatime.append(self.ltctime)
Miguel Valdez
r815 datatime.append(self.ltctime + self.timeInterval+1)
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
datatime = numpy.array(datatime)
return datatime
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765 def getFmaxTimeResponse(self):
period = (10**-6)*self.getDeltaH()/(0.15)
PRF = 1./(period * self.nCohInt)
fmax = PRF
return fmax
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 getFmax(self):
PRF = 1./(self.ippSeconds * self.nCohInt)
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765 fmax = PRF
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
return fmax
def getVmax(self):
_lambda = self.C/self.frequency
Julio Valdez
-Corrections to Vmax calculation...
r850 vmax = self.getFmax() * _lambda/2
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
return vmax
def get_ippSeconds(self):
'''
'''
return self.radarControllerHeaderObj.ippSeconds
def set_ippSeconds(self, ippSeconds):
'''
'''
self.radarControllerHeaderObj.ippSeconds = ippSeconds
return
def get_dtype(self):
'''
'''
return getNumpyDtype(self.datatype)
def set_dtype(self, numpyDtype):
'''
'''
self.datatype = getDataTypeCode(numpyDtype)
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568
def get_code(self):
'''
'''
return self.radarControllerHeaderObj.code
def set_code(self, code):
'''
'''
self.radarControllerHeaderObj.code = code
return
def get_ncode(self):
'''
'''
return self.radarControllerHeaderObj.nCode
def set_ncode(self, nCode):
'''
'''
self.radarControllerHeaderObj.nCode = nCode
return
def get_nbaud(self):
'''
'''
return self.radarControllerHeaderObj.nBaud
Miguel Valdez
JRODATA: timeInterval is a property now
r526
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 def set_nbaud(self, nBaud):
'''
'''
self.radarControllerHeaderObj.nBaud = nBaud
return
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
nChannels = property(getNChannels, "I'm the 'nChannel' property.")
channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
nHeights = property(getNHeights, "I'm the 'nHeights' property.")
#noise = property(getNoise, "I'm the 'nHeights' property.")
datatime = property(getDatatime, "I'm the 'datatime' property")
ltctime = property(getltctime, "I'm the 'ltctime' property")
ippSeconds = property(get_ippSeconds, set_ippSeconds)
dtype = property(get_dtype, set_dtype)
Miguel Valdez
JRODATA: timeInterval is a property now
r526 # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 code = property(get_code, set_code)
nCode = property(get_ncode, set_ncode)
nBaud = property(get_nbaud, set_nbaud)
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 Voltage(JROData):
#data es un numpy array de 2 dmensiones (canales, alturas)
data = None
def __init__(self):
'''
Constructor
'''
Miguel Valdez
Bug plotting RTI fixed: timezone was removed from getLimit function
r566 self.useLocalTime = True
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.radarControllerHeaderObj = RadarControllerHeader()
self.systemHeaderObj = SystemHeader()
self.type = "Voltage"
self.data = None
# self.dtype = None
# self.nChannels = 0
# self.nHeights = 0
self.nProfiles = None
self.heightList = None
self.channelList = None
# self.channelIndexList = None
self.flagNoData = True
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock = False
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.utctime = None
self.timeZone = None
self.dstFlag = None
self.errorCount = None
self.nCohInt = None
self.blocksize = None
self.flagDecodeData = False #asumo q la data no esta decodificada
self.flagDeflipData = False #asumo q la data no esta sin flip
self.flagShiftFFT = False
Miguel Valdez
JRODATA: timeInterval is a property now
r526 self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568
Miguel Valdez
Affected:...
r534 self.profileIndex = 0
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 def getNoisebyHildebrand(self, channel = 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 """
Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
Return:
noiselevel
"""
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 if channel != None:
data = self.data[channel]
nChannels = 1
else:
data = self.data
nChannels = self.nChannels
noise = numpy.zeros(nChannels)
power = data * numpy.conjugate(data)
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 for thisChannel in range(nChannels):
if nChannels == 1:
daux = power[:].real
else:
daux = power[thisChannel,:].real
noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt)
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 return noise
def getNoise(self, type = 1, channel = 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
if type == 1:
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 noise = self.getNoisebyHildebrand(channel)
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
Coherent Integration by Blocks: Bug fixed, nProfiles is divided by number of integrations
r720 return noise
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 def getPower(self, channel = None):
if channel != None:
data = self.data[channel]
else:
data = self.data
power = data * numpy.conjugate(data)
Julio Valdez
-Corrections to Vmax calculation...
r850 powerdB = 10*numpy.log10(power.real)
powerdB = numpy.squeeze(powerdB)
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568
Julio Valdez
-Corrections to Vmax calculation...
r850 return powerdB
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568
Miguel Valdez
JRODATA: timeInterval is a property now
r526 def getTimeInterval(self):
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
JRODATA: timeInterval is a property now
r526 timeInterval = self.ippSeconds * self.nCohInt
return timeInterval
noise = property(getNoise, "I'm the 'nHeights' property.")
timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
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 Spectra(JROData):
Julio Valdez
-Parameters Plot corrected...
r832 #data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas)
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_spc = None
Julio Valdez
-Parameters Plot corrected...
r832 #data cspc es un numpy array de 2 dmensiones (canales, pares, alturas)
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_cspc = None
Julio Valdez
-Parameters Plot corrected...
r832 #data dc es un numpy array de 2 dmensiones (canales, alturas)
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_dc = None
Julio Valdez
-Parameters Plot corrected...
r832 #data power
data_pwr = 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 nFFTPoints = None
# nPairs = None
pairsList = None
nIncohInt = None
wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
nCohInt = None #se requiere para determinar el valor de timeInterval
ippFactor = None
Miguel Valdez
Affected:...
r534 profileIndex = 0
Miguel Valdez
jrodata.py: plotting attribute added to SpectraData
r773 plotting = "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 def __init__(self):
'''
Constructor
'''
Miguel Valdez
Bug plotting RTI fixed: timezone was removed from getLimit function
r566 self.useLocalTime = True
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.radarControllerHeaderObj = RadarControllerHeader()
self.systemHeaderObj = SystemHeader()
self.type = "Spectra"
# self.data = None
# self.dtype = None
# self.nChannels = 0
# self.nHeights = 0
self.nProfiles = None
self.heightList = None
self.channelList = None
# self.channelIndexList = None
self.pairsList = None
self.flagNoData = True
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock = False
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.utctime = None
self.nCohInt = None
self.nIncohInt = None
self.blocksize = None
self.nFFTPoints = None
self.wavelength = None
self.flagDecodeData = False #asumo q la data no esta decodificada
self.flagDeflipData = False #asumo q la data no esta sin flip
self.flagShiftFFT = False
self.ippFactor = 1
#self.noise = None
self.beacon_heiIndexList = []
self.noise_estimation = None
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=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 """
Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
Return:
noiselevel
"""
noise = numpy.zeros(self.nChannels)
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568
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 for channel in range(self.nChannels):
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index]
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 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
return noise
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
Miguel Valdez
minor changes
r729 if self.noise_estimation is not 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 return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py
else:
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index)
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 return noise
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765
def getFreqRangeTimeResponse(self, extrapoints=0):
Miguel Valdez
minor changes
r729
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765 deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor)
freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
Miguel Valdez
jrodata: TimeRange added for ACF module
r771 return freqrange
def getAcfRange(self, extrapoints=0):
deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor))
freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
Miguel Valdez
Bug fixed: Fmax should not be divided by 2.
r765 return freqrange
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 getFreqRange(self, extrapoints=0):
deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor)
freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
return freqrange
def getVelRange(self, extrapoints=0):
deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor)
Julio Valdez
-Corrections to Vmax calculation...
r850 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) #- deltav/2
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
return velrange
def getNPairs(self):
return len(self.pairsList)
def getPairsIndexList(self):
return range(self.nPairs)
def getNormFactor(self):
Miguel Valdez
Bug fixed:...
r624
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 pwcode = 1
Miguel Valdez
Bug fixed:...
r624
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.flagDecodeData:
pwcode = numpy.sum(self.code[0]**2)
#normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
return normFactor
def getFlagCspc(self):
Miguel Valdez
Bug fixed: Padding decode data with zeros at the first heights was eliminated.
r611 if self.data_cspc 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 return True
return False
def getFlagDc(self):
Miguel Valdez
Bug fixed: Padding decode data with zeros at the first heights was eliminated.
r611 if self.data_dc 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 return True
return False
Miguel Valdez
JRODATA: timeInterval is a property now
r526 def getTimeInterval(self):
timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles
return timeInterval
Julio Valdez
-Parameters Plot corrected...
r832 def getPower(self):
factor = self.normFactor
z = self.data_spc/factor
z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
avg = numpy.average(z, axis=1)
return 10*numpy.log10(avg)
Miguel Valdez
Bug fixed:...
r624 def setValue(self, value):
print "This property should not be initialized"
return
nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.")
pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.")
normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.")
flag_cspc = property(getFlagCspc, setValue)
flag_dc = property(getFlagDc, setValue)
noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property")
Miguel Valdez
JRODATA: timeInterval is a property now
r526
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 SpectraHeis(Spectra):
data_spc = None
data_cspc = None
data_dc = None
nFFTPoints = None
# nPairs = None
pairsList = None
Miguel Valdez
Signal Chain GUI updated:...
r587 nCohInt = 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 nIncohInt = None
def __init__(self):
self.radarControllerHeaderObj = RadarControllerHeader()
self.systemHeaderObj = SystemHeader()
self.type = "SpectraHeis"
# self.dtype = None
# self.nChannels = 0
# self.nHeights = 0
self.nProfiles = None
self.heightList = None
self.channelList = None
# self.channelIndexList = None
self.flagNoData = True
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock = False
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.nPairs = 0
self.utctime = None
self.blocksize = None
Miguel Valdez
Affected:...
r534
self.profileIndex = 0
Miguel Valdez
Signal Chain GUI updated:...
r587
self.nCohInt = 1
self.nIncohInt = 1
Daniel Valdez
The Spectra-1d Plot shows the normalized power.
r496
def getNormFactor(self):
pwcode = 1
if self.flagDecodeData:
pwcode = numpy.sum(self.code[0]**2)
normFactor = self.nIncohInt*self.nCohInt*pwcode
return normFactor
Miguel Valdez
JRODATA: timeInterval is a property now
r526 def getTimeInterval(self):
timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
return timeInterval
Daniel Valdez
The Spectra-1d Plot shows the normalized power.
r496 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
Miguel Valdez
JRODATA: timeInterval is a property now
r526 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
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
Signal Chain GUI updated:...
r587 class Fits(JROData):
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
heightList = None
channelList = None
flagNoData = True
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 flagDiscontinuousBlock = False
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
useLocalTime = False
utctime = None
timeZone = None
# ippSeconds = None
Miguel Valdez
JRODATA: timeInterval is a property now
r526 # timeInterval = 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
nCohInt = None
nIncohInt = None
noise = None
windowOfFilter = 1
#Speed of ligth
C = 3e8
frequency = 49.92e6
realtime = False
def __init__(self):
self.type = "Fits"
self.nProfiles = None
self.heightList = None
self.channelList = None
# self.channelIndexList = None
self.flagNoData = True
self.utctime = None
Miguel Valdez
Signal Chain GUI updated:...
r587 self.nCohInt = 1
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
Signal Chain GUI updated:...
r587 self.nIncohInt = 1
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.useLocalTime = True
Miguel Valdez
Affected:...
r534 self.profileIndex = 0
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.utctime = None
# self.timeZone = None
# self.ltctime = None
# self.timeInterval = None
# self.header = None
# self.data_header = None
# self.data = None
# self.datatime = None
# self.flagNoData = False
# self.expName = ''
# self.nChannels = None
# self.nSamples = None
# self.dataBlocksPerFile = None
# self.comments = ''
#
def getltctime(self):
if self.useLocalTime:
return self.utctime - self.timeZone*60
return self.utctime
def getDatatime(self):
datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
return datatime
def getTimeRange(self):
datatime = []
datatime.append(self.ltctime)
datatime.append(self.ltctime + self.timeInterval)
datatime = numpy.array(datatime)
return datatime
def getHeiRange(self):
heis = self.heightList
return heis
def getNHeights(self):
return len(self.heightList)
def getNChannels(self):
return len(self.channelList)
def getChannelIndexList(self):
return range(self.nChannels)
def getNoise(self, type = 1):
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 #noise = numpy.zeros(self.nChannels)
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 type == 1:
noise = self.getNoisebyHildebrand()
if type == 2:
noise = self.getNoisebySort()
if type == 3:
noise = self.getNoisebyWindow()
return noise
Miguel Valdez
JRODATA: timeInterval is a property now
r526 def getTimeInterval(self):
Miguel Valdez
Signal Chain GUI updated:...
r587 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
return timeInterval
Miguel Valdez
JRODATA: timeInterval is a property now
r526
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 datatime = property(getDatatime, "I'm the 'datatime' property")
nHeights = property(getNHeights, "I'm the 'nHeights' property.")
nChannels = property(getNChannels, "I'm the 'nChannel' property.")
channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
noise = property(getNoise, "I'm the 'nHeights' property.")
Miguel Valdez
Duplicate property eliminated
r630
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 ltctime = property(getltctime, "I'm the 'ltctime' property")
Miguel Valdez
JRODATA: timeInterval is a property now
r526 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
Julio Valdez
-Corrections to Vmax calculation...
r850
Julio Valdez
Processing Modules added:...
r502 class Correlation(JROData):
noise = None
SNR = None
#--------------------------------------------------
Julio Valdez
-Corrections to Vmax calculation...
r850 mode = None
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 split = False
data_cf = None
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 lags = None
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 lagRange = None
Julio Valdez
Processing Modules added:...
r502
pairsList = None
Julio Valdez
-Corrections to Vmax calculation...
r850 normFactor = None
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 #--------------------------------------------------
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 # calculateVelocity = None
nLags = None
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 nPairs = None
nAvg = None
Julio Valdez
Processing Modules added:...
r502
def __init__(self):
'''
Constructor
'''
self.radarControllerHeaderObj = RadarControllerHeader()
self.systemHeaderObj = SystemHeader()
self.type = "Correlation"
self.data = None
self.dtype = None
self.nProfiles = None
self.heightList = None
self.channelList = None
self.flagNoData = True
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock = False
Julio Valdez
Processing Modules added:...
r502
self.utctime = None
self.timeZone = None
self.dstFlag = None
self.errorCount = None
self.blocksize = None
self.flagDecodeData = False #asumo q la data no esta decodificada
self.flagDeflipData = False #asumo q la data no esta sin flip
self.pairsList = None
self.nPoints = None
Julio Valdez
-Corrections to Vmax calculation...
r850
Julio Valdez
Processing Modules added:...
r502 def getPairsList(self):
return self.pairsList
Julio Valdez
-Corrections to Vmax calculation...
r850
Julio Valdez
Processing Modules added:...
r502 def getNoise(self, mode = 2):
indR = numpy.where(self.lagR == 0)[0][0]
indT = numpy.where(self.lagT == 0)[0][0]
jspectra0 = self.data_corr[:,:,indR,:]
jspectra = copy.copy(jspectra0)
num_chan = jspectra.shape[0]
num_hei = jspectra.shape[2]
freq_dc = jspectra.shape[1]/2
ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
if ind_vel[0]<0:
ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
if mode == 1:
jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
if mode == 2:
vel = numpy.array([-2,-1,1,2])
xx = numpy.zeros([4,4])
for fil in range(4):
xx[fil,:] = vel[fil]**numpy.asarray(range(4))
xx_inv = numpy.linalg.inv(xx)
xx_aux = xx_inv[0,:]
for ich in range(num_chan):
yy = jspectra[ich,ind_vel,:]
jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
junkid = jspectra[ich,freq_dc,:]<=0
cjunkid = sum(junkid)
if cjunkid.any():
jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:]
return noise
Miguel Valdez
Signal Chain GUI updated:...
r587
def getTimeInterval(self):
Julio Valdez
-Corrections to Vmax calculation...
r850 timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles
Miguel Valdez
Signal Chain GUI updated:...
r587
return timeInterval
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 def splitFunctions(self):
pairsList = self.pairsList
ccf_pairs = []
acf_pairs = []
ccf_ind = []
acf_ind = []
for l in range(len(pairsList)):
chan0 = pairsList[l][0]
chan1 = pairsList[l][1]
#Obteniendo pares de Autocorrelacion
if chan0 == chan1:
acf_pairs.append(chan0)
acf_ind.append(l)
else:
ccf_pairs.append(pairsList[l])
ccf_ind.append(l)
data_acf = self.data_cf[acf_ind]
data_ccf = self.data_cf[ccf_ind]
return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf
def getNormFactor(self):
acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions()
acf_pairs = numpy.array(acf_pairs)
normFactor = numpy.zeros((self.nPairs,self.nHeights))
for p in range(self.nPairs):
pair = self.pairsList[p]
ch0 = pair[0]
ch1 = pair[1]
ch0_max = numpy.max(data_acf[acf_pairs==ch0,:,:], axis=1)
ch1_max = numpy.max(data_acf[acf_pairs==ch1,:,:], axis=1)
normFactor[p,:] = numpy.sqrt(ch0_max*ch1_max)
return normFactor
Miguel Valdez
Signal Chain GUI updated:...
r587 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
Julio Valdez
-Corrections to Vmax calculation...
r850 normFactor = property(getNormFactor, "I'm the 'normFactor property'")
Julio Valdez
Processing Modules added:...
r502
class Parameters(JROData):
Julio Valdez
-Parameters Plot corrected...
r832 experimentInfo = None #Information about the experiment
Julio Valdez
First Spectral Fitting and EW Drifts operative module inside Signal Chain TRUNK
r513 #Information from previous data
Julio Valdez
Processing Modules added:...
r502 inputUnit = None #Type of data to be processed
operation = None #Type of operation to parametrize
Julio Valdez
First Spectral Fitting and EW Drifts operative module inside Signal Chain TRUNK
r513 normFactor = None #Normalization Factor
groupList = None #List of Pairs, Groups, etc
#Parameters
Julio Valdez
Processing Modules added:...
r502 data_param = None #Parameters obtained
data_pre = None #Data Pre Parametrization
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
Julio Valdez
First Draft HDF5 IO module
r514 data_SNR = None #Signal to Noise Ratio
Julio Valdez
data...
r608 # heightRange = None #Heights
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
data...
r608 abscissaList = None #Abscissa, can be velocities, lags or time
Julio Valdez
Processing Modules added:...
r502
noise = None #Noise Potency
Julio Valdez
data...
r608 utctimeInit = None #Initial UTC time
Julio Valdez
Processing Modules added:...
r502
paramInterval = None #Time interval to calculate Parameters in seconds
Julio Valdez
Changes in data Parameters
r802 useLocalTime = True
Julio Valdez
First Spectral Fitting and EW Drifts operative module inside Signal Chain TRUNK
r513 #Fitting
Julio Valdez
First Draft HDF5 IO module
r514 data_error = None #Error of the estimation
constants = None
Julio Valdez
First Spectral Fitting and EW Drifts operative module inside Signal Chain TRUNK
r513
library = None
#Output signal
outputInterval = None #Time interval to calculate output signal in seconds
data_output = None #Out signal
Julio Valdez
Processing Modules added:...
r502
Julio Valdez
-Corrections to Vmax calculation...
r850 nAvg = None
Julio Valdez
data...
r608
Julio Valdez
Processing Modules added:...
r502 def __init__(self):
'''
Constructor
'''
self.radarControllerHeaderObj = RadarControllerHeader()
self.systemHeaderObj = SystemHeader()
self.type = "Parameters"
Julio Valdez
data...
r608
Julio Valdez
-Functional HDF5 Format Writing and Reading Unit...
r804 def getTimeRange1(self, interval):
Julio Valdez
Processing Modules added:...
r502
datatime = []
Julio Valdez
data...
r608 if self.useLocalTime:
time1 = self.utctimeInit - self.timeZone*60
else:
Julio Valdez
Changes in data Parameters
r802 time1 = self.utctimeInit
Julio Valdez
data...
r608
# datatime.append(self.utctimeInit)
# datatime.append(self.utctimeInit + self.outputInterval)
datatime.append(time1)
Julio Valdez
-Functional HDF5 Format Writing and Reading Unit...
r804 datatime.append(time1 + interval)
Julio Valdez
Processing Modules added:...
r502
datatime = numpy.array(datatime)
Julio Valdez
data...
r608 return datatime