@@ -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 |
@@ -1,368 +1,396 | |||||
1 | import os |
|
1 | import os | |
2 | import numpy |
|
2 | import numpy | |
3 | import time, datetime |
|
3 | import time, datetime | |
4 | import mpldriver |
|
4 | import mpldriver | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | class Figure: |
|
7 | class Figure: | |
8 |
|
8 | |||
9 | __driver = mpldriver |
|
9 | __driver = mpldriver | |
10 | fig = None |
|
10 | fig = None | |
11 |
|
11 | |||
12 | idfigure = None |
|
12 | idfigure = None | |
13 | wintitle = None |
|
13 | wintitle = None | |
14 | width = None |
|
14 | width = None | |
15 | height = None |
|
15 | height = None | |
16 | nplots = None |
|
16 | nplots = None | |
17 | timerange = None |
|
17 | timerange = None | |
18 |
|
18 | |||
19 | axesObjList = [] |
|
19 | axesObjList = [] | |
20 |
|
20 | |||
21 | WIDTH = None |
|
21 | WIDTH = None | |
22 | HEIGHT = None |
|
22 | HEIGHT = None | |
23 | PREFIX = 'fig' |
|
23 | PREFIX = 'fig' | |
24 |
|
24 | |||
25 | def __init__(self): |
|
25 | def __init__(self): | |
26 |
|
26 | |||
27 | raise ValueError, "This method is not implemented" |
|
27 | raise ValueError, "This method is not implemented" | |
28 |
|
28 | |||
29 | def __del__(self): |
|
29 | def __del__(self): | |
30 |
|
30 | |||
31 | self.__driver.closeFigure() |
|
31 | self.__driver.closeFigure() | |
32 |
|
32 | |||
33 | def getFilename(self, name, ext='.png'): |
|
33 | def getFilename(self, name, ext='.png'): | |
34 |
|
34 | |||
35 | filename = '%s-%s_%s%s' %(self.wintitle[0:10], self.PREFIX, name, ext) |
|
35 | filename = '%s-%s_%s%s' %(self.wintitle[0:10], self.PREFIX, name, ext) | |
36 |
|
36 | |||
37 | return filename |
|
37 | return filename | |
38 |
|
38 | |||
39 | def getAxesObjList(self): |
|
39 | def getAxesObjList(self): | |
40 |
|
40 | |||
41 | return self.axesObjList |
|
41 | return self.axesObjList | |
42 |
|
42 | |||
43 | def getSubplots(self): |
|
43 | def getSubplots(self): | |
44 |
|
44 | |||
45 | raise ValueError, "Abstract method: This method should be defined" |
|
45 | raise ValueError, "Abstract method: This method should be defined" | |
46 |
|
46 | |||
47 | def getScreenDim(self, widthplot, heightplot): |
|
47 | def getScreenDim(self, widthplot, heightplot): | |
48 |
|
48 | |||
49 | nrow, ncol = self.getSubplots() |
|
49 | nrow, ncol = self.getSubplots() | |
50 |
|
50 | |||
51 | widthscreen = widthplot*ncol |
|
51 | widthscreen = widthplot*ncol | |
52 | heightscreen = heightplot*nrow |
|
52 | heightscreen = heightplot*nrow | |
53 |
|
53 | |||
54 | return widthscreen, heightscreen |
|
54 | return widthscreen, heightscreen | |
55 |
|
55 | |||
56 | def getTimeLim(self, x, xmin, xmax): |
|
56 | def getTimeLim(self, x, xmin, xmax): | |
57 |
|
57 | |||
58 | thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) |
|
58 | thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) | |
59 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
59 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) | |
60 |
|
60 | |||
61 | #################################################### |
|
61 | #################################################### | |
62 | #If the x is out of xrange |
|
62 | #If the x is out of xrange | |
63 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
63 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): | |
64 | xmin = None |
|
64 | xmin = None | |
65 | xmax = None |
|
65 | xmax = None | |
66 |
|
66 | |||
67 | if xmin == None: |
|
67 | if xmin == None: | |
68 | td = thisdatetime - thisdate |
|
68 | td = thisdatetime - thisdate | |
69 | xmin = td.seconds/(60*60.) |
|
69 | xmin = td.seconds/(60*60.) | |
70 |
|
70 | |||
71 | if xmax == None: |
|
71 | if xmax == None: | |
72 | xmax = xmin + self.timerange/(60*60.) |
|
72 | xmax = xmin + self.timerange/(60*60.) | |
73 |
|
73 | |||
74 | mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) |
|
74 | mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) | |
75 | tmin = time.mktime(mindt.timetuple()) |
|
75 | tmin = time.mktime(mindt.timetuple()) | |
76 |
|
76 | |||
77 | maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) |
|
77 | maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) | |
78 | tmax = time.mktime(maxdt.timetuple()) |
|
78 | tmax = time.mktime(maxdt.timetuple()) | |
79 |
|
79 | |||
80 | self.timerange = tmax - tmin |
|
80 | self.timerange = tmax - tmin | |
81 |
|
81 | |||
82 | return tmin, tmax |
|
82 | return tmin, tmax | |
83 |
|
83 | |||
84 | def init(self, idfigure, nplots, wintitle): |
|
84 | def init(self, idfigure, nplots, wintitle): | |
85 |
|
85 | |||
86 | raise ValueError, "This method has been replaced with createFigure" |
|
86 | raise ValueError, "This method has been replaced with createFigure" | |
87 |
|
87 | |||
88 | def createFigure(self, idfigure, wintitle, widthplot=None, heightplot=None): |
|
88 | def createFigure(self, idfigure, wintitle, widthplot=None, heightplot=None): | |
89 |
|
89 | |||
90 | """ |
|
90 | """ | |
91 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. |
|
91 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. | |
92 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH |
|
92 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH | |
93 | y self.HEIGHT y el numero de subplots (nrow, ncol) |
|
93 | y self.HEIGHT y el numero de subplots (nrow, ncol) | |
94 |
|
94 | |||
95 | Input: |
|
95 | Input: | |
96 | idfigure : Los parametros necesarios son |
|
96 | idfigure : Los parametros necesarios son | |
97 | wintitle : |
|
97 | wintitle : | |
98 |
|
98 | |||
99 | """ |
|
99 | """ | |
100 |
|
100 | |||
101 | if widthplot == None: |
|
101 | if widthplot == None: | |
102 | widthplot = self.WIDTH |
|
102 | widthplot = self.WIDTH | |
103 |
|
103 | |||
104 | if heightplot == None: |
|
104 | if heightplot == None: | |
105 | heightplot = self.HEIGHT |
|
105 | heightplot = self.HEIGHT | |
106 |
|
106 | |||
107 | self.idfigure = idfigure |
|
107 | self.idfigure = idfigure | |
108 |
|
108 | |||
109 | self.wintitle = wintitle |
|
109 | self.wintitle = wintitle | |
110 |
|
110 | |||
111 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) |
|
111 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) | |
112 |
|
112 | |||
113 | self.fig = self.__driver.createFigure(self.idfigure, |
|
113 | self.fig = self.__driver.createFigure(self.idfigure, | |
114 | self.wintitle, |
|
114 | self.wintitle, | |
115 | self.widthscreen, |
|
115 | self.widthscreen, | |
116 | self.heightscreen) |
|
116 | self.heightscreen) | |
117 |
|
117 | |||
118 | self.axesObjList = [] |
|
118 | self.axesObjList = [] | |
119 |
|
119 | |||
120 | def setDriver(self, driver=mpldriver): |
|
120 | def setDriver(self, driver=mpldriver): | |
121 |
|
121 | |||
122 | self.__driver = driver |
|
122 | self.__driver = driver | |
123 |
|
123 | |||
124 | def setTitle(self, title): |
|
124 | def setTitle(self, title): | |
125 |
|
125 | |||
126 | self.__driver.setTitle(self.fig, title) |
|
126 | self.__driver.setTitle(self.fig, title) | |
127 |
|
127 | |||
128 | def setWinTitle(self, title): |
|
128 | def setWinTitle(self, title): | |
129 |
|
129 | |||
130 | self.__driver.setWinTitle(self.fig, title=title) |
|
130 | self.__driver.setWinTitle(self.fig, title=title) | |
131 |
|
131 | |||
132 | def setTextFromAxes(self, text): |
|
132 | def setTextFromAxes(self, text): | |
133 |
|
133 | |||
134 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" |
|
134 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" | |
135 |
|
135 | |||
136 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
136 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): | |
137 |
|
137 | |||
138 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" |
|
138 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" | |
139 |
|
139 | |||
140 | def addAxes(self, *args): |
|
140 | def addAxes(self, *args): | |
141 | """ |
|
141 | """ | |
142 |
|
142 | |||
143 | Input: |
|
143 | Input: | |
144 | *args : Los parametros necesarios son |
|
144 | *args : Los parametros necesarios son | |
145 | nrow, ncol, xpos, ypos, colspan, rowspan |
|
145 | nrow, ncol, xpos, ypos, colspan, rowspan | |
146 | """ |
|
146 | """ | |
147 |
|
147 | |||
148 | axesObj = Axes(self.fig, *args) |
|
148 | axesObj = Axes(self.fig, *args) | |
149 | self.axesObjList.append(axesObj) |
|
149 | self.axesObjList.append(axesObj) | |
150 |
|
150 | |||
151 | def saveFigure(self, figpath, figfile, *args): |
|
151 | def saveFigure(self, figpath, figfile, *args): | |
152 |
|
152 | |||
153 | filename = os.path.join(figpath, figfile) |
|
153 | filename = os.path.join(figpath, figfile) | |
154 | self.__driver.saveFigure(self.fig, filename, *args) |
|
154 | self.__driver.saveFigure(self.fig, filename, *args) | |
155 |
|
155 | |||
156 | def draw(self): |
|
156 | def draw(self): | |
157 |
|
157 | |||
158 | self.__driver.draw(self.fig) |
|
158 | self.__driver.draw(self.fig) | |
159 |
|
159 | |||
160 | def run(self): |
|
160 | def run(self): | |
161 |
|
161 | |||
162 | raise ValueError, "This method is not implemented" |
|
162 | raise ValueError, "This method is not implemented" | |
163 |
|
163 | |||
164 | axesList = property(getAxesObjList) |
|
164 | axesList = property(getAxesObjList) | |
165 |
|
165 | |||
166 |
|
166 | |||
167 | class Axes: |
|
167 | class Axes: | |
168 |
|
168 | |||
169 | __driver = mpldriver |
|
169 | __driver = mpldriver | |
170 | fig = None |
|
170 | fig = None | |
171 | ax = None |
|
171 | ax = None | |
172 | plot = None |
|
172 | plot = None | |
173 |
|
173 | |||
174 | __firsttime = None |
|
174 | __firsttime = None | |
175 |
|
175 | |||
176 | __showprofile = False |
|
176 | __showprofile = False | |
177 |
|
177 | |||
178 | xmin = None |
|
178 | xmin = None | |
179 | xmax = None |
|
179 | xmax = None | |
180 | ymin = None |
|
180 | ymin = None | |
181 | ymax = None |
|
181 | ymax = None | |
182 | zmin = None |
|
182 | zmin = None | |
183 | zmax = None |
|
183 | zmax = None | |
184 |
|
184 | |||
185 | def __init__(self, *args): |
|
185 | def __init__(self, *args): | |
186 |
|
186 | |||
187 | """ |
|
187 | """ | |
188 |
|
188 | |||
189 | Input: |
|
189 | Input: | |
190 | *args : Los parametros necesarios son |
|
190 | *args : Los parametros necesarios son | |
191 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
191 | fig, nrow, ncol, xpos, ypos, colspan, rowspan | |
192 | """ |
|
192 | """ | |
193 |
|
193 | |||
194 | ax = self.__driver.createAxes(*args) |
|
194 | ax = self.__driver.createAxes(*args) | |
195 | self.fig = args[0] |
|
195 | self.fig = args[0] | |
196 | self.ax = ax |
|
196 | self.ax = ax | |
197 | self.plot = None |
|
197 | self.plot = None | |
198 |
|
198 | |||
199 | self.__firsttime = True |
|
199 | self.__firsttime = True | |
200 | self.idlineList = [] |
|
200 | self.idlineList = [] | |
201 |
|
201 | |||
202 | def setText(self, text): |
|
202 | def setText(self, text): | |
203 |
|
203 | |||
204 | self.__driver.setAxesText(self.ax, text) |
|
204 | self.__driver.setAxesText(self.ax, text) | |
205 |
|
205 | |||
206 | def setXAxisAsTime(self): |
|
206 | def setXAxisAsTime(self): | |
207 | pass |
|
207 | pass | |
208 |
|
208 | |||
209 | def pline(self, x, y, |
|
209 | def pline(self, x, y, | |
210 | xmin=None, xmax=None, |
|
210 | xmin=None, xmax=None, | |
211 | ymin=None, ymax=None, |
|
211 | ymin=None, ymax=None, | |
212 | xlabel='', ylabel='', |
|
212 | xlabel='', ylabel='', | |
213 | title='', |
|
213 | title='', | |
214 | **kwargs): |
|
214 | **kwargs): | |
215 |
|
215 | |||
216 | """ |
|
216 | """ | |
217 |
|
217 | |||
218 | Input: |
|
218 | Input: | |
219 | x : |
|
219 | x : | |
220 | y : |
|
220 | y : | |
221 | xmin : |
|
221 | xmin : | |
222 | xmax : |
|
222 | xmax : | |
223 | ymin : |
|
223 | ymin : | |
224 | ymax : |
|
224 | ymax : | |
225 | xlabel : |
|
225 | xlabel : | |
226 | ylabel : |
|
226 | ylabel : | |
227 | title : |
|
227 | title : | |
228 | **kwargs : Los parametros aceptados son |
|
228 | **kwargs : Los parametros aceptados son | |
229 |
|
229 | |||
230 | ticksize |
|
230 | ticksize | |
231 | ytick_visible |
|
231 | ytick_visible | |
232 | """ |
|
232 | """ | |
233 |
|
233 | |||
234 | if self.__firsttime: |
|
234 | if self.__firsttime: | |
235 |
|
235 | |||
236 | if xmin == None: xmin = numpy.nanmin(x) |
|
236 | if xmin == None: xmin = numpy.nanmin(x) | |
237 | if xmax == None: xmax = numpy.nanmax(x) |
|
237 | if xmax == None: xmax = numpy.nanmax(x) | |
238 | if ymin == None: ymin = numpy.nanmin(y) |
|
238 | if ymin == None: ymin = numpy.nanmin(y) | |
239 | if ymax == None: ymax = numpy.nanmax(y) |
|
239 | if ymax == None: ymax = numpy.nanmax(y) | |
240 |
|
240 | |||
241 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
241 | self.plot = self.__driver.createPline(self.ax, x, y, | |
242 | xmin, xmax, |
|
242 | xmin, xmax, | |
243 | ymin, ymax, |
|
243 | ymin, ymax, | |
244 | xlabel=xlabel, |
|
244 | xlabel=xlabel, | |
245 | ylabel=ylabel, |
|
245 | ylabel=ylabel, | |
246 | title=title, |
|
246 | title=title, | |
247 | **kwargs) |
|
247 | **kwargs) | |
248 |
|
248 | |||
249 | self.idlineList.append(0) |
|
249 | self.idlineList.append(0) | |
250 | self.__firsttime = False |
|
250 | self.__firsttime = False | |
251 | return |
|
251 | return | |
252 |
|
252 | |||
253 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
253 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, | |
254 | ylabel=ylabel, |
|
254 | ylabel=ylabel, | |
255 | title=title) |
|
255 | title=title) | |
256 |
|
256 | |||
257 | def addpline(self, x, y, idline, **kwargs): |
|
257 | def addpline(self, x, y, idline, **kwargs): | |
258 | lines = self.ax.lines |
|
258 | lines = self.ax.lines | |
259 |
|
259 | |||
260 | if idline in self.idlineList: |
|
260 | if idline in self.idlineList: | |
261 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
261 | self.__driver.set_linedata(self.ax, x, y, idline) | |
262 |
|
262 | |||
263 | if idline not in(self.idlineList): |
|
263 | if idline not in(self.idlineList): | |
264 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
264 | self.__driver.addpline(self.ax, x, y, **kwargs) | |
265 | self.idlineList.append(idline) |
|
265 | self.idlineList.append(idline) | |
266 |
|
266 | |||
267 | return |
|
267 | return | |
268 |
|
268 | |||
269 | def pmultiline(self, x, y, |
|
269 | def pmultiline(self, x, y, | |
270 | xmin=None, xmax=None, |
|
270 | xmin=None, xmax=None, | |
271 | ymin=None, ymax=None, |
|
271 | ymin=None, ymax=None, | |
272 | xlabel='', ylabel='', |
|
272 | xlabel='', ylabel='', | |
273 | title='', |
|
273 | title='', | |
274 | **kwargs): |
|
274 | **kwargs): | |
275 |
|
275 | |||
276 | if self.__firsttime: |
|
276 | if self.__firsttime: | |
277 |
|
277 | |||
278 | if xmin == None: xmin = numpy.nanmin(x) |
|
278 | if xmin == None: xmin = numpy.nanmin(x) | |
279 | if xmax == None: xmax = numpy.nanmax(x) |
|
279 | if xmax == None: xmax = numpy.nanmax(x) | |
280 | if ymin == None: ymin = numpy.nanmin(y) |
|
280 | if ymin == None: ymin = numpy.nanmin(y) | |
281 | if ymax == None: ymax = numpy.nanmax(y) |
|
281 | if ymax == None: ymax = numpy.nanmax(y) | |
282 |
|
282 | |||
283 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
283 | self.plot = self.__driver.createPmultiline(self.ax, x, y, | |
284 | xmin, xmax, |
|
284 | xmin, xmax, | |
285 | ymin, ymax, |
|
285 | ymin, ymax, | |
286 | xlabel=xlabel, |
|
286 | xlabel=xlabel, | |
287 | ylabel=ylabel, |
|
287 | ylabel=ylabel, | |
288 | title=title, |
|
288 | title=title, | |
289 | **kwargs) |
|
289 | **kwargs) | |
290 | self.__firsttime = False |
|
290 | self.__firsttime = False | |
291 | return |
|
291 | return | |
292 |
|
292 | |||
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 |
|
|
296 | ||
|
297 | def pmultilineyaxis(self, x, y, | |||
|
298 | xmin=None, xmax=None, | |||
|
299 | ymin=None, ymax=None, | |||
|
300 | xlabel='', ylabel='', | |||
|
301 | title='', | |||
|
302 | **kwargs): | |||
|
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, | |
300 | zmin=None, zmax=None, |
|
328 | zmin=None, zmax=None, | |
301 | xlabel='', ylabel='', |
|
329 | xlabel='', ylabel='', | |
302 | title='', rti = False, colormap='jet', |
|
330 | title='', rti = False, colormap='jet', | |
303 | **kwargs): |
|
331 | **kwargs): | |
304 |
|
332 | |||
305 | """ |
|
333 | """ | |
306 | Input: |
|
334 | Input: | |
307 | x : |
|
335 | x : | |
308 | y : |
|
336 | y : | |
309 | x : |
|
337 | x : | |
310 | xmin : |
|
338 | xmin : | |
311 | xmax : |
|
339 | xmax : | |
312 | ymin : |
|
340 | ymin : | |
313 | ymax : |
|
341 | ymax : | |
314 | zmin : |
|
342 | zmin : | |
315 | zmax : |
|
343 | zmax : | |
316 | xlabel : |
|
344 | xlabel : | |
317 | ylabel : |
|
345 | ylabel : | |
318 | title : |
|
346 | title : | |
319 | **kwargs : Los parametros aceptados son |
|
347 | **kwargs : Los parametros aceptados son | |
320 | ticksize=9, |
|
348 | ticksize=9, | |
321 | cblabel='' |
|
349 | cblabel='' | |
322 | rti = True or False |
|
350 | rti = True or False | |
323 | """ |
|
351 | """ | |
324 |
|
352 | |||
325 | if self.__firsttime: |
|
353 | if self.__firsttime: | |
326 |
|
354 | |||
327 | if xmin == None: xmin = numpy.nanmin(x) |
|
355 | if xmin == None: xmin = numpy.nanmin(x) | |
328 | if xmax == None: xmax = numpy.nanmax(x) |
|
356 | if xmax == None: xmax = numpy.nanmax(x) | |
329 | if ymin == None: ymin = numpy.nanmin(y) |
|
357 | if ymin == None: ymin = numpy.nanmin(y) | |
330 | if ymax == None: ymax = numpy.nanmax(y) |
|
358 | if ymax == None: ymax = numpy.nanmax(y) | |
331 | if zmin == None: zmin = numpy.nanmin(z) |
|
359 | if zmin == None: zmin = numpy.nanmin(z) | |
332 | if zmax == None: zmax = numpy.nanmax(z) |
|
360 | if zmax == None: zmax = numpy.nanmax(z) | |
333 |
|
361 | |||
334 |
|
362 | |||
335 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
363 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, | |
336 | xmin, xmax, |
|
364 | xmin, xmax, | |
337 | ymin, ymax, |
|
365 | ymin, ymax, | |
338 | zmin, zmax, |
|
366 | zmin, zmax, | |
339 | xlabel=xlabel, |
|
367 | xlabel=xlabel, | |
340 | ylabel=ylabel, |
|
368 | ylabel=ylabel, | |
341 | title=title, |
|
369 | title=title, | |
342 | colormap=colormap, |
|
370 | colormap=colormap, | |
343 | **kwargs) |
|
371 | **kwargs) | |
344 |
|
372 | |||
345 | if self.xmin == None: self.xmin = xmin |
|
373 | if self.xmin == None: self.xmin = xmin | |
346 | if self.xmax == None: self.xmax = xmax |
|
374 | if self.xmax == None: self.xmax = xmax | |
347 | if self.ymin == None: self.ymin = ymin |
|
375 | if self.ymin == None: self.ymin = ymin | |
348 | if self.ymax == None: self.ymax = ymax |
|
376 | if self.ymax == None: self.ymax = ymax | |
349 | if self.zmin == None: self.zmin = zmin |
|
377 | if self.zmin == None: self.zmin = zmin | |
350 | if self.zmax == None: self.zmax = zmax |
|
378 | if self.zmax == None: self.zmax = zmax | |
351 |
|
379 | |||
352 | self.__firsttime = False |
|
380 | self.__firsttime = False | |
353 | return |
|
381 | return | |
354 |
|
382 | |||
355 | if rti: |
|
383 | if rti: | |
356 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
384 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, | |
357 | xlabel=xlabel, |
|
385 | xlabel=xlabel, | |
358 | ylabel=ylabel, |
|
386 | ylabel=ylabel, | |
359 | title=title, |
|
387 | title=title, | |
360 | colormap=colormap) |
|
388 | colormap=colormap) | |
361 | return |
|
389 | return | |
362 |
|
390 | |||
363 | self.__driver.pcolor(self.plot, z, |
|
391 | self.__driver.pcolor(self.plot, z, | |
364 | xlabel=xlabel, |
|
392 | xlabel=xlabel, | |
365 | ylabel=ylabel, |
|
393 | ylabel=ylabel, | |
366 | title=title) |
|
394 | title=title) | |
367 |
|
395 | |||
368 | No newline at end of file |
|
396 |
@@ -1,275 +1,342 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import datetime |
|
2 | import datetime | |
3 | import matplotlib |
|
3 | import matplotlib | |
4 | matplotlib.use("TKAgg") |
|
4 | matplotlib.use("TKAgg") | |
5 | import matplotlib.pyplot |
|
5 | import matplotlib.pyplot | |
6 | import matplotlib.dates |
|
6 | import matplotlib.dates | |
7 | #import scitools.numpyutils |
|
7 | #import scitools.numpyutils | |
8 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
8 | from mpl_toolkits.axes_grid1 import make_axes_locatable | |
9 |
|
9 | |||
10 | from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocator, DateFormatter |
|
10 | from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocator, DateFormatter | |
11 | from matplotlib.ticker import FuncFormatter |
|
11 | from matplotlib.ticker import FuncFormatter | |
12 | from matplotlib.ticker import * |
|
12 | from matplotlib.ticker import * | |
13 |
|
13 | |||
14 | ########################################### |
|
14 | ########################################### | |
15 | #Actualizacion de las funciones del driver |
|
15 | #Actualizacion de las funciones del driver | |
16 | ########################################### |
|
16 | ########################################### | |
17 |
|
17 | |||
18 | def createFigure(idfigure, wintitle, width, height, facecolor="w"): |
|
18 | def createFigure(idfigure, wintitle, width, height, facecolor="w"): | |
19 |
|
19 | |||
20 | matplotlib.pyplot.ioff() |
|
20 | matplotlib.pyplot.ioff() | |
21 | fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) |
|
21 | fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) | |
22 | fig.canvas.manager.set_window_title(wintitle) |
|
22 | fig.canvas.manager.set_window_title(wintitle) | |
23 | fig.canvas.manager.resize(width, height) |
|
23 | fig.canvas.manager.resize(width, height) | |
24 | matplotlib.pyplot.ion() |
|
24 | matplotlib.pyplot.ion() | |
25 |
|
25 | |||
26 | return fig |
|
26 | return fig | |
27 |
|
27 | |||
28 | def closeFigure(): |
|
28 | def closeFigure(): | |
29 |
|
29 | |||
30 | matplotlib.pyplot.ioff() |
|
30 | matplotlib.pyplot.ioff() | |
31 | matplotlib.pyplot.show() |
|
31 | matplotlib.pyplot.show() | |
32 |
|
32 | |||
33 | return |
|
33 | return | |
34 |
|
34 | |||
35 | def saveFigure(fig, filename): |
|
35 | def saveFigure(fig, filename): | |
36 | fig.savefig(filename) |
|
36 | fig.savefig(filename) | |
37 |
|
37 | |||
38 | def setWinTitle(fig, title): |
|
38 | def setWinTitle(fig, title): | |
39 |
|
39 | |||
40 | fig.canvas.manager.set_window_title(title) |
|
40 | fig.canvas.manager.set_window_title(title) | |
41 |
|
41 | |||
42 | def setTitle(fig, title): |
|
42 | def setTitle(fig, title): | |
43 |
|
43 | |||
44 | fig.suptitle(title) |
|
44 | fig.suptitle(title) | |
45 |
|
45 | |||
46 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
46 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan): | |
47 |
|
47 | |||
48 | matplotlib.pyplot.figure(fig.number) |
|
48 | matplotlib.pyplot.figure(fig.number) | |
49 | axes = matplotlib.pyplot.subplot2grid((nrow, ncol), |
|
49 | axes = matplotlib.pyplot.subplot2grid((nrow, ncol), | |
50 | (xpos, ypos), |
|
50 | (xpos, ypos), | |
51 | colspan=colspan, |
|
51 | colspan=colspan, | |
52 | rowspan=rowspan) |
|
52 | rowspan=rowspan) | |
53 | return axes |
|
53 | return axes | |
54 |
|
54 | |||
55 | def setAxesText(ax, text): |
|
55 | def setAxesText(ax, text): | |
56 |
|
56 | |||
57 | ax.annotate(text, |
|
57 | ax.annotate(text, | |
58 | xy = (.1, .99), |
|
58 | xy = (.1, .99), | |
59 | xycoords = 'figure fraction', |
|
59 | xycoords = 'figure fraction', | |
60 | horizontalalignment = 'left', |
|
60 | horizontalalignment = 'left', | |
61 | verticalalignment = 'top', |
|
61 | verticalalignment = 'top', | |
62 | fontsize = 10) |
|
62 | fontsize = 10) | |
63 |
|
63 | |||
64 | def printLabels(ax, xlabel, ylabel, title): |
|
64 | def printLabels(ax, xlabel, ylabel, title): | |
65 |
|
65 | |||
66 | ax.set_xlabel(xlabel, size=11) |
|
66 | ax.set_xlabel(xlabel, size=11) | |
67 | ax.set_ylabel(ylabel, size=11) |
|
67 | ax.set_ylabel(ylabel, size=11) | |
68 | ax.set_title(title, size=12) |
|
68 | ax.set_title(title, size=12) | |
69 |
|
69 | |||
70 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', |
|
70 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', | |
71 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
71 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
72 | nxticks=4, nyticks=10, |
|
72 | nxticks=4, nyticks=10, | |
73 | grid=None): |
|
73 | grid=None): | |
74 |
|
74 | |||
75 | """ |
|
75 | """ | |
76 |
|
76 | |||
77 | Input: |
|
77 | Input: | |
78 | grid : None, 'both', 'x', 'y' |
|
78 | grid : None, 'both', 'x', 'y' | |
79 | """ |
|
79 | """ | |
80 |
|
80 | |||
81 | ax.plot(x, y) |
|
81 | ax.plot(x, y) | |
82 | ax.set_xlim([xmin,xmax]) |
|
82 | ax.set_xlim([xmin,xmax]) | |
83 | ax.set_ylim([ymin,ymax]) |
|
83 | ax.set_ylim([ymin,ymax]) | |
84 |
|
84 | |||
85 | printLabels(ax, xlabel, ylabel, title) |
|
85 | printLabels(ax, xlabel, ylabel, title) | |
86 |
|
86 | |||
87 | ###################################################### |
|
87 | ###################################################### | |
88 | if (xmax-xmin)<=1: |
|
88 | if (xmax-xmin)<=1: | |
89 | xtickspos = numpy.linspace(xmin,xmax,nxticks) |
|
89 | xtickspos = numpy.linspace(xmin,xmax,nxticks) | |
90 | xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos]) |
|
90 | xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos]) | |
91 | ax.set_xticks(xtickspos) |
|
91 | ax.set_xticks(xtickspos) | |
92 | else: |
|
92 | else: | |
93 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
93 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) | |
94 | ax.set_xticks(xtickspos) |
|
94 | ax.set_xticks(xtickspos) | |
95 |
|
95 | |||
96 | for tick in ax.get_xticklabels(): |
|
96 | for tick in ax.get_xticklabels(): | |
97 | tick.set_visible(xtick_visible) |
|
97 | tick.set_visible(xtick_visible) | |
98 |
|
98 | |||
99 | for tick in ax.xaxis.get_major_ticks(): |
|
99 | for tick in ax.xaxis.get_major_ticks(): | |
100 | tick.label.set_fontsize(ticksize) |
|
100 | tick.label.set_fontsize(ticksize) | |
101 |
|
101 | |||
102 | ###################################################### |
|
102 | ###################################################### | |
103 | for tick in ax.get_yticklabels(): |
|
103 | for tick in ax.get_yticklabels(): | |
104 | tick.set_visible(ytick_visible) |
|
104 | tick.set_visible(ytick_visible) | |
105 |
|
105 | |||
106 | for tick in ax.yaxis.get_major_ticks(): |
|
106 | for tick in ax.yaxis.get_major_ticks(): | |
107 | tick.label.set_fontsize(ticksize) |
|
107 | tick.label.set_fontsize(ticksize) | |
108 |
|
108 | |||
109 | iplot = ax.lines[-1] |
|
109 | iplot = ax.lines[-1] | |
110 |
|
110 | |||
111 | ###################################################### |
|
111 | ###################################################### | |
112 | if '0.' in matplotlib.__version__[0:2]: |
|
112 | if '0.' in matplotlib.__version__[0:2]: | |
113 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
113 | print "The matplotlib version has to be updated to 1.1 or newer" | |
114 | return iplot |
|
114 | return iplot | |
115 |
|
115 | |||
116 | if '1.0.' in matplotlib.__version__[0:4]: |
|
116 | if '1.0.' in matplotlib.__version__[0:4]: | |
117 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
117 | print "The matplotlib version has to be updated to 1.1 or newer" | |
118 | return iplot |
|
118 | return iplot | |
119 |
|
119 | |||
120 | if grid != None: |
|
120 | if grid != None: | |
121 | ax.grid(b=True, which='major', axis=grid) |
|
121 | ax.grid(b=True, which='major', axis=grid) | |
122 |
|
122 | |||
123 | matplotlib.pyplot.tight_layout() |
|
123 | matplotlib.pyplot.tight_layout() | |
124 |
|
124 | |||
125 | return iplot |
|
125 | return iplot | |
126 |
|
126 | |||
127 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
127 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): | |
128 |
|
128 | |||
129 | ax = iplot.get_axes() |
|
129 | ax = iplot.get_axes() | |
130 |
|
130 | |||
131 | printLabels(ax, xlabel, ylabel, title) |
|
131 | printLabels(ax, xlabel, ylabel, title) | |
132 |
|
132 | |||
133 | set_linedata(ax, x, y, idline=0) |
|
133 | set_linedata(ax, x, y, idline=0) | |
134 |
|
134 | |||
135 | def addpline(ax, x, y, color, linestyle, lw): |
|
135 | def addpline(ax, x, y, color, linestyle, lw): | |
136 | ax.plot(x,y,color=color,linestyle=linestyle,lw=lw) |
|
136 | ax.plot(x,y,color=color,linestyle=linestyle,lw=lw) | |
137 |
|
137 | |||
138 |
|
138 | |||
139 | def set_linedata(ax, x, y, idline): |
|
139 | def set_linedata(ax, x, y, idline): | |
140 | ax.lines[idline].set_data(x,y) |
|
140 | ax.lines[idline].set_data(x,y) | |
141 |
|
141 | |||
142 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
142 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, | |
143 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
143 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
144 | nxticks=4, nyticks=10, |
|
144 | nxticks=4, nyticks=10, | |
145 | grid=None): |
|
145 | grid=None): | |
146 |
|
146 | |||
147 | """ |
|
147 | """ | |
148 |
|
148 | |||
149 | Input: |
|
149 | Input: | |
150 | grid : None, 'both', 'x', 'y' |
|
150 | grid : None, 'both', 'x', 'y' | |
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]) | |
158 | printLabels(ax, xlabel, ylabel, title) |
|
158 | printLabels(ax, xlabel, ylabel, title) | |
159 |
|
159 | |||
160 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
160 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) | |
161 | ax.set_xticks(xtickspos) |
|
161 | ax.set_xticks(xtickspos) | |
162 |
|
162 | |||
163 | for tick in ax.get_xticklabels(): |
|
163 | for tick in ax.get_xticklabels(): | |
164 | tick.set_visible(xtick_visible) |
|
164 | tick.set_visible(xtick_visible) | |
165 |
|
165 | |||
166 | for tick in ax.xaxis.get_major_ticks(): |
|
166 | for tick in ax.xaxis.get_major_ticks(): | |
167 | tick.label.set_fontsize(ticksize) |
|
167 | tick.label.set_fontsize(ticksize) | |
168 |
|
168 | |||
169 | for tick in ax.get_yticklabels(): |
|
169 | for tick in ax.get_yticklabels(): | |
170 | tick.set_visible(ytick_visible) |
|
170 | tick.set_visible(ytick_visible) | |
171 |
|
171 | |||
172 | for tick in ax.yaxis.get_major_ticks(): |
|
172 | for tick in ax.yaxis.get_major_ticks(): | |
173 | tick.label.set_fontsize(ticksize) |
|
173 | tick.label.set_fontsize(ticksize) | |
174 |
|
174 | |||
175 | iplot = ax.lines[-1] |
|
175 | iplot = ax.lines[-1] | |
176 |
|
176 | |||
177 | if '0.' in matplotlib.__version__[0:2]: |
|
177 | if '0.' in matplotlib.__version__[0:2]: | |
178 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
178 | print "The matplotlib version has to be updated to 1.1 or newer" | |
179 | return iplot |
|
179 | return iplot | |
180 |
|
180 | |||
181 | if '1.0.' in matplotlib.__version__[0:4]: |
|
181 | if '1.0.' in matplotlib.__version__[0:4]: | |
182 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
182 | print "The matplotlib version has to be updated to 1.1 or newer" | |
183 | return iplot |
|
183 | return iplot | |
184 |
|
184 | |||
185 | if grid != None: |
|
185 | if grid != None: | |
186 | ax.grid(b=True, which='major', axis=grid) |
|
186 | ax.grid(b=True, which='major', axis=grid) | |
187 |
|
187 | |||
188 | matplotlib.pyplot.tight_layout() |
|
188 | matplotlib.pyplot.tight_layout() | |
189 |
|
189 | |||
190 | return iplot |
|
190 | return iplot | |
191 |
|
191 | |||
192 |
|
192 | |||
193 | def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
193 | def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): | |
194 |
|
194 | |||
195 | ax = iplot.get_axes() |
|
195 | ax = iplot.get_axes() | |
196 |
|
196 | |||
197 | printLabels(ax, xlabel, ylabel, title) |
|
197 | printLabels(ax, xlabel, ylabel, title) | |
198 |
|
198 | |||
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 |
|
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,:]) | |||
|
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, | |
205 | colormap='jet',cblabel='', cbsize="5%", |
|
272 | colormap='jet',cblabel='', cbsize="5%", | |
206 | XAxisAsTime=False): |
|
273 | XAxisAsTime=False): | |
207 |
|
274 | |||
208 | divider = make_axes_locatable(ax) |
|
275 | divider = make_axes_locatable(ax) | |
209 | ax_cb = divider.new_horizontal(size=cbsize, pad=0.05) |
|
276 | ax_cb = divider.new_horizontal(size=cbsize, pad=0.05) | |
210 | fig = ax.get_figure() |
|
277 | fig = ax.get_figure() | |
211 | fig.add_axes(ax_cb) |
|
278 | fig.add_axes(ax_cb) | |
212 |
|
279 | |||
213 | ax.set_xlim([xmin,xmax]) |
|
280 | ax.set_xlim([xmin,xmax]) | |
214 | ax.set_ylim([ymin,ymax]) |
|
281 | ax.set_ylim([ymin,ymax]) | |
215 |
|
282 | |||
216 | printLabels(ax, xlabel, ylabel, title) |
|
283 | printLabels(ax, xlabel, ylabel, title) | |
217 |
|
284 | |||
218 | imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
285 | imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) | |
219 | cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) |
|
286 | cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) | |
220 | cb.set_label(cblabel) |
|
287 | cb.set_label(cblabel) | |
221 |
|
288 | |||
222 | # for tl in ax_cb.get_yticklabels(): |
|
289 | # for tl in ax_cb.get_yticklabels(): | |
223 | # tl.set_visible(True) |
|
290 | # tl.set_visible(True) | |
224 |
|
291 | |||
225 | for tick in ax.yaxis.get_major_ticks(): |
|
292 | for tick in ax.yaxis.get_major_ticks(): | |
226 | tick.label.set_fontsize(ticksize) |
|
293 | tick.label.set_fontsize(ticksize) | |
227 |
|
294 | |||
228 | for tick in ax.xaxis.get_major_ticks(): |
|
295 | for tick in ax.xaxis.get_major_ticks(): | |
229 | tick.label.set_fontsize(ticksize) |
|
296 | tick.label.set_fontsize(ticksize) | |
230 |
|
297 | |||
231 | for tick in cb.ax.get_yticklabels(): |
|
298 | for tick in cb.ax.get_yticklabels(): | |
232 | tick.set_fontsize(ticksize) |
|
299 | tick.set_fontsize(ticksize) | |
233 |
|
300 | |||
234 | ax_cb.yaxis.tick_right() |
|
301 | ax_cb.yaxis.tick_right() | |
235 |
|
302 | |||
236 | if '0.' in matplotlib.__version__[0:2]: |
|
303 | if '0.' in matplotlib.__version__[0:2]: | |
237 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
304 | print "The matplotlib version has to be updated to 1.1 or newer" | |
238 | return imesh |
|
305 | return imesh | |
239 |
|
306 | |||
240 | if '1.0.' in matplotlib.__version__[0:4]: |
|
307 | if '1.0.' in matplotlib.__version__[0:4]: | |
241 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
308 | print "The matplotlib version has to be updated to 1.1 or newer" | |
242 | return imesh |
|
309 | return imesh | |
243 |
|
310 | |||
244 | matplotlib.pyplot.tight_layout() |
|
311 | matplotlib.pyplot.tight_layout() | |
245 |
|
312 | |||
246 | if XAxisAsTime: |
|
313 | if XAxisAsTime: | |
247 |
|
314 | |||
248 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
315 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) | |
249 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
316 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
250 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
317 | ax.xaxis.set_major_locator(LinearLocator(7)) | |
251 |
|
318 | |||
252 | return imesh |
|
319 | return imesh | |
253 |
|
320 | |||
254 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): |
|
321 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): | |
255 |
|
322 | |||
256 | z = z.T |
|
323 | z = z.T | |
257 |
|
324 | |||
258 | ax = imesh.get_axes() |
|
325 | ax = imesh.get_axes() | |
259 |
|
326 | |||
260 | printLabels(ax, xlabel, ylabel, title) |
|
327 | printLabels(ax, xlabel, ylabel, title) | |
261 |
|
328 | |||
262 | imesh.set_array(z.ravel()) |
|
329 | imesh.set_array(z.ravel()) | |
263 |
|
330 | |||
264 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): |
|
331 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): | |
265 |
|
332 | |||
266 | printLabels(ax, xlabel, ylabel, title) |
|
333 | printLabels(ax, xlabel, ylabel, title) | |
267 |
|
334 | |||
268 | imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
335 | imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) | |
269 |
|
336 | |||
270 | def draw(fig): |
|
337 | def draw(fig): | |
271 |
|
338 | |||
272 | if type(fig) == 'int': |
|
339 | if type(fig) == 'int': | |
273 | raise ValueError, "This parameter should be of tpye matplotlib figure" |
|
340 | raise ValueError, "This parameter should be of tpye matplotlib figure" | |
274 |
|
341 | |||
275 | fig.canvas.draw() No newline at end of file |
|
342 | fig.canvas.draw() |
@@ -1,986 +1,954 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime |
|
2 | import time, datetime | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 |
|
4 | |||
5 | class CrossSpectraPlot(Figure): |
|
5 | class CrossSpectraPlot(Figure): | |
6 |
|
6 | |||
7 | __isConfig = None |
|
7 | __isConfig = None | |
8 | __nsubplots = None |
|
8 | __nsubplots = None | |
9 |
|
9 | |||
10 | WIDTH = None |
|
10 | WIDTH = None | |
11 | HEIGHT = None |
|
11 | HEIGHT = None | |
12 | WIDTHPROF = None |
|
12 | WIDTHPROF = None | |
13 | HEIGHTPROF = None |
|
13 | HEIGHTPROF = None | |
14 | PREFIX = 'cspc' |
|
14 | PREFIX = 'cspc' | |
15 |
|
15 | |||
16 | def __init__(self): |
|
16 | def __init__(self): | |
17 |
|
17 | |||
18 | self.__isConfig = False |
|
18 | self.__isConfig = False | |
19 | self.__nsubplots = 4 |
|
19 | self.__nsubplots = 4 | |
20 |
|
20 | |||
21 | self.WIDTH = 250 |
|
21 | self.WIDTH = 250 | |
22 | self.HEIGHT = 250 |
|
22 | self.HEIGHT = 250 | |
23 | self.WIDTHPROF = 0 |
|
23 | self.WIDTHPROF = 0 | |
24 | self.HEIGHTPROF = 0 |
|
24 | self.HEIGHTPROF = 0 | |
25 |
|
25 | |||
26 | def getSubplots(self): |
|
26 | def getSubplots(self): | |
27 |
|
27 | |||
28 | ncol = 4 |
|
28 | ncol = 4 | |
29 | nrow = self.nplots |
|
29 | nrow = self.nplots | |
30 |
|
30 | |||
31 | return nrow, ncol |
|
31 | return nrow, ncol | |
32 |
|
32 | |||
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
34 |
|
34 | |||
35 | self.__showprofile = showprofile |
|
35 | self.__showprofile = showprofile | |
36 | self.nplots = nplots |
|
36 | self.nplots = nplots | |
37 |
|
37 | |||
38 | ncolspan = 1 |
|
38 | ncolspan = 1 | |
39 | colspan = 1 |
|
39 | colspan = 1 | |
40 |
|
40 | |||
41 | self.createFigure(idfigure = idfigure, |
|
41 | self.createFigure(idfigure = idfigure, | |
42 | wintitle = wintitle, |
|
42 | wintitle = wintitle, | |
43 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
43 | widthplot = self.WIDTH + self.WIDTHPROF, | |
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
45 |
|
45 | |||
46 | nrow, ncol = self.getSubplots() |
|
46 | nrow, ncol = self.getSubplots() | |
47 |
|
47 | |||
48 | counter = 0 |
|
48 | counter = 0 | |
49 | for y in range(nrow): |
|
49 | for y in range(nrow): | |
50 | for x in range(ncol): |
|
50 | for x in range(ncol): | |
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
52 |
|
52 | |||
53 | counter += 1 |
|
53 | counter += 1 | |
54 |
|
54 | |||
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
57 | save=False, figpath='./', figfile=None): |
|
57 | save=False, figpath='./', figfile=None): | |
58 |
|
58 | |||
59 | """ |
|
59 | """ | |
60 |
|
60 | |||
61 | Input: |
|
61 | Input: | |
62 | dataOut : |
|
62 | dataOut : | |
63 | idfigure : |
|
63 | idfigure : | |
64 | wintitle : |
|
64 | wintitle : | |
65 | channelList : |
|
65 | channelList : | |
66 | showProfile : |
|
66 | showProfile : | |
67 | xmin : None, |
|
67 | xmin : None, | |
68 | xmax : None, |
|
68 | xmax : None, | |
69 | ymin : None, |
|
69 | ymin : None, | |
70 | ymax : None, |
|
70 | ymax : None, | |
71 | zmin : None, |
|
71 | zmin : None, | |
72 | zmax : None |
|
72 | zmax : None | |
73 | """ |
|
73 | """ | |
74 |
|
74 | |||
75 | if pairsList == None: |
|
75 | if pairsList == None: | |
76 | pairsIndexList = dataOut.pairsIndexList |
|
76 | pairsIndexList = dataOut.pairsIndexList | |
77 | else: |
|
77 | else: | |
78 | pairsIndexList = [] |
|
78 | pairsIndexList = [] | |
79 | for pair in pairsList: |
|
79 | for pair in pairsList: | |
80 | if pair not in dataOut.pairsList: |
|
80 | if pair not in dataOut.pairsList: | |
81 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
81 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
82 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
82 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
83 |
|
83 | |||
84 | if pairsIndexList == []: |
|
84 | if pairsIndexList == []: | |
85 | return |
|
85 | return | |
86 |
|
86 | |||
87 | if len(pairsIndexList) > 4: |
|
87 | if len(pairsIndexList) > 4: | |
88 | pairsIndexList = pairsIndexList[0:4] |
|
88 | pairsIndexList = pairsIndexList[0:4] | |
89 |
|
89 | |||
90 | x = dataOut.getVelRange(1) |
|
90 | x = dataOut.getVelRange(1) | |
91 | y = dataOut.getHeiRange() |
|
91 | y = dataOut.getHeiRange() | |
92 | z = 10.*numpy.log10(dataOut.data_spc[:,:,:]) |
|
92 | z = 10.*numpy.log10(dataOut.data_spc[:,:,:]) | |
93 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
93 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
94 | avg = numpy.average(numpy.abs(z), axis=1) |
|
94 | avg = numpy.average(numpy.abs(z), axis=1) | |
95 |
|
95 | |||
96 | noise = dataOut.getNoise() |
|
96 | noise = dataOut.getNoise() | |
97 |
|
97 | |||
98 | thisDatetime = dataOut.datatime |
|
98 | thisDatetime = dataOut.datatime | |
99 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
99 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
100 | xlabel = "Velocity (m/s)" |
|
100 | xlabel = "Velocity (m/s)" | |
101 | ylabel = "Range (Km)" |
|
101 | ylabel = "Range (Km)" | |
102 |
|
102 | |||
103 | if not self.__isConfig: |
|
103 | if not self.__isConfig: | |
104 |
|
104 | |||
105 | nplots = len(pairsIndexList) |
|
105 | nplots = len(pairsIndexList) | |
106 |
|
106 | |||
107 | self.setup(idfigure=idfigure, |
|
107 | self.setup(idfigure=idfigure, | |
108 | nplots=nplots, |
|
108 | nplots=nplots, | |
109 | wintitle=wintitle, |
|
109 | wintitle=wintitle, | |
110 | showprofile=showprofile) |
|
110 | showprofile=showprofile) | |
111 |
|
111 | |||
112 | if xmin == None: xmin = numpy.nanmin(x) |
|
112 | if xmin == None: xmin = numpy.nanmin(x) | |
113 | if xmax == None: xmax = numpy.nanmax(x) |
|
113 | if xmax == None: xmax = numpy.nanmax(x) | |
114 | if ymin == None: ymin = numpy.nanmin(y) |
|
114 | if ymin == None: ymin = numpy.nanmin(y) | |
115 | if ymax == None: ymax = numpy.nanmax(y) |
|
115 | if ymax == None: ymax = numpy.nanmax(y) | |
116 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
116 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
117 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
117 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
118 |
|
118 | |||
119 | self.__isConfig = True |
|
119 | self.__isConfig = True | |
120 |
|
120 | |||
121 | self.setWinTitle(title) |
|
121 | self.setWinTitle(title) | |
122 |
|
122 | |||
123 | for i in range(self.nplots): |
|
123 | for i in range(self.nplots): | |
124 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
124 | pair = dataOut.pairsList[pairsIndexList[i]] | |
125 |
|
125 | |||
126 | title = "Channel %d: %4.2fdB" %(pair[0], noise[pair[0]]) |
|
126 | title = "Channel %d: %4.2fdB" %(pair[0], noise[pair[0]]) | |
127 | z = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]) |
|
127 | z = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]) | |
128 | axes0 = self.axesList[i*self.__nsubplots] |
|
128 | axes0 = self.axesList[i*self.__nsubplots] | |
129 | axes0.pcolor(x, y, z, |
|
129 | axes0.pcolor(x, y, z, | |
130 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
130 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
131 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
131 | xlabel=xlabel, ylabel=ylabel, title=title, | |
132 | ticksize=9, cblabel='') |
|
132 | ticksize=9, cblabel='') | |
133 |
|
133 | |||
134 | title = "Channel %d: %4.2fdB" %(pair[1], noise[pair[1]]) |
|
134 | title = "Channel %d: %4.2fdB" %(pair[1], noise[pair[1]]) | |
135 | z = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]) |
|
135 | z = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]) | |
136 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
136 | axes0 = self.axesList[i*self.__nsubplots+1] | |
137 | axes0.pcolor(x, y, z, |
|
137 | axes0.pcolor(x, y, z, | |
138 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
138 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
139 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
139 | xlabel=xlabel, ylabel=ylabel, title=title, | |
140 | ticksize=9, cblabel='') |
|
140 | ticksize=9, cblabel='') | |
141 |
|
141 | |||
142 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
142 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
143 | coherence = numpy.abs(coherenceComplex) |
|
143 | coherence = numpy.abs(coherenceComplex) | |
144 | phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
144 | phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
145 |
|
145 | |||
146 |
|
146 | |||
147 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
147 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
148 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
148 | axes0 = self.axesList[i*self.__nsubplots+2] | |
149 | axes0.pcolor(x, y, coherence, |
|
149 | axes0.pcolor(x, y, coherence, | |
150 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
150 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
151 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
151 | xlabel=xlabel, ylabel=ylabel, title=title, | |
152 | ticksize=9, cblabel='') |
|
152 | ticksize=9, cblabel='') | |
153 |
|
153 | |||
154 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
154 | title = "Phase %d%d" %(pair[0], pair[1]) | |
155 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
155 | axes0 = self.axesList[i*self.__nsubplots+3] | |
156 | axes0.pcolor(x, y, phase, |
|
156 | axes0.pcolor(x, y, phase, | |
157 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
157 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
158 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
158 | xlabel=xlabel, ylabel=ylabel, title=title, | |
159 | ticksize=9, cblabel='', colormap='RdBu_r') |
|
159 | ticksize=9, cblabel='', colormap='RdBu_r') | |
160 |
|
160 | |||
161 |
|
161 | |||
162 |
|
162 | |||
163 | self.draw() |
|
163 | self.draw() | |
164 |
|
164 | |||
165 | if save: |
|
165 | if save: | |
166 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
166 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
167 | if figfile == None: |
|
167 | if figfile == None: | |
168 | figfile = self.getFilename(name = date) |
|
168 | figfile = self.getFilename(name = date) | |
169 |
|
169 | |||
170 | self.saveFigure(figpath, figfile) |
|
170 | self.saveFigure(figpath, figfile) | |
171 |
|
171 | |||
172 |
|
172 | |||
173 | class RTIPlot(Figure): |
|
173 | class RTIPlot(Figure): | |
174 |
|
174 | |||
175 | __isConfig = None |
|
175 | __isConfig = None | |
176 | __nsubplots = None |
|
176 | __nsubplots = None | |
177 |
|
177 | |||
178 | WIDTHPROF = None |
|
178 | WIDTHPROF = None | |
179 | HEIGHTPROF = None |
|
179 | HEIGHTPROF = None | |
180 | PREFIX = 'rti' |
|
180 | PREFIX = 'rti' | |
181 |
|
181 | |||
182 | def __init__(self): |
|
182 | def __init__(self): | |
183 |
|
183 | |||
184 | self.timerange = 2*60*60 |
|
184 | self.timerange = 2*60*60 | |
185 | self.__isConfig = False |
|
185 | self.__isConfig = False | |
186 | self.__nsubplots = 1 |
|
186 | self.__nsubplots = 1 | |
187 |
|
187 | |||
188 | self.WIDTH = 800 |
|
188 | self.WIDTH = 800 | |
189 | self.HEIGHT = 200 |
|
189 | self.HEIGHT = 200 | |
190 | self.WIDTHPROF = 120 |
|
190 | self.WIDTHPROF = 120 | |
191 | self.HEIGHTPROF = 0 |
|
191 | self.HEIGHTPROF = 0 | |
192 |
|
192 | |||
193 | def getSubplots(self): |
|
193 | def getSubplots(self): | |
194 |
|
194 | |||
195 | ncol = 1 |
|
195 | ncol = 1 | |
196 | nrow = self.nplots |
|
196 | nrow = self.nplots | |
197 |
|
197 | |||
198 | return nrow, ncol |
|
198 | return nrow, ncol | |
199 |
|
199 | |||
200 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
200 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
201 |
|
201 | |||
202 | self.__showprofile = showprofile |
|
202 | self.__showprofile = showprofile | |
203 | self.nplots = nplots |
|
203 | self.nplots = nplots | |
204 |
|
204 | |||
205 | ncolspan = 1 |
|
205 | ncolspan = 1 | |
206 | colspan = 1 |
|
206 | colspan = 1 | |
207 | if showprofile: |
|
207 | if showprofile: | |
208 | ncolspan = 7 |
|
208 | ncolspan = 7 | |
209 | colspan = 6 |
|
209 | colspan = 6 | |
210 | self.__nsubplots = 2 |
|
210 | self.__nsubplots = 2 | |
211 |
|
211 | |||
212 | self.createFigure(idfigure = idfigure, |
|
212 | self.createFigure(idfigure = idfigure, | |
213 | wintitle = wintitle, |
|
213 | wintitle = wintitle, | |
214 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
214 | widthplot = self.WIDTH + self.WIDTHPROF, | |
215 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
215 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
216 |
|
216 | |||
217 | nrow, ncol = self.getSubplots() |
|
217 | nrow, ncol = self.getSubplots() | |
218 |
|
218 | |||
219 | counter = 0 |
|
219 | counter = 0 | |
220 | for y in range(nrow): |
|
220 | for y in range(nrow): | |
221 | for x in range(ncol): |
|
221 | for x in range(ncol): | |
222 |
|
222 | |||
223 | if counter >= self.nplots: |
|
223 | if counter >= self.nplots: | |
224 | break |
|
224 | break | |
225 |
|
225 | |||
226 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
226 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
227 |
|
227 | |||
228 | if showprofile: |
|
228 | if showprofile: | |
229 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
229 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
230 |
|
230 | |||
231 | counter += 1 |
|
231 | counter += 1 | |
232 |
|
232 | |||
233 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
233 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
234 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
234 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
235 | timerange=None, |
|
235 | timerange=None, | |
236 | save=False, figpath='./', figfile=None): |
|
236 | save=False, figpath='./', figfile=None): | |
237 |
|
237 | |||
238 | """ |
|
238 | """ | |
239 |
|
239 | |||
240 | Input: |
|
240 | Input: | |
241 | dataOut : |
|
241 | dataOut : | |
242 | idfigure : |
|
242 | idfigure : | |
243 | wintitle : |
|
243 | wintitle : | |
244 | channelList : |
|
244 | channelList : | |
245 | showProfile : |
|
245 | showProfile : | |
246 | xmin : None, |
|
246 | xmin : None, | |
247 | xmax : None, |
|
247 | xmax : None, | |
248 | ymin : None, |
|
248 | ymin : None, | |
249 | ymax : None, |
|
249 | ymax : None, | |
250 | zmin : None, |
|
250 | zmin : None, | |
251 | zmax : None |
|
251 | zmax : None | |
252 | """ |
|
252 | """ | |
253 |
|
253 | |||
254 | if channelList == None: |
|
254 | if channelList == None: | |
255 | channelIndexList = dataOut.channelIndexList |
|
255 | channelIndexList = dataOut.channelIndexList | |
256 | else: |
|
256 | else: | |
257 | channelIndexList = [] |
|
257 | channelIndexList = [] | |
258 | for channel in channelList: |
|
258 | for channel in channelList: | |
259 | if channel not in dataOut.channelList: |
|
259 | if channel not in dataOut.channelList: | |
260 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
260 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
261 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
261 | channelIndexList.append(dataOut.channelList.index(channel)) | |
262 |
|
262 | |||
263 | if timerange != None: |
|
263 | if timerange != None: | |
264 | self.timerange = timerange |
|
264 | self.timerange = timerange | |
265 |
|
265 | |||
266 | tmin = None |
|
266 | tmin = None | |
267 | tmax = None |
|
267 | tmax = None | |
268 | x = dataOut.getTimeRange() |
|
268 | x = dataOut.getTimeRange() | |
269 | y = dataOut.getHeiRange() |
|
269 | y = dataOut.getHeiRange() | |
270 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
270 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
271 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
271 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
272 | avg = numpy.average(z, axis=1) |
|
272 | avg = numpy.average(z, axis=1) | |
273 |
|
273 | |||
274 | noise = dataOut.getNoise() |
|
274 | noise = dataOut.getNoise() | |
275 |
|
275 | |||
276 | thisDatetime = dataOut.datatime |
|
276 | thisDatetime = dataOut.datatime | |
277 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
277 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
278 | xlabel = "Velocity (m/s)" |
|
278 | xlabel = "Velocity (m/s)" | |
279 | ylabel = "Range (Km)" |
|
279 | ylabel = "Range (Km)" | |
280 |
|
280 | |||
281 | if not self.__isConfig: |
|
281 | if not self.__isConfig: | |
282 |
|
282 | |||
283 | nplots = len(channelIndexList) |
|
283 | nplots = len(channelIndexList) | |
284 |
|
284 | |||
285 | self.setup(idfigure=idfigure, |
|
285 | self.setup(idfigure=idfigure, | |
286 | nplots=nplots, |
|
286 | nplots=nplots, | |
287 | wintitle=wintitle, |
|
287 | wintitle=wintitle, | |
288 | showprofile=showprofile) |
|
288 | showprofile=showprofile) | |
289 |
|
289 | |||
290 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
290 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
291 | if ymin == None: ymin = numpy.nanmin(y) |
|
291 | if ymin == None: ymin = numpy.nanmin(y) | |
292 | if ymax == None: ymax = numpy.nanmax(y) |
|
292 | if ymax == None: ymax = numpy.nanmax(y) | |
293 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
293 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
294 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
294 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
295 |
|
295 | |||
296 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
296 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
297 | self.__isConfig = True |
|
297 | self.__isConfig = True | |
298 |
|
298 | |||
299 |
|
299 | |||
300 | self.setWinTitle(title) |
|
300 | self.setWinTitle(title) | |
301 |
|
301 | |||
302 | for i in range(self.nplots): |
|
302 | for i in range(self.nplots): | |
303 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
303 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
304 | axes = self.axesList[i*self.__nsubplots] |
|
304 | axes = self.axesList[i*self.__nsubplots] | |
305 | z = avg[i].reshape((1,-1)) |
|
305 | z = avg[i].reshape((1,-1)) | |
306 | axes.pcolor(x, y, z, |
|
306 | axes.pcolor(x, y, z, | |
307 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
307 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
308 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
308 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
309 | ticksize=9, cblabel='', cbsize="1%") |
|
309 | ticksize=9, cblabel='', cbsize="1%") | |
310 |
|
310 | |||
311 | if self.__showprofile: |
|
311 | if self.__showprofile: | |
312 | axes = self.axesList[i*self.__nsubplots +1] |
|
312 | axes = self.axesList[i*self.__nsubplots +1] | |
313 | axes.pline(avg[i], y, |
|
313 | axes.pline(avg[i], y, | |
314 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
314 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
315 | xlabel='dB', ylabel='', title='', |
|
315 | xlabel='dB', ylabel='', title='', | |
316 | ytick_visible=False, |
|
316 | ytick_visible=False, | |
317 | grid='x') |
|
317 | grid='x') | |
318 |
|
318 | |||
319 | self.draw() |
|
319 | self.draw() | |
320 |
|
320 | |||
321 | if save: |
|
321 | if save: | |
322 |
|
322 | |||
323 | if figfile == None: |
|
323 | if figfile == None: | |
324 | figfile = self.getFilename(name = self.name) |
|
324 | figfile = self.getFilename(name = self.name) | |
325 |
|
325 | |||
326 | self.saveFigure(figpath, figfile) |
|
326 | self.saveFigure(figpath, figfile) | |
327 |
|
327 | |||
328 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
328 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
329 | self.__isConfig = False |
|
329 | self.__isConfig = False | |
330 |
|
330 | |||
331 | class SpectraPlot(Figure): |
|
331 | class SpectraPlot(Figure): | |
332 |
|
332 | |||
333 | __isConfig = None |
|
333 | __isConfig = None | |
334 | __nsubplots = None |
|
334 | __nsubplots = None | |
335 |
|
335 | |||
336 | WIDTHPROF = None |
|
336 | WIDTHPROF = None | |
337 | HEIGHTPROF = None |
|
337 | HEIGHTPROF = None | |
338 | PREFIX = 'spc' |
|
338 | PREFIX = 'spc' | |
339 |
|
339 | |||
340 | def __init__(self): |
|
340 | def __init__(self): | |
341 |
|
341 | |||
342 | self.__isConfig = False |
|
342 | self.__isConfig = False | |
343 | self.__nsubplots = 1 |
|
343 | self.__nsubplots = 1 | |
344 |
|
344 | |||
345 | self.WIDTH = 230 |
|
345 | self.WIDTH = 230 | |
346 | self.HEIGHT = 250 |
|
346 | self.HEIGHT = 250 | |
347 | self.WIDTHPROF = 120 |
|
347 | self.WIDTHPROF = 120 | |
348 | self.HEIGHTPROF = 0 |
|
348 | self.HEIGHTPROF = 0 | |
349 |
|
349 | |||
350 | def getSubplots(self): |
|
350 | def getSubplots(self): | |
351 |
|
351 | |||
352 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
352 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
353 | nrow = int(self.nplots*1./ncol + 0.9) |
|
353 | nrow = int(self.nplots*1./ncol + 0.9) | |
354 |
|
354 | |||
355 | return nrow, ncol |
|
355 | return nrow, ncol | |
356 |
|
356 | |||
357 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
357 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
358 |
|
358 | |||
359 | self.__showprofile = showprofile |
|
359 | self.__showprofile = showprofile | |
360 | self.nplots = nplots |
|
360 | self.nplots = nplots | |
361 |
|
361 | |||
362 | ncolspan = 1 |
|
362 | ncolspan = 1 | |
363 | colspan = 1 |
|
363 | colspan = 1 | |
364 | if showprofile: |
|
364 | if showprofile: | |
365 | ncolspan = 3 |
|
365 | ncolspan = 3 | |
366 | colspan = 2 |
|
366 | colspan = 2 | |
367 | self.__nsubplots = 2 |
|
367 | self.__nsubplots = 2 | |
368 |
|
368 | |||
369 | self.createFigure(idfigure = idfigure, |
|
369 | self.createFigure(idfigure = idfigure, | |
370 | wintitle = wintitle, |
|
370 | wintitle = wintitle, | |
371 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
371 | widthplot = self.WIDTH + self.WIDTHPROF, | |
372 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
372 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
373 |
|
373 | |||
374 | nrow, ncol = self.getSubplots() |
|
374 | nrow, ncol = self.getSubplots() | |
375 |
|
375 | |||
376 | counter = 0 |
|
376 | counter = 0 | |
377 | for y in range(nrow): |
|
377 | for y in range(nrow): | |
378 | for x in range(ncol): |
|
378 | for x in range(ncol): | |
379 |
|
379 | |||
380 | if counter >= self.nplots: |
|
380 | if counter >= self.nplots: | |
381 | break |
|
381 | break | |
382 |
|
382 | |||
383 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
383 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
384 |
|
384 | |||
385 | if showprofile: |
|
385 | if showprofile: | |
386 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
386 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
387 |
|
387 | |||
388 | counter += 1 |
|
388 | counter += 1 | |
389 |
|
389 | |||
390 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
390 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
391 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
391 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
392 | save=False, figpath='./', figfile=None): |
|
392 | save=False, figpath='./', figfile=None): | |
393 |
|
393 | |||
394 | """ |
|
394 | """ | |
395 |
|
395 | |||
396 | Input: |
|
396 | Input: | |
397 | dataOut : |
|
397 | dataOut : | |
398 | idfigure : |
|
398 | idfigure : | |
399 | wintitle : |
|
399 | wintitle : | |
400 | channelList : |
|
400 | channelList : | |
401 | showProfile : |
|
401 | showProfile : | |
402 | xmin : None, |
|
402 | xmin : None, | |
403 | xmax : None, |
|
403 | xmax : None, | |
404 | ymin : None, |
|
404 | ymin : None, | |
405 | ymax : None, |
|
405 | ymax : None, | |
406 | zmin : None, |
|
406 | zmin : None, | |
407 | zmax : None |
|
407 | zmax : None | |
408 | """ |
|
408 | """ | |
409 |
|
409 | |||
410 | if channelList == None: |
|
410 | if channelList == None: | |
411 | channelIndexList = dataOut.channelIndexList |
|
411 | channelIndexList = dataOut.channelIndexList | |
412 | else: |
|
412 | else: | |
413 | channelIndexList = [] |
|
413 | channelIndexList = [] | |
414 | for channel in channelList: |
|
414 | for channel in channelList: | |
415 | if channel not in dataOut.channelList: |
|
415 | if channel not in dataOut.channelList: | |
416 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
416 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
417 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
417 | channelIndexList.append(dataOut.channelList.index(channel)) | |
418 |
|
418 | |||
419 | x = dataOut.getVelRange(1) |
|
419 | x = dataOut.getVelRange(1) | |
420 | y = dataOut.getHeiRange() |
|
420 | y = dataOut.getHeiRange() | |
421 |
|
421 | |||
422 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
422 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
423 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
423 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
424 | avg = numpy.average(z, axis=1) |
|
424 | avg = numpy.average(z, axis=1) | |
425 |
|
425 | |||
426 | noise = dataOut.getNoise() |
|
426 | noise = dataOut.getNoise() | |
427 |
|
427 | |||
428 | thisDatetime = dataOut.datatime |
|
428 | thisDatetime = dataOut.datatime | |
429 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
429 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
430 | xlabel = "Velocity (m/s)" |
|
430 | xlabel = "Velocity (m/s)" | |
431 | ylabel = "Range (Km)" |
|
431 | ylabel = "Range (Km)" | |
432 |
|
432 | |||
433 | if not self.__isConfig: |
|
433 | if not self.__isConfig: | |
434 |
|
434 | |||
435 | nplots = len(channelIndexList) |
|
435 | nplots = len(channelIndexList) | |
436 |
|
436 | |||
437 | self.setup(idfigure=idfigure, |
|
437 | self.setup(idfigure=idfigure, | |
438 | nplots=nplots, |
|
438 | nplots=nplots, | |
439 | wintitle=wintitle, |
|
439 | wintitle=wintitle, | |
440 | showprofile=showprofile) |
|
440 | showprofile=showprofile) | |
441 |
|
441 | |||
442 | if xmin == None: xmin = numpy.nanmin(x) |
|
442 | if xmin == None: xmin = numpy.nanmin(x) | |
443 | if xmax == None: xmax = numpy.nanmax(x) |
|
443 | if xmax == None: xmax = numpy.nanmax(x) | |
444 | if ymin == None: ymin = numpy.nanmin(y) |
|
444 | if ymin == None: ymin = numpy.nanmin(y) | |
445 | if ymax == None: ymax = numpy.nanmax(y) |
|
445 | if ymax == None: ymax = numpy.nanmax(y) | |
446 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
446 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
447 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
447 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
448 |
|
448 | |||
449 | self.__isConfig = True |
|
449 | self.__isConfig = True | |
450 |
|
450 | |||
451 | self.setWinTitle(title) |
|
451 | self.setWinTitle(title) | |
452 |
|
452 | |||
453 | for i in range(self.nplots): |
|
453 | for i in range(self.nplots): | |
454 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i]) |
|
454 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i]) | |
455 | axes = self.axesList[i*self.__nsubplots] |
|
455 | axes = self.axesList[i*self.__nsubplots] | |
456 | axes.pcolor(x, y, z[i,:,:], |
|
456 | axes.pcolor(x, y, z[i,:,:], | |
457 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
457 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
458 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
458 | xlabel=xlabel, ylabel=ylabel, title=title, | |
459 | ticksize=9, cblabel='') |
|
459 | ticksize=9, cblabel='') | |
460 |
|
460 | |||
461 | if self.__showprofile: |
|
461 | if self.__showprofile: | |
462 | axes = self.axesList[i*self.__nsubplots +1] |
|
462 | axes = self.axesList[i*self.__nsubplots +1] | |
463 | axes.pline(avg[i], y, |
|
463 | axes.pline(avg[i], y, | |
464 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
464 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
465 | xlabel='dB', ylabel='', title='', |
|
465 | xlabel='dB', ylabel='', title='', | |
466 | ytick_visible=False, |
|
466 | ytick_visible=False, | |
467 | grid='x') |
|
467 | grid='x') | |
468 |
|
468 | |||
469 | noiseline = numpy.repeat(noise[i], len(y)) |
|
469 | noiseline = numpy.repeat(noise[i], len(y)) | |
470 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
470 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
471 |
|
471 | |||
472 | self.draw() |
|
472 | self.draw() | |
473 |
|
473 | |||
474 | if save: |
|
474 | if save: | |
475 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
475 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
476 | if figfile == None: |
|
476 | if figfile == None: | |
477 | figfile = self.getFilename(name = date) |
|
477 | figfile = self.getFilename(name = date) | |
478 |
|
478 | |||
479 | self.saveFigure(figpath, figfile) |
|
479 | self.saveFigure(figpath, figfile) | |
480 |
|
480 | |||
481 | class Scope(Figure): |
|
481 | class Scope(Figure): | |
482 |
|
482 | |||
483 | __isConfig = None |
|
483 | __isConfig = None | |
484 |
|
484 | |||
485 | def __init__(self): |
|
485 | def __init__(self): | |
486 |
|
486 | |||
487 | self.__isConfig = False |
|
487 | self.__isConfig = False | |
488 | self.WIDTH = 600 |
|
488 | self.WIDTH = 600 | |
489 | self.HEIGHT = 200 |
|
489 | self.HEIGHT = 200 | |
490 |
|
490 | |||
491 | def getSubplots(self): |
|
491 | def getSubplots(self): | |
492 |
|
492 | |||
493 | nrow = self.nplots |
|
493 | nrow = self.nplots | |
494 | ncol = 3 |
|
494 | ncol = 3 | |
495 | return nrow, ncol |
|
495 | return nrow, ncol | |
496 |
|
496 | |||
497 | def setup(self, idfigure, nplots, wintitle): |
|
497 | def setup(self, idfigure, nplots, wintitle): | |
498 |
|
498 | |||
499 | self.nplots = nplots |
|
499 | self.nplots = nplots | |
500 |
|
500 | |||
501 | self.createFigure(idfigure, wintitle) |
|
501 | self.createFigure(idfigure, wintitle) | |
502 |
|
502 | |||
503 | nrow,ncol = self.getSubplots() |
|
503 | nrow,ncol = self.getSubplots() | |
504 | colspan = 3 |
|
504 | colspan = 3 | |
505 | rowspan = 1 |
|
505 | rowspan = 1 | |
506 |
|
506 | |||
507 | for i in range(nplots): |
|
507 | for i in range(nplots): | |
508 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
508 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
509 |
|
509 | |||
510 |
|
510 | |||
511 |
|
511 | |||
512 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
512 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
513 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
513 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
514 | figpath='./', figfile=None): |
|
514 | figpath='./', figfile=None): | |
515 |
|
515 | |||
516 | """ |
|
516 | """ | |
517 |
|
517 | |||
518 | Input: |
|
518 | Input: | |
519 | dataOut : |
|
519 | dataOut : | |
520 | idfigure : |
|
520 | idfigure : | |
521 | wintitle : |
|
521 | wintitle : | |
522 | channelList : |
|
522 | channelList : | |
523 | xmin : None, |
|
523 | xmin : None, | |
524 | xmax : None, |
|
524 | xmax : None, | |
525 | ymin : None, |
|
525 | ymin : None, | |
526 | ymax : None, |
|
526 | ymax : None, | |
527 | """ |
|
527 | """ | |
528 |
|
528 | |||
529 | if channelList == None: |
|
529 | if channelList == None: | |
530 | channelIndexList = dataOut.channelIndexList |
|
530 | channelIndexList = dataOut.channelIndexList | |
531 | else: |
|
531 | else: | |
532 | channelIndexList = [] |
|
532 | channelIndexList = [] | |
533 | for channel in channelList: |
|
533 | for channel in channelList: | |
534 | if channel not in dataOut.channelList: |
|
534 | if channel not in dataOut.channelList: | |
535 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
535 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
536 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
536 | channelIndexList.append(dataOut.channelList.index(channel)) | |
537 |
|
537 | |||
538 | x = dataOut.heightList |
|
538 | x = dataOut.heightList | |
539 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
539 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
540 | y = y.real |
|
540 | y = y.real | |
541 |
|
541 | |||
542 | thisDatetime = dataOut.datatime |
|
542 | thisDatetime = dataOut.datatime | |
543 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
543 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
544 | xlabel = "Range (Km)" |
|
544 | xlabel = "Range (Km)" | |
545 | ylabel = "Intensity" |
|
545 | ylabel = "Intensity" | |
546 |
|
546 | |||
547 | if not self.__isConfig: |
|
547 | if not self.__isConfig: | |
548 | nplots = len(channelIndexList) |
|
548 | nplots = len(channelIndexList) | |
549 |
|
549 | |||
550 | self.setup(idfigure=idfigure, |
|
550 | self.setup(idfigure=idfigure, | |
551 | nplots=nplots, |
|
551 | nplots=nplots, | |
552 | wintitle=wintitle) |
|
552 | wintitle=wintitle) | |
553 |
|
553 | |||
554 | if xmin == None: xmin = numpy.nanmin(x) |
|
554 | if xmin == None: xmin = numpy.nanmin(x) | |
555 | if xmax == None: xmax = numpy.nanmax(x) |
|
555 | if xmax == None: xmax = numpy.nanmax(x) | |
556 | if ymin == None: ymin = numpy.nanmin(y) |
|
556 | if ymin == None: ymin = numpy.nanmin(y) | |
557 | if ymax == None: ymax = numpy.nanmax(y) |
|
557 | if ymax == None: ymax = numpy.nanmax(y) | |
558 |
|
558 | |||
559 | self.__isConfig = True |
|
559 | self.__isConfig = True | |
560 |
|
560 | |||
561 | self.setWinTitle(title) |
|
561 | self.setWinTitle(title) | |
562 |
|
562 | |||
563 | for i in range(len(self.axesList)): |
|
563 | for i in range(len(self.axesList)): | |
564 | title = "Channel %d" %(i) |
|
564 | title = "Channel %d" %(i) | |
565 | axes = self.axesList[i] |
|
565 | axes = self.axesList[i] | |
566 | ychannel = y[i,:] |
|
566 | ychannel = y[i,:] | |
567 | axes.pline(x, ychannel, |
|
567 | axes.pline(x, ychannel, | |
568 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
568 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
569 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
569 | xlabel=xlabel, ylabel=ylabel, title=title) | |
570 |
|
570 | |||
571 | self.draw() |
|
571 | self.draw() | |
572 |
|
572 | |||
573 | if save: |
|
573 | if save: | |
574 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
574 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
575 | if figfile == None: |
|
575 | if figfile == None: | |
576 | figfile = self.getFilename(name = date) |
|
576 | figfile = self.getFilename(name = date) | |
577 |
|
577 | |||
578 | self.saveFigure(figpath, figfile) |
|
578 | self.saveFigure(figpath, figfile) | |
579 |
|
579 | |||
580 | class ProfilePlot(Figure): |
|
580 | class ProfilePlot(Figure): | |
581 | __isConfig = None |
|
581 | __isConfig = None | |
582 | __nsubplots = None |
|
582 | __nsubplots = None | |
583 |
|
583 | |||
584 | WIDTHPROF = None |
|
584 | WIDTHPROF = None | |
585 | HEIGHTPROF = None |
|
585 | HEIGHTPROF = None | |
586 | PREFIX = 'spcprofile' |
|
586 | PREFIX = 'spcprofile' | |
587 |
|
587 | |||
588 | def __init__(self): |
|
588 | def __init__(self): | |
589 | self.__isConfig = False |
|
589 | self.__isConfig = False | |
590 | self.__nsubplots = 1 |
|
590 | self.__nsubplots = 1 | |
591 |
|
591 | |||
592 | self.WIDTH = 300 |
|
592 | self.WIDTH = 300 | |
593 | self.HEIGHT = 500 |
|
593 | self.HEIGHT = 500 | |
594 |
|
594 | |||
595 | def getSubplots(self): |
|
595 | def getSubplots(self): | |
596 | ncol = 1 |
|
596 | ncol = 1 | |
597 | nrow = 1 |
|
597 | nrow = 1 | |
598 |
|
598 | |||
599 | return nrow, ncol |
|
599 | return nrow, ncol | |
600 |
|
600 | |||
601 | def setup(self, idfigure, nplots, wintitle): |
|
601 | def setup(self, idfigure, nplots, wintitle): | |
602 |
|
602 | |||
603 | self.nplots = nplots |
|
603 | self.nplots = nplots | |
604 |
|
604 | |||
605 | ncolspan = 1 |
|
605 | ncolspan = 1 | |
606 | colspan = 1 |
|
606 | colspan = 1 | |
607 |
|
607 | |||
608 | self.createFigure(idfigure = idfigure, |
|
608 | self.createFigure(idfigure = idfigure, | |
609 | wintitle = wintitle, |
|
609 | wintitle = wintitle, | |
610 | widthplot = self.WIDTH, |
|
610 | widthplot = self.WIDTH, | |
611 | heightplot = self.HEIGHT) |
|
611 | heightplot = self.HEIGHT) | |
612 |
|
612 | |||
613 | nrow, ncol = self.getSubplots() |
|
613 | nrow, ncol = self.getSubplots() | |
614 |
|
614 | |||
615 | counter = 0 |
|
615 | counter = 0 | |
616 | for y in range(nrow): |
|
616 | for y in range(nrow): | |
617 | for x in range(ncol): |
|
617 | for x in range(ncol): | |
618 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
618 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
619 |
|
619 | |||
620 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
620 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
621 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
621 | xmin=None, xmax=None, ymin=None, ymax=None, | |
622 | save=False, figpath='./', figfile=None): |
|
622 | save=False, figpath='./', figfile=None): | |
623 |
|
623 | |||
624 | if channelList == None: |
|
624 | if channelList == None: | |
625 | channelIndexList = dataOut.channelIndexList |
|
625 | channelIndexList = dataOut.channelIndexList | |
626 | channelList = dataOut.channelList |
|
626 | channelList = dataOut.channelList | |
627 | else: |
|
627 | else: | |
628 | channelIndexList = [] |
|
628 | channelIndexList = [] | |
629 | for channel in channelList: |
|
629 | for channel in channelList: | |
630 | if channel not in dataOut.channelList: |
|
630 | if channel not in dataOut.channelList: | |
631 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
631 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
632 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
632 | channelIndexList.append(dataOut.channelList.index(channel)) | |
633 |
|
633 | |||
634 |
|
634 | |||
635 | y = dataOut.getHeiRange() |
|
635 | y = dataOut.getHeiRange() | |
636 | x = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
636 | x = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
637 | avg = numpy.average(x, axis=1) |
|
637 | avg = numpy.average(x, axis=1) | |
638 |
|
638 | |||
639 | thisDatetime = dataOut.datatime |
|
639 | thisDatetime = dataOut.datatime | |
640 | title = "Power Profile" |
|
640 | title = "Power Profile" | |
641 | xlabel = "dB" |
|
641 | xlabel = "dB" | |
642 | ylabel = "Range (Km)" |
|
642 | ylabel = "Range (Km)" | |
643 |
|
643 | |||
644 | if not self.__isConfig: |
|
644 | if not self.__isConfig: | |
645 |
|
645 | |||
646 | nplots = 1 |
|
646 | nplots = 1 | |
647 |
|
647 | |||
648 | self.setup(idfigure=idfigure, |
|
648 | self.setup(idfigure=idfigure, | |
649 | nplots=nplots, |
|
649 | nplots=nplots, | |
650 | wintitle=wintitle) |
|
650 | wintitle=wintitle) | |
651 |
|
651 | |||
652 | if ymin == None: ymin = numpy.nanmin(y) |
|
652 | if ymin == None: ymin = numpy.nanmin(y) | |
653 | if ymax == None: ymax = numpy.nanmax(y) |
|
653 | if ymax == None: ymax = numpy.nanmax(y) | |
654 | if xmin == None: xmin = numpy.nanmin(avg)*0.9 |
|
654 | if xmin == None: xmin = numpy.nanmin(avg)*0.9 | |
655 | if xmax == None: xmax = numpy.nanmax(avg)*0.9 |
|
655 | if xmax == None: xmax = numpy.nanmax(avg)*0.9 | |
656 |
|
656 | |||
657 | self.__isConfig = True |
|
657 | self.__isConfig = True | |
658 |
|
658 | |||
659 | self.setWinTitle(title) |
|
659 | self.setWinTitle(title) | |
660 |
|
660 | |||
661 |
|
661 | |||
662 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
662 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
663 | axes = self.axesList[0] |
|
663 | axes = self.axesList[0] | |
664 |
|
664 | |||
665 | legendlabels = ["channel %d"%x for x in channelList] |
|
665 | legendlabels = ["channel %d"%x for x in channelList] | |
666 | axes.pmultiline(avg, y, |
|
666 | axes.pmultiline(avg, y, | |
667 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
667 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
668 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
668 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
669 | ytick_visible=True, nxticks=5, |
|
669 | ytick_visible=True, nxticks=5, | |
670 | grid='x') |
|
670 | grid='x') | |
671 |
|
671 | |||
672 | self.draw() |
|
672 | self.draw() | |
673 |
|
673 | |||
674 | if save: |
|
674 | if save: | |
675 | date = thisDatetime.strftime("%Y%m%d") |
|
675 | date = thisDatetime.strftime("%Y%m%d") | |
676 | if figfile == None: |
|
676 | if figfile == None: | |
677 | figfile = self.getFilename(name = date) |
|
677 | figfile = self.getFilename(name = date) | |
678 |
|
678 | |||
679 | self.saveFigure(figpath, figfile) |
|
679 | self.saveFigure(figpath, figfile) | |
680 |
|
680 | |||
681 | class CoherenceMap(Figure): |
|
681 | class CoherenceMap(Figure): | |
682 | __isConfig = None |
|
682 | __isConfig = None | |
683 | __nsubplots = None |
|
683 | __nsubplots = None | |
684 |
|
684 | |||
685 | WIDTHPROF = None |
|
685 | WIDTHPROF = None | |
686 | HEIGHTPROF = None |
|
686 | HEIGHTPROF = None | |
687 | PREFIX = 'coherencemap' |
|
687 | PREFIX = 'coherencemap' | |
688 |
|
688 | |||
689 | def __init__(self): |
|
689 | def __init__(self): | |
690 | self.timerange = 2*60*60 |
|
690 | self.timerange = 2*60*60 | |
691 | self.__isConfig = False |
|
691 | self.__isConfig = False | |
692 | self.__nsubplots = 1 |
|
692 | self.__nsubplots = 1 | |
693 |
|
693 | |||
694 | self.WIDTH = 800 |
|
694 | self.WIDTH = 800 | |
695 | self.HEIGHT = 200 |
|
695 | self.HEIGHT = 200 | |
696 | self.WIDTHPROF = 120 |
|
696 | self.WIDTHPROF = 120 | |
697 | self.HEIGHTPROF = 0 |
|
697 | self.HEIGHTPROF = 0 | |
698 |
|
698 | |||
699 | def getSubplots(self): |
|
699 | def getSubplots(self): | |
700 | ncol = 1 |
|
700 | ncol = 1 | |
701 | nrow = self.nplots*2 |
|
701 | nrow = self.nplots*2 | |
702 |
|
702 | |||
703 | return nrow, ncol |
|
703 | return nrow, ncol | |
704 |
|
704 | |||
705 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
705 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
706 | self.__showprofile = showprofile |
|
706 | self.__showprofile = showprofile | |
707 | self.nplots = nplots |
|
707 | self.nplots = nplots | |
708 |
|
708 | |||
709 | ncolspan = 1 |
|
709 | ncolspan = 1 | |
710 | colspan = 1 |
|
710 | colspan = 1 | |
711 | if showprofile: |
|
711 | if showprofile: | |
712 | ncolspan = 7 |
|
712 | ncolspan = 7 | |
713 | colspan = 6 |
|
713 | colspan = 6 | |
714 | self.__nsubplots = 2 |
|
714 | self.__nsubplots = 2 | |
715 |
|
715 | |||
716 | self.createFigure(idfigure = idfigure, |
|
716 | self.createFigure(idfigure = idfigure, | |
717 | wintitle = wintitle, |
|
717 | wintitle = wintitle, | |
718 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
718 | widthplot = self.WIDTH + self.WIDTHPROF, | |
719 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
719 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
720 |
|
720 | |||
721 | nrow, ncol = self.getSubplots() |
|
721 | nrow, ncol = self.getSubplots() | |
722 |
|
722 | |||
723 | for y in range(nrow): |
|
723 | for y in range(nrow): | |
724 | for x in range(ncol): |
|
724 | for x in range(ncol): | |
725 |
|
725 | |||
726 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
726 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
727 |
|
727 | |||
728 | if showprofile: |
|
728 | if showprofile: | |
729 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
729 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
730 |
|
730 | |||
731 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
731 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
732 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
732 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
733 | timerange=None, |
|
733 | timerange=None, | |
734 | save=False, figpath='./', figfile=None): |
|
734 | save=False, figpath='./', figfile=None): | |
735 |
|
735 | |||
736 | if pairsList == None: |
|
736 | if pairsList == None: | |
737 | pairsIndexList = dataOut.pairsIndexList |
|
737 | pairsIndexList = dataOut.pairsIndexList | |
738 | else: |
|
738 | else: | |
739 | pairsIndexList = [] |
|
739 | pairsIndexList = [] | |
740 | for pair in pairsList: |
|
740 | for pair in pairsList: | |
741 | if pair not in dataOut.pairsList: |
|
741 | if pair not in dataOut.pairsList: | |
742 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
742 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
743 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
743 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
744 |
|
744 | |||
745 | if timerange != None: |
|
745 | if timerange != None: | |
746 | self.timerange = timerange |
|
746 | self.timerange = timerange | |
747 |
|
747 | |||
748 | if pairsIndexList == []: |
|
748 | if pairsIndexList == []: | |
749 | return |
|
749 | return | |
750 |
|
750 | |||
751 | if len(pairsIndexList) > 4: |
|
751 | if len(pairsIndexList) > 4: | |
752 | pairsIndexList = pairsIndexList[0:4] |
|
752 | pairsIndexList = pairsIndexList[0:4] | |
753 |
|
753 | |||
754 | tmin = None |
|
754 | tmin = None | |
755 | tmax = None |
|
755 | tmax = None | |
756 | x = dataOut.getTimeRange() |
|
756 | x = dataOut.getTimeRange() | |
757 | y = dataOut.getHeiRange() |
|
757 | y = dataOut.getHeiRange() | |
758 |
|
758 | |||
759 | thisDatetime = dataOut.datatime |
|
759 | thisDatetime = dataOut.datatime | |
760 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
760 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
761 | xlabel = "" |
|
761 | xlabel = "" | |
762 | ylabel = "Range (Km)" |
|
762 | ylabel = "Range (Km)" | |
763 |
|
763 | |||
764 | if not self.__isConfig: |
|
764 | if not self.__isConfig: | |
765 | nplots = len(pairsIndexList) |
|
765 | nplots = len(pairsIndexList) | |
766 | self.setup(idfigure=idfigure, |
|
766 | self.setup(idfigure=idfigure, | |
767 | nplots=nplots, |
|
767 | nplots=nplots, | |
768 | wintitle=wintitle, |
|
768 | wintitle=wintitle, | |
769 | showprofile=showprofile) |
|
769 | showprofile=showprofile) | |
770 |
|
770 | |||
771 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
771 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
772 | if ymin == None: ymin = numpy.nanmin(y) |
|
772 | if ymin == None: ymin = numpy.nanmin(y) | |
773 | if ymax == None: ymax = numpy.nanmax(y) |
|
773 | if ymax == None: ymax = numpy.nanmax(y) | |
774 |
|
774 | |||
775 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
775 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
776 |
|
776 | |||
777 | self.__isConfig = True |
|
777 | self.__isConfig = True | |
778 |
|
778 | |||
779 | self.setWinTitle(title) |
|
779 | self.setWinTitle(title) | |
780 |
|
780 | |||
781 | for i in range(self.nplots): |
|
781 | for i in range(self.nplots): | |
782 |
|
782 | |||
783 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
783 | pair = dataOut.pairsList[pairsIndexList[i]] | |
784 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
784 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
785 | coherence = numpy.abs(coherenceComplex) |
|
785 | coherence = numpy.abs(coherenceComplex) | |
786 | avg = numpy.average(coherence, axis=0) |
|
786 | avg = numpy.average(coherence, axis=0) | |
787 | z = avg.reshape((1,-1)) |
|
787 | z = avg.reshape((1,-1)) | |
788 |
|
788 | |||
789 | counter = 0 |
|
789 | counter = 0 | |
790 |
|
790 | |||
791 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
791 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
792 | axes = self.axesList[i*self.__nsubplots*2] |
|
792 | axes = self.axesList[i*self.__nsubplots*2] | |
793 | axes.pcolor(x, y, z, |
|
793 | axes.pcolor(x, y, z, | |
794 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
794 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
795 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
795 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
796 | ticksize=9, cblabel='', cbsize="1%") |
|
796 | ticksize=9, cblabel='', cbsize="1%") | |
797 |
|
797 | |||
798 | if self.__showprofile: |
|
798 | if self.__showprofile: | |
799 | counter += 1 |
|
799 | counter += 1 | |
800 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
800 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
801 | axes.pline(avg, y, |
|
801 | axes.pline(avg, y, | |
802 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
802 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, | |
803 | xlabel='', ylabel='', title='', ticksize=7, |
|
803 | xlabel='', ylabel='', title='', ticksize=7, | |
804 | ytick_visible=False, nxticks=5, |
|
804 | ytick_visible=False, nxticks=5, | |
805 | grid='x') |
|
805 | grid='x') | |
806 |
|
806 | |||
807 | counter += 1 |
|
807 | counter += 1 | |
808 | phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
808 | phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
809 | avg = numpy.average(phase, axis=0) |
|
809 | avg = numpy.average(phase, axis=0) | |
810 | z = avg.reshape((1,-1)) |
|
810 | z = avg.reshape((1,-1)) | |
811 |
|
811 | |||
812 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
812 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
813 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
813 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
814 | axes.pcolor(x, y, z, |
|
814 | axes.pcolor(x, y, z, | |
815 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
815 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
816 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
816 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
817 | ticksize=9, cblabel='', colormap='RdBu', cbsize="1%") |
|
817 | ticksize=9, cblabel='', colormap='RdBu', cbsize="1%") | |
818 |
|
818 | |||
819 | if self.__showprofile: |
|
819 | if self.__showprofile: | |
820 | counter += 1 |
|
820 | counter += 1 | |
821 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
821 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
822 | axes.pline(avg, y, |
|
822 | axes.pline(avg, y, | |
823 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
823 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
824 | xlabel='', ylabel='', title='', ticksize=7, |
|
824 | xlabel='', ylabel='', title='', ticksize=7, | |
825 | ytick_visible=False, nxticks=4, |
|
825 | ytick_visible=False, nxticks=4, | |
826 | grid='x') |
|
826 | grid='x') | |
827 |
|
827 | |||
828 | self.draw() |
|
828 | self.draw() | |
829 |
|
829 | |||
830 | if save: |
|
830 | if save: | |
831 |
|
831 | |||
832 | if figfile == None: |
|
832 | if figfile == None: | |
833 | figfile = self.getFilename(name = self.name) |
|
833 | figfile = self.getFilename(name = self.name) | |
834 |
|
834 | |||
835 | self.saveFigure(figpath, figfile) |
|
835 | self.saveFigure(figpath, figfile) | |
836 |
|
836 | |||
837 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
837 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
838 | self.__isConfig = False |
|
838 | self.__isConfig = False | |
839 |
|
839 | |||
840 | class RTIfromNoise(Figure): |
|
840 | 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 | |||
865 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
863 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
866 |
|
864 | |||
867 | self.__showprofile = showprofile |
|
865 | self.__showprofile = showprofile | |
868 | self.nplots = nplots |
|
866 | self.nplots = nplots | |
869 |
|
867 | |||
870 | ncolspan = 1 |
|
868 | ncolspan = 1 | |
871 | colspan = 1 |
|
869 | colspan = 1 | |
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: | |
922 | if channel not in dataOut.channelList: |
|
891 | if channel not in dataOut.channelList: | |
923 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
892 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
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 |
|
|||
934 | # z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
|||
935 | # avg = numpy.average(z, axis=1) |
|
|||
936 |
|
902 | |||
937 | noise = dataOut.getNoise() |
|
903 | noise = dataOut.getNoise() | |
938 |
|
904 | |||
939 | thisDatetime = dataOut.datatime |
|
905 | thisDatetime = dataOut.datatime | |
940 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
906 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
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, | |
|
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 | ) | |||
973 |
|
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 | |||
984 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
952 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
985 | self.__isConfig = False |
|
953 | self.__isConfig = False | |
986 | No newline at end of file |
|
954 |
General Comments 0
You need to be logged in to leave comments.
Login now