@@ -1,25 +1,40 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on 23/01/2012 |
|
2 | Created on 23/01/2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | from JRODataIO import JRODataIO |
|
8 | import os, sys | |
|
9 | import numpy | |||
|
10 | import glob | |||
|
11 | import fnmatch | |||
|
12 | import time, datetime | |||
9 |
|
13 | |||
10 | class CorrelationReader(JRODataIO): |
|
14 | path = os.path.split(os.getcwd())[0] | |
|
15 | sys.path.append(path) | |||
|
16 | ||||
|
17 | from Model.JROHeader import * | |||
|
18 | from Model.Voltage import Voltage | |||
|
19 | ||||
|
20 | from IO.JRODataIO import JRODataReader | |||
|
21 | from IO.JRODataIO import JRODataWriter | |||
|
22 | ||||
|
23 | ||||
|
24 | class CorrelationReader(JRODataReader):#JRODataReader para lectura de correlaciones en archivos HDF5 | |||
11 |
|
25 | |||
12 | def __init__(self): |
|
26 | def __init__(self): | |
13 |
|
27 | |||
14 | pass |
|
28 | pass | |
15 |
|
29 | |||
16 | class CorrelationWriter(JRODataIO): |
|
30 | class CorrelationWriter(JRODataWriter):#JRODataWriter para escritura de correlaciones en archivos HDF5 | |
17 |
|
31 | |||
18 | def __init__(self): |
|
32 | def __init__(self): | |
|
33 | ||||
19 | pass |
|
34 | pass | |
20 |
|
35 | |||
21 |
def pu |
|
36 | def puData(self): | |
22 | pass |
|
37 | pass | |
23 |
|
38 | |||
24 | def writeBlock(self): |
|
39 | def writeBlock(self): | |
25 | pass No newline at end of file |
|
40 | pass |
@@ -1,58 +1,60 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 | from JROData import JROData, Noise |
|
7 | from JROData import JROData, Noise | |
8 | from JROHeader import RadarControllerHeader, ProcessingHeader, SystemHeader, BasicHeader |
|
8 | from JROHeader import RadarControllerHeader, ProcessingHeader, SystemHeader, BasicHeader | |
9 |
|
9 | |||
10 | class Correlation(JROData): |
|
10 | class Correlation(JROData): | |
11 | ''' |
|
11 | ''' | |
12 | classdocs |
|
12 | classdocs | |
13 | ''' |
|
13 | ''' | |
14 |
|
14 | |||
15 | data = None |
|
15 | data = None | |
16 |
|
16 | |||
17 | nLags = None |
|
17 | nLags = None | |
18 |
|
18 | |||
19 | lagsList = None |
|
19 | lagsList = None | |
20 |
|
20 | |||
21 | def __init__(self): |
|
21 | def __init__(self): | |
22 | ''' |
|
22 | ''' | |
23 | Constructor |
|
23 | Constructor | |
24 | ''' |
|
24 | ''' | |
25 |
|
25 | |||
26 | self.m_RadarControllerHeader = RadarControllerHeader() |
|
26 | self.m_RadarControllerHeader = RadarControllerHeader() | |
27 |
|
27 | |||
28 | self.m_ProcessingHeader = ProcessingHeader() |
|
28 | self.m_ProcessingHeader = ProcessingHeader() | |
29 |
|
29 | |||
30 | self.m_SystemHeader = SystemHeader() |
|
30 | self.m_SystemHeader = SystemHeader() | |
31 |
|
31 | |||
32 | self.m_BasicHeader = BasicHeader() |
|
32 | self.m_BasicHeader = BasicHeader() | |
33 |
|
33 | |||
34 | self.m_NoiseObj = Noise() |
|
34 | self.m_NoiseObj = Noise() | |
35 |
|
35 | |||
36 |
self.type = " |
|
36 | self.type = "Correlation" | |
37 |
|
37 | |||
38 | self.dataType = None |
|
38 | self.dataType = None | |
39 |
|
39 | |||
40 | self.nHeights = 0 |
|
40 | self.nHeights = 0 | |
41 |
|
41 | |||
42 | self.nChannels = 0 |
|
42 | self.nChannels = 0 | |
43 |
|
43 | |||
44 | self.channelList = None |
|
44 | self.channelList = None | |
45 |
|
45 | |||
46 | self.heightList = None |
|
46 | self.heightList = None | |
47 |
|
47 | |||
48 | self.flagNoData = True |
|
48 | self.flagNoData = True | |
49 |
|
49 | |||
50 | self.flagResetProcessing = False |
|
50 | self.flagResetProcessing = False | |
51 |
|
51 | |||
52 |
|
52 | |||
53 | self.data = None |
|
53 | self.data = None | |
54 |
|
54 | |||
55 | self.nLags = 0 |
|
55 | self.nLags = 0 | |
56 |
|
56 | |||
57 |
self. |
|
57 | self.tauList = None | |
|
58 | ||||
|
59 | self.pairList = None | |||
58 | No newline at end of file |
|
60 |
@@ -1,22 +1,146 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
|
8 | import os, sys | |||
|
9 | import numpy | |||
|
10 | ||||
|
11 | path = os.path.split(os.getcwd())[0] | |||
|
12 | sys.path.append(path) | |||
|
13 | ||||
|
14 | from Model.Correlation import Correlation | |||
|
15 | from IO.CorrelationIO import CorrelationWriter | |||
|
16 | #from Graphics.CorrelationPlot import Correlator | |||
|
17 | ||||
|
18 | ||||
|
19 | from Model.Voltage import Voltage | |||
|
20 | from Model.Spectra import Spectra | |||
|
21 | ||||
8 | class CorrelationProcessor: |
|
22 | class CorrelationProcessor: | |
9 | ''' |
|
23 | ''' | |
10 | classdocs |
|
24 | classdocs | |
11 | ''' |
|
25 | ''' | |
12 |
|
26 | |||
13 |
|
27 | integratorIndex = None | ||
14 | def __init__(self): |
|
28 | writerIndex = None | |
|
29 | plotterIndex = None | |||
|
30 | ||||
|
31 | lagsList = None | |||
|
32 | ||||
|
33 | nLags = None | |||
|
34 | tauList = None | |||
|
35 | pairList = None | |||
|
36 | indexTau = None | |||
|
37 | ||||
|
38 | ||||
|
39 | def __init__(self,dataInObj, dataOutObj=None): | |||
15 | ''' |
|
40 | ''' | |
16 | Constructor |
|
41 | Constructor | |
17 | ''' |
|
42 | ''' | |
18 | pass |
|
43 | self.dataInObj = dataInObj | |
19 | m_Correlation= Correlation() |
|
44 | ||
|
45 | if dataOutObj == None: | |||
|
46 | self.dataOutObj = Correlation() | |||
|
47 | else: | |||
|
48 | self.dataOutObj = dataOutObj | |||
|
49 | ||||
|
50 | self.indexTau = 0 | |||
|
51 | self.buffer = None | |||
|
52 | ||||
|
53 | def init(self,pairList=None,tauList=None): | |||
|
54 | ||||
|
55 | self.integratorIndex = 0 | |||
|
56 | self.writerIndex = 0 | |||
|
57 | self.plotterIndex = 0 | |||
|
58 | ||||
|
59 | self.pairList = pairList | |||
|
60 | self.tauList = tauList | |||
|
61 | ||||
|
62 | if ( isinstance(self.dataInObj, Voltage) ): | |||
|
63 | self.__getCorrelation() | |||
|
64 | ||||
|
65 | if ( isinstance(self.dataInObj, Spectra) ): | |||
|
66 | sys.exit(0) | |||
|
67 | ||||
|
68 | if ( isinstance(self.dataInObj, Correlation) ): | |||
|
69 | sel.__getCopy() | |||
|
70 | ||||
|
71 | def __getCorrelation(self): | |||
|
72 | if self.dataInObj.flagNoData: | |||
|
73 | return 0 | |||
|
74 | ||||
|
75 | if self.tauList == None: # se lee el tauList desde el archivo | |||
|
76 | flip = None | |||
|
77 | if self.dataInObj.m_RadarControllerHeader.flip1 != None: | |||
|
78 | flip = self.dataInObj.m_RadarControllerHeader.flip1 | |||
|
79 | ||||
|
80 | if self.dataInObj.m_RadarControllerHeader.flip2 != None: | |||
|
81 | flip = self.dataInObj.m_RadarControllerHeader.flip2 | |||
|
82 | ||||
|
83 | if flip == None: | |||
|
84 | flip = 2 | |||
|
85 | print 'flip is None --> flip = %d '%flip | |||
|
86 | ||||
|
87 | ntaus = self.dataInObj.m_RadarControllerHeader.numTaus | |||
|
88 | taus = self.dataInObj.m_RadarControllerHeader.Taus.reshape(ntaus/flip,flip) | |||
|
89 | ||||
|
90 | index = 0 | |||
|
91 | self.tauList = taus[:,index] | |||
|
92 | print 'tauList is None --> tauList = obj.m_RadarControllerHeader.Taus[:,%d]'%index | |||
|
93 | ||||
|
94 | self.nLags = len(self.tauList) | |||
|
95 | ||||
|
96 | if self.pairList == None: | |||
|
97 | self.pairList = [(0,0)] # por defecto calcula la AutoCorrelacion de una canal | |||
|
98 | ||||
|
99 | self.dataOutObj.tauList = self.tauList | |||
|
100 | self.dataOutObj.nLags = self.nLags | |||
|
101 | self.dataOutObj.pairList = self.pairList | |||
|
102 | ||||
|
103 | if self.buffer == None: | |||
|
104 | nhei = self.dataInObj.nHeights | |||
|
105 | npairList = len(self.pairList) | |||
|
106 | self.buffer = numpy.zeros((self.nLags,nhei,npairList),dtype='complex') | |||
|
107 | ||||
|
108 | bufferZ = numpy.zeros((npairList,self.dataInObj.nHeights),dtype='complex') | |||
|
109 | ||||
|
110 | indexHeight = self.tauList[self.indexTau] / self.dataInObj.m_ProcessingHeader.deltaHeight | |||
|
111 | ||||
|
112 | countPair = 0 | |||
|
113 | ||||
|
114 | # make (signalA*signalB'), where signalA: channel without delay, signalB: channel with delay, | |||
|
115 | for pair in self.pairList: | |||
|
116 | bufferZ[countPair,0:self.dataInObj.nHeights-indexHeight] = self.dataInObj.data[pair[1],indexHeight:self.dataInObj.nHeights] | |||
|
117 | signalA = self.dataInObj.data[pair[0],:] | |||
|
118 | signalB = bufferZ[countPair,:] | |||
|
119 | data = signalA * numpy.conjugate(signalB) | |||
|
120 | self.buffer[self.indexTau,:,countPair] = data | |||
|
121 | countPair += 1 | |||
|
122 | ||||
|
123 | # change index Tau and lagCounter | |||
|
124 | self.indexTau += 1 | |||
|
125 | if self.indexTau >= self.nLags: | |||
|
126 | self.indexTau = 0 | |||
|
127 | self.dataOutObj.data = self.buffer | |||
|
128 | self.buffer = None | |||
|
129 | self.dataOutObj.flagNoData = False | |||
|
130 | else: | |||
|
131 | self.dataOutObj.flagNoData = True | |||
|
132 | ||||
20 |
|
133 | |||
21 | m_Voltage= Voltage() |
|
134 | def addIntegrator(self): | |
|
135 | pass | |||
|
136 | ||||
|
137 | def addWriter(self): | |||
|
138 | pass | |||
|
139 | ||||
|
140 | def addPlotter(self): | |||
|
141 | pass | |||
|
142 | ||||
|
143 | class Integrator(): | |||
|
144 | def __init__(self): | |||
|
145 | pass | |||
22 |
|
146 |
@@ -1,503 +1,548 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
10 |
|
10 | |||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 | from Model.Voltage import Voltage |
|
14 | from Model.Voltage import Voltage | |
15 | from IO.VoltageIO import VoltageWriter |
|
15 | from IO.VoltageIO import VoltageWriter | |
16 | from Graphics.VoltagePlot import Osciloscope |
|
16 | from Graphics.VoltagePlot import Osciloscope | |
17 |
|
17 | |||
18 | class VoltageProcessor: |
|
18 | class VoltageProcessor: | |
19 | ''' |
|
19 | ''' | |
20 | classdocs |
|
20 | classdocs | |
21 | ''' |
|
21 | ''' | |
22 |
|
22 | |||
23 | dataInObj = None |
|
23 | dataInObj = None | |
24 | dataOutObj = None |
|
24 | dataOutObj = None | |
25 |
|
25 | |||
26 | integratorObjIndex = None |
|
26 | integratorObjIndex = None | |
27 | decoderObjIndex = None |
|
27 | decoderObjIndex = None | |
28 | profSelectorObjIndex = None |
|
28 | profSelectorObjIndex = None | |
29 | writerObjIndex = None |
|
29 | writerObjIndex = None | |
30 | plotterObjIndex = None |
|
30 | plotterObjIndex = None | |
|
31 | flipIndex = None | |||
31 |
|
32 | |||
32 | integratorObjList = [] |
|
33 | integratorObjList = [] | |
33 | decoderObjList = [] |
|
34 | decoderObjList = [] | |
34 | profileSelectorObjList = [] |
|
35 | profileSelectorObjList = [] | |
35 | writerObjList = [] |
|
36 | writerObjList = [] | |
36 | plotterObjList = [] |
|
37 | plotterObjList = [] | |
37 | m_Voltage= Voltage() |
|
38 | m_Voltage= Voltage() | |
38 |
|
39 | |||
39 | m_ProfileSelector= ProfileSelector() |
|
40 | m_ProfileSelector= ProfileSelector() | |
40 |
|
41 | |||
41 | m_Decoder= Decoder() |
|
42 | m_Decoder= Decoder() | |
42 |
|
43 | |||
43 | m_CoherentIntegrator= CoherentIntegrator() |
|
44 | m_CoherentIntegrator= CoherentIntegrator() | |
44 |
|
45 | |||
45 |
|
46 | |||
46 | def __init__(self, dataInObj, dataOutObj=None): |
|
47 | def __init__(self, dataInObj, dataOutObj=None): | |
47 | ''' |
|
48 | ''' | |
48 | Constructor |
|
49 | Constructor | |
49 | ''' |
|
50 | ''' | |
50 |
|
51 | |||
51 | self.dataInObj = dataInObj |
|
52 | self.dataInObj = dataInObj | |
52 |
|
53 | |||
53 | if dataOutObj == None: |
|
54 | if dataOutObj == None: | |
54 | self.dataOutObj = Voltage() |
|
55 | self.dataOutObj = Voltage() | |
55 | else: |
|
56 | else: | |
56 | self.dataOutObj = dataOutObj |
|
57 | self.dataOutObj = dataOutObj | |
57 |
|
58 | |||
58 | self.integratorObjIndex = None |
|
59 | self.integratorObjIndex = None | |
59 | self.decoderObjIndex = None |
|
60 | self.decoderObjIndex = None | |
60 | self.profSelectorObjIndex = None |
|
61 | self.profSelectorObjIndex = None | |
61 | self.writerObjIndex = None |
|
62 | self.writerObjIndex = None | |
62 | self.plotterObjIndex = None |
|
63 | self.plotterObjIndex = None | |
63 |
|
64 | self.flipIndex = 1 | ||
64 | self.integratorObjList = [] |
|
65 | self.integratorObjList = [] | |
65 | self.decoderObjList = [] |
|
66 | self.decoderObjList = [] | |
66 | self.profileSelectorObjList = [] |
|
67 | self.profileSelectorObjList = [] | |
67 | self.writerObjList = [] |
|
68 | self.writerObjList = [] | |
68 | self.plotterObjList = [] |
|
69 | self.plotterObjList = [] | |
69 |
|
70 | |||
70 | def init(self): |
|
71 | def init(self): | |
71 |
|
72 | |||
72 | self.integratorObjIndex = 0 |
|
73 | self.integratorObjIndex = 0 | |
73 | self.decoderObjIndex = 0 |
|
74 | self.decoderObjIndex = 0 | |
74 | self.profSelectorObjIndex = 0 |
|
75 | self.profSelectorObjIndex = 0 | |
75 | self.writerObjIndex = 0 |
|
76 | self.writerObjIndex = 0 | |
76 | self.plotterObjIndex = 0 |
|
77 | self.plotterObjIndex = 0 | |
77 | self.dataOutObj.copy(self.dataInObj) |
|
78 | self.dataOutObj.copy(self.dataInObj) | |
|
79 | ||||
|
80 | if self.profSelectorObjIndex != None: | |||
|
81 | for profSelObj in self.profileSelectorObjList: | |||
|
82 | profSelObj.incIndex() | |||
78 |
|
83 | |||
79 | def addWriter(self, wrpath): |
|
84 | def addWriter(self, wrpath): | |
80 | objWriter = VoltageWriter(self.dataOutObj) |
|
85 | objWriter = VoltageWriter(self.dataOutObj) | |
81 | objWriter.setup(wrpath) |
|
86 | objWriter.setup(wrpath) | |
82 | self.writerObjList.append(objWriter) |
|
87 | self.writerObjList.append(objWriter) | |
83 |
|
88 | |||
84 | def addPlotter(self): |
|
89 | def addPlotter(self): | |
85 |
|
90 | |||
86 | plotObj = Osciloscope(self.dataOutObj,self.plotterObjIndex) |
|
91 | plotObj = Osciloscope(self.dataOutObj,self.plotterObjIndex) | |
87 | self.plotterObjList.append(plotObj) |
|
92 | self.plotterObjList.append(plotObj) | |
88 |
|
93 | |||
89 | def addIntegrator(self, nCohInt): |
|
94 | def addIntegrator(self, nCohInt): | |
90 |
|
95 | |||
91 | objCohInt = CoherentIntegrator(nCohInt) |
|
96 | objCohInt = CoherentIntegrator(nCohInt) | |
92 | self.integratorObjList.append(objCohInt) |
|
97 | self.integratorObjList.append(objCohInt) | |
93 |
|
98 | |||
94 | def addDecoder(self, code, ncode, nbaud): |
|
99 | def addDecoder(self, code, ncode, nbaud): | |
95 |
|
100 | |||
96 | objDecoder = Decoder(code,ncode,nbaud) |
|
101 | objDecoder = Decoder(code,ncode,nbaud) | |
97 | self.decoderObjList.append(objDecoder) |
|
102 | self.decoderObjList.append(objDecoder) | |
98 |
|
103 | |||
99 | def addProfileSelector(self, nProfiles): |
|
104 | def addProfileSelector(self, nProfiles): | |
100 |
|
105 | |||
101 | objProfSelector = ProfileSelector(nProfiles) |
|
106 | objProfSelector = ProfileSelector(nProfiles) | |
102 | self.profileSelectorObjList.append(objProfSelector) |
|
107 | self.profileSelectorObjList.append(objProfSelector) | |
103 |
|
108 | |||
104 | def writeData(self,wrpath): |
|
109 | def writeData(self,wrpath): | |
105 |
|
110 | |||
106 | if self.dataOutObj.flagNoData: |
|
111 | if self.dataOutObj.flagNoData: | |
107 | return 0 |
|
112 | return 0 | |
108 |
|
113 | |||
109 | if len(self.writerObjList) <= self.writerObjIndex: |
|
114 | if len(self.writerObjList) <= self.writerObjIndex: | |
110 | self.addWriter(wrpath) |
|
115 | self.addWriter(wrpath) | |
111 |
|
116 | |||
112 | self.writerObjList[self.writerObjIndex].putData() |
|
117 | self.writerObjList[self.writerObjIndex].putData() | |
113 |
|
118 | |||
114 | # myWrObj = self.writerObjList[self.writerObjIndex] |
|
119 | # myWrObj = self.writerObjList[self.writerObjIndex] | |
115 | # myWrObj.putData() |
|
120 | # myWrObj.putData() | |
116 |
|
121 | |||
117 | self.writerObjIndex += 1 |
|
122 | self.writerObjIndex += 1 | |
118 |
|
123 | |||
119 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): |
|
124 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): | |
120 | if self.dataOutObj.flagNoData: |
|
125 | if self.dataOutObj.flagNoData: | |
121 | return 0 |
|
126 | return 0 | |
122 |
|
127 | |||
123 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
128 | if len(self.plotterObjList) <= self.plotterObjIndex: | |
124 | self.addPlotter() |
|
129 | self.addPlotter() | |
125 |
|
130 | |||
126 | self.plotterObjList[self.plotterObjIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) |
|
131 | self.plotterObjList[self.plotterObjIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |
127 |
|
132 | |||
128 | self.plotterObjIndex += 1 |
|
133 | self.plotterObjIndex += 1 | |
129 |
|
134 | |||
130 | def integrator(self, N): |
|
135 | def integrator(self, N): | |
131 |
|
136 | |||
132 | if self.dataOutObj.flagNoData: |
|
137 | if self.dataOutObj.flagNoData: | |
133 | return 0 |
|
138 | return 0 | |
134 |
|
139 | |||
135 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
140 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
136 | self.addIntegrator(N) |
|
141 | self.addIntegrator(N) | |
137 |
|
142 | |||
138 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
143 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] | |
139 | myCohIntObj.exe(self.dataOutObj.data) |
|
144 | myCohIntObj.exe(self.dataOutObj.data) | |
140 |
|
145 | |||
141 | if myCohIntObj.flag: |
|
146 | if myCohIntObj.flag: | |
142 | self.dataOutObj.data = myCohIntObj.data |
|
147 | self.dataOutObj.data = myCohIntObj.data | |
143 | self.dataOutObj.m_ProcessingHeader.coherentInt *= N |
|
148 | self.dataOutObj.m_ProcessingHeader.coherentInt *= N | |
144 | self.dataOutObj.flagNoData = False |
|
149 | self.dataOutObj.flagNoData = False | |
145 |
|
150 | |||
146 | else: |
|
151 | else: | |
147 | self.dataOutObj.flagNoData = True |
|
152 | self.dataOutObj.flagNoData = True | |
148 |
|
153 | |||
149 | self.integratorObjIndex += 1 |
|
154 | self.integratorObjIndex += 1 | |
150 |
|
155 | |||
151 | def decoder(self,code=None,type = 0): |
|
156 | def decoder(self,code=None,type = 0): | |
152 |
|
157 | |||
153 | if self.dataOutObj.flagNoData: |
|
158 | if self.dataOutObj.flagNoData: | |
154 | return 0 |
|
159 | return 0 | |
155 |
|
160 | |||
156 | if code == None: |
|
161 | if code == None: | |
157 | code = self.dataOutObj.m_RadarControllerHeader.code |
|
162 | code = self.dataOutObj.m_RadarControllerHeader.code | |
158 | ncode, nbaud = code.shape |
|
163 | ncode, nbaud = code.shape | |
159 |
|
164 | |||
160 | if len(self.decoderObjList) <= self.decoderObjIndex: |
|
165 | if len(self.decoderObjList) <= self.decoderObjIndex: | |
161 | self.addDecoder(code,ncode,nbaud) |
|
166 | self.addDecoder(code,ncode,nbaud) | |
162 |
|
167 | |||
163 | myDecodObj = self.decoderObjList[self.decoderObjIndex] |
|
168 | myDecodObj = self.decoderObjList[self.decoderObjIndex] | |
164 | myDecodObj.exe(data=self.dataOutObj.data,type=type) |
|
169 | myDecodObj.exe(data=self.dataOutObj.data,type=type) | |
165 |
|
170 | |||
166 | if myDecodObj.flag: |
|
171 | if myDecodObj.flag: | |
167 | self.dataOutObj.data = myDecodObj.data |
|
172 | self.dataOutObj.data = myDecodObj.data | |
168 | self.dataOutObj.flagNoData = False |
|
173 | self.dataOutObj.flagNoData = False | |
169 | else: |
|
174 | else: | |
170 | self.dataOutObj.flagNoData = True |
|
175 | self.dataOutObj.flagNoData = True | |
171 |
|
176 | |||
172 | self.decoderObjIndex += 1 |
|
177 | self.decoderObjIndex += 1 | |
173 |
|
178 | |||
174 |
|
179 | |||
175 | def filterByHei(self, window): |
|
180 | def filterByHei(self, window): | |
176 | pass |
|
181 | if window == None: | |
177 |
|
182 | window = self.dataOutObj.m_RadarControllerHeader.txA / self.dataOutObj.m_ProcessingHeader.deltaHeight[0] | ||
|
183 | ||||
|
184 | newdelta = self.dataOutObj.m_ProcessingHeader.deltaHeight[0] * window | |||
|
185 | dim1 = self.dataOutObj.data.shape[0] | |||
|
186 | dim2 = self.dataOutObj.data.shape[1] | |||
|
187 | r = dim2 % window | |||
|
188 | ||||
|
189 | buffer = self.dataOutObj.data[:,0:dim2-r] | |||
|
190 | buffer = buffer.reshape(dim1,dim2/window,window) | |||
|
191 | buffer = numpy.sum(buffer,2) | |||
|
192 | self.dataOutObj.data = buffer | |||
|
193 | ||||
|
194 | self.dataOutObj.m_ProcessingHeader.deltaHeight = newdelta | |||
|
195 | self.dataOutObj.m_ProcessingHeader.numHeights = buffer.shape[1] | |||
|
196 | ||||
|
197 | self.dataOutObj.nHeights = self.dataOutObj.m_ProcessingHeader.numHeights | |||
|
198 | ||||
|
199 | #self.dataOutObj.heightList es un numpy.array | |||
|
200 | self.dataOutObj.heightList = numpy.arange(self.dataOutObj.m_ProcessingHeader.firstHeight[0],newdelta*self.dataOutObj.nHeights,newdelta) | |||
|
201 | ||||
|
202 | def deFlip(self): | |||
|
203 | self.dataOutObj.data *= self.flipIndex | |||
|
204 | self.flipIndex *= -1. | |||
178 |
|
205 | |||
179 | def selectChannels(self, channelList): |
|
206 | def selectChannels(self, channelList): | |
180 | """ |
|
207 | """ | |
181 | Selecciona un bloque de datos en base a canales y pares segun el channelList y el pairList |
|
208 | Selecciona un bloque de datos en base a canales y pares segun el channelList y el pairList | |
182 |
|
209 | |||
183 | Input: |
|
210 | Input: | |
184 | channelList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
211 | channelList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
185 |
|
212 | |||
186 | Affected: |
|
213 | Affected: | |
187 | self.dataOutObj.data |
|
214 | self.dataOutObj.data | |
188 | self.dataOutObj.channelList |
|
215 | self.dataOutObj.channelList | |
189 | self.dataOutObj.nChannels |
|
216 | self.dataOutObj.nChannels | |
190 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
217 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |
191 | self.dataOutObj.m_SystemHeader.numChannels |
|
218 | self.dataOutObj.m_SystemHeader.numChannels | |
192 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
219 | self.dataOutObj.m_ProcessingHeader.blockSize | |
193 |
|
220 | |||
194 | Return: |
|
221 | Return: | |
195 | None |
|
222 | None | |
196 | """ |
|
223 | """ | |
197 | if self.dataOutObj.flagNoData: |
|
224 | if self.dataOutObj.flagNoData: | |
198 | return 0 |
|
225 | return 0 | |
199 |
|
226 | |||
200 | for channel in channelList: |
|
227 | for channel in channelList: | |
201 | if channel not in self.dataOutObj.channelList: |
|
228 | if channel not in self.dataOutObj.channelList: | |
202 | raise ValueError, "The value %d in channelList is not valid" %channel |
|
229 | raise ValueError, "The value %d in channelList is not valid" %channel | |
203 |
|
230 | |||
204 | nchannels = len(channelList) |
|
231 | nchannels = len(channelList) | |
205 | profiles = self.dataOutObj.nProfiles |
|
232 | profiles = self.dataOutObj.nProfiles | |
206 | heights = self.dataOutObj.nHeights #m_ProcessingHeader.numHeights |
|
233 | heights = self.dataOutObj.nHeights #m_ProcessingHeader.numHeights | |
207 |
|
234 | |||
208 | data = numpy.zeros( (nchannels,heights), dtype='complex' ) |
|
235 | data = numpy.zeros( (nchannels,heights), dtype='complex' ) | |
209 | for index,channel in enumerate(channelList): |
|
236 | for index,channel in enumerate(channelList): | |
210 | data[index,:] = self.dataOutObj.data[channel,:] |
|
237 | data[index,:] = self.dataOutObj.data[channel,:] | |
211 |
|
238 | |||
212 | self.dataOutObj.data = data |
|
239 | self.dataOutObj.data = data | |
213 | self.dataOutObj.channelList = channelList |
|
240 | self.dataOutObj.channelList = channelList | |
214 | self.dataOutObj.nChannels = nchannels |
|
241 | self.dataOutObj.nChannels = nchannels | |
215 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nchannels |
|
242 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nchannels | |
216 | self.dataOutObj.m_SystemHeader.numChannels = nchannels |
|
243 | self.dataOutObj.m_SystemHeader.numChannels = nchannels | |
217 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size |
|
244 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size | |
218 | return 1 |
|
245 | return 1 | |
219 |
|
246 | |||
220 |
|
247 | |||
221 | def selectHeightsByValue(self, minHei, maxHei): |
|
248 | def selectHeightsByValue(self, minHei, maxHei): | |
222 | """ |
|
249 | """ | |
223 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
250 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
224 | minHei <= height <= maxHei |
|
251 | minHei <= height <= maxHei | |
225 |
|
252 | |||
226 | Input: |
|
253 | Input: | |
227 | minHei : valor minimo de altura a considerar |
|
254 | minHei : valor minimo de altura a considerar | |
228 | maxHei : valor maximo de altura a considerar |
|
255 | maxHei : valor maximo de altura a considerar | |
229 |
|
256 | |||
230 | Affected: |
|
257 | Affected: | |
231 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
258 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
232 |
|
259 | |||
233 | Return: |
|
260 | Return: | |
234 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
261 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
235 | """ |
|
262 | """ | |
236 | if self.dataOutObj.flagNoData: |
|
263 | if self.dataOutObj.flagNoData: | |
237 | return 0 |
|
264 | return 0 | |
238 |
|
265 | |||
239 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): |
|
266 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): | |
240 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
267 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
241 |
|
268 | |||
242 | if (maxHei > self.dataOutObj.heightList[-1]): |
|
269 | if (maxHei > self.dataOutObj.heightList[-1]): | |
243 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
270 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
244 |
|
271 | |||
245 | minIndex = 0 |
|
272 | minIndex = 0 | |
246 | maxIndex = 0 |
|
273 | maxIndex = 0 | |
247 | data = self.dataOutObj.heightList |
|
274 | data = self.dataOutObj.heightList | |
248 |
|
275 | |||
249 | for i,val in enumerate(data): |
|
276 | for i,val in enumerate(data): | |
250 | if val < minHei: |
|
277 | if val < minHei: | |
251 | continue |
|
278 | continue | |
252 | else: |
|
279 | else: | |
253 | minIndex = i; |
|
280 | minIndex = i; | |
254 | break |
|
281 | break | |
255 |
|
282 | |||
256 | for i,val in enumerate(data): |
|
283 | for i,val in enumerate(data): | |
257 | if val <= maxHei: |
|
284 | if val <= maxHei: | |
258 | maxIndex = i; |
|
285 | maxIndex = i; | |
259 | else: |
|
286 | else: | |
260 | break |
|
287 | break | |
261 |
|
288 | |||
262 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
289 | self.selectHeightsByIndex(minIndex, maxIndex) | |
263 | return 1 |
|
290 | return 1 | |
264 |
|
291 | |||
265 |
|
292 | |||
266 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
293 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
267 | """ |
|
294 | """ | |
268 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
295 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
269 | minIndex <= index <= maxIndex |
|
296 | minIndex <= index <= maxIndex | |
270 |
|
297 | |||
271 | Input: |
|
298 | Input: | |
272 | minIndex : valor de indice minimo de altura a considerar |
|
299 | minIndex : valor de indice minimo de altura a considerar | |
273 | maxIndex : valor de indice maximo de altura a considerar |
|
300 | maxIndex : valor de indice maximo de altura a considerar | |
274 |
|
301 | |||
275 | Affected: |
|
302 | Affected: | |
276 | self.dataOutObj.data |
|
303 | self.dataOutObj.data | |
277 | self.dataOutObj.heightList |
|
304 | self.dataOutObj.heightList | |
278 | self.dataOutObj.nHeights |
|
305 | self.dataOutObj.nHeights | |
279 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
306 | self.dataOutObj.m_ProcessingHeader.blockSize | |
280 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
307 | self.dataOutObj.m_ProcessingHeader.numHeights | |
281 | self.dataOutObj.m_ProcessingHeader.firstHeight |
|
308 | self.dataOutObj.m_ProcessingHeader.firstHeight | |
282 | self.dataOutObj.m_RadarControllerHeader |
|
309 | self.dataOutObj.m_RadarControllerHeader | |
283 |
|
310 | |||
284 | Return: |
|
311 | Return: | |
285 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
312 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
286 | """ |
|
313 | """ | |
287 | if self.dataOutObj.flagNoData: |
|
314 | if self.dataOutObj.flagNoData: | |
288 | return 0 |
|
315 | return 0 | |
289 |
|
316 | |||
290 | if (minIndex < 0) or (minIndex > maxIndex): |
|
317 | if (minIndex < 0) or (minIndex > maxIndex): | |
291 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
318 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
292 |
|
319 | |||
293 | if (maxIndex >= self.dataOutObj.nHeights): |
|
320 | if (maxIndex >= self.dataOutObj.nHeights): | |
294 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
321 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
295 |
|
322 | |||
296 | nHeights = maxIndex - minIndex + 1 |
|
323 | nHeights = maxIndex - minIndex + 1 | |
297 | firstHeight = 0 |
|
324 | firstHeight = 0 | |
298 |
|
325 | |||
299 | #voltage |
|
326 | #voltage | |
300 | data = self.dataOutObj.data[:,minIndex:maxIndex+1] |
|
327 | data = self.dataOutObj.data[:,minIndex:maxIndex+1] | |
301 |
|
328 | |||
302 | firstHeight = self.dataOutObj.heightList[minIndex] |
|
329 | firstHeight = self.dataOutObj.heightList[minIndex] | |
303 |
|
330 | |||
304 | self.dataOutObj.data = data |
|
331 | self.dataOutObj.data = data | |
305 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] |
|
332 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] | |
306 | self.dataOutObj.nHeights = nHeights |
|
333 | self.dataOutObj.nHeights = nHeights | |
307 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size |
|
334 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size | |
308 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights |
|
335 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights | |
309 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight |
|
336 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight | |
310 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights |
|
337 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights | |
311 | return 1 |
|
338 | return 1 | |
312 |
|
339 | |||
|
340 | def selectProfilesByValue(self,indexList, nProfiles): | |||
|
341 | if self.dataOutObj.flagNoData: | |||
|
342 | return 0 | |||
|
343 | ||||
|
344 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): | |||
|
345 | self.addProfileSelector(nProfiles) | |||
|
346 | ||||
|
347 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] | |||
|
348 | ||||
|
349 | if not(profileSelectorObj.isProfileInList(indexList)): | |||
|
350 | self.dataOutObj.flagNoData = True | |||
|
351 | self.profSelectorObjIndex += 1 | |||
|
352 | return 0 | |||
|
353 | ||||
|
354 | self.dataOutObj.flagNoData = False | |||
|
355 | self.profSelectorObjIndex += 1 | |||
|
356 | ||||
|
357 | return 1 | |||
|
358 | ||||
313 |
|
359 | |||
314 | def selectProfiles(self, minIndex, maxIndex, nProfiles): |
|
360 | def selectProfilesByIndex(self, minIndex, maxIndex, nProfiles): | |
315 | """ |
|
361 | """ | |
316 | Selecciona un bloque de datos en base a un grupo indices de perfiles segun el rango |
|
362 | Selecciona un bloque de datos en base a un grupo indices de perfiles segun el rango | |
317 | minIndex <= index <= maxIndex |
|
363 | minIndex <= index <= maxIndex | |
318 |
|
364 | |||
319 | Input: |
|
365 | Input: | |
320 | minIndex : valor de indice minimo de perfil a considerar |
|
366 | minIndex : valor de indice minimo de perfil a considerar | |
321 | maxIndex : valor de indice maximo de perfil a considerar |
|
367 | maxIndex : valor de indice maximo de perfil a considerar | |
322 | nProfiles : numero de profiles |
|
368 | nProfiles : numero de profiles | |
323 |
|
369 | |||
324 | Affected: |
|
370 | Affected: | |
325 | self.dataOutObj.flagNoData |
|
371 | self.dataOutObj.flagNoData | |
326 | self.profSelectorObjIndex |
|
372 | self.profSelectorObjIndex | |
327 |
|
373 | |||
328 | Return: |
|
374 | Return: | |
329 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
375 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
330 | """ |
|
376 | """ | |
331 |
|
377 | |||
332 | if self.dataOutObj.flagNoData: |
|
378 | if self.dataOutObj.flagNoData: | |
333 | return 0 |
|
379 | return 0 | |
334 |
|
380 | |||
335 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): |
|
381 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): | |
336 | self.addProfileSelector(nProfiles) |
|
382 | self.addProfileSelector(nProfiles) | |
337 |
|
383 | |||
338 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] |
|
384 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] | |
339 |
|
385 | |||
340 | if profileSelectorObj.isProfileInRange(minIndex, maxIndex): |
|
386 | if not(profileSelectorObj.isProfileInRange(minIndex, maxIndex)): | |
341 |
self.dataOutObj.flagNoData = |
|
387 | self.dataOutObj.flagNoData = True | |
342 | self.profSelectorObjIndex += 1 |
|
388 | self.profSelectorObjIndex += 1 | |
343 |
return |
|
389 | return 0 | |
344 |
|
390 | |||
345 |
self.dataOutObj.flagNoData = |
|
391 | self.dataOutObj.flagNoData = False | |
346 | self.profSelectorObjIndex += 1 |
|
392 | self.profSelectorObjIndex += 1 | |
347 |
|
393 | |||
348 |
return |
|
394 | return 1 | |
349 |
|
395 | |||
350 | def selectNtxs(self, ntx): |
|
396 | def selectNtxs(self, ntx): | |
351 | pass |
|
397 | pass | |
352 |
|
398 | |||
353 |
|
399 | |||
354 | class Decoder: |
|
400 | class Decoder: | |
355 |
|
401 | |||
356 | data = None |
|
402 | data = None | |
357 | profCounter = 1 |
|
403 | profCounter = 1 | |
358 | nCode = ncode |
|
404 | nCode = ncode | |
359 | nBaud = nbaud |
|
405 | nBaud = nbaud | |
360 | codeIndex = 0 |
|
406 | codeIndex = 0 | |
361 | code = code #this is a List |
|
407 | code = code #this is a List | |
362 | fft_code = None |
|
408 | fft_code = None | |
363 | flag = False |
|
409 | flag = False | |
364 | setCodeFft = False |
|
410 | setCodeFft = False | |
365 |
|
411 | |||
366 | def __init__(self,code, ncode, nbaud): |
|
412 | def __init__(self,code, ncode, nbaud): | |
367 |
|
413 | |||
368 | self.data = None |
|
414 | self.data = None | |
369 | self.profCounter = 1 |
|
415 | self.profCounter = 1 | |
370 | self.nCode = ncode |
|
416 | self.nCode = ncode | |
371 | self.nBaud = nbaud |
|
417 | self.nBaud = nbaud | |
372 | self.codeIndex = 0 |
|
418 | self.codeIndex = 0 | |
373 | self.code = code #this is a List |
|
419 | self.code = code #this is a List | |
374 | self.fft_code = None |
|
420 | self.fft_code = None | |
375 | self.flag = False |
|
421 | self.flag = False | |
376 | self.setCodeFft = False |
|
422 | self.setCodeFft = False | |
377 |
|
423 | |||
378 | def exe(self, data, ndata=None, type = 0): |
|
424 | def exe(self, data, ndata=None, type = 0): | |
379 |
|
425 | |||
380 | if ndata == None: ndata = data.shape[1] |
|
426 | if ndata == None: ndata = data.shape[1] | |
381 |
|
427 | |||
382 | if type == 0: |
|
428 | if type == 0: | |
383 | self.convolutionInFreq(data,ndata) |
|
429 | self.convolutionInFreq(data,ndata) | |
384 |
|
430 | |||
385 | if type == 1: |
|
431 | if type == 1: | |
386 | self.convolutionInTime(data, ndata) |
|
432 | self.convolutionInTime(data, ndata) | |
387 |
|
433 | |||
388 | def convolutionInFreq(self,data, ndata): |
|
434 | def convolutionInFreq(self,data, ndata): | |
389 |
|
435 | |||
390 | newcode = numpy.zeros(ndata) |
|
436 | newcode = numpy.zeros(ndata) | |
391 | newcode[0:self.nBaud] = self.code[self.codeIndex] |
|
437 | newcode[0:self.nBaud] = self.code[self.codeIndex] | |
392 |
|
438 | |||
393 | self.codeIndex += 1 |
|
439 | self.codeIndex += 1 | |
394 |
|
440 | |||
395 | fft_data = numpy.fft.fft(data, axis=1) |
|
441 | fft_data = numpy.fft.fft(data, axis=1) | |
396 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
442 | fft_code = numpy.conj(numpy.fft.fft(newcode)) | |
397 | fft_code = fft_code.reshape(1,len(fft_code)) |
|
443 | fft_code = fft_code.reshape(1,len(fft_code)) | |
398 |
|
444 | |||
399 | conv = fft_data.copy() |
|
445 | conv = fft_data.copy() | |
400 | conv.fill(0) |
|
446 | conv.fill(0) | |
401 |
|
447 | |||
402 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays |
|
448 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays | |
403 | # for i in range(ndata): |
|
449 | # for i in range(ndata): | |
404 | # conv[i,:] = fft_data[i,:]*fft_code[i] |
|
450 | # conv[i,:] = fft_data[i,:]*fft_code[i] | |
405 |
|
451 | |||
406 | self.data = numpy.fft.ifft(conv,axis=1) |
|
452 | self.data = numpy.fft.ifft(conv,axis=1) | |
407 | self.flag = True |
|
453 | self.flag = True | |
408 |
|
454 | |||
409 | if self.profCounter == self.nCode: |
|
455 | if self.profCounter == self.nCode: | |
410 | self.profCounter = 0 |
|
456 | self.profCounter = 0 | |
411 | self.codeIndex = 0 |
|
457 | self.codeIndex = 0 | |
412 |
|
458 | |||
413 | self.profCounter += 1 |
|
459 | self.profCounter += 1 | |
414 |
|
460 | |||
415 | def convolutionInTime(self, data, ndata): |
|
461 | def convolutionInTime(self, data, ndata): | |
416 |
|
462 | |||
417 | nchannel = data.shape[1] |
|
463 | nchannel = data.shape[1] | |
418 | newcode = self.code[self.codeIndex] |
|
464 | newcode = self.code[self.codeIndex] | |
419 | self.codeIndex += 1 |
|
465 | self.codeIndex += 1 | |
420 | conv = data.copy() |
|
466 | conv = data.copy() | |
421 | for i in range(nchannel): |
|
467 | for i in range(nchannel): | |
422 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') |
|
468 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') | |
423 |
|
469 | |||
424 | self.data = conv |
|
470 | self.data = conv | |
425 | self.flag = True |
|
471 | self.flag = True | |
426 |
|
472 | |||
427 | if self.profCounter == self.nCode: |
|
473 | if self.profCounter == self.nCode: | |
428 | self.profCounter = 0 |
|
474 | self.profCounter = 0 | |
429 | self.codeIndex = 0 |
|
475 | self.codeIndex = 0 | |
430 |
|
476 | |||
431 | self.profCounter += 1 |
|
477 | self.profCounter += 1 | |
432 |
|
478 | |||
433 |
|
479 | |||
434 | class CoherentIntegrator: |
|
480 | class CoherentIntegrator: | |
435 |
|
481 | |||
436 | profCounter = 1 |
|
482 | profCounter = 1 | |
437 | data = None |
|
483 | data = None | |
438 | buffer = None |
|
484 | buffer = None | |
439 | flag = False |
|
485 | flag = False | |
440 | nCohInt = N |
|
486 | nCohInt = N | |
441 |
|
487 | |||
442 | def __init__(self, N): |
|
488 | def __init__(self, N): | |
443 |
|
489 | |||
444 | self.profCounter = 1 |
|
490 | self.profCounter = 1 | |
445 | self.data = None |
|
491 | self.data = None | |
446 | self.buffer = None |
|
492 | self.buffer = None | |
447 | self.flag = False |
|
493 | self.flag = False | |
448 | self.nCohInt = N |
|
494 | self.nCohInt = N | |
449 |
|
495 | |||
450 | def exe(self, data): |
|
496 | def exe(self, data): | |
451 |
|
497 | |||
452 | if self.buffer == None: |
|
498 | if self.buffer == None: | |
453 | self.buffer = data |
|
499 | self.buffer = data | |
454 | else: |
|
500 | else: | |
455 | self.buffer = self.buffer + data |
|
501 | self.buffer = self.buffer + data | |
456 |
|
502 | |||
457 | if self.profCounter == self.nCohInt: |
|
503 | if self.profCounter == self.nCohInt: | |
458 | self.data = self.buffer |
|
504 | self.data = self.buffer | |
459 | self.buffer = None |
|
505 | self.buffer = None | |
460 | self.profCounter = 0 |
|
506 | self.profCounter = 0 | |
461 | self.flag = True |
|
507 | self.flag = True | |
462 | else: |
|
508 | else: | |
463 | self.flag = False |
|
509 | self.flag = False | |
464 |
|
510 | |||
465 | self.profCounter += 1 |
|
511 | self.profCounter += 1 | |
466 |
|
512 | |||
467 | class ProfileSelector: |
|
513 | class ProfileSelector: | |
468 |
|
514 | |||
469 |
|
|
515 | profileIndex = None | |
470 | # Tamanho total de los perfiles |
|
516 | # Tamanho total de los perfiles | |
471 | nProfiles = None |
|
517 | nProfiles = None | |
472 |
|
518 | |||
473 | def __init__(self, nProfiles): |
|
519 | def __init__(self, nProfiles): | |
474 |
|
520 | |||
475 |
self. |
|
521 | self.profileIndex = 0 | |
476 | self.nProfiles = nProfiles |
|
522 | self.nProfiles = nProfiles | |
477 |
|
523 | |||
|
524 | def incIndex(self): | |||
|
525 | self.profileIndex += 1 | |||
|
526 | ||||
|
527 | if self.profileIndex >= self.nProfiles: | |||
|
528 | self.profileIndex = 0 | |||
|
529 | ||||
478 | def isProfileInRange(self, minIndex, maxIndex): |
|
530 | def isProfileInRange(self, minIndex, maxIndex): | |
479 |
|
531 | |||
480 |
if self. |
|
532 | if self.profileIndex < minIndex: | |
481 | self.indexProfile += 1 |
|
|||
482 | return False |
|
533 | return False | |
483 |
|
534 | |||
484 |
if self. |
|
535 | if self.profileIndex > maxIndex: | |
485 | self.indexProfile += 1 |
|
|||
486 | return False |
|
536 | return False | |
487 |
|
537 | |||
488 | self.indexProfile += 1 |
|
|||
489 |
|
||||
490 | return True |
|
538 | return True | |
491 |
|
539 | |||
492 | def isProfileInList(self, profileList): |
|
540 | def isProfileInList(self, profileList): | |
493 |
|
541 | |||
494 |
if self. |
|
542 | if self.profileIndex not in profileList: | |
495 | self.indexProfile += 1 |
|
|||
496 | return False |
|
543 | return False | |
497 |
|
544 | |||
498 | self.indexProfile += 1 |
|
|||
499 |
|
||||
500 | return True |
|
545 | return True | |
501 |
|
546 | |||
502 |
|
547 | |||
503 | No newline at end of file |
|
548 |
General Comments 0
You need to be logged in to leave comments.
Login now