@@ -1,230 +1,232 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import os, sys |
|
7 | import os, sys | |
8 | import copy |
|
8 | import copy | |
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 IO.JROHeaderIO import SystemHeader, RadarControllerHeader |
|
14 | from IO.JROHeaderIO import SystemHeader, RadarControllerHeader | |
15 |
|
15 | |||
16 | class JROData: |
|
16 | class JROData: | |
17 |
|
17 | |||
18 | # m_BasicHeader = BasicHeader() |
|
18 | # m_BasicHeader = BasicHeader() | |
19 | # m_ProcessingHeader = ProcessingHeader() |
|
19 | # m_ProcessingHeader = ProcessingHeader() | |
20 |
|
20 | |||
21 | systemHeaderObj = SystemHeader() |
|
21 | systemHeaderObj = SystemHeader() | |
22 |
|
22 | |||
23 | radarControllerHeaderObj = RadarControllerHeader() |
|
23 | radarControllerHeaderObj = RadarControllerHeader() | |
24 |
|
24 | |||
25 | # data = None |
|
25 | # data = None | |
26 |
|
26 | |||
27 | type = None |
|
27 | type = None | |
28 |
|
28 | |||
29 | dtype = None |
|
29 | dtype = None | |
30 |
|
30 | |||
31 | nChannels = None |
|
31 | nChannels = None | |
32 |
|
32 | |||
33 | nHeights = None |
|
33 | nHeights = None | |
34 |
|
34 | |||
35 | nProfiles = None |
|
35 | nProfiles = None | |
36 |
|
36 | |||
37 | heightList = None |
|
37 | heightList = None | |
38 |
|
38 | |||
39 | channelList = None |
|
39 | channelList = None | |
40 |
|
40 | |||
41 | channelIndexList = None |
|
41 | channelIndexList = None | |
42 |
|
42 | |||
43 | flagNoData = True |
|
43 | flagNoData = True | |
44 |
|
44 | |||
45 | flagTimeBlock = False |
|
45 | flagTimeBlock = False | |
46 |
|
46 | |||
47 | utctime = None |
|
47 | utctime = None | |
48 |
|
48 | |||
49 | blocksize = None |
|
49 | blocksize = None | |
50 |
|
50 | |||
51 | nCode = None |
|
51 | nCode = None | |
52 |
|
52 | |||
53 | nBaud = None |
|
53 | nBaud = None | |
54 |
|
54 | |||
55 | code = None |
|
55 | code = None | |
56 |
|
56 | |||
57 | flagDecodeData = True #asumo q la data esta decodificada |
|
57 | flagDecodeData = True #asumo q la data esta decodificada | |
58 |
|
58 | |||
59 | flagDeflipData = True #asumo q la data esta sin flip |
|
59 | flagDeflipData = True #asumo q la data esta sin flip | |
60 |
|
60 | |||
61 | flagShiftFFT = False |
|
61 | flagShiftFFT = False | |
62 |
|
62 | |||
63 | ippSeconds = None |
|
63 | ippSeconds = None | |
64 |
|
64 | |||
65 | timeInterval = None |
|
65 | timeInterval = None | |
66 |
|
66 | |||
67 | def __init__(self): |
|
67 | def __init__(self): | |
68 |
|
68 | |||
69 | raise ValueError, "This class has not been implemented" |
|
69 | raise ValueError, "This class has not been implemented" | |
70 |
|
70 | |||
71 | def copy(self, inputObj=None): |
|
71 | def copy(self, inputObj=None): | |
72 |
|
72 | |||
73 | if inputObj == None: |
|
73 | if inputObj == None: | |
74 | return copy.deepcopy(self) |
|
74 | return copy.deepcopy(self) | |
75 |
|
75 | |||
76 | for key in inputObj.__dict__.keys(): |
|
76 | for key in inputObj.__dict__.keys(): | |
77 | self.__dict__[key] = inputObj.__dict__[key] |
|
77 | self.__dict__[key] = inputObj.__dict__[key] | |
78 |
|
78 | |||
79 | def deepcopy(self): |
|
79 | def deepcopy(self): | |
80 |
|
80 | |||
81 | return copy.deepcopy(self) |
|
81 | return copy.deepcopy(self) | |
82 |
|
82 | |||
83 | class Voltage(JROData): |
|
83 | class Voltage(JROData): | |
84 |
|
84 | |||
85 | nCohInt = None |
|
85 | nCohInt = None | |
86 |
|
86 | |||
87 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
87 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
88 | data = None |
|
88 | data = None | |
89 |
|
89 | |||
90 | def __init__(self): |
|
90 | def __init__(self): | |
91 | ''' |
|
91 | ''' | |
92 | Constructor |
|
92 | Constructor | |
93 | ''' |
|
93 | ''' | |
94 |
|
94 | |||
95 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
95 | self.radarControllerHeaderObj = RadarControllerHeader() | |
96 |
|
96 | |||
97 | self.systemHeaderObj = SystemHeader() |
|
97 | self.systemHeaderObj = SystemHeader() | |
98 |
|
98 | |||
99 | self.type = "Voltage" |
|
99 | self.type = "Voltage" | |
100 |
|
100 | |||
101 | self.data = None |
|
101 | self.data = None | |
102 |
|
102 | |||
103 | self.dtype = None |
|
103 | self.dtype = None | |
104 |
|
104 | |||
105 | self.nChannels = 0 |
|
105 | self.nChannels = 0 | |
106 |
|
106 | |||
107 | self.nHeights = 0 |
|
107 | self.nHeights = 0 | |
108 |
|
108 | |||
109 | self.nProfiles = None |
|
109 | self.nProfiles = None | |
110 |
|
110 | |||
111 | self.heightList = None |
|
111 | self.heightList = None | |
112 |
|
112 | |||
113 | self.channelList = None |
|
113 | self.channelList = None | |
114 |
|
114 | |||
115 | self.channelIndexList = None |
|
115 | self.channelIndexList = None | |
116 |
|
116 | |||
117 | self.flagNoData = True |
|
117 | self.flagNoData = True | |
118 |
|
118 | |||
119 | self.flagTimeBlock = False |
|
119 | self.flagTimeBlock = False | |
120 |
|
120 | |||
121 | self.utctime = None |
|
121 | self.utctime = None | |
122 |
|
122 | |||
123 | self.nCohInt = None |
|
123 | self.nCohInt = None | |
124 |
|
124 | |||
125 | self.blocksize = None |
|
125 | self.blocksize = None | |
126 |
|
126 | |||
127 | class Spectra(JROData): |
|
127 | class Spectra(JROData): | |
128 |
|
128 | |||
129 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
129 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
130 | data_spc = None |
|
130 | data_spc = None | |
131 |
|
131 | |||
132 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
132 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) | |
133 | data_cspc = None |
|
133 | data_cspc = None | |
134 |
|
134 | |||
135 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
135 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
136 | data_dc = None |
|
136 | data_dc = None | |
137 |
|
137 | |||
138 | nFFTPoints = None |
|
138 | nFFTPoints = None | |
139 |
|
139 | |||
140 | nPairs = None |
|
140 | nPairs = None | |
141 |
|
141 | |||
142 | pairsList = None |
|
142 | pairsList = None | |
143 |
|
143 | |||
144 | nIncohInt = None |
|
144 | nIncohInt = None | |
145 |
|
145 | |||
|
146 | nCohInt = None #se requiere para determinar el valor de timeInterval | |||
|
147 | ||||
146 | def __init__(self): |
|
148 | def __init__(self): | |
147 | ''' |
|
149 | ''' | |
148 | Constructor |
|
150 | Constructor | |
149 | ''' |
|
151 | ''' | |
150 |
|
152 | |||
151 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
153 | self.radarControllerHeaderObj = RadarControllerHeader() | |
152 |
|
154 | |||
153 | self.systemHeaderObj = SystemHeader() |
|
155 | self.systemHeaderObj = SystemHeader() | |
154 |
|
156 | |||
155 | self.type = "Spectra" |
|
157 | self.type = "Spectra" | |
156 |
|
158 | |||
157 | # self.data = None |
|
159 | # self.data = None | |
158 |
|
160 | |||
159 | self.dtype = None |
|
161 | self.dtype = None | |
160 |
|
162 | |||
161 | self.nChannels = 0 |
|
163 | self.nChannels = 0 | |
162 |
|
164 | |||
163 | self.nHeights = 0 |
|
165 | self.nHeights = 0 | |
164 |
|
166 | |||
165 | self.nProfiles = None |
|
167 | self.nProfiles = None | |
166 |
|
168 | |||
167 | self.heightList = None |
|
169 | self.heightList = None | |
168 |
|
170 | |||
169 | self.channelList = None |
|
171 | self.channelList = None | |
170 |
|
172 | |||
171 | self.channelIndexList = None |
|
173 | self.channelIndexList = None | |
172 |
|
174 | |||
173 | self.flagNoData = True |
|
175 | self.flagNoData = True | |
174 |
|
176 | |||
175 | self.flagTimeBlock = False |
|
177 | self.flagTimeBlock = False | |
176 |
|
178 | |||
177 | self.utctime = None |
|
179 | self.utctime = None | |
178 |
|
180 | |||
179 | self.nIncohInt = None |
|
181 | self.nIncohInt = None | |
180 |
|
182 | |||
181 | self.blocksize = None |
|
183 | self.blocksize = None | |
182 |
|
184 | |||
183 |
|
185 | |||
184 | class SpectraHeis(JROData): |
|
186 | class SpectraHeis(JROData): | |
185 |
|
187 | |||
186 | data_spc = None |
|
188 | data_spc = None | |
187 |
|
189 | |||
188 | data_cspc = None |
|
190 | data_cspc = None | |
189 |
|
191 | |||
190 | data_dc = None |
|
192 | data_dc = None | |
191 |
|
193 | |||
192 | nFFTPoints = None |
|
194 | nFFTPoints = None | |
193 |
|
195 | |||
194 | nPairs = None |
|
196 | nPairs = None | |
195 |
|
197 | |||
196 | pairsList = None |
|
198 | pairsList = None | |
197 |
|
199 | |||
198 | nIncohInt = None |
|
200 | nIncohInt = None | |
199 |
|
201 | |||
200 | def __init__(self): |
|
202 | def __init__(self): | |
201 |
|
203 | |||
202 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
204 | self.radarControllerHeaderObj = RadarControllerHeader() | |
203 |
|
205 | |||
204 | self.systemHeaderObj = SystemHeader() |
|
206 | self.systemHeaderObj = SystemHeader() | |
205 |
|
207 | |||
206 | self.type = "SpectraHeis" |
|
208 | self.type = "SpectraHeis" | |
207 |
|
209 | |||
208 | self.dtype = None |
|
210 | self.dtype = None | |
209 |
|
211 | |||
210 | self.nChannels = 0 |
|
212 | self.nChannels = 0 | |
211 |
|
213 | |||
212 | self.nHeights = 0 |
|
214 | self.nHeights = 0 | |
213 |
|
215 | |||
214 | self.nProfiles = None |
|
216 | self.nProfiles = None | |
215 |
|
217 | |||
216 | self.heightList = None |
|
218 | self.heightList = None | |
217 |
|
219 | |||
218 | self.channelList = None |
|
220 | self.channelList = None | |
219 |
|
221 | |||
220 | self.channelIndexList = None |
|
222 | self.channelIndexList = None | |
221 |
|
223 | |||
222 | self.flagNoData = True |
|
224 | self.flagNoData = True | |
223 |
|
225 | |||
224 | self.flagTimeBlock = False |
|
226 | self.flagTimeBlock = False | |
225 |
|
227 | |||
226 | self.nPairs = 0 |
|
228 | self.nPairs = 0 | |
227 |
|
229 | |||
228 | self.utctime = None |
|
230 | self.utctime = None | |
229 |
|
231 | |||
230 | self.blocksize = None |
|
232 | self.blocksize = None |
@@ -1,781 +1,781 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
9 | import glob |
|
9 | import glob | |
10 | import fnmatch |
|
10 | import fnmatch | |
11 | import time, datetime |
|
11 | import time, datetime | |
12 |
|
12 | |||
13 | path = os.path.split(os.getcwd())[0] |
|
13 | path = os.path.split(os.getcwd())[0] | |
14 | sys.path.append(path) |
|
14 | sys.path.append(path) | |
15 |
|
15 | |||
16 | from JROHeaderIO import * |
|
16 | from JROHeaderIO import * | |
17 | from JRODataIO import JRODataReader |
|
17 | from JRODataIO import JRODataReader | |
18 | from JRODataIO import JRODataWriter |
|
18 | from JRODataIO import JRODataWriter | |
19 |
|
19 | |||
20 | from Data.JROData import Spectra |
|
20 | from Data.JROData import Spectra | |
21 |
|
21 | |||
22 | class SpectraReader(JRODataReader): |
|
22 | class SpectraReader(JRODataReader): | |
23 | """ |
|
23 | """ | |
24 | Esta clase permite leer datos de espectros desde archivos procesados (.pdata). La lectura |
|
24 | Esta clase permite leer datos de espectros desde archivos procesados (.pdata). La lectura | |
25 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones) |
|
25 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones) | |
26 | son almacenados en tres buffer's para el Self Spectra, el Cross Spectra y el DC Channel. |
|
26 | son almacenados en tres buffer's para el Self Spectra, el Cross Spectra y el DC Channel. | |
27 |
|
27 | |||
28 | paresCanalesIguales * alturas * perfiles (Self Spectra) |
|
28 | paresCanalesIguales * alturas * perfiles (Self Spectra) | |
29 | paresCanalesDiferentes * alturas * perfiles (Cross Spectra) |
|
29 | paresCanalesDiferentes * alturas * perfiles (Cross Spectra) | |
30 | canales * alturas (DC Channels) |
|
30 | canales * alturas (DC Channels) | |
31 |
|
31 | |||
32 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, |
|
32 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, | |
33 | RadarControllerHeader y Spectra. Los tres primeros se usan para almacenar informacion de la |
|
33 | RadarControllerHeader y Spectra. Los tres primeros se usan para almacenar informacion de la | |
34 | cabecera de datos (metadata), y el cuarto (Spectra) para obtener y almacenar un bloque de |
|
34 | cabecera de datos (metadata), y el cuarto (Spectra) para obtener y almacenar un bloque de | |
35 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". |
|
35 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". | |
36 |
|
36 | |||
37 | Example: |
|
37 | Example: | |
38 | dpath = "/home/myuser/data" |
|
38 | dpath = "/home/myuser/data" | |
39 |
|
39 | |||
40 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) |
|
40 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) | |
41 |
|
41 | |||
42 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) |
|
42 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) | |
43 |
|
43 | |||
44 | readerObj = SpectraReader() |
|
44 | readerObj = SpectraReader() | |
45 |
|
45 | |||
46 | readerObj.setup(dpath, startTime, endTime) |
|
46 | readerObj.setup(dpath, startTime, endTime) | |
47 |
|
47 | |||
48 | while(True): |
|
48 | while(True): | |
49 |
|
49 | |||
50 | readerObj.getData() |
|
50 | readerObj.getData() | |
51 |
|
51 | |||
52 | print readerObj.data_spc |
|
52 | print readerObj.data_spc | |
53 |
|
53 | |||
54 | print readerObj.data_cspc |
|
54 | print readerObj.data_cspc | |
55 |
|
55 | |||
56 | print readerObj.data_dc |
|
56 | print readerObj.data_dc | |
57 |
|
57 | |||
58 | if readerObj.flagNoMoreFiles: |
|
58 | if readerObj.flagNoMoreFiles: | |
59 | break |
|
59 | break | |
60 |
|
60 | |||
61 | """ |
|
61 | """ | |
62 |
|
62 | |||
63 | pts2read_SelfSpectra = 0 |
|
63 | pts2read_SelfSpectra = 0 | |
64 |
|
64 | |||
65 | pts2read_CrossSpectra = 0 |
|
65 | pts2read_CrossSpectra = 0 | |
66 |
|
66 | |||
67 | pts2read_DCchannels = 0 |
|
67 | pts2read_DCchannels = 0 | |
68 |
|
68 | |||
69 | ext = ".pdata" |
|
69 | ext = ".pdata" | |
70 |
|
70 | |||
71 | optchar = "P" |
|
71 | optchar = "P" | |
72 |
|
72 | |||
73 | dataOutObj = None |
|
73 | dataOutObj = None | |
74 |
|
74 | |||
75 | nRdChannels = None |
|
75 | nRdChannels = None | |
76 |
|
76 | |||
77 | nRdPairs = None |
|
77 | nRdPairs = None | |
78 |
|
78 | |||
79 | rdPairList = [] |
|
79 | rdPairList = [] | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | def __init__(self, dataOutObj=None): |
|
82 | def __init__(self, dataOutObj=None): | |
83 | """ |
|
83 | """ | |
84 | Inicializador de la clase SpectraReader para la lectura de datos de espectros. |
|
84 | Inicializador de la clase SpectraReader para la lectura de datos de espectros. | |
85 |
|
85 | |||
86 | Inputs: |
|
86 | Inputs: | |
87 | dataOutObj : Objeto de la clase Spectra. Este objeto sera utilizado para |
|
87 | dataOutObj : Objeto de la clase Spectra. Este objeto sera utilizado para | |
88 | almacenar un perfil de datos cada vez que se haga un requerimiento |
|
88 | almacenar un perfil de datos cada vez que se haga un requerimiento | |
89 | (getData). El perfil sera obtenido a partir del buffer de datos, |
|
89 | (getData). El perfil sera obtenido a partir del buffer de datos, | |
90 | si el buffer esta vacio se hara un nuevo proceso de lectura de un |
|
90 | si el buffer esta vacio se hara un nuevo proceso de lectura de un | |
91 | bloque de datos. |
|
91 | bloque de datos. | |
92 | Si este parametro no es pasado se creara uno internamente. |
|
92 | Si este parametro no es pasado se creara uno internamente. | |
93 |
|
93 | |||
94 | Affected: |
|
94 | Affected: | |
95 | self.dataOutObj |
|
95 | self.dataOutObj | |
96 |
|
96 | |||
97 | Return : None |
|
97 | Return : None | |
98 | """ |
|
98 | """ | |
99 |
|
99 | |||
100 | self.pts2read_SelfSpectra = 0 |
|
100 | self.pts2read_SelfSpectra = 0 | |
101 |
|
101 | |||
102 | self.pts2read_CrossSpectra = 0 |
|
102 | self.pts2read_CrossSpectra = 0 | |
103 |
|
103 | |||
104 | self.pts2read_DCchannels = 0 |
|
104 | self.pts2read_DCchannels = 0 | |
105 |
|
105 | |||
106 | self.datablock = None |
|
106 | self.datablock = None | |
107 |
|
107 | |||
108 | self.utc = None |
|
108 | self.utc = None | |
109 |
|
109 | |||
110 | self.ext = ".pdata" |
|
110 | self.ext = ".pdata" | |
111 |
|
111 | |||
112 | self.optchar = "P" |
|
112 | self.optchar = "P" | |
113 |
|
113 | |||
114 | self.basicHeaderObj = BasicHeader() |
|
114 | self.basicHeaderObj = BasicHeader() | |
115 |
|
115 | |||
116 | self.systemHeaderObj = SystemHeader() |
|
116 | self.systemHeaderObj = SystemHeader() | |
117 |
|
117 | |||
118 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
118 | self.radarControllerHeaderObj = RadarControllerHeader() | |
119 |
|
119 | |||
120 | self.processingHeaderObj = ProcessingHeader() |
|
120 | self.processingHeaderObj = ProcessingHeader() | |
121 |
|
121 | |||
122 | self.online = 0 |
|
122 | self.online = 0 | |
123 |
|
123 | |||
124 | self.fp = None |
|
124 | self.fp = None | |
125 |
|
125 | |||
126 | self.idFile = None |
|
126 | self.idFile = None | |
127 |
|
127 | |||
128 | self.dtype = None |
|
128 | self.dtype = None | |
129 |
|
129 | |||
130 | self.fileSizeByHeader = None |
|
130 | self.fileSizeByHeader = None | |
131 |
|
131 | |||
132 | self.filenameList = [] |
|
132 | self.filenameList = [] | |
133 |
|
133 | |||
134 | self.filename = None |
|
134 | self.filename = None | |
135 |
|
135 | |||
136 | self.fileSize = None |
|
136 | self.fileSize = None | |
137 |
|
137 | |||
138 | self.firstHeaderSize = 0 |
|
138 | self.firstHeaderSize = 0 | |
139 |
|
139 | |||
140 | self.basicHeaderSize = 24 |
|
140 | self.basicHeaderSize = 24 | |
141 |
|
141 | |||
142 | self.pathList = [] |
|
142 | self.pathList = [] | |
143 |
|
143 | |||
144 | self.lastUTTime = 0 |
|
144 | self.lastUTTime = 0 | |
145 |
|
145 | |||
146 | self.maxTimeStep = 30 |
|
146 | self.maxTimeStep = 30 | |
147 |
|
147 | |||
148 | self.flagNoMoreFiles = 0 |
|
148 | self.flagNoMoreFiles = 0 | |
149 |
|
149 | |||
150 | self.set = 0 |
|
150 | self.set = 0 | |
151 |
|
151 | |||
152 | self.path = None |
|
152 | self.path = None | |
153 |
|
153 | |||
154 | self.delay = 3 #seconds |
|
154 | self.delay = 3 #seconds | |
155 |
|
155 | |||
156 | self.nTries = 3 #quantity tries |
|
156 | self.nTries = 3 #quantity tries | |
157 |
|
157 | |||
158 | self.nFiles = 3 #number of files for searching |
|
158 | self.nFiles = 3 #number of files for searching | |
159 |
|
159 | |||
160 | self.nReadBlocks = 0 |
|
160 | self.nReadBlocks = 0 | |
161 |
|
161 | |||
162 | self.flagIsNewFile = 1 |
|
162 | self.flagIsNewFile = 1 | |
163 |
|
163 | |||
164 | self.ippSeconds = 0 |
|
164 | self.ippSeconds = 0 | |
165 |
|
165 | |||
166 | self.flagTimeBlock = 0 |
|
166 | self.flagTimeBlock = 0 | |
167 |
|
167 | |||
168 | self.flagIsNewBlock = 0 |
|
168 | self.flagIsNewBlock = 0 | |
169 |
|
169 | |||
170 | self.nTotalBlocks = 0 |
|
170 | self.nTotalBlocks = 0 | |
171 |
|
171 | |||
172 | self.blocksize = 0 |
|
172 | self.blocksize = 0 | |
173 |
|
173 | |||
174 |
|
174 | |||
175 | def createObjByDefault(self): |
|
175 | def createObjByDefault(self): | |
176 |
|
176 | |||
177 | dataObj = Spectra() |
|
177 | dataObj = Spectra() | |
178 |
|
178 | |||
179 | return dataObj |
|
179 | return dataObj | |
180 |
|
180 | |||
181 | def __hasNotDataInBuffer(self): |
|
181 | def __hasNotDataInBuffer(self): | |
182 | return 1 |
|
182 | return 1 | |
183 |
|
183 | |||
184 |
|
184 | |||
185 | def getBlockDimension(self): |
|
185 | def getBlockDimension(self): | |
186 | """ |
|
186 | """ | |
187 | Obtiene la cantidad de puntos a leer por cada bloque de datos |
|
187 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
188 |
|
188 | |||
189 | Affected: |
|
189 | Affected: | |
190 | self.nRdChannels |
|
190 | self.nRdChannels | |
191 | self.nRdPairs |
|
191 | self.nRdPairs | |
192 | self.pts2read_SelfSpectra |
|
192 | self.pts2read_SelfSpectra | |
193 | self.pts2read_CrossSpectra |
|
193 | self.pts2read_CrossSpectra | |
194 | self.pts2read_DCchannels |
|
194 | self.pts2read_DCchannels | |
195 | self.blocksize |
|
195 | self.blocksize | |
196 | self.dataOutObj.nChannels |
|
196 | self.dataOutObj.nChannels | |
197 | self.dataOutObj.nPairs |
|
197 | self.dataOutObj.nPairs | |
198 |
|
198 | |||
199 | Return: |
|
199 | Return: | |
200 | None |
|
200 | None | |
201 | """ |
|
201 | """ | |
202 | self.nRdChannels = 0 |
|
202 | self.nRdChannels = 0 | |
203 | self.nRdPairs = 0 |
|
203 | self.nRdPairs = 0 | |
204 | self.rdPairList = [] |
|
204 | self.rdPairList = [] | |
205 |
|
205 | |||
206 | for i in range(0, self.processingHeaderObj.totalSpectra*2, 2): |
|
206 | for i in range(0, self.processingHeaderObj.totalSpectra*2, 2): | |
207 | if self.processingHeaderObj.spectraComb[i] == self.processingHeaderObj.spectraComb[i+1]: |
|
207 | if self.processingHeaderObj.spectraComb[i] == self.processingHeaderObj.spectraComb[i+1]: | |
208 | self.nRdChannels = self.nRdChannels + 1 #par de canales iguales |
|
208 | self.nRdChannels = self.nRdChannels + 1 #par de canales iguales | |
209 | else: |
|
209 | else: | |
210 | self.nRdPairs = self.nRdPairs + 1 #par de canales diferentes |
|
210 | self.nRdPairs = self.nRdPairs + 1 #par de canales diferentes | |
211 | self.rdPairList.append((self.processingHeaderObj.spectraComb[i], self.processingHeaderObj.spectraComb[i+1])) |
|
211 | self.rdPairList.append((self.processingHeaderObj.spectraComb[i], self.processingHeaderObj.spectraComb[i+1])) | |
212 |
|
212 | |||
213 | pts2read = self.processingHeaderObj.nHeights * self.processingHeaderObj.profilesPerBlock |
|
213 | pts2read = self.processingHeaderObj.nHeights * self.processingHeaderObj.profilesPerBlock | |
214 |
|
214 | |||
215 | self.pts2read_SelfSpectra = int(self.nRdChannels * pts2read) |
|
215 | self.pts2read_SelfSpectra = int(self.nRdChannels * pts2read) | |
216 | self.blocksize = self.pts2read_SelfSpectra |
|
216 | self.blocksize = self.pts2read_SelfSpectra | |
217 |
|
217 | |||
218 | if self.processingHeaderObj.flag_cspc: |
|
218 | if self.processingHeaderObj.flag_cspc: | |
219 | self.pts2read_CrossSpectra = int(self.nRdPairs * pts2read) |
|
219 | self.pts2read_CrossSpectra = int(self.nRdPairs * pts2read) | |
220 | self.blocksize += self.pts2read_CrossSpectra |
|
220 | self.blocksize += self.pts2read_CrossSpectra | |
221 |
|
221 | |||
222 | if self.processingHeaderObj.flag_dc: |
|
222 | if self.processingHeaderObj.flag_dc: | |
223 | self.pts2read_DCchannels = int(self.systemHeaderObj.nChannels * self.processingHeaderObj.nHeights) |
|
223 | self.pts2read_DCchannels = int(self.systemHeaderObj.nChannels * self.processingHeaderObj.nHeights) | |
224 | self.blocksize += self.pts2read_DCchannels |
|
224 | self.blocksize += self.pts2read_DCchannels | |
225 |
|
225 | |||
226 | # self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels |
|
226 | # self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels | |
227 |
|
227 | |||
228 |
|
228 | |||
229 | def readBlock(self): |
|
229 | def readBlock(self): | |
230 | """ |
|
230 | """ | |
231 | Lee el bloque de datos desde la posicion actual del puntero del archivo |
|
231 | Lee el bloque de datos desde la posicion actual del puntero del archivo | |
232 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos |
|
232 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos | |
233 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer |
|
233 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |
234 | es seteado a 0 |
|
234 | es seteado a 0 | |
235 |
|
235 | |||
236 | Return: None |
|
236 | Return: None | |
237 |
|
237 | |||
238 | Variables afectadas: |
|
238 | Variables afectadas: | |
239 |
|
239 | |||
240 | self.flagIsNewFile |
|
240 | self.flagIsNewFile | |
241 | self.flagIsNewBlock |
|
241 | self.flagIsNewBlock | |
242 | self.nTotalBlocks |
|
242 | self.nTotalBlocks | |
243 | self.data_spc |
|
243 | self.data_spc | |
244 | self.data_cspc |
|
244 | self.data_cspc | |
245 | self.data_dc |
|
245 | self.data_dc | |
246 |
|
246 | |||
247 | Exceptions: |
|
247 | Exceptions: | |
248 | Si un bloque leido no es un bloque valido |
|
248 | Si un bloque leido no es un bloque valido | |
249 | """ |
|
249 | """ | |
250 | blockOk_flag = False |
|
250 | blockOk_flag = False | |
251 | fpointer = self.fp.tell() |
|
251 | fpointer = self.fp.tell() | |
252 |
|
252 | |||
253 | spc = numpy.fromfile( self.fp, self.dtype[0], self.pts2read_SelfSpectra ) |
|
253 | spc = numpy.fromfile( self.fp, self.dtype[0], self.pts2read_SelfSpectra ) | |
254 | spc = spc.reshape( (self.nRdChannels, self.processingHeaderObj.nHeights, self.processingHeaderObj.profilesPerBlock) ) #transforma a un arreglo 3D |
|
254 | spc = spc.reshape( (self.nRdChannels, self.processingHeaderObj.nHeights, self.processingHeaderObj.profilesPerBlock) ) #transforma a un arreglo 3D | |
255 |
|
255 | |||
256 | if self.processingHeaderObj.flag_cspc: |
|
256 | if self.processingHeaderObj.flag_cspc: | |
257 | cspc = numpy.fromfile( self.fp, self.dtype, self.pts2read_CrossSpectra ) |
|
257 | cspc = numpy.fromfile( self.fp, self.dtype, self.pts2read_CrossSpectra ) | |
258 | cspc = cspc.reshape( (self.nRdPairs, self.processingHeaderObj.nHeights, self.processingHeaderObj.profilesPerBlock) ) #transforma a un arreglo 3D |
|
258 | cspc = cspc.reshape( (self.nRdPairs, self.processingHeaderObj.nHeights, self.processingHeaderObj.profilesPerBlock) ) #transforma a un arreglo 3D | |
259 |
|
259 | |||
260 | if self.processingHeaderObj.flag_dc: |
|
260 | if self.processingHeaderObj.flag_dc: | |
261 | dc = numpy.fromfile( self.fp, self.dtype, self.pts2read_DCchannels ) #int(self.processingHeaderObj.nHeights*self.systemHeaderObj.nChannels) ) |
|
261 | dc = numpy.fromfile( self.fp, self.dtype, self.pts2read_DCchannels ) #int(self.processingHeaderObj.nHeights*self.systemHeaderObj.nChannels) ) | |
262 | dc = dc.reshape( (self.systemHeaderObj.nChannels, self.processingHeaderObj.nHeights) ) #transforma a un arreglo 2D |
|
262 | dc = dc.reshape( (self.systemHeaderObj.nChannels, self.processingHeaderObj.nHeights) ) #transforma a un arreglo 2D | |
263 |
|
263 | |||
264 |
|
264 | |||
265 | if not(self.processingHeaderObj.shif_fft): |
|
265 | if not(self.processingHeaderObj.shif_fft): | |
266 | spc = numpy.roll( spc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones |
|
266 | spc = numpy.roll( spc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones | |
267 |
|
267 | |||
268 | if self.processingHeaderObj.flag_cspc: |
|
268 | if self.processingHeaderObj.flag_cspc: | |
269 | cspc = numpy.roll( cspc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones |
|
269 | cspc = numpy.roll( cspc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones | |
270 |
|
270 | |||
271 |
|
271 | |||
272 | spc = numpy.transpose( spc, (0,2,1) ) |
|
272 | spc = numpy.transpose( spc, (0,2,1) ) | |
273 | self.data_spc = spc |
|
273 | self.data_spc = spc | |
274 |
|
274 | |||
275 | if self.processingHeaderObj.flag_cspc: |
|
275 | if self.processingHeaderObj.flag_cspc: | |
276 | cspc = numpy.transpose( cspc, (0,2,1) ) |
|
276 | cspc = numpy.transpose( cspc, (0,2,1) ) | |
277 | self.data_cspc = cspc['real'] + cspc['imag']*1j |
|
277 | self.data_cspc = cspc['real'] + cspc['imag']*1j | |
278 | else: |
|
278 | else: | |
279 | self.data_cspc = None |
|
279 | self.data_cspc = None | |
280 |
|
280 | |||
281 | if self.processingHeaderObj.flag_dc: |
|
281 | if self.processingHeaderObj.flag_dc: | |
282 | self.data_dc = dc['real'] + dc['imag']*1j |
|
282 | self.data_dc = dc['real'] + dc['imag']*1j | |
283 | else: |
|
283 | else: | |
284 | self.data_dc = None |
|
284 | self.data_dc = None | |
285 |
|
285 | |||
286 | self.flagIsNewFile = 0 |
|
286 | self.flagIsNewFile = 0 | |
287 | self.flagIsNewBlock = 1 |
|
287 | self.flagIsNewBlock = 1 | |
288 |
|
288 | |||
289 | self.nTotalBlocks += 1 |
|
289 | self.nTotalBlocks += 1 | |
290 | self.nReadBlocks += 1 |
|
290 | self.nReadBlocks += 1 | |
291 |
|
291 | |||
292 | return 1 |
|
292 | return 1 | |
293 |
|
293 | |||
294 |
|
294 | |||
295 | def getData(self): |
|
295 | def getData(self): | |
296 | """ |
|
296 | """ | |
297 | Copia el buffer de lectura a la clase "Spectra", |
|
297 | Copia el buffer de lectura a la clase "Spectra", | |
298 | con todos los parametros asociados a este (metadata). cuando no hay datos en el buffer de |
|
298 | con todos los parametros asociados a este (metadata). cuando no hay datos en el buffer de | |
299 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" |
|
299 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" | |
300 |
|
300 | |||
301 | Return: |
|
301 | Return: | |
302 | 0 : Si no hay mas archivos disponibles |
|
302 | 0 : Si no hay mas archivos disponibles | |
303 | 1 : Si hizo una buena copia del buffer |
|
303 | 1 : Si hizo una buena copia del buffer | |
304 |
|
304 | |||
305 | Affected: |
|
305 | Affected: | |
306 | self.dataOutObj |
|
306 | self.dataOutObj | |
307 |
|
307 | |||
308 | self.flagTimeBlock |
|
308 | self.flagTimeBlock | |
309 | self.flagIsNewBlock |
|
309 | self.flagIsNewBlock | |
310 | """ |
|
310 | """ | |
311 |
|
311 | |||
312 | if self.flagNoMoreFiles: return 0 |
|
312 | if self.flagNoMoreFiles: return 0 | |
313 |
|
313 | |||
314 | self.flagTimeBlock = 0 |
|
314 | self.flagTimeBlock = 0 | |
315 | self.flagIsNewBlock = 0 |
|
315 | self.flagIsNewBlock = 0 | |
316 |
|
316 | |||
317 | if self.__hasNotDataInBuffer(): |
|
317 | if self.__hasNotDataInBuffer(): | |
318 |
|
318 | |||
319 | if not( self.readNextBlock() ): |
|
319 | if not( self.readNextBlock() ): | |
320 | return 0 |
|
320 | return 0 | |
321 |
|
321 | |||
322 | # self.updateDataHeader() |
|
322 | # self.updateDataHeader() | |
323 |
|
323 | |||
324 | if self.flagNoMoreFiles == 1: |
|
324 | if self.flagNoMoreFiles == 1: | |
325 | print 'Process finished' |
|
325 | print 'Process finished' | |
326 | return 0 |
|
326 | return 0 | |
327 |
|
327 | |||
328 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) |
|
328 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |
329 |
|
329 | |||
330 | if self.data_dc == None: |
|
330 | if self.data_dc == None: | |
331 | self.dataOutObj.flagNoData = True |
|
331 | self.dataOutObj.flagNoData = True | |
332 | return 0 |
|
332 | return 0 | |
333 |
|
333 | |||
334 |
|
334 | |||
335 | self.dataOutObj.data_spc = self.data_spc |
|
335 | self.dataOutObj.data_spc = self.data_spc | |
336 |
|
336 | |||
337 | self.dataOutObj.data_cspc = self.data_cspc |
|
337 | self.dataOutObj.data_cspc = self.data_cspc | |
338 |
|
338 | |||
339 | self.dataOutObj.data_dc = self.data_dc |
|
339 | self.dataOutObj.data_dc = self.data_dc | |
340 |
|
340 | |||
341 | self.dataOutObj.flagTimeBlock = self.flagTimeBlock |
|
341 | self.dataOutObj.flagTimeBlock = self.flagTimeBlock | |
342 |
|
342 | |||
343 | self.dataOutObj.flagNoData = False |
|
343 | self.dataOutObj.flagNoData = False | |
344 |
|
344 | |||
345 | self.dataOutObj.dtype = self.dtype |
|
345 | self.dataOutObj.dtype = self.dtype | |
346 |
|
346 | |||
347 | self.dataOutObj.nChannels = self.nRdChannels |
|
347 | self.dataOutObj.nChannels = self.nRdChannels | |
348 |
|
348 | |||
349 | self.dataOutObj.nPairs = self.nRdPairs |
|
349 | self.dataOutObj.nPairs = self.nRdPairs | |
350 |
|
350 | |||
351 | self.dataOutObj.pairsList = self.rdPairList |
|
351 | self.dataOutObj.pairsList = self.rdPairList | |
352 |
|
352 | |||
353 | self.dataOutObj.nHeights = self.processingHeaderObj.nHeights |
|
353 | self.dataOutObj.nHeights = self.processingHeaderObj.nHeights | |
354 |
|
354 | |||
355 | self.dataOutObj.nProfiles = self.processingHeaderObj.profilesPerBlock |
|
355 | self.dataOutObj.nProfiles = self.processingHeaderObj.profilesPerBlock | |
356 |
|
356 | |||
357 | self.dataOutObj.nFFTPoints = self.processingHeaderObj.profilesPerBlock |
|
357 | self.dataOutObj.nFFTPoints = self.processingHeaderObj.profilesPerBlock | |
358 |
|
358 | |||
359 | self.dataOutObj.nIncohInt = self.processingHeaderObj.nIncohInt |
|
359 | self.dataOutObj.nIncohInt = self.processingHeaderObj.nIncohInt | |
360 |
|
360 | |||
361 |
|
361 | |||
362 | xf = self.processingHeaderObj.firstHeight + self.processingHeaderObj.nHeights*self.processingHeaderObj.deltaHeight |
|
362 | xf = self.processingHeaderObj.firstHeight + self.processingHeaderObj.nHeights*self.processingHeaderObj.deltaHeight | |
363 |
|
363 | |||
364 | self.dataOutObj.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) |
|
364 | self.dataOutObj.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) | |
365 |
|
365 | |||
366 | self.dataOutObj.channelList = range(self.systemHeaderObj.nChannels) |
|
366 | self.dataOutObj.channelList = range(self.systemHeaderObj.nChannels) | |
367 |
|
367 | |||
368 | self.dataOutObj.channelIndexList = range(self.systemHeaderObj.nChannels) |
|
368 | self.dataOutObj.channelIndexList = range(self.systemHeaderObj.nChannels) | |
369 |
|
369 | |||
370 | self.dataOutObj.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000.#+ self.profileIndex * self.ippSeconds |
|
370 | self.dataOutObj.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000.#+ self.profileIndex * self.ippSeconds | |
371 |
|
371 | |||
372 | self.dataOutObj.ippSeconds = self.ippSeconds |
|
372 | self.dataOutObj.ippSeconds = self.ippSeconds | |
373 |
|
373 | |||
374 | self.dataOutObj.timeInterval = self.ippSeconds * self.processingHeaderObj.nCohInt * self.processingHeaderObj.nIncohInt * self.dataOutObj.nFFTPoints |
|
374 | self.dataOutObj.timeInterval = self.ippSeconds * self.processingHeaderObj.nCohInt * self.processingHeaderObj.nIncohInt * self.dataOutObj.nFFTPoints | |
375 |
|
375 | |||
376 | self.dataOutObj.flagShiftFFT = self.processingHeaderObj.shif_fft |
|
376 | self.dataOutObj.flagShiftFFT = self.processingHeaderObj.shif_fft | |
377 |
|
377 | |||
378 | # self.profileIndex += 1 |
|
378 | # self.profileIndex += 1 | |
379 |
|
379 | |||
380 | self.dataOutObj.systemHeaderObj = self.systemHeaderObj.copy() |
|
380 | self.dataOutObj.systemHeaderObj = self.systemHeaderObj.copy() | |
381 |
|
381 | |||
382 | self.dataOutObj.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
382 | self.dataOutObj.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
383 |
|
383 | |||
384 | return self.dataOutObj.data_spc |
|
384 | return self.dataOutObj.data_spc | |
385 |
|
385 | |||
386 |
|
386 | |||
387 | class SpectraWriter(JRODataWriter): |
|
387 | class SpectraWriter(JRODataWriter): | |
388 |
|
388 | |||
389 | """ |
|
389 | """ | |
390 | Esta clase permite escribir datos de espectros a archivos procesados (.pdata). La escritura |
|
390 | Esta clase permite escribir datos de espectros a archivos procesados (.pdata). La escritura | |
391 | de los datos siempre se realiza por bloques. |
|
391 | de los datos siempre se realiza por bloques. | |
392 | """ |
|
392 | """ | |
393 |
|
393 | |||
394 | ext = ".pdata" |
|
394 | ext = ".pdata" | |
395 |
|
395 | |||
396 | optchar = "P" |
|
396 | optchar = "P" | |
397 |
|
397 | |||
398 | shape_spc_Buffer = None |
|
398 | shape_spc_Buffer = None | |
399 |
|
399 | |||
400 | shape_cspc_Buffer = None |
|
400 | shape_cspc_Buffer = None | |
401 |
|
401 | |||
402 | shape_dc_Buffer = None |
|
402 | shape_dc_Buffer = None | |
403 |
|
403 | |||
404 | data_spc = None |
|
404 | data_spc = None | |
405 |
|
405 | |||
406 | data_cspc = None |
|
406 | data_cspc = None | |
407 |
|
407 | |||
408 | data_dc = None |
|
408 | data_dc = None | |
409 |
|
409 | |||
410 | wrPairList = [] |
|
410 | wrPairList = [] | |
411 |
|
411 | |||
412 | nWrPairs = 0 |
|
412 | nWrPairs = 0 | |
413 |
|
413 | |||
414 | nWrChannels = 0 |
|
414 | nWrChannels = 0 | |
415 |
|
415 | |||
416 | # dataOutObj = None |
|
416 | # dataOutObj = None | |
417 |
|
417 | |||
418 | def __init__(self, dataOutObj=None): |
|
418 | def __init__(self, dataOutObj=None): | |
419 | """ |
|
419 | """ | |
420 | Inicializador de la clase SpectraWriter para la escritura de datos de espectros. |
|
420 | Inicializador de la clase SpectraWriter para la escritura de datos de espectros. | |
421 |
|
421 | |||
422 | Affected: |
|
422 | Affected: | |
423 | self.dataOutObj |
|
423 | self.dataOutObj | |
424 | self.basicHeaderObj |
|
424 | self.basicHeaderObj | |
425 | self.systemHeaderObj |
|
425 | self.systemHeaderObj | |
426 | self.radarControllerHeaderObj |
|
426 | self.radarControllerHeaderObj | |
427 | self.processingHeaderObj |
|
427 | self.processingHeaderObj | |
428 |
|
428 | |||
429 | Return: None |
|
429 | Return: None | |
430 | """ |
|
430 | """ | |
431 | if dataOutObj == None: |
|
431 | if dataOutObj == None: | |
432 | dataOutObj = Spectra() |
|
432 | dataOutObj = Spectra() | |
433 |
|
433 | |||
434 | if not( isinstance(dataOutObj, Spectra) ): |
|
434 | if not( isinstance(dataOutObj, Spectra) ): | |
435 | raise ValueError, "in SpectraReader, dataOutObj must be an Spectra class object" |
|
435 | raise ValueError, "in SpectraReader, dataOutObj must be an Spectra class object" | |
436 |
|
436 | |||
437 | self.dataOutObj = dataOutObj |
|
437 | self.dataOutObj = dataOutObj | |
438 |
|
438 | |||
439 | self.nTotalBlocks = 0 |
|
439 | self.nTotalBlocks = 0 | |
440 |
|
440 | |||
441 | self.nWrChannels = self.dataOutObj.nChannels |
|
441 | self.nWrChannels = self.dataOutObj.nChannels | |
442 |
|
442 | |||
443 | # if len(pairList) > 0: |
|
443 | # if len(pairList) > 0: | |
444 | # self.wrPairList = pairList |
|
444 | # self.wrPairList = pairList | |
445 | # |
|
445 | # | |
446 | # self.nWrPairs = len(pairList) |
|
446 | # self.nWrPairs = len(pairList) | |
447 |
|
447 | |||
448 | self.wrPairList = self.dataOutObj.pairsList |
|
448 | self.wrPairList = self.dataOutObj.pairsList | |
449 |
|
449 | |||
450 | self.nWrPairs = self.dataOutObj.nPairs |
|
450 | self.nWrPairs = self.dataOutObj.nPairs | |
451 |
|
451 | |||
452 |
|
452 | |||
453 |
|
453 | |||
454 |
|
454 | |||
455 |
|
455 | |||
456 | # self.data_spc = None |
|
456 | # self.data_spc = None | |
457 | # self.data_cspc = None |
|
457 | # self.data_cspc = None | |
458 | # self.data_dc = None |
|
458 | # self.data_dc = None | |
459 |
|
459 | |||
460 | # self.fp = None |
|
460 | # self.fp = None | |
461 |
|
461 | |||
462 | # self.flagIsNewFile = 1 |
|
462 | # self.flagIsNewFile = 1 | |
463 | # |
|
463 | # | |
464 | # self.nTotalBlocks = 0 |
|
464 | # self.nTotalBlocks = 0 | |
465 | # |
|
465 | # | |
466 | # self.flagIsNewBlock = 0 |
|
466 | # self.flagIsNewBlock = 0 | |
467 | # |
|
467 | # | |
468 | # self.flagNoMoreFiles = 0 |
|
468 | # self.flagNoMoreFiles = 0 | |
469 | # |
|
469 | # | |
470 | # self.setFile = None |
|
470 | # self.setFile = None | |
471 | # |
|
471 | # | |
472 | # self.dtype = None |
|
472 | # self.dtype = None | |
473 | # |
|
473 | # | |
474 | # self.path = None |
|
474 | # self.path = None | |
475 | # |
|
475 | # | |
476 | # self.noMoreFiles = 0 |
|
476 | # self.noMoreFiles = 0 | |
477 | # |
|
477 | # | |
478 | # self.filename = None |
|
478 | # self.filename = None | |
479 | # |
|
479 | # | |
480 | # self.basicHeaderObj = BasicHeader() |
|
480 | # self.basicHeaderObj = BasicHeader() | |
481 | # |
|
481 | # | |
482 | # self.systemHeaderObj = SystemHeader() |
|
482 | # self.systemHeaderObj = SystemHeader() | |
483 | # |
|
483 | # | |
484 | # self.radarControllerHeaderObj = RadarControllerHeader() |
|
484 | # self.radarControllerHeaderObj = RadarControllerHeader() | |
485 | # |
|
485 | # | |
486 | # self.processingHeaderObj = ProcessingHeader() |
|
486 | # self.processingHeaderObj = ProcessingHeader() | |
487 |
|
487 | |||
488 |
|
488 | |||
489 | def hasAllDataInBuffer(self): |
|
489 | def hasAllDataInBuffer(self): | |
490 | return 1 |
|
490 | return 1 | |
491 |
|
491 | |||
492 |
|
492 | |||
493 | def setBlockDimension(self): |
|
493 | def setBlockDimension(self): | |
494 | """ |
|
494 | """ | |
495 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque |
|
495 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque | |
496 |
|
496 | |||
497 | Affected: |
|
497 | Affected: | |
498 | self.shape_spc_Buffer |
|
498 | self.shape_spc_Buffer | |
499 | self.shape_cspc_Buffer |
|
499 | self.shape_cspc_Buffer | |
500 | self.shape_dc_Buffer |
|
500 | self.shape_dc_Buffer | |
501 |
|
501 | |||
502 | Return: None |
|
502 | Return: None | |
503 | """ |
|
503 | """ | |
504 | self.shape_spc_Buffer = (self.dataOutObj.nChannels, |
|
504 | self.shape_spc_Buffer = (self.dataOutObj.nChannels, | |
505 | self.processingHeaderObj.nHeights, |
|
505 | self.processingHeaderObj.nHeights, | |
506 | self.processingHeaderObj.profilesPerBlock) |
|
506 | self.processingHeaderObj.profilesPerBlock) | |
507 |
|
507 | |||
508 | self.shape_cspc_Buffer = (self.dataOutObj.nPairs, |
|
508 | self.shape_cspc_Buffer = (self.dataOutObj.nPairs, | |
509 | self.processingHeaderObj.nHeights, |
|
509 | self.processingHeaderObj.nHeights, | |
510 | self.processingHeaderObj.profilesPerBlock) |
|
510 | self.processingHeaderObj.profilesPerBlock) | |
511 |
|
511 | |||
512 | self.shape_dc_Buffer = (self.dataOutObj.nChannels, |
|
512 | self.shape_dc_Buffer = (self.dataOutObj.nChannels, | |
513 | self.processingHeaderObj.nHeights) |
|
513 | self.processingHeaderObj.nHeights) | |
514 |
|
514 | |||
515 |
|
515 | |||
516 | def writeBlock(self): |
|
516 | def writeBlock(self): | |
517 | """ |
|
517 | """ | |
518 | Escribe el buffer en el file designado |
|
518 | Escribe el buffer en el file designado | |
519 |
|
519 | |||
520 | Affected: |
|
520 | Affected: | |
521 | self.data_spc |
|
521 | self.data_spc | |
522 | self.data_cspc |
|
522 | self.data_cspc | |
523 | self.data_dc |
|
523 | self.data_dc | |
524 | self.flagIsNewFile |
|
524 | self.flagIsNewFile | |
525 | self.flagIsNewBlock |
|
525 | self.flagIsNewBlock | |
526 | self.nTotalBlocks |
|
526 | self.nTotalBlocks | |
527 | self.nWriteBlocks |
|
527 | self.nWriteBlocks | |
528 |
|
528 | |||
529 | Return: None |
|
529 | Return: None | |
530 | """ |
|
530 | """ | |
531 |
|
531 | |||
532 | spc = numpy.transpose( self.data_spc, (0,2,1) ) |
|
532 | spc = numpy.transpose( self.data_spc, (0,2,1) ) | |
533 | if not( self.processingHeaderObj.shif_fft ): |
|
533 | if not( self.processingHeaderObj.shif_fft ): | |
534 | spc = numpy.roll( spc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones |
|
534 | spc = numpy.roll( spc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones | |
535 | data = spc.reshape((-1)) |
|
535 | data = spc.reshape((-1)) | |
536 | data.tofile(self.fp) |
|
536 | data.tofile(self.fp) | |
537 |
|
537 | |||
538 | if self.data_cspc != None: |
|
538 | if self.data_cspc != None: | |
539 | data = numpy.zeros( self.shape_cspc_Buffer, self.dtype ) |
|
539 | data = numpy.zeros( self.shape_cspc_Buffer, self.dtype ) | |
540 | cspc = numpy.transpose( self.data_cspc, (0,2,1) ) |
|
540 | cspc = numpy.transpose( self.data_cspc, (0,2,1) ) | |
541 | if not( self.processingHeaderObj.shif_fft ): |
|
541 | if not( self.processingHeaderObj.shif_fft ): | |
542 | cspc = numpy.roll( cspc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones |
|
542 | cspc = numpy.roll( cspc, self.processingHeaderObj.profilesPerBlock/2, axis=2 ) #desplaza a la derecha en el eje 2 determinadas posiciones | |
543 | data['real'] = cspc.real |
|
543 | data['real'] = cspc.real | |
544 | data['imag'] = cspc.imag |
|
544 | data['imag'] = cspc.imag | |
545 | data = data.reshape((-1)) |
|
545 | data = data.reshape((-1)) | |
546 | data.tofile(self.fp) |
|
546 | data.tofile(self.fp) | |
547 |
|
547 | |||
548 | if self.data_dc != None: |
|
548 | if self.data_dc != None: | |
549 | data = numpy.zeros( self.shape_dc_Buffer, self.dtype ) |
|
549 | data = numpy.zeros( self.shape_dc_Buffer, self.dtype ) | |
550 | dc = self.data_dc |
|
550 | dc = self.data_dc | |
551 | data['real'] = dc.real |
|
551 | data['real'] = dc.real | |
552 | data['imag'] = dc.imag |
|
552 | data['imag'] = dc.imag | |
553 | data = data.reshape((-1)) |
|
553 | data = data.reshape((-1)) | |
554 | data.tofile(self.fp) |
|
554 | data.tofile(self.fp) | |
555 |
|
555 | |||
556 | self.data_spc.fill(0) |
|
556 | self.data_spc.fill(0) | |
557 | self.data_dc.fill(0) |
|
557 | self.data_dc.fill(0) | |
558 | if self.data_cspc != None: |
|
558 | if self.data_cspc != None: | |
559 | self.data_cspc.fill(0) |
|
559 | self.data_cspc.fill(0) | |
560 |
|
560 | |||
561 | self.flagIsNewFile = 0 |
|
561 | self.flagIsNewFile = 0 | |
562 | self.flagIsNewBlock = 1 |
|
562 | self.flagIsNewBlock = 1 | |
563 | self.nTotalBlocks += 1 |
|
563 | self.nTotalBlocks += 1 | |
564 | self.nWriteBlocks += 1 |
|
564 | self.nWriteBlocks += 1 | |
565 | self.blockIndex += 1 |
|
565 | self.blockIndex += 1 | |
566 |
|
566 | |||
567 |
|
567 | |||
568 | def putData(self): |
|
568 | def putData(self): | |
569 | """ |
|
569 | """ | |
570 | Setea un bloque de datos y luego los escribe en un file |
|
570 | Setea un bloque de datos y luego los escribe en un file | |
571 |
|
571 | |||
572 | Affected: |
|
572 | Affected: | |
573 | self.data_spc |
|
573 | self.data_spc | |
574 | self.data_cspc |
|
574 | self.data_cspc | |
575 | self.data_dc |
|
575 | self.data_dc | |
576 |
|
576 | |||
577 | Return: |
|
577 | Return: | |
578 | 0 : Si no hay data o no hay mas files que puedan escribirse |
|
578 | 0 : Si no hay data o no hay mas files que puedan escribirse | |
579 | 1 : Si se escribio la data de un bloque en un file |
|
579 | 1 : Si se escribio la data de un bloque en un file | |
580 | """ |
|
580 | """ | |
581 | self.flagIsNewBlock = 0 |
|
581 | self.flagIsNewBlock = 0 | |
582 |
|
582 | |||
583 | if self.dataOutObj.flagNoData: |
|
583 | if self.dataOutObj.flagNoData: | |
584 | return 0 |
|
584 | return 0 | |
585 |
|
585 | |||
586 | if self.dataOutObj.flagTimeBlock: |
|
586 | if self.dataOutObj.flagTimeBlock: | |
587 | self.data_spc.fill(0) |
|
587 | self.data_spc.fill(0) | |
588 | self.data_cspc.fill(0) |
|
588 | self.data_cspc.fill(0) | |
589 | self.data_dc.fill(0) |
|
589 | self.data_dc.fill(0) | |
590 | self.setNextFile() |
|
590 | self.setNextFile() | |
591 |
|
591 | |||
592 | if self.flagIsNewFile == 0: |
|
592 | if self.flagIsNewFile == 0: | |
593 | self.getBasicHeader() |
|
593 | self.getBasicHeader() | |
594 |
|
594 | |||
595 | self.data_spc = self.dataOutObj.data_spc |
|
595 | self.data_spc = self.dataOutObj.data_spc | |
596 | self.data_cspc = self.dataOutObj.data_cspc |
|
596 | self.data_cspc = self.dataOutObj.data_cspc | |
597 | self.data_dc = self.dataOutObj.data_dc |
|
597 | self.data_dc = self.dataOutObj.data_dc | |
598 |
|
598 | |||
599 | # #self.processingHeaderObj.dataBlocksPerFile) |
|
599 | # #self.processingHeaderObj.dataBlocksPerFile) | |
600 | if self.hasAllDataInBuffer(): |
|
600 | if self.hasAllDataInBuffer(): | |
601 | # self.getDataHeader() |
|
601 | # self.getDataHeader() | |
602 | self.writeNextBlock() |
|
602 | self.writeNextBlock() | |
603 |
|
603 | |||
604 | if self.flagNoMoreFiles: |
|
604 | if self.flagNoMoreFiles: | |
605 | #print 'Process finished' |
|
605 | #print 'Process finished' | |
606 | return 0 |
|
606 | return 0 | |
607 |
|
607 | |||
608 | return 1 |
|
608 | return 1 | |
609 |
|
609 | |||
610 |
|
610 | |||
611 | def __getProcessFlags(self): |
|
611 | def __getProcessFlags(self): | |
612 |
|
612 | |||
613 | processFlags = 0 |
|
613 | processFlags = 0 | |
614 |
|
614 | |||
615 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
615 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
616 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
616 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
617 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
617 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
618 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
618 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
619 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
619 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
620 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
620 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
621 |
|
621 | |||
622 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
622 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
623 |
|
623 | |||
624 |
|
624 | |||
625 |
|
625 | |||
626 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, |
|
626 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, | |
627 | PROCFLAG.DATATYPE_SHORT, |
|
627 | PROCFLAG.DATATYPE_SHORT, | |
628 | PROCFLAG.DATATYPE_LONG, |
|
628 | PROCFLAG.DATATYPE_LONG, | |
629 | PROCFLAG.DATATYPE_INT64, |
|
629 | PROCFLAG.DATATYPE_INT64, | |
630 | PROCFLAG.DATATYPE_FLOAT, |
|
630 | PROCFLAG.DATATYPE_FLOAT, | |
631 | PROCFLAG.DATATYPE_DOUBLE] |
|
631 | PROCFLAG.DATATYPE_DOUBLE] | |
632 |
|
632 | |||
633 |
|
633 | |||
634 | for index in range(len(dtypeList)): |
|
634 | for index in range(len(dtypeList)): | |
635 | if self.dataOutObj.dtype == dtypeList[index]: |
|
635 | if self.dataOutObj.dtype == dtypeList[index]: | |
636 | dtypeValue = datatypeValueList[index] |
|
636 | dtypeValue = datatypeValueList[index] | |
637 | break |
|
637 | break | |
638 |
|
638 | |||
639 | processFlags += dtypeValue |
|
639 | processFlags += dtypeValue | |
640 |
|
640 | |||
641 | if self.dataOutObj.flagDecodeData: |
|
641 | if self.dataOutObj.flagDecodeData: | |
642 | processFlags += PROCFLAG.DECODE_DATA |
|
642 | processFlags += PROCFLAG.DECODE_DATA | |
643 |
|
643 | |||
644 | if self.dataOutObj.flagDeflipData: |
|
644 | if self.dataOutObj.flagDeflipData: | |
645 | processFlags += PROCFLAG.DEFLIP_DATA |
|
645 | processFlags += PROCFLAG.DEFLIP_DATA | |
646 |
|
646 | |||
647 | if self.dataOutObj.code != None: |
|
647 | if self.dataOutObj.code != None: | |
648 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE |
|
648 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE | |
649 |
|
649 | |||
650 | if self.dataOutObj.nIncohInt > 1: |
|
650 | if self.dataOutObj.nIncohInt > 1: | |
651 | processFlags += PROCFLAG.INCOHERENT_INTEGRATION |
|
651 | processFlags += PROCFLAG.INCOHERENT_INTEGRATION | |
652 |
|
652 | |||
653 | if self.dataOutObj.data_dc != None: |
|
653 | if self.dataOutObj.data_dc != None: | |
654 | processFlags += PROCFLAG.SAVE_CHANNELS_DC |
|
654 | processFlags += PROCFLAG.SAVE_CHANNELS_DC | |
655 |
|
655 | |||
656 | return processFlags |
|
656 | return processFlags | |
657 |
|
657 | |||
658 |
|
658 | |||
659 | def __getBlockSize(self): |
|
659 | def __getBlockSize(self): | |
660 | ''' |
|
660 | ''' | |
661 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Spectra |
|
661 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Spectra | |
662 | ''' |
|
662 | ''' | |
663 |
|
663 | |||
664 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
664 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
665 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
665 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
666 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
666 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
667 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
667 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
668 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
668 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
669 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
669 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
670 |
|
670 | |||
671 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
671 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
672 | datatypeValueList = [1,2,4,8,4,8] |
|
672 | datatypeValueList = [1,2,4,8,4,8] | |
673 | for index in range(len(dtypeList)): |
|
673 | for index in range(len(dtypeList)): | |
674 | if self.dataOutObj.dtype == dtypeList[index]: |
|
674 | if self.dataOutObj.dtype == dtypeList[index]: | |
675 | datatypeValue = datatypeValueList[index] |
|
675 | datatypeValue = datatypeValueList[index] | |
676 | break |
|
676 | break | |
677 |
|
677 | |||
678 |
|
678 | |||
679 | pts2write = self.dataOutObj.nHeights * self.dataOutObj.nFFTPoints |
|
679 | pts2write = self.dataOutObj.nHeights * self.dataOutObj.nFFTPoints | |
680 |
|
680 | |||
681 | pts2write_SelfSpectra = int(self.nWrChannels * pts2write) |
|
681 | pts2write_SelfSpectra = int(self.nWrChannels * pts2write) | |
682 | blocksize = (pts2write_SelfSpectra*datatypeValue) |
|
682 | blocksize = (pts2write_SelfSpectra*datatypeValue) | |
683 |
|
683 | |||
684 | if self.dataOutObj.data_cspc != None: |
|
684 | if self.dataOutObj.data_cspc != None: | |
685 | pts2write_CrossSpectra = int(self.nWrPairs * pts2write) |
|
685 | pts2write_CrossSpectra = int(self.nWrPairs * pts2write) | |
686 | blocksize += (pts2write_CrossSpectra*datatypeValue*2) |
|
686 | blocksize += (pts2write_CrossSpectra*datatypeValue*2) | |
687 |
|
687 | |||
688 | if self.dataOutObj.data_dc != None: |
|
688 | if self.dataOutObj.data_dc != None: | |
689 | pts2write_DCchannels = int(self.nWrChannels * self.dataOutObj.nHeights) |
|
689 | pts2write_DCchannels = int(self.nWrChannels * self.dataOutObj.nHeights) | |
690 | blocksize += (pts2write_DCchannels*datatypeValue*2) |
|
690 | blocksize += (pts2write_DCchannels*datatypeValue*2) | |
691 |
|
691 | |||
692 | blocksize = blocksize #* datatypeValue * 2 #CORREGIR ESTO |
|
692 | blocksize = blocksize #* datatypeValue * 2 #CORREGIR ESTO | |
693 |
|
693 | |||
694 | return blocksize |
|
694 | return blocksize | |
695 |
|
695 | |||
696 |
|
696 | |||
697 | def getBasicHeader(self): |
|
697 | def getBasicHeader(self): | |
698 | self.basicHeaderObj.size = self.basicHeaderSize #bytes |
|
698 | self.basicHeaderObj.size = self.basicHeaderSize #bytes | |
699 | self.basicHeaderObj.version = self.versionFile |
|
699 | self.basicHeaderObj.version = self.versionFile | |
700 | self.basicHeaderObj.dataBlock = self.nTotalBlocks |
|
700 | self.basicHeaderObj.dataBlock = self.nTotalBlocks | |
701 |
|
701 | |||
702 | utc = numpy.floor(self.dataOutObj.utctime) |
|
702 | utc = numpy.floor(self.dataOutObj.utctime) | |
703 | milisecond = (self.dataOutObj.utctime - utc)* 1000.0 |
|
703 | milisecond = (self.dataOutObj.utctime - utc)* 1000.0 | |
704 |
|
704 | |||
705 | self.basicHeaderObj.utc = utc |
|
705 | self.basicHeaderObj.utc = utc | |
706 | self.basicHeaderObj.miliSecond = milisecond |
|
706 | self.basicHeaderObj.miliSecond = milisecond | |
707 | self.basicHeaderObj.timeZone = 0 |
|
707 | self.basicHeaderObj.timeZone = 0 | |
708 | self.basicHeaderObj.dstFlag = 0 |
|
708 | self.basicHeaderObj.dstFlag = 0 | |
709 | self.basicHeaderObj.errorCount = 0 |
|
709 | self.basicHeaderObj.errorCount = 0 | |
710 |
|
710 | |||
711 | def getDataHeader(self): |
|
711 | def getDataHeader(self): | |
712 |
|
712 | |||
713 | """ |
|
713 | """ | |
714 | Obtiene una copia del First Header |
|
714 | Obtiene una copia del First Header | |
715 |
|
715 | |||
716 | Affected: |
|
716 | Affected: | |
717 | self.systemHeaderObj |
|
717 | self.systemHeaderObj | |
718 | self.radarControllerHeaderObj |
|
718 | self.radarControllerHeaderObj | |
719 | self.dtype |
|
719 | self.dtype | |
720 |
|
720 | |||
721 | Return: |
|
721 | Return: | |
722 | None |
|
722 | None | |
723 | """ |
|
723 | """ | |
724 |
|
724 | |||
725 | self.systemHeaderObj = self.dataOutObj.systemHeaderObj.copy() |
|
725 | self.systemHeaderObj = self.dataOutObj.systemHeaderObj.copy() | |
726 | self.systemHeaderObj.nChannels = self.dataOutObj.nChannels |
|
726 | self.systemHeaderObj.nChannels = self.dataOutObj.nChannels | |
727 | self.radarControllerHeaderObj = self.dataOutObj.radarControllerHeaderObj.copy() |
|
727 | self.radarControllerHeaderObj = self.dataOutObj.radarControllerHeaderObj.copy() | |
728 |
|
728 | |||
729 | self.getBasicHeader() |
|
729 | self.getBasicHeader() | |
730 |
|
730 | |||
731 | processingHeaderSize = 40 # bytes |
|
731 | processingHeaderSize = 40 # bytes | |
732 | self.processingHeaderObj.dtype = 0 # Voltage |
|
732 | self.processingHeaderObj.dtype = 0 # Voltage | |
733 | self.processingHeaderObj.blockSize = self.__getBlockSize() |
|
733 | self.processingHeaderObj.blockSize = self.__getBlockSize() | |
734 | self.processingHeaderObj.profilesPerBlock = self.dataOutObj.nFFTPoints |
|
734 | self.processingHeaderObj.profilesPerBlock = self.dataOutObj.nFFTPoints | |
735 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
735 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile | |
736 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOutObj.processingHeaderObj.nWindows |
|
736 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOutObj.processingHeaderObj.nWindows | |
737 | self.processingHeaderObj.processFlags = self.__getProcessFlags() |
|
737 | self.processingHeaderObj.processFlags = self.__getProcessFlags() | |
738 |
self.processingHeaderObj.nCohInt = |
|
738 | self.processingHeaderObj.nCohInt = self.dataOutObj.nCohInt# Se requiere para determinar el valor de timeInterval | |
739 | self.processingHeaderObj.nIncohInt = self.dataOutObj.nIncohInt |
|
739 | self.processingHeaderObj.nIncohInt = self.dataOutObj.nIncohInt | |
740 | self.processingHeaderObj.totalSpectra = self.dataOutObj.nPairs + self.dataOutObj.nChannels |
|
740 | self.processingHeaderObj.totalSpectra = self.dataOutObj.nPairs + self.dataOutObj.nChannels | |
741 |
|
741 | |||
742 | if self.processingHeaderObj.totalSpectra > 0: |
|
742 | if self.processingHeaderObj.totalSpectra > 0: | |
743 | channelList = [] |
|
743 | channelList = [] | |
744 | for channel in range(self.dataOutObj.nChannels): |
|
744 | for channel in range(self.dataOutObj.nChannels): | |
745 | channelList.append(channel) |
|
745 | channelList.append(channel) | |
746 | channelList.append(channel) |
|
746 | channelList.append(channel) | |
747 |
|
747 | |||
748 | pairsList = [] |
|
748 | pairsList = [] | |
749 | for pair in self.dataOutObj.pairsList: |
|
749 | for pair in self.dataOutObj.pairsList: | |
750 | pairsList.append(pair[0]) |
|
750 | pairsList.append(pair[0]) | |
751 | pairsList.append(pair[1]) |
|
751 | pairsList.append(pair[1]) | |
752 | spectraComb = channelList + pairsList |
|
752 | spectraComb = channelList + pairsList | |
753 | spectraComb = numpy.array(spectraComb,dtype="u1") |
|
753 | spectraComb = numpy.array(spectraComb,dtype="u1") | |
754 | self.processingHeaderObj.spectraComb = spectraComb |
|
754 | self.processingHeaderObj.spectraComb = spectraComb | |
755 | sizeOfSpcComb = len(spectraComb) |
|
755 | sizeOfSpcComb = len(spectraComb) | |
756 | processingHeaderSize += sizeOfSpcComb |
|
756 | processingHeaderSize += sizeOfSpcComb | |
757 |
|
757 | |||
758 | if self.dataOutObj.code != None: |
|
758 | if self.dataOutObj.code != None: | |
759 | self.processingHeaderObj.code = self.dataOutObj.code |
|
759 | self.processingHeaderObj.code = self.dataOutObj.code | |
760 | self.processingHeaderObj.nCode = self.dataOutObj.nCode |
|
760 | self.processingHeaderObj.nCode = self.dataOutObj.nCode | |
761 | self.processingHeaderObj.nBaud = self.dataOutObj.nBaud |
|
761 | self.processingHeaderObj.nBaud = self.dataOutObj.nBaud | |
762 | nCodeSize = 4 # bytes |
|
762 | nCodeSize = 4 # bytes | |
763 | nBaudSize = 4 # bytes |
|
763 | nBaudSize = 4 # bytes | |
764 | codeSize = 4 # bytes |
|
764 | codeSize = 4 # bytes | |
765 | sizeOfCode = int(nCodeSize + nBaudSize + codeSize * self.dataOutObj.nCode * self.dataOutObj.nBaud) |
|
765 | sizeOfCode = int(nCodeSize + nBaudSize + codeSize * self.dataOutObj.nCode * self.dataOutObj.nBaud) | |
766 | processingHeaderSize += sizeOfCode |
|
766 | processingHeaderSize += sizeOfCode | |
767 |
|
767 | |||
768 | if self.processingHeaderObj.nWindows != 0: |
|
768 | if self.processingHeaderObj.nWindows != 0: | |
769 | self.processingHeaderObj.firstHeight = self.dataOutObj.heightList[0] |
|
769 | self.processingHeaderObj.firstHeight = self.dataOutObj.heightList[0] | |
770 | self.processingHeaderObj.deltaHeight = self.dataOutObj.heightList[1] - self.dataOutObj.heightList[0] |
|
770 | self.processingHeaderObj.deltaHeight = self.dataOutObj.heightList[1] - self.dataOutObj.heightList[0] | |
771 | self.processingHeaderObj.nHeights = self.dataOutObj.nHeights |
|
771 | self.processingHeaderObj.nHeights = self.dataOutObj.nHeights | |
772 | self.processingHeaderObj.samplesWin = self.dataOutObj.nHeights |
|
772 | self.processingHeaderObj.samplesWin = self.dataOutObj.nHeights | |
773 | sizeOfFirstHeight = 4 |
|
773 | sizeOfFirstHeight = 4 | |
774 | sizeOfdeltaHeight = 4 |
|
774 | sizeOfdeltaHeight = 4 | |
775 | sizeOfnHeights = 4 |
|
775 | sizeOfnHeights = 4 | |
776 | sizeOfWindows = (sizeOfFirstHeight + sizeOfdeltaHeight + sizeOfnHeights)*self.processingHeaderObj.nWindows |
|
776 | sizeOfWindows = (sizeOfFirstHeight + sizeOfdeltaHeight + sizeOfnHeights)*self.processingHeaderObj.nWindows | |
777 | processingHeaderSize += sizeOfWindows |
|
777 | processingHeaderSize += sizeOfWindows | |
778 |
|
778 | |||
779 | self.processingHeaderObj.size = processingHeaderSize |
|
779 | self.processingHeaderObj.size = processingHeaderSize | |
780 |
|
780 | |||
781 | No newline at end of file |
|
781 |
@@ -1,698 +1,737 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
9 | import time |
|
9 | import time | |
10 | import datetime |
|
10 | import datetime | |
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 Data.JROData import Spectra, SpectraHeis |
|
14 | from Data.JROData import Spectra, SpectraHeis | |
15 | from IO.SpectraIO import SpectraWriter |
|
15 | from IO.SpectraIO import SpectraWriter | |
16 | from Graphics.schainPlotTypes import ScopeFigure, SpcFigure |
|
16 | from Graphics.schainPlotTypes import ScopeFigure, SpcFigure, RTIFigure | |
17 | #from JRONoise import Noise |
|
17 | #from JRONoise import Noise | |
18 |
|
18 | |||
19 | class SpectraProcessor: |
|
19 | class SpectraProcessor: | |
20 | ''' |
|
20 | ''' | |
21 | classdocs |
|
21 | classdocs | |
22 | ''' |
|
22 | ''' | |
23 |
|
23 | |||
24 | dataInObj = None |
|
24 | dataInObj = None | |
25 |
|
25 | |||
26 | dataOutObj = None |
|
26 | dataOutObj = None | |
27 |
|
27 | |||
28 | noiseObj = None |
|
28 | noiseObj = None | |
29 |
|
29 | |||
30 | integratorObjList = [] |
|
30 | integratorObjList = [] | |
31 |
|
31 | |||
32 | writerObjList = [] |
|
32 | writerObjList = [] | |
33 |
|
33 | |||
34 | integratorObjIndex = None |
|
34 | integratorObjIndex = None | |
35 |
|
35 | |||
36 | writerObjIndex = None |
|
36 | writerObjIndex = None | |
37 |
|
37 | |||
38 | profIndex = 0 # Se emplea cuando el objeto de entrada es un Voltage |
|
38 | profIndex = 0 # Se emplea cuando el objeto de entrada es un Voltage | |
39 |
|
39 | |||
|
40 | firstdatatime = None | |||
40 |
|
41 | |||
41 | def __init__(self): |
|
42 | def __init__(self): | |
42 | ''' |
|
43 | ''' | |
43 | Constructor |
|
44 | Constructor | |
44 | ''' |
|
45 | ''' | |
45 |
|
46 | |||
46 | self.integratorObjIndex = None |
|
47 | self.integratorObjIndex = None | |
47 | self.writerObjIndex = None |
|
48 | self.writerObjIndex = None | |
48 | self.plotObjIndex = None |
|
49 | self.plotObjIndex = None | |
49 | self.integratorOst = [] |
|
50 | self.integratorOst = [] | |
50 | self.plotObjList = [] |
|
51 | self.plotObjList = [] | |
51 | self.noiseObj = [] |
|
52 | self.noiseObj = [] | |
52 | self.writerObjList = [] |
|
53 | self.writerObjList = [] | |
53 | self.buffer = None |
|
54 | self.buffer = None | |
|
55 | self.firstdatatime = None | |||
54 | self.profIndex = 0 |
|
56 | self.profIndex = 0 | |
55 |
|
57 | |||
56 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairsList=None): |
|
58 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairsList=None): | |
57 |
|
59 | |||
58 | if dataInObj == None: |
|
60 | if dataInObj == None: | |
59 | raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" |
|
61 | raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" | |
60 |
|
62 | |||
61 | if dataInObj.type == "Voltage": |
|
63 | if dataInObj.type == "Voltage": | |
62 | if nFFTPoints == None: |
|
64 | if nFFTPoints == None: | |
63 | raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable" |
|
65 | raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable" | |
64 |
|
66 | |||
65 |
|
67 | |||
66 |
|
68 | |||
67 | if dataInObj.type == "Spectra": |
|
69 | if dataInObj.type == "Spectra": | |
68 | if nFFTPoints != None: |
|
70 | if nFFTPoints != None: | |
69 | raise ValueError, "The nFFTPoints cannot be selected to this object type" |
|
71 | raise ValueError, "The nFFTPoints cannot be selected to this object type" | |
70 |
|
72 | |||
71 | nFFTPoints = dataInObj.nFFTPoints |
|
73 | nFFTPoints = dataInObj.nFFTPoints | |
72 |
|
74 | |||
73 | if pairsList == None: |
|
75 | if pairsList == None: | |
74 | pairsList = dataInObj.pairsList |
|
76 | pairsList = dataInObj.pairsList | |
75 |
|
77 | |||
76 | if pairsList == None: |
|
78 | if pairsList == None: | |
77 | nPairs = 0 |
|
79 | nPairs = 0 | |
78 | else: |
|
80 | else: | |
79 | nPairs = len(pairsList) |
|
81 | nPairs = len(pairsList) | |
80 |
|
82 | |||
81 | self.dataInObj = dataInObj |
|
83 | self.dataInObj = dataInObj | |
82 |
|
84 | |||
83 | if dataOutObj == None: |
|
85 | if dataOutObj == None: | |
84 | dataOutObj = Spectra() |
|
86 | dataOutObj = Spectra() | |
85 |
|
87 | |||
86 | self.dataOutObj = dataOutObj |
|
88 | self.dataOutObj = dataOutObj | |
87 | self.dataOutObj.nFFTPoints = nFFTPoints |
|
89 | self.dataOutObj.nFFTPoints = nFFTPoints | |
88 | self.dataOutObj.pairsList = pairsList |
|
90 | self.dataOutObj.pairsList = pairsList | |
89 | self.dataOutObj.nPairs = nPairs |
|
91 | self.dataOutObj.nPairs = nPairs | |
90 |
|
92 | |||
91 | return self.dataOutObj |
|
93 | return self.dataOutObj | |
92 |
|
94 | |||
93 | def init(self): |
|
95 | def init(self): | |
94 |
|
96 | |||
95 | self.dataOutObj.flagNoData = True |
|
97 | self.dataOutObj.flagNoData = True | |
96 |
|
98 | |||
97 | if self.dataInObj.flagNoData: |
|
99 | if self.dataInObj.flagNoData: | |
98 | return 0 |
|
100 | return 0 | |
99 |
|
101 | |||
100 | self.integratorObjIndex = 0 |
|
102 | self.integratorObjIndex = 0 | |
101 | self.writerObjIndex = 0 |
|
103 | self.writerObjIndex = 0 | |
102 | self.plotObjIndex = 0 |
|
104 | self.plotObjIndex = 0 | |
103 |
|
105 | |||
104 |
|
106 | |||
105 | if self.dataInObj.type == "Spectra": |
|
107 | if self.dataInObj.type == "Spectra": | |
106 |
|
108 | |||
107 | self.dataOutObj.copy(self.dataInObj) |
|
109 | self.dataOutObj.copy(self.dataInObj) | |
108 | self.dataOutObj.flagNoData = False |
|
110 | self.dataOutObj.flagNoData = False | |
109 | return |
|
111 | return | |
110 |
|
112 | |||
111 | if self.dataInObj.type == "Voltage": |
|
113 | if self.dataInObj.type == "Voltage": | |
112 |
|
114 | |||
113 | if self.buffer == None: |
|
115 | if self.buffer == None: | |
114 | self.buffer = numpy.zeros((self.dataInObj.nChannels, |
|
116 | self.buffer = numpy.zeros((self.dataInObj.nChannels, | |
115 | self.dataOutObj.nFFTPoints, |
|
117 | self.dataOutObj.nFFTPoints, | |
116 | self.dataInObj.nHeights), |
|
118 | self.dataInObj.nHeights), | |
117 | dtype='complex') |
|
119 | dtype='complex') | |
118 |
|
120 | |||
119 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
121 | self.buffer[:,self.profIndex,:] = self.dataInObj.data | |
120 | self.profIndex += 1 |
|
122 | self.profIndex += 1 | |
121 |
|
123 | |||
|
124 | if self.firstdatatime == None: | |||
|
125 | self.firstdatatime = self.dataInObj.utctime | |||
|
126 | ||||
122 | if self.profIndex == self.dataOutObj.nFFTPoints: |
|
127 | if self.profIndex == self.dataOutObj.nFFTPoints: | |
123 |
|
128 | |||
124 | self.__updateObjFromInput() |
|
129 | self.__updateObjFromInput() | |
125 | self.__getFft() |
|
130 | self.__getFft() | |
126 |
|
131 | |||
127 | self.dataOutObj.flagNoData = False |
|
132 | self.dataOutObj.flagNoData = False | |
128 |
|
133 | |||
129 | self.buffer = None |
|
134 | self.buffer = None | |
|
135 | self.firstdatatime = None | |||
130 | self.profIndex = 0 |
|
136 | self.profIndex = 0 | |
131 |
|
137 | |||
132 | return |
|
138 | return | |
133 |
|
139 | |||
134 | #Other kind of data |
|
140 | #Other kind of data | |
135 | raise ValueError, "The type object %(s) is not valid " %(self.dataOutObj.type) |
|
141 | raise ValueError, "The type object %(s) is not valid " %(self.dataOutObj.type) | |
136 |
|
142 | |||
137 | def __getFft(self): |
|
143 | def __getFft(self): | |
138 | """ |
|
144 | """ | |
139 | Convierte valores de Voltaje a Spectra |
|
145 | Convierte valores de Voltaje a Spectra | |
140 |
|
146 | |||
141 | Affected: |
|
147 | Affected: | |
142 | self.dataOutObj.data_spc |
|
148 | self.dataOutObj.data_spc | |
143 | self.dataOutObj.data_cspc |
|
149 | self.dataOutObj.data_cspc | |
144 | self.dataOutObj.data_dc |
|
150 | self.dataOutObj.data_dc | |
145 | self.dataOutObj.heightList |
|
151 | self.dataOutObj.heightList | |
146 | self.dataOutObj.m_BasicHeader |
|
152 | self.dataOutObj.m_BasicHeader | |
147 | self.dataOutObj.m_ProcessingHeader |
|
153 | self.dataOutObj.m_ProcessingHeader | |
148 | self.dataOutObj.radarControllerHeaderObj |
|
154 | self.dataOutObj.radarControllerHeaderObj | |
149 | self.dataOutObj.systemHeaderObj |
|
155 | self.dataOutObj.systemHeaderObj | |
150 | self.profIndex |
|
156 | self.profIndex | |
151 | self.buffer |
|
157 | self.buffer | |
152 | self.dataOutObj.flagNoData |
|
158 | self.dataOutObj.flagNoData | |
153 | self.dataOutObj.dtype |
|
159 | self.dataOutObj.dtype | |
154 | self.dataOutObj.nPairs |
|
160 | self.dataOutObj.nPairs | |
155 | self.dataOutObj.nChannels |
|
161 | self.dataOutObj.nChannels | |
156 | self.dataOutObj.nProfiles |
|
162 | self.dataOutObj.nProfiles | |
157 | self.dataOutObj.systemHeaderObj.numChannels |
|
163 | self.dataOutObj.systemHeaderObj.numChannels | |
158 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
164 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |
159 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock |
|
165 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock | |
160 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
166 | self.dataOutObj.m_ProcessingHeader.numHeights | |
161 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
167 | self.dataOutObj.m_ProcessingHeader.spectraComb | |
162 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
168 | self.dataOutObj.m_ProcessingHeader.shif_fft | |
163 | """ |
|
169 | """ | |
164 |
|
170 | |||
165 | fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
171 | fft_volt = numpy.fft.fft(self.buffer,axis=1) | |
166 | dc = fft_volt[:,0,:] |
|
172 | dc = fft_volt[:,0,:] | |
167 |
|
173 | |||
168 | #calculo de self-spectra |
|
174 | #calculo de self-spectra | |
169 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
175 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
170 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
176 | spc = fft_volt * numpy.conjugate(fft_volt) | |
171 | spc = spc.real |
|
177 | spc = spc.real | |
172 |
|
178 | |||
173 | blocksize = 0 |
|
179 | blocksize = 0 | |
174 | blocksize += dc.size |
|
180 | blocksize += dc.size | |
175 | blocksize += spc.size |
|
181 | blocksize += spc.size | |
176 |
|
182 | |||
177 | cspc = None |
|
183 | cspc = None | |
178 | pairIndex = 0 |
|
184 | pairIndex = 0 | |
179 | if self.dataOutObj.pairsList != None: |
|
185 | if self.dataOutObj.pairsList != None: | |
180 | #calculo de cross-spectra |
|
186 | #calculo de cross-spectra | |
181 | cspc = numpy.zeros((self.dataOutObj.nPairs, self.dataOutObj.nFFTPoints, self.dataOutObj.nHeights), dtype='complex') |
|
187 | cspc = numpy.zeros((self.dataOutObj.nPairs, self.dataOutObj.nFFTPoints, self.dataOutObj.nHeights), dtype='complex') | |
182 | for pair in self.dataOutObj.pairsList: |
|
188 | for pair in self.dataOutObj.pairsList: | |
183 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) |
|
189 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) | |
184 | pairIndex += 1 |
|
190 | pairIndex += 1 | |
185 | blocksize += cspc.size |
|
191 | blocksize += cspc.size | |
186 |
|
192 | |||
187 | self.dataOutObj.data_spc = spc |
|
193 | self.dataOutObj.data_spc = spc | |
188 | self.dataOutObj.data_cspc = cspc |
|
194 | self.dataOutObj.data_cspc = cspc | |
189 | self.dataOutObj.data_dc = dc |
|
195 | self.dataOutObj.data_dc = dc | |
190 | self.dataOutObj.blockSize = blocksize |
|
196 | self.dataOutObj.blockSize = blocksize | |
191 |
|
197 | |||
192 | # self.getNoise() |
|
198 | # self.getNoise() | |
193 |
|
199 | |||
194 | def __updateObjFromInput(self): |
|
200 | def __updateObjFromInput(self): | |
195 |
|
201 | |||
196 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() |
|
202 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() | |
197 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() |
|
203 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() | |
198 | self.dataOutObj.channelList = self.dataInObj.channelList |
|
204 | self.dataOutObj.channelList = self.dataInObj.channelList | |
199 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
205 | self.dataOutObj.heightList = self.dataInObj.heightList | |
200 | self.dataOutObj.dtype = self.dataInObj.dtype |
|
206 | self.dataOutObj.dtype = self.dataInObj.dtype | |
201 | self.dataOutObj.nHeights = self.dataInObj.nHeights |
|
207 | self.dataOutObj.nHeights = self.dataInObj.nHeights | |
202 | self.dataOutObj.nChannels = self.dataInObj.nChannels |
|
208 | self.dataOutObj.nChannels = self.dataInObj.nChannels | |
203 | self.dataOutObj.nBaud = self.dataInObj.nBaud |
|
209 | self.dataOutObj.nBaud = self.dataInObj.nBaud | |
204 | self.dataOutObj.nCode = self.dataInObj.nCode |
|
210 | self.dataOutObj.nCode = self.dataInObj.nCode | |
205 | self.dataOutObj.code = self.dataInObj.code |
|
211 | self.dataOutObj.code = self.dataInObj.code | |
206 | self.dataOutObj.nProfiles = self.dataOutObj.nFFTPoints |
|
212 | self.dataOutObj.nProfiles = self.dataOutObj.nFFTPoints | |
207 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
213 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList | |
208 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock |
|
214 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock | |
209 |
self.dataOutObj.utctime = self.data |
|
215 | self.dataOutObj.utctime = self.firstdatatime | |
210 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada |
|
216 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada | |
211 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip |
|
217 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip | |
212 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT |
|
218 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT | |
|
219 | self.dataOutObj.nCohInt = self.dataInObj.nCohInt | |||
213 | self.dataOutObj.nIncohInt = 1 |
|
220 | self.dataOutObj.nIncohInt = 1 | |
214 | self.dataOutObj.ippSeconds = self.dataInObj.ippSeconds |
|
221 | self.dataOutObj.ippSeconds = self.dataInObj.ippSeconds | |
215 | self.dataOutObj.timeInterval = self.dataInObj.timeInterval |
|
222 | self.dataOutObj.timeInterval = self.dataInObj.timeInterval*self.dataOutObj.nFFTPoints | |
216 |
|
223 | |||
217 | def addWriter(self, wrpath, blocksPerFile): |
|
224 | def addWriter(self, wrpath, blocksPerFile): | |
218 |
|
225 | |||
219 | objWriter = SpectraWriter(self.dataOutObj) |
|
226 | objWriter = SpectraWriter(self.dataOutObj) | |
220 | objWriter.setup(wrpath, blocksPerFile) |
|
227 | objWriter.setup(wrpath, blocksPerFile) | |
221 | self.writerObjList.append(objWriter) |
|
228 | self.writerObjList.append(objWriter) | |
222 |
|
229 | |||
223 | def addIntegrator(self,N,timeInterval): |
|
230 | def addIntegrator(self,N,timeInterval): | |
224 |
|
231 | |||
225 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
232 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
226 | self.integratorObjList.append(objIncohInt) |
|
233 | self.integratorObjList.append(objIncohInt) | |
227 |
|
234 | |||
228 | def addCrossSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
235 | def addCrossSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
229 | crossSpcObj = CrossSpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
236 | crossSpcObj = CrossSpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
230 | self.plotObjList.append(crossSpcObj) |
|
237 | self.plotObjList.append(crossSpcObj) | |
231 |
|
238 | |||
232 | def plotCrossSpc(self, idfigure=None, |
|
239 | def plotCrossSpc(self, idfigure=None, | |
233 | xmin=None, |
|
240 | xmin=None, | |
234 | xmax=None, |
|
241 | xmax=None, | |
235 | ymin=None, |
|
242 | ymin=None, | |
236 | ymax=None, |
|
243 | ymax=None, | |
237 | minvalue=None, |
|
244 | minvalue=None, | |
238 | maxvalue=None, |
|
245 | maxvalue=None, | |
239 | wintitle='', |
|
246 | wintitle='', | |
240 | driver='plplot', |
|
247 | driver='plplot', | |
241 | colormap='br_green', |
|
248 | colormap='br_green', | |
242 | colorbar=True, |
|
249 | colorbar=True, | |
243 | showprofile=False, |
|
250 | showprofile=False, | |
244 | save=False, |
|
251 | save=False, | |
245 | gpath=None, |
|
252 | gpath=None, | |
246 | pairsList = None): |
|
253 | pairsList = None): | |
247 |
|
254 | |||
248 | if self.dataOutObj.flagNoData: |
|
255 | if self.dataOutObj.flagNoData: | |
249 | return 0 |
|
256 | return 0 | |
250 |
|
257 | |||
251 | if pairsList == None: |
|
258 | if pairsList == None: | |
252 | pairsList = self.dataOutObj.pairsList |
|
259 | pairsList = self.dataOutObj.pairsList | |
253 |
|
260 | |||
254 | nframes = len(pairsList) |
|
261 | nframes = len(pairsList) | |
255 |
|
262 | |||
256 | x = numpy.arange(self.dataOutObj.nFFTPoints) |
|
263 | x = numpy.arange(self.dataOutObj.nFFTPoints) | |
257 |
|
264 | |||
258 | y = self.dataOutObj.heightList |
|
265 | y = self.dataOutObj.heightList | |
259 |
|
266 | |||
|
267 | data_spc = self.dataOutObj.data_spc | |||
|
268 | data_cspc = self.dataOutObj.data_cspc | |||
260 |
|
269 | |||
|
270 | data = [] | |||
261 |
|
271 | |||
262 |
|
272 | |||
263 | if len(self.plotObjList) <= self.plotObjIndex: |
|
273 | if len(self.plotObjList) <= self.plotObjIndex: | |
264 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
274 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
265 |
|
275 | |||
|
276 | ||||
|
277 | ||||
|
278 | ||||
|
279 | ||||
266 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
280 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
267 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
281 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
268 | self.plotObjList.append(rtiObj) |
|
282 | self.plotObjList.append(rtiObj) | |
269 |
|
283 | |||
270 | def plotRti(self, idfigure=None, |
|
284 | def plotRti(self, idfigure=None, | |
271 | starttime=None, |
|
285 | starttime=None, | |
272 | endtime=None, |
|
286 | endtime=None, | |
273 | rangemin=None, |
|
287 | rangemin=None, | |
274 | rangemax=None, |
|
288 | rangemax=None, | |
275 | minvalue=None, |
|
289 | minvalue=None, | |
276 | maxvalue=None, |
|
290 | maxvalue=None, | |
277 | wintitle='', |
|
291 | wintitle='', | |
278 | driver='plplot', |
|
292 | driver='plplot', | |
279 | colormap='br_greeen', |
|
293 | colormap='br_greeen', | |
280 | colorbar=True, |
|
294 | colorbar=True, | |
281 | showprofile=False, |
|
295 | showprofile=False, | |
282 | xrangestep=None, |
|
296 | xrangestep=None, | |
283 | save=False, |
|
297 | save=False, | |
284 | gpath=None, |
|
298 | gpath=None, | |
285 | ratio=1, |
|
299 | ratio=1, | |
286 | channelList=None): |
|
300 | channelList=None): | |
287 |
|
301 | |||
288 | if self.dataOutObj.flagNoData: |
|
302 | if self.dataOutObj.flagNoData: | |
289 | return 0 |
|
303 | return 0 | |
290 |
|
304 | |||
291 | if channelList == None: |
|
305 | if channelList == None: | |
292 | channelList = self.dataOutObj.channelList |
|
306 | channelList = self.dataOutObj.channelList | |
293 |
|
307 | |||
294 | nframes = len(channelList) |
|
308 | nframes = len(channelList) | |
295 |
|
309 | |||
296 | if len(self.plotObjList) <= self.plotObjIndex: |
|
310 | if len(self.plotObjList) <= self.plotObjIndex: | |
297 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
311 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
298 |
|
312 | |||
299 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) |
|
313 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) | |
300 |
|
314 | |||
|
315 | data = numpy.average(data, axis=1) | |||
|
316 | ||||
301 | currenttime = self.dataOutObj.utctime - time.timezone |
|
317 | currenttime = self.dataOutObj.utctime - time.timezone | |
302 |
|
318 | |||
303 | range = self.dataOutObj.heightList |
|
319 | range = self.dataOutObj.heightList | |
304 |
|
320 | |||
305 |
|
321 | |||
306 | figuretitle = "RTI Plot for Spectra Data" #+ date |
|
322 | figuretitle = "RTI Plot for Spectra Data" #+ date | |
307 |
|
323 | |||
308 | cleardata = False |
|
324 | cleardata = False | |
309 |
|
325 | |||
310 | deltax = self.dataOutObj.timeInterval |
|
326 | deltax = self.dataOutObj.timeInterval | |
311 |
|
327 | |||
312 | plotObj = self.plotObjList[self.plotObjIndex] |
|
328 | plotObj = self.plotObjList[self.plotObjIndex] | |
313 |
|
329 | |||
314 |
|
330 | plotObj.plotPcolor(data=data, | ||
|
331 | x=currenttime, | |||
|
332 | y=range, | |||
|
333 | channelList=channelList, | |||
|
334 | xmin=starttime, | |||
|
335 | xmax=endtime, | |||
|
336 | ymin=rangemin, | |||
|
337 | ymax=rangemax, | |||
|
338 | minvalue=minvalue, | |||
|
339 | maxvalue=maxvalue, | |||
|
340 | figuretitle=figuretitle, | |||
|
341 | xrangestep=xrangestep, | |||
|
342 | deltax=deltax, | |||
|
343 | save=save, | |||
|
344 | gpath=gpath, | |||
|
345 | ratio=ratio, | |||
|
346 | cleardata=cleardata | |||
|
347 | ) | |||
315 |
|
348 | |||
316 |
|
349 | |||
317 |
|
350 | |||
318 | self.plotObjIndex += 1 |
|
351 | self.plotObjIndex += 1 | |
319 |
|
352 | |||
320 |
|
353 | |||
321 |
|
354 | |||
322 |
|
355 | |||
323 |
|
356 | |||
324 |
|
357 | |||
325 |
|
358 | |||
326 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
359 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
327 |
|
360 | |||
328 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
361 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
329 | self.plotObjList.append(spcObj) |
|
362 | self.plotObjList.append(spcObj) | |
330 |
|
363 | |||
331 | def plotSpc(self, idfigure=None, |
|
364 | def plotSpc(self, idfigure=None, | |
332 | xmin=None, |
|
365 | xmin=None, | |
333 | xmax=None, |
|
366 | xmax=None, | |
334 | ymin=None, |
|
367 | ymin=None, | |
335 | ymax=None, |
|
368 | ymax=None, | |
336 | minvalue=None, |
|
369 | minvalue=None, | |
337 | maxvalue=None, |
|
370 | maxvalue=None, | |
338 | wintitle='', |
|
371 | wintitle='', | |
339 | driver='plplot', |
|
372 | driver='plplot', | |
340 | colormap='br_green', |
|
373 | colormap='br_green', | |
341 | colorbar=True, |
|
374 | colorbar=True, | |
342 | showprofile=False, |
|
375 | showprofile=False, | |
343 | save=False, |
|
376 | save=False, | |
344 | gpath=None, |
|
377 | gpath=None, | |
345 | ratio=1, |
|
378 | ratio=1, | |
346 | channelList=None): |
|
379 | channelList=None): | |
347 |
|
380 | |||
348 | if self.dataOutObj.flagNoData: |
|
381 | if self.dataOutObj.flagNoData: | |
349 | return 0 |
|
382 | return 0 | |
350 |
|
383 | |||
351 | if channelList == None: |
|
384 | if channelList == None: | |
352 | channelList = self.dataOutObj.channelList |
|
385 | channelList = self.dataOutObj.channelList | |
353 |
|
386 | |||
354 | nframes = len(channelList) |
|
387 | nframes = len(channelList) | |
355 |
|
388 | |||
356 | if len(self.plotObjList) <= self.plotObjIndex: |
|
389 | if len(self.plotObjList) <= self.plotObjIndex: | |
357 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
390 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
358 |
|
391 | |||
359 | x = numpy.arange(self.dataOutObj.nFFTPoints) |
|
392 | x = numpy.arange(self.dataOutObj.nFFTPoints) | |
360 |
|
393 | |||
361 | y = self.dataOutObj.heightList |
|
394 | y = self.dataOutObj.heightList | |
362 |
|
395 | |||
363 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) |
|
396 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) | |
364 | # noisedB = 10.*numpy.log10(noise) |
|
397 | # noisedB = 10.*numpy.log10(noise) | |
365 | noisedB = numpy.arange(len(channelList)+1) |
|
398 | noisedB = numpy.arange(len(channelList)+1) | |
366 | noisedB = noisedB *1.2 |
|
399 | noisedB = noisedB *1.2 | |
367 | titleList = [] |
|
400 | titleList = [] | |
368 | for i in range(len(noisedB)): |
|
401 | for i in range(len(noisedB)): | |
369 | title = "%.2f"%noisedB[i] |
|
402 | title = "%.2f"%noisedB[i] | |
370 | titleList.append(title) |
|
403 | titleList.append(title) | |
371 |
|
404 | |||
372 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
405 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) | |
373 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
406 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
374 | figuretitle = "Spc Radar Data: %s"%dateTime |
|
407 | figuretitle = "Spc Radar Data: %s"%dateTime | |
375 |
|
408 | |||
376 | cleardata = True |
|
409 | cleardata = True | |
377 |
|
410 | |||
378 | plotObj = self.plotObjList[self.plotObjIndex] |
|
411 | plotObj = self.plotObjList[self.plotObjIndex] | |
379 |
|
412 | |||
380 | plotObj.plotPcolor(data=data, |
|
413 | plotObj.plotPcolor(data=data, | |
381 | x=x, |
|
414 | x=x, | |
382 | y=y, |
|
415 | y=y, | |
383 | channelList=channelList, |
|
416 | channelList=channelList, | |
384 | xmin=xmin, |
|
417 | xmin=xmin, | |
385 | xmax=xmax, |
|
418 | xmax=xmax, | |
386 | ymin=ymin, |
|
419 | ymin=ymin, | |
387 | ymax=ymax, |
|
420 | ymax=ymax, | |
388 | minvalue=minvalue, |
|
421 | minvalue=minvalue, | |
389 | maxvalue=maxvalue, |
|
422 | maxvalue=maxvalue, | |
390 | figuretitle=figuretitle, |
|
423 | figuretitle=figuretitle, | |
391 | xrangestep=None, |
|
424 | xrangestep=None, | |
392 | deltax=None, |
|
425 | deltax=None, | |
393 | save=save, |
|
426 | save=save, | |
394 | gpath=gpath, |
|
427 | gpath=gpath, | |
395 | cleardata=cleardata |
|
428 | cleardata=cleardata | |
396 | ) |
|
429 | ) | |
397 |
|
430 | |||
398 | self.plotObjIndex += 1 |
|
431 | self.plotObjIndex += 1 | |
399 |
|
432 | |||
400 |
|
433 | |||
401 | def writeData(self, wrpath, blocksPerFile): |
|
434 | def writeData(self, wrpath, blocksPerFile): | |
402 |
|
435 | |||
403 | if self.dataOutObj.flagNoData: |
|
436 | if self.dataOutObj.flagNoData: | |
404 | return 0 |
|
437 | return 0 | |
405 |
|
438 | |||
406 | if len(self.writerObjList) <= self.writerObjIndex: |
|
439 | if len(self.writerObjList) <= self.writerObjIndex: | |
407 | self.addWriter(wrpath, blocksPerFile) |
|
440 | self.addWriter(wrpath, blocksPerFile) | |
408 |
|
441 | |||
409 | self.writerObjList[self.writerObjIndex].putData() |
|
442 | self.writerObjList[self.writerObjIndex].putData() | |
410 |
|
443 | |||
411 | self.writerObjIndex += 1 |
|
444 | self.writerObjIndex += 1 | |
412 |
|
445 | |||
413 | def integrator(self, N=None, timeInterval=None): |
|
446 | def integrator(self, N=None, timeInterval=None): | |
414 |
|
447 | |||
415 | if self.dataOutObj.flagNoData: |
|
448 | if self.dataOutObj.flagNoData: | |
416 | return 0 |
|
449 | return 0 | |
417 |
|
450 | |||
418 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
451 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
419 | self.addIntegrator(N,timeInterval) |
|
452 | self.addIntegrator(N,timeInterval) | |
420 |
|
453 | |||
421 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
454 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] | |
422 |
myIncohIntObj.exe(data=self.dataOutObj.data_spc,time |
|
455 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,datatime=self.dataOutObj.utctime) | |
423 |
|
456 | |||
424 | if myIncohIntObj.isReady: |
|
457 | if myIncohIntObj.isReady: | |
425 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
458 | self.dataOutObj.data_spc = myIncohIntObj.data | |
426 |
self.dataOutObj. |
|
459 | self.dataOutObj.timeInterval *= myCohIntObj.nIncohInt | |
427 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg |
|
460 | self.dataOutObj.nIncohInt = myIncohIntObj.navg * self.dataInObj.nIncohInt | |
|
461 | self.dataOutObj.utctime = myIncohIntObj.firstdatatime | |||
428 | self.dataOutObj.flagNoData = False |
|
462 | self.dataOutObj.flagNoData = False | |
429 |
|
463 | |||
430 | """Calcular el ruido""" |
|
464 | """Calcular el ruido""" | |
431 | self.getNoise() |
|
465 | self.getNoise() | |
432 | else: |
|
466 | else: | |
433 | self.dataOutObj.flagNoData = True |
|
467 | self.dataOutObj.flagNoData = True | |
434 |
|
468 | |||
435 | self.integratorObjIndex += 1 |
|
469 | self.integratorObjIndex += 1 | |
436 |
|
470 | |||
437 |
|
471 | |||
438 | class SpectraHeisProcessor: |
|
472 | class SpectraHeisProcessor: | |
439 |
|
473 | |||
440 | def __init__(self): |
|
474 | def __init__(self): | |
441 |
|
475 | |||
442 | self.integratorObjIndex = None |
|
476 | self.integratorObjIndex = None | |
443 | self.writerObjIndex = None |
|
477 | self.writerObjIndex = None | |
444 | self.plotObjIndex = None |
|
478 | self.plotObjIndex = None | |
445 | self.integratorObjList = [] |
|
479 | self.integratorObjList = [] | |
446 | self.writerObjList = [] |
|
480 | self.writerObjList = [] | |
447 | self.plotObjList = [] |
|
481 | self.plotObjList = [] | |
448 | #self.noiseObj = Noise() |
|
482 | #self.noiseObj = Noise() | |
449 |
|
483 | |||
450 | def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
484 | def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None): | |
451 |
|
485 | |||
452 | if nFFTPoints == None: |
|
486 | if nFFTPoints == None: | |
453 | nFFTPoints = self.dataInObj.nHeights |
|
487 | nFFTPoints = self.dataInObj.nHeights | |
454 |
|
488 | |||
455 | self.dataInObj = dataInObj |
|
489 | self.dataInObj = dataInObj | |
456 |
|
490 | |||
457 | if dataOutObj == None: |
|
491 | if dataOutObj == None: | |
458 | dataOutObj = SpectraHeis() |
|
492 | dataOutObj = SpectraHeis() | |
459 |
|
493 | |||
460 | self.dataOutObj = dataOutObj |
|
494 | self.dataOutObj = dataOutObj | |
461 |
|
495 | |||
462 | return self.dataOutObj |
|
496 | return self.dataOutObj | |
463 |
|
497 | |||
464 | def init(self): |
|
498 | def init(self): | |
465 |
|
499 | |||
466 | self.dataOutObj.flagNoData = True |
|
500 | self.dataOutObj.flagNoData = True | |
467 |
|
501 | |||
468 | if self.dataInObj.flagNoData: |
|
502 | if self.dataInObj.flagNoData: | |
469 | return 0 |
|
503 | return 0 | |
470 |
|
504 | |||
471 | self.integratorObjIndex = 0 |
|
505 | self.integratorObjIndex = 0 | |
472 | self.writerObjIndex = 0 |
|
506 | self.writerObjIndex = 0 | |
473 | self.plotObjIndex = 0 |
|
507 | self.plotObjIndex = 0 | |
474 |
|
508 | |||
475 | if self.dataInObj.type == "Voltage": |
|
509 | if self.dataInObj.type == "Voltage": | |
476 | self.__updateObjFromInput() |
|
510 | self.__updateObjFromInput() | |
477 | self.__getFft() |
|
511 | self.__getFft() | |
478 | self.dataOutObj.flagNoData = False |
|
512 | self.dataOutObj.flagNoData = False | |
479 | return |
|
513 | return | |
480 |
|
514 | |||
481 | #Other kind of data |
|
515 | #Other kind of data | |
482 | if self.dataInObj.type == "SpectraHeis": |
|
516 | if self.dataInObj.type == "SpectraHeis": | |
483 | self.dataOutObj.copy(self.dataInObj) |
|
517 | self.dataOutObj.copy(self.dataInObj) | |
484 | self.dataOutObj.flagNoData = False |
|
518 | self.dataOutObj.flagNoData = False | |
485 | return |
|
519 | return | |
486 |
|
520 | |||
487 | raise ValueError, "The type is not valid" |
|
521 | raise ValueError, "The type is not valid" | |
488 |
|
522 | |||
489 | def __updateObjFromInput(self): |
|
523 | def __updateObjFromInput(self): | |
490 |
|
524 | |||
491 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() |
|
525 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() | |
492 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() |
|
526 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() | |
493 | self.dataOutObj.channelList = self.dataInObj.channelList |
|
527 | self.dataOutObj.channelList = self.dataInObj.channelList | |
494 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
528 | self.dataOutObj.heightList = self.dataInObj.heightList | |
495 | self.dataOutObj.dtype = self.dataInObj.dtype |
|
529 | self.dataOutObj.dtype = self.dataInObj.dtype | |
496 | self.dataOutObj.nHeights = self.dataInObj.nHeights |
|
530 | self.dataOutObj.nHeights = self.dataInObj.nHeights | |
497 | self.dataOutObj.nChannels = self.dataInObj.nChannels |
|
531 | self.dataOutObj.nChannels = self.dataInObj.nChannels | |
498 | self.dataOutObj.nBaud = self.dataInObj.nBaud |
|
532 | self.dataOutObj.nBaud = self.dataInObj.nBaud | |
499 | self.dataOutObj.nCode = self.dataInObj.nCode |
|
533 | self.dataOutObj.nCode = self.dataInObj.nCode | |
500 | self.dataOutObj.code = self.dataInObj.code |
|
534 | self.dataOutObj.code = self.dataInObj.code | |
501 | self.dataOutObj.nProfiles = 1 |
|
535 | self.dataOutObj.nProfiles = 1 | |
502 | self.dataOutObj.nFFTPoints = self.dataInObj.nHeights |
|
536 | self.dataOutObj.nFFTPoints = self.dataInObj.nHeights | |
503 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList |
|
537 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList | |
504 | self.dataOutObj.flagNoData = self.dataInObj.flagNoData |
|
538 | self.dataOutObj.flagNoData = self.dataInObj.flagNoData | |
505 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock |
|
539 | self.dataOutObj.flagTimeBlock = self.dataInObj.flagTimeBlock | |
506 | self.dataOutObj.utctime = self.dataInObj.utctime |
|
540 | self.dataOutObj.utctime = self.dataInObj.utctime | |
507 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada |
|
541 | self.dataOutObj.flagDecodeData = self.dataInObj.flagDecodeData #asumo q la data esta decodificada | |
508 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip |
|
542 | self.dataOutObj.flagDeflipData = self.dataInObj.flagDeflipData #asumo q la data esta sin flip | |
509 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT |
|
543 | self.dataOutObj.flagShiftFFT = self.dataInObj.flagShiftFFT | |
510 | self.dataOutObj.nIncohInt = 1 |
|
544 | self.dataOutObj.nIncohInt = 1 | |
511 |
|
545 | |||
512 | def __getFft(self): |
|
546 | def __getFft(self): | |
513 |
|
547 | |||
514 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) |
|
548 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) | |
515 | #print fft_volt |
|
549 | #print fft_volt | |
516 | #calculo de self-spectra |
|
550 | #calculo de self-spectra | |
517 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
551 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
518 |
|
552 | |||
519 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) |
|
553 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) | |
520 | self.dataOutObj.data_spc = spc |
|
554 | self.dataOutObj.data_spc = spc | |
521 |
|
555 | |||
522 | def getSpectra(self): |
|
556 | def getSpectra(self): | |
523 |
|
557 | |||
524 | return self.dataOutObj.data_spc |
|
558 | return self.dataOutObj.data_spc | |
525 |
|
559 | |||
526 | def getFrecuencies(self): |
|
560 | def getFrecuencies(self): | |
527 |
|
561 | |||
528 | print self.nFFTPoints |
|
562 | print self.nFFTPoints | |
529 | return numpy.arange(int(self.nFFTPoints)) |
|
563 | return numpy.arange(int(self.nFFTPoints)) | |
530 |
|
564 | |||
531 | def addIntegrator(self,N,timeInterval): |
|
565 | def addIntegrator(self,N,timeInterval): | |
532 |
|
566 | |||
533 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
567 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
534 | self.integratorObjList.append(objIncohInt) |
|
568 | self.integratorObjList.append(objIncohInt) | |
535 |
|
569 | |||
536 | def integrator(self, N=None, timeInterval=None): |
|
570 | def integrator(self, N=None, timeInterval=None): | |
537 |
|
571 | |||
538 | if self.dataOutObj.flagNoData: |
|
572 | if self.dataOutObj.flagNoData: | |
539 | return 0 |
|
573 | return 0 | |
540 |
|
574 | |||
541 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
575 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
542 | self.addIntegrator(N,timeInterval) |
|
576 | self.addIntegrator(N,timeInterval) | |
543 |
|
577 | |||
544 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
578 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] | |
545 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.utctime) |
|
579 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.utctime) | |
546 |
|
580 | |||
547 | if myIncohIntObj.isReady: |
|
581 | if myIncohIntObj.isReady: | |
548 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
582 | self.dataOutObj.data_spc = myIncohIntObj.data | |
549 | self.dataOutObj.nIncohInt = self.dataOutObj.nIncohInt*myIncohIntObj.navg |
|
583 | self.dataOutObj.nIncohInt = self.dataOutObj.nIncohInt*myIncohIntObj.navg | |
550 | self.dataOutObj.flagNoData = False |
|
584 | self.dataOutObj.flagNoData = False | |
551 |
|
585 | |||
552 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) |
|
586 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) | |
553 | # self.getNoise(type="sort", parm=16) |
|
587 | # self.getNoise(type="sort", parm=16) | |
554 |
|
588 | |||
555 | else: |
|
589 | else: | |
556 | self.dataOutObj.flagNoData = True |
|
590 | self.dataOutObj.flagNoData = True | |
557 |
|
591 | |||
558 | self.integratorObjIndex += 1 |
|
592 | self.integratorObjIndex += 1 | |
559 |
|
593 | |||
560 |
|
594 | |||
561 | def addScope(self, idfigure, nframes, wintitle, driver): |
|
595 | def addScope(self, idfigure, nframes, wintitle, driver): | |
562 |
|
596 | |||
563 | if idfigure==None: |
|
597 | if idfigure==None: | |
564 | idfigure = self.plotObjIndex |
|
598 | idfigure = self.plotObjIndex | |
565 |
|
599 | |||
566 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) |
|
600 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) | |
567 | self.plotObjList.append(scopeObj) |
|
601 | self.plotObjList.append(scopeObj) | |
568 |
|
602 | |||
569 | def plotScope(self, |
|
603 | def plotScope(self, | |
570 | idfigure=None, |
|
604 | idfigure=None, | |
571 | minvalue=None, |
|
605 | minvalue=None, | |
572 | maxvalue=None, |
|
606 | maxvalue=None, | |
573 | xmin=None, |
|
607 | xmin=None, | |
574 | xmax=None, |
|
608 | xmax=None, | |
575 | wintitle='', |
|
609 | wintitle='', | |
576 | driver='plplot', |
|
610 | driver='plplot', | |
577 | save=False, |
|
611 | save=False, | |
578 | gpath=None, |
|
612 | gpath=None, | |
579 | titleList=None, |
|
613 | titleList=None, | |
580 | xlabelList=None, |
|
614 | xlabelList=None, | |
581 | ylabelList=None): |
|
615 | ylabelList=None): | |
582 |
|
616 | |||
583 | if self.dataOutObj.flagNoData: |
|
617 | if self.dataOutObj.flagNoData: | |
584 | return 0 |
|
618 | return 0 | |
585 |
|
619 | |||
586 | nframes = len(self.dataOutObj.channelList) |
|
620 | nframes = len(self.dataOutObj.channelList) | |
587 |
|
621 | |||
588 | if len(self.plotObjList) <= self.plotObjIndex: |
|
622 | if len(self.plotObjList) <= self.plotObjIndex: | |
589 | self.addScope(idfigure, nframes, wintitle, driver) |
|
623 | self.addScope(idfigure, nframes, wintitle, driver) | |
590 |
|
624 | |||
591 |
|
625 | |||
592 | data1D = self.dataOutObj.data_spc |
|
626 | data1D = self.dataOutObj.data_spc | |
593 |
|
627 | |||
594 | x = numpy.arange(self.dataOutObj.nHeights) |
|
628 | x = numpy.arange(self.dataOutObj.nHeights) | |
595 |
|
629 | |||
596 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
630 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) | |
597 |
|
631 | |||
598 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
632 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
599 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) |
|
633 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) | |
600 |
|
634 | |||
601 | figureTitle = "Scope Plot Radar Data: " + date |
|
635 | figureTitle = "Scope Plot Radar Data: " + date | |
602 |
|
636 | |||
603 | plotObj = self.plotObjList[self.plotObjIndex] |
|
637 | plotObj = self.plotObjList[self.plotObjIndex] | |
604 |
|
638 | |||
605 | plotObj.plot1DArray(data1D, |
|
639 | plotObj.plot1DArray(data1D, | |
606 | x, |
|
640 | x, | |
607 | self.dataOutObj.channelList, |
|
641 | self.dataOutObj.channelList, | |
608 | xmin, |
|
642 | xmin, | |
609 | xmax, |
|
643 | xmax, | |
610 | minvalue, |
|
644 | minvalue, | |
611 | maxvalue, |
|
645 | maxvalue, | |
612 | figureTitle, |
|
646 | figureTitle, | |
613 | save, |
|
647 | save, | |
614 | gpath) |
|
648 | gpath) | |
615 |
|
649 | |||
616 | self.plotObjIndex += 1 |
|
650 | self.plotObjIndex += 1 | |
617 |
|
651 | |||
618 | class IncoherentIntegration: |
|
652 | class IncoherentIntegration: | |
619 |
|
653 | |||
620 | integ_counter = None |
|
654 | integ_counter = None | |
621 | data = None |
|
655 | data = None | |
622 | navg = None |
|
656 | navg = None | |
623 | buffer = None |
|
657 | buffer = None | |
624 | nIncohInt = None |
|
658 | nIncohInt = None | |
|
659 | firstdatatime = None | |||
625 |
|
660 | |||
626 | def __init__(self, N = None, timeInterval = None): |
|
661 | def __init__(self, N = None, timeInterval = None): | |
627 | """ |
|
662 | """ | |
628 | N |
|
663 | N | |
629 | timeInterval - interval time [min], integer value |
|
664 | timeInterval - interval time [min], integer value | |
630 | """ |
|
665 | """ | |
631 |
|
666 | |||
632 | self.data = None |
|
667 | self.data = None | |
633 | self.navg = None |
|
668 | self.navg = None | |
634 | self.buffer = None |
|
669 | self.buffer = None | |
635 | self.timeOut = None |
|
670 | self.timeOut = None | |
636 | self.exitCondition = False |
|
671 | self.exitCondition = False | |
637 | self.isReady = False |
|
672 | self.isReady = False | |
638 | self.nIncohInt = N |
|
673 | self.nIncohInt = N | |
639 | self.integ_counter = 0 |
|
674 | self.integ_counter = 0 | |
|
675 | self.firstdatatime = None | |||
|
676 | ||||
640 | if timeInterval!=None: |
|
677 | if timeInterval!=None: | |
641 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
678 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line | |
642 |
|
679 | |||
643 | if ((timeInterval==None) and (N==None)): |
|
680 | if ((timeInterval==None) and (N==None)): | |
644 | print 'N = None ; timeInterval = None' |
|
681 | print 'N = None ; timeInterval = None' | |
645 | sys.exit(0) |
|
682 | sys.exit(0) | |
646 | elif timeInterval == None: |
|
683 | elif timeInterval == None: | |
647 | self.timeFlag = False |
|
684 | self.timeFlag = False | |
648 | else: |
|
685 | else: | |
649 | self.timeFlag = True |
|
686 | self.timeFlag = True | |
650 |
|
687 | |||
651 |
|
688 | |||
652 |
def exe(self,data,time |
|
689 | def exe(self,data,datatime): | |
653 | """ |
|
690 | """ | |
654 | data |
|
691 | data | |
655 |
|
692 | |||
656 |
time |
|
693 | datatime [seconds] | |
657 | """ |
|
694 | """ | |
|
695 | if self.firstdatatime == None or self.isReady: | |||
|
696 | self.firstdatatime = datatime | |||
658 |
|
697 | |||
659 | if self.timeFlag: |
|
698 | if self.timeFlag: | |
660 | if self.timeOut == None: |
|
699 | if self.timeOut == None: | |
661 |
self.timeOut = time |
|
700 | self.timeOut = datatime + self.timeIntervalInSeconds | |
662 |
|
701 | |||
663 |
if time |
|
702 | if datatime < self.timeOut: | |
664 | if self.buffer == None: |
|
703 | if self.buffer == None: | |
665 | self.buffer = data |
|
704 | self.buffer = data | |
666 | else: |
|
705 | else: | |
667 | self.buffer = self.buffer + data |
|
706 | self.buffer = self.buffer + data | |
668 | self.integ_counter += 1 |
|
707 | self.integ_counter += 1 | |
669 | else: |
|
708 | else: | |
670 | self.exitCondition = True |
|
709 | self.exitCondition = True | |
671 |
|
710 | |||
672 | else: |
|
711 | else: | |
673 | if self.integ_counter < self.nIncohInt: |
|
712 | if self.integ_counter < self.nIncohInt: | |
674 | if self.buffer == None: |
|
713 | if self.buffer == None: | |
675 | self.buffer = data |
|
714 | self.buffer = data | |
676 | else: |
|
715 | else: | |
677 | self.buffer = self.buffer + data |
|
716 | self.buffer = self.buffer + data | |
678 |
|
717 | |||
679 | self.integ_counter += 1 |
|
718 | self.integ_counter += 1 | |
680 |
|
719 | |||
681 | if self.integ_counter == self.nIncohInt: |
|
720 | if self.integ_counter == self.nIncohInt: | |
682 | self.exitCondition = True |
|
721 | self.exitCondition = True | |
683 |
|
722 | |||
684 | if self.exitCondition: |
|
723 | if self.exitCondition: | |
685 | self.data = self.buffer |
|
724 | self.data = self.buffer | |
686 | self.navg = self.integ_counter |
|
725 | self.navg = self.integ_counter | |
687 | self.isReady = True |
|
726 | self.isReady = True | |
688 | self.buffer = None |
|
727 | self.buffer = None | |
689 | self.timeOut = None |
|
728 | self.timeOut = None | |
690 | self.integ_counter = 0 |
|
729 | self.integ_counter = 0 | |
691 | self.exitCondition = False |
|
730 | self.exitCondition = False | |
692 |
|
731 | |||
693 | if self.timeFlag: |
|
732 | if self.timeFlag: | |
694 | self.buffer = data |
|
733 | self.buffer = data | |
695 |
self.timeOut = time |
|
734 | self.timeOut = datatime + self.timeIntervalInSeconds | |
696 | else: |
|
735 | else: | |
697 | self.isReady = False |
|
736 | self.isReady = False | |
698 | No newline at end of file |
|
737 |
@@ -1,419 +1,429 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import os |
|
7 | import os | |
8 | import sys |
|
8 | import sys | |
9 | import numpy |
|
9 | import numpy | |
10 | import datetime |
|
10 | import datetime | |
11 | import time |
|
11 | import time | |
12 |
|
12 | |||
13 | path = os.path.split(os.getcwd())[0] |
|
13 | path = os.path.split(os.getcwd())[0] | |
14 | sys.path.append(path) |
|
14 | sys.path.append(path) | |
15 |
|
15 | |||
16 | from Data.JROData import Voltage |
|
16 | from Data.JROData import Voltage | |
17 | from IO.VoltageIO import VoltageWriter |
|
17 | from IO.VoltageIO import VoltageWriter | |
18 | from Graphics.schainPlotTypes import ScopeFigure, RTIFigure |
|
18 | from Graphics.schainPlotTypes import ScopeFigure, RTIFigure | |
19 |
|
19 | |||
20 | class VoltageProcessor: |
|
20 | class VoltageProcessor: | |
21 |
|
21 | |||
22 | dataInObj = None |
|
22 | dataInObj = None | |
23 | dataOutObj = None |
|
23 | dataOutObj = None | |
24 | integratorObjIndex = None |
|
24 | integratorObjIndex = None | |
25 | writerObjIndex = None |
|
25 | writerObjIndex = None | |
26 | integratorObjList = None |
|
26 | integratorObjList = None | |
27 | writerObjList = None |
|
27 | writerObjList = None | |
28 |
|
28 | |||
29 | def __init__(self): |
|
29 | def __init__(self): | |
30 | self.integratorObjIndex = None |
|
30 | self.integratorObjIndex = None | |
31 | self.writerObjIndex = None |
|
31 | self.writerObjIndex = None | |
32 | self.plotObjIndex = None |
|
32 | self.plotObjIndex = None | |
33 | self.integratorObjList = [] |
|
33 | self.integratorObjList = [] | |
34 | self.writerObjList = [] |
|
34 | self.writerObjList = [] | |
35 | self.plotObjList = [] |
|
35 | self.plotObjList = [] | |
36 |
|
36 | |||
37 | def setup(self,dataInObj=None,dataOutObj=None): |
|
37 | def setup(self,dataInObj=None,dataOutObj=None): | |
38 | self.dataInObj = dataInObj |
|
38 | self.dataInObj = dataInObj | |
39 |
|
39 | |||
40 | if self.dataOutObj == None: |
|
40 | if self.dataOutObj == None: | |
41 | dataOutObj = Voltage() |
|
41 | dataOutObj = Voltage() | |
42 |
|
42 | |||
43 | self.dataOutObj = dataOutObj |
|
43 | self.dataOutObj = dataOutObj | |
44 |
|
44 | |||
45 | return self.dataOutObj |
|
45 | return self.dataOutObj | |
46 |
|
46 | |||
47 | def init(self): |
|
47 | def init(self): | |
48 | self.integratorObjIndex = 0 |
|
48 | self.integratorObjIndex = 0 | |
49 | self.writerObjIndex = 0 |
|
49 | self.writerObjIndex = 0 | |
50 | self.plotObjIndex = 0 |
|
50 | self.plotObjIndex = 0 | |
51 |
|
51 | |||
52 | if not(self.dataInObj.flagNoData): |
|
52 | if not(self.dataInObj.flagNoData): | |
53 | self.dataOutObj.copy(self.dataInObj) |
|
53 | self.dataOutObj.copy(self.dataInObj) | |
54 | # No necesita copiar en cada init() los atributos de dataInObj |
|
54 | # No necesita copiar en cada init() los atributos de dataInObj | |
55 | # la copia deberia hacerse por cada nuevo bloque de datos |
|
55 | # la copia deberia hacerse por cada nuevo bloque de datos | |
56 |
|
56 | |||
57 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
57 | def addRti(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
58 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
58 | rtiObj = RTIFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
59 | self.plotObjList.append(rtiObj) |
|
59 | self.plotObjList.append(rtiObj) | |
60 |
|
60 | |||
61 | def plotRti(self, idfigure=None, |
|
61 | def plotRti(self, idfigure=None, | |
62 | starttime=None, |
|
62 | starttime=None, | |
63 | endtime=None, |
|
63 | endtime=None, | |
64 | rangemin=None, |
|
64 | rangemin=None, | |
65 | rangemax=None, |
|
65 | rangemax=None, | |
66 | minvalue=None, |
|
66 | minvalue=None, | |
67 | maxvalue=None, |
|
67 | maxvalue=None, | |
68 | wintitle='', |
|
68 | wintitle='', | |
69 | driver='plplot', |
|
69 | driver='plplot', | |
70 | colormap='br_greeen', |
|
70 | colormap='br_greeen', | |
71 | colorbar=True, |
|
71 | colorbar=True, | |
72 | showprofile=False, |
|
72 | showprofile=False, | |
73 | xrangestep=None, |
|
73 | xrangestep=None, | |
74 | save=False, |
|
74 | save=False, | |
75 | gpath=None, |
|
75 | gpath=None, | |
76 | ratio=1, |
|
76 | ratio=1, | |
77 | channelList=None): |
|
77 | channelList=None): | |
78 |
|
78 | |||
79 | if self.dataOutObj.flagNoData: |
|
79 | if self.dataOutObj.flagNoData: | |
80 | return 0 |
|
80 | return 0 | |
81 |
|
81 | |||
82 | if channelList == None: |
|
82 | if channelList == None: | |
83 | channelList = self.dataOutObj.channelList |
|
83 | channelList = self.dataOutObj.channelList | |
84 |
|
84 | |||
85 | nframes = len(channelList) |
|
85 | nframes = len(channelList) | |
86 |
|
86 | |||
87 | if len(self.plotObjList) <= self.plotObjIndex: |
|
87 | if len(self.plotObjList) <= self.plotObjIndex: | |
88 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
88 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
89 |
|
89 | |||
90 | data = self.dataOutObj.data[channelList,:] * numpy.conjugate(self.dataOutObj.data[channelList,:]) |
|
90 | data = self.dataOutObj.data[channelList,:] * numpy.conjugate(self.dataOutObj.data[channelList,:]) | |
91 | data = 10*numpy.log10(data.real) |
|
91 | data = 10*numpy.log10(data.real) | |
92 |
|
92 | |||
93 | currenttime = self.dataOutObj.utctime - time.timezone |
|
93 | currenttime = self.dataOutObj.utctime - time.timezone | |
94 |
|
94 | |||
95 | range = self.dataOutObj.heightList |
|
95 | range = self.dataOutObj.heightList | |
96 |
|
96 | |||
97 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
97 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) | |
98 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
98 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
99 | date = "%s"%(thisdatetime.strftime("%d-%b-%Y")) |
|
99 | date = "%s"%(thisdatetime.strftime("%d-%b-%Y")) | |
100 |
|
100 | |||
101 | figuretitle = "RTI Plot Radar Data" #+ date |
|
101 | figuretitle = "RTI Plot Radar Data" #+ date | |
102 |
|
102 | |||
103 | plotObj = self.plotObjList[self.plotObjIndex] |
|
103 | plotObj = self.plotObjList[self.plotObjIndex] | |
104 |
|
104 | |||
105 | cleardata = False |
|
105 | cleardata = False | |
106 |
|
106 | |||
107 | deltax = self.dataOutObj.timeInterval |
|
107 | deltax = self.dataOutObj.timeInterval | |
108 |
|
108 | |||
109 | plotObj.plotPcolor(data=data, |
|
109 | plotObj.plotPcolor(data=data, | |
110 | x=currenttime, |
|
110 | x=currenttime, | |
111 | y=range, |
|
111 | y=range, | |
112 | channelList=channelList, |
|
112 | channelList=channelList, | |
113 | xmin=starttime, |
|
113 | xmin=starttime, | |
114 | xmax=endtime, |
|
114 | xmax=endtime, | |
115 | ymin=rangemin, |
|
115 | ymin=rangemin, | |
116 | ymax=rangemax, |
|
116 | ymax=rangemax, | |
117 | minvalue=minvalue, |
|
117 | minvalue=minvalue, | |
118 | maxvalue=maxvalue, |
|
118 | maxvalue=maxvalue, | |
119 | figuretitle=figuretitle, |
|
119 | figuretitle=figuretitle, | |
120 | xrangestep=xrangestep, |
|
120 | xrangestep=xrangestep, | |
121 | deltax=deltax, |
|
121 | deltax=deltax, | |
122 | save=save, |
|
122 | save=save, | |
123 | gpath=gpath, |
|
123 | gpath=gpath, | |
124 | ratio=ratio, |
|
124 | ratio=ratio, | |
125 | cleardata=cleardata |
|
125 | cleardata=cleardata | |
126 | ) |
|
126 | ) | |
127 |
|
127 | |||
128 |
|
128 | |||
129 | self.plotObjIndex += 1 |
|
129 | self.plotObjIndex += 1 | |
130 |
|
130 | |||
131 | def addScope(self, idfigure, nframes, wintitle, driver): |
|
131 | def addScope(self, idfigure, nframes, wintitle, driver): | |
132 | if idfigure==None: |
|
132 | if idfigure==None: | |
133 | idfigure = self.plotObjIndex |
|
133 | idfigure = self.plotObjIndex | |
134 |
|
134 | |||
135 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) |
|
135 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) | |
136 | self.plotObjList.append(scopeObj) |
|
136 | self.plotObjList.append(scopeObj) | |
137 |
|
137 | |||
138 | def plotScope(self, |
|
138 | def plotScope(self, | |
139 | idfigure=None, |
|
139 | idfigure=None, | |
140 | minvalue=None, |
|
140 | minvalue=None, | |
141 | maxvalue=None, |
|
141 | maxvalue=None, | |
142 | xmin=None, |
|
142 | xmin=None, | |
143 | xmax=None, |
|
143 | xmax=None, | |
144 | wintitle='', |
|
144 | wintitle='', | |
145 | driver='plplot', |
|
145 | driver='plplot', | |
146 | save=False, |
|
146 | save=False, | |
147 | gpath=None, |
|
147 | gpath=None, | |
148 | ratio=1, |
|
148 | ratio=1, | |
149 | type="power"): |
|
149 | type="power"): | |
150 |
|
150 | |||
151 | if self.dataOutObj.flagNoData: |
|
151 | if self.dataOutObj.flagNoData: | |
152 | return 0 |
|
152 | return 0 | |
153 |
|
153 | |||
154 | nframes = len(self.dataOutObj.channelList) |
|
154 | nframes = len(self.dataOutObj.channelList) | |
155 |
|
155 | |||
156 | if len(self.plotObjList) <= self.plotObjIndex: |
|
156 | if len(self.plotObjList) <= self.plotObjIndex: | |
157 | self.addScope(idfigure, nframes, wintitle, driver) |
|
157 | self.addScope(idfigure, nframes, wintitle, driver) | |
158 |
|
158 | |||
159 |
|
159 | |||
160 | if type=="power": |
|
160 | if type=="power": | |
161 | data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) |
|
161 | data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) | |
162 | data1D = data1D.real |
|
162 | data1D = data1D.real | |
163 |
|
163 | |||
164 | if type =="iq": |
|
164 | if type =="iq": | |
165 | data1D = self.dataOutObj.data |
|
165 | data1D = self.dataOutObj.data | |
166 |
|
166 | |||
167 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) |
|
167 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.utctime) | |
168 |
|
168 | |||
169 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
169 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
170 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) |
|
170 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) | |
171 |
|
171 | |||
172 | figuretitle = "Scope Plot Radar Data: " + date |
|
172 | figuretitle = "Scope Plot Radar Data: " + date | |
173 |
|
173 | |||
174 | plotObj = self.plotObjList[self.plotObjIndex] |
|
174 | plotObj = self.plotObjList[self.plotObjIndex] | |
175 |
|
175 | |||
176 | plotObj.plot1DArray(data1D=data1D, |
|
176 | plotObj.plot1DArray(data1D=data1D, | |
177 | x=self.dataOutObj.heightList, |
|
177 | x=self.dataOutObj.heightList, | |
178 | channelList=self.dataOutObj.channelList, |
|
178 | channelList=self.dataOutObj.channelList, | |
179 | xmin=xmin, |
|
179 | xmin=xmin, | |
180 | xmax=xmax, |
|
180 | xmax=xmax, | |
181 | minvalue=minvalue, |
|
181 | minvalue=minvalue, | |
182 | maxvalue=maxvalue, |
|
182 | maxvalue=maxvalue, | |
183 | figuretitle=figuretitle, |
|
183 | figuretitle=figuretitle, | |
184 | save=save, |
|
184 | save=save, | |
185 | gpath=gpath, |
|
185 | gpath=gpath, | |
186 | ratio=ratio) |
|
186 | ratio=ratio) | |
187 |
|
187 | |||
188 |
|
188 | |||
189 | self.plotObjIndex += 1 |
|
189 | self.plotObjIndex += 1 | |
190 |
|
190 | |||
191 |
|
191 | |||
192 | def addIntegrator(self, *args): |
|
192 | def addIntegrator(self, *args): | |
193 | objCohInt = CoherentIntegrator(*args) |
|
193 | objCohInt = CoherentIntegrator(*args) | |
194 | self.integratorObjList.append(objCohInt) |
|
194 | self.integratorObjList.append(objCohInt) | |
195 |
|
195 | |||
196 | def addWriter(self, *args): |
|
196 | def addWriter(self, *args): | |
197 | writerObj = VoltageWriter(self.dataOutObj) |
|
197 | writerObj = VoltageWriter(self.dataOutObj) | |
198 | writerObj.setup(*args) |
|
198 | writerObj.setup(*args) | |
199 | self.writerObjList.append(writerObj) |
|
199 | self.writerObjList.append(writerObj) | |
200 |
|
200 | |||
201 | def writeData(self, wrpath, blocksPerFile, profilesPerBlock): |
|
201 | def writeData(self, wrpath, blocksPerFile, profilesPerBlock): | |
202 |
|
202 | |||
203 | if self.dataOutObj.flagNoData: |
|
203 | if self.dataOutObj.flagNoData: | |
204 | return 0 |
|
204 | return 0 | |
205 |
|
205 | |||
206 | if len(self.writerObjList) <= self.writerObjIndex: |
|
206 | if len(self.writerObjList) <= self.writerObjIndex: | |
207 | self.addWriter(wrpath, blocksPerFile, profilesPerBlock) |
|
207 | self.addWriter(wrpath, blocksPerFile, profilesPerBlock) | |
208 |
|
208 | |||
209 | self.writerObjList[self.writerObjIndex].putData() |
|
209 | self.writerObjList[self.writerObjIndex].putData() | |
210 |
|
210 | |||
211 | self.writerObjIndex += 1 |
|
211 | self.writerObjIndex += 1 | |
212 |
|
212 | |||
213 | def integrator(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
213 | def integrator(self, nCohInt=None, timeInterval=None, overlapping=False): | |
214 |
|
214 | |||
215 | if self.dataOutObj.flagNoData: |
|
215 | if self.dataOutObj.flagNoData: | |
216 | return 0 |
|
216 | return 0 | |
217 |
|
217 | |||
218 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
218 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
219 | self.addIntegrator(nCohInt, timeInterval, overlapping) |
|
219 | self.addIntegrator(nCohInt, timeInterval, overlapping) | |
220 |
|
220 | |||
221 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
221 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] | |
222 |
myCohIntObj.exe(data = self.dataOutObj.data, datatime= |
|
222 | myCohIntObj.exe(data = self.dataOutObj.data, datatime=self.dataOutObj.utctime) | |
223 |
|
223 | |||
224 | # self.dataOutObj.timeInterval *= nCohInt |
|
224 | # self.dataOutObj.timeInterval *= nCohInt | |
225 | self.dataOutObj.flagNoData = True |
|
225 | self.dataOutObj.flagNoData = True | |
226 |
|
226 | |||
227 | if myCohIntObj.isReady: |
|
227 | if myCohIntObj.isReady: | |
228 |
self.dataOutObj. |
|
228 | self.dataOutObj.data = myCohIntObj.data | |
|
229 | self.dataOutObj.timeInterval *= myCohIntObj.nCohInt | |||
|
230 | self.dataOutObj.nCohInt = myCohIntObj.nCohInt * self.dataInObj.nCohInt | |||
|
231 | self.dataOutObj.utctime = myCohIntObj.firstdatatime | |||
229 | self.dataOutObj.flagNoData = False |
|
232 | self.dataOutObj.flagNoData = False | |
230 |
|
233 | |||
231 | def selectChannels(self, channelList): |
|
234 | def selectChannels(self, channelList): | |
232 |
|
235 | |||
233 | self.selectChannelsByIndex(channelList) |
|
236 | self.selectChannelsByIndex(channelList) | |
234 |
|
237 | |||
235 | def selectChannelsByIndex(self, channelIndexList): |
|
238 | def selectChannelsByIndex(self, channelIndexList): | |
236 | """ |
|
239 | """ | |
237 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
240 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |
238 |
|
241 | |||
239 | Input: |
|
242 | Input: | |
240 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
243 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
241 |
|
244 | |||
242 | Affected: |
|
245 | Affected: | |
243 | self.dataOutObj.data |
|
246 | self.dataOutObj.data | |
244 | self.dataOutObj.channelIndexList |
|
247 | self.dataOutObj.channelIndexList | |
245 | self.dataOutObj.nChannels |
|
248 | self.dataOutObj.nChannels | |
246 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
249 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |
247 | self.dataOutObj.systemHeaderObj.numChannels |
|
250 | self.dataOutObj.systemHeaderObj.numChannels | |
248 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
251 | self.dataOutObj.m_ProcessingHeader.blockSize | |
249 |
|
252 | |||
250 | Return: |
|
253 | Return: | |
251 | None |
|
254 | None | |
252 | """ |
|
255 | """ | |
253 | if self.dataOutObj.flagNoData: |
|
256 | if self.dataOutObj.flagNoData: | |
254 | return 0 |
|
257 | return 0 | |
255 |
|
258 | |||
256 | for channel in channelIndexList: |
|
259 | for channel in channelIndexList: | |
257 | if channel not in self.dataOutObj.channelIndexList: |
|
260 | if channel not in self.dataOutObj.channelIndexList: | |
258 | raise ValueError, "The value %d in channelIndexList is not valid" %channel |
|
261 | raise ValueError, "The value %d in channelIndexList is not valid" %channel | |
259 |
|
262 | |||
260 | nChannels = len(channelIndexList) |
|
263 | nChannels = len(channelIndexList) | |
261 |
|
264 | |||
262 | data = self.dataOutObj.data[channelIndexList,:] |
|
265 | data = self.dataOutObj.data[channelIndexList,:] | |
263 |
|
266 | |||
264 | self.dataOutObj.data = data |
|
267 | self.dataOutObj.data = data | |
265 | self.dataOutObj.channelIndexList = channelIndexList |
|
268 | self.dataOutObj.channelIndexList = channelIndexList | |
266 | self.dataOutObj.channelList = [self.dataOutObj.channelList[i] for i in channelIndexList] |
|
269 | self.dataOutObj.channelList = [self.dataOutObj.channelList[i] for i in channelIndexList] | |
267 | self.dataOutObj.nChannels = nChannels |
|
270 | self.dataOutObj.nChannels = nChannels | |
268 |
|
271 | |||
269 | return 1 |
|
272 | return 1 | |
270 |
|
273 | |||
271 | class CoherentIntegrator: |
|
274 | class CoherentIntegrator: | |
272 |
|
275 | |||
273 |
|
276 | |||
274 | __profIndex = 0 |
|
277 | __profIndex = 0 | |
275 | __withOverapping = False |
|
278 | __withOverapping = False | |
276 |
|
279 | |||
277 | __isByTime = False |
|
280 | __isByTime = False | |
278 | __initime = None |
|
281 | __initime = None | |
279 | __integrationtime = None |
|
282 | __integrationtime = None | |
280 |
|
283 | |||
281 | __buffer = None |
|
284 | __buffer = None | |
282 |
|
285 | |||
283 | isReady = False |
|
286 | isReady = False | |
284 | nCohInt = None |
|
287 | nCohInt = None | |
285 |
|
288 | firstdatatime = None | ||
286 |
|
289 | |||
287 | def __init__(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
290 | def __init__(self, nCohInt=None, timeInterval=None, overlapping=False): | |
288 |
|
291 | |||
289 | """ |
|
292 | """ | |
290 | Set the parameters of the integration class. |
|
293 | Set the parameters of the integration class. | |
291 |
|
294 | |||
292 | Inputs: |
|
295 | Inputs: | |
293 |
|
296 | |||
294 | nCohInt : Number of coherent integrations |
|
297 | nCohInt : Number of coherent integrations | |
295 | timeInterval : Time of integration. If nCohInt is selected this parameter does not work |
|
298 | timeInterval : Time of integration. If nCohInt is selected this parameter does not work | |
296 | overlapping : |
|
299 | overlapping : | |
297 |
|
300 | |||
298 | """ |
|
301 | """ | |
299 |
|
302 | |||
300 | self.__buffer = None |
|
303 | self.__buffer = None | |
301 | self.isReady = False |
|
304 | self.isReady = False | |
302 |
|
305 | |||
303 | if nCohInt == None and timeInterval == None: |
|
306 | if nCohInt == None and timeInterval == None: | |
304 | raise ValueError, "nCohInt or timeInterval should be specified ..." |
|
307 | raise ValueError, "nCohInt or timeInterval should be specified ..." | |
305 |
|
308 | |||
306 | if nCohInt != None: |
|
309 | if nCohInt != None: | |
307 | self.nCohInt = nCohInt |
|
310 | self.nCohInt = nCohInt | |
308 | self.__isByTime = False |
|
311 | self.__isByTime = False | |
309 | else: |
|
312 | else: | |
310 | self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
313 | self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line | |
311 | self.__isByTime = True |
|
314 | self.__isByTime = True | |
312 |
|
315 | |||
313 | if overlapping: |
|
316 | if overlapping: | |
314 | self.__withOverapping = True |
|
317 | self.__withOverapping = True | |
315 | self.__buffer = None |
|
318 | self.__buffer = None | |
316 | else: |
|
319 | else: | |
317 | self.__withOverapping = False |
|
320 | self.__withOverapping = False | |
318 | self.__buffer = 0 |
|
321 | self.__buffer = 0 | |
319 |
|
322 | |||
320 | self.__profIndex = 0 |
|
323 | self.__profIndex = 0 | |
|
324 | firstdatatime = None | |||
321 |
|
325 | |||
322 | def putData(self, data): |
|
326 | def putData(self, data): | |
323 |
|
327 | |||
324 | """ |
|
328 | """ | |
325 | Add a profile to the __buffer and increase in one the __profileIndex |
|
329 | Add a profile to the __buffer and increase in one the __profileIndex | |
326 |
|
330 | |||
327 | """ |
|
331 | """ | |
328 | if not self.__withOverapping: |
|
332 | if not self.__withOverapping: | |
329 | self.__buffer += data |
|
333 | self.__buffer += data | |
330 | self.__profIndex += 1 |
|
334 | self.__profIndex += 1 | |
331 | return |
|
335 | return | |
332 |
|
336 | |||
333 | #Overlapping data |
|
337 | #Overlapping data | |
334 | nChannels, nHeis = data.shape |
|
338 | nChannels, nHeis = data.shape | |
335 | data = numpy.reshape(data, (1, nChannels, nHeis)) |
|
339 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
336 |
|
340 | |||
337 | if self.__buffer == None: |
|
341 | if self.__buffer == None: | |
338 | self.__buffer = data |
|
342 | self.__buffer = data | |
339 | self.__profIndex += 1 |
|
343 | self.__profIndex += 1 | |
340 | return |
|
344 | return | |
341 |
|
345 | |||
342 | if self.__profIndex < self.nCohInt: |
|
346 | if self.__profIndex < self.nCohInt: | |
343 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
347 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
344 | self.__profIndex += 1 |
|
348 | self.__profIndex += 1 | |
345 | return |
|
349 | return | |
346 |
|
350 | |||
347 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
351 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
348 | self.__buffer[self.nCohInt-1] = data |
|
352 | self.__buffer[self.nCohInt-1] = data | |
349 | #self.__profIndex = self.nCohInt |
|
353 | #self.__profIndex = self.nCohInt | |
350 | return |
|
354 | return | |
351 |
|
355 | |||
352 |
|
356 | |||
353 | def pushData(self): |
|
357 | def pushData(self): | |
354 | """ |
|
358 | """ | |
355 | Return the sum of the last profiles and the profiles used in the sum. |
|
359 | Return the sum of the last profiles and the profiles used in the sum. | |
356 |
|
360 | |||
357 | Affected: |
|
361 | Affected: | |
358 |
|
362 | |||
359 | self.__profileIndex |
|
363 | self.__profileIndex | |
360 |
|
364 | |||
361 | """ |
|
365 | """ | |
362 |
|
366 | |||
363 | if not self.__withOverapping: |
|
367 | if not self.__withOverapping: | |
364 | data = self.__buffer |
|
368 | data = self.__buffer | |
365 | nCohInt = self.__profIndex |
|
369 | nCohInt = self.__profIndex | |
366 |
|
370 | |||
367 | self.__buffer = 0 |
|
371 | self.__buffer = 0 | |
368 | self.__profIndex = 0 |
|
372 | self.__profIndex = 0 | |
369 |
|
373 | |||
370 | return data, nCohInt |
|
374 | return data, nCohInt | |
371 |
|
375 | |||
372 | #Overlapping data |
|
376 | #Overlapping data | |
373 | data = numpy.sum(self.__buffer, axis=0) |
|
377 | data = numpy.sum(self.__buffer, axis=0) | |
374 | nCohInt = self.__profIndex |
|
378 | nCohInt = self.__profIndex | |
375 |
|
379 | |||
376 | return data, nCohInt |
|
380 | return data, nCohInt | |
377 |
|
381 | |||
378 | def byProfiles(self, data): |
|
382 | def byProfiles(self, data): | |
379 |
|
383 | |||
380 | self.isReady = False |
|
384 | self.isReady = False | |
381 | avg_data = None |
|
385 | avg_data = None | |
382 |
|
386 | |||
383 | self.putData(data) |
|
387 | self.putData(data) | |
384 |
|
388 | |||
385 | if self.__profIndex == self.nCohInt: |
|
389 | if self.__profIndex == self.nCohInt: | |
386 | avg_data, nCohInt = self.pushData() |
|
390 | avg_data, nCohInt = self.pushData() | |
387 | self.isReady = True |
|
391 | self.isReady = True | |
388 |
|
392 | |||
389 | return avg_data |
|
393 | return avg_data | |
390 |
|
394 | |||
391 | def byTime(self, data, datatime): |
|
395 | def byTime(self, data, datatime): | |
392 |
|
396 | |||
393 | self.isReady = False |
|
397 | self.isReady = False | |
394 | avg_data = None |
|
398 | avg_data = None | |
395 |
|
399 | |||
396 | if self.__initime == None: |
|
400 | if self.__initime == None: | |
397 | self.__initime = datatime |
|
401 | self.__initime = datatime | |
398 |
|
402 | |||
399 | self.putData(data) |
|
403 | self.putData(data) | |
400 |
|
404 | |||
401 | if (datatime - self.__initime) >= self.__integrationtime: |
|
405 | if (datatime - self.__initime) >= self.__integrationtime: | |
402 | avg_data, nCohInt = self.pushData() |
|
406 | avg_data, nCohInt = self.pushData() | |
403 | self.nCohInt = nCohInt |
|
407 | self.nCohInt = nCohInt | |
404 | self.isReady = True |
|
408 | self.isReady = True | |
405 |
|
409 | |||
406 | return avg_data |
|
410 | return avg_data | |
407 |
|
411 | |||
408 | def exe(self, data, datatime=None): |
|
412 | def exe(self, data, datatime=None): | |
409 |
|
413 | |||
|
414 | ||||
|
415 | if self.firstdatatime == None or self.isReady: | |||
|
416 | self.firstdatatime = datatime | |||
|
417 | ||||
410 | if not self.__isByTime: |
|
418 | if not self.__isByTime: | |
411 | avg_data = self.byProfiles(data) |
|
419 | avg_data = self.byProfiles(data) | |
412 | else: |
|
420 | else: | |
413 | avg_data = self.byTime(data, datatime) |
|
421 | avg_data = self.byTime(data, datatime) | |
414 |
|
422 | |||
415 | self.data = avg_data |
|
423 | self.data = avg_data | |
416 |
|
424 | |||
|
425 | ||||
|
426 | ||||
417 | return avg_data |
|
427 | return avg_data | |
418 |
|
428 | |||
419 |
|
429 |
General Comments 0
You need to be logged in to leave comments.
Login now