##// END OF EJS Templates
Version 2.1.3.1
Miguel Valdez -
r669:350fc0523b69
parent child
Show More
@@ -1,31 +1,32
1 Prerequisites:
1 Prerequisites:
2
2
3 -numpy 1.8.0
3 -numpy 1.8.0
4 -scipy
4 -scipy
5 -math
5 -math
6 -matplotlib
6 -matplotlib
7 -h5py
7 -h5py
8 -ftplib
8 -ftplib
9 -paramiko and scp (optional for using SendTFilesToServer)
9 -paramiko and scp (optional for using SendTFilesToServer)
10 -stuffr (optional for using jroIO_hf)
10 -stuffr (optional for using jroIO_hf)
11 -PyQt4 (for using GUI)
11 -PyQt4 (for using GUI)
12 -pyfits (Fits data)
12
13
13 Signal Chain Installation:
14 Signal Chain Installation:
14
15
15 1. Install numpy, matplotlib, TKAgg
16 1. Install numpy, matplotlib, TKAgg
16 2. Install digital_rf_hdf5 module (developed by Haystack Observatory)
17 2. Install digital_rf_hdf5 module (developed by Haystack Observatory)
17 if you want to use USRP data
18 if you want to use USRP data
18 3. untar schainpy-x.x.x.tar.gz
19 3. untar schainpy-x.x.x.tar.gz
19 4. cd schainpy-x.x.x
20 4. cd schainpy-x.x.x
20 5. execute:
21 5. execute:
21 [hostname]$ sudo pyhon setup.py install
22 [hostname]$ sudo pyhon setup.py install
22 6. testing gui:
23 6. testing gui:
23 [hostname]$ schainGUI (enter)
24 [hostname]$ schainGUI (enter)
24
25
25 If you want to use serialization and zerorpc you will need to install the next packages:
26 If you want to use serialization and zerorpc you will need to install the next packages:
26
27
27 1. zerorpc
28 1. zerorpc
28 [hostname]$ sudo port install zerorpc
29 [hostname]$ sudo port install zerorpc
29
30
30 2. cPickle, msgpack and msgpack_numpy
31 2. cPickle, msgpack and msgpack_numpy
31 [hostname]$ sudo port install cPickle msgpack mspack_numpy No newline at end of file
32 [hostname]$ sudo port install cPickle msgpack mspack_numpy
@@ -1,15 +1,19
1 VERSIONS:
1 VERSIONS:
2
2
3 2.1.2:
3 2.1.2:
4 -jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread
4 -jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread
5 Server thread opens and closes remote server each time file list is sent
5 Server thread opens and closes remote server each time file list is sent
6 -jroplot_spectra.py: Noise path was not being created saving noise data.
6 -jroplot_spectra.py: Noise path was not being created saving noise data.
7 -jroIO_base.py: startTime can be greater than endTime
7 -jroIO_base.py: startTime can be greater than endTime
8
8
9 2.1.3:
9 2.1.3:
10 -jroplot_heispectra.py: SpectraHeisScope was not showing the right channels
10 -jroplot_heispectra.py: SpectraHeisScope was not showing the right channels
11 -jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value),
11 -jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value),
12 Bug fixed selecting heights by block (selecting profiles instead heights)
12 Bug fixed selecting heights by block (selecting profiles instead heights)
13 -jroproc_voltage.py: New feature added: decoding data by block using FFT.
13 -jroproc_voltage.py: New feature added: decoding data by block using FFT.
14 -jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits object instead schainpy.mode.data.jrodata.Fits object.
14 -jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits object instead schainpy.mode.data.jrodata.Fits object.
15 -jroIO_heispectra.py: Channel index list does not exist. No newline at end of file
15 -jroIO_heispectra.py: Channel index list does not exist.
16
17 2.1.3.1:
18 -GUI: every icon were resized
19 -jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file
@@ -1,7 +1,7
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7 __version__ = "2.1.3" No newline at end of file
7 __version__ = "2.1.3.1" No newline at end of file
@@ -1,442 +1,442
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import sys
3 import sys
4 import matplotlib
4 import matplotlib
5
5
6 if 'linux' in sys.platform:
6 if 'linux' in sys.platform:
7 matplotlib.use("TKAgg")
7 matplotlib.use("TKAgg")
8
8
9 if 'darwin' in sys.platform:
9 if 'darwin' in sys.platform:
10 matplotlib.use("WXAgg")
10 matplotlib.use('GTKAgg')
11 #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX'
11 #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX'
12 import matplotlib.pyplot
12 import matplotlib.pyplot
13
13
14 from mpl_toolkits.axes_grid1 import make_axes_locatable
14 from mpl_toolkits.axes_grid1 import make_axes_locatable
15 from matplotlib.ticker import *
15 from matplotlib.ticker import *
16
16
17 ###########################################
17 ###########################################
18 #Actualizacion de las funciones del driver
18 #Actualizacion de las funciones del driver
19 ###########################################
19 ###########################################
20
20
21 def createFigure(id, wintitle, width, height, facecolor="w", show=True):
21 def createFigure(id, wintitle, width, height, facecolor="w", show=True):
22
22
23 matplotlib.pyplot.ioff()
23 matplotlib.pyplot.ioff()
24 fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor)
24 fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor)
25 fig.canvas.manager.set_window_title(wintitle)
25 fig.canvas.manager.set_window_title(wintitle)
26 fig.canvas.manager.resize(width, height)
26 fig.canvas.manager.resize(width, height)
27 matplotlib.pyplot.ion()
27 matplotlib.pyplot.ion()
28 if show:
28 if show:
29 matplotlib.pyplot.show()
29 matplotlib.pyplot.show()
30
30
31 return fig
31 return fig
32
32
33 def closeFigure(show=False, fig=None):
33 def closeFigure(show=False, fig=None):
34
34
35 matplotlib.pyplot.ioff()
35 matplotlib.pyplot.ioff()
36 matplotlib.pyplot.pause(0.1)
36 matplotlib.pyplot.pause(0.1)
37
37
38 if show:
38 if show:
39 matplotlib.pyplot.show()
39 matplotlib.pyplot.show()
40
40
41 if fig != None:
41 if fig != None:
42 matplotlib.pyplot.close(fig)
42 matplotlib.pyplot.close(fig)
43 matplotlib.pyplot.pause(0.1)
43 matplotlib.pyplot.pause(0.1)
44 matplotlib.pyplot.ion()
44 matplotlib.pyplot.ion()
45 return
45 return
46
46
47 matplotlib.pyplot.close("all")
47 matplotlib.pyplot.close("all")
48 matplotlib.pyplot.pause(0.1)
48 matplotlib.pyplot.pause(0.1)
49 matplotlib.pyplot.ion()
49 matplotlib.pyplot.ion()
50 return
50 return
51
51
52 def saveFigure(fig, filename):
52 def saveFigure(fig, filename):
53
53
54 matplotlib.pyplot.ioff()
54 matplotlib.pyplot.ioff()
55 fig.savefig(filename)
55 fig.savefig(filename)
56 matplotlib.pyplot.ion()
56 matplotlib.pyplot.ion()
57
57
58 def setWinTitle(fig, title):
58 def setWinTitle(fig, title):
59
59
60 fig.canvas.manager.set_window_title(title)
60 fig.canvas.manager.set_window_title(title)
61
61
62 def setTitle(fig, title):
62 def setTitle(fig, title):
63
63
64 fig.suptitle(title)
64 fig.suptitle(title)
65
65
66 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False):
66 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False):
67
67
68 matplotlib.pyplot.ioff()
68 matplotlib.pyplot.ioff()
69 matplotlib.pyplot.figure(fig.number)
69 matplotlib.pyplot.figure(fig.number)
70 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
70 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
71 (xpos, ypos),
71 (xpos, ypos),
72 colspan=colspan,
72 colspan=colspan,
73 rowspan=rowspan,
73 rowspan=rowspan,
74 polar=polar)
74 polar=polar)
75
75
76 matplotlib.pyplot.ion()
76 matplotlib.pyplot.ion()
77 return axes
77 return axes
78
78
79 def setAxesText(ax, text):
79 def setAxesText(ax, text):
80
80
81 ax.annotate(text,
81 ax.annotate(text,
82 xy = (.1, .99),
82 xy = (.1, .99),
83 xycoords = 'figure fraction',
83 xycoords = 'figure fraction',
84 horizontalalignment = 'left',
84 horizontalalignment = 'left',
85 verticalalignment = 'top',
85 verticalalignment = 'top',
86 fontsize = 10)
86 fontsize = 10)
87
87
88 def printLabels(ax, xlabel, ylabel, title):
88 def printLabels(ax, xlabel, ylabel, title):
89
89
90 ax.set_xlabel(xlabel, size=11)
90 ax.set_xlabel(xlabel, size=11)
91 ax.set_ylabel(ylabel, size=11)
91 ax.set_ylabel(ylabel, size=11)
92 ax.set_title(title, size=8)
92 ax.set_title(title, size=8)
93
93
94 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
94 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
95 ticksize=9, xtick_visible=True, ytick_visible=True,
95 ticksize=9, xtick_visible=True, ytick_visible=True,
96 nxticks=4, nyticks=10,
96 nxticks=4, nyticks=10,
97 grid=None,color='blue'):
97 grid=None,color='blue'):
98
98
99 """
99 """
100
100
101 Input:
101 Input:
102 grid : None, 'both', 'x', 'y'
102 grid : None, 'both', 'x', 'y'
103 """
103 """
104
104
105 matplotlib.pyplot.ioff()
105 matplotlib.pyplot.ioff()
106
106
107 ax.set_xlim([xmin,xmax])
107 ax.set_xlim([xmin,xmax])
108 ax.set_ylim([ymin,ymax])
108 ax.set_ylim([ymin,ymax])
109
109
110 printLabels(ax, xlabel, ylabel, title)
110 printLabels(ax, xlabel, ylabel, title)
111
111
112 ######################################################
112 ######################################################
113 if (xmax-xmin)<=1:
113 if (xmax-xmin)<=1:
114 xtickspos = numpy.linspace(xmin,xmax,nxticks)
114 xtickspos = numpy.linspace(xmin,xmax,nxticks)
115 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
115 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
116 ax.set_xticks(xtickspos)
116 ax.set_xticks(xtickspos)
117 else:
117 else:
118 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
118 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
119 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
119 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
120 ax.set_xticks(xtickspos)
120 ax.set_xticks(xtickspos)
121
121
122 for tick in ax.get_xticklabels():
122 for tick in ax.get_xticklabels():
123 tick.set_visible(xtick_visible)
123 tick.set_visible(xtick_visible)
124
124
125 for tick in ax.xaxis.get_major_ticks():
125 for tick in ax.xaxis.get_major_ticks():
126 tick.label.set_fontsize(ticksize)
126 tick.label.set_fontsize(ticksize)
127
127
128 ######################################################
128 ######################################################
129 for tick in ax.get_yticklabels():
129 for tick in ax.get_yticklabels():
130 tick.set_visible(ytick_visible)
130 tick.set_visible(ytick_visible)
131
131
132 for tick in ax.yaxis.get_major_ticks():
132 for tick in ax.yaxis.get_major_ticks():
133 tick.label.set_fontsize(ticksize)
133 tick.label.set_fontsize(ticksize)
134
134
135 ax.plot(x, y, color=color)
135 ax.plot(x, y, color=color)
136 iplot = ax.lines[-1]
136 iplot = ax.lines[-1]
137
137
138 ######################################################
138 ######################################################
139 if '0.' in matplotlib.__version__[0:2]:
139 if '0.' in matplotlib.__version__[0:2]:
140 print "The matplotlib version has to be updated to 1.1 or newer"
140 print "The matplotlib version has to be updated to 1.1 or newer"
141 return iplot
141 return iplot
142
142
143 if '1.0.' in matplotlib.__version__[0:4]:
143 if '1.0.' in matplotlib.__version__[0:4]:
144 print "The matplotlib version has to be updated to 1.1 or newer"
144 print "The matplotlib version has to be updated to 1.1 or newer"
145 return iplot
145 return iplot
146
146
147 if grid != None:
147 if grid != None:
148 ax.grid(b=True, which='major', axis=grid)
148 ax.grid(b=True, which='major', axis=grid)
149
149
150 matplotlib.pyplot.tight_layout()
150 matplotlib.pyplot.tight_layout()
151
151
152 matplotlib.pyplot.ion()
152 matplotlib.pyplot.ion()
153
153
154 return iplot
154 return iplot
155
155
156 def set_linedata(ax, x, y, idline):
156 def set_linedata(ax, x, y, idline):
157
157
158 ax.lines[idline].set_data(x,y)
158 ax.lines[idline].set_data(x,y)
159
159
160 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
160 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
161
161
162 ax = iplot.get_axes()
162 ax = iplot.get_axes()
163
163
164 printLabels(ax, xlabel, ylabel, title)
164 printLabels(ax, xlabel, ylabel, title)
165
165
166 set_linedata(ax, x, y, idline=0)
166 set_linedata(ax, x, y, idline=0)
167
167
168 def addpline(ax, x, y, color, linestyle, lw):
168 def addpline(ax, x, y, color, linestyle, lw):
169
169
170 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
170 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
171
171
172
172
173 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
173 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
174 xlabel='', ylabel='', title='', ticksize = 9,
174 xlabel='', ylabel='', title='', ticksize = 9,
175 colormap='jet',cblabel='', cbsize="5%",
175 colormap='jet',cblabel='', cbsize="5%",
176 XAxisAsTime=False):
176 XAxisAsTime=False):
177
177
178 matplotlib.pyplot.ioff()
178 matplotlib.pyplot.ioff()
179
179
180 divider = make_axes_locatable(ax)
180 divider = make_axes_locatable(ax)
181 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
181 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
182 fig = ax.get_figure()
182 fig = ax.get_figure()
183 fig.add_axes(ax_cb)
183 fig.add_axes(ax_cb)
184
184
185 ax.set_xlim([xmin,xmax])
185 ax.set_xlim([xmin,xmax])
186 ax.set_ylim([ymin,ymax])
186 ax.set_ylim([ymin,ymax])
187
187
188 printLabels(ax, xlabel, ylabel, title)
188 printLabels(ax, xlabel, ylabel, title)
189
189
190 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
190 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
191 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
191 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
192 cb.set_label(cblabel)
192 cb.set_label(cblabel)
193
193
194 # for tl in ax_cb.get_yticklabels():
194 # for tl in ax_cb.get_yticklabels():
195 # tl.set_visible(True)
195 # tl.set_visible(True)
196
196
197 for tick in ax.yaxis.get_major_ticks():
197 for tick in ax.yaxis.get_major_ticks():
198 tick.label.set_fontsize(ticksize)
198 tick.label.set_fontsize(ticksize)
199
199
200 for tick in ax.xaxis.get_major_ticks():
200 for tick in ax.xaxis.get_major_ticks():
201 tick.label.set_fontsize(ticksize)
201 tick.label.set_fontsize(ticksize)
202
202
203 for tick in cb.ax.get_yticklabels():
203 for tick in cb.ax.get_yticklabels():
204 tick.set_fontsize(ticksize)
204 tick.set_fontsize(ticksize)
205
205
206 ax_cb.yaxis.tick_right()
206 ax_cb.yaxis.tick_right()
207
207
208 if '0.' in matplotlib.__version__[0:2]:
208 if '0.' in matplotlib.__version__[0:2]:
209 print "The matplotlib version has to be updated to 1.1 or newer"
209 print "The matplotlib version has to be updated to 1.1 or newer"
210 return imesh
210 return imesh
211
211
212 if '1.0.' in matplotlib.__version__[0:4]:
212 if '1.0.' in matplotlib.__version__[0:4]:
213 print "The matplotlib version has to be updated to 1.1 or newer"
213 print "The matplotlib version has to be updated to 1.1 or newer"
214 return imesh
214 return imesh
215
215
216 matplotlib.pyplot.tight_layout()
216 matplotlib.pyplot.tight_layout()
217
217
218 if XAxisAsTime:
218 if XAxisAsTime:
219
219
220 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
220 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
221 ax.xaxis.set_major_formatter(FuncFormatter(func))
221 ax.xaxis.set_major_formatter(FuncFormatter(func))
222 ax.xaxis.set_major_locator(LinearLocator(7))
222 ax.xaxis.set_major_locator(LinearLocator(7))
223
223
224 matplotlib.pyplot.ion()
224 matplotlib.pyplot.ion()
225 return imesh
225 return imesh
226
226
227 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
227 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
228
228
229 z = z.T
229 z = z.T
230 ax = imesh.get_axes()
230 ax = imesh.get_axes()
231 printLabels(ax, xlabel, ylabel, title)
231 printLabels(ax, xlabel, ylabel, title)
232 imesh.set_array(z.ravel())
232 imesh.set_array(z.ravel())
233
233
234 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
234 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
235
235
236 printLabels(ax, xlabel, ylabel, title)
236 printLabels(ax, xlabel, ylabel, title)
237
237
238 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
238 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
239
239
240 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
240 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
241
241
242 printLabels(ax, xlabel, ylabel, title)
242 printLabels(ax, xlabel, ylabel, title)
243
243
244 ax.collections.remove(ax.collections[0])
244 ax.collections.remove(ax.collections[0])
245
245
246 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
246 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
247
247
248 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
248 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
249 ticksize=9, xtick_visible=True, ytick_visible=True,
249 ticksize=9, xtick_visible=True, ytick_visible=True,
250 nxticks=4, nyticks=10,
250 nxticks=4, nyticks=10,
251 grid=None):
251 grid=None):
252
252
253 """
253 """
254
254
255 Input:
255 Input:
256 grid : None, 'both', 'x', 'y'
256 grid : None, 'both', 'x', 'y'
257 """
257 """
258
258
259 matplotlib.pyplot.ioff()
259 matplotlib.pyplot.ioff()
260
260
261 lines = ax.plot(x.T, y)
261 lines = ax.plot(x.T, y)
262 leg = ax.legend(lines, legendlabels, loc='upper right')
262 leg = ax.legend(lines, legendlabels, loc='upper right')
263 leg.get_frame().set_alpha(0.5)
263 leg.get_frame().set_alpha(0.5)
264 ax.set_xlim([xmin,xmax])
264 ax.set_xlim([xmin,xmax])
265 ax.set_ylim([ymin,ymax])
265 ax.set_ylim([ymin,ymax])
266 printLabels(ax, xlabel, ylabel, title)
266 printLabels(ax, xlabel, ylabel, title)
267
267
268 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
268 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
269 ax.set_xticks(xtickspos)
269 ax.set_xticks(xtickspos)
270
270
271 for tick in ax.get_xticklabels():
271 for tick in ax.get_xticklabels():
272 tick.set_visible(xtick_visible)
272 tick.set_visible(xtick_visible)
273
273
274 for tick in ax.xaxis.get_major_ticks():
274 for tick in ax.xaxis.get_major_ticks():
275 tick.label.set_fontsize(ticksize)
275 tick.label.set_fontsize(ticksize)
276
276
277 for tick in ax.get_yticklabels():
277 for tick in ax.get_yticklabels():
278 tick.set_visible(ytick_visible)
278 tick.set_visible(ytick_visible)
279
279
280 for tick in ax.yaxis.get_major_ticks():
280 for tick in ax.yaxis.get_major_ticks():
281 tick.label.set_fontsize(ticksize)
281 tick.label.set_fontsize(ticksize)
282
282
283 iplot = ax.lines[-1]
283 iplot = ax.lines[-1]
284
284
285 if '0.' in matplotlib.__version__[0:2]:
285 if '0.' in matplotlib.__version__[0:2]:
286 print "The matplotlib version has to be updated to 1.1 or newer"
286 print "The matplotlib version has to be updated to 1.1 or newer"
287 return iplot
287 return iplot
288
288
289 if '1.0.' in matplotlib.__version__[0:4]:
289 if '1.0.' in matplotlib.__version__[0:4]:
290 print "The matplotlib version has to be updated to 1.1 or newer"
290 print "The matplotlib version has to be updated to 1.1 or newer"
291 return iplot
291 return iplot
292
292
293 if grid != None:
293 if grid != None:
294 ax.grid(b=True, which='major', axis=grid)
294 ax.grid(b=True, which='major', axis=grid)
295
295
296 matplotlib.pyplot.tight_layout()
296 matplotlib.pyplot.tight_layout()
297
297
298 matplotlib.pyplot.ion()
298 matplotlib.pyplot.ion()
299
299
300 return iplot
300 return iplot
301
301
302
302
303 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
303 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
304
304
305 ax = iplot.get_axes()
305 ax = iplot.get_axes()
306
306
307 printLabels(ax, xlabel, ylabel, title)
307 printLabels(ax, xlabel, ylabel, title)
308
308
309 for i in range(len(ax.lines)):
309 for i in range(len(ax.lines)):
310 line = ax.lines[i]
310 line = ax.lines[i]
311 line.set_data(x[i,:],y)
311 line.set_data(x[i,:],y)
312
312
313 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
313 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
314 ticksize=9, xtick_visible=True, ytick_visible=True,
314 ticksize=9, xtick_visible=True, ytick_visible=True,
315 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
315 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
316 grid=None, XAxisAsTime=False):
316 grid=None, XAxisAsTime=False):
317
317
318 """
318 """
319
319
320 Input:
320 Input:
321 grid : None, 'both', 'x', 'y'
321 grid : None, 'both', 'x', 'y'
322 """
322 """
323
323
324 matplotlib.pyplot.ioff()
324 matplotlib.pyplot.ioff()
325
325
326 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
326 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
327 lines = ax.plot(x, y.T, linestyle=linestyle, marker=marker, markersize=markersize)
327 lines = ax.plot(x, y.T, linestyle=linestyle, marker=marker, markersize=markersize)
328 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
328 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
329 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
329 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
330
330
331 for label in leg.get_texts(): label.set_fontsize(9)
331 for label in leg.get_texts(): label.set_fontsize(9)
332
332
333 ax.set_xlim([xmin,xmax])
333 ax.set_xlim([xmin,xmax])
334 ax.set_ylim([ymin,ymax])
334 ax.set_ylim([ymin,ymax])
335 printLabels(ax, xlabel, ylabel, title)
335 printLabels(ax, xlabel, ylabel, title)
336
336
337 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
337 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
338 # ax.set_xticks(xtickspos)
338 # ax.set_xticks(xtickspos)
339
339
340 for tick in ax.get_xticklabels():
340 for tick in ax.get_xticklabels():
341 tick.set_visible(xtick_visible)
341 tick.set_visible(xtick_visible)
342
342
343 for tick in ax.xaxis.get_major_ticks():
343 for tick in ax.xaxis.get_major_ticks():
344 tick.label.set_fontsize(ticksize)
344 tick.label.set_fontsize(ticksize)
345
345
346 for tick in ax.get_yticklabels():
346 for tick in ax.get_yticklabels():
347 tick.set_visible(ytick_visible)
347 tick.set_visible(ytick_visible)
348
348
349 for tick in ax.yaxis.get_major_ticks():
349 for tick in ax.yaxis.get_major_ticks():
350 tick.label.set_fontsize(ticksize)
350 tick.label.set_fontsize(ticksize)
351
351
352 iplot = ax.lines[-1]
352 iplot = ax.lines[-1]
353
353
354 if '0.' in matplotlib.__version__[0:2]:
354 if '0.' in matplotlib.__version__[0:2]:
355 print "The matplotlib version has to be updated to 1.1 or newer"
355 print "The matplotlib version has to be updated to 1.1 or newer"
356 return iplot
356 return iplot
357
357
358 if '1.0.' in matplotlib.__version__[0:4]:
358 if '1.0.' in matplotlib.__version__[0:4]:
359 print "The matplotlib version has to be updated to 1.1 or newer"
359 print "The matplotlib version has to be updated to 1.1 or newer"
360 return iplot
360 return iplot
361
361
362 if grid != None:
362 if grid != None:
363 ax.grid(b=True, which='major', axis=grid)
363 ax.grid(b=True, which='major', axis=grid)
364
364
365 matplotlib.pyplot.tight_layout()
365 matplotlib.pyplot.tight_layout()
366
366
367 if XAxisAsTime:
367 if XAxisAsTime:
368
368
369 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
369 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
370 ax.xaxis.set_major_formatter(FuncFormatter(func))
370 ax.xaxis.set_major_formatter(FuncFormatter(func))
371 ax.xaxis.set_major_locator(LinearLocator(7))
371 ax.xaxis.set_major_locator(LinearLocator(7))
372
372
373 matplotlib.pyplot.ion()
373 matplotlib.pyplot.ion()
374
374
375 return iplot
375 return iplot
376
376
377 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
377 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
378
378
379 ax = iplot.get_axes()
379 ax = iplot.get_axes()
380
380
381 printLabels(ax, xlabel, ylabel, title)
381 printLabels(ax, xlabel, ylabel, title)
382
382
383 for i in range(len(ax.lines)):
383 for i in range(len(ax.lines)):
384 line = ax.lines[i]
384 line = ax.lines[i]
385 line.set_data(x,y[i,:])
385 line.set_data(x,y[i,:])
386
386
387 def createPolar(ax, x, y,
387 def createPolar(ax, x, y,
388 xlabel='', ylabel='', title='', ticksize = 9,
388 xlabel='', ylabel='', title='', ticksize = 9,
389 colormap='jet',cblabel='', cbsize="5%",
389 colormap='jet',cblabel='', cbsize="5%",
390 XAxisAsTime=False):
390 XAxisAsTime=False):
391
391
392 matplotlib.pyplot.ioff()
392 matplotlib.pyplot.ioff()
393
393
394 ax.plot(x,y,'bo', markersize=5)
394 ax.plot(x,y,'bo', markersize=5)
395 # ax.set_rmax(90)
395 # ax.set_rmax(90)
396 ax.set_ylim(0,90)
396 ax.set_ylim(0,90)
397 ax.set_yticks(numpy.arange(0,90,20))
397 ax.set_yticks(numpy.arange(0,90,20))
398 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center' ,size='11')
398 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center' ,size='11')
399 # ax.text(0, 50, ylabel, rotation='vertical', va ='center', ha = 'left' ,size='11')
399 # ax.text(0, 50, ylabel, rotation='vertical', va ='center', ha = 'left' ,size='11')
400 # ax.text(100, 100, 'example', ha='left', va='center', rotation='vertical')
400 # ax.text(100, 100, 'example', ha='left', va='center', rotation='vertical')
401 ax.yaxis.labelpad = 230
401 ax.yaxis.labelpad = 230
402 printLabels(ax, xlabel, ylabel, title)
402 printLabels(ax, xlabel, ylabel, title)
403 iplot = ax.lines[-1]
403 iplot = ax.lines[-1]
404
404
405 if '0.' in matplotlib.__version__[0:2]:
405 if '0.' in matplotlib.__version__[0:2]:
406 print "The matplotlib version has to be updated to 1.1 or newer"
406 print "The matplotlib version has to be updated to 1.1 or newer"
407 return iplot
407 return iplot
408
408
409 if '1.0.' in matplotlib.__version__[0:4]:
409 if '1.0.' in matplotlib.__version__[0:4]:
410 print "The matplotlib version has to be updated to 1.1 or newer"
410 print "The matplotlib version has to be updated to 1.1 or newer"
411 return iplot
411 return iplot
412
412
413 # if grid != None:
413 # if grid != None:
414 # ax.grid(b=True, which='major', axis=grid)
414 # ax.grid(b=True, which='major', axis=grid)
415
415
416 matplotlib.pyplot.tight_layout()
416 matplotlib.pyplot.tight_layout()
417
417
418 matplotlib.pyplot.ion()
418 matplotlib.pyplot.ion()
419
419
420
420
421 return iplot
421 return iplot
422
422
423 def polar(iplot, x, y, xlabel='', ylabel='', title=''):
423 def polar(iplot, x, y, xlabel='', ylabel='', title=''):
424
424
425 ax = iplot.get_axes()
425 ax = iplot.get_axes()
426
426
427 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center',size='11')
427 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center',size='11')
428 printLabels(ax, xlabel, ylabel, title)
428 printLabels(ax, xlabel, ylabel, title)
429
429
430 set_linedata(ax, x, y, idline=0)
430 set_linedata(ax, x, y, idline=0)
431
431
432 def draw(fig):
432 def draw(fig):
433
433
434 if type(fig) == 'int':
434 if type(fig) == 'int':
435 raise ValueError, "Error drawing: Fig parameter should be a matplotlib figure object figure"
435 raise ValueError, "Error drawing: Fig parameter should be a matplotlib figure object figure"
436
436
437 fig.canvas.draw()
437 fig.canvas.draw()
438
438
439 def pause(interval=0.000001):
439 def pause(interval=0.000001):
440
440
441 matplotlib.pyplot.pause(interval)
441 matplotlib.pyplot.pause(interval)
442 No newline at end of file
442
@@ -1,1087 +1,1095
1 import numpy
1 import numpy
2
2
3 from jroproc_base import ProcessingUnit, Operation
3 from jroproc_base import ProcessingUnit, Operation
4 from schainpy.model.data.jrodata import Voltage
4 from schainpy.model.data.jrodata import Voltage
5
5
6 class VoltageProc(ProcessingUnit):
6 class VoltageProc(ProcessingUnit):
7
7
8
8
9 def __init__(self):
9 def __init__(self):
10
10
11 ProcessingUnit.__init__(self)
11 ProcessingUnit.__init__(self)
12
12
13 # self.objectDict = {}
13 # self.objectDict = {}
14 self.dataOut = Voltage()
14 self.dataOut = Voltage()
15 self.flip = 1
15 self.flip = 1
16
16
17 def run(self):
17 def run(self):
18 if self.dataIn.type == 'AMISR':
18 if self.dataIn.type == 'AMISR':
19 self.__updateObjFromAmisrInput()
19 self.__updateObjFromAmisrInput()
20
20
21 if self.dataIn.type == 'Voltage':
21 if self.dataIn.type == 'Voltage':
22 self.dataOut.copy(self.dataIn)
22 self.dataOut.copy(self.dataIn)
23
23
24 # self.dataOut.copy(self.dataIn)
24 # self.dataOut.copy(self.dataIn)
25
25
26 def __updateObjFromAmisrInput(self):
26 def __updateObjFromAmisrInput(self):
27
27
28 self.dataOut.timeZone = self.dataIn.timeZone
28 self.dataOut.timeZone = self.dataIn.timeZone
29 self.dataOut.dstFlag = self.dataIn.dstFlag
29 self.dataOut.dstFlag = self.dataIn.dstFlag
30 self.dataOut.errorCount = self.dataIn.errorCount
30 self.dataOut.errorCount = self.dataIn.errorCount
31 self.dataOut.useLocalTime = self.dataIn.useLocalTime
31 self.dataOut.useLocalTime = self.dataIn.useLocalTime
32
32
33 self.dataOut.flagNoData = self.dataIn.flagNoData
33 self.dataOut.flagNoData = self.dataIn.flagNoData
34 self.dataOut.data = self.dataIn.data
34 self.dataOut.data = self.dataIn.data
35 self.dataOut.utctime = self.dataIn.utctime
35 self.dataOut.utctime = self.dataIn.utctime
36 self.dataOut.channelList = self.dataIn.channelList
36 self.dataOut.channelList = self.dataIn.channelList
37 # self.dataOut.timeInterval = self.dataIn.timeInterval
37 # self.dataOut.timeInterval = self.dataIn.timeInterval
38 self.dataOut.heightList = self.dataIn.heightList
38 self.dataOut.heightList = self.dataIn.heightList
39 self.dataOut.nProfiles = self.dataIn.nProfiles
39 self.dataOut.nProfiles = self.dataIn.nProfiles
40
40
41 self.dataOut.nCohInt = self.dataIn.nCohInt
41 self.dataOut.nCohInt = self.dataIn.nCohInt
42 self.dataOut.ippSeconds = self.dataIn.ippSeconds
42 self.dataOut.ippSeconds = self.dataIn.ippSeconds
43 self.dataOut.frequency = self.dataIn.frequency
43 self.dataOut.frequency = self.dataIn.frequency
44
44
45 self.dataOut.azimuth = self.dataIn.azimuth
45 self.dataOut.azimuth = self.dataIn.azimuth
46 self.dataOut.zenith = self.dataIn.zenith
46 self.dataOut.zenith = self.dataIn.zenith
47
47
48 self.dataOut.beam.codeList = self.dataIn.beam.codeList
48 self.dataOut.beam.codeList = self.dataIn.beam.codeList
49 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
49 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
50 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
50 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
51 #
51 #
52 # pass#
52 # pass#
53 #
53 #
54 # def init(self):
54 # def init(self):
55 #
55 #
56 #
56 #
57 # if self.dataIn.type == 'AMISR':
57 # if self.dataIn.type == 'AMISR':
58 # self.__updateObjFromAmisrInput()
58 # self.__updateObjFromAmisrInput()
59 #
59 #
60 # if self.dataIn.type == 'Voltage':
60 # if self.dataIn.type == 'Voltage':
61 # self.dataOut.copy(self.dataIn)
61 # self.dataOut.copy(self.dataIn)
62 # # No necesita copiar en cada init() los atributos de dataIn
62 # # No necesita copiar en cada init() los atributos de dataIn
63 # # la copia deberia hacerse por cada nuevo bloque de datos
63 # # la copia deberia hacerse por cada nuevo bloque de datos
64
64
65 def selectChannels(self, channelList):
65 def selectChannels(self, channelList):
66
66
67 channelIndexList = []
67 channelIndexList = []
68
68
69 for channel in channelList:
69 for channel in channelList:
70 if channel not in self.dataOut.channelList:
70 if channel not in self.dataOut.channelList:
71 raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList))
71 raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList))
72
72
73 index = self.dataOut.channelList.index(channel)
73 index = self.dataOut.channelList.index(channel)
74 channelIndexList.append(index)
74 channelIndexList.append(index)
75
75
76 self.selectChannelsByIndex(channelIndexList)
76 self.selectChannelsByIndex(channelIndexList)
77
77
78 def selectChannelsByIndex(self, channelIndexList):
78 def selectChannelsByIndex(self, channelIndexList):
79 """
79 """
80 Selecciona un bloque de datos en base a canales segun el channelIndexList
80 Selecciona un bloque de datos en base a canales segun el channelIndexList
81
81
82 Input:
82 Input:
83 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
83 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
84
84
85 Affected:
85 Affected:
86 self.dataOut.data
86 self.dataOut.data
87 self.dataOut.channelIndexList
87 self.dataOut.channelIndexList
88 self.dataOut.nChannels
88 self.dataOut.nChannels
89 self.dataOut.m_ProcessingHeader.totalSpectra
89 self.dataOut.m_ProcessingHeader.totalSpectra
90 self.dataOut.systemHeaderObj.numChannels
90 self.dataOut.systemHeaderObj.numChannels
91 self.dataOut.m_ProcessingHeader.blockSize
91 self.dataOut.m_ProcessingHeader.blockSize
92
92
93 Return:
93 Return:
94 None
94 None
95 """
95 """
96
96
97 for channelIndex in channelIndexList:
97 for channelIndex in channelIndexList:
98 if channelIndex not in self.dataOut.channelIndexList:
98 if channelIndex not in self.dataOut.channelIndexList:
99 print channelIndexList
99 print channelIndexList
100 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
100 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
101
101
102 # nChannels = len(channelIndexList)
102 # nChannels = len(channelIndexList)
103 if self.dataOut.flagDataAsBlock:
103 if self.dataOut.flagDataAsBlock:
104 """
104 """
105 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
105 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
106 """
106 """
107 data = self.dataOut.data[channelIndexList,:,:]
107 data = self.dataOut.data[channelIndexList,:,:]
108 else:
108 else:
109 data = self.dataOut.data[channelIndexList,:]
109 data = self.dataOut.data[channelIndexList,:]
110
110
111 self.dataOut.data = data
111 self.dataOut.data = data
112 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
112 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
113 # self.dataOut.nChannels = nChannels
113 # self.dataOut.nChannels = nChannels
114
114
115 return 1
115 return 1
116
116
117 def selectHeights(self, minHei=None, maxHei=None):
117 def selectHeights(self, minHei=None, maxHei=None):
118 """
118 """
119 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
119 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
120 minHei <= height <= maxHei
120 minHei <= height <= maxHei
121
121
122 Input:
122 Input:
123 minHei : valor minimo de altura a considerar
123 minHei : valor minimo de altura a considerar
124 maxHei : valor maximo de altura a considerar
124 maxHei : valor maximo de altura a considerar
125
125
126 Affected:
126 Affected:
127 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
127 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
128
128
129 Return:
129 Return:
130 1 si el metodo se ejecuto con exito caso contrario devuelve 0
130 1 si el metodo se ejecuto con exito caso contrario devuelve 0
131 """
131 """
132
132
133 if minHei == None:
133 if minHei == None:
134 minHei = self.dataOut.heightList[0]
134 minHei = self.dataOut.heightList[0]
135
135
136 if maxHei == None:
136 if maxHei == None:
137 maxHei = self.dataOut.heightList[-1]
137 maxHei = self.dataOut.heightList[-1]
138
138
139 if (minHei < self.dataOut.heightList[0]):
139 if (minHei < self.dataOut.heightList[0]):
140 minHei = self.dataOut.heightList[0]
140 minHei = self.dataOut.heightList[0]
141 # raise ValueError, "height range [%d,%d] is not valid. Data height range is [%d, %d]" % (minHei,
141 # raise ValueError, "height range [%d,%d] is not valid. Data height range is [%d, %d]" % (minHei,
142 # maxHei,
142 # maxHei,
143 # self.dataOut.heightList[0],
143 # self.dataOut.heightList[0],
144 # self.dataOut.heightList[-1])
144 # self.dataOut.heightList[-1])
145
145
146 if (maxHei > self.dataOut.heightList[-1]):
146 if (maxHei > self.dataOut.heightList[-1]):
147 maxHei = self.dataOut.heightList[-1]
147 maxHei = self.dataOut.heightList[-1]
148 # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
148 # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
149
149
150 minIndex = 0
150 minIndex = 0
151 maxIndex = 0
151 maxIndex = 0
152 heights = self.dataOut.heightList
152 heights = self.dataOut.heightList
153
153
154 inda = numpy.where(heights >= minHei)
154 inda = numpy.where(heights >= minHei)
155 indb = numpy.where(heights <= maxHei)
155 indb = numpy.where(heights <= maxHei)
156
156
157 try:
157 try:
158 minIndex = inda[0][0]
158 minIndex = inda[0][0]
159 except:
159 except:
160 minIndex = 0
160 minIndex = 0
161
161
162 try:
162 try:
163 maxIndex = indb[0][-1]
163 maxIndex = indb[0][-1]
164 except:
164 except:
165 maxIndex = len(heights)
165 maxIndex = len(heights)
166
166
167 self.selectHeightsByIndex(minIndex, maxIndex)
167 self.selectHeightsByIndex(minIndex, maxIndex)
168
168
169 return 1
169 return 1
170
170
171
171
172 def selectHeightsByIndex(self, minIndex, maxIndex):
172 def selectHeightsByIndex(self, minIndex, maxIndex):
173 """
173 """
174 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
174 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
175 minIndex <= index <= maxIndex
175 minIndex <= index <= maxIndex
176
176
177 Input:
177 Input:
178 minIndex : valor de indice minimo de altura a considerar
178 minIndex : valor de indice minimo de altura a considerar
179 maxIndex : valor de indice maximo de altura a considerar
179 maxIndex : valor de indice maximo de altura a considerar
180
180
181 Affected:
181 Affected:
182 self.dataOut.data
182 self.dataOut.data
183 self.dataOut.heightList
183 self.dataOut.heightList
184
184
185 Return:
185 Return:
186 1 si el metodo se ejecuto con exito caso contrario devuelve 0
186 1 si el metodo se ejecuto con exito caso contrario devuelve 0
187 """
187 """
188
188
189 if (minIndex < 0) or (minIndex > maxIndex):
189 if (minIndex < 0) or (minIndex > maxIndex):
190 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
190 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
191
191
192 if (maxIndex >= self.dataOut.nHeights):
192 if (maxIndex >= self.dataOut.nHeights):
193 maxIndex = self.dataOut.nHeights
193 maxIndex = self.dataOut.nHeights
194 # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
194 # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
195
195
196 # nHeights = maxIndex - minIndex + 1
196 # nHeights = maxIndex - minIndex + 1
197
197
198 #voltage
198 #voltage
199 if self.dataOut.flagDataAsBlock:
199 if self.dataOut.flagDataAsBlock:
200 """
200 """
201 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
201 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
202 """
202 """
203 data = self.dataOut.data[:,:, minIndex:maxIndex]
203 data = self.dataOut.data[:,:, minIndex:maxIndex]
204 else:
204 else:
205 data = self.dataOut.data[:, minIndex:maxIndex]
205 data = self.dataOut.data[:, minIndex:maxIndex]
206
206
207 # firstHeight = self.dataOut.heightList[minIndex]
207 # firstHeight = self.dataOut.heightList[minIndex]
208
208
209 self.dataOut.data = data
209 self.dataOut.data = data
210 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex]
210 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex]
211
211
212 if self.dataOut.nHeights <= 1:
212 if self.dataOut.nHeights <= 1:
213 raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)
213 raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)
214
214
215 return 1
215 return 1
216
216
217
217
218 def filterByHeights(self, window):
218 def filterByHeights(self, window):
219
219
220 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
220 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
221
221
222 if window == None:
222 if window == None:
223 window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight
223 window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight
224
224
225 newdelta = deltaHeight * window
225 newdelta = deltaHeight * window
226 r = self.dataOut.nHeights % window
226 r = self.dataOut.nHeights % window
227 newheights = (self.dataOut.nHeights-r)/window
227 newheights = (self.dataOut.nHeights-r)/window
228
228
229 if newheights <= 1:
229 if newheights <= 1:
230 raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window)
230 raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window)
231
231
232 if self.dataOut.flagDataAsBlock:
232 if self.dataOut.flagDataAsBlock:
233 """
233 """
234 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
234 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
235 """
235 """
236 buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r]
236 buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r]
237 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window)
237 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window)
238 buffer = numpy.sum(buffer,3)
238 buffer = numpy.sum(buffer,3)
239
239
240 else:
240 else:
241 buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r]
241 buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r]
242 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window)
242 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window)
243 buffer = numpy.sum(buffer,2)
243 buffer = numpy.sum(buffer,2)
244
244
245 self.dataOut.data = buffer
245 self.dataOut.data = buffer
246 self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta
246 self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta
247 self.dataOut.windowOfFilter = window
247 self.dataOut.windowOfFilter = window
248
248
249 def setH0(self, h0, deltaHeight = None):
249 def setH0(self, h0, deltaHeight = None):
250
250
251 if not deltaHeight:
251 if not deltaHeight:
252 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
252 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
253
253
254 nHeights = self.dataOut.nHeights
254 nHeights = self.dataOut.nHeights
255
255
256 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
256 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
257
257
258 self.dataOut.heightList = newHeiRange
258 self.dataOut.heightList = newHeiRange
259
259
260 def deFlip(self, channelList = []):
260 def deFlip(self, channelList = []):
261
261
262 data = self.dataOut.data.copy()
262 data = self.dataOut.data.copy()
263
263
264 if self.dataOut.flagDataAsBlock:
264 if self.dataOut.flagDataAsBlock:
265 flip = self.flip
265 flip = self.flip
266 profileList = range(self.dataOut.nProfiles)
266 profileList = range(self.dataOut.nProfiles)
267
267
268 if not channelList:
268 if not channelList:
269 for thisProfile in profileList:
269 for thisProfile in profileList:
270 data[:,thisProfile,:] = data[:,thisProfile,:]*flip
270 data[:,thisProfile,:] = data[:,thisProfile,:]*flip
271 flip *= -1.0
271 flip *= -1.0
272 else:
272 else:
273 for thisChannel in channelList:
273 for thisChannel in channelList:
274 if thisChannel not in self.dataOut.channelList:
274 if thisChannel not in self.dataOut.channelList:
275 continue
275 continue
276
276
277 for thisProfile in profileList:
277 for thisProfile in profileList:
278 data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip
278 data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip
279 flip *= -1.0
279 flip *= -1.0
280
280
281 self.flip = flip
281 self.flip = flip
282
282
283 else:
283 else:
284 if not channelList:
284 if not channelList:
285 data[:,:] = data[:,:]*self.flip
285 data[:,:] = data[:,:]*self.flip
286 else:
286 else:
287 for thisChannel in channelList:
287 for thisChannel in channelList:
288 if thisChannel not in self.dataOut.channelList:
288 if thisChannel not in self.dataOut.channelList:
289 continue
289 continue
290
290
291 data[thisChannel,:] = data[thisChannel,:]*self.flip
291 data[thisChannel,:] = data[thisChannel,:]*self.flip
292
292
293 self.flip *= -1.
293 self.flip *= -1.
294
294
295 self.dataOut.data = data
295 self.dataOut.data = data
296
296
297 def setRadarFrequency(self, frequency=None):
297 def setRadarFrequency(self, frequency=None):
298
298
299 if frequency != None:
299 if frequency != None:
300 self.dataOut.frequency = frequency
300 self.dataOut.frequency = frequency
301
301
302 return 1
302 return 1
303
303
304 class CohInt(Operation):
304 class CohInt(Operation):
305
305
306 isConfig = False
306 isConfig = False
307
307
308 __profIndex = 0
308 __profIndex = 0
309 __withOverapping = False
309 __withOverapping = False
310
310
311 __byTime = False
311 __byTime = False
312 __initime = None
312 __initime = None
313 __lastdatatime = None
313 __lastdatatime = None
314 __integrationtime = None
314 __integrationtime = None
315
315
316 __buffer = None
316 __buffer = None
317
317
318 __dataReady = False
318 __dataReady = False
319
319
320 n = None
320 n = None
321
321
322
322
323 def __init__(self):
323 def __init__(self):
324
324
325 Operation.__init__(self)
325 Operation.__init__(self)
326
326
327 # self.isConfig = False
327 # self.isConfig = False
328
328
329 def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False):
329 def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False):
330 """
330 """
331 Set the parameters of the integration class.
331 Set the parameters of the integration class.
332
332
333 Inputs:
333 Inputs:
334
334
335 n : Number of coherent integrations
335 n : Number of coherent integrations
336 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
336 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
337 overlapping :
337 overlapping :
338
338
339 """
339 """
340
340
341 self.__initime = None
341 self.__initime = None
342 self.__lastdatatime = 0
342 self.__lastdatatime = 0
343 self.__buffer = None
343 self.__buffer = None
344 self.__dataReady = False
344 self.__dataReady = False
345 self.byblock = byblock
345 self.byblock = byblock
346
346
347 if n == None and timeInterval == None:
347 if n == None and timeInterval == None:
348 raise ValueError, "n or timeInterval should be specified ..."
348 raise ValueError, "n or timeInterval should be specified ..."
349
349
350 if n != None:
350 if n != None:
351 self.n = n
351 self.n = n
352 self.__byTime = False
352 self.__byTime = False
353 else:
353 else:
354 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
354 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
355 self.n = 9999
355 self.n = 9999
356 self.__byTime = True
356 self.__byTime = True
357
357
358 if overlapping:
358 if overlapping:
359 self.__withOverapping = True
359 self.__withOverapping = True
360 self.__buffer = None
360 self.__buffer = None
361 else:
361 else:
362 self.__withOverapping = False
362 self.__withOverapping = False
363 self.__buffer = 0
363 self.__buffer = 0
364
364
365 self.__profIndex = 0
365 self.__profIndex = 0
366
366
367 def putData(self, data):
367 def putData(self, data):
368
368
369 """
369 """
370 Add a profile to the __buffer and increase in one the __profileIndex
370 Add a profile to the __buffer and increase in one the __profileIndex
371
371
372 """
372 """
373
373
374 if not self.__withOverapping:
374 if not self.__withOverapping:
375 self.__buffer += data.copy()
375 self.__buffer += data.copy()
376 self.__profIndex += 1
376 self.__profIndex += 1
377 return
377 return
378
378
379 #Overlapping data
379 #Overlapping data
380 nChannels, nHeis = data.shape
380 nChannels, nHeis = data.shape
381 data = numpy.reshape(data, (1, nChannels, nHeis))
381 data = numpy.reshape(data, (1, nChannels, nHeis))
382
382
383 #If the buffer is empty then it takes the data value
383 #If the buffer is empty then it takes the data value
384 if self.__buffer is None:
384 if self.__buffer is None:
385 self.__buffer = data
385 self.__buffer = data
386 self.__profIndex += 1
386 self.__profIndex += 1
387 return
387 return
388
388
389 #If the buffer length is lower than n then stakcing the data value
389 #If the buffer length is lower than n then stakcing the data value
390 if self.__profIndex < self.n:
390 if self.__profIndex < self.n:
391 self.__buffer = numpy.vstack((self.__buffer, data))
391 self.__buffer = numpy.vstack((self.__buffer, data))
392 self.__profIndex += 1
392 self.__profIndex += 1
393 return
393 return
394
394
395 #If the buffer length is equal to n then replacing the last buffer value with the data value
395 #If the buffer length is equal to n then replacing the last buffer value with the data value
396 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
396 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
397 self.__buffer[self.n-1] = data
397 self.__buffer[self.n-1] = data
398 self.__profIndex = self.n
398 self.__profIndex = self.n
399 return
399 return
400
400
401
401
402 def pushData(self):
402 def pushData(self):
403 """
403 """
404 Return the sum of the last profiles and the profiles used in the sum.
404 Return the sum of the last profiles and the profiles used in the sum.
405
405
406 Affected:
406 Affected:
407
407
408 self.__profileIndex
408 self.__profileIndex
409
409
410 """
410 """
411
411
412 if not self.__withOverapping:
412 if not self.__withOverapping:
413 data = self.__buffer
413 data = self.__buffer
414 n = self.__profIndex
414 n = self.__profIndex
415
415
416 self.__buffer = 0
416 self.__buffer = 0
417 self.__profIndex = 0
417 self.__profIndex = 0
418
418
419 return data, n
419 return data, n
420
420
421 #Integration with Overlapping
421 #Integration with Overlapping
422 data = numpy.sum(self.__buffer, axis=0)
422 data = numpy.sum(self.__buffer, axis=0)
423 n = self.__profIndex
423 n = self.__profIndex
424
424
425 return data, n
425 return data, n
426
426
427 def byProfiles(self, data):
427 def byProfiles(self, data):
428
428
429 self.__dataReady = False
429 self.__dataReady = False
430 avgdata = None
430 avgdata = None
431 # n = None
431 # n = None
432
432
433 self.putData(data)
433 self.putData(data)
434
434
435 if self.__profIndex == self.n:
435 if self.__profIndex == self.n:
436
436
437 avgdata, n = self.pushData()
437 avgdata, n = self.pushData()
438 self.__dataReady = True
438 self.__dataReady = True
439
439
440 return avgdata
440 return avgdata
441
441
442 def byTime(self, data, datatime):
442 def byTime(self, data, datatime):
443
443
444 self.__dataReady = False
444 self.__dataReady = False
445 avgdata = None
445 avgdata = None
446 n = None
446 n = None
447
447
448 self.putData(data)
448 self.putData(data)
449
449
450 if (datatime - self.__initime) >= self.__integrationtime:
450 if (datatime - self.__initime) >= self.__integrationtime:
451 avgdata, n = self.pushData()
451 avgdata, n = self.pushData()
452 self.n = n
452 self.n = n
453 self.__dataReady = True
453 self.__dataReady = True
454
454
455 return avgdata
455 return avgdata
456
456
457 def integrate(self, data, datatime=None):
457 def integrate(self, data, datatime=None):
458
458
459 if self.__initime == None:
459 if self.__initime == None:
460 self.__initime = datatime
460 self.__initime = datatime
461
461
462 if self.__byTime:
462 if self.__byTime:
463 avgdata = self.byTime(data, datatime)
463 avgdata = self.byTime(data, datatime)
464 else:
464 else:
465 avgdata = self.byProfiles(data)
465 avgdata = self.byProfiles(data)
466
466
467
467
468 self.__lastdatatime = datatime
468 self.__lastdatatime = datatime
469
469
470 if avgdata is None:
470 if avgdata is None:
471 return None, None
471 return None, None
472
472
473 avgdatatime = self.__initime
473 avgdatatime = self.__initime
474
474
475 deltatime = datatime -self.__lastdatatime
475 deltatime = datatime -self.__lastdatatime
476
476
477 if not self.__withOverapping:
477 if not self.__withOverapping:
478 self.__initime = datatime
478 self.__initime = datatime
479 else:
479 else:
480 self.__initime += deltatime
480 self.__initime += deltatime
481
481
482 return avgdata, avgdatatime
482 return avgdata, avgdatatime
483
483
484 def integrateByBlock(self, dataOut):
484 def integrateByBlock(self, dataOut):
485
485
486 times = int(dataOut.data.shape[1]/self.n)
486 times = int(dataOut.data.shape[1]/self.n)
487 avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex)
487 avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex)
488
488
489 id_min = 0
489 id_min = 0
490 id_max = self.n
490 id_max = self.n
491
491
492 for i in range(times):
492 for i in range(times):
493 junk = dataOut.data[:,id_min:id_max,:]
493 junk = dataOut.data[:,id_min:id_max,:]
494 avgdata[:,i,:] = junk.sum(axis=1)
494 avgdata[:,i,:] = junk.sum(axis=1)
495 id_min += self.n
495 id_min += self.n
496 id_max += self.n
496 id_max += self.n
497
497
498 timeInterval = dataOut.ippSeconds*self.n
498 timeInterval = dataOut.ippSeconds*self.n
499 avgdatatime = (times - 1) * timeInterval + dataOut.utctime
499 avgdatatime = (times - 1) * timeInterval + dataOut.utctime
500 self.__dataReady = True
500 self.__dataReady = True
501 return avgdata, avgdatatime
501 return avgdata, avgdatatime
502
502
503 def run(self, dataOut, **kwargs):
503 def run(self, dataOut, **kwargs):
504
504
505 if not self.isConfig:
505 if not self.isConfig:
506 self.setup(**kwargs)
506 self.setup(**kwargs)
507 self.isConfig = True
507 self.isConfig = True
508
508
509 if dataOut.flagDataAsBlock:
509 if dataOut.flagDataAsBlock:
510 """
510 """
511 Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis]
511 Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis]
512 """
512 """
513 avgdata, avgdatatime = self.integrateByBlock(dataOut)
513 avgdata, avgdatatime = self.integrateByBlock(dataOut)
514 else:
514 else:
515 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
515 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
516
516
517 # dataOut.timeInterval *= n
517 # dataOut.timeInterval *= n
518 dataOut.flagNoData = True
518 dataOut.flagNoData = True
519
519
520 if self.__dataReady:
520 if self.__dataReady:
521 dataOut.data = avgdata
521 dataOut.data = avgdata
522 dataOut.nCohInt *= self.n
522 dataOut.nCohInt *= self.n
523 dataOut.utctime = avgdatatime
523 dataOut.utctime = avgdatatime
524 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
524 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
525 dataOut.flagNoData = False
525 dataOut.flagNoData = False
526
526
527 class Decoder(Operation):
527 class Decoder(Operation):
528
528
529 isConfig = False
529 isConfig = False
530 __profIndex = 0
530 __profIndex = 0
531
531
532 code = None
532 code = None
533
533
534 nCode = None
534 nCode = None
535 nBaud = None
535 nBaud = None
536
536
537
537
538 def __init__(self):
538 def __init__(self):
539
539
540 Operation.__init__(self)
540 Operation.__init__(self)
541
541
542 self.times = None
542 self.times = None
543 self.osamp = None
543 self.osamp = None
544 # self.__setValues = False
544 # self.__setValues = False
545 self.isConfig = False
545 self.isConfig = False
546
546
547 def setup(self, code, osamp, dataOut):
547 def setup(self, code, osamp, dataOut):
548
548
549 self.__profIndex = 0
549 self.__profIndex = 0
550
550
551 self.code = code
551 self.code = code
552
552
553 self.nCode = len(code)
553 self.nCode = len(code)
554 self.nBaud = len(code[0])
554 self.nBaud = len(code[0])
555
555
556 if (osamp != None) and (osamp >1):
556 if (osamp != None) and (osamp >1):
557 self.osamp = osamp
557 self.osamp = osamp
558 self.code = numpy.repeat(code, repeats=self.osamp, axis=1)
558 self.code = numpy.repeat(code, repeats=self.osamp, axis=1)
559 self.nBaud = self.nBaud*self.osamp
559 self.nBaud = self.nBaud*self.osamp
560
560
561 self.__nChannels = dataOut.nChannels
561 self.__nChannels = dataOut.nChannels
562 self.__nProfiles = dataOut.nProfiles
562 self.__nProfiles = dataOut.nProfiles
563 self.__nHeis = dataOut.nHeights
563 self.__nHeis = dataOut.nHeights
564
564
565 if self.__nHeis < self.nBaud:
565 if self.__nHeis < self.nBaud:
566 print 'IOError: Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
566 print 'IOError: Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
567 raise IOError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
567 raise IOError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
568
568
569 #Frequency
569 #Frequency
570 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
570 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
571
571
572 __codeBuffer[:,0:self.nBaud] = self.code
572 __codeBuffer[:,0:self.nBaud] = self.code
573
573
574 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
574 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
575
575
576 if dataOut.flagDataAsBlock:
576 if dataOut.flagDataAsBlock:
577
577
578 self.ndatadec = self.__nHeis #- self.nBaud + 1
578 self.ndatadec = self.__nHeis #- self.nBaud + 1
579
579
580 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
580 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
581
581
582 else:
582 else:
583
583
584 #Time
584 #Time
585 self.ndatadec = self.__nHeis #- self.nBaud + 1
585 self.ndatadec = self.__nHeis #- self.nBaud + 1
586
586
587 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
587 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
588
588
589 def __convolutionInFreq(self, data):
589 def __convolutionInFreq(self, data):
590
590
591 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
591 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
592
592
593 fft_data = numpy.fft.fft(data, axis=1)
593 fft_data = numpy.fft.fft(data, axis=1)
594
594
595 conv = fft_data*fft_code
595 conv = fft_data*fft_code
596
596
597 data = numpy.fft.ifft(conv,axis=1)
597 data = numpy.fft.ifft(conv,axis=1)
598
598
599 return data
599 return data
600
600
601 def __convolutionInFreqOpt(self, data):
601 def __convolutionInFreqOpt(self, data):
602
602
603 raise NotImplementedError
603 raise NotImplementedError
604
604
605 # fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
605 # fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
606 #
606 #
607 # data = cfunctions.decoder(fft_code, data)
607 # data = cfunctions.decoder(fft_code, data)
608 #
608 #
609 # datadec = data#[:,:]
609 # datadec = data#[:,:]
610 #
610 #
611 # return datadec
611 # return datadec
612
612
613 def __convolutionInTime(self, data):
613 def __convolutionInTime(self, data):
614
614
615 code = self.code[self.__profIndex]
615 code = self.code[self.__profIndex]
616
616
617 for i in range(self.__nChannels):
617 for i in range(self.__nChannels):
618 self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:]
618 self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:]
619
619
620 return self.datadecTime
620 return self.datadecTime
621
621
622 def __convolutionByBlockInTime(self, data):
622 def __convolutionByBlockInTime(self, data):
623
623
624 repetitions = self.__nProfiles / self.nCode
624 repetitions = self.__nProfiles / self.nCode
625
625
626 junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize))
626 junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize))
627 junk = junk.flatten()
627 junk = junk.flatten()
628 code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud))
628 code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud))
629
629
630 for i in range(self.__nChannels):
630 for i in range(self.__nChannels):
631 for j in range(self.__nProfiles):
631 for j in range(self.__nProfiles):
632 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:]
632 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:]
633
633
634 return self.datadecTime
634 return self.datadecTime
635
635
636 def __convolutionByBlockInFreq(self, data):
636 def __convolutionByBlockInFreq(self, data):
637
637
638 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
638 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
639
639
640 fft_data = numpy.fft.fft(data, axis=2)
640 fft_data = numpy.fft.fft(data, axis=2)
641
641
642 conv = fft_data*fft_code
642 conv = fft_data*fft_code
643
643
644 data = numpy.fft.ifft(conv,axis=2)
644 data = numpy.fft.ifft(conv,axis=2)
645
645
646 return data
646 return data
647
647
648 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
648 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
649
649
650 dataOut.flagNoData = True
651
650 if dataOut.flagDecodeData:
652 if dataOut.flagDecodeData:
651 print "This data is already decoded, recoding again ..."
653 print "This data is already decoded, recoding again ..."
652
654
653 if not self.isConfig:
655 if not self.isConfig:
654
656
655 if code is None:
657 if code is None:
658 if not dataOut.code:
659 print "Code is not defined"
660 raise ValueError, "Code could not be read from %s object. Enter a value in Code parameter" %dataOut.type
661
656 code = dataOut.code
662 code = dataOut.code
657 else:
663 else:
658 code = numpy.array(code).reshape(nCode,nBaud)
664 code = numpy.array(code).reshape(nCode,nBaud)
659
665
660 self.setup(code, osamp, dataOut)
666 self.setup(code, osamp, dataOut)
661
667
662 self.isConfig = True
668 self.isConfig = True
663
669
664 if self.code is None:
670 if self.code is None:
665 print "Fail decoding: Code is not defined."
671 print "Fail decoding: Code is not defined."
666 return
672 return
667
673
668 datadec = None
674 datadec = None
669
675
670 if dataOut.flagDataAsBlock:
676 if dataOut.flagDataAsBlock:
671 """
677 """
672 Decoding when data have been read as block,
678 Decoding when data have been read as block,
673 """
679 """
674 if mode == 0:
680 if mode == 0:
675 datadec = self.__convolutionByBlockInTime(dataOut.data)
681 datadec = self.__convolutionByBlockInTime(dataOut.data)
676 if mode == 1:
682 if mode == 1:
677 datadec = self.__convolutionByBlockInFreq(dataOut.data)
683 datadec = self.__convolutionByBlockInFreq(dataOut.data)
678 else:
684 else:
679 """
685 """
680 Decoding when data have been read profile by profile
686 Decoding when data have been read profile by profile
681 """
687 """
682 if mode == 0:
688 if mode == 0:
683 datadec = self.__convolutionInTime(dataOut.data)
689 datadec = self.__convolutionInTime(dataOut.data)
684
690
685 if mode == 1:
691 if mode == 1:
686 datadec = self.__convolutionInFreq(dataOut.data)
692 datadec = self.__convolutionInFreq(dataOut.data)
687
693
688 if mode == 2:
694 if mode == 2:
689 datadec = self.__convolutionInFreqOpt(dataOut.data)
695 datadec = self.__convolutionInFreqOpt(dataOut.data)
690
696
691 if datadec is None:
697 if datadec is None:
692 raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode
698 raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode
693
699
694 dataOut.code = self.code
700 dataOut.code = self.code
695 dataOut.nCode = self.nCode
701 dataOut.nCode = self.nCode
696 dataOut.nBaud = self.nBaud
702 dataOut.nBaud = self.nBaud
697
703
698 dataOut.data = datadec
704 dataOut.data = datadec
699
705
700 dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]]
706 dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]]
701
707
702 dataOut.flagDecodeData = True #asumo q la data esta decodificada
708 dataOut.flagDecodeData = True #asumo q la data esta decodificada
703
709
704 if self.__profIndex == self.nCode-1:
710 if self.__profIndex == self.nCode-1:
705 self.__profIndex = 0
711 self.__profIndex = 0
706 return 1
712 return 1
707
713
708 self.__profIndex += 1
714 self.__profIndex += 1
709
715
716 dataOut.flagNoData = False
717
710 return 1
718 return 1
711 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
719 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
712
720
713
721
714 class ProfileConcat(Operation):
722 class ProfileConcat(Operation):
715
723
716 isConfig = False
724 isConfig = False
717 buffer = None
725 buffer = None
718
726
719 def __init__(self):
727 def __init__(self):
720
728
721 Operation.__init__(self)
729 Operation.__init__(self)
722 self.profileIndex = 0
730 self.profileIndex = 0
723
731
724 def reset(self):
732 def reset(self):
725 self.buffer = numpy.zeros_like(self.buffer)
733 self.buffer = numpy.zeros_like(self.buffer)
726 self.start_index = 0
734 self.start_index = 0
727 self.times = 1
735 self.times = 1
728
736
729 def setup(self, data, m, n=1):
737 def setup(self, data, m, n=1):
730 self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0]))
738 self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0]))
731 self.nHeights = data.nHeights
739 self.nHeights = data.nHeights
732 self.start_index = 0
740 self.start_index = 0
733 self.times = 1
741 self.times = 1
734
742
735 def concat(self, data):
743 def concat(self, data):
736
744
737 self.buffer[:,self.start_index:self.profiles*self.times] = data.copy()
745 self.buffer[:,self.start_index:self.profiles*self.times] = data.copy()
738 self.start_index = self.start_index + self.nHeights
746 self.start_index = self.start_index + self.nHeights
739
747
740 def run(self, dataOut, m):
748 def run(self, dataOut, m):
741
749
742 dataOut.flagNoData = True
750 dataOut.flagNoData = True
743
751
744 if not self.isConfig:
752 if not self.isConfig:
745 self.setup(dataOut.data, m, 1)
753 self.setup(dataOut.data, m, 1)
746 self.isConfig = True
754 self.isConfig = True
747
755
748 if dataOut.flagDataAsBlock:
756 if dataOut.flagDataAsBlock:
749
757
750 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
758 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
751
759
752 else:
760 else:
753 self.concat(dataOut.data)
761 self.concat(dataOut.data)
754 self.times += 1
762 self.times += 1
755 if self.times > m:
763 if self.times > m:
756 dataOut.data = self.buffer
764 dataOut.data = self.buffer
757 self.reset()
765 self.reset()
758 dataOut.flagNoData = False
766 dataOut.flagNoData = False
759 # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas
767 # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas
760 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
768 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
761 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
769 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
762 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
770 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
763 dataOut.ippSeconds *= m
771 dataOut.ippSeconds *= m
764
772
765 class ProfileSelector(Operation):
773 class ProfileSelector(Operation):
766
774
767 profileIndex = None
775 profileIndex = None
768 # Tamanho total de los perfiles
776 # Tamanho total de los perfiles
769 nProfiles = None
777 nProfiles = None
770
778
771 def __init__(self):
779 def __init__(self):
772
780
773 Operation.__init__(self)
781 Operation.__init__(self)
774 self.profileIndex = 0
782 self.profileIndex = 0
775
783
776 def incIndex(self):
784 def incIndex(self):
777
785
778 self.profileIndex += 1
786 self.profileIndex += 1
779
787
780 if self.profileIndex >= self.nProfiles:
788 if self.profileIndex >= self.nProfiles:
781 self.profileIndex = 0
789 self.profileIndex = 0
782
790
783 def isThisProfileInRange(self, profileIndex, minIndex, maxIndex):
791 def isThisProfileInRange(self, profileIndex, minIndex, maxIndex):
784
792
785 if profileIndex < minIndex:
793 if profileIndex < minIndex:
786 return False
794 return False
787
795
788 if profileIndex > maxIndex:
796 if profileIndex > maxIndex:
789 return False
797 return False
790
798
791 return True
799 return True
792
800
793 def isThisProfileInList(self, profileIndex, profileList):
801 def isThisProfileInList(self, profileIndex, profileList):
794
802
795 if profileIndex not in profileList:
803 if profileIndex not in profileList:
796 return False
804 return False
797
805
798 return True
806 return True
799
807
800 def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None):
808 def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None):
801
809
802 """
810 """
803 ProfileSelector:
811 ProfileSelector:
804
812
805 Inputs:
813 Inputs:
806 profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8)
814 profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8)
807
815
808 profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30)
816 profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30)
809
817
810 rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256))
818 rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256))
811
819
812 """
820 """
813
821
814 dataOut.flagNoData = True
822 dataOut.flagNoData = True
815
823
816 if dataOut.flagDataAsBlock:
824 if dataOut.flagDataAsBlock:
817 """
825 """
818 data dimension = [nChannels, nProfiles, nHeis]
826 data dimension = [nChannels, nProfiles, nHeis]
819 """
827 """
820 if profileList != None:
828 if profileList != None:
821 dataOut.data = dataOut.data[:,profileList,:]
829 dataOut.data = dataOut.data[:,profileList,:]
822 dataOut.nProfiles = len(profileList)
830 dataOut.nProfiles = len(profileList)
823 dataOut.profileIndex = dataOut.nProfiles - 1
831 dataOut.profileIndex = dataOut.nProfiles - 1
824
832
825 if profileRangeList != None:
833 if profileRangeList != None:
826 minIndex = profileRangeList[0]
834 minIndex = profileRangeList[0]
827 maxIndex = profileRangeList[1]
835 maxIndex = profileRangeList[1]
828
836
829 dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:]
837 dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:]
830 dataOut.nProfiles = maxIndex - minIndex + 1
838 dataOut.nProfiles = maxIndex - minIndex + 1
831 dataOut.profileIndex = dataOut.nProfiles - 1
839 dataOut.profileIndex = dataOut.nProfiles - 1
832
840
833 if rangeList != None:
841 if rangeList != None:
834 raise ValueError, "Profile Selector: Invalid argument rangeList. Not implemented for getByBlock yet"
842 raise ValueError, "Profile Selector: Invalid argument rangeList. Not implemented for getByBlock yet"
835
843
836 dataOut.flagNoData = False
844 dataOut.flagNoData = False
837
845
838 return True
846 return True
839
847
840 """
848 """
841 data dimension = [nChannels, nHeis]
849 data dimension = [nChannels, nHeis]
842 """
850 """
843
851
844 if nProfiles:
852 if nProfiles:
845 self.nProfiles = nProfiles
853 self.nProfiles = nProfiles
846 else:
854 else:
847 self.nProfiles = dataOut.nProfiles
855 self.nProfiles = dataOut.nProfiles
848
856
849 if profileList != None:
857 if profileList != None:
850
858
851 dataOut.nProfiles = len(profileList)
859 dataOut.nProfiles = len(profileList)
852
860
853 if self.isThisProfileInList(dataOut.profileIndex, profileList):
861 if self.isThisProfileInList(dataOut.profileIndex, profileList):
854 dataOut.flagNoData = False
862 dataOut.flagNoData = False
855 dataOut.profileIndex = self.profileIndex
863 dataOut.profileIndex = self.profileIndex
856
864
857 self.incIndex()
865 self.incIndex()
858 return True
866 return True
859
867
860 if profileRangeList != None:
868 if profileRangeList != None:
861
869
862 minIndex = profileRangeList[0]
870 minIndex = profileRangeList[0]
863 maxIndex = profileRangeList[1]
871 maxIndex = profileRangeList[1]
864
872
865 dataOut.nProfiles = maxIndex - minIndex + 1
873 dataOut.nProfiles = maxIndex - minIndex + 1
866
874
867 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
875 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
868 dataOut.flagNoData = False
876 dataOut.flagNoData = False
869 dataOut.profileIndex = self.profileIndex
877 dataOut.profileIndex = self.profileIndex
870
878
871 self.incIndex()
879 self.incIndex()
872 return True
880 return True
873
881
874 if rangeList != None:
882 if rangeList != None:
875
883
876 nProfiles = 0
884 nProfiles = 0
877
885
878 for thisRange in rangeList:
886 for thisRange in rangeList:
879 minIndex = thisRange[0]
887 minIndex = thisRange[0]
880 maxIndex = thisRange[1]
888 maxIndex = thisRange[1]
881
889
882 nProfiles += maxIndex - minIndex + 1
890 nProfiles += maxIndex - minIndex + 1
883
891
884 dataOut.nProfiles = nProfiles
892 dataOut.nProfiles = nProfiles
885
893
886 for thisRange in rangeList:
894 for thisRange in rangeList:
887
895
888 minIndex = thisRange[0]
896 minIndex = thisRange[0]
889 maxIndex = thisRange[1]
897 maxIndex = thisRange[1]
890
898
891 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
899 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
892
900
893 # print "profileIndex = ", dataOut.profileIndex
901 # print "profileIndex = ", dataOut.profileIndex
894
902
895 dataOut.flagNoData = False
903 dataOut.flagNoData = False
896 dataOut.profileIndex = self.profileIndex
904 dataOut.profileIndex = self.profileIndex
897
905
898 self.incIndex()
906 self.incIndex()
899 break
907 break
900 return True
908 return True
901
909
902
910
903 if beam != None: #beam is only for AMISR data
911 if beam != None: #beam is only for AMISR data
904 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
912 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
905 dataOut.flagNoData = False
913 dataOut.flagNoData = False
906 dataOut.profileIndex = self.profileIndex
914 dataOut.profileIndex = self.profileIndex
907
915
908 self.incIndex()
916 self.incIndex()
909
917
910 return True
918 return True
911
919
912 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
920 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
913
921
914 return False
922 return False
915
923
916
924
917
925
918 class Reshaper(Operation):
926 class Reshaper(Operation):
919
927
920 def __init__(self):
928 def __init__(self):
921
929
922 Operation.__init__(self)
930 Operation.__init__(self)
923 self.updateNewHeights = True
931 self.updateNewHeights = True
924
932
925 def run(self, dataOut, shape):
933 def run(self, dataOut, shape):
926
934
927 if not dataOut.flagDataAsBlock:
935 if not dataOut.flagDataAsBlock:
928 raise ValueError, "Reshaper can only be used when voltage have been read as Block, getBlock = True"
936 raise ValueError, "Reshaper can only be used when voltage have been read as Block, getBlock = True"
929
937
930 if len(shape) != 3:
938 if len(shape) != 3:
931 raise ValueError, "shape len should be equal to 3, (nChannels, nProfiles, nHeis)"
939 raise ValueError, "shape len should be equal to 3, (nChannels, nProfiles, nHeis)"
932
940
933 shape_tuple = tuple(shape)
941 shape_tuple = tuple(shape)
934 dataOut.data = numpy.reshape(dataOut.data, shape_tuple)
942 dataOut.data = numpy.reshape(dataOut.data, shape_tuple)
935 dataOut.flagNoData = False
943 dataOut.flagNoData = False
936
944
937 if self.updateNewHeights:
945 if self.updateNewHeights:
938
946
939 old_nheights = dataOut.nHeights
947 old_nheights = dataOut.nHeights
940 new_nheights = dataOut.data.shape[2]
948 new_nheights = dataOut.data.shape[2]
941 factor = 1.0*new_nheights / old_nheights
949 factor = 1.0*new_nheights / old_nheights
942
950
943 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
951 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
944
952
945 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * factor
953 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * factor
946
954
947 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
955 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
948
956
949 dataOut.nProfiles = dataOut.data.shape[1]
957 dataOut.nProfiles = dataOut.data.shape[1]
950
958
951 dataOut.ippSeconds *= factor
959 dataOut.ippSeconds *= factor
952 #
960 #
953 # import collections
961 # import collections
954 # from scipy.stats import mode
962 # from scipy.stats import mode
955 #
963 #
956 # class Synchronize(Operation):
964 # class Synchronize(Operation):
957 #
965 #
958 # isConfig = False
966 # isConfig = False
959 # __profIndex = 0
967 # __profIndex = 0
960 #
968 #
961 # def __init__(self):
969 # def __init__(self):
962 #
970 #
963 # Operation.__init__(self)
971 # Operation.__init__(self)
964 # # self.isConfig = False
972 # # self.isConfig = False
965 # self.__powBuffer = None
973 # self.__powBuffer = None
966 # self.__startIndex = 0
974 # self.__startIndex = 0
967 # self.__pulseFound = False
975 # self.__pulseFound = False
968 #
976 #
969 # def __findTxPulse(self, dataOut, channel=0, pulse_with = None):
977 # def __findTxPulse(self, dataOut, channel=0, pulse_with = None):
970 #
978 #
971 # #Read data
979 # #Read data
972 #
980 #
973 # powerdB = dataOut.getPower(channel = channel)
981 # powerdB = dataOut.getPower(channel = channel)
974 # noisedB = dataOut.getNoise(channel = channel)[0]
982 # noisedB = dataOut.getNoise(channel = channel)[0]
975 #
983 #
976 # self.__powBuffer.extend(powerdB.flatten())
984 # self.__powBuffer.extend(powerdB.flatten())
977 #
985 #
978 # dataArray = numpy.array(self.__powBuffer)
986 # dataArray = numpy.array(self.__powBuffer)
979 #
987 #
980 # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same")
988 # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same")
981 #
989 #
982 # maxValue = numpy.nanmax(filteredPower)
990 # maxValue = numpy.nanmax(filteredPower)
983 #
991 #
984 # if maxValue < noisedB + 10:
992 # if maxValue < noisedB + 10:
985 # #No se encuentra ningun pulso de transmision
993 # #No se encuentra ningun pulso de transmision
986 # return None
994 # return None
987 #
995 #
988 # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0]
996 # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0]
989 #
997 #
990 # if len(maxValuesIndex) < 2:
998 # if len(maxValuesIndex) < 2:
991 # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX
999 # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX
992 # return None
1000 # return None
993 #
1001 #
994 # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples
1002 # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples
995 #
1003 #
996 # #Seleccionar solo valores con un espaciamiento de nSamples
1004 # #Seleccionar solo valores con un espaciamiento de nSamples
997 # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex)
1005 # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex)
998 #
1006 #
999 # if len(pulseIndex) < 2:
1007 # if len(pulseIndex) < 2:
1000 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1008 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1001 # return None
1009 # return None
1002 #
1010 #
1003 # spacing = pulseIndex[1:] - pulseIndex[:-1]
1011 # spacing = pulseIndex[1:] - pulseIndex[:-1]
1004 #
1012 #
1005 # #remover senales que se distancien menos de 10 unidades o muestras
1013 # #remover senales que se distancien menos de 10 unidades o muestras
1006 # #(No deberian existir IPP menor a 10 unidades)
1014 # #(No deberian existir IPP menor a 10 unidades)
1007 #
1015 #
1008 # realIndex = numpy.where(spacing > 10 )[0]
1016 # realIndex = numpy.where(spacing > 10 )[0]
1009 #
1017 #
1010 # if len(realIndex) < 2:
1018 # if len(realIndex) < 2:
1011 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1019 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1012 # return None
1020 # return None
1013 #
1021 #
1014 # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs)
1022 # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs)
1015 # realPulseIndex = pulseIndex[realIndex]
1023 # realPulseIndex = pulseIndex[realIndex]
1016 #
1024 #
1017 # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0]
1025 # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0]
1018 #
1026 #
1019 # print "IPP = %d samples" %period
1027 # print "IPP = %d samples" %period
1020 #
1028 #
1021 # self.__newNSamples = dataOut.nHeights #int(period)
1029 # self.__newNSamples = dataOut.nHeights #int(period)
1022 # self.__startIndex = int(realPulseIndex[0])
1030 # self.__startIndex = int(realPulseIndex[0])
1023 #
1031 #
1024 # return 1
1032 # return 1
1025 #
1033 #
1026 #
1034 #
1027 # def setup(self, nSamples, nChannels, buffer_size = 4):
1035 # def setup(self, nSamples, nChannels, buffer_size = 4):
1028 #
1036 #
1029 # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float),
1037 # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float),
1030 # maxlen = buffer_size*nSamples)
1038 # maxlen = buffer_size*nSamples)
1031 #
1039 #
1032 # bufferList = []
1040 # bufferList = []
1033 #
1041 #
1034 # for i in range(nChannels):
1042 # for i in range(nChannels):
1035 # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN,
1043 # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN,
1036 # maxlen = buffer_size*nSamples)
1044 # maxlen = buffer_size*nSamples)
1037 #
1045 #
1038 # bufferList.append(bufferByChannel)
1046 # bufferList.append(bufferByChannel)
1039 #
1047 #
1040 # self.__nSamples = nSamples
1048 # self.__nSamples = nSamples
1041 # self.__nChannels = nChannels
1049 # self.__nChannels = nChannels
1042 # self.__bufferList = bufferList
1050 # self.__bufferList = bufferList
1043 #
1051 #
1044 # def run(self, dataOut, channel = 0):
1052 # def run(self, dataOut, channel = 0):
1045 #
1053 #
1046 # if not self.isConfig:
1054 # if not self.isConfig:
1047 # nSamples = dataOut.nHeights
1055 # nSamples = dataOut.nHeights
1048 # nChannels = dataOut.nChannels
1056 # nChannels = dataOut.nChannels
1049 # self.setup(nSamples, nChannels)
1057 # self.setup(nSamples, nChannels)
1050 # self.isConfig = True
1058 # self.isConfig = True
1051 #
1059 #
1052 # #Append new data to internal buffer
1060 # #Append new data to internal buffer
1053 # for thisChannel in range(self.__nChannels):
1061 # for thisChannel in range(self.__nChannels):
1054 # bufferByChannel = self.__bufferList[thisChannel]
1062 # bufferByChannel = self.__bufferList[thisChannel]
1055 # bufferByChannel.extend(dataOut.data[thisChannel])
1063 # bufferByChannel.extend(dataOut.data[thisChannel])
1056 #
1064 #
1057 # if self.__pulseFound:
1065 # if self.__pulseFound:
1058 # self.__startIndex -= self.__nSamples
1066 # self.__startIndex -= self.__nSamples
1059 #
1067 #
1060 # #Finding Tx Pulse
1068 # #Finding Tx Pulse
1061 # if not self.__pulseFound:
1069 # if not self.__pulseFound:
1062 # indexFound = self.__findTxPulse(dataOut, channel)
1070 # indexFound = self.__findTxPulse(dataOut, channel)
1063 #
1071 #
1064 # if indexFound == None:
1072 # if indexFound == None:
1065 # dataOut.flagNoData = True
1073 # dataOut.flagNoData = True
1066 # return
1074 # return
1067 #
1075 #
1068 # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex)
1076 # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex)
1069 # self.__pulseFound = True
1077 # self.__pulseFound = True
1070 # self.__startIndex = indexFound
1078 # self.__startIndex = indexFound
1071 #
1079 #
1072 # #If pulse was found ...
1080 # #If pulse was found ...
1073 # for thisChannel in range(self.__nChannels):
1081 # for thisChannel in range(self.__nChannels):
1074 # bufferByChannel = self.__bufferList[thisChannel]
1082 # bufferByChannel = self.__bufferList[thisChannel]
1075 # #print self.__startIndex
1083 # #print self.__startIndex
1076 # x = numpy.array(bufferByChannel)
1084 # x = numpy.array(bufferByChannel)
1077 # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples]
1085 # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples]
1078 #
1086 #
1079 # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1087 # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1080 # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight
1088 # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight
1081 # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6
1089 # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6
1082 #
1090 #
1083 # dataOut.data = self.__arrayBuffer
1091 # dataOut.data = self.__arrayBuffer
1084 #
1092 #
1085 # self.__startIndex += self.__newNSamples
1093 # self.__startIndex += self.__newNSamples
1086 #
1094 #
1087 # return No newline at end of file
1095 # return
@@ -1,38 +1,38
1 '''
1 '''
2 Created on Jul 16, 2014
2 Created on Jul 16, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 from schainpy import __version__
7 from schainpy import __version__
8 from setuptools import setup, Extension
8 from setuptools import setup, Extension
9
9
10 setup(name="schainpy",
10 setup(name="schainpy",
11 version=__version__,
11 version=__version__,
12 description="Python tools to read, write and process Jicamarca data",
12 description="Python tools to read, write and process Jicamarca data",
13 author="Miguel Urco",
13 author="Miguel Urco",
14 author_email="miguel.urco@jro.igp.gob.pe",
14 author_email="miguel.urco@jro.igp.gob.pe",
15 url="http://jro.igp.gob.pe",
15 url="http://jro.igp.gob.pe",
16 packages = {'schainpy',
16 packages = {'schainpy',
17 'schainpy.model',
17 'schainpy.model',
18 'schainpy.model.data',
18 'schainpy.model.data',
19 'schainpy.model.graphics',
19 'schainpy.model.graphics',
20 'schainpy.model.io',
20 'schainpy.model.io',
21 'schainpy.model.proc',
21 'schainpy.model.proc',
22 'schainpy.model.utils',
22 'schainpy.model.utils',
23 'schainpy.gui',
23 'schainpy.gui',
24 'schainpy.gui.figures',
24 'schainpy.gui.figures',
25 'schainpy.gui.viewcontroller',
25 'schainpy.gui.viewcontroller',
26 'schainpy.gui.viewer',
26 'schainpy.gui.viewer',
27 'schainpy.gui.viewer.windows'},
27 'schainpy.gui.viewer.windows'},
28 py_modules=['schainpy.serializer.DataTranslate',
28 py_modules=['schainpy.serializer.DataTranslate',
29 'schainpy.serializer.JROSerializer'],
29 'schainpy.serializer.JROSerializer'],
30 package_data={'schainpy.gui.figures': ['*.jpg', '*.jpeg', '*.png', '*.gif']},
30 package_data={'schainpy.gui.figures': ['*.png']},
31 include_package_data=True,
31 include_package_data=True,
32 scripts =['schainpy/gui/schainGUI'],
32 scripts =['schainpy/gui/schainGUI'],
33 install_requires=["numpy >= 1.6.0",
33 install_requires=["numpy >= 1.6.0",
34 "scipy >= 0.11.0",
34 "scipy >= 0.9.0",
35 "h5py >= 2.0.1",
35 "h5py >= 2.0.1",
36 "matplotlib >= 1.0.0"
36 "matplotlib >= 1.0.0"
37 ],
37 ],
38 ) No newline at end of file
38 )
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now