@@ -1,227 +1,227 | |||||
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 = False |
|
43 | flagNoData = False | |
44 |
|
44 | |||
45 | flagTimeBlock = False |
|
45 | flagTimeBlock = False | |
46 |
|
46 | |||
47 | dataUtcTime = None |
|
47 | dataUtcTime = None | |
48 |
|
48 | |||
49 | nCode = None |
|
49 | nCode = None | |
50 |
|
50 | |||
51 | nBaud = None |
|
51 | nBaud = None | |
52 |
|
52 | |||
53 | code = None |
|
53 | code = None | |
54 |
|
54 | |||
55 | flagDecodeData = True #asumo q la data esta decodificada |
|
55 | flagDecodeData = True #asumo q la data esta decodificada | |
56 |
|
56 | |||
57 | flagDeflipData = True #asumo q la data esta sin flip |
|
57 | flagDeflipData = True #asumo q la data esta sin flip | |
58 |
|
58 | |||
59 | flagShiftFFT = False |
|
59 | flagShiftFFT = False | |
60 |
|
60 | |||
61 | ippSeconds = None |
|
61 | ippSeconds = None | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | def __init__(self): |
|
64 | def __init__(self): | |
65 |
|
65 | |||
66 | raise ValueError, "This class has not been implemented" |
|
66 | raise ValueError, "This class has not been implemented" | |
67 |
|
67 | |||
68 | def copy(self, inputObj=None): |
|
68 | def copy(self, inputObj=None): | |
69 |
|
69 | |||
70 | if inputObj == None: |
|
70 | if inputObj == None: | |
71 | return copy.deepcopy(self) |
|
71 | return copy.deepcopy(self) | |
72 |
|
72 | |||
73 | for key in inputObj.__dict__.keys(): |
|
73 | for key in inputObj.__dict__.keys(): | |
74 | self.__dict__[key] = inputObj.__dict__[key] |
|
74 | self.__dict__[key] = inputObj.__dict__[key] | |
75 |
|
75 | |||
76 | def deepcopy(self): |
|
76 | def deepcopy(self): | |
77 |
|
77 | |||
78 | return copy.deepcopy(self) |
|
78 | return copy.deepcopy(self) | |
79 |
|
79 | |||
80 | class Voltage(JROData): |
|
80 | class Voltage(JROData): | |
81 |
|
81 | |||
82 | nCohInt = None |
|
82 | nCohInt = None | |
83 |
|
83 | |||
84 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
84 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
85 | data = None |
|
85 | data = None | |
86 |
|
86 | |||
87 | def __init__(self): |
|
87 | def __init__(self): | |
88 | ''' |
|
88 | ''' | |
89 | Constructor |
|
89 | Constructor | |
90 | ''' |
|
90 | ''' | |
91 |
|
91 | |||
92 |
self. |
|
92 | self.radarControllerHeaderObj = RadarControllerHeader() | |
93 |
|
93 | |||
94 |
self. |
|
94 | self.systemHeaderObj = SystemHeader() | |
95 |
|
95 | |||
96 | self.type = "Voltage" |
|
96 | self.type = "Voltage" | |
97 |
|
97 | |||
98 | self.data = None |
|
98 | self.data = None | |
99 |
|
99 | |||
100 | self.dtype = None |
|
100 | self.dtype = None | |
101 |
|
101 | |||
102 | self.nChannels = 0 |
|
102 | self.nChannels = 0 | |
103 |
|
103 | |||
104 | self.nHeights = 0 |
|
104 | self.nHeights = 0 | |
105 |
|
105 | |||
106 | self.nProfiles = None |
|
106 | self.nProfiles = None | |
107 |
|
107 | |||
108 | self.heightList = None |
|
108 | self.heightList = None | |
109 |
|
109 | |||
110 | self.channelList = None |
|
110 | self.channelList = None | |
111 |
|
111 | |||
112 | self.channelIndexList = None |
|
112 | self.channelIndexList = None | |
113 |
|
113 | |||
114 | self.flagNoData = True |
|
114 | self.flagNoData = True | |
115 |
|
115 | |||
116 | self.flagTimeBlock = False |
|
116 | self.flagTimeBlock = False | |
117 |
|
117 | |||
118 | self.dataUtcTime = None |
|
118 | self.dataUtcTime = None | |
119 |
|
119 | |||
120 | self.nCohInt = None |
|
120 | self.nCohInt = None | |
121 |
|
121 | |||
122 | class Spectra(JROData): |
|
122 | class Spectra(JROData): | |
123 |
|
123 | |||
124 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
124 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
125 | data_spc = None |
|
125 | data_spc = None | |
126 |
|
126 | |||
127 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
127 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) | |
128 | data_cspc = None |
|
128 | data_cspc = None | |
129 |
|
129 | |||
130 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
130 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
131 | data_dc = None |
|
131 | data_dc = None | |
132 |
|
132 | |||
133 | nFFTPoints = None |
|
133 | nFFTPoints = None | |
134 |
|
134 | |||
135 | nPairs = None |
|
135 | nPairs = None | |
136 |
|
136 | |||
137 | pairsList = None |
|
137 | pairsList = None | |
138 |
|
138 | |||
139 | nIncohInt = None |
|
139 | nIncohInt = None | |
140 |
|
140 | |||
141 | def __init__(self): |
|
141 | def __init__(self): | |
142 | ''' |
|
142 | ''' | |
143 | Constructor |
|
143 | Constructor | |
144 | ''' |
|
144 | ''' | |
145 |
|
145 | |||
146 |
self. |
|
146 | self.radarControllerHeaderObj = RadarControllerHeader() | |
147 |
|
147 | |||
148 |
self. |
|
148 | self.systemHeaderObj = SystemHeader() | |
149 |
|
149 | |||
150 | self.type = "Spectra" |
|
150 | self.type = "Spectra" | |
151 |
|
151 | |||
152 | # self.data = None |
|
152 | # self.data = None | |
153 |
|
153 | |||
154 | self.dtype = None |
|
154 | self.dtype = None | |
155 |
|
155 | |||
156 | self.nChannels = 0 |
|
156 | self.nChannels = 0 | |
157 |
|
157 | |||
158 | self.nHeights = 0 |
|
158 | self.nHeights = 0 | |
159 |
|
159 | |||
160 | self.nProfiles = None |
|
160 | self.nProfiles = None | |
161 |
|
161 | |||
162 | self.heightList = None |
|
162 | self.heightList = None | |
163 |
|
163 | |||
164 | self.channelList = None |
|
164 | self.channelList = None | |
165 |
|
165 | |||
166 | self.channelIndexList = None |
|
166 | self.channelIndexList = None | |
167 |
|
167 | |||
168 | self.flagNoData = True |
|
168 | self.flagNoData = True | |
169 |
|
169 | |||
170 | self.flagTimeBlock = False |
|
170 | self.flagTimeBlock = False | |
171 |
|
171 | |||
172 | self.dataUtcTime = None |
|
172 | self.dataUtcTime = None | |
173 |
|
173 | |||
174 | self.nIncohInt = None |
|
174 | self.nIncohInt = None | |
175 |
|
175 | |||
176 |
|
176 | |||
177 | class SpectraHeis(JROData): |
|
177 | class SpectraHeis(JROData): | |
178 |
|
178 | |||
179 | data_spc = None |
|
179 | data_spc = None | |
180 |
|
180 | |||
181 | data_cspc = None |
|
181 | data_cspc = None | |
182 |
|
182 | |||
183 | data_dc = None |
|
183 | data_dc = None | |
184 |
|
184 | |||
185 | nFFTPoints = None |
|
185 | nFFTPoints = None | |
186 |
|
186 | |||
187 | nPairs = None |
|
187 | nPairs = None | |
188 |
|
188 | |||
189 | pairsList = None |
|
189 | pairsList = None | |
190 |
|
190 | |||
191 | def __init__(self): |
|
191 | def __init__(self): | |
192 |
|
192 | |||
193 |
self. |
|
193 | self.radarControllerHeaderObj = RadarControllerHeader() | |
194 |
|
194 | |||
195 |
self. |
|
195 | self.systemHeaderObj = SystemHeader() | |
196 |
|
196 | |||
197 | self.type = "SpectraHeis" |
|
197 | self.type = "SpectraHeis" | |
198 |
|
198 | |||
199 | self.dataType = None |
|
199 | self.dataType = None | |
200 |
|
200 | |||
201 | self.nHeights = 0 |
|
201 | self.nHeights = 0 | |
202 |
|
202 | |||
203 | self.nChannels = 0 |
|
203 | self.nChannels = 0 | |
204 |
|
204 | |||
205 | self.channelList = None |
|
205 | self.channelList = None | |
206 |
|
206 | |||
207 | self.heightList = None |
|
207 | self.heightList = None | |
208 |
|
208 | |||
209 | self.flagNoData = True |
|
209 | self.flagNoData = True | |
210 |
|
210 | |||
211 | self.flagResetProcessing = False |
|
211 | self.flagResetProcessing = False | |
212 |
|
212 | |||
213 |
|
213 | |||
214 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) |
|
214 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |
215 | self.data_spc = None |
|
215 | self.data_spc = None | |
216 |
|
216 | |||
217 | self.data_cspc = None |
|
217 | self.data_cspc = None | |
218 |
|
218 | |||
219 | self.data_dc = None |
|
219 | self.data_dc = None | |
220 |
|
220 | |||
221 | self.nFFTPoints = None |
|
221 | self.nFFTPoints = None | |
222 |
|
222 | |||
223 | self.nAvg = None |
|
223 | self.nAvg = None | |
224 |
|
224 | |||
225 | self.nPairs = 0 |
|
225 | self.nPairs = 0 | |
226 |
|
226 | |||
227 | self.pairsList = None |
|
227 | self.pairsList = None |
@@ -1,1211 +1,1211 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @autor $Author: dsuarez $ |
|
4 | @autor $Author: dsuarez $ | |
5 | @version $Id: BaseGraph.py 117 2012-09-04 21:16:59Z dsuarez $ |
|
5 | @version $Id: BaseGraph.py 117 2012-09-04 21:16:59Z dsuarez $ | |
6 |
|
6 | |||
7 | ''' |
|
7 | ''' | |
8 | #from __future__ import division |
|
8 | #from __future__ import division | |
9 | #import os |
|
9 | #import os | |
10 | import numpy |
|
10 | import numpy | |
11 | #import sys |
|
11 | #import sys | |
12 | import time |
|
12 | import time | |
13 | import datetime |
|
13 | import datetime | |
14 |
|
14 | |||
15 | #import plplot |
|
15 | #import plplot | |
16 | import matplotlib as mpl |
|
16 | import matplotlib as mpl | |
17 | mpl.use('TKAgg') |
|
17 | #mpl.use('TKAgg') | |
18 | import matplotlib.pyplot as plt |
|
18 | import matplotlib.pyplot as plt | |
19 |
|
19 | |||
20 | import scitools.numpyutils as sn |
|
20 | #import scitools.numpyutils as sn | |
21 |
|
21 | |||
22 | def cmap1_init(colormap='gray'): |
|
22 | def cmap1_init(colormap='gray'): | |
23 |
|
23 | |||
24 | # if colormap == None: |
|
24 | # if colormap == None: | |
25 | # return |
|
25 | # return | |
26 | # |
|
26 | # | |
27 | # ncolor = None |
|
27 | # ncolor = None | |
28 | # rgb_lvl = None |
|
28 | # rgb_lvl = None | |
29 | # |
|
29 | # | |
30 | # # Routine for defining a specific color map 1 in HLS space. |
|
30 | # # Routine for defining a specific color map 1 in HLS space. | |
31 | # # if gray is true, use basic grayscale variation from half-dark to light. |
|
31 | # # if gray is true, use basic grayscale variation from half-dark to light. | |
32 | # # otherwise use false color variation from blue (240 deg) to red (360 deg). |
|
32 | # # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
33 | # |
|
33 | # | |
34 | # # Independent variable of control points. |
|
34 | # # Independent variable of control points. | |
35 | # i = numpy.array((0., 1.)) |
|
35 | # i = numpy.array((0., 1.)) | |
36 | # if colormap=='gray': |
|
36 | # if colormap=='gray': | |
37 | # ncolor = 256 |
|
37 | # ncolor = 256 | |
38 | # # Hue for control points. Doesn't matter since saturation is zero. |
|
38 | # # Hue for control points. Doesn't matter since saturation is zero. | |
39 | # h = numpy.array((0., 0.)) |
|
39 | # h = numpy.array((0., 0.)) | |
40 | # # Lightness ranging from half-dark (for interest) to light. |
|
40 | # # Lightness ranging from half-dark (for interest) to light. | |
41 | # l = numpy.array((0.5, 1.)) |
|
41 | # l = numpy.array((0.5, 1.)) | |
42 | # # Gray scale has zero saturation |
|
42 | # # Gray scale has zero saturation | |
43 | # s = numpy.array((0., 0.)) |
|
43 | # s = numpy.array((0., 0.)) | |
44 | # |
|
44 | # | |
45 | # # number of cmap1 colours is 256 in this case. |
|
45 | # # number of cmap1 colours is 256 in this case. | |
46 | # plplot.plscmap1n(ncolor) |
|
46 | # plplot.plscmap1n(ncolor) | |
47 | # # Interpolate between control points to set up cmap1. |
|
47 | # # Interpolate between control points to set up cmap1. | |
48 | # plplot.plscmap1l(0, i, h, l, s) |
|
48 | # plplot.plscmap1l(0, i, h, l, s) | |
49 | # |
|
49 | # | |
50 | # return None |
|
50 | # return None | |
51 | # |
|
51 | # | |
52 | # if colormap == 'jet': |
|
52 | # if colormap == 'jet': | |
53 | # ncolor = 256 |
|
53 | # ncolor = 256 | |
54 | # pos = numpy.zeros((ncolor)) |
|
54 | # pos = numpy.zeros((ncolor)) | |
55 | # r = numpy.zeros((ncolor)) |
|
55 | # r = numpy.zeros((ncolor)) | |
56 | # g = numpy.zeros((ncolor)) |
|
56 | # g = numpy.zeros((ncolor)) | |
57 | # b = numpy.zeros((ncolor)) |
|
57 | # b = numpy.zeros((ncolor)) | |
58 | # |
|
58 | # | |
59 | # for i in range(ncolor): |
|
59 | # for i in range(ncolor): | |
60 | # if(i <= 35.0/100*(ncolor-1)): rf = 0.0 |
|
60 | # if(i <= 35.0/100*(ncolor-1)): rf = 0.0 | |
61 | # elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31 |
|
61 | # elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31 | |
62 | # elif (i <= 89.0/100*(ncolor-1)): rf = 1.0 |
|
62 | # elif (i <= 89.0/100*(ncolor-1)): rf = 1.0 | |
63 | # else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22 |
|
63 | # else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22 | |
64 | # |
|
64 | # | |
65 | # if(i <= 12.0/100*(ncolor-1)): gf = 0.0 |
|
65 | # if(i <= 12.0/100*(ncolor-1)): gf = 0.0 | |
66 | # elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26 |
|
66 | # elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26 | |
67 | # elif(i <= 64.0/100*(ncolor-1)): gf = 1.0 |
|
67 | # elif(i <= 64.0/100*(ncolor-1)): gf = 1.0 | |
68 | # elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27 |
|
68 | # elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27 | |
69 | # else: gf = 0.0 |
|
69 | # else: gf = 0.0 | |
70 | # |
|
70 | # | |
71 | # if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5 |
|
71 | # if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5 | |
72 | # elif(i <= 34.0/100*(ncolor-1)): bf = 1.0 |
|
72 | # elif(i <= 34.0/100*(ncolor-1)): bf = 1.0 | |
73 | # elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31 |
|
73 | # elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31 | |
74 | # else: bf = 0 |
|
74 | # else: bf = 0 | |
75 | # |
|
75 | # | |
76 | # r[i] = rf |
|
76 | # r[i] = rf | |
77 | # g[i] = gf |
|
77 | # g[i] = gf | |
78 | # b[i] = bf |
|
78 | # b[i] = bf | |
79 | # |
|
79 | # | |
80 | # pos[i] = float(i)/float(ncolor-1) |
|
80 | # pos[i] = float(i)/float(ncolor-1) | |
81 | # |
|
81 | # | |
82 | # |
|
82 | # | |
83 | # plplot.plscmap1n(ncolor) |
|
83 | # plplot.plscmap1n(ncolor) | |
84 | # plplot.plscmap1l(1, pos, r, g, b) |
|
84 | # plplot.plscmap1l(1, pos, r, g, b) | |
85 | # |
|
85 | # | |
86 | # |
|
86 | # | |
87 | # |
|
87 | # | |
88 | # if colormap=='br_green': |
|
88 | # if colormap=='br_green': | |
89 | # ncolor = 256 |
|
89 | # ncolor = 256 | |
90 | # # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
90 | # # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
91 | # h = numpy.array((240., 0.)) |
|
91 | # h = numpy.array((240., 0.)) | |
92 | # # Lightness and saturation are constant (values taken from C example). |
|
92 | # # Lightness and saturation are constant (values taken from C example). | |
93 | # l = numpy.array((0.6, 0.6)) |
|
93 | # l = numpy.array((0.6, 0.6)) | |
94 | # s = numpy.array((0.8, 0.8)) |
|
94 | # s = numpy.array((0.8, 0.8)) | |
95 | # |
|
95 | # | |
96 | # # number of cmap1 colours is 256 in this case. |
|
96 | # # number of cmap1 colours is 256 in this case. | |
97 | # plplot.plscmap1n(ncolor) |
|
97 | # plplot.plscmap1n(ncolor) | |
98 | # # Interpolate between control points to set up cmap1. |
|
98 | # # Interpolate between control points to set up cmap1. | |
99 | # plplot.plscmap1l(0, i, h, l, s) |
|
99 | # plplot.plscmap1l(0, i, h, l, s) | |
100 | # |
|
100 | # | |
101 | # return None |
|
101 | # return None | |
102 | # |
|
102 | # | |
103 | # if colormap=='tricolor': |
|
103 | # if colormap=='tricolor': | |
104 | # ncolor = 3 |
|
104 | # ncolor = 3 | |
105 | # # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
105 | # # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
106 | # h = numpy.array((240., 0.)) |
|
106 | # h = numpy.array((240., 0.)) | |
107 | # # Lightness and saturation are constant (values taken from C example). |
|
107 | # # Lightness and saturation are constant (values taken from C example). | |
108 | # l = numpy.array((0.6, 0.6)) |
|
108 | # l = numpy.array((0.6, 0.6)) | |
109 | # s = numpy.array((0.8, 0.8)) |
|
109 | # s = numpy.array((0.8, 0.8)) | |
110 | # |
|
110 | # | |
111 | # # number of cmap1 colours is 256 in this case. |
|
111 | # # number of cmap1 colours is 256 in this case. | |
112 | # plplot.plscmap1n(ncolor) |
|
112 | # plplot.plscmap1n(ncolor) | |
113 | # # Interpolate between control points to set up cmap1. |
|
113 | # # Interpolate between control points to set up cmap1. | |
114 | # plplot.plscmap1l(0, i, h, l, s) |
|
114 | # plplot.plscmap1l(0, i, h, l, s) | |
115 | # |
|
115 | # | |
116 | # return None |
|
116 | # return None | |
117 | # |
|
117 | # | |
118 | # if colormap == 'rgb' or colormap == 'rgb666': |
|
118 | # if colormap == 'rgb' or colormap == 'rgb666': | |
119 | # |
|
119 | # | |
120 | # color_sz = 6 |
|
120 | # color_sz = 6 | |
121 | # ncolor = color_sz*color_sz*color_sz |
|
121 | # ncolor = color_sz*color_sz*color_sz | |
122 | # pos = numpy.zeros((ncolor)) |
|
122 | # pos = numpy.zeros((ncolor)) | |
123 | # r = numpy.zeros((ncolor)) |
|
123 | # r = numpy.zeros((ncolor)) | |
124 | # g = numpy.zeros((ncolor)) |
|
124 | # g = numpy.zeros((ncolor)) | |
125 | # b = numpy.zeros((ncolor)) |
|
125 | # b = numpy.zeros((ncolor)) | |
126 | # ind = 0 |
|
126 | # ind = 0 | |
127 | # for ri in range(color_sz): |
|
127 | # for ri in range(color_sz): | |
128 | # for gi in range(color_sz): |
|
128 | # for gi in range(color_sz): | |
129 | # for bi in range(color_sz): |
|
129 | # for bi in range(color_sz): | |
130 | # r[ind] = ri/(color_sz-1.0) |
|
130 | # r[ind] = ri/(color_sz-1.0) | |
131 | # g[ind] = gi/(color_sz-1.0) |
|
131 | # g[ind] = gi/(color_sz-1.0) | |
132 | # b[ind] = bi/(color_sz-1.0) |
|
132 | # b[ind] = bi/(color_sz-1.0) | |
133 | # pos[ind] = ind/(ncolor-1.0) |
|
133 | # pos[ind] = ind/(ncolor-1.0) | |
134 | # ind += 1 |
|
134 | # ind += 1 | |
135 | # rgb_lvl = [6,6,6] #Levels for RGB colors |
|
135 | # rgb_lvl = [6,6,6] #Levels for RGB colors | |
136 | # |
|
136 | # | |
137 | # if colormap == 'rgb676': |
|
137 | # if colormap == 'rgb676': | |
138 | # ncolor = 6*7*6 |
|
138 | # ncolor = 6*7*6 | |
139 | # pos = numpy.zeros((ncolor)) |
|
139 | # pos = numpy.zeros((ncolor)) | |
140 | # r = numpy.zeros((ncolor)) |
|
140 | # r = numpy.zeros((ncolor)) | |
141 | # g = numpy.zeros((ncolor)) |
|
141 | # g = numpy.zeros((ncolor)) | |
142 | # b = numpy.zeros((ncolor)) |
|
142 | # b = numpy.zeros((ncolor)) | |
143 | # ind = 0 |
|
143 | # ind = 0 | |
144 | # for ri in range(8): |
|
144 | # for ri in range(8): | |
145 | # for gi in range(8): |
|
145 | # for gi in range(8): | |
146 | # for bi in range(4): |
|
146 | # for bi in range(4): | |
147 | # r[ind] = ri/(6-1.0) |
|
147 | # r[ind] = ri/(6-1.0) | |
148 | # g[ind] = gi/(7-1.0) |
|
148 | # g[ind] = gi/(7-1.0) | |
149 | # b[ind] = bi/(6-1.0) |
|
149 | # b[ind] = bi/(6-1.0) | |
150 | # pos[ind] = ind/(ncolor-1.0) |
|
150 | # pos[ind] = ind/(ncolor-1.0) | |
151 | # ind += 1 |
|
151 | # ind += 1 | |
152 | # rgb_lvl = [6,7,6] #Levels for RGB colors |
|
152 | # rgb_lvl = [6,7,6] #Levels for RGB colors | |
153 | # |
|
153 | # | |
154 | # if colormap == 'rgb685': |
|
154 | # if colormap == 'rgb685': | |
155 | # ncolor = 6*8*5 |
|
155 | # ncolor = 6*8*5 | |
156 | # pos = numpy.zeros((ncolor)) |
|
156 | # pos = numpy.zeros((ncolor)) | |
157 | # r = numpy.zeros((ncolor)) |
|
157 | # r = numpy.zeros((ncolor)) | |
158 | # g = numpy.zeros((ncolor)) |
|
158 | # g = numpy.zeros((ncolor)) | |
159 | # b = numpy.zeros((ncolor)) |
|
159 | # b = numpy.zeros((ncolor)) | |
160 | # ind = 0 |
|
160 | # ind = 0 | |
161 | # for ri in range(8): |
|
161 | # for ri in range(8): | |
162 | # for gi in range(8): |
|
162 | # for gi in range(8): | |
163 | # for bi in range(4): |
|
163 | # for bi in range(4): | |
164 | # r[ind] = ri/(6-1.0) |
|
164 | # r[ind] = ri/(6-1.0) | |
165 | # g[ind] = gi/(8-1.0) |
|
165 | # g[ind] = gi/(8-1.0) | |
166 | # b[ind] = bi/(5-1.0) |
|
166 | # b[ind] = bi/(5-1.0) | |
167 | # pos[ind] = ind/(ncolor-1.0) |
|
167 | # pos[ind] = ind/(ncolor-1.0) | |
168 | # ind += 1 |
|
168 | # ind += 1 | |
169 | # rgb_lvl = [6,8,5] #Levels for RGB colors |
|
169 | # rgb_lvl = [6,8,5] #Levels for RGB colors | |
170 | # |
|
170 | # | |
171 | # if colormap == 'rgb884': |
|
171 | # if colormap == 'rgb884': | |
172 | # ncolor = 8*8*4 |
|
172 | # ncolor = 8*8*4 | |
173 | # pos = numpy.zeros((ncolor)) |
|
173 | # pos = numpy.zeros((ncolor)) | |
174 | # r = numpy.zeros((ncolor)) |
|
174 | # r = numpy.zeros((ncolor)) | |
175 | # g = numpy.zeros((ncolor)) |
|
175 | # g = numpy.zeros((ncolor)) | |
176 | # b = numpy.zeros((ncolor)) |
|
176 | # b = numpy.zeros((ncolor)) | |
177 | # ind = 0 |
|
177 | # ind = 0 | |
178 | # for ri in range(8): |
|
178 | # for ri in range(8): | |
179 | # for gi in range(8): |
|
179 | # for gi in range(8): | |
180 | # for bi in range(4): |
|
180 | # for bi in range(4): | |
181 | # r[ind] = ri/(8-1.0) |
|
181 | # r[ind] = ri/(8-1.0) | |
182 | # g[ind] = gi/(8-1.0) |
|
182 | # g[ind] = gi/(8-1.0) | |
183 | # b[ind] = bi/(4-1.0) |
|
183 | # b[ind] = bi/(4-1.0) | |
184 | # pos[ind] = ind/(ncolor-1.0) |
|
184 | # pos[ind] = ind/(ncolor-1.0) | |
185 | # ind += 1 |
|
185 | # ind += 1 | |
186 | # rgb_lvl = [8,8,4] #Levels for RGB colors |
|
186 | # rgb_lvl = [8,8,4] #Levels for RGB colors | |
187 | # |
|
187 | # | |
188 | # if ncolor == None: |
|
188 | # if ncolor == None: | |
189 | # raise ValueError, 'The colormap selected is not valid' |
|
189 | # raise ValueError, 'The colormap selected is not valid' | |
190 | # |
|
190 | # | |
191 | # plplot.plscmap1n(ncolor) |
|
191 | # plplot.plscmap1n(ncolor) | |
192 | # plplot.plscmap1l(1, pos, r, g, b) |
|
192 | # plplot.plscmap1l(1, pos, r, g, b) | |
193 | # |
|
193 | # | |
194 | # return rgb_lvl |
|
194 | # return rgb_lvl | |
195 | pass |
|
195 | pass | |
196 |
|
196 | |||
197 | def setColormap(colormap='jet'): |
|
197 | def setColormap(colormap='jet'): | |
198 | # cmap1_init(colormap) |
|
198 | # cmap1_init(colormap) | |
199 | pass |
|
199 | pass | |
200 |
|
200 | |||
201 | def savePlplot(filename,width,height): |
|
201 | def savePlplot(filename,width,height): | |
202 | # curr_strm = plplot.plgstrm() |
|
202 | # curr_strm = plplot.plgstrm() | |
203 | # save_strm = plplot.plmkstrm() |
|
203 | # save_strm = plplot.plmkstrm() | |
204 | # plplot.plsetopt('geometry', '%dx%d'%(width,height)) |
|
204 | # plplot.plsetopt('geometry', '%dx%d'%(width,height)) | |
205 | # plplot.plsdev('png') |
|
205 | # plplot.plsdev('png') | |
206 | # plplot.plsfnam(filename) |
|
206 | # plplot.plsfnam(filename) | |
207 | # plplot.plcpstrm(curr_strm,0) |
|
207 | # plplot.plcpstrm(curr_strm,0) | |
208 | # plplot.plreplot() |
|
208 | # plplot.plreplot() | |
209 | # plplot.plend1() |
|
209 | # plplot.plend1() | |
210 | # plplot.plsstrm(curr_strm) |
|
210 | # plplot.plsstrm(curr_strm) | |
211 | pass |
|
211 | pass | |
212 |
|
212 | |||
213 | def initMatplotlib(indexFig,ncol,nrow,winTitle,width,height): |
|
213 | def initMatplotlib(indexFig,ncol,nrow,winTitle,width,height): | |
214 |
|
214 | |||
215 | plt.ioff() |
|
215 | plt.ioff() | |
216 | fig = plt.figure(indexFig) |
|
216 | fig = plt.figure(indexFig) | |
217 | fig.canvas.manager.set_window_title(winTitle) |
|
217 | fig.canvas.manager.set_window_title(winTitle) | |
218 | fig.canvas.manager.resize(width,height) |
|
218 | fig.canvas.manager.resize(width,height) | |
219 | # fig.add_subplot(nrow,ncol,1) |
|
219 | # fig.add_subplot(nrow,ncol,1) | |
220 | plt.ion() |
|
220 | plt.ion() | |
221 |
|
221 | |||
222 | def setNewPage(): |
|
222 | def setNewPage(): | |
223 | # plplot.plbop() |
|
223 | # plplot.plbop() | |
224 | # plplot.pladv(0) |
|
224 | # plplot.pladv(0) | |
225 | plt.clf() |
|
225 | plt.clf() | |
226 |
|
226 | |||
227 | def closePage(): |
|
227 | def closePage(): | |
228 | # plplot.pleop() |
|
228 | # plplot.pleop() | |
229 | pass |
|
229 | pass | |
230 |
|
230 | |||
231 | def clearData(objGraph): |
|
231 | def clearData(objGraph): | |
232 | objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], 'bc', 'bc') |
|
232 | objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], 'bc', 'bc') | |
233 |
|
233 | |||
234 | objGraph.setColor(15) #Setting Line Color to White |
|
234 | objGraph.setColor(15) #Setting Line Color to White | |
235 |
|
235 | |||
236 | if objGraph.datatype == 'complex': |
|
236 | if objGraph.datatype == 'complex': | |
237 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real) |
|
237 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real) | |
238 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag) |
|
238 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag) | |
239 |
|
239 | |||
240 | if objGraph.datatype == 'real': |
|
240 | if objGraph.datatype == 'real': | |
241 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata) |
|
241 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata) | |
242 |
|
242 | |||
243 | objGraph.setColor(1) #Setting Line Color to Black |
|
243 | objGraph.setColor(1) #Setting Line Color to Black | |
244 | # objGraph.setLineStyle(2) |
|
244 | # objGraph.setLineStyle(2) | |
245 | # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], 'bcntg', 'bc') |
|
245 | # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], 'bcntg', 'bc') | |
246 | # objGraph.setLineStyle(1) |
|
246 | # objGraph.setLineStyle(1) | |
247 |
|
247 | |||
248 | def setFigure(indexFig): |
|
248 | def setFigure(indexFig): | |
249 | # plplot.plsstrm(indexFig) |
|
249 | # plplot.plsstrm(indexFig) | |
250 | plt.figure(indexFig) |
|
250 | plt.figure(indexFig) | |
251 |
|
251 | |||
252 | def refresh(): |
|
252 | def refresh(): | |
253 | # plplot.refresh() |
|
253 | # plplot.refresh() | |
254 | plt.draw() |
|
254 | plt.draw() | |
255 |
|
255 | |||
256 | def show(): |
|
256 | def show(): | |
257 | # plplot.plspause(True) |
|
257 | # plplot.plspause(True) | |
258 | # plplot.plend() |
|
258 | # plplot.plend() | |
259 | plt.ioff() |
|
259 | plt.ioff() | |
260 | plt.show() |
|
260 | plt.show() | |
261 | plt.ion() |
|
261 | plt.ion() | |
262 |
|
262 | |||
263 | def setPlTitle(pltitle,color, szchar=0.7): |
|
263 | def setPlTitle(pltitle,color, szchar=0.7): | |
264 | # setSubpages(1, 0) |
|
264 | # setSubpages(1, 0) | |
265 | # plplot.pladv(0) |
|
265 | # plplot.pladv(0) | |
266 | # plplot.plvpor(0., 1., 0., 1.) |
|
266 | # plplot.plvpor(0., 1., 0., 1.) | |
267 | # |
|
267 | # | |
268 | # if color == 'black': |
|
268 | # if color == 'black': | |
269 | # plplot.plcol0(1) |
|
269 | # plplot.plcol0(1) | |
270 | # if color == 'white': |
|
270 | # if color == 'white': | |
271 | # plplot.plcol0(15) |
|
271 | # plplot.plcol0(15) | |
272 | # |
|
272 | # | |
273 | # plplot.plschr(0.0,szchar) |
|
273 | # plplot.plschr(0.0,szchar) | |
274 | # plplot.plmtex('t',-1., 0.5, 0.5, pltitle) |
|
274 | # plplot.plmtex('t',-1., 0.5, 0.5, pltitle) | |
275 | pass |
|
275 | pass | |
276 |
|
276 | |||
277 | def setSubpages(ncol,nrow): |
|
277 | def setSubpages(ncol,nrow): | |
278 | # plplot.plssub(ncol,nrow) |
|
278 | # plplot.plssub(ncol,nrow) | |
279 | pass |
|
279 | pass | |
280 |
|
280 | |||
281 | class BaseGraph: |
|
281 | class BaseGraph: | |
282 |
|
282 | |||
283 | __name = None |
|
283 | __name = None | |
284 | __xpos = None |
|
284 | __xpos = None | |
285 | __ypos = None |
|
285 | __ypos = None | |
286 | __subplot = None |
|
286 | __subplot = None | |
287 | __xg = None |
|
287 | __xg = None | |
288 | __yg = None |
|
288 | __yg = None | |
289 | __axesId = None |
|
289 | __axesId = None | |
290 | xdata = None |
|
290 | xdata = None | |
291 | ydata = None |
|
291 | ydata = None | |
292 | getGrid = True |
|
292 | getGrid = True | |
293 | xaxisIsTime = False |
|
293 | xaxisIsTime = False | |
294 | deltax = None |
|
294 | deltax = None | |
295 | xmin = None |
|
295 | xmin = None | |
296 | xmax = None |
|
296 | xmax = None | |
297 |
|
297 | |||
298 | def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0): |
|
298 | def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0): | |
299 |
|
299 | |||
300 | self.setName(name) |
|
300 | self.setName(name) | |
301 | self.setScreenPos(xpos, ypos) |
|
301 | self.setScreenPos(xpos, ypos) | |
302 | self.setSubPlot(subplot) |
|
302 | self.setSubPlot(subplot) | |
303 | self.setXYZrange(xrange,yrange,zrange) |
|
303 | self.setXYZrange(xrange,yrange,zrange) | |
304 | self.setSizeOfChar(szchar) |
|
304 | self.setSizeOfChar(szchar) | |
305 | self.setLabels(xlabel,ylabel,title) |
|
305 | self.setLabels(xlabel,ylabel,title) | |
306 | self.getGrid = True |
|
306 | self.getGrid = True | |
307 | self.xaxisIsTime = False |
|
307 | self.xaxisIsTime = False | |
308 | self.deltax = deltax |
|
308 | self.deltax = deltax | |
309 | pass |
|
309 | pass | |
310 |
|
310 | |||
311 | def makeAxes(self,indexFig,nrow,ncol,subplot): |
|
311 | def makeAxes(self,indexFig,nrow,ncol,subplot): | |
312 | fig = plt.figure(indexFig) |
|
312 | fig = plt.figure(indexFig) | |
313 | self.__axesId = fig.add_subplot(nrow,ncol,subplot) |
|
313 | self.__axesId = fig.add_subplot(nrow,ncol,subplot) | |
314 |
|
314 | |||
315 | def setParentAxesId(self,parent): |
|
315 | def setParentAxesId(self,parent): | |
316 | self.__axesId = parent.__axesId |
|
316 | self.__axesId = parent.__axesId | |
317 |
|
317 | |||
318 | def setName(self, name): |
|
318 | def setName(self, name): | |
319 | self.__name = name |
|
319 | self.__name = name | |
320 |
|
320 | |||
321 | def setScreenPos(self,xpos,ypos): |
|
321 | def setScreenPos(self,xpos,ypos): | |
322 | self.__xpos = xpos |
|
322 | self.__xpos = xpos | |
323 | self.__ypos = ypos |
|
323 | self.__ypos = ypos | |
324 |
|
324 | |||
325 | def setSubPlot(self,subplot): |
|
325 | def setSubPlot(self,subplot): | |
326 | self.__subplot = subplot |
|
326 | self.__subplot = subplot | |
327 |
|
327 | |||
328 | def setXYZrange(self,xrange,yrange,zrange): |
|
328 | def setXYZrange(self,xrange,yrange,zrange): | |
329 | self.xrange = xrange |
|
329 | self.xrange = xrange | |
330 | self.yrange = yrange |
|
330 | self.yrange = yrange | |
331 | self.zrange = zrange |
|
331 | self.zrange = zrange | |
332 |
|
332 | |||
333 | def setSizeOfChar(self,szchar): |
|
333 | def setSizeOfChar(self,szchar): | |
334 | self.__szchar = szchar |
|
334 | self.__szchar = szchar | |
335 |
|
335 | |||
336 | def setLabels(self,xlabel=None,ylabel=None,title=None): |
|
336 | def setLabels(self,xlabel=None,ylabel=None,title=None): | |
337 | if xlabel != None: self.xlabel = xlabel |
|
337 | if xlabel != None: self.xlabel = xlabel | |
338 | if ylabel != None: self.ylabel = ylabel |
|
338 | if ylabel != None: self.ylabel = ylabel | |
339 | if title != None: self.title = title |
|
339 | if title != None: self.title = title | |
340 |
|
340 | |||
341 | def setXYData(self,xdata=None,ydata=None,datatype='real'): |
|
341 | def setXYData(self,xdata=None,ydata=None,datatype='real'): | |
342 | if ((xdata != None) and (ydata != None)): |
|
342 | if ((xdata != None) and (ydata != None)): | |
343 | self.xdata = xdata |
|
343 | self.xdata = xdata | |
344 | self.ydata = ydata |
|
344 | self.ydata = ydata | |
345 | self.datatype = datatype |
|
345 | self.datatype = datatype | |
346 | if ((self.xdata == None) and (self.ydata == None)): |
|
346 | if ((self.xdata == None) and (self.ydata == None)): | |
347 | return None |
|
347 | return None | |
348 | return 1 |
|
348 | return 1 | |
349 |
|
349 | |||
350 | def setLineStyle(self, style): |
|
350 | def setLineStyle(self, style): | |
351 | # plplot.pllsty(style) |
|
351 | # plplot.pllsty(style) | |
352 | pass |
|
352 | pass | |
353 |
|
353 | |||
354 | def setColor(self, color): |
|
354 | def setColor(self, color): | |
355 | # plplot.plcol0(color) |
|
355 | # plplot.plcol0(color) | |
356 | pass |
|
356 | pass | |
357 |
|
357 | |||
358 | def setXAxisAsTime(self, value=False): |
|
358 | def setXAxisAsTime(self, value=False): | |
359 | self.xaxisIsTime = value |
|
359 | self.xaxisIsTime = value | |
360 |
|
360 | |||
361 | def basicLineTimePlot(self, x, y, colline=1): |
|
361 | def basicLineTimePlot(self, x, y, colline=1): | |
362 | # plplot.plcol0(colline) |
|
362 | # plplot.plcol0(colline) | |
363 | # plplot.plline(x, y) |
|
363 | # plplot.plline(x, y) | |
364 | # plplot.plcol0(1) |
|
364 | # plplot.plcol0(1) | |
365 | ax = self.__axesId |
|
365 | ax = self.__axesId | |
366 | if self.setXYData() == None: |
|
366 | if self.setXYData() == None: | |
367 | ax.plot(x,y) |
|
367 | ax.plot(x,y) | |
368 | else: |
|
368 | else: | |
369 | ax.lines[0].set_data(x,y) |
|
369 | ax.lines[0].set_data(x,y) | |
370 |
|
370 | |||
371 | def basicXYPlot(self, x, y): |
|
371 | def basicXYPlot(self, x, y): | |
372 | # plplot.plline(x, y) |
|
372 | # plplot.plline(x, y) | |
373 | ax = self.__axesId |
|
373 | ax = self.__axesId | |
374 | if self.setXYData() == None: |
|
374 | if self.setXYData() == None: | |
375 | ax.plot(x,y) |
|
375 | ax.plot(x,y) | |
376 | else: |
|
376 | else: | |
377 | ax.lines[0].set_data(x,y) |
|
377 | ax.lines[0].set_data(x,y) | |
378 |
|
378 | |||
379 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
379 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
380 | # |
|
380 | # | |
381 | # if xmin == None: xmin = x[0] |
|
381 | # if xmin == None: xmin = x[0] | |
382 | # if xmax == None: xmax = x[-1] |
|
382 | # if xmax == None: xmax = x[-1] | |
383 | # if ymin == None: ymin = y[0] |
|
383 | # if ymin == None: ymin = y[0] | |
384 | # if ymax == None: ymax = y[-1] |
|
384 | # if ymax == None: ymax = y[-1] | |
385 | # if zmin == None: zmin = numpy.nanmin(data) |
|
385 | # if zmin == None: zmin = numpy.nanmin(data) | |
386 | # if zmax == None: zmax = numpy.nanmax(data) |
|
386 | # if zmax == None: zmax = numpy.nanmax(data) | |
387 | # |
|
387 | # | |
388 | # plplot.plimage(data, |
|
388 | # plplot.plimage(data, | |
389 | # float(x[0]), |
|
389 | # float(x[0]), | |
390 | # float(x[-1]), |
|
390 | # float(x[-1]), | |
391 | # float(y[0]), |
|
391 | # float(y[0]), | |
392 | # float(y[-1]), |
|
392 | # float(y[-1]), | |
393 | # float(zmin), |
|
393 | # float(zmin), | |
394 | # float(zmax), |
|
394 | # float(zmax), | |
395 | # float(xmin), |
|
395 | # float(xmin), | |
396 | # float(xmax), |
|
396 | # float(xmax), | |
397 | # float(ymin), |
|
397 | # float(ymin), | |
398 | # float(ymax) |
|
398 | # float(ymax) | |
399 | # ) |
|
399 | # ) | |
400 | pass |
|
400 | pass | |
401 |
|
401 | |||
402 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): |
|
402 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |
403 |
|
403 | |||
404 | # if not(len(x)>0 and len(y)>0): |
|
404 | # if not(len(x)>0 and len(y)>0): | |
405 | # raise ValueError, 'x axis and y axis are empty' |
|
405 | # raise ValueError, 'x axis and y axis are empty' | |
406 | # |
|
406 | # | |
407 | # if deltax == None: deltax = x[-1] - x[-2] |
|
407 | # if deltax == None: deltax = x[-1] - x[-2] | |
408 | # if deltay == None: deltay = y[-1] - y[-2] |
|
408 | # if deltay == None: deltay = y[-1] - y[-2] | |
409 | # |
|
409 | # | |
410 | # x1 = numpy.append(x, x[-1] + deltax) |
|
410 | # x1 = numpy.append(x, x[-1] + deltax) | |
411 | # y1 = numpy.append(y, y[-1] + deltay) |
|
411 | # y1 = numpy.append(y, y[-1] + deltay) | |
412 | # |
|
412 | # | |
413 | # xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) |
|
413 | # xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |
414 | # yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) |
|
414 | # yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |
415 | # |
|
415 | # | |
416 | # self.__xg = xg |
|
416 | # self.__xg = xg | |
417 | # self.__yg = yg |
|
417 | # self.__yg = yg | |
418 | # |
|
418 | # | |
419 | # return xg, yg |
|
419 | # return xg, yg | |
420 | pass |
|
420 | pass | |
421 |
|
421 | |||
422 | def advPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0., deltax=1.0, deltay=None, getGrid = True): |
|
422 | def advPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0., deltax=1.0, deltay=None, getGrid = True): | |
423 | # if getGrid: |
|
423 | # if getGrid: | |
424 | # xg, yg = self.__getBoxpltr(x, y, deltax, deltay) |
|
424 | # xg, yg = self.__getBoxpltr(x, y, deltax, deltay) | |
425 | # else: |
|
425 | # else: | |
426 | # xg = self.__xg |
|
426 | # xg = self.__xg | |
427 | # yg = self.__yg |
|
427 | # yg = self.__yg | |
428 | # |
|
428 | # | |
429 | # plplot.plimagefr(data, |
|
429 | # plplot.plimagefr(data, | |
430 | # float(xmin), |
|
430 | # float(xmin), | |
431 | # float(xmax), |
|
431 | # float(xmax), | |
432 | # float(ymin), |
|
432 | # float(ymin), | |
433 | # float(ymax), |
|
433 | # float(ymax), | |
434 | # 0., |
|
434 | # 0., | |
435 | # 0., |
|
435 | # 0., | |
436 | # float(zmin), |
|
436 | # float(zmin), | |
437 | # float(zmax), |
|
437 | # float(zmax), | |
438 | # plplot.pltr2, |
|
438 | # plplot.pltr2, | |
439 | # xg, |
|
439 | # xg, | |
440 | # yg) |
|
440 | # yg) | |
441 |
|
441 | |||
442 | ax = self.__axesId |
|
442 | ax = self.__axesId | |
443 | # if self.setXYData() == None: |
|
443 | # if self.setXYData() == None: | |
444 | ax.pcolormesh(x,y,data.T,vmin=zmin,vmax=zmax) |
|
444 | ax.pcolormesh(x,y,data.T,vmin=zmin,vmax=zmax) | |
445 | # else: |
|
445 | # else: | |
446 | # ax.lines[0].set_data(x,y) |
|
446 | # ax.lines[0].set_data(x,y) | |
447 |
|
447 | |||
448 |
|
448 | |||
449 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): |
|
449 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): | |
450 | # data = numpy.arange(256) |
|
450 | # data = numpy.arange(256) | |
451 | # data = numpy.reshape(data, (1,-1)) |
|
451 | # data = numpy.reshape(data, (1,-1)) | |
452 | # plplot.plimage(data, |
|
452 | # plplot.plimage(data, | |
453 | # float(xmin), |
|
453 | # float(xmin), | |
454 | # float(xmax), |
|
454 | # float(xmax), | |
455 | # float(ymin), |
|
455 | # float(ymin), | |
456 | # float(ymax), |
|
456 | # float(ymax), | |
457 | # 0., |
|
457 | # 0., | |
458 | # 255., |
|
458 | # 255., | |
459 | # float(xmin), |
|
459 | # float(xmin), | |
460 | # float(xmax), |
|
460 | # float(xmax), | |
461 | # float(ymin), |
|
461 | # float(ymin), | |
462 | # float(ymax)) |
|
462 | # float(ymax)) | |
463 | ax = self.__axesId |
|
463 | ax = self.__axesId | |
464 | cax, kw = mpl.colorbar.make_axes(ax) |
|
464 | cax, kw = mpl.colorbar.make_axes(ax) | |
465 | norm = mpl.colors.Normalize(vmin=ymin, vmax=ymax) |
|
465 | norm = mpl.colors.Normalize(vmin=ymin, vmax=ymax) | |
466 | cb = mpl.colorbar.ColorbarBase(cax,norm=norm,**kw) |
|
466 | cb = mpl.colorbar.ColorbarBase(cax,norm=norm,**kw) | |
467 | self.__colorbarId = cb |
|
467 | self.__colorbarId = cb | |
468 | cb.set_label(self.title) |
|
468 | cb.set_label(self.title) | |
469 |
|
469 | |||
470 | def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False): |
|
470 | def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False): | |
471 |
|
471 | |||
472 | # plplot.plschr(0.0,self.__szchar-0.05) |
|
472 | # plplot.plschr(0.0,self.__szchar-0.05) | |
473 | # plplot.pladv(self.__subplot) |
|
473 | # plplot.pladv(self.__subplot) | |
474 | # plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
474 | # plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
475 | # plplot.plwind(float(xmin), # self.xrange[0] |
|
475 | # plplot.plwind(float(xmin), # self.xrange[0] | |
476 | # float(xmax), # self.xrange[1] |
|
476 | # float(xmax), # self.xrange[1] | |
477 | # float(ymin), # self.yrange[0] |
|
477 | # float(ymin), # self.yrange[0] | |
478 | # float(ymax) # self.yrange[1] |
|
478 | # float(ymax) # self.yrange[1] | |
479 | # ) |
|
479 | # ) | |
480 | # |
|
480 | # | |
481 | # |
|
481 | # | |
482 | # |
|
482 | # | |
483 | # if self.xaxisIsTime: |
|
483 | # if self.xaxisIsTime: | |
484 | # plplot.pltimefmt('%H:%M') |
|
484 | # plplot.pltimefmt('%H:%M') | |
485 | # timedelta = (xmax - xmin + 1)/8. |
|
485 | # timedelta = (xmax - xmin + 1)/8. | |
486 | # plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0) |
|
486 | # plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0) | |
487 | # else: |
|
487 | # else: | |
488 | # plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) |
|
488 | # plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) | |
489 | # |
|
489 | # | |
490 | # |
|
490 | # | |
491 | # if not(nolabels): |
|
491 | # if not(nolabels): | |
492 | # plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
492 | # plplot.pllab(self.xlabel, self.ylabel, self.title) | |
493 |
|
493 | |||
494 | ax = self.__axesId |
|
494 | ax = self.__axesId | |
495 | ax.set_xlim([xmin,xmax]) |
|
495 | ax.set_xlim([xmin,xmax]) | |
496 | ax.set_ylim([ymin,ymax]) |
|
496 | ax.set_ylim([ymin,ymax]) | |
497 |
|
497 | |||
498 | if not(nolabels): |
|
498 | if not(nolabels): | |
499 | ax.set_xlabel(self.xlabel) |
|
499 | ax.set_xlabel(self.xlabel) | |
500 | ax.set_ylabel(self.ylabel) |
|
500 | ax.set_ylabel(self.ylabel) | |
501 | ax.set_title(self.title) |
|
501 | ax.set_title(self.title) | |
502 |
|
502 | |||
503 | # fig = plt.gcf() |
|
503 | # fig = plt.gcf() | |
504 | # nrows = self. |
|
504 | # nrows = self. | |
505 | # fig.add_subplot |
|
505 | # fig.add_subplot | |
506 |
|
506 | |||
507 | pass |
|
507 | pass | |
508 |
|
508 | |||
509 | def delLabels(self): |
|
509 | def delLabels(self): | |
510 | # self.setColor(15) #Setting Line Color to White |
|
510 | # self.setColor(15) #Setting Line Color to White | |
511 | # plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
511 | # plplot.pllab(self.xlabel, self.ylabel, self.title) | |
512 | # self.setColor(1) #Setting Line Color to Black |
|
512 | # self.setColor(1) #Setting Line Color to Black | |
513 | pass |
|
513 | pass | |
514 |
|
514 | |||
515 | def plotImage(self,x,y,z,xrange,yrange,zrange): |
|
515 | def plotImage(self,x,y,z,xrange,yrange,zrange): | |
516 | # xi = x[0] |
|
516 | # xi = x[0] | |
517 | # xf = x[-1] |
|
517 | # xf = x[-1] | |
518 | # yi = y[0] |
|
518 | # yi = y[0] | |
519 | # yf = y[-1] |
|
519 | # yf = y[-1] | |
520 | # |
|
520 | # | |
521 | # plplot.plimage(z, |
|
521 | # plplot.plimage(z, | |
522 | # float(xi), |
|
522 | # float(xi), | |
523 | # float(xf), |
|
523 | # float(xf), | |
524 | # float(yi), |
|
524 | # float(yi), | |
525 | # float(yf), |
|
525 | # float(yf), | |
526 | # float(zrange[0]), |
|
526 | # float(zrange[0]), | |
527 | # float(zrange[1]), |
|
527 | # float(zrange[1]), | |
528 | # float(xi), |
|
528 | # float(xi), | |
529 | # float(xf), |
|
529 | # float(xf), | |
530 | # float(yrange[0]), |
|
530 | # float(yrange[0]), | |
531 | # yrange[1]) |
|
531 | # yrange[1]) | |
532 | pass |
|
532 | pass | |
533 |
|
533 | |||
534 | class LinearPlot: |
|
534 | class LinearPlot: | |
535 |
|
535 | |||
536 | linearObjDic = {} |
|
536 | linearObjDic = {} | |
537 | __xpos = None |
|
537 | __xpos = None | |
538 | __ypos = None |
|
538 | __ypos = None | |
539 |
|
539 | |||
540 | def __init__(self,indexFig,nsubplot,winTitle): |
|
540 | def __init__(self,indexFig,nsubplot,winTitle): | |
541 | self.width = 700 |
|
541 | self.width = 700 | |
542 | self.height = 150 |
|
542 | self.height = 150 | |
543 | self.indexFig = indexFig |
|
543 | self.indexFig = indexFig | |
544 | self.ncol = 1 |
|
544 | self.ncol = 1 | |
545 | self.nrow = nsubplot |
|
545 | self.nrow = nsubplot | |
546 | initMatplotlib(indexFig,self.ncol,self.nrow,winTitle,self.width,self.height) |
|
546 | initMatplotlib(indexFig,self.ncol,self.nrow,winTitle,self.width,self.height) | |
547 |
|
547 | |||
548 | def setFigure(self,indexFig): |
|
548 | def setFigure(self,indexFig): | |
549 | setFigure(indexFig) |
|
549 | setFigure(indexFig) | |
550 |
|
550 | |||
551 | def setPosition(self): |
|
551 | def setPosition(self): | |
552 |
|
552 | |||
553 | xi = 0.07; xf = 0.9 #0.8,0.7,0.5 |
|
553 | xi = 0.07; xf = 0.9 #0.8,0.7,0.5 | |
554 | yi = 0.15; yf = 0.8 |
|
554 | yi = 0.15; yf = 0.8 | |
555 |
|
555 | |||
556 | xpos = [xi,xf] |
|
556 | xpos = [xi,xf] | |
557 | ypos = [yi,yf] |
|
557 | ypos = [yi,yf] | |
558 |
|
558 | |||
559 | self.__xpos = xpos |
|
559 | self.__xpos = xpos | |
560 | self.__ypos = ypos |
|
560 | self.__ypos = ypos | |
561 |
|
561 | |||
562 | return xpos,ypos |
|
562 | return xpos,ypos | |
563 |
|
563 | |||
564 | def show(self): |
|
564 | def show(self): | |
565 | show() |
|
565 | show() | |
566 |
|
566 | |||
567 | def refresh(self): |
|
567 | def refresh(self): | |
568 | refresh() |
|
568 | refresh() | |
569 |
|
569 | |||
570 | def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel): |
|
570 | def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel): | |
571 | szchar = 1.10 |
|
571 | szchar = 1.10 | |
572 | name = 'linear' |
|
572 | name = 'linear' | |
573 | key = name + '%d'%subplot |
|
573 | key = name + '%d'%subplot | |
574 | xrange = [xmin,xmax] |
|
574 | xrange = [xmin,xmax] | |
575 | yrange = [ymin,ymax] |
|
575 | yrange = [ymin,ymax] | |
576 |
|
576 | |||
577 | xpos,ypos = self.setPosition() |
|
577 | xpos,ypos = self.setPosition() | |
578 | linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange) |
|
578 | linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange) | |
579 | linearObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
579 | linearObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
580 | linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcnst', 'bcnstv') |
|
580 | linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcnst', 'bcnstv') | |
581 | self.linearObjDic[key] = linearObj |
|
581 | self.linearObjDic[key] = linearObj | |
582 |
|
582 | |||
583 |
|
583 | |||
584 | def plot(self,subplot,x,y,type='abs'): |
|
584 | def plot(self,subplot,x,y,type='abs'): | |
585 | name = 'linear' |
|
585 | name = 'linear' | |
586 | key = name + '%d'%subplot |
|
586 | key = name + '%d'%subplot | |
587 |
|
587 | |||
588 | linearObj = self.linearObjDic[key] |
|
588 | linearObj = self.linearObjDic[key] | |
589 | #linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcst', 'bcst') |
|
589 | #linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcst', 'bcst') | |
590 |
|
590 | |||
591 | # if linearObj.setXYData() != None: |
|
591 | # if linearObj.setXYData() != None: | |
592 | # clearData(linearObj) |
|
592 | # clearData(linearObj) | |
593 | # else: |
|
593 | # else: | |
594 | # if type.lower() == 'simple': |
|
594 | # if type.lower() == 'simple': | |
595 | # linearObj.setXYData(x,y,'real') |
|
595 | # linearObj.setXYData(x,y,'real') | |
596 | # if type.lower() == 'power': |
|
596 | # if type.lower() == 'power': | |
597 | # linearObj.setXYData(x,abs(y),'real') |
|
597 | # linearObj.setXYData(x,abs(y),'real') | |
598 | # if type.lower() == 'iq': |
|
598 | # if type.lower() == 'iq': | |
599 | # linearObj.setXYData(x,y,'complex') |
|
599 | # linearObj.setXYData(x,y,'complex') | |
600 |
|
600 | |||
601 | if type.lower() == 'simple': |
|
601 | if type.lower() == 'simple': | |
602 | colline = 9 |
|
602 | colline = 9 | |
603 | linearObj.basicLineTimePlot(x, y) |
|
603 | linearObj.basicLineTimePlot(x, y) | |
604 | linearObj.setXYData(x,y,'real') |
|
604 | linearObj.setXYData(x,y,'real') | |
605 |
|
605 | |||
606 | if type.lower() == 'abs': |
|
606 | if type.lower() == 'abs': | |
607 | colline = 9 |
|
607 | colline = 9 | |
608 | linearObj.basicLineTimePlot(x, abs(y), colline) |
|
608 | linearObj.basicLineTimePlot(x, abs(y), colline) | |
609 | linearObj.setXYData(x,abs(y),'real') |
|
609 | linearObj.setXYData(x,abs(y),'real') | |
610 |
|
610 | |||
611 | if type.lower() == 'iq': |
|
611 | if type.lower() == 'iq': | |
612 | colline = 9 |
|
612 | colline = 9 | |
613 | linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline) |
|
613 | linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline) | |
614 | colline = 13 |
|
614 | colline = 13 | |
615 | linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline) |
|
615 | linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline) | |
616 | linearObj.setXYData(x,y,'complex') |
|
616 | linearObj.setXYData(x,y,'complex') | |
617 |
|
617 | |||
618 | # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcst', 'bcst') |
|
618 | # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcst', 'bcst') | |
619 |
|
619 | |||
620 | pass |
|
620 | pass | |
621 |
|
621 | |||
622 |
|
622 | |||
623 | class PcolorPlot: |
|
623 | class PcolorPlot: | |
624 |
|
624 | |||
625 | pcolorObjDic = {} |
|
625 | pcolorObjDic = {} | |
626 | colorbarObjDic = {} |
|
626 | colorbarObjDic = {} | |
627 | pwprofileObjDic = {} |
|
627 | pwprofileObjDic = {} | |
628 | showColorbar = None |
|
628 | showColorbar = None | |
629 | showPowerProfile = None |
|
629 | showPowerProfile = None | |
630 | XAxisAsTime = None |
|
630 | XAxisAsTime = None | |
631 | width = None |
|
631 | width = None | |
632 | height = None |
|
632 | height = None | |
633 | __spcxpos = None |
|
633 | __spcxpos = None | |
634 | __spcypos = None |
|
634 | __spcypos = None | |
635 | __cmapxpos = None |
|
635 | __cmapxpos = None | |
636 | __cmapypos = None |
|
636 | __cmapypos = None | |
637 | __profxpos = None |
|
637 | __profxpos = None | |
638 | __profypos = None |
|
638 | __profypos = None | |
639 | __lastTitle = None |
|
639 | __lastTitle = None | |
640 |
|
640 | |||
641 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): |
|
641 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): | |
642 |
|
642 | |||
643 | self.width = 460 |
|
643 | self.width = 460 | |
644 | self.height = 300 |
|
644 | self.height = 300 | |
645 | self.showColorbar = showColorbar |
|
645 | self.showColorbar = showColorbar | |
646 | self.showPowerProfile = showPowerProfile |
|
646 | self.showPowerProfile = showPowerProfile | |
647 | self.XAxisAsTime = XAxisAsTime |
|
647 | self.XAxisAsTime = XAxisAsTime | |
648 |
|
648 | |||
649 | ncol = int(numpy.sqrt(nsubplot)+0.9) |
|
649 | ncol = int(numpy.sqrt(nsubplot)+0.9) | |
650 | nrow = int(nsubplot*1./ncol + 0.9) |
|
650 | nrow = int(nsubplot*1./ncol + 0.9) | |
651 |
|
651 | |||
652 | self.ncol = ncol |
|
652 | self.ncol = ncol | |
653 | self.nrow = nrow |
|
653 | self.nrow = nrow | |
654 | self.indexFig = indexFig |
|
654 | self.indexFig = indexFig | |
655 |
|
655 | |||
656 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) |
|
656 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) | |
657 | setColormap(colormap) |
|
657 | setColormap(colormap) | |
658 |
|
658 | |||
659 | def setFigure(self,indexFig): |
|
659 | def setFigure(self,indexFig): | |
660 | setFigure(indexFig) |
|
660 | setFigure(indexFig) | |
661 |
|
661 | |||
662 | def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile |
|
662 | def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile | |
663 | if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075 |
|
663 | if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075 | |
664 | else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5 |
|
664 | else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5 | |
665 | yi = 0.15; yf = 0.80 |
|
665 | yi = 0.15; yf = 0.80 | |
666 |
|
666 | |||
667 | xpos = [xi,xf] |
|
667 | xpos = [xi,xf] | |
668 | ypos = [yi,yf] |
|
668 | ypos = [yi,yf] | |
669 |
|
669 | |||
670 | self.__spcxpos = xpos |
|
670 | self.__spcxpos = xpos | |
671 | self.__spcypos = ypos |
|
671 | self.__spcypos = ypos | |
672 |
|
672 | |||
673 | return xpos,ypos |
|
673 | return xpos,ypos | |
674 |
|
674 | |||
675 | def setColorbarScreenPos(self): |
|
675 | def setColorbarScreenPos(self): | |
676 |
|
676 | |||
677 | xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03 |
|
677 | xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03 | |
678 | yi = self.__spcypos[0]; yf = self.__spcypos[1] |
|
678 | yi = self.__spcypos[0]; yf = self.__spcypos[1] | |
679 |
|
679 | |||
680 | xpos = [xi,xf] |
|
680 | xpos = [xi,xf] | |
681 | ypos = [yi,yf] |
|
681 | ypos = [yi,yf] | |
682 |
|
682 | |||
683 | self.__cmapxpos = xpos |
|
683 | self.__cmapxpos = xpos | |
684 | self.__cmapypos = ypos |
|
684 | self.__cmapypos = ypos | |
685 |
|
685 | |||
686 | return xpos,ypos |
|
686 | return xpos,ypos | |
687 |
|
687 | |||
688 | def setPowerprofileScreenPos(self): |
|
688 | def setPowerprofileScreenPos(self): | |
689 |
|
689 | |||
690 | xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25 |
|
690 | xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25 | |
691 | yi = self.__spcypos[0]; yf = self.__spcypos[1] |
|
691 | yi = self.__spcypos[0]; yf = self.__spcypos[1] | |
692 |
|
692 | |||
693 | xpos = [xi,xf] |
|
693 | xpos = [xi,xf] | |
694 | ypos = [yi,yf] |
|
694 | ypos = [yi,yf] | |
695 |
|
695 | |||
696 | self.__profxpos = [xi,xf] |
|
696 | self.__profxpos = [xi,xf] | |
697 | self.__profypos = [yi,yf] |
|
697 | self.__profypos = [yi,yf] | |
698 |
|
698 | |||
699 | return xpos,ypos |
|
699 | return xpos,ypos | |
700 |
|
700 | |||
701 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel): |
|
701 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel): | |
702 |
|
702 | |||
703 | ''' |
|
703 | ''' | |
704 | Crea los objetos necesarios para un subplot |
|
704 | Crea los objetos necesarios para un subplot | |
705 | ''' |
|
705 | ''' | |
706 |
|
706 | |||
707 | # Config Spectra plot |
|
707 | # Config Spectra plot | |
708 |
|
708 | |||
709 | szchar = 0.7 |
|
709 | szchar = 0.7 | |
710 | name = 'spc' |
|
710 | name = 'spc' | |
711 | key = name + '%d'%subplot |
|
711 | key = name + '%d'%subplot | |
712 | xrange = [xmin,xmax] |
|
712 | xrange = [xmin,xmax] | |
713 | yrange = [ymin,ymax] |
|
713 | yrange = [ymin,ymax] | |
714 | zrange = [zmin,zmax] |
|
714 | zrange = [zmin,zmax] | |
715 |
|
715 | |||
716 | xpos,ypos = self.setSpectraPos() |
|
716 | xpos,ypos = self.setSpectraPos() | |
717 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange) |
|
717 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange) | |
718 | #pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
718 | #pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
719 | self.pcolorObjDic[key] = pcolorObj |
|
719 | self.pcolorObjDic[key] = pcolorObj | |
720 |
|
720 | |||
721 | # Config Colorbar |
|
721 | # Config Colorbar | |
722 | if self.showColorbar: |
|
722 | if self.showColorbar: | |
723 | szchar = 0.65 |
|
723 | szchar = 0.65 | |
724 | name = 'colorbar' |
|
724 | name = 'colorbar' | |
725 | key = name + '%d'%subplot |
|
725 | key = name + '%d'%subplot | |
726 |
|
726 | |||
727 | xpos,ypos = self.setColorbarScreenPos() |
|
727 | xpos,ypos = self.setColorbarScreenPos() | |
728 | xrange = [0.,1.] |
|
728 | xrange = [0.,1.] | |
729 | yrange = [zmin,zmax] |
|
729 | yrange = [zmin,zmax] | |
730 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) |
|
730 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) | |
731 | self.colorbarObjDic[key] = cmapObj |
|
731 | self.colorbarObjDic[key] = cmapObj | |
732 |
|
732 | |||
733 | # Config Power profile |
|
733 | # Config Power profile | |
734 | if self.showPowerProfile: |
|
734 | if self.showPowerProfile: | |
735 | szchar = 0.55 |
|
735 | szchar = 0.55 | |
736 | name = 'pwprofile' |
|
736 | name = 'pwprofile' | |
737 | key = name + '%d'%subplot |
|
737 | key = name + '%d'%subplot | |
738 |
|
738 | |||
739 | xpos,ypos = self.setPowerprofileScreenPos() |
|
739 | xpos,ypos = self.setPowerprofileScreenPos() | |
740 | xrange = [zmin,zmax] |
|
740 | xrange = [zmin,zmax] | |
741 | yrange = [ymin,ymax] |
|
741 | yrange = [ymin,ymax] | |
742 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) |
|
742 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) | |
743 | #powObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
743 | #powObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
744 | self.pwprofileObjDic[key] = powObj |
|
744 | self.pwprofileObjDic[key] = powObj | |
745 |
|
745 | |||
746 | def setNewPage(self, pltitle='No title'): |
|
746 | def setNewPage(self, pltitle='No title'): | |
747 | szchar = 0.7 |
|
747 | szchar = 0.7 | |
748 | setNewPage() |
|
748 | setNewPage() | |
749 | setPlTitle(pltitle,'black', szchar=szchar) |
|
749 | setPlTitle(pltitle,'black', szchar=szchar) | |
750 | setSubpages(self.ncol, self.nrow) |
|
750 | setSubpages(self.ncol, self.nrow) | |
751 |
|
751 | |||
752 | def closePage(self): |
|
752 | def closePage(self): | |
753 | closePage() |
|
753 | closePage() | |
754 |
|
754 | |||
755 | def show(self): |
|
755 | def show(self): | |
756 | show() |
|
756 | show() | |
757 |
|
757 | |||
758 | def iniPlot(self,subplot): |
|
758 | def iniPlot(self,subplot): | |
759 | ''' |
|
759 | ''' | |
760 | Inicializa los subplots con su frame, titulo, etc |
|
760 | Inicializa los subplots con su frame, titulo, etc | |
761 | ''' |
|
761 | ''' | |
762 |
|
762 | |||
763 | # Config Spectra plot |
|
763 | # Config Spectra plot | |
764 | name = 'spc' |
|
764 | name = 'spc' | |
765 | key = name + '%d'%subplot |
|
765 | key = name + '%d'%subplot | |
766 |
|
766 | |||
767 | pcolorObj = self.pcolorObjDic[key] |
|
767 | pcolorObj = self.pcolorObjDic[key] | |
768 | pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
768 | pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
769 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcnst', 'bcnstv') |
|
769 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcnst', 'bcnstv') | |
770 |
|
770 | |||
771 | # Config Colorbar |
|
771 | # Config Colorbar | |
772 | if self.showColorbar: |
|
772 | if self.showColorbar: | |
773 | name = 'colorbar' |
|
773 | name = 'colorbar' | |
774 | key = name + '%d'%subplot |
|
774 | key = name + '%d'%subplot | |
775 |
|
775 | |||
776 | cmapObj = self.colorbarObjDic[key] |
|
776 | cmapObj = self.colorbarObjDic[key] | |
777 | cmapObj.setParentAxesId(pcolorObj) |
|
777 | cmapObj.setParentAxesId(pcolorObj) | |
778 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') |
|
778 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') | |
779 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) |
|
779 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) | |
780 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') |
|
780 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') | |
781 |
|
781 | |||
782 | # Config Power profile |
|
782 | # Config Power profile | |
783 | if self.showPowerProfile: |
|
783 | if self.showPowerProfile: | |
784 | name = 'pwprofile' |
|
784 | name = 'pwprofile' | |
785 | key = name + '%d'%subplot |
|
785 | key = name + '%d'%subplot | |
786 |
|
786 | |||
787 | powObj = self.pwprofileObjDic[key] |
|
787 | powObj = self.pwprofileObjDic[key] | |
788 | powObj.setLineStyle(2) |
|
788 | powObj.setLineStyle(2) | |
789 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
789 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
790 | powObj.setLineStyle(1) |
|
790 | powObj.setLineStyle(1) | |
791 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
791 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
792 |
|
792 | |||
793 | def printTitle(self,pltitle): |
|
793 | def printTitle(self,pltitle): | |
794 | # if self.__lastTitle != None: |
|
794 | # if self.__lastTitle != None: | |
795 | # setPlTitle(self.__lastTitle,'white') |
|
795 | # setPlTitle(self.__lastTitle,'white') | |
796 | # |
|
796 | # | |
797 | # self.__lastTitle = pltitle |
|
797 | # self.__lastTitle = pltitle | |
798 |
|
798 | |||
799 | setPlTitle(pltitle,'black') |
|
799 | setPlTitle(pltitle,'black') | |
800 |
|
800 | |||
801 | # setSubpages(self.ncol,self.nrow) |
|
801 | # setSubpages(self.ncol,self.nrow) | |
802 |
|
802 | |||
803 | def plot(self,subplot,x,y,z,subtitle=''): |
|
803 | def plot(self,subplot,x,y,z,subtitle=''): | |
804 | # Spectra plot |
|
804 | # Spectra plot | |
805 |
|
805 | |||
806 | name = 'spc' |
|
806 | name = 'spc' | |
807 | key = name + '%d'%subplot |
|
807 | key = name + '%d'%subplot | |
808 |
|
808 | |||
809 | # newx = [x[0],x[-1]] |
|
809 | # newx = [x[0],x[-1]] | |
810 | pcolorObj = self.pcolorObjDic[key] |
|
810 | pcolorObj = self.pcolorObjDic[key] | |
811 | # pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst') |
|
811 | # pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst') | |
812 |
|
812 | |||
813 | #pcolorObj.delLabels() |
|
813 | #pcolorObj.delLabels() | |
814 | pcolorObj.setLabels(title=subtitle) |
|
814 | pcolorObj.setLabels(title=subtitle) | |
815 |
|
815 | |||
816 | deltax = None; deltay = None |
|
816 | deltax = None; deltay = None | |
817 |
|
817 | |||
818 | pcolorObj.advPcolorPlot(z, |
|
818 | pcolorObj.advPcolorPlot(z, | |
819 | x, |
|
819 | x, | |
820 | y, |
|
820 | y, | |
821 | xmin=pcolorObj.xrange[0], |
|
821 | xmin=pcolorObj.xrange[0], | |
822 | xmax=pcolorObj.xrange[1], |
|
822 | xmax=pcolorObj.xrange[1], | |
823 | ymin=pcolorObj.yrange[0], |
|
823 | ymin=pcolorObj.yrange[0], | |
824 | ymax=pcolorObj.yrange[1], |
|
824 | ymax=pcolorObj.yrange[1], | |
825 | zmin=pcolorObj.zrange[0], |
|
825 | zmin=pcolorObj.zrange[0], | |
826 | zmax=pcolorObj.zrange[1], |
|
826 | zmax=pcolorObj.zrange[1], | |
827 | deltax=deltax, |
|
827 | deltax=deltax, | |
828 | deltay=deltay, |
|
828 | deltay=deltay, | |
829 | getGrid=pcolorObj.getGrid) |
|
829 | getGrid=pcolorObj.getGrid) | |
830 |
|
830 | |||
831 | #Solo se calcula la primera vez que se ingresa a la funcion |
|
831 | #Solo se calcula la primera vez que se ingresa a la funcion | |
832 | pcolorObj.getGrid = False |
|
832 | pcolorObj.getGrid = False | |
833 |
|
833 | |||
834 | #pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst', nolabels=True) |
|
834 | #pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst', nolabels=True) | |
835 |
|
835 | |||
836 | # Power Profile |
|
836 | # Power Profile | |
837 | if self.showPowerProfile: |
|
837 | if self.showPowerProfile: | |
838 | power = numpy.average(z, axis=0) |
|
838 | power = numpy.average(z, axis=0) | |
839 | name = 'pwprofile' |
|
839 | name = 'pwprofile' | |
840 | key = name + '%d'%subplot |
|
840 | key = name + '%d'%subplot | |
841 | powObj = self.pwprofileObjDic[key] |
|
841 | powObj = self.pwprofileObjDic[key] | |
842 |
|
842 | |||
843 | if powObj.setXYData() != None: |
|
843 | if powObj.setXYData() != None: | |
844 | #clearData(powObj) |
|
844 | #clearData(powObj) | |
845 | powObj.setLineStyle(2) |
|
845 | powObj.setLineStyle(2) | |
846 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
846 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
847 | powObj.setLineStyle(1) |
|
847 | powObj.setLineStyle(1) | |
848 | else: |
|
848 | else: | |
849 | powObj.setXYData(power,y) |
|
849 | powObj.setXYData(power,y) | |
850 |
|
850 | |||
851 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
851 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
852 | powObj.basicXYPlot(power,y) |
|
852 | powObj.basicXYPlot(power,y) | |
853 | powObj.setXYData(power,y) |
|
853 | powObj.setXYData(power,y) | |
854 |
|
854 | |||
855 | def savePlot(self,indexFig,filename): |
|
855 | def savePlot(self,indexFig,filename): | |
856 |
|
856 | |||
857 | width = self.width*self.ncol |
|
857 | width = self.width*self.ncol | |
858 | hei = self.height*self.nrow |
|
858 | hei = self.height*self.nrow | |
859 | savePlplot(filename,width,hei) |
|
859 | savePlplot(filename,width,hei) | |
860 |
|
860 | |||
861 | def refresh(self): |
|
861 | def refresh(self): | |
862 | refresh() |
|
862 | refresh() | |
863 |
|
863 | |||
864 |
|
864 | |||
865 | class RtiPlot: |
|
865 | class RtiPlot: | |
866 |
|
866 | |||
867 | pcolorObjDic = {} |
|
867 | pcolorObjDic = {} | |
868 | colorbarObjDic = {} |
|
868 | colorbarObjDic = {} | |
869 | pwprofileObjDic = {} |
|
869 | pwprofileObjDic = {} | |
870 | showColorbar = None |
|
870 | showColorbar = None | |
871 | showPowerProfile = None |
|
871 | showPowerProfile = None | |
872 | XAxisAsTime = None |
|
872 | XAxisAsTime = None | |
873 | widht = None |
|
873 | widht = None | |
874 | height = None |
|
874 | height = None | |
875 | __rtixpos = None |
|
875 | __rtixpos = None | |
876 | __rtiypos = None |
|
876 | __rtiypos = None | |
877 | __cmapxpos = None |
|
877 | __cmapxpos = None | |
878 | __cmapypos = None |
|
878 | __cmapypos = None | |
879 | __profxpos = None |
|
879 | __profxpos = None | |
880 | __profypos = None |
|
880 | __profypos = None | |
881 |
|
881 | |||
882 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): |
|
882 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): | |
883 | self.width = 700 |
|
883 | self.width = 700 | |
884 | self.height = 150 |
|
884 | self.height = 150 | |
885 | self.showColorbar = showColorbar |
|
885 | self.showColorbar = showColorbar | |
886 | self.showPowerProfile = showPowerProfile |
|
886 | self.showPowerProfile = showPowerProfile | |
887 | self.XAxisAsTime = XAxisAsTime |
|
887 | self.XAxisAsTime = XAxisAsTime | |
888 |
|
888 | |||
889 | ncol = 1 |
|
889 | ncol = 1 | |
890 | nrow = nsubplot |
|
890 | nrow = nsubplot | |
891 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) |
|
891 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) | |
892 | setColormap(colormap) |
|
892 | setColormap(colormap) | |
893 | self.ncol = ncol |
|
893 | self.ncol = ncol | |
894 | self.nrow = nrow |
|
894 | self.nrow = nrow | |
895 |
|
895 | |||
896 | def setFigure(self,indexFig): |
|
896 | def setFigure(self,indexFig): | |
897 | setFigure(indexFig) |
|
897 | setFigure(indexFig) | |
898 |
|
898 | |||
899 | def setRtiScreenPos(self): |
|
899 | def setRtiScreenPos(self): | |
900 |
|
900 | |||
901 | if self.showPowerProfile: xi = 0.07; xf = 0.65 |
|
901 | if self.showPowerProfile: xi = 0.07; xf = 0.65 | |
902 | else: xi = 0.07; xf = 0.9 |
|
902 | else: xi = 0.07; xf = 0.9 | |
903 | yi = 0.15; yf = 0.80 |
|
903 | yi = 0.15; yf = 0.80 | |
904 |
|
904 | |||
905 | xpos = [xi,xf] |
|
905 | xpos = [xi,xf] | |
906 | ypos = [yi,yf] |
|
906 | ypos = [yi,yf] | |
907 |
|
907 | |||
908 | self.__rtixpos = xpos |
|
908 | self.__rtixpos = xpos | |
909 | self.__rtiypos = ypos |
|
909 | self.__rtiypos = ypos | |
910 |
|
910 | |||
911 | return xpos,ypos |
|
911 | return xpos,ypos | |
912 |
|
912 | |||
913 | def setColorbarScreenPos(self): |
|
913 | def setColorbarScreenPos(self): | |
914 |
|
914 | |||
915 | xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03 |
|
915 | xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03 | |
916 |
|
916 | |||
917 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] |
|
917 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] | |
918 |
|
918 | |||
919 | xpos = [xi,xf] |
|
919 | xpos = [xi,xf] | |
920 | ypos = [yi,yf] |
|
920 | ypos = [yi,yf] | |
921 |
|
921 | |||
922 | self.__cmapxpos = xpos |
|
922 | self.__cmapxpos = xpos | |
923 | self.__cmapypos = ypos |
|
923 | self.__cmapypos = ypos | |
924 |
|
924 | |||
925 | return xpos,ypos |
|
925 | return xpos,ypos | |
926 |
|
926 | |||
927 | def setPowerprofileScreenPos(self): |
|
927 | def setPowerprofileScreenPos(self): | |
928 |
|
928 | |||
929 | xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20 |
|
929 | xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20 | |
930 |
|
930 | |||
931 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] |
|
931 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] | |
932 |
|
932 | |||
933 | xpos = [xi,xf] |
|
933 | xpos = [xi,xf] | |
934 | ypos = [yi,yf] |
|
934 | ypos = [yi,yf] | |
935 |
|
935 | |||
936 | self.__profxpos = [xi,xf] |
|
936 | self.__profxpos = [xi,xf] | |
937 | self.__profypos = [yi,yf] |
|
937 | self.__profypos = [yi,yf] | |
938 |
|
938 | |||
939 | return xpos,ypos |
|
939 | return xpos,ypos | |
940 |
|
940 | |||
941 | def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone='lt',npoints=100): |
|
941 | def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone='lt',npoints=100): | |
942 | # Config Rti plot |
|
942 | # Config Rti plot | |
943 | szchar = 1.10 |
|
943 | szchar = 1.10 | |
944 | name = 'rti' |
|
944 | name = 'rti' | |
945 | key = name + '%d'%subplot |
|
945 | key = name + '%d'%subplot | |
946 |
|
946 | |||
947 | # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal] |
|
947 | # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal] | |
948 | thisDateTime = datetime.datetime.fromtimestamp(timedata) |
|
948 | thisDateTime = datetime.datetime.fromtimestamp(timedata) | |
949 | startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0) |
|
949 | startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0) | |
950 | endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59) |
|
950 | endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59) | |
951 | deltaTime = 0 |
|
951 | deltaTime = 0 | |
952 | if timezone == 'lt': |
|
952 | if timezone == 'lt': | |
953 | deltaTime = time.timezone |
|
953 | deltaTime = time.timezone | |
954 | startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime |
|
954 | startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime | |
955 | endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime |
|
955 | endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime | |
956 |
|
956 | |||
957 | xrange = [startTimeInSecs,endTimeInSecs] |
|
957 | xrange = [startTimeInSecs,endTimeInSecs] | |
958 | totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1. |
|
958 | totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1. | |
959 | deltax = totalTimeInXrange / npoints |
|
959 | deltax = totalTimeInXrange / npoints | |
960 |
|
960 | |||
961 | yrange = [ymin,ymax] |
|
961 | yrange = [ymin,ymax] | |
962 | zrange = [zmin,zmax] |
|
962 | zrange = [zmin,zmax] | |
963 |
|
963 | |||
964 | xpos,ypos = self.setRtiScreenPos() |
|
964 | xpos,ypos = self.setRtiScreenPos() | |
965 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax) |
|
965 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax) | |
966 | if self.XAxisAsTime: |
|
966 | if self.XAxisAsTime: | |
967 | pcolorObj.setXAxisAsTime(self.XAxisAsTime) |
|
967 | pcolorObj.setXAxisAsTime(self.XAxisAsTime) | |
968 | xopt = 'bcnstd' |
|
968 | xopt = 'bcnstd' | |
969 | yopt = 'bcnstv' |
|
969 | yopt = 'bcnstv' | |
970 | else: |
|
970 | else: | |
971 | xopt = 'bcnst' |
|
971 | xopt = 'bcnst' | |
972 | yopt = 'bcnstv' |
|
972 | yopt = 'bcnstv' | |
973 |
|
973 | |||
974 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) |
|
974 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) | |
975 | self.pcolorObjDic[key] = pcolorObj |
|
975 | self.pcolorObjDic[key] = pcolorObj | |
976 |
|
976 | |||
977 |
|
977 | |||
978 | # Config Colorbar |
|
978 | # Config Colorbar | |
979 | if self.showColorbar: |
|
979 | if self.showColorbar: | |
980 | szchar = 0.9 |
|
980 | szchar = 0.9 | |
981 | name = 'colorbar' |
|
981 | name = 'colorbar' | |
982 | key = name + '%d'%subplot |
|
982 | key = name + '%d'%subplot | |
983 |
|
983 | |||
984 | xpos,ypos = self.setColorbarScreenPos() |
|
984 | xpos,ypos = self.setColorbarScreenPos() | |
985 | xrange = [0.,1.] |
|
985 | xrange = [0.,1.] | |
986 | yrange = [zmin,zmax] |
|
986 | yrange = [zmin,zmax] | |
987 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) |
|
987 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) | |
988 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcm') |
|
988 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcm') | |
989 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) |
|
989 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) | |
990 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') |
|
990 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') | |
991 | self.colorbarObjDic[key] = cmapObj |
|
991 | self.colorbarObjDic[key] = cmapObj | |
992 |
|
992 | |||
993 |
|
993 | |||
994 | # Config Power profile |
|
994 | # Config Power profile | |
995 | if self.showPowerProfile: |
|
995 | if self.showPowerProfile: | |
996 | szchar = 0.8 |
|
996 | szchar = 0.8 | |
997 | name = 'pwprofile' |
|
997 | name = 'pwprofile' | |
998 | key = name + '%d'%subplot |
|
998 | key = name + '%d'%subplot | |
999 |
|
999 | |||
1000 | xpos,ypos = self.setPowerprofileScreenPos() |
|
1000 | xpos,ypos = self.setPowerprofileScreenPos() | |
1001 | xrange = [zmin,zmax] |
|
1001 | xrange = [zmin,zmax] | |
1002 | yrange = [ymin,ymax] |
|
1002 | yrange = [ymin,ymax] | |
1003 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) |
|
1003 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) | |
1004 | powObj.setLineStyle(2) |
|
1004 | powObj.setLineStyle(2) | |
1005 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
1005 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
1006 | powObj.setLineStyle(1) |
|
1006 | powObj.setLineStyle(1) | |
1007 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
1007 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
1008 | self.pwprofileObjDic[key] = powObj |
|
1008 | self.pwprofileObjDic[key] = powObj | |
1009 |
|
1009 | |||
1010 |
|
1010 | |||
1011 | def plot(self,subplot,x,y,z): |
|
1011 | def plot(self,subplot,x,y,z): | |
1012 | # RTI plot |
|
1012 | # RTI plot | |
1013 | name = 'rti' |
|
1013 | name = 'rti' | |
1014 | key = name + '%d'%subplot |
|
1014 | key = name + '%d'%subplot | |
1015 |
|
1015 | |||
1016 | data = numpy.reshape(z, (1,-1)) |
|
1016 | data = numpy.reshape(z, (1,-1)) | |
1017 | data = numpy.abs(data) |
|
1017 | data = numpy.abs(data) | |
1018 | data = 10*numpy.log10(data) |
|
1018 | data = 10*numpy.log10(data) | |
1019 | newx = [x,x+1] |
|
1019 | newx = [x,x+1] | |
1020 |
|
1020 | |||
1021 | pcolorObj = self.pcolorObjDic[key] |
|
1021 | pcolorObj = self.pcolorObjDic[key] | |
1022 |
|
1022 | |||
1023 | if pcolorObj.xaxisIsTime: |
|
1023 | if pcolorObj.xaxisIsTime: | |
1024 | xopt = 'bcstd' |
|
1024 | xopt = 'bcstd' | |
1025 | yopt = 'bcst' |
|
1025 | yopt = 'bcst' | |
1026 | else: |
|
1026 | else: | |
1027 | xopt = 'bcst' |
|
1027 | xopt = 'bcst' | |
1028 | yopt = 'bcst' |
|
1028 | yopt = 'bcst' | |
1029 |
|
1029 | |||
1030 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) |
|
1030 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) | |
1031 |
|
1031 | |||
1032 | deltax = pcolorObj.deltax |
|
1032 | deltax = pcolorObj.deltax | |
1033 | deltay = None |
|
1033 | deltay = None | |
1034 |
|
1034 | |||
1035 | if pcolorObj.xmin == None and pcolorObj.xmax == None: |
|
1035 | if pcolorObj.xmin == None and pcolorObj.xmax == None: | |
1036 | pcolorObj.xmin = x |
|
1036 | pcolorObj.xmin = x | |
1037 | pcolorObj.xmax = x |
|
1037 | pcolorObj.xmax = x | |
1038 |
|
1038 | |||
1039 | if x >= pcolorObj.xmax: |
|
1039 | if x >= pcolorObj.xmax: | |
1040 | xmin = x |
|
1040 | xmin = x | |
1041 | xmax = x + deltax |
|
1041 | xmax = x + deltax | |
1042 | x = [x] |
|
1042 | x = [x] | |
1043 | pcolorObj.advPcolorPlot(data, |
|
1043 | pcolorObj.advPcolorPlot(data, | |
1044 | x, |
|
1044 | x, | |
1045 | y, |
|
1045 | y, | |
1046 | xmin=xmin, |
|
1046 | xmin=xmin, | |
1047 | xmax=xmax, |
|
1047 | xmax=xmax, | |
1048 | ymin=pcolorObj.yrange[0], |
|
1048 | ymin=pcolorObj.yrange[0], | |
1049 | ymax=pcolorObj.yrange[1], |
|
1049 | ymax=pcolorObj.yrange[1], | |
1050 | zmin=pcolorObj.zrange[0], |
|
1050 | zmin=pcolorObj.zrange[0], | |
1051 | zmax=pcolorObj.zrange[1], |
|
1051 | zmax=pcolorObj.zrange[1], | |
1052 | deltax=deltax, |
|
1052 | deltax=deltax, | |
1053 | deltay=deltay, |
|
1053 | deltay=deltay, | |
1054 | getGrid=pcolorObj.getGrid) |
|
1054 | getGrid=pcolorObj.getGrid) | |
1055 |
|
1055 | |||
1056 | pcolorObj.xmin = xmin |
|
1056 | pcolorObj.xmin = xmin | |
1057 | pcolorObj.xmax = xmax |
|
1057 | pcolorObj.xmax = xmax | |
1058 |
|
1058 | |||
1059 |
|
1059 | |||
1060 | # Power Profile |
|
1060 | # Power Profile | |
1061 | if self.showPowerProfile: |
|
1061 | if self.showPowerProfile: | |
1062 | data = numpy.reshape(data,(numpy.size(data))) |
|
1062 | data = numpy.reshape(data,(numpy.size(data))) | |
1063 | name = 'pwprofile' |
|
1063 | name = 'pwprofile' | |
1064 | key = name + '%d'%subplot |
|
1064 | key = name + '%d'%subplot | |
1065 | powObj = self.pwprofileObjDic[key] |
|
1065 | powObj = self.pwprofileObjDic[key] | |
1066 |
|
1066 | |||
1067 | if powObj.setXYData() != None: |
|
1067 | if powObj.setXYData() != None: | |
1068 | clearData(powObj) |
|
1068 | clearData(powObj) | |
1069 | powObj.setLineStyle(2) |
|
1069 | powObj.setLineStyle(2) | |
1070 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
1070 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
1071 | powObj.setLineStyle(1) |
|
1071 | powObj.setLineStyle(1) | |
1072 | else: |
|
1072 | else: | |
1073 | powObj.setXYData(data,y) |
|
1073 | powObj.setXYData(data,y) | |
1074 |
|
1074 | |||
1075 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
1075 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
1076 | powObj.basicXYPlot(data,y) |
|
1076 | powObj.basicXYPlot(data,y) | |
1077 | powObj.setXYData(data,y) |
|
1077 | powObj.setXYData(data,y) | |
1078 |
|
1078 | |||
1079 | def savePlot(self,indexFig,filename): |
|
1079 | def savePlot(self,indexFig,filename): | |
1080 |
|
1080 | |||
1081 | width = self.width*self.ncol |
|
1081 | width = self.width*self.ncol | |
1082 | hei = self.height*self.nrow |
|
1082 | hei = self.height*self.nrow | |
1083 | savePlplot(filename,width,hei) |
|
1083 | savePlplot(filename,width,hei) | |
1084 |
|
1084 | |||
1085 | def refresh(self): |
|
1085 | def refresh(self): | |
1086 | refresh() |
|
1086 | refresh() | |
1087 |
|
1087 | |||
1088 |
|
1088 | |||
1089 | if __name__ == '__main__': |
|
1089 | if __name__ == '__main__': | |
1090 |
|
1090 | |||
1091 | """ |
|
1091 | """ | |
1092 | Ejemplo1 |
|
1092 | Ejemplo1 | |
1093 | """ |
|
1093 | """ | |
1094 | #Setting the signal |
|
1094 | #Setting the signal | |
1095 | fs = 8000 |
|
1095 | fs = 8000 | |
1096 | f0 = 200 |
|
1096 | f0 = 200 | |
1097 | f1 = 400 |
|
1097 | f1 = 400 | |
1098 | T = 1./fs |
|
1098 | T = 1./fs | |
1099 | x = numpy.arange(160) |
|
1099 | x = numpy.arange(160) | |
1100 | y1 = numpy.sin(2*numpy.pi*f0*x*T) |
|
1100 | y1 = numpy.sin(2*numpy.pi*f0*x*T) | |
1101 | y2 = numpy.sin(2*numpy.pi*f1*x*T) |
|
1101 | y2 = numpy.sin(2*numpy.pi*f1*x*T) | |
1102 | signalList = [y1,y2] |
|
1102 | signalList = [y1,y2] | |
1103 |
|
1103 | |||
1104 | xmin = numpy.min(x) |
|
1104 | xmin = numpy.min(x) | |
1105 | xmax = numpy.max(x) |
|
1105 | xmax = numpy.max(x) | |
1106 | ymin = numpy.min(y1) |
|
1106 | ymin = numpy.min(y1) | |
1107 | ymax = numpy.max(y1) |
|
1107 | ymax = numpy.max(y1) | |
1108 |
|
1108 | |||
1109 | # Creating Object |
|
1109 | # Creating Object | |
1110 | indexPlot = 1 |
|
1110 | indexPlot = 1 | |
1111 | nsubplot = 2 |
|
1111 | nsubplot = 2 | |
1112 | winTitle = "mi grafico v1" |
|
1112 | winTitle = "mi grafico v1" | |
1113 |
|
1113 | |||
1114 | subplotTitle = "subplot - No." |
|
1114 | subplotTitle = "subplot - No." | |
1115 | xlabel = "" |
|
1115 | xlabel = "" | |
1116 | ylabel = "" |
|
1116 | ylabel = "" | |
1117 |
|
1117 | |||
1118 | linearObj = LinearPlot(indexPlot,nsubplot,winTitle) |
|
1118 | linearObj = LinearPlot(indexPlot,nsubplot,winTitle) | |
1119 |
|
1119 | |||
1120 | #Config SubPlots |
|
1120 | #Config SubPlots | |
1121 | for subplot in range(nsubplot): |
|
1121 | for subplot in range(nsubplot): | |
1122 | indexplot = subplot + 1 |
|
1122 | indexplot = subplot + 1 | |
1123 | title = subplotTitle + '%d'%indexplot |
|
1123 | title = subplotTitle + '%d'%indexplot | |
1124 | linearObj.setup(indexplot, xmin, xmax, ymin, ymax, title, xlabel, ylabel) |
|
1124 | linearObj.setup(indexplot, xmin, xmax, ymin, ymax, title, xlabel, ylabel) | |
1125 |
|
1125 | |||
1126 | #Plotting |
|
1126 | #Plotting | |
1127 | type = "simple" |
|
1127 | type = "simple" | |
1128 | for subplot in range(nsubplot): |
|
1128 | for subplot in range(nsubplot): | |
1129 | indexplot = subplot + 1 |
|
1129 | indexplot = subplot + 1 | |
1130 | y = signalList[subplot] |
|
1130 | y = signalList[subplot] | |
1131 | linearObj.plot(indexplot, x, y, type) |
|
1131 | linearObj.plot(indexplot, x, y, type) | |
1132 |
|
1132 | |||
1133 | linearObj.refresh() |
|
1133 | linearObj.refresh() | |
1134 | linearObj.show() |
|
1134 | linearObj.show() | |
1135 |
|
1135 | |||
1136 |
|
1136 | |||
1137 | # """ |
|
1137 | # """ | |
1138 | # Ejemplo2 |
|
1138 | # Ejemplo2 | |
1139 | # """ |
|
1139 | # """ | |
1140 | # |
|
1140 | # | |
1141 | # # make these smaller to increase the resolution |
|
1141 | # # make these smaller to increase the resolution | |
1142 | # dx, dy = 0.05, 0.05 |
|
1142 | # dx, dy = 0.05, 0.05 | |
1143 | # x = numpy.arange(-3.0, 3.0001, dx) |
|
1143 | # x = numpy.arange(-3.0, 3.0001, dx) | |
1144 | # y = numpy.arange(-2.0, 2.0001, dy) |
|
1144 | # y = numpy.arange(-2.0, 2.0001, dy) | |
1145 | ## X,Y = numpy.meshgrid(x, y) |
|
1145 | ## X,Y = numpy.meshgrid(x, y) | |
1146 | # X,Y = sn.ndgrid(x, y) |
|
1146 | # X,Y = sn.ndgrid(x, y) | |
1147 | # Z = (1- X/2 + X**5 + Y**3)*numpy.exp(-X**2-Y**2) |
|
1147 | # Z = (1- X/2 + X**5 + Y**3)*numpy.exp(-X**2-Y**2) | |
1148 | # |
|
1148 | # | |
1149 | # # Creating Object |
|
1149 | # # Creating Object | |
1150 | # indexPlot = 2 |
|
1150 | # indexPlot = 2 | |
1151 | # nsubplot = 1 |
|
1151 | # nsubplot = 1 | |
1152 | # winTitle = "mi grafico pcolor" |
|
1152 | # winTitle = "mi grafico pcolor" | |
1153 | # colormap = "br_green" |
|
1153 | # colormap = "br_green" | |
1154 | # showColorbar = True |
|
1154 | # showColorbar = True | |
1155 | # showPowerProfile = False |
|
1155 | # showPowerProfile = False | |
1156 | # XAxisAsTime = False |
|
1156 | # XAxisAsTime = False | |
1157 | # |
|
1157 | # | |
1158 | # subplotTitle = "subplot no. " |
|
1158 | # subplotTitle = "subplot no. " | |
1159 | # xlabel = "" |
|
1159 | # xlabel = "" | |
1160 | # ylabel = "" |
|
1160 | # ylabel = "" | |
1161 | # |
|
1161 | # | |
1162 | # xmin = -3.0 |
|
1162 | # xmin = -3.0 | |
1163 | # xmax = 3.0 |
|
1163 | # xmax = 3.0 | |
1164 | # ymin = -2.0 |
|
1164 | # ymin = -2.0 | |
1165 | # ymax = 2.0 |
|
1165 | # ymax = 2.0 | |
1166 | # zmin = -0.3 |
|
1166 | # zmin = -0.3 | |
1167 | # zmax = 1.0 |
|
1167 | # zmax = 1.0 | |
1168 | # |
|
1168 | # | |
1169 | # isPlotIni = False |
|
1169 | # isPlotIni = False | |
1170 | # isPlotConfig = False |
|
1170 | # isPlotConfig = False | |
1171 | # ntimes = 10 |
|
1171 | # ntimes = 10 | |
1172 | # |
|
1172 | # | |
1173 | # |
|
1173 | # | |
1174 | # for i in range(ntimes): |
|
1174 | # for i in range(ntimes): | |
1175 | # |
|
1175 | # | |
1176 | # # Instancia del objeto |
|
1176 | # # Instancia del objeto | |
1177 | # if not(isPlotConfig): |
|
1177 | # if not(isPlotConfig): | |
1178 | # pcolorObj = PcolorPlot(indexPlot, nsubplot, winTitle, colormap, showColorbar, showPowerProfile, XAxisAsTime) |
|
1178 | # pcolorObj = PcolorPlot(indexPlot, nsubplot, winTitle, colormap, showColorbar, showPowerProfile, XAxisAsTime) | |
1179 | # isPlotConfig = True |
|
1179 | # isPlotConfig = True | |
1180 | # |
|
1180 | # | |
1181 | # # Crea los subplots |
|
1181 | # # Crea los subplots | |
1182 | # if not(isPlotIni): |
|
1182 | # if not(isPlotIni): | |
1183 | # for index in range(nsubplot): |
|
1183 | # for index in range(nsubplot): | |
1184 | # indexplot = index + 1 |
|
1184 | # indexplot = index + 1 | |
1185 | # title = subplotTitle + '%d'%indexplot |
|
1185 | # title = subplotTitle + '%d'%indexplot | |
1186 | # subplot = index |
|
1186 | # subplot = index | |
1187 | # pcolorObj.createObjects(indexplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel) |
|
1187 | # pcolorObj.createObjects(indexplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel) | |
1188 | # isPlotIni = True |
|
1188 | # isPlotIni = True | |
1189 | # |
|
1189 | # | |
1190 | # # Inicializa el grafico en cada iteracion |
|
1190 | # # Inicializa el grafico en cada iteracion | |
1191 | # pcolorObj.setFigure(indexPlot) |
|
1191 | # pcolorObj.setFigure(indexPlot) | |
1192 | # pcolorObj.setNewPage("") |
|
1192 | # pcolorObj.setNewPage("") | |
1193 | # |
|
1193 | # | |
1194 | # for index in range(nsubplot): |
|
1194 | # for index in range(nsubplot): | |
1195 | # subplot = index |
|
1195 | # subplot = index | |
1196 | # pcolorObj.iniPlot(subplot+1) |
|
1196 | # pcolorObj.iniPlot(subplot+1) | |
1197 | # |
|
1197 | # | |
1198 | # #plotea los datos |
|
1198 | # #plotea los datos | |
1199 | # for channel in range(nsubplot): |
|
1199 | # for channel in range(nsubplot): | |
1200 | # data = Z+0.1*numpy.random.randn(len(x),len(y)) |
|
1200 | # data = Z+0.1*numpy.random.randn(len(x),len(y)) | |
1201 | # pcolorObj.plot(channel+1, x, y, data) |
|
1201 | # pcolorObj.plot(channel+1, x, y, data) | |
1202 | # |
|
1202 | # | |
1203 | # pcolorObj.refresh() |
|
1203 | # pcolorObj.refresh() | |
1204 | # |
|
1204 | # | |
1205 | ## pcolorObj.closePage() #descomentar esta linea para mas iteraciones |
|
1205 | ## pcolorObj.closePage() #descomentar esta linea para mas iteraciones | |
1206 | # |
|
1206 | # | |
1207 | # time.sleep(1) |
|
1207 | # time.sleep(1) | |
1208 | # |
|
1208 | # | |
1209 | # pcolorObj.show() |
|
1209 | # pcolorObj.show() | |
1210 | # |
|
1210 | # | |
1211 | # print "end" No newline at end of file |
|
1211 | # print "end" |
@@ -1,505 +1,505 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import numpy |
|
7 | import numpy | |
8 | import copy |
|
8 | import copy | |
9 |
|
9 | |||
10 | class Header: |
|
10 | class Header: | |
11 |
|
11 | |||
12 | def __init__(self): |
|
12 | def __init__(self): | |
13 | raise |
|
13 | raise | |
14 |
|
14 | |||
15 | def copy(self): |
|
15 | def copy(self): | |
16 | return copy.deepcopy(self) |
|
16 | return copy.deepcopy(self) | |
17 |
|
17 | |||
18 | def read(): |
|
18 | def read(): | |
19 | pass |
|
19 | pass | |
20 |
|
20 | |||
21 | def write(): |
|
21 | def write(): | |
22 | pass |
|
22 | pass | |
23 |
|
23 | |||
24 | class BasicHeader(Header): |
|
24 | class BasicHeader(Header): | |
25 |
|
25 | |||
26 | size = None |
|
26 | size = None | |
27 | version = None |
|
27 | version = None | |
28 | dataBlock = None |
|
28 | dataBlock = None | |
29 | utc = None |
|
29 | utc = None | |
30 | miliSecond = None |
|
30 | miliSecond = None | |
31 | timeZone = None |
|
31 | timeZone = None | |
32 | dstFlag = None |
|
32 | dstFlag = None | |
33 | errorCount = None |
|
33 | errorCount = None | |
34 | struct = None |
|
34 | struct = None | |
35 |
|
35 | |||
36 | def __init__(self): |
|
36 | def __init__(self): | |
37 |
|
37 | |||
38 | self.size = 0 |
|
38 | self.size = 0 | |
39 | self.version = 0 |
|
39 | self.version = 0 | |
40 | self.dataBlock = 0 |
|
40 | self.dataBlock = 0 | |
41 | self.utc = 0 |
|
41 | self.utc = 0 | |
42 | self.miliSecond = 0 |
|
42 | self.miliSecond = 0 | |
43 | self.timeZone = 0 |
|
43 | self.timeZone = 0 | |
44 | self.dstFlag = 0 |
|
44 | self.dstFlag = 0 | |
45 | self.errorCount = 0 |
|
45 | self.errorCount = 0 | |
46 | self.struct = numpy.dtype([ |
|
46 | self.struct = numpy.dtype([ | |
47 | ('nSize','<u4'), |
|
47 | ('nSize','<u4'), | |
48 | ('nVersion','<u2'), |
|
48 | ('nVersion','<u2'), | |
49 | ('nDataBlockId','<u4'), |
|
49 | ('nDataBlockId','<u4'), | |
50 | ('nUtime','<u4'), |
|
50 | ('nUtime','<u4'), | |
51 | ('nMilsec','<u2'), |
|
51 | ('nMilsec','<u2'), | |
52 | ('nTimezone','<i2'), |
|
52 | ('nTimezone','<i2'), | |
53 | ('nDstflag','<i2'), |
|
53 | ('nDstflag','<i2'), | |
54 | ('nErrorCount','<u4') |
|
54 | ('nErrorCount','<u4') | |
55 | ]) |
|
55 | ]) | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | def read(self, fp): |
|
58 | def read(self, fp): | |
59 | try: |
|
59 | try: | |
60 | header = numpy.fromfile(fp, self.struct,1) |
|
60 | header = numpy.fromfile(fp, self.struct,1) | |
61 | self.size = header['nSize'][0] |
|
61 | self.size = header['nSize'][0] | |
62 | self.version = header['nVersion'][0] |
|
62 | self.version = header['nVersion'][0] | |
63 | self.dataBlock = header['nDataBlockId'][0] |
|
63 | self.dataBlock = header['nDataBlockId'][0] | |
64 | self.utc = header['nUtime'][0] |
|
64 | self.utc = header['nUtime'][0] | |
65 | self.miliSecond = header['nMilsec'][0] |
|
65 | self.miliSecond = header['nMilsec'][0] | |
66 | self.timeZone = header['nTimezone'][0] |
|
66 | self.timeZone = header['nTimezone'][0] | |
67 | self.dstFlag = header['nDstflag'][0] |
|
67 | self.dstFlag = header['nDstflag'][0] | |
68 | self.errorCount = header['nErrorCount'][0] |
|
68 | self.errorCount = header['nErrorCount'][0] | |
69 | except: |
|
69 | except: | |
70 | return 0 |
|
70 | return 0 | |
71 |
|
71 | |||
72 | return 1 |
|
72 | return 1 | |
73 |
|
73 | |||
74 | def write(self, fp): |
|
74 | def write(self, fp): | |
75 | headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount) |
|
75 | headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount) | |
76 | header = numpy.array(headerTuple,self.struct) |
|
76 | header = numpy.array(headerTuple,self.struct) | |
77 | header.tofile(fp) |
|
77 | header.tofile(fp) | |
78 |
|
78 | |||
79 | return 1 |
|
79 | return 1 | |
80 |
|
80 | |||
81 | class SystemHeader(Header): |
|
81 | class SystemHeader(Header): | |
82 |
|
82 | |||
83 | size = None |
|
83 | size = None | |
84 | nSamples = None |
|
84 | nSamples = None | |
85 | nProfiles = None |
|
85 | nProfiles = None | |
86 | nChannels = None |
|
86 | nChannels = None | |
87 | adcResolution = None |
|
87 | adcResolution = None | |
88 | pciDioBusWidth = None |
|
88 | pciDioBusWidth = None | |
89 | struct = None |
|
89 | struct = None | |
90 |
|
90 | |||
91 | def __init__(self): |
|
91 | def __init__(self): | |
92 | self.size = 0 |
|
92 | self.size = 0 | |
93 | self.nSamples = 0 |
|
93 | self.nSamples = 0 | |
94 | self.nProfiles = 0 |
|
94 | self.nProfiles = 0 | |
95 | self.nChannels = 0 |
|
95 | self.nChannels = 0 | |
96 | self.adcResolution = 0 |
|
96 | self.adcResolution = 0 | |
97 | self.pciDioBusWidth = 0 |
|
97 | self.pciDioBusWidth = 0 | |
98 | self.struct = numpy.dtype([ |
|
98 | self.struct = numpy.dtype([ | |
99 | ('nSize','<u4'), |
|
99 | ('nSize','<u4'), | |
100 | ('nNumSamples','<u4'), |
|
100 | ('nNumSamples','<u4'), | |
101 | ('nNumProfiles','<u4'), |
|
101 | ('nNumProfiles','<u4'), | |
102 | ('nNumChannels','<u4'), |
|
102 | ('nNumChannels','<u4'), | |
103 | ('nADCResolution','<u4'), |
|
103 | ('nADCResolution','<u4'), | |
104 | ('nPCDIOBusWidth','<u4'), |
|
104 | ('nPCDIOBusWidth','<u4'), | |
105 | ]) |
|
105 | ]) | |
106 |
|
106 | |||
107 |
|
107 | |||
108 | def read(self, fp): |
|
108 | def read(self, fp): | |
109 | try: |
|
109 | try: | |
110 | header = numpy.fromfile(fp,self.struct,1) |
|
110 | header = numpy.fromfile(fp,self.struct,1) | |
111 | self.size = header['nSize'][0] |
|
111 | self.size = header['nSize'][0] | |
112 | self.nSamples = header['nNumSamples'][0] |
|
112 | self.nSamples = header['nNumSamples'][0] | |
113 | self.nProfiles = header['nNumProfiles'][0] |
|
113 | self.nProfiles = header['nNumProfiles'][0] | |
114 | self.nChannels = header['nNumChannels'][0] |
|
114 | self.nChannels = header['nNumChannels'][0] | |
115 | self.adcResolution = header['nADCResolution'][0] |
|
115 | self.adcResolution = header['nADCResolution'][0] | |
116 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
116 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] | |
117 | except: |
|
117 | except: | |
118 | return 0 |
|
118 | return 0 | |
119 |
|
119 | |||
120 | return 1 |
|
120 | return 1 | |
121 |
|
121 | |||
122 | def write(self, fp): |
|
122 | def write(self, fp): | |
123 | headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth) |
|
123 | headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth) | |
124 | header = numpy.array(headerTuple,self.struct) |
|
124 | header = numpy.array(headerTuple,self.struct) | |
125 | header.tofile(fp) |
|
125 | header.tofile(fp) | |
126 |
|
126 | |||
127 | return 1 |
|
127 | return 1 | |
128 |
|
128 | |||
129 | class RadarControllerHeader(Header): |
|
129 | class RadarControllerHeader(Header): | |
130 |
|
130 | |||
131 | size = None |
|
131 | size = None | |
132 | expType = None |
|
132 | expType = None | |
133 | nTx = None |
|
133 | nTx = None | |
134 | ipp = None |
|
134 | ipp = None | |
135 | txA = None |
|
135 | txA = None | |
136 | txB = None |
|
136 | txB = None | |
137 | nWindows = None |
|
137 | nWindows = None | |
138 | numTaus = None |
|
138 | numTaus = None | |
139 | codeType = None |
|
139 | codeType = None | |
140 | line6Function = None |
|
140 | line6Function = None | |
141 | line5Function = None |
|
141 | line5Function = None | |
142 | fClock = None |
|
142 | fClock = None | |
143 | prePulseBefore = None |
|
143 | prePulseBefore = None | |
144 | prePulserAfter = None |
|
144 | prePulserAfter = None | |
145 | rangeIpp = None |
|
145 | rangeIpp = None | |
146 | rangeTxA = None |
|
146 | rangeTxA = None | |
147 | rangeTxB = None |
|
147 | rangeTxB = None | |
148 | struct = None |
|
148 | struct = None | |
149 |
|
149 | |||
150 | def __init__(self): |
|
150 | def __init__(self): | |
151 | self.size = 0 |
|
151 | self.size = 0 | |
152 | self.expType = 0 |
|
152 | self.expType = 0 | |
153 | self.nTx = 0 |
|
153 | self.nTx = 0 | |
154 | self.ipp = 0 |
|
154 | self.ipp = 0 | |
155 | self.txA = 0 |
|
155 | self.txA = 0 | |
156 | self.txB = 0 |
|
156 | self.txB = 0 | |
157 | self.nWindows = 0 |
|
157 | self.nWindows = 0 | |
158 | self.numTaus = 0 |
|
158 | self.numTaus = 0 | |
159 | self.codeType = 0 |
|
159 | self.codeType = 0 | |
160 | self.line6Function = 0 |
|
160 | self.line6Function = 0 | |
161 | self.line5Function = 0 |
|
161 | self.line5Function = 0 | |
162 | self.fClock = 0 |
|
162 | self.fClock = 0 | |
163 | self.prePulseBefore = 0 |
|
163 | self.prePulseBefore = 0 | |
164 | self.prePulserAfter = 0 |
|
164 | self.prePulserAfter = 0 | |
165 | self.rangeIpp = 0 |
|
165 | self.rangeIpp = 0 | |
166 | self.rangeTxA = 0 |
|
166 | self.rangeTxA = 0 | |
167 | self.rangeTxB = 0 |
|
167 | self.rangeTxB = 0 | |
168 | self.struct = numpy.dtype([ |
|
168 | self.struct = numpy.dtype([ | |
169 | ('nSize','<u4'), |
|
169 | ('nSize','<u4'), | |
170 | ('nExpType','<u4'), |
|
170 | ('nExpType','<u4'), | |
171 | ('nNTx','<u4'), |
|
171 | ('nNTx','<u4'), | |
172 | ('fIpp','<f4'), |
|
172 | ('fIpp','<f4'), | |
173 | ('fTxA','<f4'), |
|
173 | ('fTxA','<f4'), | |
174 | ('fTxB','<f4'), |
|
174 | ('fTxB','<f4'), | |
175 | ('nNumWindows','<u4'), |
|
175 | ('nNumWindows','<u4'), | |
176 | ('nNumTaus','<u4'), |
|
176 | ('nNumTaus','<u4'), | |
177 | ('nCodeType','<u4'), |
|
177 | ('nCodeType','<u4'), | |
178 | ('nLine6Function','<u4'), |
|
178 | ('nLine6Function','<u4'), | |
179 | ('nLine5Function','<u4'), |
|
179 | ('nLine5Function','<u4'), | |
180 | ('fClock','<f4'), |
|
180 | ('fClock','<f4'), | |
181 | ('nPrePulseBefore','<u4'), |
|
181 | ('nPrePulseBefore','<u4'), | |
182 | ('nPrePulseAfter','<u4'), |
|
182 | ('nPrePulseAfter','<u4'), | |
183 | ('sRangeIPP','<a20'), |
|
183 | ('sRangeIPP','<a20'), | |
184 | ('sRangeTxA','<a20'), |
|
184 | ('sRangeTxA','<a20'), | |
185 | ('sRangeTxB','<a20'), |
|
185 | ('sRangeTxB','<a20'), | |
186 | ]) |
|
186 | ]) | |
187 |
|
187 | |||
188 | self.samplingWindowStruct = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
188 | self.samplingWindowStruct = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) | |
189 |
|
189 | |||
190 | self.samplingWindow = None |
|
190 | self.samplingWindow = None | |
191 | self.nHeights = None |
|
191 | self.nHeights = None | |
192 | self.firstHeight = None |
|
192 | self.firstHeight = None | |
193 | self.deltaHeight = None |
|
193 | self.deltaHeight = None | |
194 | self.samplesWin = None |
|
194 | self.samplesWin = None | |
195 |
|
195 | |||
196 | self.nCode = None |
|
196 | self.nCode = None | |
197 | self.nBaud = None |
|
197 | self.nBaud = None | |
198 | self.code = None |
|
198 | self.code = None | |
199 | self.flip1 = None |
|
199 | self.flip1 = None | |
200 | self.flip2 = None |
|
200 | self.flip2 = None | |
201 |
|
201 | |||
202 | self.dynamic = numpy.array([],numpy.dtype('byte')) |
|
202 | self.dynamic = numpy.array([],numpy.dtype('byte')) | |
203 |
|
203 | |||
204 |
|
204 | |||
205 | def read(self, fp): |
|
205 | def read(self, fp): | |
206 | try: |
|
206 | try: | |
207 | startFp = fp.tell() |
|
207 | startFp = fp.tell() | |
208 | header = numpy.fromfile(fp,self.struct,1) |
|
208 | header = numpy.fromfile(fp,self.struct,1) | |
209 | self.size = header['nSize'][0] |
|
209 | self.size = header['nSize'][0] | |
210 | self.expType = header['nExpType'][0] |
|
210 | self.expType = header['nExpType'][0] | |
211 | self.nTx = header['nNTx'][0] |
|
211 | self.nTx = header['nNTx'][0] | |
212 | self.ipp = header['fIpp'][0] |
|
212 | self.ipp = header['fIpp'][0] | |
213 | self.txA = header['fTxA'][0] |
|
213 | self.txA = header['fTxA'][0] | |
214 | self.txB = header['fTxB'][0] |
|
214 | self.txB = header['fTxB'][0] | |
215 | self.nWindows = header['nNumWindows'][0] |
|
215 | self.nWindows = header['nNumWindows'][0] | |
216 | self.numTaus = header['nNumTaus'][0] |
|
216 | self.numTaus = header['nNumTaus'][0] | |
217 | self.codeType = header['nCodeType'][0] |
|
217 | self.codeType = header['nCodeType'][0] | |
218 | self.line6Function = header['nLine6Function'][0] |
|
218 | self.line6Function = header['nLine6Function'][0] | |
219 | self.line5Function = header['nLine5Function'][0] |
|
219 | self.line5Function = header['nLine5Function'][0] | |
220 | self.fClock = header['fClock'][0] |
|
220 | self.fClock = header['fClock'][0] | |
221 | self.prePulseBefore = header['nPrePulseBefore'][0] |
|
221 | self.prePulseBefore = header['nPrePulseBefore'][0] | |
222 | self.prePulserAfter = header['nPrePulseAfter'][0] |
|
222 | self.prePulserAfter = header['nPrePulseAfter'][0] | |
223 | self.rangeIpp = header['sRangeIPP'][0] |
|
223 | self.rangeIpp = header['sRangeIPP'][0] | |
224 | self.rangeTxA = header['sRangeTxA'][0] |
|
224 | self.rangeTxA = header['sRangeTxA'][0] | |
225 | self.rangeTxB = header['sRangeTxB'][0] |
|
225 | self.rangeTxB = header['sRangeTxB'][0] | |
226 | # jump Dynamic Radar Controller Header |
|
226 | # jump Dynamic Radar Controller Header | |
227 | jumpFp = self.size - 116 |
|
227 | jumpFp = self.size - 116 | |
228 | self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpFp) |
|
228 | self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpFp) | |
229 | #pointer backward to dynamic header and read |
|
229 | #pointer backward to dynamic header and read | |
230 | backFp = fp.tell() - jumpFp |
|
230 | backFp = fp.tell() - jumpFp | |
231 | fp.seek(backFp) |
|
231 | fp.seek(backFp) | |
232 |
|
232 | |||
233 | self.samplingWindow = numpy.fromfile(fp,self.samplingWindowStruct,self.nWindows) |
|
233 | self.samplingWindow = numpy.fromfile(fp,self.samplingWindowStruct,self.nWindows) | |
234 | self.nHeights = numpy.sum(self.samplingWindow['nsa']) |
|
234 | self.nHeights = numpy.sum(self.samplingWindow['nsa']) | |
235 | self.firstHeight = self.samplingWindow['h0'] |
|
235 | self.firstHeight = self.samplingWindow['h0'] | |
236 | self.deltaHeight = self.samplingWindow['dh'] |
|
236 | self.deltaHeight = self.samplingWindow['dh'] | |
237 | self.samplesWin = self.samplingWindow['nsa'] |
|
237 | self.samplesWin = self.samplingWindow['nsa'] | |
238 |
|
238 | |||
239 | self.Taus = numpy.fromfile(fp,'<f4',self.numTaus) |
|
239 | self.Taus = numpy.fromfile(fp,'<f4',self.numTaus) | |
240 |
|
240 | |||
241 | if self.codeType != 0: |
|
241 | if self.codeType != 0: | |
242 | self.nCode = numpy.fromfile(fp,'<u4',1) |
|
242 | self.nCode = numpy.fromfile(fp,'<u4',1) | |
243 | self.nBaud = numpy.fromfile(fp,'<u4',1) |
|
243 | self.nBaud = numpy.fromfile(fp,'<u4',1) | |
244 | self.code = numpy.empty([self.nCode,self.nBaud],dtype='u1') |
|
244 | self.code = numpy.empty([self.nCode,self.nBaud],dtype='u1') | |
245 | tempList = [] |
|
245 | tempList = [] | |
246 | for ic in range(self.nCode): |
|
246 | for ic in range(self.nCode): | |
247 | temp = numpy.fromfile(fp,'u1',4*numpy.ceil(self.nBaud/32.)) |
|
247 | temp = numpy.fromfile(fp,'u1',4*numpy.ceil(self.nBaud/32.)) | |
248 | tempList.append(temp) |
|
248 | tempList.append(temp) | |
249 | self.code[ic] = numpy.unpackbits(temp[::-1])[-1*self.nBaud:] |
|
249 | self.code[ic] = numpy.unpackbits(temp[::-1])[-1*self.nBaud:] | |
250 | self.code = 2.0*self.code - 1.0 |
|
250 | self.code = 2.0*self.code - 1.0 | |
251 |
|
251 | |||
252 | if self.line5Function == RCfunction.FLIP: |
|
252 | if self.line5Function == RCfunction.FLIP: | |
253 | self.flip1 = numpy.fromfile(fp,'<u4',1) |
|
253 | self.flip1 = numpy.fromfile(fp,'<u4',1) | |
254 |
|
254 | |||
255 | if self.line6Function == RCfunction.FLIP: |
|
255 | if self.line6Function == RCfunction.FLIP: | |
256 | self.flip2 = numpy.fromfile(fp,'<u4',1) |
|
256 | self.flip2 = numpy.fromfile(fp,'<u4',1) | |
257 |
|
257 | |||
258 | endFp = self.size + startFp |
|
258 | endFp = self.size + startFp | |
259 | jumpFp = endFp - fp.tell() |
|
259 | jumpFp = endFp - fp.tell() | |
260 | if jumpFp > 0: |
|
260 | if jumpFp > 0: | |
261 | fp.seek(jumpFp) |
|
261 | fp.seek(jumpFp) | |
262 |
|
262 | |||
263 | except: |
|
263 | except: | |
264 | return 0 |
|
264 | return 0 | |
265 |
|
265 | |||
266 | return 1 |
|
266 | return 1 | |
267 |
|
267 | |||
268 | def write(self, fp): |
|
268 | def write(self, fp): | |
269 | headerTuple = (self.size, |
|
269 | headerTuple = (self.size, | |
270 | self.expType, |
|
270 | self.expType, | |
271 | self.nTx, |
|
271 | self.nTx, | |
272 | self.ipp, |
|
272 | self.ipp, | |
273 | self.txA, |
|
273 | self.txA, | |
274 | self.txB, |
|
274 | self.txB, | |
275 | self.nWindows, |
|
275 | self.nWindows, | |
276 | self.numTaus, |
|
276 | self.numTaus, | |
277 | self.codeType, |
|
277 | self.codeType, | |
278 | self.line6Function, |
|
278 | self.line6Function, | |
279 | self.line5Function, |
|
279 | self.line5Function, | |
280 | self.fClock, |
|
280 | self.fClock, | |
281 | self.prePulseBefore, |
|
281 | self.prePulseBefore, | |
282 | self.prePulserAfter, |
|
282 | self.prePulserAfter, | |
283 | self.rangeIpp, |
|
283 | self.rangeIpp, | |
284 | self.rangeTxA, |
|
284 | self.rangeTxA, | |
285 | self.rangeTxB) |
|
285 | self.rangeTxB) | |
286 |
|
286 | |||
287 | header = numpy.array(headerTuple,self.struct) |
|
287 | header = numpy.array(headerTuple,self.struct) | |
288 | header.tofile(fp) |
|
288 | header.tofile(fp) | |
289 |
|
289 | |||
290 | dynamic = self.dynamic |
|
290 | dynamic = self.dynamic | |
291 | dynamic.tofile(fp) |
|
291 | dynamic.tofile(fp) | |
292 |
|
292 | |||
293 | return 1 |
|
293 | return 1 | |
294 |
|
294 | |||
295 |
|
295 | |||
296 |
|
296 | |||
297 | class ProcessingHeader(Header): |
|
297 | class ProcessingHeader(Header): | |
298 |
|
298 | |||
299 | size = None |
|
299 | size = None | |
300 | dtype = None |
|
300 | dtype = None | |
301 | blockSize = None |
|
301 | blockSize = None | |
302 | profilesPerBlock = None |
|
302 | profilesPerBlock = None | |
303 | dataBlocksPerFile = None |
|
303 | dataBlocksPerFile = None | |
304 | nWindows = None |
|
304 | nWindows = None | |
305 | processFlags = None |
|
305 | processFlags = None | |
306 | nCohInt = None |
|
306 | nCohInt = None | |
307 | nIncohInt = None |
|
307 | nIncohInt = None | |
308 | totalSpectra = None |
|
308 | totalSpectra = None | |
309 | struct = None |
|
309 | struct = None | |
310 | flag_dc = None |
|
310 | flag_dc = None | |
311 | flag_cspc = None |
|
311 | flag_cspc = None | |
312 |
|
312 | |||
313 | def __init__(self): |
|
313 | def __init__(self): | |
314 | self.size = 0 |
|
314 | self.size = 0 | |
315 |
self.d |
|
315 | self.dtype = 0 | |
316 | self.blockSize = 0 |
|
316 | self.blockSize = 0 | |
317 | self.profilesPerBlock = 0 |
|
317 | self.profilesPerBlock = 0 | |
318 | self.dataBlocksPerFile = 0 |
|
318 | self.dataBlocksPerFile = 0 | |
319 | self.nWindows = 0 |
|
319 | self.nWindows = 0 | |
320 | self.processFlags = 0 |
|
320 | self.processFlags = 0 | |
321 | self.nCohInt = 0 |
|
321 | self.nCohInt = 0 | |
322 | self.nIncohInt = 0 |
|
322 | self.nIncohInt = 0 | |
323 | self.totalSpectra = 0 |
|
323 | self.totalSpectra = 0 | |
324 | self.struct = numpy.dtype([ |
|
324 | self.struct = numpy.dtype([ | |
325 | ('nSize','<u4'), |
|
325 | ('nSize','<u4'), | |
326 | ('nDataType','<u4'), |
|
326 | ('nDataType','<u4'), | |
327 | ('nSizeOfDataBlock','<u4'), |
|
327 | ('nSizeOfDataBlock','<u4'), | |
328 | ('nProfilesperBlock','<u4'), |
|
328 | ('nProfilesperBlock','<u4'), | |
329 | ('nDataBlocksperFile','<u4'), |
|
329 | ('nDataBlocksperFile','<u4'), | |
330 | ('nNumWindows','<u4'), |
|
330 | ('nNumWindows','<u4'), | |
331 | ('nProcessFlags','<u4'), |
|
331 | ('nProcessFlags','<u4'), | |
332 | ('nCoherentIntegrations','<u4'), |
|
332 | ('nCoherentIntegrations','<u4'), | |
333 | ('nIncoherentIntegrations','<u4'), |
|
333 | ('nIncoherentIntegrations','<u4'), | |
334 | ('nTotalSpectra','<u4') |
|
334 | ('nTotalSpectra','<u4') | |
335 | ]) |
|
335 | ]) | |
336 | self.samplingWindow = 0 |
|
336 | self.samplingWindow = 0 | |
337 | self.structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
337 | self.structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) | |
338 | self.nHeights = 0 |
|
338 | self.nHeights = 0 | |
339 | self.firstHeight = 0 |
|
339 | self.firstHeight = 0 | |
340 | self.deltaHeight = 0 |
|
340 | self.deltaHeight = 0 | |
341 | self.samplesWin = 0 |
|
341 | self.samplesWin = 0 | |
342 | self.spectraComb = 0 |
|
342 | self.spectraComb = 0 | |
343 | self.nCode = None |
|
343 | self.nCode = None | |
344 | self.code = None |
|
344 | self.code = None | |
345 | self.nBaud = None |
|
345 | self.nBaud = None | |
346 | self.shif_fft = False |
|
346 | self.shif_fft = False | |
347 | self.flag_dc = False |
|
347 | self.flag_dc = False | |
348 | self.flag_cspc = False |
|
348 | self.flag_cspc = False | |
349 |
|
349 | |||
350 | def read(self, fp): |
|
350 | def read(self, fp): | |
351 | try: |
|
351 | try: | |
352 | header = numpy.fromfile(fp,self.struct,1) |
|
352 | header = numpy.fromfile(fp,self.struct,1) | |
353 | self.size = header['nSize'][0] |
|
353 | self.size = header['nSize'][0] | |
354 |
self.d |
|
354 | self.dtype = header['nDataType'][0] | |
355 | self.blockSize = header['nSizeOfDataBlock'][0] |
|
355 | self.blockSize = header['nSizeOfDataBlock'][0] | |
356 | self.profilesPerBlock = header['nProfilesperBlock'][0] |
|
356 | self.profilesPerBlock = header['nProfilesperBlock'][0] | |
357 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] |
|
357 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] | |
358 | self.nWindows = header['nNumWindows'][0] |
|
358 | self.nWindows = header['nNumWindows'][0] | |
359 | self.processFlags = header['nProcessFlags'] |
|
359 | self.processFlags = header['nProcessFlags'] | |
360 | self.nCohInt = header['nCoherentIntegrations'][0] |
|
360 | self.nCohInt = header['nCoherentIntegrations'][0] | |
361 | self.nIncohInt = header['nIncoherentIntegrations'][0] |
|
361 | self.nIncohInt = header['nIncoherentIntegrations'][0] | |
362 | self.totalSpectra = header['nTotalSpectra'][0] |
|
362 | self.totalSpectra = header['nTotalSpectra'][0] | |
363 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.nWindows) |
|
363 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.nWindows) | |
364 | self.nHeights = numpy.sum(self.samplingWindow['nsa']) |
|
364 | self.nHeights = numpy.sum(self.samplingWindow['nsa']) | |
365 | self.firstHeight = self.samplingWindow['h0'][0] |
|
365 | self.firstHeight = self.samplingWindow['h0'][0] | |
366 | self.deltaHeight = self.samplingWindow['dh'][0] |
|
366 | self.deltaHeight = self.samplingWindow['dh'][0] | |
367 | self.samplesWin = self.samplingWindow['nsa'] |
|
367 | self.samplesWin = self.samplingWindow['nsa'] | |
368 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) |
|
368 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) | |
369 |
|
369 | |||
370 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): |
|
370 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): | |
371 | self.nCode = numpy.fromfile(fp,'<u4',1) |
|
371 | self.nCode = numpy.fromfile(fp,'<u4',1) | |
372 | self.nBaud = numpy.fromfile(fp,'<u4',1) |
|
372 | self.nBaud = numpy.fromfile(fp,'<u4',1) | |
373 | self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nBaud,self.nCode) |
|
373 | self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nBaud,self.nCode) | |
374 |
|
374 | |||
375 | if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA): |
|
375 | if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA): | |
376 | self.shif_fft = True |
|
376 | self.shif_fft = True | |
377 | else: |
|
377 | else: | |
378 | self.shif_fft = False |
|
378 | self.shif_fft = False | |
379 |
|
379 | |||
380 | if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC): |
|
380 | if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC): | |
381 | self.flag_dc = True |
|
381 | self.flag_dc = True | |
382 |
|
382 | |||
383 | nChannels = 0 |
|
383 | nChannels = 0 | |
384 | nPairs = 0 |
|
384 | nPairs = 0 | |
385 | pairList = [] |
|
385 | pairList = [] | |
386 |
|
386 | |||
387 | for i in range( 0, self.totalSpectra*2, 2 ): |
|
387 | for i in range( 0, self.totalSpectra*2, 2 ): | |
388 | if self.spectraComb[i] == self.spectraComb[i+1]: |
|
388 | if self.spectraComb[i] == self.spectraComb[i+1]: | |
389 | nChannels = nChannels + 1 #par de canales iguales |
|
389 | nChannels = nChannels + 1 #par de canales iguales | |
390 | else: |
|
390 | else: | |
391 | nPairs = nPairs + 1 #par de canales diferentes |
|
391 | nPairs = nPairs + 1 #par de canales diferentes | |
392 | pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) ) |
|
392 | pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) ) | |
393 |
|
393 | |||
394 | self.flag_cspc = False |
|
394 | self.flag_cspc = False | |
395 | if nPairs > 0: |
|
395 | if nPairs > 0: | |
396 | self.flag_cspc = True |
|
396 | self.flag_cspc = True | |
397 |
|
397 | |||
398 | except: |
|
398 | except: | |
399 | return 0 |
|
399 | return 0 | |
400 |
|
400 | |||
401 | return 1 |
|
401 | return 1 | |
402 |
|
402 | |||
403 | def write(self, fp): |
|
403 | def write(self, fp): | |
404 | headerTuple = (self.size, |
|
404 | headerTuple = (self.size, | |
405 |
self.d |
|
405 | self.dtype, | |
406 | self.blockSize, |
|
406 | self.blockSize, | |
407 | self.profilesPerBlock, |
|
407 | self.profilesPerBlock, | |
408 | self.dataBlocksPerFile, |
|
408 | self.dataBlocksPerFile, | |
409 | self.nWindows, |
|
409 | self.nWindows, | |
410 | self.processFlags, |
|
410 | self.processFlags, | |
411 | self.nCohInt, |
|
411 | self.nCohInt, | |
412 | self.nIncohInt, |
|
412 | self.nIncohInt, | |
413 | self.totalSpectra) |
|
413 | self.totalSpectra) | |
414 |
|
414 | |||
415 | header = numpy.array(headerTuple,self.struct) |
|
415 | header = numpy.array(headerTuple,self.struct) | |
416 | header.tofile(fp) |
|
416 | header.tofile(fp) | |
417 |
|
417 | |||
418 | if self.nWindows != 0: |
|
418 | if self.nWindows != 0: | |
419 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
419 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) | |
420 | samplingWindow = numpy.array(sampleWindowTuple,self.structSamplingWindow) |
|
420 | samplingWindow = numpy.array(sampleWindowTuple,self.structSamplingWindow) | |
421 | samplingWindow.tofile(fp) |
|
421 | samplingWindow.tofile(fp) | |
422 |
|
422 | |||
423 |
|
423 | |||
424 | if self.totalSpectra != 0: |
|
424 | if self.totalSpectra != 0: | |
425 | spectraComb = numpy.array([],numpy.dtype('u1')) |
|
425 | spectraComb = numpy.array([],numpy.dtype('u1')) | |
426 | spectraComb = self.spectraComb |
|
426 | spectraComb = self.spectraComb | |
427 | spectraComb.tofile(fp) |
|
427 | spectraComb.tofile(fp) | |
428 |
|
428 | |||
429 |
|
429 | |||
430 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
430 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: | |
431 | nCode = self.nCode #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba |
|
431 | nCode = self.nCode #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba | |
432 | nCode.tofile(fp) |
|
432 | nCode.tofile(fp) | |
433 |
|
433 | |||
434 | nBaud = self.nBaud |
|
434 | nBaud = self.nBaud | |
435 | nBaud.tofile(fp) |
|
435 | nBaud.tofile(fp) | |
436 |
|
436 | |||
437 | code = self.code.reshape(nCode*nBaud) |
|
437 | code = self.code.reshape(nCode*nBaud) | |
438 | code.tofile(fp) |
|
438 | code.tofile(fp) | |
439 |
|
439 | |||
440 | return 1 |
|
440 | return 1 | |
441 |
|
441 | |||
442 | class RCfunction: |
|
442 | class RCfunction: | |
443 | NONE=0 |
|
443 | NONE=0 | |
444 | FLIP=1 |
|
444 | FLIP=1 | |
445 | CODE=2 |
|
445 | CODE=2 | |
446 | SAMPLING=3 |
|
446 | SAMPLING=3 | |
447 | LIN6DIV256=4 |
|
447 | LIN6DIV256=4 | |
448 | SYNCHRO=5 |
|
448 | SYNCHRO=5 | |
449 |
|
449 | |||
450 | class nCodeType: |
|
450 | class nCodeType: | |
451 | NONE=0 |
|
451 | NONE=0 | |
452 | USERDEFINE=1 |
|
452 | USERDEFINE=1 | |
453 | BARKER2=2 |
|
453 | BARKER2=2 | |
454 | BARKER3=3 |
|
454 | BARKER3=3 | |
455 | BARKER4=4 |
|
455 | BARKER4=4 | |
456 | BARKER5=5 |
|
456 | BARKER5=5 | |
457 | BARKER7=6 |
|
457 | BARKER7=6 | |
458 | BARKER11=7 |
|
458 | BARKER11=7 | |
459 | BARKER13=8 |
|
459 | BARKER13=8 | |
460 | AC128=9 |
|
460 | AC128=9 | |
461 | COMPLEMENTARYCODE2=10 |
|
461 | COMPLEMENTARYCODE2=10 | |
462 | COMPLEMENTARYCODE4=11 |
|
462 | COMPLEMENTARYCODE4=11 | |
463 | COMPLEMENTARYCODE8=12 |
|
463 | COMPLEMENTARYCODE8=12 | |
464 | COMPLEMENTARYCODE16=13 |
|
464 | COMPLEMENTARYCODE16=13 | |
465 | COMPLEMENTARYCODE32=14 |
|
465 | COMPLEMENTARYCODE32=14 | |
466 | COMPLEMENTARYCODE64=15 |
|
466 | COMPLEMENTARYCODE64=15 | |
467 | COMPLEMENTARYCODE128=16 |
|
467 | COMPLEMENTARYCODE128=16 | |
468 | CODE_BINARY28=17 |
|
468 | CODE_BINARY28=17 | |
469 |
|
469 | |||
470 | class PROCFLAG: |
|
470 | class PROCFLAG: | |
471 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
471 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) | |
472 | DECODE_DATA = numpy.uint32(0x00000002) |
|
472 | DECODE_DATA = numpy.uint32(0x00000002) | |
473 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
473 | SPECTRA_CALC = numpy.uint32(0x00000004) | |
474 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
474 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) | |
475 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
475 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) | |
476 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
476 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) | |
477 |
|
477 | |||
478 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
478 | DATATYPE_CHAR = numpy.uint32(0x00000040) | |
479 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
479 | DATATYPE_SHORT = numpy.uint32(0x00000080) | |
480 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
480 | DATATYPE_LONG = numpy.uint32(0x00000100) | |
481 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
481 | DATATYPE_INT64 = numpy.uint32(0x00000200) | |
482 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
482 | DATATYPE_FLOAT = numpy.uint32(0x00000400) | |
483 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
483 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) | |
484 |
|
484 | |||
485 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
485 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) | |
486 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
486 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) | |
487 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
487 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) | |
488 |
|
488 | |||
489 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
489 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) | |
490 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
490 | DEFLIP_DATA = numpy.uint32(0x00010000) | |
491 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
491 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) | |
492 |
|
492 | |||
493 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
493 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) | |
494 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
494 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) | |
495 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
495 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) | |
496 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
496 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) | |
497 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
497 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) | |
498 |
|
498 | |||
499 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
499 | EXP_NAME_ESP = numpy.uint32(0x00200000) | |
500 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
500 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) | |
501 |
|
501 | |||
502 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
502 | OPERATION_MASK = numpy.uint32(0x0000003F) | |
503 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
503 | DATATYPE_MASK = numpy.uint32(0x00000FC0) | |
504 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
504 | DATAARRANGE_MASK = numpy.uint32(0x00007000) | |
505 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) No newline at end of file |
|
505 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
@@ -1,516 +1,530 | |||||
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 SpectraHeis |
|
14 | from Data.JROData import SpectraHeis | |
15 | from IO.SpectraIO import SpectraWriter |
|
15 | from IO.SpectraIO import SpectraWriter | |
16 | #from Graphics.schainPlotTypes import SpcFigure |
|
16 | #from Graphics.schainPlotTypes import SpcFigure | |
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 |
|
40 | |||
41 | def __init__(self): |
|
41 | def __init__(self): | |
42 | ''' |
|
42 | ''' | |
43 | Constructor |
|
43 | Constructor | |
44 | ''' |
|
44 | ''' | |
45 |
|
45 | |||
46 | self.integratorObjIndex = None |
|
46 | self.integratorObjIndex = None | |
47 | self.writerObjIndex = None |
|
47 | self.writerObjIndex = None | |
48 | self.plotObjIndex = None |
|
48 | self.plotObjIndex = None | |
49 | self.integratorOst = [] |
|
49 | self.integratorOst = [] | |
50 | self.plotObjList = [] |
|
50 | self.plotObjList = [] | |
51 | self.noiseObj = bjList = [] |
|
51 | self.noiseObj = bjList = [] | |
52 | self.writerObjLiNone |
|
52 | self.writerObjLiNone | |
53 | self.buffer = None |
|
53 | self.buffer = None | |
54 | self.profIndex = 0 |
|
54 | self.profIndex = 0 | |
55 |
|
55 | |||
56 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): |
|
56 | def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): | |
57 |
|
57 | |||
58 | if dataInObj == None: |
|
58 | if dataInObj == None: | |
59 | raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" |
|
59 | raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" | |
60 |
|
60 | |||
61 | if dataInObj.type == "Voltage": |
|
61 | if dataInObj.type == "Voltage": | |
62 | if nFFTPoints == None: |
|
62 | if nFFTPoints == None: | |
63 | raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable" |
|
63 | raise ValueError, "This SpectraProcessor.setup() function needs nFFTPoints input variable" | |
64 | else: |
|
64 | else: | |
65 | nFFTPoints = dataInObj.nFFTPoints |
|
65 | nFFTPoints = dataInObj.nFFTPoints | |
66 |
|
66 | |||
67 | self.dataInObj = dataInObj |
|
67 | self.dataInObj = dataInObj | |
68 |
|
68 | |||
69 | if dataOutObj == None: |
|
69 | if dataOutObj == None: | |
70 | dataOutObj = Spectra() |
|
70 | dataOutObj = Spectra() | |
71 |
|
71 | |||
72 | self.dataOutObj = dataOutObj |
|
72 | self.dataOutObj = dataOutObj | |
73 |
|
73 | |||
74 | return self.dataOutObj |
|
74 | return self.dataOutObj | |
75 |
|
75 | |||
76 | def init(self): |
|
76 | def init(self): | |
77 |
|
77 | |||
78 | self.integratorObjIndex = 0 |
|
78 | self.integratorObjIndex = 0 | |
79 | self.writerObjIndex = 0 |
|
79 | self.writerObjIndex = 0 | |
80 | self.plotObjIndex = 0 |
|
80 | self.plotObjIndex = 0 | |
81 | if self.dataInObj.type == "Voltage": |
|
81 | if self.dataInObj.type == "Voltage": | |
82 |
|
82 | |||
83 | if self.buffer == None: |
|
83 | if self.buffer == None: | |
84 | self.buffer = numpy.zeros((self.nChannels, |
|
84 | self.buffer = numpy.zeros((self.nChannels, | |
85 | self.nFFTPoints, |
|
85 | self.nFFTPoints, | |
86 | self.dataInObj.nHeights), |
|
86 | self.dataInObj.nHeights), | |
87 | dtype='complex') |
|
87 | dtype='complex') | |
88 |
|
88 | |||
89 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
89 | self.buffer[:,self.profIndex,:] = self.dataInObj.data | |
90 | self.profIndex += 1 |
|
90 | self.profIndex += 1 | |
91 |
|
91 | |||
92 | if self.profIndex == self.nFFTPoints: |
|
92 | if self.profIndex == self.nFFTPoints: | |
93 | self.__getFft() |
|
93 | self.__getFft() | |
94 | self.dataOutObj.flagNoData = False |
|
94 | self.dataOutObj.flagNoData = False | |
95 |
|
95 | |||
96 | self.buffer = None |
|
96 | self.buffer = None | |
97 | self.profIndex = 0 |
|
97 | self.profIndex = 0 | |
98 | return |
|
98 | return | |
99 |
|
99 | |||
100 | self.dataOutObj.flagNoData = True |
|
100 | self.dataOutObj.flagNoData = True | |
101 |
|
101 | |||
102 | return |
|
102 | return | |
103 |
|
103 | |||
104 | #Other kind of data |
|
104 | #Other kind of data | |
105 | if self.dataInObj.type == "Spectra": |
|
105 | if self.dataInObj.type == "Spectra": | |
106 | self.dataOutObj.copy(self.dataInObj) |
|
106 | self.dataOutObj.copy(self.dataInObj) | |
107 | self.dataOutObj.flagNoData = False |
|
107 | self.dataOutObj.flagNoData = False | |
108 | return |
|
108 | return | |
109 |
|
109 | |||
110 |
raise ValueError, "The d |
|
110 | raise ValueError, "The dtype is not valid" | |
111 |
|
111 | |||
112 | def __getFft(self): |
|
112 | def __getFft(self): | |
113 | """ |
|
113 | """ | |
114 | Convierte valores de Voltaje a Spectra |
|
114 | Convierte valores de Voltaje a Spectra | |
115 |
|
115 | |||
116 | Affected: |
|
116 | Affected: | |
117 | self.dataOutObj.data_spc |
|
117 | self.dataOutObj.data_spc | |
118 | self.dataOutObj.data_cspc |
|
118 | self.dataOutObj.data_cspc | |
119 | self.dataOutObj.data_dc |
|
119 | self.dataOutObj.data_dc | |
120 | self.dataOutObj.heightList |
|
120 | self.dataOutObj.heightList | |
121 | self.dataOutObj.m_BasicHeader |
|
121 | self.dataOutObj.m_BasicHeader | |
122 | self.dataOutObj.m_ProcessingHeader |
|
122 | self.dataOutObj.m_ProcessingHeader | |
123 |
self.dataOutObj. |
|
123 | self.dataOutObj.radarControllerHeaderObj | |
124 |
self.dataOutObj. |
|
124 | self.dataOutObj.systemHeaderObj | |
125 | self.profIndex |
|
125 | self.profIndex | |
126 | self.buffer |
|
126 | self.buffer | |
127 | self.dataOutObj.flagNoData |
|
127 | self.dataOutObj.flagNoData | |
128 |
self.dataOutObj.d |
|
128 | self.dataOutObj.dtype | |
129 | self.dataOutObj.nPairs |
|
129 | self.dataOutObj.nPairs | |
130 | self.dataOutObj.nChannels |
|
130 | self.dataOutObj.nChannels | |
131 | self.dataOutObj.nProfiles |
|
131 | self.dataOutObj.nProfiles | |
132 |
self.dataOutObj. |
|
132 | self.dataOutObj.systemHeaderObj.numChannels | |
133 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
133 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |
134 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock |
|
134 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock | |
135 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
135 | self.dataOutObj.m_ProcessingHeader.numHeights | |
136 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
136 | self.dataOutObj.m_ProcessingHeader.spectraComb | |
137 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
137 | self.dataOutObj.m_ProcessingHeader.shif_fft | |
138 | """ |
|
138 | """ | |
139 |
|
139 | |||
140 | if self.dataInObj.flagNoData: |
|
140 | if self.dataInObj.flagNoData: | |
141 | return 0 |
|
141 | return 0 | |
142 |
|
142 | |||
143 | fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
143 | fft_volt = numpy.fft.fft(self.buffer,axis=1) | |
144 | dc = fft_volt[:,0,:] |
|
144 | dc = fft_volt[:,0,:] | |
145 |
|
145 | |||
146 | #calculo de self-spectra |
|
146 | #calculo de self-spectra | |
147 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
147 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
148 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
148 | spc = fft_volt * numpy.conjugate(fft_volt) | |
149 | spc = spc.real |
|
149 | spc = spc.real | |
150 |
|
150 | |||
151 | blocksize = 0 |
|
151 | blocksize = 0 | |
152 | blocksize += dc.size |
|
152 | blocksize += dc.size | |
153 | blocksize += spc.size |
|
153 | blocksize += spc.size | |
154 |
|
154 | |||
155 | cspc = None |
|
155 | cspc = None | |
156 | pairIndex = 0 |
|
156 | pairIndex = 0 | |
157 | if self.pairList != None: |
|
157 | if self.pairList != None: | |
158 | #calculo de cross-spectra |
|
158 | #calculo de cross-spectra | |
159 | cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex') |
|
159 | cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex') | |
160 | for pair in self.pairList: |
|
160 | for pair in self.pairList: | |
161 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) |
|
161 | cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) | |
162 | pairIndex += 1 |
|
162 | pairIndex += 1 | |
163 | blocksize += cspc.size |
|
163 | blocksize += cspc.size | |
164 |
|
164 | |||
165 | self.dataOutObj.data_spc = spc |
|
165 | self.dataOutObj.data_spc = spc | |
166 | self.dataOutObj.data_cspc = cspc |
|
166 | self.dataOutObj.data_cspc = cspc | |
167 | self.dataOutObj.data_dc = dc |
|
167 | self.dataOutObj.data_dc = dc | |
168 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
168 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize | |
169 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc |
|
169 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc | |
170 |
|
170 | |||
171 | # self.getNoise() |
|
171 | # self.getNoise() | |
172 |
|
172 | |||
173 | def addWriter(self, wrpath, blocksPerFile): |
|
173 | def addWriter(self, wrpath, blocksPerFile): | |
174 | objWriter = SpectraWriter(self.dataOutObj) |
|
174 | objWriter = SpectraWriter(self.dataOutObj) | |
175 | objWriter.setup(wrpath, blocksPerFile) |
|
175 | objWriter.setup(wrpath, blocksPerFile) | |
176 | self.writerObjList.append(objWriter) |
|
176 | self.writerObjList.append(objWriter) | |
177 |
|
177 | |||
178 | def addIntegrator(self,N,timeInterval): |
|
178 | def addIntegrator(self,N,timeInterval): | |
179 |
|
179 | |||
180 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
180 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
181 | self.integratorObjList.append(objIncohInt) |
|
181 | self.integratorObjList.append(objIncohInt) | |
182 |
|
182 | |||
183 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
183 | def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
184 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
184 | spcObj = SpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
185 | self.plotObjList.append(spcObj) |
|
185 | self.plotObjList.append(spcObj) | |
186 |
|
186 | |||
187 | def plotSpc(self, idfigure=None, |
|
187 | def plotSpc(self, idfigure=None, | |
188 | xmin=None, |
|
188 | xmin=None, | |
189 | xmax=None, |
|
189 | xmax=None, | |
190 | ymin=None, |
|
190 | ymin=None, | |
191 | ymax=None, |
|
191 | ymax=None, | |
192 | minvalue=None, |
|
192 | minvalue=None, | |
193 | maxvalue=None, |
|
193 | maxvalue=None, | |
194 | wintitle='', |
|
194 | wintitle='', | |
195 | driver='plplot', |
|
195 | driver='plplot', | |
196 | colormap='br_greeen', |
|
196 | colormap='br_greeen', | |
197 | colorbar=True, |
|
197 | colorbar=True, | |
198 | showprofile=False, |
|
198 | showprofile=False, | |
199 | save=False, |
|
199 | save=False, | |
200 | gpath=None): |
|
200 | gpath=None): | |
201 |
|
201 | |||
202 | if self.dataOutObj.flagNoData: |
|
202 | if self.dataOutObj.flagNoData: | |
203 | return 0 |
|
203 | return 0 | |
204 |
|
204 | |||
205 | nframes = len(self.dataOutObj.channelList) |
|
205 | nframes = len(self.dataOutObj.channelList) | |
206 |
|
206 | |||
207 | if len(self.plotObjList) <= self.plotObjIndex: |
|
207 | if len(self.plotObjList) <= self.plotObjIndex: | |
208 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
208 | self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
209 |
|
209 | |||
210 | x = numpy.arange(self.dataOutObj.nFFTPoints) |
|
210 | x = numpy.arange(self.dataOutObj.nFFTPoints) | |
211 |
|
211 | |||
212 | y = self.dataOutObj.heightList |
|
212 | y = self.dataOutObj.heightList | |
213 |
|
213 | |||
214 | channelList = self.dataOutObj.channelList |
|
214 | channelList = self.dataOutObj.channelList | |
215 |
|
215 | |||
216 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) |
|
216 | data = 10.*numpy.log10(self.dataOutObj.data_spc[channelList,:,:]) | |
217 | # noisedB = 10.*numpy.log10(noise) |
|
217 | # noisedB = 10.*numpy.log10(noise) | |
218 | noisedB = numpy.arange(len(channelList)+1) |
|
218 | noisedB = numpy.arange(len(channelList)+1) | |
219 | noisedB = noisedB *1.2 |
|
219 | noisedB = noisedB *1.2 | |
220 | titleList = [] |
|
220 | titleList = [] | |
221 | for i in range(len(noisedB)): |
|
221 | for i in range(len(noisedB)): | |
222 | title = "%.2f"%noisedB[i] |
|
222 | title = "%.2f"%noisedB[i] | |
223 | titleList.append(title) |
|
223 | titleList.append(title) | |
224 |
|
224 | |||
225 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) |
|
225 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) | |
226 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
226 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
227 | figuretitle = "Spc Radar Data: %s"%dateTime |
|
227 | figuretitle = "Spc Radar Data: %s"%dateTime | |
228 |
|
228 | |||
229 | cleardata = True |
|
229 | cleardata = True | |
230 |
|
230 | |||
231 | plotObj = self.plotObjList[self.plotObjIndex] |
|
231 | plotObj = self.plotObjList[self.plotObjIndex] | |
232 |
|
232 | |||
233 | plotObj.plotPcolor(data, |
|
233 | plotObj.plotPcolor(data, | |
234 | x, |
|
234 | x, | |
235 | y, |
|
235 | y, | |
236 | channelList, |
|
236 | channelList, | |
237 | xmin, |
|
237 | xmin, | |
238 | xmax, |
|
238 | xmax, | |
239 | ymin, |
|
239 | ymin, | |
240 | ymax, |
|
240 | ymax, | |
241 | minvalue, |
|
241 | minvalue, | |
242 | maxvalue, |
|
242 | maxvalue, | |
243 | figuretitle, |
|
243 | figuretitle, | |
244 | None, |
|
244 | None, | |
245 | save, |
|
245 | save, | |
246 | gpath, |
|
246 | gpath, | |
247 | cleardata, |
|
247 | cleardata, | |
248 | titleList) |
|
248 | titleList) | |
249 |
|
249 | |||
250 | self.plotObjIndex += 1 |
|
250 | self.plotObjIndex += 1 | |
251 |
|
251 | |||
252 |
|
252 | |||
253 | def writeData(self, wrpath, blocksPerFile): |
|
253 | def writeData(self, wrpath, blocksPerFile): | |
254 | if self.dataOutObj.flagNoData: |
|
254 | if self.dataOutObj.flagNoData: | |
255 | return 0 |
|
255 | return 0 | |
256 |
|
256 | |||
257 | if len(self.writerObjList) <= self.writerObjIndex: |
|
257 | if len(self.writerObjList) <= self.writerObjIndex: | |
258 | self.addWriter(wrpath, blocksPerFile) |
|
258 | self.addWriter(wrpath, blocksPerFile) | |
259 |
|
259 | |||
260 | self.writerObjList[self.writerObjIndex].putData() |
|
260 | self.writerObjList[self.writerObjIndex].putData() | |
261 |
|
261 | |||
262 | self.writerObjIndex += 1 |
|
262 | self.writerObjIndex += 1 | |
263 |
|
263 | |||
264 | def integrator(self, N=None, timeInterval=None): |
|
264 | def integrator(self, N=None, timeInterval=None): | |
265 |
|
265 | |||
266 | if self.dataOutObj.flagNoData: |
|
266 | if self.dataOutObj.flagNoData: | |
267 | return 0 |
|
267 | return 0 | |
268 |
|
268 | |||
269 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
269 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
270 | self.addIntegrator(N,timeInterval) |
|
270 | self.addIntegrator(N,timeInterval) | |
271 |
|
271 | |||
272 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
272 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] | |
273 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) |
|
273 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) | |
274 |
|
274 | |||
275 | if myIncohIntObj.isReady: |
|
275 | if myIncohIntObj.isReady: | |
276 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
276 | self.dataOutObj.data_spc = myIncohIntObj.data | |
277 | self.dataOutObj.nAvg = myIncohIntObj.navg |
|
277 | self.dataOutObj.nAvg = myIncohIntObj.navg | |
278 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg |
|
278 | self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg | |
279 | self.dataOutObj.flagNoData = False |
|
279 | self.dataOutObj.flagNoData = False | |
280 |
|
280 | |||
281 | """Calcular el ruido""" |
|
281 | """Calcular el ruido""" | |
282 | self.getNoise() |
|
282 | self.getNoise() | |
283 | else: |
|
283 | else: | |
284 | self.dataOutObj.flagNoData = True |
|
284 | self.dataOutObj.flagNoData = True | |
285 |
|
285 | |||
286 | self.integratorObjIndex += 1 |
|
286 | self.integratorObjIndex += 1 | |
287 |
|
287 | |||
288 |
|
288 | |||
289 | class SpectraHeisProcessor: |
|
289 | class SpectraHeisProcessor: | |
|
290 | ||||
290 | def __init__(self): |
|
291 | def __init__(self): | |
|
292 | ||||
291 | self.integratorObjIndex = None |
|
293 | self.integratorObjIndex = None | |
292 | self.writerObjIndex = None |
|
294 | self.writerObjIndex = None | |
293 | self.plotterObjIndex = None |
|
295 | self.plotterObjIndex = None | |
294 | self.integratorObjList = [] |
|
296 | self.integratorObjList = [] | |
295 | self.writerObjList = [] |
|
297 | self.writerObjList = [] | |
296 | self.plotterObjList = [] |
|
298 | self.plotterObjList = [] | |
297 | #self.noiseObj = Noise() |
|
299 | #self.noiseObj = Noise() | |
298 |
|
300 | |||
299 |
def setup(self,dataInObj |
|
301 | def setup(self, dataInObj, dataOutObj=None, nFFTPoints=None, pairList=None): | |
300 | if dataInObj == None: |
|
|||
301 | raise ValueError, "" |
|
|||
302 |
|
302 | |||
303 | if nFFTPoints == None: |
|
303 | if nFFTPoints == None: | |
304 | raise ValueError, "" |
|
304 | nFFTPoints = self.dataInObj.nHeights | |
305 |
|
305 | |||
306 | self.dataInObj = dataInObj |
|
306 | self.dataInObj = dataInObj | |
307 |
|
307 | |||
308 | if dataOutObj == None: |
|
308 | if dataOutObj == None: | |
309 | dataOutObj = SpectraHeis() |
|
309 | dataOutObj = SpectraHeis() | |
310 |
|
310 | |||
311 | self.dataOutObj = dataOutObj |
|
311 | self.dataOutObj = dataOutObj | |
312 | # self.noiseObj = Noise() |
|
312 | # self.noiseObj = Noise() | |
313 |
|
313 | |||
314 | ########################################## |
|
314 | ########################################## | |
315 | self.nFFTPoints = nFFTPoints |
|
315 | self.nFFTPoints = nFFTPoints | |
316 | self.nChannels = self.dataInObj.nChannels |
|
316 | self.nChannels = self.dataInObj.nChannels | |
317 | self.nHeights = self.dataInObj.nHeights |
|
317 | self.nHeights = self.dataInObj.nHeights | |
318 | self.pairList = pairList |
|
318 | self.pairList = pairList | |
|
319 | ||||
319 | if pairList != None: |
|
320 | if pairList != None: | |
320 | self.nPairs = len(pairList) |
|
321 | self.nPairs = len(pairList) | |
321 | else: |
|
322 | else: | |
322 | self.nPairs = 0 |
|
323 | self.nPairs = 0 | |
323 |
|
324 | |||
324 | self.dataOutObj.heightList = self.dataInObj.heightList |
|
325 | self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy() | |
325 |
self.dataOutObj. |
|
326 | self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy() | |
326 | self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy() |
|
327 | ||
327 | self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy() |
|
328 | self.dataOutObj.type = "SpectraHeis" | |
|
329 | ||||
|
330 | self.dataOutObj.dtype = self.dataInObj.dtype | |||
328 |
|
331 | |||
329 | self.dataOutObj.dataType = self.dataInObj.dataType |
|
|||
330 | self.dataOutObj.nPairs = self.nPairs |
|
|||
331 | self.dataOutObj.nChannels = self.nChannels |
|
332 | self.dataOutObj.nChannels = self.nChannels | |
332 | self.dataOutObj.nProfiles = self.nFFTPoints |
|
333 | ||
333 | self.dataOutObj.nHeights = self.nHeights |
|
334 | self.dataOutObj.nHeights = self.nHeights | |
334 | self.dataOutObj.nFFTPoints = self.nFFTPoints |
|
|||
335 | #self.dataOutObj.data = None |
|
|||
336 |
|
335 | |||
337 |
self.dataOutObj. |
|
336 | self.dataOutObj.nProfiles = self.nFFTPoints | |
338 | self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints |
|
337 | ||
|
338 | self.dataOutObj.heightList = None | |||
|
339 | ||||
|
340 | self.dataOutObj.channelList = None | |||
|
341 | ||||
|
342 | self.dataOutObj.channelIndexList = None | |||
|
343 | ||||
|
344 | self.dataOutObj.flagNoData = False | |||
|
345 | ||||
|
346 | self.dataOutObj.flagTimeBlock = False | |||
|
347 | ||||
|
348 | self.dataOutObj.dataUtcTime = None | |||
339 |
|
349 | |||
340 | self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs |
|
350 | self.dataOutObj.nCode = None | |
341 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints |
|
|||
342 | self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights |
|
|||
343 | self.dataOutObj.m_ProcessingHeader.shif_fft = True |
|
|||
344 |
|
351 | |||
345 | spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1')) |
|
352 | self.dataOutObj.nBaud = None | |
346 | k = 0 |
|
|||
347 | for i in range( 0,self.nChannels*2,2 ): |
|
|||
348 | spectraComb[i] = k |
|
|||
349 | spectraComb[i+1] = k |
|
|||
350 | k += 1 |
|
|||
351 |
|
353 | |||
352 | k *= 2 |
|
354 | self.dataOutObj.code = None | |
|
355 | ||||
|
356 | self.dataOutObj.flagDecodeData = True #asumo q la data esta decodificada | |||
|
357 | ||||
|
358 | self.dataOutObj.flagDeflipData = True #asumo q la data esta sin flip | |||
|
359 | ||||
|
360 | self.dataOutObj.flagShiftFFT = False | |||
|
361 | ||||
|
362 | self.dataOutObj.ippSeconds = None | |||
353 |
|
363 | |||
354 | if self.pairList != None: |
|
364 | self.dataOutObjdata_spc = None | |
355 |
|
365 | |||
356 | for pair in self.pairList: |
|
366 | self.dataOutObjdata_cspc = None | |
357 | spectraComb[k] = pair[0] |
|
367 | ||
358 | spectraComb[k+1] = pair[1] |
|
368 | self.dataOutObjdata_dc = None | |
359 | k += 2 |
|
369 | ||
360 |
|
370 | self.dataOutObjnFFTPoints = None | ||
361 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb |
|
371 | ||
|
372 | self.dataOutObjnPairs = None | |||
|
373 | ||||
|
374 | self.dataOutObjpairsList = None | |||
|
375 | ||||
362 |
|
376 | |||
363 | return self.dataOutObj |
|
377 | return self.dataOutObj | |
364 |
|
378 | |||
365 | def init(self): |
|
379 | def init(self): | |
366 | self.integratorObjIndex = 0 |
|
380 | self.integratorObjIndex = 0 | |
367 | self.writerObjIndex = 0 |
|
381 | self.writerObjIndex = 0 | |
368 | self.plotterObjIndex = 0 |
|
382 | self.plotterObjIndex = 0 | |
369 |
|
383 | |||
370 | if self.dataInObj.type == "Voltage": |
|
384 | if self.dataInObj.type == "Voltage": | |
371 | self.__getFft() |
|
385 | self.__getFft() | |
372 | self.dataOutObj.flagNoData = False |
|
386 | self.dataOutObj.flagNoData = False | |
373 | return |
|
387 | return | |
374 |
|
388 | |||
375 | #Other kind of data |
|
389 | #Other kind of data | |
376 | if self.dataInObj.type == "SpectraHeis": |
|
390 | if self.dataInObj.type == "SpectraHeis": | |
377 | self.dataOutObj.copy(self.dataInObj) |
|
391 | self.dataOutObj.copy(self.dataInObj) | |
378 | self.dataOutObj.flagNoData = False |
|
392 | self.dataOutObj.flagNoData = False | |
379 | return |
|
393 | return | |
380 |
|
394 | |||
381 |
raise ValueError, "The |
|
395 | raise ValueError, "The type is not valid" | |
382 |
|
396 | |||
383 | def __getFft(self): |
|
397 | def __getFft(self): | |
384 | if self.dataInObj.flagNoData: |
|
398 | if self.dataInObj.flagNoData: | |
385 | return 0 |
|
399 | return 0 | |
386 |
|
400 | |||
387 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) |
|
401 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) | |
388 | #print fft_volt |
|
402 | #print fft_volt | |
389 | #calculo de self-spectra |
|
403 | #calculo de self-spectra | |
390 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
404 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
391 |
|
405 | |||
392 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) |
|
406 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) | |
393 | self.dataOutObj.data_spc = spc |
|
407 | self.dataOutObj.data_spc = spc | |
394 | #print spc |
|
408 | #print spc | |
395 |
|
409 | |||
396 | def getSpectra(self): |
|
410 | def getSpectra(self): | |
397 |
|
411 | |||
398 | return self.dataOutObj.data_spc |
|
412 | return self.dataOutObj.data_spc | |
399 |
|
413 | |||
400 | def getFrecuencies(self): |
|
414 | def getFrecuencies(self): | |
401 |
|
415 | |||
402 | print self.nFFTPoints |
|
416 | print self.nFFTPoints | |
403 | return numpy.arange(int(self.nFFTPoints)) |
|
417 | return numpy.arange(int(self.nFFTPoints)) | |
404 |
|
418 | |||
405 | def addIntegrator(self,N,timeInterval): |
|
419 | def addIntegrator(self,N,timeInterval): | |
406 | objIncohInt = IncoherentIntegration(N,timeInterval) |
|
420 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
407 | self.integratorObjList.append(objIncohInt) |
|
421 | self.integratorObjList.append(objIncohInt) | |
408 |
|
422 | |||
409 | def integrator(self, N=None, timeInterval=None): |
|
423 | def integrator(self, N=None, timeInterval=None): | |
410 | if self.dataOutObj.flagNoData: |
|
424 | if self.dataOutObj.flagNoData: | |
411 | return 0 |
|
425 | return 0 | |
412 |
|
426 | |||
413 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
427 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
414 | self.addIntegrator(N,timeInterval) |
|
428 | self.addIntegrator(N,timeInterval) | |
415 |
|
429 | |||
416 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
430 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] | |
417 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) |
|
431 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) | |
418 |
|
432 | |||
419 | if myIncohIntObj.isReady: |
|
433 | if myIncohIntObj.isReady: | |
420 | self.dataOutObj.data_spc = myIncohIntObj.data |
|
434 | self.dataOutObj.data_spc = myIncohIntObj.data | |
421 | self.dataOutObj.nAvg = myIncohIntObj.navg |
|
435 | self.dataOutObj.nAvg = myIncohIntObj.navg | |
422 | self.dataOutObj.m_ProcessingHeader.incoherentInt *= myIncohIntObj.navg |
|
436 | self.dataOutObj.m_ProcessingHeader.incoherentInt *= myIncohIntObj.navg | |
423 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg |
|
437 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg | |
424 | self.dataOutObj.flagNoData = False |
|
438 | self.dataOutObj.flagNoData = False | |
425 |
|
439 | |||
426 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) |
|
440 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) | |
427 | # self.getNoise(type="sort", parm=16) |
|
441 | # self.getNoise(type="sort", parm=16) | |
428 |
|
442 | |||
429 | else: |
|
443 | else: | |
430 | self.dataOutObj.flagNoData = True |
|
444 | self.dataOutObj.flagNoData = True | |
431 |
|
445 | |||
432 | self.integratorObjIndex += 1 |
|
446 | self.integratorObjIndex += 1 | |
433 |
|
447 | |||
434 |
|
448 | |||
435 |
|
449 | |||
436 | class IncoherentIntegration: |
|
450 | class IncoherentIntegration: | |
437 |
|
451 | |||
438 | integ_counter = None |
|
452 | integ_counter = None | |
439 | data = None |
|
453 | data = None | |
440 | navg = None |
|
454 | navg = None | |
441 | buffer = None |
|
455 | buffer = None | |
442 | nIncohInt = None |
|
456 | nIncohInt = None | |
443 |
|
457 | |||
444 | def __init__(self, N = None, timeInterval = None): |
|
458 | def __init__(self, N = None, timeInterval = None): | |
445 | """ |
|
459 | """ | |
446 | N |
|
460 | N | |
447 | timeInterval - interval time [min], integer value |
|
461 | timeInterval - interval time [min], integer value | |
448 | """ |
|
462 | """ | |
449 |
|
463 | |||
450 | self.data = None |
|
464 | self.data = None | |
451 | self.navg = None |
|
465 | self.navg = None | |
452 | self.buffer = None |
|
466 | self.buffer = None | |
453 | self.timeOut = None |
|
467 | self.timeOut = None | |
454 | self.exitCondition = False |
|
468 | self.exitCondition = False | |
455 | self.isReady = False |
|
469 | self.isReady = False | |
456 | self.nIncohInt = N |
|
470 | self.nIncohInt = N | |
457 | self.integ_counter = 0 |
|
471 | self.integ_counter = 0 | |
458 | if timeInterval!=None: |
|
472 | if timeInterval!=None: | |
459 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
473 | self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line | |
460 |
|
474 | |||
461 | if ((timeInterval==None) and (N==None)): |
|
475 | if ((timeInterval==None) and (N==None)): | |
462 | print 'N = None ; timeInterval = None' |
|
476 | print 'N = None ; timeInterval = None' | |
463 | sys.exit(0) |
|
477 | sys.exit(0) | |
464 | elif timeInterval == None: |
|
478 | elif timeInterval == None: | |
465 | self.timeFlag = False |
|
479 | self.timeFlag = False | |
466 | else: |
|
480 | else: | |
467 | self.timeFlag = True |
|
481 | self.timeFlag = True | |
468 |
|
482 | |||
469 |
|
483 | |||
470 | def exe(self,data,timeOfData): |
|
484 | def exe(self,data,timeOfData): | |
471 | """ |
|
485 | """ | |
472 | data |
|
486 | data | |
473 |
|
487 | |||
474 | timeOfData [seconds] |
|
488 | timeOfData [seconds] | |
475 | """ |
|
489 | """ | |
476 |
|
490 | |||
477 | if self.timeFlag: |
|
491 | if self.timeFlag: | |
478 | if self.timeOut == None: |
|
492 | if self.timeOut == None: | |
479 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
493 | self.timeOut = timeOfData + self.timeIntervalInSeconds | |
480 |
|
494 | |||
481 | if timeOfData < self.timeOut: |
|
495 | if timeOfData < self.timeOut: | |
482 | if self.buffer == None: |
|
496 | if self.buffer == None: | |
483 | self.buffer = data |
|
497 | self.buffer = data | |
484 | else: |
|
498 | else: | |
485 | self.buffer = self.buffer + data |
|
499 | self.buffer = self.buffer + data | |
486 | self.integ_counter += 1 |
|
500 | self.integ_counter += 1 | |
487 | else: |
|
501 | else: | |
488 | self.exitCondition = True |
|
502 | self.exitCondition = True | |
489 |
|
503 | |||
490 | else: |
|
504 | else: | |
491 | if self.integ_counter < self.nIncohInt: |
|
505 | if self.integ_counter < self.nIncohInt: | |
492 | if self.buffer == None: |
|
506 | if self.buffer == None: | |
493 | self.buffer = data |
|
507 | self.buffer = data | |
494 | else: |
|
508 | else: | |
495 | self.buffer = self.buffer + data |
|
509 | self.buffer = self.buffer + data | |
496 |
|
510 | |||
497 | self.integ_counter += 1 |
|
511 | self.integ_counter += 1 | |
498 |
|
512 | |||
499 | if self.integ_counter == self.nIncohInt: |
|
513 | if self.integ_counter == self.nIncohInt: | |
500 | self.exitCondition = True |
|
514 | self.exitCondition = True | |
501 |
|
515 | |||
502 | if self.exitCondition: |
|
516 | if self.exitCondition: | |
503 | self.data = self.buffer |
|
517 | self.data = self.buffer | |
504 | self.navg = self.integ_counter |
|
518 | self.navg = self.integ_counter | |
505 | self.isReady = True |
|
519 | self.isReady = True | |
506 | self.buffer = None |
|
520 | self.buffer = None | |
507 | self.timeOut = None |
|
521 | self.timeOut = None | |
508 | self.integ_counter = 0 |
|
522 | self.integ_counter = 0 | |
509 | self.exitCondition = False |
|
523 | self.exitCondition = False | |
510 |
|
524 | |||
511 | if self.timeFlag: |
|
525 | if self.timeFlag: | |
512 | self.buffer = data |
|
526 | self.buffer = data | |
513 | self.timeOut = timeOfData + self.timeIntervalInSeconds |
|
527 | self.timeOut = timeOfData + self.timeIntervalInSeconds | |
514 | else: |
|
528 | else: | |
515 | self.isReady = False |
|
529 | self.isReady = False | |
516 | No newline at end of file |
|
530 |
@@ -1,372 +1,372 | |||||
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 |
|
76 | |||
77 | if self.dataOutObj.flagNoData: |
|
77 | if self.dataOutObj.flagNoData: | |
78 | return 0 |
|
78 | return 0 | |
79 |
|
79 | |||
80 | nframes = len(self.dataOutObj.channelList) |
|
80 | nframes = len(self.dataOutObj.channelList) | |
81 |
|
81 | |||
82 | if len(self.plotObjList) <= self.plotObjIndex: |
|
82 | if len(self.plotObjList) <= self.plotObjIndex: | |
83 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) |
|
83 | self.addRti(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) | |
84 |
|
84 | |||
85 | data = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) |
|
85 | data = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) | |
86 | data = 10*numpy.log10(data.real) |
|
86 | data = 10*numpy.log10(data.real) | |
87 |
|
87 | |||
88 | # currenttime = self.dataOutObj.dataUtcTime |
|
88 | # currenttime = self.dataOutObj.dataUtcTime | |
89 | # if timezone == "lt": |
|
89 | # if timezone == "lt": | |
90 | currenttime = self.dataOutObj.dataUtcTime - time.timezone |
|
90 | currenttime = self.dataOutObj.dataUtcTime - time.timezone | |
91 |
|
91 | |||
92 | range = self.dataOutObj.heightList |
|
92 | range = self.dataOutObj.heightList | |
93 |
|
93 | |||
94 | channelList = self.dataOutObj.channelList |
|
94 | channelList = self.dataOutObj.channelList | |
95 |
|
95 | |||
96 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) |
|
96 | thisdatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) | |
97 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
97 | dateTime = "%s"%(thisdatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
98 | date = "%s"%(thisdatetime.strftime("%d-%b-%Y")) |
|
98 | date = "%s"%(thisdatetime.strftime("%d-%b-%Y")) | |
99 |
|
99 | |||
100 | figuretitle = "RTI Plot Radar Data" #+ date |
|
100 | figuretitle = "RTI Plot Radar Data" #+ date | |
101 |
|
101 | |||
102 | plotObj = self.plotObjList[self.plotObjIndex] |
|
102 | plotObj = self.plotObjList[self.plotObjIndex] | |
103 |
|
103 | |||
104 | cleardata = False |
|
104 | cleardata = False | |
105 |
|
105 | |||
106 | plotObj.plotPcolor(data, |
|
106 | plotObj.plotPcolor(data, | |
107 | currenttime, |
|
107 | currenttime, | |
108 | range, |
|
108 | range, | |
109 | channelList, |
|
109 | channelList, | |
110 | starttime, |
|
110 | starttime, | |
111 | endtime, |
|
111 | endtime, | |
112 | rangemin, |
|
112 | rangemin, | |
113 | rangemax, |
|
113 | rangemax, | |
114 | minvalue, |
|
114 | minvalue, | |
115 | maxvalue, |
|
115 | maxvalue, | |
116 | figuretitle, |
|
116 | figuretitle, | |
117 | xrangestep, |
|
117 | xrangestep, | |
118 | save, |
|
118 | save, | |
119 | gpath, |
|
119 | gpath, | |
120 | cleardata) |
|
120 | cleardata) | |
121 |
|
121 | |||
122 | self.plotObjIndex += 1 |
|
122 | self.plotObjIndex += 1 | |
123 |
|
123 | |||
124 | def addScope(self, idfigure, nframes, wintitle, driver): |
|
124 | def addScope(self, idfigure, nframes, wintitle, driver): | |
125 | if idfigure==None: |
|
125 | if idfigure==None: | |
126 | idfigure = self.plotObjIndex |
|
126 | idfigure = self.plotObjIndex | |
127 |
|
127 | |||
128 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) |
|
128 | scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) | |
129 | self.plotObjList.append(scopeObj) |
|
129 | self.plotObjList.append(scopeObj) | |
130 |
|
130 | |||
131 | def plotScope(self, |
|
131 | def plotScope(self, | |
132 | idfigure=None, |
|
132 | idfigure=None, | |
133 | minvalue=None, |
|
133 | minvalue=None, | |
134 | maxvalue=None, |
|
134 | maxvalue=None, | |
135 | xmin=None, |
|
135 | xmin=None, | |
136 | xmax=None, |
|
136 | xmax=None, | |
137 | wintitle='', |
|
137 | wintitle='', | |
138 | driver='plplot', |
|
138 | driver='plplot', | |
139 | save=False, |
|
139 | save=False, | |
140 | gpath=None, |
|
140 | gpath=None, | |
141 | titleList=None, |
|
141 | titleList=None, | |
142 | xlabelList=None, |
|
142 | xlabelList=None, | |
143 | ylabelList=None, |
|
143 | ylabelList=None, | |
144 | type="power"): |
|
144 | type="power"): | |
145 |
|
145 | |||
146 | if self.dataOutObj.flagNoData: |
|
146 | if self.dataOutObj.flagNoData: | |
147 | return 0 |
|
147 | return 0 | |
148 |
|
148 | |||
149 | nframes = len(self.dataOutObj.channelList) |
|
149 | nframes = len(self.dataOutObj.channelList) | |
150 |
|
150 | |||
151 | if len(self.plotObjList) <= self.plotObjIndex: |
|
151 | if len(self.plotObjList) <= self.plotObjIndex: | |
152 | self.addScope(idfigure, nframes, wintitle, driver) |
|
152 | self.addScope(idfigure, nframes, wintitle, driver) | |
153 |
|
153 | |||
154 |
|
154 | |||
155 | if type=="power": |
|
155 | if type=="power": | |
156 | data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) |
|
156 | data1D = self.dataOutObj.data * numpy.conjugate(self.dataOutObj.data) | |
157 | data1D = data1D.real |
|
157 | data1D = data1D.real | |
158 |
|
158 | |||
159 | if type =="iq": |
|
159 | if type =="iq": | |
160 | data1D = self.dataOutObj.data |
|
160 | data1D = self.dataOutObj.data | |
161 |
|
161 | |||
162 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) |
|
162 | thisDatetime = datetime.datetime.fromtimestamp(self.dataOutObj.dataUtcTime) | |
163 |
|
163 | |||
164 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
164 | dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
165 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) |
|
165 | date = "%s"%(thisDatetime.strftime("%d-%b-%Y")) | |
166 |
|
166 | |||
167 | figureTitle = "Scope Plot Radar Data: " + date |
|
167 | figureTitle = "Scope Plot Radar Data: " + date | |
168 |
|
168 | |||
169 | plotObj = self.plotObjList[self.plotObjIndex] |
|
169 | plotObj = self.plotObjList[self.plotObjIndex] | |
170 |
|
170 | |||
171 | plotObj.plot1DArray(data1D, |
|
171 | plotObj.plot1DArray(data1D, | |
172 | self.dataOutObj.heightList, |
|
172 | self.dataOutObj.heightList, | |
173 | self.dataOutObj.channelList, |
|
173 | self.dataOutObj.channelList, | |
174 | xmin, |
|
174 | xmin, | |
175 | xmax, |
|
175 | xmax, | |
176 | minvalue, |
|
176 | minvalue, | |
177 | maxvalue, |
|
177 | maxvalue, | |
178 | figureTitle, |
|
178 | figureTitle, | |
179 | save, |
|
179 | save, | |
180 | gpath) |
|
180 | gpath) | |
181 |
|
181 | |||
182 | self.plotObjIndex += 1 |
|
182 | self.plotObjIndex += 1 | |
183 |
|
183 | |||
184 |
|
184 | |||
185 | def addIntegrator(self, *args): |
|
185 | def addIntegrator(self, *args): | |
186 | objCohInt = CoherentIntegrator(*args) |
|
186 | objCohInt = CoherentIntegrator(*args) | |
187 | self.integratorObjList.append(objCohInt) |
|
187 | self.integratorObjList.append(objCohInt) | |
188 |
|
188 | |||
189 | def addWriter(self, *args): |
|
189 | def addWriter(self, *args): | |
190 | writerObj = VoltageWriter(self.dataOutObj) |
|
190 | writerObj = VoltageWriter(self.dataOutObj) | |
191 | writerObj.setup(*args) |
|
191 | writerObj.setup(*args) | |
192 | self.writerObjList.append(writerObj) |
|
192 | self.writerObjList.append(writerObj) | |
193 |
|
193 | |||
194 | def writeData(self, wrpath, blocksPerFile, profilesPerBlock): |
|
194 | def writeData(self, wrpath, blocksPerFile, profilesPerBlock): | |
195 |
|
195 | |||
196 | if self.dataOutObj.flagNoData: |
|
196 | if self.dataOutObj.flagNoData: | |
197 | return 0 |
|
197 | return 0 | |
198 |
|
198 | |||
199 | if len(self.writerObjList) <= self.writerObjIndex: |
|
199 | if len(self.writerObjList) <= self.writerObjIndex: | |
200 | self.addWriter(wrpath, blocksPerFile, profilesPerBlock) |
|
200 | self.addWriter(wrpath, blocksPerFile, profilesPerBlock) | |
201 |
|
201 | |||
202 | self.writerObjList[self.writerObjIndex].putData() |
|
202 | self.writerObjList[self.writerObjIndex].putData() | |
203 |
|
203 | |||
204 | self.writerObjIndex += 1 |
|
204 | self.writerObjIndex += 1 | |
205 |
|
205 | |||
206 | def integrator(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
206 | def integrator(self, nCohInt=None, timeInterval=None, overlapping=False): | |
207 |
|
207 | |||
208 | if self.dataOutObj.flagNoData: |
|
208 | if self.dataOutObj.flagNoData: | |
209 | return 0 |
|
209 | return 0 | |
210 |
|
210 | |||
211 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
211 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
212 | self.addIntegrator(nCohInt, timeInterval, overlapping) |
|
212 | self.addIntegrator(nCohInt, timeInterval, overlapping) | |
213 |
|
213 | |||
214 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
214 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] | |
215 | myCohIntObj.exe(data = self.dataOutObj.data, datatime=None) |
|
215 | myCohIntObj.exe(data = self.dataOutObj.data, datatime=None) | |
216 |
|
216 | |||
217 | self.dataOutObj.flagNoData = True |
|
217 | self.dataOutObj.flagNoData = True | |
218 |
|
218 | |||
219 | if myCohIntObj.isReady: |
|
219 | if myCohIntObj.isReady: | |
220 | self.dataOutObj.flagNoData = False |
|
220 | self.dataOutObj.flagNoData = False | |
221 |
|
221 | |||
222 |
|
222 | |||
223 |
|
223 | |||
224 | class CoherentIntegrator: |
|
224 | class CoherentIntegrator: | |
225 |
|
225 | |||
226 |
|
226 | |||
227 | __profIndex = 0 |
|
227 | __profIndex = 0 | |
228 | __withOverapping = False |
|
228 | __withOverapping = False | |
229 |
|
229 | |||
230 | __isByTime = False |
|
230 | __isByTime = False | |
231 | __initime = None |
|
231 | __initime = None | |
232 | __integrationtime = None |
|
232 | __integrationtime = None | |
233 |
|
233 | |||
234 | __buffer = None |
|
234 | __buffer = None | |
235 |
|
235 | |||
236 | isReady = False |
|
236 | isReady = False | |
237 | nCohInt = None |
|
237 | nCohInt = None | |
238 |
|
238 | |||
239 |
|
239 | |||
240 | def __init__(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
240 | def __init__(self, nCohInt=None, timeInterval=None, overlapping=False): | |
241 |
|
241 | |||
242 | """ |
|
242 | """ | |
243 | Set the parameters of the integration class. |
|
243 | Set the parameters of the integration class. | |
244 |
|
244 | |||
245 | Inputs: |
|
245 | Inputs: | |
246 |
|
246 | |||
247 | nCohInt : Number of coherent integrations |
|
247 | nCohInt : Number of coherent integrations | |
248 | timeInterval : Time of integration. If nCohInt is selected this parameter does not work |
|
248 | timeInterval : Time of integration. If nCohInt is selected this parameter does not work | |
249 | overlapping : |
|
249 | overlapping : | |
250 |
|
250 | |||
251 | """ |
|
251 | """ | |
252 |
|
252 | |||
253 | self.__buffer = None |
|
253 | self.__buffer = None | |
254 | self.isReady = False |
|
254 | self.isReady = False | |
255 |
|
255 | |||
256 | if nCohInt == None and timeInterval == None: |
|
256 | if nCohInt == None and timeInterval == None: | |
257 | raise ValueError, "nCohInt or timeInterval should be specified ..." |
|
257 | raise ValueError, "nCohInt or timeInterval should be specified ..." | |
258 |
|
258 | |||
259 | if nCohInt != None: |
|
259 | if nCohInt != None: | |
260 | self.nCohInt = nCohInt |
|
260 | self.nCohInt = nCohInt | |
261 | self.__isByTime = False |
|
261 | self.__isByTime = False | |
262 | else: |
|
262 | else: | |
263 | self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line |
|
263 | self.__integrationtime = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line | |
264 | self.__isByTime = True |
|
264 | self.__isByTime = True | |
265 |
|
265 | |||
266 | if overlapping: |
|
266 | if overlapping: | |
267 | self.__withOverapping = True |
|
267 | self.__withOverapping = True | |
268 | self.__buffer = None |
|
268 | self.__buffer = None | |
269 | else: |
|
269 | else: | |
270 | self.__withOverapping = False |
|
270 | self.__withOverapping = False | |
271 | self.__buffer = 0 |
|
271 | self.__buffer = 0 | |
272 |
|
272 | |||
273 | self.__profIndex = 0 |
|
273 | self.__profIndex = 0 | |
274 |
|
274 | |||
275 | def putData(self, data): |
|
275 | def putData(self, data): | |
276 |
|
276 | |||
277 | """ |
|
277 | """ | |
278 | Add a profile to the __buffer and increase in one the __profileIndex |
|
278 | Add a profile to the __buffer and increase in one the __profileIndex | |
279 |
|
279 | |||
280 | """ |
|
280 | """ | |
281 | if not self.__withOverapping: |
|
281 | if not self.__withOverapping: | |
282 | self.__buffer += data |
|
282 | self.__buffer += data | |
283 | self.__profIndex += 1 |
|
283 | self.__profIndex += 1 | |
284 | return |
|
284 | return | |
285 |
|
285 | |||
286 | #Overlapping data |
|
286 | #Overlapping data | |
287 |
nChannels, n |
|
287 | nChannels, nHeis = data.shape | |
288 |
data = numpy.reshape(data, (1, nChannels, n |
|
288 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
289 |
|
289 | |||
290 | if self.__buffer == None: |
|
290 | if self.__buffer == None: | |
291 | self.__buffer = data |
|
291 | self.__buffer = data | |
292 | self.__profIndex += 1 |
|
292 | self.__profIndex += 1 | |
293 | return |
|
293 | return | |
294 |
|
294 | |||
295 | if self.__profIndex < self.nCohInt: |
|
295 | if self.__profIndex < self.nCohInt: | |
296 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
296 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
297 | self.__profIndex += 1 |
|
297 | self.__profIndex += 1 | |
298 | return |
|
298 | return | |
299 |
|
299 | |||
300 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
300 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
301 | self.__buffer[self.nCohInt-1] = data |
|
301 | self.__buffer[self.nCohInt-1] = data | |
302 | #self.__profIndex = self.nCohInt |
|
302 | #self.__profIndex = self.nCohInt | |
303 | return |
|
303 | return | |
304 |
|
304 | |||
305 |
|
305 | |||
306 | def pushData(self): |
|
306 | def pushData(self): | |
307 | """ |
|
307 | """ | |
308 | Return the sum of the last profiles and the profiles used in the sum. |
|
308 | Return the sum of the last profiles and the profiles used in the sum. | |
309 |
|
309 | |||
310 | Affected: |
|
310 | Affected: | |
311 |
|
311 | |||
312 | self.__profileIndex |
|
312 | self.__profileIndex | |
313 |
|
313 | |||
314 | """ |
|
314 | """ | |
315 |
|
315 | |||
316 | if not self.__withOverapping: |
|
316 | if not self.__withOverapping: | |
317 | data = self.__buffer |
|
317 | data = self.__buffer | |
318 | nCohInt = self.__profIndex |
|
318 | nCohInt = self.__profIndex | |
319 |
|
319 | |||
320 | self.__buffer = 0 |
|
320 | self.__buffer = 0 | |
321 | self.__profIndex = 0 |
|
321 | self.__profIndex = 0 | |
322 |
|
322 | |||
323 | return data, nCohInt |
|
323 | return data, nCohInt | |
324 |
|
324 | |||
325 | #Overlapping data |
|
325 | #Overlapping data | |
326 | data = numpy.sum(self.__buffer, axis=0) |
|
326 | data = numpy.sum(self.__buffer, axis=0) | |
327 | nCohInt = self.__profIndex |
|
327 | nCohInt = self.__profIndex | |
328 |
|
328 | |||
329 | return data, nCohInt |
|
329 | return data, nCohInt | |
330 |
|
330 | |||
331 | def byProfiles(self, data): |
|
331 | def byProfiles(self, data): | |
332 |
|
332 | |||
333 | self.isReady = False |
|
333 | self.isReady = False | |
334 | avg_data = None |
|
334 | avg_data = None | |
335 |
|
335 | |||
336 | self.putData(data) |
|
336 | self.putData(data) | |
337 |
|
337 | |||
338 | if self.__profIndex == self.nCohInt: |
|
338 | if self.__profIndex == self.nCohInt: | |
339 | avg_data, nCohInt = self.pushData() |
|
339 | avg_data, nCohInt = self.pushData() | |
340 | self.isReady = True |
|
340 | self.isReady = True | |
341 |
|
341 | |||
342 | return avg_data |
|
342 | return avg_data | |
343 |
|
343 | |||
344 | def byTime(self, data, datatime): |
|
344 | def byTime(self, data, datatime): | |
345 |
|
345 | |||
346 | self.isReady = False |
|
346 | self.isReady = False | |
347 | avg_data = None |
|
347 | avg_data = None | |
348 |
|
348 | |||
349 | if self.__initime == None: |
|
349 | if self.__initime == None: | |
350 | self.__initime = datatime |
|
350 | self.__initime = datatime | |
351 |
|
351 | |||
352 | self.putData(data) |
|
352 | self.putData(data) | |
353 |
|
353 | |||
354 | if (datatime - self.__initime) >= self.__integrationtime: |
|
354 | if (datatime - self.__initime) >= self.__integrationtime: | |
355 | avg_data, nCohInt = self.pushData() |
|
355 | avg_data, nCohInt = self.pushData() | |
356 | self.nCohInt = nCohInt |
|
356 | self.nCohInt = nCohInt | |
357 | self.isReady = True |
|
357 | self.isReady = True | |
358 |
|
358 | |||
359 | return avg_data |
|
359 | return avg_data | |
360 |
|
360 | |||
361 | def exe(self, data, datatime=None): |
|
361 | def exe(self, data, datatime=None): | |
362 |
|
362 | |||
363 | if not self.__isByTime: |
|
363 | if not self.__isByTime: | |
364 | avg_data = self.byProfiles(data) |
|
364 | avg_data = self.byProfiles(data) | |
365 | else: |
|
365 | else: | |
366 | avg_data = self.byTime(data, datatime) |
|
366 | avg_data = self.byTime(data, datatime) | |
367 |
|
367 | |||
368 | self.data = avg_data |
|
368 | self.data = avg_data | |
369 |
|
369 | |||
370 | return avg_data |
|
370 | return avg_data | |
371 |
|
371 | |||
372 |
|
372 |
@@ -1,159 +1,160 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 31, 2012 |
|
2 | Created on Jul 31, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import time, datetime |
|
9 | import time, datetime | |
10 | #import pylab as pl |
|
10 | #import pylab as pl | |
11 |
|
11 | |||
12 | from Data.JROData import Voltage |
|
12 | from Data.JROData import Voltage | |
13 | from IO.VoltageIO import * |
|
13 | from IO.VoltageIO import * | |
14 |
|
14 | |||
15 | from Data.JROData import SpectraHeis |
|
15 | from Data.JROData import SpectraHeis | |
16 | from IO.SpectraIO import * |
|
16 | from IO.SpectraIO import * | |
17 |
|
17 | |||
18 | from Processing.VoltageProcessor import * |
|
18 | from Processing.VoltageProcessor import * | |
19 | from Processing.SpectraProcessor import * |
|
19 | from Processing.SpectraProcessor import * | |
20 |
|
20 | |||
21 | from Graphics.BaseGraph_mpl import LinearPlot |
|
21 | from Graphics.BaseGraph_mpl import LinearPlot | |
22 |
|
22 | |||
23 | class TestHeis(): |
|
23 | class TestHeis(): | |
24 | i=None |
|
24 | i=None | |
25 | def __init__(self): |
|
25 | def __init__(self): | |
26 | self.setValues() |
|
26 | self.setValues() | |
27 | self.createObjects() |
|
27 | self.createObjects() | |
28 | self.testSChain() |
|
28 | self.testSChain() | |
29 | self.i=0 |
|
29 | self.i=0 | |
|
30 | ||||
30 | def setValues( self ): |
|
31 | def setValues( self ): | |
31 |
|
32 | |||
32 | self.path="C:\data2" |
|
33 | self.path="C:\data2" | |
33 | self.startDate = datetime.date(2012,4,1) |
|
34 | self.startDate = datetime.date(2012,4,1) | |
34 | self.endDate = datetime.date(2012,6,30) |
|
35 | self.endDate = datetime.date(2012,6,30) | |
35 |
|
36 | |||
36 | self.startTime = datetime.time(0,0,0) |
|
37 | self.startTime = datetime.time(0,0,0) | |
37 | self.endTime = datetime.time(23,0,0) |
|
38 | self.endTime = datetime.time(23,0,0) | |
38 | #self.N = 4 |
|
39 | #self.N = 4 | |
39 | #self.npts = 8 |
|
40 | #self.npts = 8 | |
40 |
|
41 | |||
41 | def createObjects( self ): |
|
42 | def createObjects( self ): | |
42 |
|
43 | |||
43 | self.readerObj = VoltageReader() |
|
44 | self.readerObj = VoltageReader() | |
44 | self.specProcObj = SpectraHeisProcessor() |
|
45 | self.specProcObj = SpectraHeisProcessor() | |
45 |
|
46 | |||
46 | self.voltObj1 = self.readerObj.setup( |
|
47 | self.voltObj1 = self.readerObj.setup( | |
47 | path = self.path, |
|
48 | path = self.path, | |
48 | startDate = self.startDate, |
|
49 | startDate = self.startDate, | |
49 | endDate = self.endDate, |
|
50 | endDate = self.endDate, | |
50 | startTime = self.startTime, |
|
51 | startTime = self.startTime, | |
51 | endTime = self.endTime, |
|
52 | endTime = self.endTime, | |
52 | expLabel = '', |
|
53 | expLabel = '', | |
53 | online = 0) |
|
54 | online = 0) | |
54 |
|
55 | |||
55 | if not(self.voltObj1): |
|
56 | if not(self.voltObj1): | |
56 | sys.exit(0) |
|
57 | sys.exit(0) | |
57 |
|
58 | |||
58 | print "voltaje o alturas: %03d"%(self.voltObj1.nHeights) |
|
59 | print "voltaje o alturas: %03d"%(self.voltObj1.nHeights) | |
59 | #print "perfiles: %03d"%(self.voltObj1.nProfiles) |
|
60 | #print "perfiles: %03d"%(self.voltObj1.nProfiles) | |
60 | self.specObj1 = self.specProcObj.setup(dataInObj = self.voltObj1,nFFTPoints=self.voltObj1.nHeights) |
|
61 | self.specObj1 = self.specProcObj.setup(dataInObj = self.voltObj1,nFFTPoints=self.voltObj1.nHeights) | |
61 |
|
62 | |||
62 |
|
63 | |||
63 |
|
64 | |||
64 | print "nChannels: %03d"%(self.specObj1.nChannels) |
|
65 | print "nChannels: %03d"%(self.specObj1.nChannels) | |
65 | print "nHeights: %03d"%( self.specObj1.nHeights) |
|
66 | print "nHeights: %03d"%( self.specObj1.nHeights) | |
66 | print "nFFTPoints: %03d"% int(self.specObj1.nFFTPoints) |
|
67 | print "nFFTPoints: %03d"% int(self.specObj1.nFFTPoints) | |
67 |
|
68 | |||
68 |
|
69 | |||
69 | def testSChain( self ): |
|
70 | def testSChain( self ): | |
70 |
|
71 | |||
71 | ini = time.time() |
|
72 | ini = time.time() | |
72 |
|
73 | |||
73 | while(True): |
|
74 | while(True): | |
74 | self.readerObj.getData() |
|
75 | self.readerObj.getData() | |
75 | #print self.readerObj.datablock |
|
76 | #print self.readerObj.datablock | |
76 | #self.voltProcObj.init() |
|
77 | #self.voltProcObj.init() | |
77 | self.specProcObj.init() |
|
78 | self.specProcObj.init() | |
78 |
|
79 | |||
79 | self.specProcObj.integrator(N=32) ## return self.dataOutObj |
|
80 | self.specProcObj.integrator(N=32) ## return self.dataOutObj | |
80 |
|
81 | |||
81 | self.plot() |
|
82 | self.plot() | |
82 | #print self.readerObj.dataOutObj.data |
|
83 | #print self.readerObj.dataOutObj.data | |
83 |
|
84 | |||
84 | #CON TODO ESTO PLoTEO |
|
85 | #CON TODO ESTO PLoTEO | |
85 | #freq = self.specProcObj.getFrecuencies() |
|
86 | #freq = self.specProcObj.getFrecuencies() | |
86 | #spc = self.specProcObj.getSpectra() |
|
87 | #spc = self.specProcObj.getSpectra() | |
87 | # print freq |
|
88 | # print freq | |
88 | # print spc, spc.shape |
|
89 | # print spc, spc.shape | |
89 | # pl.plot(freq, spc[2]) |
|
90 | # pl.plot(freq, spc[2]) | |
90 | # pl.show() |
|
91 | # pl.show() | |
91 |
|
92 | |||
92 | if self.readerObj.flagNoMoreFiles: |
|
93 | if self.readerObj.flagNoMoreFiles: | |
93 | break |
|
94 | break | |
94 |
|
95 | |||
95 | if self.readerObj.flagIsNewBlock: |
|
96 | if self.readerObj.flagIsNewBlock: | |
96 | print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, |
|
97 | print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, | |
97 | datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) |
|
98 | datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) | |
98 |
|
99 | |||
99 |
|
100 | |||
100 | def plot(self): |
|
101 | def plot(self): | |
101 |
|
102 | |||
102 | # x = self.specProcObj.getFrecuencies() |
|
103 | # x = self.specProcObj.getFrecuencies() | |
103 | x = numpy.arange(self.specObj1.nFFTPoints) |
|
104 | x = numpy.arange(self.specObj1.nFFTPoints) | |
104 | spc = self.specObj1.data_spc |
|
105 | spc = self.specObj1.data_spc | |
105 | # spc = self.specProcObj.getSpectra() |
|
106 | # spc = self.specProcObj.getSpectra() | |
106 | nchannels = self.specObj1.nChannels |
|
107 | nchannels = self.specObj1.nChannels | |
107 |
|
108 | |||
108 | # y1=spc[0] |
|
109 | # y1=spc[0] | |
109 | # y2=spc[1] |
|
110 | # y2=spc[1] | |
110 | # y3=spc[2] |
|
111 | # y3=spc[2] | |
111 | # y4=spc[3] |
|
112 | # y4=spc[3] | |
112 |
|
113 | |||
113 | # signalList=[y1,y2,y3,y4] |
|
114 | # signalList=[y1,y2,y3,y4] | |
114 | # xmin = numpy.min(x) |
|
115 | # xmin = numpy.min(x) | |
115 | # xmax = numpy.max(x) |
|
116 | # xmax = numpy.max(x) | |
116 |
|
117 | |||
117 | #Creating Object |
|
118 | #Creating Object | |
118 | indexPlot = 1 |
|
119 | indexPlot = 1 | |
119 | nsubplot = nchannels |
|
120 | nsubplot = nchannels | |
120 | #nsubplot = 1 |
|
121 | #nsubplot = 1 | |
121 | print "nsubplot:%d"%(nsubplot) |
|
122 | print "nsubplot:%d"%(nsubplot) | |
122 | winTitle = "mi grafico de Espectrov1" |
|
123 | winTitle = "mi grafico de Espectrov1" | |
123 |
|
124 | |||
124 | subplotTitle = "subplot-Espectro - No Channel." |
|
125 | subplotTitle = "subplot-Espectro - No Channel." | |
125 | xlabel = "" |
|
126 | xlabel = "" | |
126 | ylabel = "" |
|
127 | ylabel = "" | |
127 |
|
128 | |||
128 | linearObj = LinearPlot(indexPlot,nsubplot,winTitle) |
|
129 | linearObj = LinearPlot(indexPlot,nsubplot,winTitle) | |
129 |
|
130 | |||
130 | #Config SubPlots |
|
131 | #Config SubPlots | |
131 | print "ConfigSubPlots" |
|
132 | print "ConfigSubPlots" | |
132 | print "nsubplot: %d "%nsubplot |
|
133 | print "nsubplot: %d "%nsubplot | |
133 | for subplot in range(nsubplot): |
|
134 | for subplot in range(nsubplot): | |
134 | indexplot = subplot + 1 |
|
135 | indexplot = subplot + 1 | |
135 | name=subplot+1 |
|
136 | name=subplot+1 | |
136 | print "Channel: %d"%(name) |
|
137 | print "Channel: %d"%(name) | |
137 | title = subplotTitle + '%d'%name |
|
138 | title = subplotTitle + '%d'%name | |
138 | xmin = numpy.min(x) |
|
139 | xmin = numpy.min(x) | |
139 | xmax = numpy.max(x) |
|
140 | xmax = numpy.max(x) | |
140 | ymin = numpy.min(spc[subplot]) |
|
141 | ymin = numpy.min(spc[subplot]) | |
141 | ymax = numpy.max(spc[subplot]) |
|
142 | ymax = numpy.max(spc[subplot]) | |
142 | linearObj.setup(indexplot, xmin, xmax, ymin, ymax, title, xlabel, ylabel) |
|
143 | linearObj.setup(indexplot, xmin, xmax, ymin, ymax, title, xlabel, ylabel) | |
143 |
|
144 | |||
144 | #Plotting |
|
145 | #Plotting | |
145 | type = "simple" |
|
146 | type = "simple" | |
146 | print "Ploteando" |
|
147 | print "Ploteando" | |
147 | print "nsubplot: %d "%nsubplot |
|
148 | print "nsubplot: %d "%nsubplot | |
148 | for subplot in range(nsubplot): |
|
149 | for subplot in range(nsubplot): | |
149 | indexplot = subplot + 1 |
|
150 | indexplot = subplot + 1 | |
150 | y = spc[subplot,:] |
|
151 | y = spc[subplot,:] | |
151 | linearObj.plot(indexplot, x, y, type) |
|
152 | linearObj.plot(indexplot, x, y, type) | |
152 |
|
153 | |||
153 | linearObj.refresh() |
|
154 | linearObj.refresh() | |
154 | linearObj.show() |
|
155 | linearObj.show() | |
155 |
|
156 | |||
156 | if __name__ == '__main__': |
|
157 | if __name__ == '__main__': | |
157 | TestHeis() |
|
158 | TestHeis() | |
158 |
|
159 | |||
159 | No newline at end of file |
|
160 |
@@ -1,92 +1,86 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author$ |
|
3 | $Author$ | |
4 | $Id$ |
|
4 | $Id$ | |
5 | ''' |
|
5 | ''' | |
6 | import os, sys |
|
6 | import os, sys | |
7 | import time, datetime |
|
7 | import time, datetime | |
8 |
|
8 | |||
9 | path = os.path.split(os.getcwd())[0] |
|
9 | path = os.path.split(os.getcwd())[0] | |
10 | sys.path.append(path) |
|
10 | sys.path.append(path) | |
11 |
|
11 | |||
12 |
from Data. |
|
12 | from Data.JROData import Voltage | |
13 | from IO.VoltageIO import * |
|
13 | from IO.VoltageIO import * | |
14 |
|
14 | |||
15 | from Processing.VoltageProcessor import * |
|
15 | from Processing.VoltageProcessor import * | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | class TestSChain(): |
|
18 | class TestSChain(): | |
19 |
|
19 | |||
20 | def __init__(self): |
|
20 | def __init__(self): | |
21 | self.setValues() |
|
21 | self.setValues() | |
22 | self.createObjects() |
|
22 | self.createObjects() | |
23 | self.testSChain() |
|
23 | self.testSChain() | |
24 |
|
24 | |||
25 | def setValues(self): |
|
25 | def setValues(self): | |
26 |
self.path = "/home/ |
|
26 | self.path = "/home/roj-idl71/Data/RAWDATA/Meteors" | |
27 | self.startDate = datetime.date(2012,6,1) |
|
|||
28 | self.endDate = datetime.date(2012,7,30) |
|
|||
29 |
|
27 | |||
30 | # self.path = "/Users/danielangelsuarezmunoz/Data/Imaging_rawdata" |
|
28 | self.startDate = datetime.date(2005,1,1) | |
31 |
|
|
29 | self.endDate = datetime.date(2012,7,30) | |
32 | # self.endDate = datetime.date(2011,10,4) |
|
|||
33 |
|
||||
34 | # Probando los escritos por Signal Chain |
|
|||
35 | # self.path = "/home/dsuarez/RadaData" |
|
|||
36 | # self.startDate = datetime.date(2011,11,28) |
|
|||
37 | # self.endDate = datetime.date(2011,11,30) |
|
|||
38 |
|
30 | |||
39 | self.startTime = datetime.time(0,0,0) |
|
31 | self.startTime = datetime.time(0,0,0) | |
40 | self.endTime = datetime.time(23,59,59) |
|
32 | self.endTime = datetime.time(23,59,59) | |
41 |
|
33 | |||
42 |
self.wrpath = "/home/ |
|
34 | self.wrpath = "/home/roj-idl71/tmp/results" | |
43 | self.profilesPerBlock = 40 |
|
35 | self.profilesPerBlock = 40 | |
44 | self.blocksPerFile = 50 |
|
36 | self.blocksPerFile = 50 | |
45 |
|
37 | |||
46 | def createObjects(self): |
|
38 | def createObjects(self): | |
47 |
|
39 | |||
48 | self.readerObj = VoltageReader() |
|
40 | self.readerObj = VoltageReader() | |
49 |
|
41 | self.voltProcObj = VoltageProcessor() | ||
|
42 | self.specProcObj = SpectraProcessor() | |||
|
43 | ||||
50 | self.voltObj1 = self.readerObj.setup( |
|
44 | self.voltObj1 = self.readerObj.setup( | |
51 | path = self.path, |
|
45 | path = self.path, | |
52 | startDate = self.startDate, |
|
46 | startDate = self.startDate, | |
53 | endDate = self.endDate, |
|
47 | endDate = self.endDate, | |
54 | startTime = self.startTime, |
|
48 | startTime = self.startTime, | |
55 | endTime = self.endTime, |
|
49 | endTime = self.endTime, | |
56 | expLabel = '', |
|
50 | expLabel = '', | |
57 | online = 0) |
|
51 | online = 0) | |
58 |
|
||||
59 | self.voltObjProc = VoltageProcessor() |
|
|||
60 |
|
52 | |||
61 |
self.voltObj2 = self.volt |
|
53 | self.voltObj2 = self.voltProcObj.setup(dataInObj = self.voltObj1) | |
62 |
|
54 | |||
63 | def testSChain(self): |
|
55 | def testSChain(self): | |
64 |
|
56 | |||
65 | ini = time.time() |
|
57 | ini = time.time() | |
66 |
|
58 | |||
67 | while(True): |
|
59 | while(True): | |
68 | self.readerObj.getData() |
|
60 | self.readerObj.getData() | |
69 |
|
61 | |||
70 |
self.volt |
|
62 | self.voltProcObj.init() | |
|
63 | ||||
|
64 | self.voltProcObj.integrator(1000, overlapping=True) | |||
71 | # |
|
65 | # | |
72 |
# self.volt |
|
66 | # self.voltProcObj.writeData(self.wrpath,self.profilesPerBlock,self.blocksPerFile) | |
73 |
|
67 | |||
74 |
|
68 | |||
75 |
self.volt |
|
69 | self.voltProcObj.plotScope(idfigure=1, | |
76 | wintitle='test plot library', |
|
70 | wintitle='test plot library', | |
77 | driver='plplot', |
|
71 | driver='plplot', | |
78 | save=False, |
|
72 | save=False, | |
79 | gpath=None, |
|
73 | gpath=None, | |
80 | type="power") |
|
74 | type="power") | |
81 |
|
75 | |||
82 | if self.readerObj.flagNoMoreFiles: |
|
76 | if self.readerObj.flagNoMoreFiles: | |
83 | break |
|
77 | break | |
84 |
|
78 | |||
85 | if self.readerObj.flagIsNewBlock: |
|
79 | if self.readerObj.flagIsNewBlock: | |
86 | # print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, datetime.datetime.fromtimestamp(self.readerObj.basicHeaderObj.utc),) |
|
80 | # print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, datetime.datetime.fromtimestamp(self.readerObj.basicHeaderObj.utc),) | |
87 | print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, |
|
81 | print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, | |
88 | datetime.datetime.utcfromtimestamp(self.readerObj.basicHeaderObj.utc + self.readerObj.basicHeaderObj.miliSecond/1000.0),) |
|
82 | datetime.datetime.utcfromtimestamp(self.readerObj.basicHeaderObj.utc + self.readerObj.basicHeaderObj.miliSecond/1000.0),) | |
89 |
|
83 | |||
90 |
|
84 | |||
91 | if __name__ == '__main__': |
|
85 | if __name__ == '__main__': | |
92 | TestSChain() No newline at end of file |
|
86 | TestSChain() |
General Comments 0
You need to be logged in to leave comments.
Login now