@@ -0,0 +1,95 | |||||
|
1 | import os, sys | |||
|
2 | ||||
|
3 | path = os.path.split(os.getcwd())[0] | |||
|
4 | sys.path.append(path) | |||
|
5 | ||||
|
6 | from controller import * | |||
|
7 | ||||
|
8 | desc = "EWDrifts Experiment Test" | |||
|
9 | filename = "ewdrifts.xml" | |||
|
10 | ||||
|
11 | controllerObj = Project() | |||
|
12 | ||||
|
13 | controllerObj.setup(id = '191', name='test01', description=desc) | |||
|
14 | ||||
|
15 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |||
|
16 | path='/Users/dsuarez/Remote/EW_DRIFTS_Sep2012', | |||
|
17 | startDate='2011/01/01', | |||
|
18 | endDate='2012/12/31', | |||
|
19 | startTime='00:00:00', | |||
|
20 | endTime='23:59:59', | |||
|
21 | online=0, | |||
|
22 | walk=0) | |||
|
23 | ||||
|
24 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |||
|
25 | ||||
|
26 | opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') | |||
|
27 | opObj11.addParameter(name='profileRangeList', value='0,127', format='intlist') | |||
|
28 | ||||
|
29 | opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') | |||
|
30 | opObj11.addParameter(name='window', value='3', format='int') | |||
|
31 | ||||
|
32 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |||
|
33 | ||||
|
34 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |||
|
35 | procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int') | |||
|
36 | procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(2,3)', format='pairslist') | |||
|
37 | ||||
|
38 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |||
|
39 | opObj11.addParameter(name='n', value='10', format='float') | |||
|
40 | #opObj11.addParameter(name='timeInterval', value='0.33', format='float') | |||
|
41 | ||||
|
42 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |||
|
43 | opObj11.addParameter(name='idfigure', value='1', format='int') | |||
|
44 | opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |||
|
45 | #opObj11.addParameter(name='channelList', value='0,6', format='intlist') | |||
|
46 | opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
47 | opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
48 | opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
49 | ||||
|
50 | ||||
|
51 | #opObj11 = procUnitConfObj1.addOperation(name='RTIfromNoise', optype='other') | |||
|
52 | #opObj11.addParameter(name='idfigure', value='2', format='int') | |||
|
53 | #opObj11.addParameter(name='timerange', value='10', format='int') | |||
|
54 | #opObj11.addParameter(name='ymin', value='20', format='int') | |||
|
55 | #opObj11.addParameter(name='ymax', value='120', format='int') | |||
|
56 | ||||
|
57 | opObj11 = procUnitConfObj1.addOperation(name='ProfilePlot', optype='other') | |||
|
58 | opObj11.addParameter(name='idfigure', value='2', format='int') | |||
|
59 | #opObj11.addParameter(name='wintitle', value='Prof', format='str') | |||
|
60 | opObj11.addParameter(name='xmin', value='30', format='int') | |||
|
61 | opObj11.addParameter(name='xmax', value='120', format='int') | |||
|
62 | ||||
|
63 | opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') | |||
|
64 | opObj11.addParameter(name='idfigure', value='3', format='int') | |||
|
65 | opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |||
|
66 | opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
67 | opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
68 | #opObj11.addParameter(name='pairsList', value='(0,2)', format='pairslist') | |||
|
69 | ||||
|
70 | opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |||
|
71 | opObj11.addParameter(name='idfigure', value='4', format='int') | |||
|
72 | opObj11.addParameter(name='wintitle', value='RTIPLot', format='str') | |||
|
73 | opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
74 | opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
75 | opObj11.addParameter(name='timerange', value='3600', format='int') | |||
|
76 | opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
77 | opObj11.addParameter(name='save', value='1', format='bool') | |||
|
78 | opObj11.addParameter(name='figpath', value='/Users/dsuarez/Pictures', format='str') | |||
|
79 | ||||
|
80 | opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other') | |||
|
81 | opObj11.addParameter(name='idfigure', value='5', format='int') | |||
|
82 | #opObj11.addParameter(name='pairsList', value='(0,2)', format='pairslist') | |||
|
83 | opObj11.addParameter(name='timerange', value='300', format='int') | |||
|
84 | opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
85 | ||||
|
86 | print "Escribiendo el archivo XML" | |||
|
87 | controllerObj.writeXml(filename) | |||
|
88 | print "Leyendo el archivo XML" | |||
|
89 | controllerObj.readXml(filename) | |||
|
90 | ||||
|
91 | controllerObj.createObjects() | |||
|
92 | controllerObj.connectObjects() | |||
|
93 | controllerObj.run() | |||
|
94 | ||||
|
95 | No newline at end of file |
@@ -0,0 +1,62 | |||||
|
1 | import os, sys | |||
|
2 | ||||
|
3 | path = os.path.split(os.getcwd())[0] | |||
|
4 | sys.path.append(path) | |||
|
5 | ||||
|
6 | from controller import * | |||
|
7 | ||||
|
8 | desc = "Faraday Experiment Test" | |||
|
9 | filename = "faraday.xml" | |||
|
10 | ||||
|
11 | controllerObj = Project() | |||
|
12 | ||||
|
13 | controllerObj.setup(id = '191', name='test01', description=desc) | |||
|
14 | ||||
|
15 | path = '' | |||
|
16 | ||||
|
17 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |||
|
18 | path=path, | |||
|
19 | startDate='2011/01/01', | |||
|
20 | endDate='2012/12/31', | |||
|
21 | startTime='00:00:00', | |||
|
22 | endTime='23:59:59', | |||
|
23 | online=0, | |||
|
24 | walk=0) | |||
|
25 | ||||
|
26 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |||
|
27 | ||||
|
28 | opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') | |||
|
29 | opObj11.addParameter(name='profileRangeList', value='0,127', format='intlist') | |||
|
30 | ||||
|
31 | opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') | |||
|
32 | opObj11.addParameter(name='window', value='3', format='int') | |||
|
33 | ||||
|
34 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |||
|
35 | ||||
|
36 | opObj11 = procUnitConfObj0.addOperation(name='deFlip') | |||
|
37 | ||||
|
38 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |||
|
39 | procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int') | |||
|
40 | procUnitConfObj1.addParameter(name='pairsList', value='(0,1)', format='pairslist') | |||
|
41 | ||||
|
42 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |||
|
43 | opObj11.addParameter(name='n', value='10', format='float') | |||
|
44 | #opObj11.addParameter(name='timeInterval', value='0.33', format='float') | |||
|
45 | ||||
|
46 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |||
|
47 | opObj11.addParameter(name='idfigure', value='1', format='int') | |||
|
48 | opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |||
|
49 | opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
50 | opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
51 | opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
52 | ||||
|
53 | ||||
|
54 | print "Escribiendo el archivo XML" | |||
|
55 | controllerObj.writeXml(filename) | |||
|
56 | print "Leyendo el archivo XML" | |||
|
57 | controllerObj.readXml(filename) | |||
|
58 | ||||
|
59 | controllerObj.createObjects() | |||
|
60 | controllerObj.connectObjects() | |||
|
61 | controllerObj.run() | |||
|
62 |
@@ -0,0 +1,83 | |||||
|
1 | import sys | |||
|
2 | ||||
|
3 | from controller import * | |||
|
4 | ||||
|
5 | desc = "Imaging Experiment Test" | |||
|
6 | filename = "imaging.xml" | |||
|
7 | ||||
|
8 | controllerObj = Project() | |||
|
9 | ||||
|
10 | controllerObj.setup(id = '191', name='test01', description=desc) | |||
|
11 | ||||
|
12 | readUnitConfObj = controllerObj.addReadUnit(datatype='Spectra', | |||
|
13 | path='/Users/dsuarez/Remote/IMAGING/D2012080', | |||
|
14 | startDate='2011/01/01', | |||
|
15 | endDate='2012/12/31', | |||
|
16 | startTime='00:00:00', | |||
|
17 | endTime='23:59:59', | |||
|
18 | online=0, | |||
|
19 | walk=0) | |||
|
20 | ||||
|
21 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) | |||
|
22 | ||||
|
23 | #opObj11 = procUnitConfObj0.addOperation(name='selectChannels') | |||
|
24 | #opObj11.addParameter(name='channelList', value='0,2,6', format='intlist') | |||
|
25 | ||||
|
26 | ||||
|
27 | ## | |||
|
28 | #procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |||
|
29 | #procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
30 | #procUnitConfObj1.addParameter(name='pairsList', value='(0,1)', format='pairslist') | |||
|
31 | ||||
|
32 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |||
|
33 | opObj11.addParameter(name='n', value='2', format='int') | |||
|
34 | ||||
|
35 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |||
|
36 | opObj11.addParameter(name='idfigure', value='1', format='int') | |||
|
37 | opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |||
|
38 | #opObj11.addParameter(name='channelList', value='0,6', format='intlist') | |||
|
39 | opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
40 | opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
41 | opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
42 | ||||
|
43 | opObj11 = procUnitConfObj1.addOperation(name='ProfilePlot', optype='other') | |||
|
44 | opObj11.addParameter(name='idfigure', value='2', format='int') | |||
|
45 | opObj11.addParameter(name='wintitle', value='O', format='str') | |||
|
46 | opObj11.addParameter(name='xmin', value='30', format='int') | |||
|
47 | opObj11.addParameter(name='xmax', value='120', format='int') | |||
|
48 | ||||
|
49 | ||||
|
50 | ||||
|
51 | #opObj11 = procUnitConfObj0.addOperation(name='CrossSpectraPlot', optype='other') | |||
|
52 | #opObj11.addParameter(name='idfigure', value='3', format='int') | |||
|
53 | #opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |||
|
54 | #opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
55 | #opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
56 | #opObj11.addParameter(name='pairsList', value='(0,2)', format='pairslist') | |||
|
57 | ||||
|
58 | #opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |||
|
59 | #opObj11.addParameter(name='idfigure', value='4', format='int') | |||
|
60 | #opObj11.addParameter(name='wintitle', value='RTIPLot', format='str') | |||
|
61 | #opObj11.addParameter(name='zmin', value='30', format='int') | |||
|
62 | #opObj11.addParameter(name='zmax', value='120', format='int') | |||
|
63 | #opObj11.addParameter(name='timerange', value='3600', format='int') | |||
|
64 | #opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
65 | #opObj11.addParameter(name='save', value='1', format='bool') | |||
|
66 | #opObj11.addParameter(name='figpath', value='/Users/dsuarez/Pictures', format='str') | |||
|
67 | ||||
|
68 | #opObj11 = procUnitConfObj0.addOperation(name='CoherencePlot', optype='other') | |||
|
69 | #opObj11.addParameter(name='idfigure', value='5', format='int') | |||
|
70 | #opObj11.addParameter(name='pairsList', value='(0,2)', format='pairslist') | |||
|
71 | #opObj11.addParameter(name='timerange', value='300', format='int') | |||
|
72 | #opObj11.addParameter(name='showprofile', value='1', format='int') | |||
|
73 | ||||
|
74 | print "Escribiendo el archivo XML" | |||
|
75 | controllerObj.writeXml(filename) | |||
|
76 | print "Leyendo el archivo XML" | |||
|
77 | controllerObj.readXml(filename) | |||
|
78 | ||||
|
79 | controllerObj.createObjects() | |||
|
80 | controllerObj.connectObjects() | |||
|
81 | controllerObj.run() | |||
|
82 | ||||
|
83 | No newline at end of file |
@@ -293,7 +293,35 class Axes: | |||||
293 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
293 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, | |
294 | ylabel=ylabel, |
|
294 | ylabel=ylabel, | |
295 | title=title) |
|
295 | title=title) | |
|
296 | ||||
|
297 | def pmultilineyaxis(self, x, y, | |||
|
298 | xmin=None, xmax=None, | |||
|
299 | ymin=None, ymax=None, | |||
|
300 | xlabel='', ylabel='', | |||
|
301 | title='', | |||
|
302 | **kwargs): | |||
296 |
|
303 | |||
|
304 | if self.__firsttime: | |||
|
305 | ||||
|
306 | if xmin == None: xmin = numpy.nanmin(x) | |||
|
307 | if xmax == None: xmax = numpy.nanmax(x) | |||
|
308 | if ymin == None: ymin = numpy.nanmin(y) | |||
|
309 | if ymax == None: ymax = numpy.nanmax(y) | |||
|
310 | ||||
|
311 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, | |||
|
312 | xmin, xmax, | |||
|
313 | ymin, ymax, | |||
|
314 | xlabel=xlabel, | |||
|
315 | ylabel=ylabel, | |||
|
316 | title=title, | |||
|
317 | **kwargs) | |||
|
318 | self.__firsttime = False | |||
|
319 | return | |||
|
320 | ||||
|
321 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, | |||
|
322 | ylabel=ylabel, | |||
|
323 | title=title) | |||
|
324 | ||||
297 | def pcolor(self, x, y, z, |
|
325 | def pcolor(self, x, y, z, | |
298 | xmin=None, xmax=None, |
|
326 | xmin=None, xmax=None, | |
299 | ymin=None, ymax=None, |
|
327 | ymin=None, ymax=None, |
@@ -151,7 +151,7 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', tit | |||||
151 | """ |
|
151 | """ | |
152 |
|
152 | |||
153 | lines = ax.plot(x.T, y) |
|
153 | lines = ax.plot(x.T, y) | |
154 |
leg = ax.legend(lines, legendlabels, loc='upper |
|
154 | leg = ax.legend(lines, legendlabels, loc='upper right') | |
155 | leg.get_frame().set_alpha(0.5) |
|
155 | leg.get_frame().set_alpha(0.5) | |
156 | ax.set_xlim([xmin,xmax]) |
|
156 | ax.set_xlim([xmin,xmax]) | |
157 | ax.set_ylim([ymin,ymax]) |
|
157 | ax.set_ylim([ymin,ymax]) | |
@@ -199,6 +199,73 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): | |||||
199 | for i in range(len(ax.lines)): |
|
199 | for i in range(len(ax.lines)): | |
200 | line = ax.lines[i] |
|
200 | line = ax.lines[i] | |
201 | line.set_data(x[i,:],y) |
|
201 | line.set_data(x[i,:],y) | |
|
202 | ||||
|
203 | def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, | |||
|
204 | ticksize=9, xtick_visible=True, ytick_visible=True, | |||
|
205 | nxticks=4, nyticks=10, marker='^', markersize=8, linestyle="solid", | |||
|
206 | grid=None, XAxisAsTime=False): | |||
|
207 | ||||
|
208 | """ | |||
|
209 | ||||
|
210 | Input: | |||
|
211 | grid : None, 'both', 'x', 'y' | |||
|
212 | """ | |||
|
213 | ||||
|
214 | lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle) | |||
|
215 | leg = ax.legend(lines, legendlabels, bbox_to_anchor=(1.05, 1), loc='upper right', numpoints=1, handlelength=1.5, \ | |||
|
216 | handletextpad=0.5, borderpad=0.2, labelspacing=0.2, borderaxespad=0.) | |||
|
217 | ||||
|
218 | ax.set_xlim([xmin,xmax]) | |||
|
219 | ax.set_ylim([ymin,ymax]) | |||
|
220 | printLabels(ax, xlabel, ylabel, title) | |||
|
221 | ||||
|
222 | # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) | |||
|
223 | # ax.set_xticks(xtickspos) | |||
|
224 | ||||
|
225 | for tick in ax.get_xticklabels(): | |||
|
226 | tick.set_visible(xtick_visible) | |||
|
227 | ||||
|
228 | for tick in ax.xaxis.get_major_ticks(): | |||
|
229 | tick.label.set_fontsize(ticksize) | |||
|
230 | ||||
|
231 | for tick in ax.get_yticklabels(): | |||
|
232 | tick.set_visible(ytick_visible) | |||
|
233 | ||||
|
234 | for tick in ax.yaxis.get_major_ticks(): | |||
|
235 | tick.label.set_fontsize(ticksize) | |||
|
236 | ||||
|
237 | iplot = ax.lines[-1] | |||
|
238 | ||||
|
239 | if '0.' in matplotlib.__version__[0:2]: | |||
|
240 | print "The matplotlib version has to be updated to 1.1 or newer" | |||
|
241 | return iplot | |||
|
242 | ||||
|
243 | if '1.0.' in matplotlib.__version__[0:4]: | |||
|
244 | print "The matplotlib version has to be updated to 1.1 or newer" | |||
|
245 | return iplot | |||
|
246 | ||||
|
247 | if grid != None: | |||
|
248 | ax.grid(b=True, which='major', axis=grid) | |||
|
249 | ||||
|
250 | matplotlib.pyplot.tight_layout() | |||
|
251 | ||||
|
252 | if XAxisAsTime: | |||
|
253 | ||||
|
254 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) | |||
|
255 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |||
|
256 | ax.xaxis.set_major_locator(LinearLocator(7)) | |||
|
257 | ||||
|
258 | return iplot | |||
|
259 | ||||
|
260 | def pmultilineinyaxis(iplot, x, y, xlabel='', ylabel='', title=''): | |||
|
261 | ||||
|
262 | ax = iplot.get_axes() | |||
|
263 | ||||
|
264 | printLabels(ax, xlabel, ylabel, title) | |||
|
265 | ||||
|
266 | for i in range(len(ax.lines)): | |||
|
267 | line = ax.lines[i] | |||
|
268 | line.set_data(x,y[i,:]) | |||
202 |
|
269 | |||
203 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, |
|
270 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, | |
204 | xlabel='', ylabel='', title='', ticksize = 9, |
|
271 | xlabel='', ylabel='', title='', ticksize = 9, |
@@ -841,24 +841,22 class RTIfromNoise(Figure): | |||||
841 |
|
841 | |||
842 | __isConfig = None |
|
842 | __isConfig = None | |
843 | __nsubplots = None |
|
843 | __nsubplots = None | |
844 |
|
844 | |||
845 | WIDTHPROF = None |
|
845 | PREFIX = 'rtinoise' | |
846 | HEIGHTPROF = None |
|
|||
847 | PREFIX = 'rti' |
|
|||
848 |
|
846 | |||
849 | def __init__(self): |
|
847 | def __init__(self): | |
850 |
|
848 | |||
851 |
self. |
|
849 | self.timerange = 24*60*60 | |
852 | self.__isConfig = False |
|
850 | self.__isConfig = False | |
853 | self.__nsubplots = 1 |
|
851 | self.__nsubplots = 1 | |
854 |
|
852 | |||
855 |
self.WIDTH = 8 |
|
853 | self.WIDTH = 820 | |
856 | self.HEIGHT = 200 |
|
854 | self.HEIGHT = 200 | |
857 |
|
855 | |||
858 | def getSubplots(self): |
|
856 | def getSubplots(self): | |
859 |
|
857 | |||
860 | ncol = 1 |
|
858 | ncol = 1 | |
861 |
nrow = |
|
859 | nrow = 1 | |
862 |
|
860 | |||
863 | return nrow, ncol |
|
861 | return nrow, ncol | |
864 |
|
862 | |||
@@ -872,50 +870,21 class RTIfromNoise(Figure): | |||||
872 |
|
870 | |||
873 | self.createFigure(idfigure = idfigure, |
|
871 | self.createFigure(idfigure = idfigure, | |
874 | wintitle = wintitle, |
|
872 | wintitle = wintitle, | |
875 |
widthplot = self.WIDTH |
|
873 | widthplot = self.WIDTH, | |
876 |
heightplot = self.HEIGHT |
|
874 | heightplot = self.HEIGHT) | |
877 |
|
875 | |||
878 | nrow, ncol = self.getSubplots() |
|
876 | nrow, ncol = self.getSubplots() | |
879 |
|
877 | |||
880 | self.addAxes(nrow, ncol, 0, 0, 1, 1) |
|
878 | self.addAxes(nrow, ncol, 0, 0, 1, 1) | |
881 |
|
879 | |||
882 |
|
||||
883 |
|
||||
884 | def __getTimeLim(self, x, xmin, xmax): |
|
|||
885 |
|
||||
886 | thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) |
|
|||
887 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
|||
888 |
|
||||
889 | #################################################### |
|
|||
890 | #If the x is out of xrange |
|
|||
891 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
|||
892 | xmin = None |
|
|||
893 | xmax = None |
|
|||
894 |
|
||||
895 | if xmin == None: |
|
|||
896 | td = thisdatetime - thisdate |
|
|||
897 | xmin = td.seconds/(60*60.) |
|
|||
898 |
|
||||
899 | if xmax == None: |
|
|||
900 | xmax = xmin + self.__timerange/(60*60.) |
|
|||
901 |
|
||||
902 | mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) |
|
|||
903 | tmin = time.mktime(mindt.timetuple()) |
|
|||
904 |
|
||||
905 | maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) |
|
|||
906 | tmax = time.mktime(maxdt.timetuple()) |
|
|||
907 |
|
||||
908 | self.__timerange = tmax - tmin |
|
|||
909 |
|
||||
910 | return tmin, tmax |
|
|||
911 |
|
||||
912 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
880 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
913 |
xmin=None, xmax=None, ymin=None, ymax=None, |
|
881 | xmin=None, xmax=None, ymin=None, ymax=None, | |
914 | timerange=None, |
|
882 | timerange=None, | |
915 | save=False, figpath='./', figfile=None): |
|
883 | save=False, figpath='./', figfile=None): | |
916 |
|
884 | |||
917 | if channelList == None: |
|
885 | if channelList == None: | |
918 | channelIndexList = dataOut.channelIndexList |
|
886 | channelIndexList = dataOut.channelIndexList | |
|
887 | channelList = dataOut.channelList | |||
919 | else: |
|
888 | else: | |
920 | channelIndexList = [] |
|
889 | channelIndexList = [] | |
921 | for channel in channelList: |
|
890 | for channel in channelList: | |
@@ -924,16 +893,13 class RTIfromNoise(Figure): | |||||
924 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
893 | channelIndexList.append(dataOut.channelList.index(channel)) | |
925 |
|
894 | |||
926 | if timerange != None: |
|
895 | if timerange != None: | |
927 |
self. |
|
896 | self.timerange = timerange | |
928 |
|
897 | |||
929 | tmin = None |
|
898 | tmin = None | |
930 | tmax = None |
|
899 | tmax = None | |
931 | x = dataOut.getTimeRange() |
|
900 | x = dataOut.getTimeRange() | |
932 | y = dataOut.getHeiRange() |
|
901 | y = dataOut.getHeiRange() | |
933 | x1 = dataOut.datatime |
|
902 | ||
934 | # z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
|||
935 | # avg = numpy.average(z, axis=1) |
|
|||
936 |
|
||||
937 | noise = dataOut.getNoise() |
|
903 | noise = dataOut.getNoise() | |
938 |
|
904 | |||
939 | thisDatetime = dataOut.datatime |
|
905 | thisDatetime = dataOut.datatime | |
@@ -941,43 +907,45 class RTIfromNoise(Figure): | |||||
941 | xlabel = "Velocity (m/s)" |
|
907 | xlabel = "Velocity (m/s)" | |
942 | ylabel = "Range (Km)" |
|
908 | ylabel = "Range (Km)" | |
943 |
|
909 | |||
944 |
|
||||
945 | if not self.__isConfig: |
|
910 | if not self.__isConfig: | |
946 |
|
911 | |||
947 |
nplots = |
|
912 | nplots = 1 | |
948 |
|
913 | |||
949 | self.setup(idfigure=idfigure, |
|
914 | self.setup(idfigure=idfigure, | |
950 | nplots=nplots, |
|
915 | nplots=nplots, | |
951 | wintitle=wintitle, |
|
916 | wintitle=wintitle, | |
952 | showprofile=showprofile) |
|
917 | showprofile=showprofile) | |
953 |
|
918 | |||
954 |
tmin, tmax = self. |
|
919 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
955 |
if ymin == None: ymin = numpy.nanmin( |
|
920 | if ymin == None: ymin = numpy.nanmin(noise) | |
956 |
if ymax == None: ymax = numpy.nanmax( |
|
921 | if ymax == None: ymax = numpy.nanmax(noise) | |
957 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
|||
958 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
|||
959 |
|
922 | |||
|
923 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |||
960 | self.__isConfig = True |
|
924 | self.__isConfig = True | |
961 |
|
|
925 | ||
962 |
|
926 | |||
963 | self.setWinTitle(title) |
|
927 | self.setWinTitle(title) | |
964 |
|
928 | |||
965 | for i in range(self.nplots): |
|
929 | ||
966 |
|
|
930 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
967 | axes = self.axesList[i*self.__nsubplots] |
|
931 | ||
968 | z = avg[i].reshape((1,-1)) |
|
932 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
969 | axes.pcolor(x, y, z, |
|
933 | axes = self.axesList[0] | |
970 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
934 | xdata = x[0:1] | |
971 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
935 | ydata = noise[channelIndexList].reshape(-1,1) | |
972 | ticksize=9, cblabel='', cbsize="1%") |
|
936 | axes.pmultilineyaxis(x=xdata, y=ydata, | |
973 |
|
937 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | ||
|
938 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |||
|
939 | XAxisAsTime=True | |||
|
940 | ) | |||
|
941 | ||||
974 |
|
942 | |||
975 | self.draw() |
|
943 | self.draw() | |
976 |
|
944 | |||
977 | if save: |
|
945 | if save: | |
978 | date = thisDatetime.strftime("%Y%m%d") |
|
946 | ||
979 | if figfile == None: |
|
947 | if figfile == None: | |
980 |
figfile = self.getFilename(name = |
|
948 | figfile = self.getFilename(name = self.name) | |
981 |
|
949 | |||
982 | self.saveFigure(figpath, figfile) |
|
950 | self.saveFigure(figpath, figfile) | |
983 |
|
951 |
General Comments 0
You need to be logged in to leave comments.
Login now