@@ -1,131 +1,132 | |||||
1 | # Signal Chain |
|
1 | # Signal Chain | |
2 |
|
2 | |||
3 | ## Introduction |
|
3 | ## Introduction | |
4 |
|
4 | |||
5 | Signal Chain (SCh) is a radar data processing library developed using [Python](www.python.org) at JRO. SCh provides modules to read, write, process and plot data. |
|
5 | Signal Chain (SCh) is a radar data processing library developed using [Python](www.python.org) at JRO. SCh provides modules to read, write, process and plot data. | |
6 |
|
6 | |||
7 | ## Installation |
|
7 | ## Installation | |
8 |
|
8 | |||
9 |
Install system dependencies, |
|
9 | Install system dependencies, clone the latest version from [git](http://jro-dev.igp.gob.pe/rhodecode/schain/) and install it as a normal python package. | |
10 |
|
10 | |||
11 | ``` |
|
11 | ``` | |
12 | $ sudo apt-get install python-pip python-dev gfortran libpng-dev freetype* libblas-dev liblapack-dev libatlas-base-dev python-qt4 python-tk libssl-dev libhdf5-dev |
|
12 | $ sudo apt-get install python-pip python-dev gfortran libpng-dev freetype* libblas-dev liblapack-dev libatlas-base-dev python-qt4 python-tk libssl-dev libhdf5-dev | |
13 | $ tar xvzf schainpy-2.2.5.tar.gz |
|
13 | $ sudo pip install numpy | |
14 | $ cd schainpy-2.2.5 |
|
14 | $ git clone http://jro-dev.igp.gob.pe/rhodecode/schain/ | |
|
15 | $ cd schain | |||
15 | $ sudo pip install ./ |
|
16 | $ sudo pip install ./ | |
16 | ``` |
|
17 | ``` | |
17 |
|
18 | |||
18 | **Its recommended to install schain in a virtual environment** |
|
19 | **Its recommended to install schain in a virtual environment** | |
19 |
|
20 | |||
20 | ``` |
|
21 | ``` | |
21 | $ sudo pip install virtualenv |
|
22 | $ sudo pip install virtualenv | |
22 | $ virtualenv /path/to/virtual --system-site-packages |
|
23 | $ virtualenv /path/to/virtual --system-site-packages | |
23 | $ source /path/to/virtual/bin/activate |
|
24 | $ source /path/to/virtual/bin/activate | |
24 |
(virtual) $ cd schain |
|
25 | (virtual) $ cd schain | |
25 | (virtual) $ pip install ./ |
|
26 | (virtual) $ pip install ./ | |
26 | ``` |
|
27 | ``` | |
27 |
|
28 | |||
28 | ## First Script |
|
29 | ## First Script | |
29 |
|
30 | |||
30 | Read Spectra data (.pdata) - remove dc - plot spectra & RTI |
|
31 | Read Spectra data (.pdata) - remove dc - plot spectra & RTI | |
31 |
|
32 | |||
32 | Import SCh and creating a project |
|
33 | Import SCh and creating a project | |
33 |
|
34 | |||
34 | ```python |
|
35 | ```python | |
35 | #!/usr/bin/python |
|
36 | #!/usr/bin/python | |
36 |
|
37 | |||
37 | from schainpy.controller import Project |
|
38 | from schainpy.controller import Project | |
38 |
|
39 | |||
39 | controller = Project() |
|
40 | controller = Project() | |
40 | controller.setup(id = '100', |
|
41 | controller.setup(id = '100', | |
41 | name='test', |
|
42 | name='test', | |
42 | description='Basic experiment') |
|
43 | description='Basic experiment') | |
43 |
|
44 | |||
44 |
|
45 | |||
45 | ``` |
|
46 | ``` | |
46 |
|
47 | |||
47 | Adding read unit and operations |
|
48 | Adding read unit and operations | |
48 |
|
49 | |||
49 | ```python |
|
50 | ```python | |
50 | read_unit = controller.addReadUnit(datatype='Spectra', |
|
51 | read_unit = controller.addReadUnit(datatype='Spectra', | |
51 | path='/path/to/pdata/', |
|
52 | path='/path/to/pdata/', | |
52 | startDate='2014/01/31', |
|
53 | startDate='2014/01/31', | |
53 | endDate='2014/03/31', |
|
54 | endDate='2014/03/31', | |
54 | startTime='00:00:00', |
|
55 | startTime='00:00:00', | |
55 | endTime='23:59:59', |
|
56 | endTime='23:59:59', | |
56 | online=0, |
|
57 | online=0, | |
57 | walk=0) |
|
58 | walk=0) | |
58 |
|
59 | |||
59 | proc_unit = controller.addProcUnit(datatype='Spectra', |
|
60 | proc_unit = controller.addProcUnit(datatype='Spectra', | |
60 | inputId=read_unit.getId()) |
|
61 | inputId=read_unit.getId()) | |
61 |
|
62 | |||
62 | op = proc_unit.addOperation(name='selectChannels') |
|
63 | op = proc_unit.addOperation(name='selectChannels') | |
63 | op.addParameter(name='channelList', value='0,1', format='intlist') |
|
64 | op.addParameter(name='channelList', value='0,1', format='intlist') | |
64 |
|
65 | |||
65 | op = proc_unit.addOperation(name='selectHeights') |
|
66 | op = proc_unit.addOperation(name='selectHeights') | |
66 | op.addParameter(name='minHei', value='80', format='float') |
|
67 | op.addParameter(name='minHei', value='80', format='float') | |
67 | op.addParameter(name='maxHei', value='200', format='float') |
|
68 | op.addParameter(name='maxHei', value='200', format='float') | |
68 |
|
69 | |||
69 | op = proc_unit.addOperation(name='removeDC') |
|
70 | op = proc_unit.addOperation(name='removeDC') | |
70 |
|
71 | |||
71 | ``` |
|
72 | ``` | |
72 |
|
73 | |||
73 | Plotting data & start project |
|
74 | Plotting data & start project | |
74 |
|
75 | |||
75 | ```python |
|
76 | ```python | |
76 | op = proc_unit.addOperation(name='SpectraPlot', optype='other') |
|
77 | op = proc_unit.addOperation(name='SpectraPlot', optype='other') | |
77 | op.addParameter(name='id', value='1', format='int') |
|
78 | op.addParameter(name='id', value='1', format='int') | |
78 | op.addParameter(name='wintitle', value='Spectra', format='str') |
|
79 | op.addParameter(name='wintitle', value='Spectra', format='str') | |
79 |
|
80 | |||
80 | op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
81 | op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
81 | op.addParameter(name='id', value='2', format='int') |
|
82 | op.addParameter(name='id', value='2', format='int') | |
82 | op.addParameter(name='wintitle', value='RTI', format='str') |
|
83 | op.addParameter(name='wintitle', value='RTI', format='str') | |
83 |
|
84 | |||
84 | controller.start() |
|
85 | controller.start() | |
85 |
|
86 | |||
86 | ``` |
|
87 | ``` | |
87 |
|
88 | |||
88 | Full script |
|
89 | Full script | |
89 |
|
90 | |||
90 |
|
91 | |||
91 | ```python |
|
92 | ```python | |
92 | #!/usr/bin/python |
|
93 | #!/usr/bin/python | |
93 |
|
94 | |||
94 | from schainpy.controller import Project |
|
95 | from schainpy.controller import Project | |
95 |
|
96 | |||
96 | controller = Project() |
|
97 | controller = Project() | |
97 | controller.setup(id = '100', |
|
98 | controller.setup(id = '100', | |
98 | name='test', |
|
99 | name='test', | |
99 | description='Basic experiment') |
|
100 | description='Basic experiment') | |
100 | read_unit = controller.addReadUnit(datatype='Spectra', |
|
101 | read_unit = controller.addReadUnit(datatype='Spectra', | |
101 | path='/path/to/pdata/', |
|
102 | path='/path/to/pdata/', | |
102 | startDate='2014/01/31', |
|
103 | startDate='2014/01/31', | |
103 | endDate='2014/03/31', |
|
104 | endDate='2014/03/31', | |
104 | startTime='00:00:00', |
|
105 | startTime='00:00:00', | |
105 | endTime='23:59:59', |
|
106 | endTime='23:59:59', | |
106 | online=0, |
|
107 | online=0, | |
107 | walk=0) |
|
108 | walk=0) | |
108 |
|
109 | |||
109 | proc_unit = controller.addProcUnit(datatype='Spectra', |
|
110 | proc_unit = controller.addProcUnit(datatype='Spectra', | |
110 | inputId=read_unit.getId()) |
|
111 | inputId=read_unit.getId()) | |
111 |
|
112 | |||
112 | op = proc_unit.addOperation(name='selectChannels') |
|
113 | op = proc_unit.addOperation(name='selectChannels') | |
113 | op.addParameter(name='channelList', value='0,1', format='intlist') |
|
114 | op.addParameter(name='channelList', value='0,1', format='intlist') | |
114 |
|
115 | |||
115 | op = proc_unit.addOperation(name='selectHeights') |
|
116 | op = proc_unit.addOperation(name='selectHeights') | |
116 | op.addParameter(name='minHei', value='80', format='float') |
|
117 | op.addParameter(name='minHei', value='80', format='float') | |
117 | op.addParameter(name='maxHei', value='200', format='float') |
|
118 | op.addParameter(name='maxHei', value='200', format='float') | |
118 |
|
119 | |||
119 | op = proc_unit.addOperation(name='removeDC') |
|
120 | op = proc_unit.addOperation(name='removeDC') | |
120 |
|
121 | |||
121 | op = proc_unit.addOperation(name='SpectraPlot', optype='other') |
|
122 | op = proc_unit.addOperation(name='SpectraPlot', optype='other') | |
122 | op.addParameter(name='id', value='6', format='int') |
|
123 | op.addParameter(name='id', value='6', format='int') | |
123 | op.addParameter(name='wintitle', value='Spectra', format='str') |
|
124 | op.addParameter(name='wintitle', value='Spectra', format='str') | |
124 |
|
125 | |||
125 | op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
126 | op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
126 | op.addParameter(name='id', value='2', format='int') |
|
127 | op.addParameter(name='id', value='2', format='int') | |
127 | op.addParameter(name='wintitle', value='RTI', format='str') |
|
128 | op.addParameter(name='wintitle', value='RTI', format='str') | |
128 |
|
129 | |||
129 | controller.start() |
|
130 | controller.start() | |
130 |
|
131 | |||
131 | ``` |
|
132 | ``` |
@@ -1,1329 +1,1333 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on September , 2012 |
|
2 | Created on September , 2012 | |
3 | @author: |
|
3 | @author: | |
4 | ''' |
|
4 | ''' | |
5 |
|
5 | |||
6 | import sys |
|
6 | import sys | |
7 | import ast |
|
7 | import ast | |
8 | import datetime |
|
8 | import datetime | |
9 | import traceback |
|
9 | import traceback | |
10 | import math |
|
10 | import math | |
11 | import time |
|
11 | import time | |
12 | from multiprocessing import Process, Queue, cpu_count |
|
12 | from multiprocessing import Process, Queue, cpu_count | |
13 | from profilehooks import profile, coverage |
|
13 | from profilehooks import profile, coverage | |
14 |
|
14 | |||
15 | import schainpy |
|
15 | import schainpy | |
16 | import schainpy.admin |
|
16 | import schainpy.admin | |
17 |
|
17 | |||
18 | from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring |
|
18 | from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring | |
19 | from xml.dom import minidom |
|
19 | from xml.dom import minidom | |
20 |
|
20 | |||
21 | from schainpy.model import * |
|
21 | from schainpy.model import * | |
22 | from time import sleep |
|
22 | from time import sleep | |
23 |
|
23 | |||
24 |
|
24 | |||
25 |
|
25 | |||
26 | def prettify(elem): |
|
26 | def prettify(elem): | |
27 | """Return a pretty-printed XML string for the Element. |
|
27 | """Return a pretty-printed XML string for the Element. | |
28 | """ |
|
28 | """ | |
29 | rough_string = tostring(elem, 'utf-8') |
|
29 | rough_string = tostring(elem, 'utf-8') | |
30 | reparsed = minidom.parseString(rough_string) |
|
30 | reparsed = minidom.parseString(rough_string) | |
31 | return reparsed.toprettyxml(indent=" ") |
|
31 | return reparsed.toprettyxml(indent=" ") | |
32 |
|
32 | |||
33 | def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False): |
|
33 | def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False): | |
34 | skip = 0 |
|
34 | skip = 0 | |
35 | cursor = 0 |
|
35 | cursor = 0 | |
36 | nFiles = None |
|
36 | nFiles = None | |
37 | processes = [] |
|
37 | processes = [] | |
38 | dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d') |
|
38 | dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d') | |
39 | dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d') |
|
39 | dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d') | |
40 | days = (dt2 - dt1).days |
|
40 | days = (dt2 - dt1).days | |
41 |
|
41 | |||
42 | for day in range(days+1): |
|
42 | for day in range(days+1): | |
43 | skip = 0 |
|
43 | skip = 0 | |
44 | cursor = 0 |
|
44 | cursor = 0 | |
45 | q = Queue() |
|
45 | q = Queue() | |
46 | processes = [] |
|
46 | processes = [] | |
47 | dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d') |
|
47 | dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d') | |
48 | firstProcess = Process(target=child, args=(cursor, skip, q, dt)) |
|
48 | firstProcess = Process(target=child, args=(cursor, skip, q, dt)) | |
49 | firstProcess.start() |
|
49 | firstProcess.start() | |
50 | if by_day: |
|
50 | if by_day: | |
51 | continue |
|
51 | continue | |
52 | nFiles = q.get() |
|
52 | nFiles = q.get() | |
|
53 | if nFiles==0: | |||
|
54 | continue | |||
53 | firstProcess.terminate() |
|
55 | firstProcess.terminate() | |
54 | skip = int(math.ceil(nFiles/nProcess)) |
|
56 | skip = int(math.ceil(nFiles/nProcess)) | |
55 | while True: |
|
57 | while True: | |
56 | processes.append(Process(target=child, args=(cursor, skip, q, dt))) |
|
58 | processes.append(Process(target=child, args=(cursor, skip, q, dt))) | |
57 | processes[cursor].start() |
|
59 | processes[cursor].start() | |
58 | if nFiles < cursor*skip: |
|
60 | if nFiles < cursor*skip: | |
59 | break |
|
61 | break | |
60 | cursor += 1 |
|
62 | cursor += 1 | |
61 |
|
63 | |||
62 | def beforeExit(exctype, value, trace): |
|
64 | def beforeExit(exctype, value, trace): | |
63 | for process in processes: |
|
65 | for process in processes: | |
64 | process.terminate() |
|
66 | process.terminate() | |
65 | process.join() |
|
67 | process.join() | |
66 | print traceback.print_tb(trace) |
|
68 | print traceback.print_tb(trace) | |
67 |
|
69 | |||
68 | sys.excepthook = beforeExit |
|
70 | sys.excepthook = beforeExit | |
69 |
|
71 | |||
70 | for process in processes: |
|
72 | for process in processes: | |
71 | process.join() |
|
73 | process.join() | |
72 | process.terminate() |
|
74 | process.terminate() | |
|
75 | ||||
73 | time.sleep(3) |
|
76 | time.sleep(3) | |
74 |
|
77 | |||
|
78 | ||||
75 | class ParameterConf(): |
|
79 | class ParameterConf(): | |
76 |
|
80 | |||
77 | id = None |
|
81 | id = None | |
78 | name = None |
|
82 | name = None | |
79 | value = None |
|
83 | value = None | |
80 | format = None |
|
84 | format = None | |
81 |
|
85 | |||
82 | __formated_value = None |
|
86 | __formated_value = None | |
83 |
|
87 | |||
84 | ELEMENTNAME = 'Parameter' |
|
88 | ELEMENTNAME = 'Parameter' | |
85 |
|
89 | |||
86 | def __init__(self): |
|
90 | def __init__(self): | |
87 |
|
91 | |||
88 | self.format = 'str' |
|
92 | self.format = 'str' | |
89 |
|
93 | |||
90 | def getElementName(self): |
|
94 | def getElementName(self): | |
91 |
|
95 | |||
92 | return self.ELEMENTNAME |
|
96 | return self.ELEMENTNAME | |
93 |
|
97 | |||
94 | def getValue(self): |
|
98 | def getValue(self): | |
95 |
|
99 | |||
96 | value = self.value |
|
100 | value = self.value | |
97 | format = self.format |
|
101 | format = self.format | |
98 |
|
102 | |||
99 | if self.__formated_value != None: |
|
103 | if self.__formated_value != None: | |
100 |
|
104 | |||
101 | return self.__formated_value |
|
105 | return self.__formated_value | |
102 |
|
106 | |||
103 | if format == 'obj': |
|
107 | if format == 'obj': | |
104 | return value |
|
108 | return value | |
105 |
|
109 | |||
106 | if format == 'str': |
|
110 | if format == 'str': | |
107 | self.__formated_value = str(value) |
|
111 | self.__formated_value = str(value) | |
108 | return self.__formated_value |
|
112 | return self.__formated_value | |
109 |
|
113 | |||
110 | if value == '': |
|
114 | if value == '': | |
111 | raise ValueError, "%s: This parameter value is empty" %self.name |
|
115 | raise ValueError, "%s: This parameter value is empty" %self.name | |
112 |
|
116 | |||
113 | if format == 'list': |
|
117 | if format == 'list': | |
114 | strList = value.split(',') |
|
118 | strList = value.split(',') | |
115 |
|
119 | |||
116 | self.__formated_value = strList |
|
120 | self.__formated_value = strList | |
117 |
|
121 | |||
118 | return self.__formated_value |
|
122 | return self.__formated_value | |
119 |
|
123 | |||
120 | if format == 'intlist': |
|
124 | if format == 'intlist': | |
121 | """ |
|
125 | """ | |
122 | Example: |
|
126 | Example: | |
123 | value = (0,1,2) |
|
127 | value = (0,1,2) | |
124 | """ |
|
128 | """ | |
125 |
|
129 | |||
126 | new_value = ast.literal_eval(value) |
|
130 | new_value = ast.literal_eval(value) | |
127 |
|
131 | |||
128 | if type(new_value) not in (tuple, list): |
|
132 | if type(new_value) not in (tuple, list): | |
129 | new_value = [int(new_value)] |
|
133 | new_value = [int(new_value)] | |
130 |
|
134 | |||
131 | self.__formated_value = new_value |
|
135 | self.__formated_value = new_value | |
132 |
|
136 | |||
133 | return self.__formated_value |
|
137 | return self.__formated_value | |
134 |
|
138 | |||
135 | if format == 'floatlist': |
|
139 | if format == 'floatlist': | |
136 | """ |
|
140 | """ | |
137 | Example: |
|
141 | Example: | |
138 | value = (0.5, 1.4, 2.7) |
|
142 | value = (0.5, 1.4, 2.7) | |
139 | """ |
|
143 | """ | |
140 |
|
144 | |||
141 | new_value = ast.literal_eval(value) |
|
145 | new_value = ast.literal_eval(value) | |
142 |
|
146 | |||
143 | if type(new_value) not in (tuple, list): |
|
147 | if type(new_value) not in (tuple, list): | |
144 | new_value = [float(new_value)] |
|
148 | new_value = [float(new_value)] | |
145 |
|
149 | |||
146 | self.__formated_value = new_value |
|
150 | self.__formated_value = new_value | |
147 |
|
151 | |||
148 | return self.__formated_value |
|
152 | return self.__formated_value | |
149 |
|
153 | |||
150 | if format == 'date': |
|
154 | if format == 'date': | |
151 | strList = value.split('/') |
|
155 | strList = value.split('/') | |
152 | intList = [int(x) for x in strList] |
|
156 | intList = [int(x) for x in strList] | |
153 | date = datetime.date(intList[0], intList[1], intList[2]) |
|
157 | date = datetime.date(intList[0], intList[1], intList[2]) | |
154 |
|
158 | |||
155 | self.__formated_value = date |
|
159 | self.__formated_value = date | |
156 |
|
160 | |||
157 | return self.__formated_value |
|
161 | return self.__formated_value | |
158 |
|
162 | |||
159 | if format == 'time': |
|
163 | if format == 'time': | |
160 | strList = value.split(':') |
|
164 | strList = value.split(':') | |
161 | intList = [int(x) for x in strList] |
|
165 | intList = [int(x) for x in strList] | |
162 | time = datetime.time(intList[0], intList[1], intList[2]) |
|
166 | time = datetime.time(intList[0], intList[1], intList[2]) | |
163 |
|
167 | |||
164 | self.__formated_value = time |
|
168 | self.__formated_value = time | |
165 |
|
169 | |||
166 | return self.__formated_value |
|
170 | return self.__formated_value | |
167 |
|
171 | |||
168 | if format == 'pairslist': |
|
172 | if format == 'pairslist': | |
169 | """ |
|
173 | """ | |
170 | Example: |
|
174 | Example: | |
171 | value = (0,1),(1,2) |
|
175 | value = (0,1),(1,2) | |
172 | """ |
|
176 | """ | |
173 |
|
177 | |||
174 | new_value = ast.literal_eval(value) |
|
178 | new_value = ast.literal_eval(value) | |
175 |
|
179 | |||
176 | if type(new_value) not in (tuple, list): |
|
180 | if type(new_value) not in (tuple, list): | |
177 | raise ValueError, "%s has to be a tuple or list of pairs" %value |
|
181 | raise ValueError, "%s has to be a tuple or list of pairs" %value | |
178 |
|
182 | |||
179 | if type(new_value[0]) not in (tuple, list): |
|
183 | if type(new_value[0]) not in (tuple, list): | |
180 | if len(new_value) != 2: |
|
184 | if len(new_value) != 2: | |
181 | raise ValueError, "%s has to be a tuple or list of pairs" %value |
|
185 | raise ValueError, "%s has to be a tuple or list of pairs" %value | |
182 | new_value = [new_value] |
|
186 | new_value = [new_value] | |
183 |
|
187 | |||
184 | for thisPair in new_value: |
|
188 | for thisPair in new_value: | |
185 | if len(thisPair) != 2: |
|
189 | if len(thisPair) != 2: | |
186 | raise ValueError, "%s has to be a tuple or list of pairs" %value |
|
190 | raise ValueError, "%s has to be a tuple or list of pairs" %value | |
187 |
|
191 | |||
188 | self.__formated_value = new_value |
|
192 | self.__formated_value = new_value | |
189 |
|
193 | |||
190 | return self.__formated_value |
|
194 | return self.__formated_value | |
191 |
|
195 | |||
192 | if format == 'multilist': |
|
196 | if format == 'multilist': | |
193 | """ |
|
197 | """ | |
194 | Example: |
|
198 | Example: | |
195 | value = (0,1,2),(3,4,5) |
|
199 | value = (0,1,2),(3,4,5) | |
196 | """ |
|
200 | """ | |
197 | multiList = ast.literal_eval(value) |
|
201 | multiList = ast.literal_eval(value) | |
198 |
|
202 | |||
199 | if type(multiList[0]) == int: |
|
203 | if type(multiList[0]) == int: | |
200 | multiList = ast.literal_eval("(" + value + ")") |
|
204 | multiList = ast.literal_eval("(" + value + ")") | |
201 |
|
205 | |||
202 | self.__formated_value = multiList |
|
206 | self.__formated_value = multiList | |
203 |
|
207 | |||
204 | return self.__formated_value |
|
208 | return self.__formated_value | |
205 |
|
209 | |||
206 | if format == 'bool': |
|
210 | if format == 'bool': | |
207 | value = int(value) |
|
211 | value = int(value) | |
208 |
|
212 | |||
209 | if format == 'int': |
|
213 | if format == 'int': | |
210 | value = float(value) |
|
214 | value = float(value) | |
211 |
|
215 | |||
212 | format_func = eval(format) |
|
216 | format_func = eval(format) | |
213 |
|
217 | |||
214 | self.__formated_value = format_func(value) |
|
218 | self.__formated_value = format_func(value) | |
215 |
|
219 | |||
216 | return self.__formated_value |
|
220 | return self.__formated_value | |
217 |
|
221 | |||
218 | def updateId(self, new_id): |
|
222 | def updateId(self, new_id): | |
219 |
|
223 | |||
220 | self.id = str(new_id) |
|
224 | self.id = str(new_id) | |
221 |
|
225 | |||
222 | def setup(self, id, name, value, format='str'): |
|
226 | def setup(self, id, name, value, format='str'): | |
223 | self.id = str(id) |
|
227 | self.id = str(id) | |
224 | self.name = name |
|
228 | self.name = name | |
225 | if format == 'obj': |
|
229 | if format == 'obj': | |
226 | self.value = value |
|
230 | self.value = value | |
227 | else: |
|
231 | else: | |
228 | self.value = str(value) |
|
232 | self.value = str(value) | |
229 | self.format = str.lower(format) |
|
233 | self.format = str.lower(format) | |
230 |
|
234 | |||
231 | self.getValue() |
|
235 | self.getValue() | |
232 |
|
236 | |||
233 | return 1 |
|
237 | return 1 | |
234 |
|
238 | |||
235 | def update(self, name, value, format='str'): |
|
239 | def update(self, name, value, format='str'): | |
236 |
|
240 | |||
237 | self.name = name |
|
241 | self.name = name | |
238 | self.value = str(value) |
|
242 | self.value = str(value) | |
239 | self.format = format |
|
243 | self.format = format | |
240 |
|
244 | |||
241 | def makeXml(self, opElement): |
|
245 | def makeXml(self, opElement): | |
242 | if self.name not in ('queue',): |
|
246 | if self.name not in ('queue',): | |
243 | parmElement = SubElement(opElement, self.ELEMENTNAME) |
|
247 | parmElement = SubElement(opElement, self.ELEMENTNAME) | |
244 | parmElement.set('id', str(self.id)) |
|
248 | parmElement.set('id', str(self.id)) | |
245 | parmElement.set('name', self.name) |
|
249 | parmElement.set('name', self.name) | |
246 | parmElement.set('value', self.value) |
|
250 | parmElement.set('value', self.value) | |
247 | parmElement.set('format', self.format) |
|
251 | parmElement.set('format', self.format) | |
248 |
|
252 | |||
249 | def readXml(self, parmElement): |
|
253 | def readXml(self, parmElement): | |
250 |
|
254 | |||
251 | self.id = parmElement.get('id') |
|
255 | self.id = parmElement.get('id') | |
252 | self.name = parmElement.get('name') |
|
256 | self.name = parmElement.get('name') | |
253 | self.value = parmElement.get('value') |
|
257 | self.value = parmElement.get('value') | |
254 | self.format = str.lower(parmElement.get('format')) |
|
258 | self.format = str.lower(parmElement.get('format')) | |
255 |
|
259 | |||
256 | #Compatible with old signal chain version |
|
260 | #Compatible with old signal chain version | |
257 | if self.format == 'int' and self.name == 'idfigure': |
|
261 | if self.format == 'int' and self.name == 'idfigure': | |
258 | self.name = 'id' |
|
262 | self.name = 'id' | |
259 |
|
263 | |||
260 | def printattr(self): |
|
264 | def printattr(self): | |
261 |
|
265 | |||
262 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
266 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) | |
263 |
|
267 | |||
264 | class OperationConf(): |
|
268 | class OperationConf(): | |
265 |
|
269 | |||
266 | id = None |
|
270 | id = None | |
267 | name = None |
|
271 | name = None | |
268 | priority = None |
|
272 | priority = None | |
269 | type = None |
|
273 | type = None | |
270 |
|
274 | |||
271 | parmConfObjList = [] |
|
275 | parmConfObjList = [] | |
272 |
|
276 | |||
273 | ELEMENTNAME = 'Operation' |
|
277 | ELEMENTNAME = 'Operation' | |
274 |
|
278 | |||
275 | def __init__(self): |
|
279 | def __init__(self): | |
276 |
|
280 | |||
277 | self.id = '0' |
|
281 | self.id = '0' | |
278 | self.name = None |
|
282 | self.name = None | |
279 | self.priority = None |
|
283 | self.priority = None | |
280 | self.type = 'self' |
|
284 | self.type = 'self' | |
281 |
|
285 | |||
282 |
|
286 | |||
283 | def __getNewId(self): |
|
287 | def __getNewId(self): | |
284 |
|
288 | |||
285 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
289 | return int(self.id)*10 + len(self.parmConfObjList) + 1 | |
286 |
|
290 | |||
287 | def updateId(self, new_id): |
|
291 | def updateId(self, new_id): | |
288 |
|
292 | |||
289 | self.id = str(new_id) |
|
293 | self.id = str(new_id) | |
290 |
|
294 | |||
291 | n = 1 |
|
295 | n = 1 | |
292 | for parmObj in self.parmConfObjList: |
|
296 | for parmObj in self.parmConfObjList: | |
293 |
|
297 | |||
294 | idParm = str(int(new_id)*10 + n) |
|
298 | idParm = str(int(new_id)*10 + n) | |
295 | parmObj.updateId(idParm) |
|
299 | parmObj.updateId(idParm) | |
296 |
|
300 | |||
297 | n += 1 |
|
301 | n += 1 | |
298 |
|
302 | |||
299 | def getElementName(self): |
|
303 | def getElementName(self): | |
300 |
|
304 | |||
301 | return self.ELEMENTNAME |
|
305 | return self.ELEMENTNAME | |
302 |
|
306 | |||
303 | def getParameterObjList(self): |
|
307 | def getParameterObjList(self): | |
304 |
|
308 | |||
305 | return self.parmConfObjList |
|
309 | return self.parmConfObjList | |
306 |
|
310 | |||
307 | def getParameterObj(self, parameterName): |
|
311 | def getParameterObj(self, parameterName): | |
308 |
|
312 | |||
309 | for parmConfObj in self.parmConfObjList: |
|
313 | for parmConfObj in self.parmConfObjList: | |
310 |
|
314 | |||
311 | if parmConfObj.name != parameterName: |
|
315 | if parmConfObj.name != parameterName: | |
312 | continue |
|
316 | continue | |
313 |
|
317 | |||
314 | return parmConfObj |
|
318 | return parmConfObj | |
315 |
|
319 | |||
316 | return None |
|
320 | return None | |
317 |
|
321 | |||
318 | def getParameterObjfromValue(self, parameterValue): |
|
322 | def getParameterObjfromValue(self, parameterValue): | |
319 |
|
323 | |||
320 | for parmConfObj in self.parmConfObjList: |
|
324 | for parmConfObj in self.parmConfObjList: | |
321 |
|
325 | |||
322 | if parmConfObj.getValue() != parameterValue: |
|
326 | if parmConfObj.getValue() != parameterValue: | |
323 | continue |
|
327 | continue | |
324 |
|
328 | |||
325 | return parmConfObj.getValue() |
|
329 | return parmConfObj.getValue() | |
326 |
|
330 | |||
327 | return None |
|
331 | return None | |
328 |
|
332 | |||
329 | def getParameterValue(self, parameterName): |
|
333 | def getParameterValue(self, parameterName): | |
330 |
|
334 | |||
331 | parameterObj = self.getParameterObj(parameterName) |
|
335 | parameterObj = self.getParameterObj(parameterName) | |
332 |
|
336 | |||
333 | # if not parameterObj: |
|
337 | # if not parameterObj: | |
334 | # return None |
|
338 | # return None | |
335 |
|
339 | |||
336 | value = parameterObj.getValue() |
|
340 | value = parameterObj.getValue() | |
337 |
|
341 | |||
338 | return value |
|
342 | return value | |
339 |
|
343 | |||
340 |
|
344 | |||
341 | def getKwargs(self): |
|
345 | def getKwargs(self): | |
342 |
|
346 | |||
343 | kwargs = {} |
|
347 | kwargs = {} | |
344 |
|
348 | |||
345 | for parmConfObj in self.parmConfObjList: |
|
349 | for parmConfObj in self.parmConfObjList: | |
346 | if self.name == 'run' and parmConfObj.name == 'datatype': |
|
350 | if self.name == 'run' and parmConfObj.name == 'datatype': | |
347 | continue |
|
351 | continue | |
348 |
|
352 | |||
349 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
353 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
350 |
|
354 | |||
351 | return kwargs |
|
355 | return kwargs | |
352 |
|
356 | |||
353 | def setup(self, id, name, priority, type): |
|
357 | def setup(self, id, name, priority, type): | |
354 |
|
358 | |||
355 | self.id = str(id) |
|
359 | self.id = str(id) | |
356 | self.name = name |
|
360 | self.name = name | |
357 | self.type = type |
|
361 | self.type = type | |
358 | self.priority = priority |
|
362 | self.priority = priority | |
359 |
|
363 | |||
360 | self.parmConfObjList = [] |
|
364 | self.parmConfObjList = [] | |
361 |
|
365 | |||
362 | def removeParameters(self): |
|
366 | def removeParameters(self): | |
363 |
|
367 | |||
364 | for obj in self.parmConfObjList: |
|
368 | for obj in self.parmConfObjList: | |
365 | del obj |
|
369 | del obj | |
366 |
|
370 | |||
367 | self.parmConfObjList = [] |
|
371 | self.parmConfObjList = [] | |
368 |
|
372 | |||
369 | def addParameter(self, name, value, format='str'): |
|
373 | def addParameter(self, name, value, format='str'): | |
370 |
|
374 | |||
371 | id = self.__getNewId() |
|
375 | id = self.__getNewId() | |
372 |
|
376 | |||
373 | parmConfObj = ParameterConf() |
|
377 | parmConfObj = ParameterConf() | |
374 | if not parmConfObj.setup(id, name, value, format): |
|
378 | if not parmConfObj.setup(id, name, value, format): | |
375 | return None |
|
379 | return None | |
376 |
|
380 | |||
377 | self.parmConfObjList.append(parmConfObj) |
|
381 | self.parmConfObjList.append(parmConfObj) | |
378 |
|
382 | |||
379 | return parmConfObj |
|
383 | return parmConfObj | |
380 |
|
384 | |||
381 | def changeParameter(self, name, value, format='str'): |
|
385 | def changeParameter(self, name, value, format='str'): | |
382 |
|
386 | |||
383 | parmConfObj = self.getParameterObj(name) |
|
387 | parmConfObj = self.getParameterObj(name) | |
384 | parmConfObj.update(name, value, format) |
|
388 | parmConfObj.update(name, value, format) | |
385 |
|
389 | |||
386 | return parmConfObj |
|
390 | return parmConfObj | |
387 |
|
391 | |||
388 | def makeXml(self, procUnitElement): |
|
392 | def makeXml(self, procUnitElement): | |
389 |
|
393 | |||
390 | opElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
394 | opElement = SubElement(procUnitElement, self.ELEMENTNAME) | |
391 | opElement.set('id', str(self.id)) |
|
395 | opElement.set('id', str(self.id)) | |
392 | opElement.set('name', self.name) |
|
396 | opElement.set('name', self.name) | |
393 | opElement.set('type', self.type) |
|
397 | opElement.set('type', self.type) | |
394 | opElement.set('priority', str(self.priority)) |
|
398 | opElement.set('priority', str(self.priority)) | |
395 |
|
399 | |||
396 | for parmConfObj in self.parmConfObjList: |
|
400 | for parmConfObj in self.parmConfObjList: | |
397 | parmConfObj.makeXml(opElement) |
|
401 | parmConfObj.makeXml(opElement) | |
398 |
|
402 | |||
399 | def readXml(self, opElement): |
|
403 | def readXml(self, opElement): | |
400 |
|
404 | |||
401 | self.id = opElement.get('id') |
|
405 | self.id = opElement.get('id') | |
402 | self.name = opElement.get('name') |
|
406 | self.name = opElement.get('name') | |
403 | self.type = opElement.get('type') |
|
407 | self.type = opElement.get('type') | |
404 | self.priority = opElement.get('priority') |
|
408 | self.priority = opElement.get('priority') | |
405 |
|
409 | |||
406 | #Compatible with old signal chain version |
|
410 | #Compatible with old signal chain version | |
407 | #Use of 'run' method instead 'init' |
|
411 | #Use of 'run' method instead 'init' | |
408 | if self.type == 'self' and self.name == 'init': |
|
412 | if self.type == 'self' and self.name == 'init': | |
409 | self.name = 'run' |
|
413 | self.name = 'run' | |
410 |
|
414 | |||
411 | self.parmConfObjList = [] |
|
415 | self.parmConfObjList = [] | |
412 |
|
416 | |||
413 | parmElementList = opElement.iter(ParameterConf().getElementName()) |
|
417 | parmElementList = opElement.iter(ParameterConf().getElementName()) | |
414 |
|
418 | |||
415 | for parmElement in parmElementList: |
|
419 | for parmElement in parmElementList: | |
416 | parmConfObj = ParameterConf() |
|
420 | parmConfObj = ParameterConf() | |
417 | parmConfObj.readXml(parmElement) |
|
421 | parmConfObj.readXml(parmElement) | |
418 |
|
422 | |||
419 | #Compatible with old signal chain version |
|
423 | #Compatible with old signal chain version | |
420 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER |
|
424 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER | |
421 | if self.type != 'self' and self.name == 'Plot': |
|
425 | if self.type != 'self' and self.name == 'Plot': | |
422 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': |
|
426 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': | |
423 | self.name = parmConfObj.value |
|
427 | self.name = parmConfObj.value | |
424 | continue |
|
428 | continue | |
425 |
|
429 | |||
426 | self.parmConfObjList.append(parmConfObj) |
|
430 | self.parmConfObjList.append(parmConfObj) | |
427 |
|
431 | |||
428 | def printattr(self): |
|
432 | def printattr(self): | |
429 |
|
433 | |||
430 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, |
|
434 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, | |
431 | self.id, |
|
435 | self.id, | |
432 | self.name, |
|
436 | self.name, | |
433 | self.type, |
|
437 | self.type, | |
434 | self.priority) |
|
438 | self.priority) | |
435 |
|
439 | |||
436 | for parmConfObj in self.parmConfObjList: |
|
440 | for parmConfObj in self.parmConfObjList: | |
437 | parmConfObj.printattr() |
|
441 | parmConfObj.printattr() | |
438 |
|
442 | |||
439 | def createObject(self, plotter_queue=None): |
|
443 | def createObject(self, plotter_queue=None): | |
440 |
|
444 | |||
441 |
|
445 | |||
442 | if self.type == 'self': |
|
446 | if self.type == 'self': | |
443 | raise ValueError, "This operation type cannot be created" |
|
447 | raise ValueError, "This operation type cannot be created" | |
444 |
|
448 | |||
445 | if self.type == 'plotter': |
|
449 | if self.type == 'plotter': | |
446 | #Plotter(plotter_name) |
|
450 | #Plotter(plotter_name) | |
447 | if not plotter_queue: |
|
451 | if not plotter_queue: | |
448 | raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)" |
|
452 | raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)" | |
449 |
|
453 | |||
450 | opObj = Plotter(self.name, plotter_queue) |
|
454 | opObj = Plotter(self.name, plotter_queue) | |
451 |
|
455 | |||
452 | if self.type == 'external' or self.type == 'other': |
|
456 | if self.type == 'external' or self.type == 'other': | |
453 |
|
457 | |||
454 | className = eval(self.name) |
|
458 | className = eval(self.name) | |
455 | kwargs = self.getKwargs() |
|
459 | kwargs = self.getKwargs() | |
456 |
|
460 | |||
457 | opObj = className(**kwargs) |
|
461 | opObj = className(**kwargs) | |
458 |
|
462 | |||
459 | return opObj |
|
463 | return opObj | |
460 |
|
464 | |||
461 |
|
465 | |||
462 | class ProcUnitConf(): |
|
466 | class ProcUnitConf(): | |
463 |
|
467 | |||
464 | id = None |
|
468 | id = None | |
465 | name = None |
|
469 | name = None | |
466 | datatype = None |
|
470 | datatype = None | |
467 | inputId = None |
|
471 | inputId = None | |
468 | parentId = None |
|
472 | parentId = None | |
469 |
|
473 | |||
470 | opConfObjList = [] |
|
474 | opConfObjList = [] | |
471 |
|
475 | |||
472 | procUnitObj = None |
|
476 | procUnitObj = None | |
473 | opObjList = [] |
|
477 | opObjList = [] | |
474 |
|
478 | |||
475 | ELEMENTNAME = 'ProcUnit' |
|
479 | ELEMENTNAME = 'ProcUnit' | |
476 |
|
480 | |||
477 | def __init__(self): |
|
481 | def __init__(self): | |
478 |
|
482 | |||
479 | self.id = None |
|
483 | self.id = None | |
480 | self.datatype = None |
|
484 | self.datatype = None | |
481 | self.name = None |
|
485 | self.name = None | |
482 | self.inputId = None |
|
486 | self.inputId = None | |
483 |
|
487 | |||
484 | self.opConfObjList = [] |
|
488 | self.opConfObjList = [] | |
485 |
|
489 | |||
486 | self.procUnitObj = None |
|
490 | self.procUnitObj = None | |
487 | self.opObjDict = {} |
|
491 | self.opObjDict = {} | |
488 |
|
492 | |||
489 | def __getPriority(self): |
|
493 | def __getPriority(self): | |
490 |
|
494 | |||
491 | return len(self.opConfObjList)+1 |
|
495 | return len(self.opConfObjList)+1 | |
492 |
|
496 | |||
493 | def __getNewId(self): |
|
497 | def __getNewId(self): | |
494 |
|
498 | |||
495 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
499 | return int(self.id)*10 + len(self.opConfObjList) + 1 | |
496 |
|
500 | |||
497 | def getElementName(self): |
|
501 | def getElementName(self): | |
498 |
|
502 | |||
499 | return self.ELEMENTNAME |
|
503 | return self.ELEMENTNAME | |
500 |
|
504 | |||
501 | def getId(self): |
|
505 | def getId(self): | |
502 |
|
506 | |||
503 | return self.id |
|
507 | return self.id | |
504 |
|
508 | |||
505 | def updateId(self, new_id, parentId=parentId): |
|
509 | def updateId(self, new_id, parentId=parentId): | |
506 |
|
510 | |||
507 |
|
511 | |||
508 | new_id = int(parentId)*10 + (int(self.id) % 10) |
|
512 | new_id = int(parentId)*10 + (int(self.id) % 10) | |
509 | new_inputId = int(parentId)*10 + (int(self.inputId) % 10) |
|
513 | new_inputId = int(parentId)*10 + (int(self.inputId) % 10) | |
510 |
|
514 | |||
511 | #If this proc unit has not inputs |
|
515 | #If this proc unit has not inputs | |
512 | if self.inputId == '0': |
|
516 | if self.inputId == '0': | |
513 | new_inputId = 0 |
|
517 | new_inputId = 0 | |
514 |
|
518 | |||
515 | n = 1 |
|
519 | n = 1 | |
516 | for opConfObj in self.opConfObjList: |
|
520 | for opConfObj in self.opConfObjList: | |
517 |
|
521 | |||
518 | idOp = str(int(new_id)*10 + n) |
|
522 | idOp = str(int(new_id)*10 + n) | |
519 | opConfObj.updateId(idOp) |
|
523 | opConfObj.updateId(idOp) | |
520 |
|
524 | |||
521 | n += 1 |
|
525 | n += 1 | |
522 |
|
526 | |||
523 | self.parentId = str(parentId) |
|
527 | self.parentId = str(parentId) | |
524 | self.id = str(new_id) |
|
528 | self.id = str(new_id) | |
525 | self.inputId = str(new_inputId) |
|
529 | self.inputId = str(new_inputId) | |
526 |
|
530 | |||
527 |
|
531 | |||
528 | def getInputId(self): |
|
532 | def getInputId(self): | |
529 |
|
533 | |||
530 | return self.inputId |
|
534 | return self.inputId | |
531 |
|
535 | |||
532 | def getOperationObjList(self): |
|
536 | def getOperationObjList(self): | |
533 |
|
537 | |||
534 | return self.opConfObjList |
|
538 | return self.opConfObjList | |
535 |
|
539 | |||
536 | def getOperationObj(self, name=None): |
|
540 | def getOperationObj(self, name=None): | |
537 |
|
541 | |||
538 | for opConfObj in self.opConfObjList: |
|
542 | for opConfObj in self.opConfObjList: | |
539 |
|
543 | |||
540 | if opConfObj.name != name: |
|
544 | if opConfObj.name != name: | |
541 | continue |
|
545 | continue | |
542 |
|
546 | |||
543 | return opConfObj |
|
547 | return opConfObj | |
544 |
|
548 | |||
545 | return None |
|
549 | return None | |
546 |
|
550 | |||
547 | def getOpObjfromParamValue(self, value=None): |
|
551 | def getOpObjfromParamValue(self, value=None): | |
548 |
|
552 | |||
549 | for opConfObj in self.opConfObjList: |
|
553 | for opConfObj in self.opConfObjList: | |
550 | if opConfObj.getParameterObjfromValue(parameterValue=value) != value: |
|
554 | if opConfObj.getParameterObjfromValue(parameterValue=value) != value: | |
551 | continue |
|
555 | continue | |
552 | return opConfObj |
|
556 | return opConfObj | |
553 | return None |
|
557 | return None | |
554 |
|
558 | |||
555 | def getProcUnitObj(self): |
|
559 | def getProcUnitObj(self): | |
556 |
|
560 | |||
557 | return self.procUnitObj |
|
561 | return self.procUnitObj | |
558 |
|
562 | |||
559 | def setup(self, id, name, datatype, inputId, parentId=None): |
|
563 | def setup(self, id, name, datatype, inputId, parentId=None): | |
560 |
|
564 | |||
561 | #Compatible with old signal chain version |
|
565 | #Compatible with old signal chain version | |
562 | if datatype==None and name==None: |
|
566 | if datatype==None and name==None: | |
563 | raise ValueError, "datatype or name should be defined" |
|
567 | raise ValueError, "datatype or name should be defined" | |
564 |
|
568 | |||
565 | if name==None: |
|
569 | if name==None: | |
566 | if 'Proc' in datatype: |
|
570 | if 'Proc' in datatype: | |
567 | name = datatype |
|
571 | name = datatype | |
568 | else: |
|
572 | else: | |
569 | name = '%sProc' %(datatype) |
|
573 | name = '%sProc' %(datatype) | |
570 |
|
574 | |||
571 | if datatype==None: |
|
575 | if datatype==None: | |
572 | datatype = name.replace('Proc','') |
|
576 | datatype = name.replace('Proc','') | |
573 |
|
577 | |||
574 | self.id = str(id) |
|
578 | self.id = str(id) | |
575 | self.name = name |
|
579 | self.name = name | |
576 | self.datatype = datatype |
|
580 | self.datatype = datatype | |
577 | self.inputId = inputId |
|
581 | self.inputId = inputId | |
578 | self.parentId = parentId |
|
582 | self.parentId = parentId | |
579 |
|
583 | |||
580 | self.opConfObjList = [] |
|
584 | self.opConfObjList = [] | |
581 |
|
585 | |||
582 | self.addOperation(name='run', optype='self') |
|
586 | self.addOperation(name='run', optype='self') | |
583 |
|
587 | |||
584 | def removeOperations(self): |
|
588 | def removeOperations(self): | |
585 |
|
589 | |||
586 | for obj in self.opConfObjList: |
|
590 | for obj in self.opConfObjList: | |
587 | del obj |
|
591 | del obj | |
588 |
|
592 | |||
589 | self.opConfObjList = [] |
|
593 | self.opConfObjList = [] | |
590 | self.addOperation(name='run') |
|
594 | self.addOperation(name='run') | |
591 |
|
595 | |||
592 | def addParameter(self, **kwargs): |
|
596 | def addParameter(self, **kwargs): | |
593 | ''' |
|
597 | ''' | |
594 | Add parameters to "run" operation |
|
598 | Add parameters to "run" operation | |
595 | ''' |
|
599 | ''' | |
596 | opObj = self.opConfObjList[0] |
|
600 | opObj = self.opConfObjList[0] | |
597 |
|
601 | |||
598 | opObj.addParameter(**kwargs) |
|
602 | opObj.addParameter(**kwargs) | |
599 |
|
603 | |||
600 | return opObj |
|
604 | return opObj | |
601 |
|
605 | |||
602 | def addOperation(self, name, optype='self'): |
|
606 | def addOperation(self, name, optype='self'): | |
603 |
|
607 | |||
604 | id = self.__getNewId() |
|
608 | id = self.__getNewId() | |
605 | priority = self.__getPriority() |
|
609 | priority = self.__getPriority() | |
606 |
|
610 | |||
607 | opConfObj = OperationConf() |
|
611 | opConfObj = OperationConf() | |
608 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
612 | opConfObj.setup(id, name=name, priority=priority, type=optype) | |
609 |
|
613 | |||
610 | self.opConfObjList.append(opConfObj) |
|
614 | self.opConfObjList.append(opConfObj) | |
611 |
|
615 | |||
612 | return opConfObj |
|
616 | return opConfObj | |
613 |
|
617 | |||
614 | def makeXml(self, projectElement): |
|
618 | def makeXml(self, projectElement): | |
615 |
|
619 | |||
616 | procUnitElement = SubElement(projectElement, self.ELEMENTNAME) |
|
620 | procUnitElement = SubElement(projectElement, self.ELEMENTNAME) | |
617 | procUnitElement.set('id', str(self.id)) |
|
621 | procUnitElement.set('id', str(self.id)) | |
618 | procUnitElement.set('name', self.name) |
|
622 | procUnitElement.set('name', self.name) | |
619 | procUnitElement.set('datatype', self.datatype) |
|
623 | procUnitElement.set('datatype', self.datatype) | |
620 | procUnitElement.set('inputId', str(self.inputId)) |
|
624 | procUnitElement.set('inputId', str(self.inputId)) | |
621 |
|
625 | |||
622 | for opConfObj in self.opConfObjList: |
|
626 | for opConfObj in self.opConfObjList: | |
623 | opConfObj.makeXml(procUnitElement) |
|
627 | opConfObj.makeXml(procUnitElement) | |
624 |
|
628 | |||
625 | def readXml(self, upElement): |
|
629 | def readXml(self, upElement): | |
626 |
|
630 | |||
627 | self.id = upElement.get('id') |
|
631 | self.id = upElement.get('id') | |
628 | self.name = upElement.get('name') |
|
632 | self.name = upElement.get('name') | |
629 | self.datatype = upElement.get('datatype') |
|
633 | self.datatype = upElement.get('datatype') | |
630 | self.inputId = upElement.get('inputId') |
|
634 | self.inputId = upElement.get('inputId') | |
631 |
|
635 | |||
632 | if self.ELEMENTNAME == "ReadUnit": |
|
636 | if self.ELEMENTNAME == "ReadUnit": | |
633 | self.datatype = self.datatype.replace("Reader", "") |
|
637 | self.datatype = self.datatype.replace("Reader", "") | |
634 |
|
638 | |||
635 | if self.ELEMENTNAME == "ProcUnit": |
|
639 | if self.ELEMENTNAME == "ProcUnit": | |
636 | self.datatype = self.datatype.replace("Proc", "") |
|
640 | self.datatype = self.datatype.replace("Proc", "") | |
637 |
|
641 | |||
638 | if self.inputId == 'None': |
|
642 | if self.inputId == 'None': | |
639 | self.inputId = '0' |
|
643 | self.inputId = '0' | |
640 |
|
644 | |||
641 | self.opConfObjList = [] |
|
645 | self.opConfObjList = [] | |
642 |
|
646 | |||
643 | opElementList = upElement.iter(OperationConf().getElementName()) |
|
647 | opElementList = upElement.iter(OperationConf().getElementName()) | |
644 |
|
648 | |||
645 | for opElement in opElementList: |
|
649 | for opElement in opElementList: | |
646 | opConfObj = OperationConf() |
|
650 | opConfObj = OperationConf() | |
647 | opConfObj.readXml(opElement) |
|
651 | opConfObj.readXml(opElement) | |
648 | self.opConfObjList.append(opConfObj) |
|
652 | self.opConfObjList.append(opConfObj) | |
649 |
|
653 | |||
650 | def printattr(self): |
|
654 | def printattr(self): | |
651 |
|
655 | |||
652 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
656 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, | |
653 | self.id, |
|
657 | self.id, | |
654 | self.name, |
|
658 | self.name, | |
655 | self.datatype, |
|
659 | self.datatype, | |
656 | self.inputId) |
|
660 | self.inputId) | |
657 |
|
661 | |||
658 | for opConfObj in self.opConfObjList: |
|
662 | for opConfObj in self.opConfObjList: | |
659 | opConfObj.printattr() |
|
663 | opConfObj.printattr() | |
660 |
|
664 | |||
661 |
|
665 | |||
662 | def getKwargs(self): |
|
666 | def getKwargs(self): | |
663 |
|
667 | |||
664 | opObj = self.opConfObjList[0] |
|
668 | opObj = self.opConfObjList[0] | |
665 | kwargs = opObj.getKwargs() |
|
669 | kwargs = opObj.getKwargs() | |
666 |
|
670 | |||
667 | return kwargs |
|
671 | return kwargs | |
668 |
|
672 | |||
669 | def createObjects(self, plotter_queue=None): |
|
673 | def createObjects(self, plotter_queue=None): | |
670 |
|
674 | |||
671 | className = eval(self.name) |
|
675 | className = eval(self.name) | |
672 | kwargs = self.getKwargs() |
|
676 | kwargs = self.getKwargs() | |
673 | procUnitObj = className(**kwargs) |
|
677 | procUnitObj = className(**kwargs) | |
674 |
|
678 | |||
675 | for opConfObj in self.opConfObjList: |
|
679 | for opConfObj in self.opConfObjList: | |
676 |
|
680 | |||
677 | if opConfObj.type=='self' and self.name=='run': |
|
681 | if opConfObj.type=='self' and self.name=='run': | |
678 | continue |
|
682 | continue | |
679 | elif opConfObj.type=='self': |
|
683 | elif opConfObj.type=='self': | |
680 | procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs()) |
|
684 | procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs()) | |
681 | continue |
|
685 | continue | |
682 |
|
686 | |||
683 | opObj = opConfObj.createObject(plotter_queue) |
|
687 | opObj = opConfObj.createObject(plotter_queue) | |
684 |
|
688 | |||
685 | self.opObjDict[opConfObj.id] = opObj |
|
689 | self.opObjDict[opConfObj.id] = opObj | |
686 |
|
690 | |||
687 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
691 | procUnitObj.addOperation(opObj, opConfObj.id) | |
688 |
|
692 | |||
689 | self.procUnitObj = procUnitObj |
|
693 | self.procUnitObj = procUnitObj | |
690 |
|
694 | |||
691 | return procUnitObj |
|
695 | return procUnitObj | |
692 |
|
696 | |||
693 | ## @profile |
|
697 | ## @profile | |
694 | def run(self): |
|
698 | def run(self): | |
695 |
|
699 | |||
696 | is_ok = False |
|
700 | is_ok = False | |
697 |
|
701 | |||
698 | for opConfObj in self.opConfObjList: |
|
702 | for opConfObj in self.opConfObjList: | |
699 |
|
703 | |||
700 | kwargs = {} |
|
704 | kwargs = {} | |
701 | for parmConfObj in opConfObj.getParameterObjList(): |
|
705 | for parmConfObj in opConfObj.getParameterObjList(): | |
702 | if opConfObj.name == 'run' and parmConfObj.name == 'datatype': |
|
706 | if opConfObj.name == 'run' and parmConfObj.name == 'datatype': | |
703 | continue |
|
707 | continue | |
704 |
|
708 | |||
705 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
709 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
706 |
|
710 | |||
707 | #ini = time.time() |
|
711 | #ini = time.time() | |
708 |
|
712 | |||
709 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
713 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) | |
710 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
714 | sts = self.procUnitObj.call(opType = opConfObj.type, | |
711 | opName = opConfObj.name, |
|
715 | opName = opConfObj.name, | |
712 | opId = opConfObj.id, |
|
716 | opId = opConfObj.id, | |
713 | ) |
|
717 | ) | |
714 |
|
718 | |||
715 | # total_time = time.time() - ini |
|
719 | # total_time = time.time() - ini | |
716 | # |
|
720 | # | |
717 | # if total_time > 0.002: |
|
721 | # if total_time > 0.002: | |
718 | # print "%s::%s took %f seconds" %(self.name, opConfObj.name, total_time) |
|
722 | # print "%s::%s took %f seconds" %(self.name, opConfObj.name, total_time) | |
719 |
|
723 | |||
720 | is_ok = is_ok or sts |
|
724 | is_ok = is_ok or sts | |
721 |
|
725 | |||
722 | return is_ok |
|
726 | return is_ok | |
723 |
|
727 | |||
724 | def close(self): |
|
728 | def close(self): | |
725 |
|
729 | |||
726 | for opConfObj in self.opConfObjList: |
|
730 | for opConfObj in self.opConfObjList: | |
727 | if opConfObj.type == 'self': |
|
731 | if opConfObj.type == 'self': | |
728 | continue |
|
732 | continue | |
729 |
|
733 | |||
730 | opObj = self.procUnitObj.getOperationObj(opConfObj.id) |
|
734 | opObj = self.procUnitObj.getOperationObj(opConfObj.id) | |
731 | opObj.close() |
|
735 | opObj.close() | |
732 |
|
736 | |||
733 | self.procUnitObj.close() |
|
737 | self.procUnitObj.close() | |
734 |
|
738 | |||
735 | return |
|
739 | return | |
736 |
|
740 | |||
737 | class ReadUnitConf(ProcUnitConf): |
|
741 | class ReadUnitConf(ProcUnitConf): | |
738 |
|
742 | |||
739 | path = None |
|
743 | path = None | |
740 | startDate = None |
|
744 | startDate = None | |
741 | endDate = None |
|
745 | endDate = None | |
742 | startTime = None |
|
746 | startTime = None | |
743 | endTime = None |
|
747 | endTime = None | |
744 |
|
748 | |||
745 | ELEMENTNAME = 'ReadUnit' |
|
749 | ELEMENTNAME = 'ReadUnit' | |
746 |
|
750 | |||
747 | def __init__(self): |
|
751 | def __init__(self): | |
748 |
|
752 | |||
749 | self.id = None |
|
753 | self.id = None | |
750 | self.datatype = None |
|
754 | self.datatype = None | |
751 | self.name = None |
|
755 | self.name = None | |
752 | self.inputId = None |
|
756 | self.inputId = None | |
753 |
|
757 | |||
754 | self.parentId = None |
|
758 | self.parentId = None | |
755 |
|
759 | |||
756 | self.opConfObjList = [] |
|
760 | self.opConfObjList = [] | |
757 | self.opObjList = [] |
|
761 | self.opObjList = [] | |
758 |
|
762 | |||
759 | def getElementName(self): |
|
763 | def getElementName(self): | |
760 |
|
764 | |||
761 | return self.ELEMENTNAME |
|
765 | return self.ELEMENTNAME | |
762 |
|
766 | |||
763 | def setup(self, id, name, datatype, path='', startDate="", endDate="", startTime="", |
|
767 | def setup(self, id, name, datatype, path='', startDate="", endDate="", startTime="", | |
764 | endTime="", parentId=None, queue=None, server=None, **kwargs): |
|
768 | endTime="", parentId=None, queue=None, server=None, **kwargs): | |
765 |
|
769 | |||
766 | #Compatible with old signal chain version |
|
770 | #Compatible with old signal chain version | |
767 | if datatype==None and name==None: |
|
771 | if datatype==None and name==None: | |
768 | raise ValueError, "datatype or name should be defined" |
|
772 | raise ValueError, "datatype or name should be defined" | |
769 |
|
773 | |||
770 | if name==None: |
|
774 | if name==None: | |
771 | if 'Reader' in datatype: |
|
775 | if 'Reader' in datatype: | |
772 | name = datatype |
|
776 | name = datatype | |
773 | else: |
|
777 | else: | |
774 | name = '%sReader' %(datatype) |
|
778 | name = '%sReader' %(datatype) | |
775 | if datatype==None: |
|
779 | if datatype==None: | |
776 | datatype = name.replace('Reader','') |
|
780 | datatype = name.replace('Reader','') | |
777 |
|
781 | |||
778 | self.id = id |
|
782 | self.id = id | |
779 | self.name = name |
|
783 | self.name = name | |
780 | self.datatype = datatype |
|
784 | self.datatype = datatype | |
781 | if path != '': |
|
785 | if path != '': | |
782 | self.path = os.path.abspath(path) |
|
786 | self.path = os.path.abspath(path) | |
783 | self.startDate = startDate |
|
787 | self.startDate = startDate | |
784 | self.endDate = endDate |
|
788 | self.endDate = endDate | |
785 | self.startTime = startTime |
|
789 | self.startTime = startTime | |
786 | self.endTime = endTime |
|
790 | self.endTime = endTime | |
787 |
|
791 | |||
788 | self.inputId = '0' |
|
792 | self.inputId = '0' | |
789 | self.parentId = parentId |
|
793 | self.parentId = parentId | |
790 | self.queue = queue |
|
794 | self.queue = queue | |
791 | self.server = server |
|
795 | self.server = server | |
792 | self.addRunOperation(**kwargs) |
|
796 | self.addRunOperation(**kwargs) | |
793 |
|
797 | |||
794 | def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs): |
|
798 | def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs): | |
795 |
|
799 | |||
796 | #Compatible with old signal chain version |
|
800 | #Compatible with old signal chain version | |
797 | if datatype==None and name==None: |
|
801 | if datatype==None and name==None: | |
798 | raise ValueError, "datatype or name should be defined" |
|
802 | raise ValueError, "datatype or name should be defined" | |
799 |
|
803 | |||
800 | if name==None: |
|
804 | if name==None: | |
801 | if 'Reader' in datatype: |
|
805 | if 'Reader' in datatype: | |
802 | name = datatype |
|
806 | name = datatype | |
803 | else: |
|
807 | else: | |
804 | name = '%sReader' %(datatype) |
|
808 | name = '%sReader' %(datatype) | |
805 |
|
809 | |||
806 | if datatype==None: |
|
810 | if datatype==None: | |
807 | datatype = name.replace('Reader','') |
|
811 | datatype = name.replace('Reader','') | |
808 |
|
812 | |||
809 | self.datatype = datatype |
|
813 | self.datatype = datatype | |
810 | self.name = name |
|
814 | self.name = name | |
811 | self.path = path |
|
815 | self.path = path | |
812 | self.startDate = startDate |
|
816 | self.startDate = startDate | |
813 | self.endDate = endDate |
|
817 | self.endDate = endDate | |
814 | self.startTime = startTime |
|
818 | self.startTime = startTime | |
815 | self.endTime = endTime |
|
819 | self.endTime = endTime | |
816 |
|
820 | |||
817 | self.inputId = '0' |
|
821 | self.inputId = '0' | |
818 | self.parentId = parentId |
|
822 | self.parentId = parentId | |
819 |
|
823 | |||
820 | self.updateRunOperation(**kwargs) |
|
824 | self.updateRunOperation(**kwargs) | |
821 |
|
825 | |||
822 | def removeOperations(self): |
|
826 | def removeOperations(self): | |
823 |
|
827 | |||
824 | for obj in self.opConfObjList: |
|
828 | for obj in self.opConfObjList: | |
825 | del obj |
|
829 | del obj | |
826 |
|
830 | |||
827 | self.opConfObjList = [] |
|
831 | self.opConfObjList = [] | |
828 |
|
832 | |||
829 | def addRunOperation(self, **kwargs): |
|
833 | def addRunOperation(self, **kwargs): | |
830 |
|
834 | |||
831 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
835 | opObj = self.addOperation(name = 'run', optype = 'self') | |
832 |
|
836 | |||
833 | if self.server is None: |
|
837 | if self.server is None: | |
834 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') |
|
838 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') | |
835 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
839 | opObj.addParameter(name='path' , value=self.path, format='str') | |
836 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
840 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
837 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
841 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
838 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
842 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
839 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
843 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
840 | opObj.addParameter(name='queue' , value=self.queue, format='obj') |
|
844 | opObj.addParameter(name='queue' , value=self.queue, format='obj') | |
841 | for key, value in kwargs.items(): |
|
845 | for key, value in kwargs.items(): | |
842 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
846 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
843 | else: |
|
847 | else: | |
844 | opObj.addParameter(name='server' , value=self.server, format='str') |
|
848 | opObj.addParameter(name='server' , value=self.server, format='str') | |
845 |
|
849 | |||
846 |
|
850 | |||
847 | return opObj |
|
851 | return opObj | |
848 |
|
852 | |||
849 | def updateRunOperation(self, **kwargs): |
|
853 | def updateRunOperation(self, **kwargs): | |
850 |
|
854 | |||
851 | opObj = self.getOperationObj(name = 'run') |
|
855 | opObj = self.getOperationObj(name = 'run') | |
852 | opObj.removeParameters() |
|
856 | opObj.removeParameters() | |
853 |
|
857 | |||
854 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') |
|
858 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') | |
855 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
859 | opObj.addParameter(name='path' , value=self.path, format='str') | |
856 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
860 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
857 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
861 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
858 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
862 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
859 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
863 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
860 |
|
864 | |||
861 | for key, value in kwargs.items(): |
|
865 | for key, value in kwargs.items(): | |
862 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
866 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
863 |
|
867 | |||
864 | return opObj |
|
868 | return opObj | |
865 |
|
869 | |||
866 | # def makeXml(self, projectElement): |
|
870 | # def makeXml(self, projectElement): | |
867 | # |
|
871 | # | |
868 | # procUnitElement = SubElement(projectElement, self.ELEMENTNAME) |
|
872 | # procUnitElement = SubElement(projectElement, self.ELEMENTNAME) | |
869 | # procUnitElement.set('id', str(self.id)) |
|
873 | # procUnitElement.set('id', str(self.id)) | |
870 | # procUnitElement.set('name', self.name) |
|
874 | # procUnitElement.set('name', self.name) | |
871 | # procUnitElement.set('datatype', self.datatype) |
|
875 | # procUnitElement.set('datatype', self.datatype) | |
872 | # procUnitElement.set('inputId', str(self.inputId)) |
|
876 | # procUnitElement.set('inputId', str(self.inputId)) | |
873 | # |
|
877 | # | |
874 | # for opConfObj in self.opConfObjList: |
|
878 | # for opConfObj in self.opConfObjList: | |
875 | # opConfObj.makeXml(procUnitElement) |
|
879 | # opConfObj.makeXml(procUnitElement) | |
876 |
|
880 | |||
877 | def readXml(self, upElement): |
|
881 | def readXml(self, upElement): | |
878 |
|
882 | |||
879 | self.id = upElement.get('id') |
|
883 | self.id = upElement.get('id') | |
880 | self.name = upElement.get('name') |
|
884 | self.name = upElement.get('name') | |
881 | self.datatype = upElement.get('datatype') |
|
885 | self.datatype = upElement.get('datatype') | |
882 | self.inputId = upElement.get('inputId') |
|
886 | self.inputId = upElement.get('inputId') | |
883 |
|
887 | |||
884 | if self.ELEMENTNAME == "ReadUnit": |
|
888 | if self.ELEMENTNAME == "ReadUnit": | |
885 | self.datatype = self.datatype.replace("Reader", "") |
|
889 | self.datatype = self.datatype.replace("Reader", "") | |
886 |
|
890 | |||
887 | if self.inputId == 'None': |
|
891 | if self.inputId == 'None': | |
888 | self.inputId = '0' |
|
892 | self.inputId = '0' | |
889 |
|
893 | |||
890 | self.opConfObjList = [] |
|
894 | self.opConfObjList = [] | |
891 |
|
895 | |||
892 | opElementList = upElement.iter(OperationConf().getElementName()) |
|
896 | opElementList = upElement.iter(OperationConf().getElementName()) | |
893 |
|
897 | |||
894 | for opElement in opElementList: |
|
898 | for opElement in opElementList: | |
895 | opConfObj = OperationConf() |
|
899 | opConfObj = OperationConf() | |
896 | opConfObj.readXml(opElement) |
|
900 | opConfObj.readXml(opElement) | |
897 | self.opConfObjList.append(opConfObj) |
|
901 | self.opConfObjList.append(opConfObj) | |
898 |
|
902 | |||
899 | if opConfObj.name == 'run': |
|
903 | if opConfObj.name == 'run': | |
900 | self.path = opConfObj.getParameterValue('path') |
|
904 | self.path = opConfObj.getParameterValue('path') | |
901 | self.startDate = opConfObj.getParameterValue('startDate') |
|
905 | self.startDate = opConfObj.getParameterValue('startDate') | |
902 | self.endDate = opConfObj.getParameterValue('endDate') |
|
906 | self.endDate = opConfObj.getParameterValue('endDate') | |
903 | self.startTime = opConfObj.getParameterValue('startTime') |
|
907 | self.startTime = opConfObj.getParameterValue('startTime') | |
904 | self.endTime = opConfObj.getParameterValue('endTime') |
|
908 | self.endTime = opConfObj.getParameterValue('endTime') | |
905 |
|
909 | |||
906 | class Project(): |
|
910 | class Project(): | |
907 |
|
911 | |||
908 | id = None |
|
912 | id = None | |
909 | name = None |
|
913 | name = None | |
910 | description = None |
|
914 | description = None | |
911 | filename = None |
|
915 | filename = None | |
912 |
|
916 | |||
913 | procUnitConfObjDict = None |
|
917 | procUnitConfObjDict = None | |
914 |
|
918 | |||
915 | ELEMENTNAME = 'Project' |
|
919 | ELEMENTNAME = 'Project' | |
916 |
|
920 | |||
917 | plotterQueue = None |
|
921 | plotterQueue = None | |
918 |
|
922 | |||
919 | def __init__(self, plotter_queue=None): |
|
923 | def __init__(self, plotter_queue=None): | |
920 |
|
924 | |||
921 | self.id = None |
|
925 | self.id = None | |
922 | self.name = None |
|
926 | self.name = None | |
923 | self.description = None |
|
927 | self.description = None | |
924 |
|
928 | |||
925 | self.plotterQueue = plotter_queue |
|
929 | self.plotterQueue = plotter_queue | |
926 |
|
930 | |||
927 | self.procUnitConfObjDict = {} |
|
931 | self.procUnitConfObjDict = {} | |
928 |
|
932 | |||
929 | def __getNewId(self): |
|
933 | def __getNewId(self): | |
930 |
|
934 | |||
931 | idList = self.procUnitConfObjDict.keys() |
|
935 | idList = self.procUnitConfObjDict.keys() | |
932 |
|
936 | |||
933 | id = int(self.id)*10 |
|
937 | id = int(self.id)*10 | |
934 |
|
938 | |||
935 | while True: |
|
939 | while True: | |
936 | id += 1 |
|
940 | id += 1 | |
937 |
|
941 | |||
938 | if str(id) in idList: |
|
942 | if str(id) in idList: | |
939 | continue |
|
943 | continue | |
940 |
|
944 | |||
941 | break |
|
945 | break | |
942 |
|
946 | |||
943 | return str(id) |
|
947 | return str(id) | |
944 |
|
948 | |||
945 | def getElementName(self): |
|
949 | def getElementName(self): | |
946 |
|
950 | |||
947 | return self.ELEMENTNAME |
|
951 | return self.ELEMENTNAME | |
948 |
|
952 | |||
949 | def getId(self): |
|
953 | def getId(self): | |
950 |
|
954 | |||
951 | return self.id |
|
955 | return self.id | |
952 |
|
956 | |||
953 | def updateId(self, new_id): |
|
957 | def updateId(self, new_id): | |
954 |
|
958 | |||
955 | self.id = str(new_id) |
|
959 | self.id = str(new_id) | |
956 |
|
960 | |||
957 | keyList = self.procUnitConfObjDict.keys() |
|
961 | keyList = self.procUnitConfObjDict.keys() | |
958 | keyList.sort() |
|
962 | keyList.sort() | |
959 |
|
963 | |||
960 | n = 1 |
|
964 | n = 1 | |
961 | newProcUnitConfObjDict = {} |
|
965 | newProcUnitConfObjDict = {} | |
962 |
|
966 | |||
963 | for procKey in keyList: |
|
967 | for procKey in keyList: | |
964 |
|
968 | |||
965 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
969 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
966 | idProcUnit = str(int(self.id)*10 + n) |
|
970 | idProcUnit = str(int(self.id)*10 + n) | |
967 | procUnitConfObj.updateId(idProcUnit, parentId = self.id) |
|
971 | procUnitConfObj.updateId(idProcUnit, parentId = self.id) | |
968 |
|
972 | |||
969 | newProcUnitConfObjDict[idProcUnit] = procUnitConfObj |
|
973 | newProcUnitConfObjDict[idProcUnit] = procUnitConfObj | |
970 | n += 1 |
|
974 | n += 1 | |
971 |
|
975 | |||
972 | self.procUnitConfObjDict = newProcUnitConfObjDict |
|
976 | self.procUnitConfObjDict = newProcUnitConfObjDict | |
973 |
|
977 | |||
974 | def setup(self, id, name, description): |
|
978 | def setup(self, id, name, description): | |
975 |
|
979 | |||
976 | self.id = str(id) |
|
980 | self.id = str(id) | |
977 | self.name = name |
|
981 | self.name = name | |
978 | self.description = description |
|
982 | self.description = description | |
979 |
|
983 | |||
980 | def update(self, name, description): |
|
984 | def update(self, name, description): | |
981 |
|
985 | |||
982 | self.name = name |
|
986 | self.name = name | |
983 | self.description = description |
|
987 | self.description = description | |
984 |
|
988 | |||
985 | def addReadUnit(self, id=None, datatype=None, name=None, **kwargs): |
|
989 | def addReadUnit(self, id=None, datatype=None, name=None, **kwargs): | |
986 |
|
990 | |||
987 | if id is None: |
|
991 | if id is None: | |
988 | idReadUnit = self.__getNewId() |
|
992 | idReadUnit = self.__getNewId() | |
989 | else: |
|
993 | else: | |
990 | idReadUnit = str(id) |
|
994 | idReadUnit = str(id) | |
991 |
|
995 | |||
992 | readUnitConfObj = ReadUnitConf() |
|
996 | readUnitConfObj = ReadUnitConf() | |
993 | readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs) |
|
997 | readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs) | |
994 |
|
998 | |||
995 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
999 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
996 |
|
1000 | |||
997 | return readUnitConfObj |
|
1001 | return readUnitConfObj | |
998 |
|
1002 | |||
999 | def addProcUnit(self, inputId='0', datatype=None, name=None): |
|
1003 | def addProcUnit(self, inputId='0', datatype=None, name=None): | |
1000 |
|
1004 | |||
1001 | idProcUnit = self.__getNewId() |
|
1005 | idProcUnit = self.__getNewId() | |
1002 |
|
1006 | |||
1003 | procUnitConfObj = ProcUnitConf() |
|
1007 | procUnitConfObj = ProcUnitConf() | |
1004 | procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id) |
|
1008 | procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id) | |
1005 |
|
1009 | |||
1006 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
1010 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
1007 |
|
1011 | |||
1008 | return procUnitConfObj |
|
1012 | return procUnitConfObj | |
1009 |
|
1013 | |||
1010 | def removeProcUnit(self, id): |
|
1014 | def removeProcUnit(self, id): | |
1011 |
|
1015 | |||
1012 | if id in self.procUnitConfObjDict.keys(): |
|
1016 | if id in self.procUnitConfObjDict.keys(): | |
1013 | self.procUnitConfObjDict.pop(id) |
|
1017 | self.procUnitConfObjDict.pop(id) | |
1014 |
|
1018 | |||
1015 | def getReadUnitId(self): |
|
1019 | def getReadUnitId(self): | |
1016 |
|
1020 | |||
1017 | readUnitConfObj = self.getReadUnitObj() |
|
1021 | readUnitConfObj = self.getReadUnitObj() | |
1018 |
|
1022 | |||
1019 | return readUnitConfObj.id |
|
1023 | return readUnitConfObj.id | |
1020 |
|
1024 | |||
1021 | def getReadUnitObj(self): |
|
1025 | def getReadUnitObj(self): | |
1022 |
|
1026 | |||
1023 | for obj in self.procUnitConfObjDict.values(): |
|
1027 | for obj in self.procUnitConfObjDict.values(): | |
1024 | if obj.getElementName() == "ReadUnit": |
|
1028 | if obj.getElementName() == "ReadUnit": | |
1025 | return obj |
|
1029 | return obj | |
1026 |
|
1030 | |||
1027 | return None |
|
1031 | return None | |
1028 |
|
1032 | |||
1029 | def getProcUnitObj(self, id=None, name=None): |
|
1033 | def getProcUnitObj(self, id=None, name=None): | |
1030 |
|
1034 | |||
1031 | if id != None: |
|
1035 | if id != None: | |
1032 | return self.procUnitConfObjDict[id] |
|
1036 | return self.procUnitConfObjDict[id] | |
1033 |
|
1037 | |||
1034 | if name != None: |
|
1038 | if name != None: | |
1035 | return self.getProcUnitObjByName(name) |
|
1039 | return self.getProcUnitObjByName(name) | |
1036 |
|
1040 | |||
1037 | return None |
|
1041 | return None | |
1038 |
|
1042 | |||
1039 | def getProcUnitObjByName(self, name): |
|
1043 | def getProcUnitObjByName(self, name): | |
1040 |
|
1044 | |||
1041 | for obj in self.procUnitConfObjDict.values(): |
|
1045 | for obj in self.procUnitConfObjDict.values(): | |
1042 | if obj.name == name: |
|
1046 | if obj.name == name: | |
1043 | return obj |
|
1047 | return obj | |
1044 |
|
1048 | |||
1045 | return None |
|
1049 | return None | |
1046 |
|
1050 | |||
1047 | def procUnitItems(self): |
|
1051 | def procUnitItems(self): | |
1048 |
|
1052 | |||
1049 | return self.procUnitConfObjDict.items() |
|
1053 | return self.procUnitConfObjDict.items() | |
1050 |
|
1054 | |||
1051 | def makeXml(self): |
|
1055 | def makeXml(self): | |
1052 |
|
1056 | |||
1053 | projectElement = Element('Project') |
|
1057 | projectElement = Element('Project') | |
1054 | projectElement.set('id', str(self.id)) |
|
1058 | projectElement.set('id', str(self.id)) | |
1055 | projectElement.set('name', self.name) |
|
1059 | projectElement.set('name', self.name) | |
1056 | projectElement.set('description', self.description) |
|
1060 | projectElement.set('description', self.description) | |
1057 |
|
1061 | |||
1058 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
1062 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
1059 | procUnitConfObj.makeXml(projectElement) |
|
1063 | procUnitConfObj.makeXml(projectElement) | |
1060 |
|
1064 | |||
1061 | self.projectElement = projectElement |
|
1065 | self.projectElement = projectElement | |
1062 |
|
1066 | |||
1063 | def writeXml(self, filename=None): |
|
1067 | def writeXml(self, filename=None): | |
1064 |
|
1068 | |||
1065 | if filename == None: |
|
1069 | if filename == None: | |
1066 | if self.filename: |
|
1070 | if self.filename: | |
1067 | filename = self.filename |
|
1071 | filename = self.filename | |
1068 | else: |
|
1072 | else: | |
1069 | filename = "schain.xml" |
|
1073 | filename = "schain.xml" | |
1070 |
|
1074 | |||
1071 | if not filename: |
|
1075 | if not filename: | |
1072 | print "filename has not been defined. Use setFilename(filename) for do it." |
|
1076 | print "filename has not been defined. Use setFilename(filename) for do it." | |
1073 | return 0 |
|
1077 | return 0 | |
1074 |
|
1078 | |||
1075 | abs_file = os.path.abspath(filename) |
|
1079 | abs_file = os.path.abspath(filename) | |
1076 |
|
1080 | |||
1077 | if not os.access(os.path.dirname(abs_file), os.W_OK): |
|
1081 | if not os.access(os.path.dirname(abs_file), os.W_OK): | |
1078 | print "No write permission on %s" %os.path.dirname(abs_file) |
|
1082 | print "No write permission on %s" %os.path.dirname(abs_file) | |
1079 | return 0 |
|
1083 | return 0 | |
1080 |
|
1084 | |||
1081 | if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)): |
|
1085 | if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)): | |
1082 | print "File %s already exists and it could not be overwriten" %abs_file |
|
1086 | print "File %s already exists and it could not be overwriten" %abs_file | |
1083 | return 0 |
|
1087 | return 0 | |
1084 |
|
1088 | |||
1085 | self.makeXml() |
|
1089 | self.makeXml() | |
1086 |
|
1090 | |||
1087 | ElementTree(self.projectElement).write(abs_file, method='xml') |
|
1091 | ElementTree(self.projectElement).write(abs_file, method='xml') | |
1088 |
|
1092 | |||
1089 | self.filename = abs_file |
|
1093 | self.filename = abs_file | |
1090 |
|
1094 | |||
1091 | return 1 |
|
1095 | return 1 | |
1092 |
|
1096 | |||
1093 | def readXml(self, filename = None): |
|
1097 | def readXml(self, filename = None): | |
1094 |
|
1098 | |||
1095 | if not filename: |
|
1099 | if not filename: | |
1096 | print "filename is not defined" |
|
1100 | print "filename is not defined" | |
1097 | return 0 |
|
1101 | return 0 | |
1098 |
|
1102 | |||
1099 | abs_file = os.path.abspath(filename) |
|
1103 | abs_file = os.path.abspath(filename) | |
1100 |
|
1104 | |||
1101 | if not os.path.isfile(abs_file): |
|
1105 | if not os.path.isfile(abs_file): | |
1102 | print "%s file does not exist" %abs_file |
|
1106 | print "%s file does not exist" %abs_file | |
1103 | return 0 |
|
1107 | return 0 | |
1104 |
|
1108 | |||
1105 | self.projectElement = None |
|
1109 | self.projectElement = None | |
1106 | self.procUnitConfObjDict = {} |
|
1110 | self.procUnitConfObjDict = {} | |
1107 |
|
1111 | |||
1108 | try: |
|
1112 | try: | |
1109 | self.projectElement = ElementTree().parse(abs_file) |
|
1113 | self.projectElement = ElementTree().parse(abs_file) | |
1110 | except: |
|
1114 | except: | |
1111 | print "Error reading %s, verify file format" %filename |
|
1115 | print "Error reading %s, verify file format" %filename | |
1112 | return 0 |
|
1116 | return 0 | |
1113 |
|
1117 | |||
1114 | self.project = self.projectElement.tag |
|
1118 | self.project = self.projectElement.tag | |
1115 |
|
1119 | |||
1116 | self.id = self.projectElement.get('id') |
|
1120 | self.id = self.projectElement.get('id') | |
1117 | self.name = self.projectElement.get('name') |
|
1121 | self.name = self.projectElement.get('name') | |
1118 | self.description = self.projectElement.get('description') |
|
1122 | self.description = self.projectElement.get('description') | |
1119 |
|
1123 | |||
1120 | readUnitElementList = self.projectElement.iter(ReadUnitConf().getElementName()) |
|
1124 | readUnitElementList = self.projectElement.iter(ReadUnitConf().getElementName()) | |
1121 |
|
1125 | |||
1122 | for readUnitElement in readUnitElementList: |
|
1126 | for readUnitElement in readUnitElementList: | |
1123 | readUnitConfObj = ReadUnitConf() |
|
1127 | readUnitConfObj = ReadUnitConf() | |
1124 | readUnitConfObj.readXml(readUnitElement) |
|
1128 | readUnitConfObj.readXml(readUnitElement) | |
1125 |
|
1129 | |||
1126 | if readUnitConfObj.parentId == None: |
|
1130 | if readUnitConfObj.parentId == None: | |
1127 | readUnitConfObj.parentId = self.id |
|
1131 | readUnitConfObj.parentId = self.id | |
1128 |
|
1132 | |||
1129 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
1133 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
1130 |
|
1134 | |||
1131 | procUnitElementList = self.projectElement.iter(ProcUnitConf().getElementName()) |
|
1135 | procUnitElementList = self.projectElement.iter(ProcUnitConf().getElementName()) | |
1132 |
|
1136 | |||
1133 | for procUnitElement in procUnitElementList: |
|
1137 | for procUnitElement in procUnitElementList: | |
1134 | procUnitConfObj = ProcUnitConf() |
|
1138 | procUnitConfObj = ProcUnitConf() | |
1135 | procUnitConfObj.readXml(procUnitElement) |
|
1139 | procUnitConfObj.readXml(procUnitElement) | |
1136 |
|
1140 | |||
1137 | if procUnitConfObj.parentId == None: |
|
1141 | if procUnitConfObj.parentId == None: | |
1138 | procUnitConfObj.parentId = self.id |
|
1142 | procUnitConfObj.parentId = self.id | |
1139 |
|
1143 | |||
1140 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
1144 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
1141 |
|
1145 | |||
1142 | self.filename = abs_file |
|
1146 | self.filename = abs_file | |
1143 |
|
1147 | |||
1144 | return 1 |
|
1148 | return 1 | |
1145 |
|
1149 | |||
1146 | def printattr(self): |
|
1150 | def printattr(self): | |
1147 |
|
1151 | |||
1148 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
1152 | print "Project[%s]: name = %s, description = %s" %(self.id, | |
1149 | self.name, |
|
1153 | self.name, | |
1150 | self.description) |
|
1154 | self.description) | |
1151 |
|
1155 | |||
1152 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
1156 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
1153 | procUnitConfObj.printattr() |
|
1157 | procUnitConfObj.printattr() | |
1154 |
|
1158 | |||
1155 | def createObjects(self): |
|
1159 | def createObjects(self): | |
1156 |
|
1160 | |||
1157 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
1161 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
1158 | procUnitConfObj.createObjects(self.plotterQueue) |
|
1162 | procUnitConfObj.createObjects(self.plotterQueue) | |
1159 |
|
1163 | |||
1160 | def __connect(self, objIN, thisObj): |
|
1164 | def __connect(self, objIN, thisObj): | |
1161 |
|
1165 | |||
1162 | thisObj.setInput(objIN.getOutputObj()) |
|
1166 | thisObj.setInput(objIN.getOutputObj()) | |
1163 |
|
1167 | |||
1164 | def connectObjects(self): |
|
1168 | def connectObjects(self): | |
1165 |
|
1169 | |||
1166 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
1170 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
1167 |
|
1171 | |||
1168 | inputId = thisPUConfObj.getInputId() |
|
1172 | inputId = thisPUConfObj.getInputId() | |
1169 |
|
1173 | |||
1170 | if int(inputId) == 0: |
|
1174 | if int(inputId) == 0: | |
1171 | continue |
|
1175 | continue | |
1172 |
|
1176 | |||
1173 | #Get input object |
|
1177 | #Get input object | |
1174 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
1178 | puConfINObj = self.procUnitConfObjDict[inputId] | |
1175 | puObjIN = puConfINObj.getProcUnitObj() |
|
1179 | puObjIN = puConfINObj.getProcUnitObj() | |
1176 |
|
1180 | |||
1177 | #Get current object |
|
1181 | #Get current object | |
1178 | thisPUObj = thisPUConfObj.getProcUnitObj() |
|
1182 | thisPUObj = thisPUConfObj.getProcUnitObj() | |
1179 |
|
1183 | |||
1180 | self.__connect(puObjIN, thisPUObj) |
|
1184 | self.__connect(puObjIN, thisPUObj) | |
1181 |
|
1185 | |||
1182 | def __handleError(self, procUnitConfObj, send_email=True): |
|
1186 | def __handleError(self, procUnitConfObj, send_email=True): | |
1183 |
|
1187 | |||
1184 | import socket |
|
1188 | import socket | |
1185 |
|
1189 | |||
1186 | err = traceback.format_exception(sys.exc_info()[0], |
|
1190 | err = traceback.format_exception(sys.exc_info()[0], | |
1187 | sys.exc_info()[1], |
|
1191 | sys.exc_info()[1], | |
1188 | sys.exc_info()[2]) |
|
1192 | sys.exc_info()[2]) | |
1189 |
|
1193 | |||
1190 | print "***** Error occurred in %s *****" %(procUnitConfObj.name) |
|
1194 | print "***** Error occurred in %s *****" %(procUnitConfObj.name) | |
1191 | print "***** %s" %err[-1] |
|
1195 | print "***** %s" %err[-1] | |
1192 |
|
1196 | |||
1193 | message = "".join(err) |
|
1197 | message = "".join(err) | |
1194 |
|
1198 | |||
1195 | sys.stderr.write(message) |
|
1199 | sys.stderr.write(message) | |
1196 |
|
1200 | |||
1197 | if not send_email: |
|
1201 | if not send_email: | |
1198 | return |
|
1202 | return | |
1199 |
|
1203 | |||
1200 | subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name) |
|
1204 | subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name) | |
1201 |
|
1205 | |||
1202 | subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name) |
|
1206 | subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name) | |
1203 | subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname()) |
|
1207 | subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname()) | |
1204 | subtitle += "Working directory: %s\n" %os.path.abspath("./") |
|
1208 | subtitle += "Working directory: %s\n" %os.path.abspath("./") | |
1205 | subtitle += "Configuration file: %s\n" %self.filename |
|
1209 | subtitle += "Configuration file: %s\n" %self.filename | |
1206 | subtitle += "Time: %s\n" %str(datetime.datetime.now()) |
|
1210 | subtitle += "Time: %s\n" %str(datetime.datetime.now()) | |
1207 |
|
1211 | |||
1208 | readUnitConfObj = self.getReadUnitObj() |
|
1212 | readUnitConfObj = self.getReadUnitObj() | |
1209 | if readUnitConfObj: |
|
1213 | if readUnitConfObj: | |
1210 | subtitle += "\nInput parameters:\n" |
|
1214 | subtitle += "\nInput parameters:\n" | |
1211 | subtitle += "[Data path = %s]\n" %readUnitConfObj.path |
|
1215 | subtitle += "[Data path = %s]\n" %readUnitConfObj.path | |
1212 | subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype |
|
1216 | subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype | |
1213 | subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate |
|
1217 | subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate | |
1214 | subtitle += "[End date = %s]\n" %readUnitConfObj.endDate |
|
1218 | subtitle += "[End date = %s]\n" %readUnitConfObj.endDate | |
1215 | subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime |
|
1219 | subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime | |
1216 | subtitle += "[End time = %s]\n" %readUnitConfObj.endTime |
|
1220 | subtitle += "[End time = %s]\n" %readUnitConfObj.endTime | |
1217 |
|
1221 | |||
1218 | adminObj = schainpy.admin.SchainNotify() |
|
1222 | adminObj = schainpy.admin.SchainNotify() | |
1219 | adminObj.sendAlert(message=message, |
|
1223 | adminObj.sendAlert(message=message, | |
1220 | subject=subject, |
|
1224 | subject=subject, | |
1221 | subtitle=subtitle, |
|
1225 | subtitle=subtitle, | |
1222 | filename=self.filename) |
|
1226 | filename=self.filename) | |
1223 |
|
1227 | |||
1224 | def isPaused(self): |
|
1228 | def isPaused(self): | |
1225 | return 0 |
|
1229 | return 0 | |
1226 |
|
1230 | |||
1227 | def isStopped(self): |
|
1231 | def isStopped(self): | |
1228 | return 0 |
|
1232 | return 0 | |
1229 |
|
1233 | |||
1230 | def runController(self): |
|
1234 | def runController(self): | |
1231 | """ |
|
1235 | """ | |
1232 | returns 0 when this process has been stopped, 1 otherwise |
|
1236 | returns 0 when this process has been stopped, 1 otherwise | |
1233 | """ |
|
1237 | """ | |
1234 |
|
1238 | |||
1235 | if self.isPaused(): |
|
1239 | if self.isPaused(): | |
1236 | print "Process suspended" |
|
1240 | print "Process suspended" | |
1237 |
|
1241 | |||
1238 | while True: |
|
1242 | while True: | |
1239 | sleep(0.1) |
|
1243 | sleep(0.1) | |
1240 |
|
1244 | |||
1241 | if not self.isPaused(): |
|
1245 | if not self.isPaused(): | |
1242 | break |
|
1246 | break | |
1243 |
|
1247 | |||
1244 | if self.isStopped(): |
|
1248 | if self.isStopped(): | |
1245 | break |
|
1249 | break | |
1246 |
|
1250 | |||
1247 | print "Process reinitialized" |
|
1251 | print "Process reinitialized" | |
1248 |
|
1252 | |||
1249 | if self.isStopped(): |
|
1253 | if self.isStopped(): | |
1250 | print "Process stopped" |
|
1254 | print "Process stopped" | |
1251 | return 0 |
|
1255 | return 0 | |
1252 |
|
1256 | |||
1253 | return 1 |
|
1257 | return 1 | |
1254 |
|
1258 | |||
1255 | def setFilename(self, filename): |
|
1259 | def setFilename(self, filename): | |
1256 |
|
1260 | |||
1257 | self.filename = filename |
|
1261 | self.filename = filename | |
1258 |
|
1262 | |||
1259 | def setPlotterQueue(self, plotter_queue): |
|
1263 | def setPlotterQueue(self, plotter_queue): | |
1260 |
|
1264 | |||
1261 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" |
|
1265 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" | |
1262 |
|
1266 | |||
1263 | def getPlotterQueue(self): |
|
1267 | def getPlotterQueue(self): | |
1264 |
|
1268 | |||
1265 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" |
|
1269 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" | |
1266 |
|
1270 | |||
1267 | def useExternalPlotter(self): |
|
1271 | def useExternalPlotter(self): | |
1268 |
|
1272 | |||
1269 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" |
|
1273 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" | |
1270 |
|
1274 | |||
1271 |
|
1275 | |||
1272 | def run(self): |
|
1276 | def run(self): | |
1273 |
|
1277 | |||
1274 |
|
1278 | |||
1275 | print "*"*60 |
|
1279 | print "*"*60 | |
1276 | print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__ |
|
1280 | print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__ | |
1277 | print "*"*60 |
|
1281 | print "*"*60 | |
1278 |
|
1282 | |||
1279 |
|
1283 | |||
1280 | keyList = self.procUnitConfObjDict.keys() |
|
1284 | keyList = self.procUnitConfObjDict.keys() | |
1281 | keyList.sort() |
|
1285 | keyList.sort() | |
1282 |
|
1286 | |||
1283 | while(True): |
|
1287 | while(True): | |
1284 |
|
1288 | |||
1285 | is_ok = False |
|
1289 | is_ok = False | |
1286 |
|
1290 | |||
1287 | for procKey in keyList: |
|
1291 | for procKey in keyList: | |
1288 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
1292 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
1289 |
|
1293 | |||
1290 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1294 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
1291 |
|
1295 | |||
1292 | try: |
|
1296 | try: | |
1293 | sts = procUnitConfObj.run() |
|
1297 | sts = procUnitConfObj.run() | |
1294 | is_ok = is_ok or sts |
|
1298 | is_ok = is_ok or sts | |
1295 | except KeyboardInterrupt: |
|
1299 | except KeyboardInterrupt: | |
1296 | is_ok = False |
|
1300 | is_ok = False | |
1297 | break |
|
1301 | break | |
1298 | except ValueError, e: |
|
1302 | except ValueError, e: | |
1299 | sleep(0.5) |
|
1303 | sleep(0.5) | |
1300 | self.__handleError(procUnitConfObj, send_email=True) |
|
1304 | self.__handleError(procUnitConfObj, send_email=True) | |
1301 | is_ok = False |
|
1305 | is_ok = False | |
1302 | break |
|
1306 | break | |
1303 | except: |
|
1307 | except: | |
1304 | sleep(0.5) |
|
1308 | sleep(0.5) | |
1305 | self.__handleError(procUnitConfObj) |
|
1309 | self.__handleError(procUnitConfObj) | |
1306 | is_ok = False |
|
1310 | is_ok = False | |
1307 | break |
|
1311 | break | |
1308 |
|
1312 | |||
1309 | #If every process unit finished so end process |
|
1313 | #If every process unit finished so end process | |
1310 | if not(is_ok): |
|
1314 | if not(is_ok): | |
1311 | # print "Every process unit have finished" |
|
1315 | # print "Every process unit have finished" | |
1312 | break |
|
1316 | break | |
1313 |
|
1317 | |||
1314 | if not self.runController(): |
|
1318 | if not self.runController(): | |
1315 | break |
|
1319 | break | |
1316 |
|
1320 | |||
1317 | #Closing every process |
|
1321 | #Closing every process | |
1318 | for procKey in keyList: |
|
1322 | for procKey in keyList: | |
1319 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1323 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
1320 | procUnitConfObj.close() |
|
1324 | procUnitConfObj.close() | |
1321 |
|
1325 | |||
1322 | print "Process finished" |
|
1326 | print "Process finished" | |
1323 |
|
1327 | |||
1324 | def start(self, filename=None): |
|
1328 | def start(self, filename=None): | |
1325 |
|
1329 | |||
1326 | self.writeXml(filename) |
|
1330 | self.writeXml(filename) | |
1327 | self.createObjects() |
|
1331 | self.createObjects() | |
1328 | self.connectObjects() |
|
1332 | self.connectObjects() | |
1329 | self.run() |
|
1333 | self.run() |
@@ -1,12 +1,12 | |||||
1 | #from schainpy.model.data.jrodata import * |
|
1 | #from schainpy.model.data.jrodata import * | |
2 | # from schainpy.model.io.jrodataIO import * |
|
2 | # from schainpy.model.io.jrodataIO import * | |
3 | # from schainpy.model.proc.jroprocessing import * |
|
3 | # from schainpy.model.proc.jroprocessing import * | |
4 | # from schainpy.model.graphics.jroplot import * |
|
4 | # from schainpy.model.graphics.jroplot import * | |
5 | # from schainpy.model.utils.jroutils import * |
|
5 | # from schainpy.model.utils.jroutils import * | |
6 | # from schainpy.serializer import * |
|
6 | # from schainpy.serializer import * | |
7 |
|
7 | |||
8 | from data import * |
|
8 | from data import * | |
9 | from io import * |
|
9 | from io import * | |
10 | from proc import * |
|
10 | from proc import * | |
11 |
|
|
11 | from graphics import * | |
12 | from utils import * |
|
12 | from utils import * |
@@ -1,783 +1,964 | |||||
1 |
|
1 | |||
2 | import os |
|
2 | import os | |
3 | import zmq |
|
3 | import zmq | |
4 | import time |
|
4 | import time | |
5 | import numpy |
|
5 | import numpy | |
6 | import datetime |
|
6 | import datetime | |
7 | import numpy as np |
|
7 | import numpy as np | |
8 | import matplotlib |
|
8 | import matplotlib | |
|
9 | import glob | |||
9 | matplotlib.use('TkAgg') |
|
10 | matplotlib.use('TkAgg') | |
10 | import matplotlib.pyplot as plt |
|
11 | import matplotlib.pyplot as plt | |
11 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
12 | from mpl_toolkits.axes_grid1 import make_axes_locatable | |
12 | from matplotlib.ticker import FuncFormatter, LinearLocator |
|
13 | from matplotlib.ticker import FuncFormatter, LinearLocator | |
13 | from multiprocessing import Process |
|
14 | from multiprocessing import Process | |
14 |
|
15 | |||
15 | from schainpy.model.proc.jroproc_base import Operation |
|
16 | from schainpy.model.proc.jroproc_base import Operation | |
16 |
|
17 | |||
17 | plt.ion() |
|
18 | plt.ion() | |
18 |
|
19 | |||
19 | func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) |
|
20 | func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) | |
20 | fromtimestamp = lambda x, mintime : (datetime.datetime.utcfromtimestamp(mintime).replace(hour=(x + 5), minute=0) - d1970).total_seconds() |
|
21 | fromtimestamp = lambda x, mintime : (datetime.datetime.utcfromtimestamp(mintime).replace(hour=(x + 5), minute=0) - d1970).total_seconds() | |
21 |
|
22 | |||
22 |
|
23 | |||
23 | d1970 = datetime.datetime(1970,1,1) |
|
24 | d1970 = datetime.datetime(1970,1,1) | |
24 |
|
25 | |||
25 | class PlotData(Operation, Process): |
|
26 | class PlotData(Operation, Process): | |
26 |
|
27 | |||
27 | CODE = 'Figure' |
|
28 | CODE = 'Figure' | |
28 | colormap = 'jro' |
|
29 | colormap = 'jro' | |
29 | CONFLATE = False |
|
30 | CONFLATE = False | |
30 | __MAXNUMX = 80 |
|
31 | __MAXNUMX = 80 | |
31 | __missing = 1E30 |
|
32 | __missing = 1E30 | |
32 |
|
33 | |||
33 | def __init__(self, **kwargs): |
|
34 | def __init__(self, **kwargs): | |
34 |
|
35 | |||
35 | Operation.__init__(self, plot=True, **kwargs) |
|
36 | Operation.__init__(self, plot=True, **kwargs) | |
36 | Process.__init__(self) |
|
37 | Process.__init__(self) | |
37 | self.kwargs['code'] = self.CODE |
|
38 | self.kwargs['code'] = self.CODE | |
38 | self.mp = False |
|
39 | self.mp = False | |
39 | self.dataOut = None |
|
40 | self.dataOut = None | |
40 | self.isConfig = False |
|
41 | self.isConfig = False | |
41 | self.figure = None |
|
42 | self.figure = None | |
42 | self.axes = [] |
|
43 | self.axes = [] | |
43 | self.localtime = kwargs.pop('localtime', True) |
|
44 | self.localtime = kwargs.pop('localtime', True) | |
44 | self.show = kwargs.get('show', True) |
|
45 | self.show = kwargs.get('show', True) | |
45 | self.save = kwargs.get('save', False) |
|
46 | self.save = kwargs.get('save', False) | |
46 | self.colormap = kwargs.get('colormap', self.colormap) |
|
47 | self.colormap = kwargs.get('colormap', self.colormap) | |
47 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') |
|
48 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') | |
48 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') |
|
49 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') | |
49 | self.showprofile = kwargs.get('showprofile', True) |
|
50 | self.showprofile = kwargs.get('showprofile', True) | |
50 | self.title = kwargs.get('wintitle', '') |
|
51 | self.title = kwargs.get('wintitle', '') | |
51 | self.xaxis = kwargs.get('xaxis', 'frequency') |
|
52 | self.xaxis = kwargs.get('xaxis', 'frequency') | |
52 | self.zmin = kwargs.get('zmin', None) |
|
53 | self.zmin = kwargs.get('zmin', None) | |
53 | self.zmax = kwargs.get('zmax', None) |
|
54 | self.zmax = kwargs.get('zmax', None) | |
54 | self.xmin = kwargs.get('xmin', None) |
|
55 | self.xmin = kwargs.get('xmin', None) | |
55 | self.xmax = kwargs.get('xmax', None) |
|
56 | self.xmax = kwargs.get('xmax', None) | |
56 | self.xrange = kwargs.get('xrange', 24) |
|
57 | self.xrange = kwargs.get('xrange', 24) | |
57 | self.ymin = kwargs.get('ymin', None) |
|
58 | self.ymin = kwargs.get('ymin', None) | |
58 | self.ymax = kwargs.get('ymax', None) |
|
59 | self.ymax = kwargs.get('ymax', None) | |
59 | self.__MAXNUMY = kwargs.get('decimation', 5000) |
|
60 | self.__MAXNUMY = kwargs.get('decimation', 5000) | |
60 | self.throttle_value = 5 |
|
61 | self.throttle_value = 5 | |
61 | self.times = [] |
|
62 | self.times = [] | |
62 | #self.interactive = self.kwargs['parent'] |
|
63 | #self.interactive = self.kwargs['parent'] | |
63 |
|
64 | |||
|
65 | ''' | |||
|
66 | this new parameter is created to plot data from varius channels at different figures | |||
|
67 | 1. crear una lista de figuras donde se puedan plotear las figuras, | |||
|
68 | 2. dar las opciones de configuracion a cada figura, estas opciones son iguales para ambas figuras | |||
|
69 | 3. probar? | |||
|
70 | ''' | |||
|
71 | self.ind_plt_ch = kwargs.get('ind_plt_ch', False) | |||
|
72 | self.figurelist = None | |||
|
73 | ||||
64 |
|
74 | |||
65 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
75 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): | |
66 |
|
76 | |||
67 | if x_buffer.shape[0] < 2: |
|
77 | if x_buffer.shape[0] < 2: | |
68 | return x_buffer, y_buffer, z_buffer |
|
78 | return x_buffer, y_buffer, z_buffer | |
69 |
|
79 | |||
70 | deltas = x_buffer[1:] - x_buffer[0:-1] |
|
80 | deltas = x_buffer[1:] - x_buffer[0:-1] | |
71 | x_median = np.median(deltas) |
|
81 | x_median = np.median(deltas) | |
72 |
|
82 | |||
73 | index = np.where(deltas > 5*x_median) |
|
83 | index = np.where(deltas > 5*x_median) | |
74 |
|
84 | |||
75 | if len(index[0]) != 0: |
|
85 | if len(index[0]) != 0: | |
76 | z_buffer[::, index[0], ::] = self.__missing |
|
86 | z_buffer[::, index[0], ::] = self.__missing | |
77 | z_buffer = np.ma.masked_inside(z_buffer, |
|
87 | z_buffer = np.ma.masked_inside(z_buffer, | |
78 | 0.99*self.__missing, |
|
88 | 0.99*self.__missing, | |
79 | 1.01*self.__missing) |
|
89 | 1.01*self.__missing) | |
80 |
|
90 | |||
81 | return x_buffer, y_buffer, z_buffer |
|
91 | return x_buffer, y_buffer, z_buffer | |
82 |
|
92 | |||
83 | def decimate(self): |
|
93 | def decimate(self): | |
84 |
|
94 | |||
85 | # dx = int(len(self.x)/self.__MAXNUMX) + 1 |
|
95 | # dx = int(len(self.x)/self.__MAXNUMX) + 1 | |
86 | dy = int(len(self.y)/self.__MAXNUMY) + 1 |
|
96 | dy = int(len(self.y)/self.__MAXNUMY) + 1 | |
87 |
|
97 | |||
88 | # x = self.x[::dx] |
|
98 | # x = self.x[::dx] | |
89 | x = self.x |
|
99 | x = self.x | |
90 | y = self.y[::dy] |
|
100 | y = self.y[::dy] | |
91 | z = self.z[::, ::, ::dy] |
|
101 | z = self.z[::, ::, ::dy] | |
92 |
|
102 | |||
93 | return x, y, z |
|
103 | return x, y, z | |
94 |
|
104 | |||
|
105 | ''' | |||
|
106 | JM: | |||
|
107 | elimana las otras imagenes generadas debido a que lso workers no llegan en orden y le pueden | |||
|
108 | poner otro tiempo a la figura q no necesariamente es el ultimo. | |||
|
109 | Solo se realiza cuando termina la imagen. | |||
|
110 | Problemas: | |||
|
111 | ||||
|
112 | File "/home/ci-81/workspace/schainv2.3/schainpy/model/graphics/jroplot_data.py", line 145, in __plot | |||
|
113 | for n, eachfigure in enumerate(self.figurelist): | |||
|
114 | TypeError: 'NoneType' object is not iterable | |||
|
115 | ||||
|
116 | ''' | |||
|
117 | def deleteanotherfiles(self): | |||
|
118 | figurenames=[] | |||
|
119 | if self.figurelist != None: | |||
|
120 | for n, eachfigure in enumerate(self.figurelist): | |||
|
121 | #add specific name for each channel in channelList | |||
|
122 | ghostfigname = os.path.join(self.save, '{}_{}_{}'.format(self.titles[n].replace(' ',''),self.CODE, | |||
|
123 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d'))) | |||
|
124 | figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE, | |||
|
125 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |||
|
126 | ||||
|
127 | for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures | |||
|
128 | if ghostfigure != figname: | |||
|
129 | os.remove(ghostfigure) | |||
|
130 | print 'Removing GhostFigures:' , figname | |||
|
131 | else : | |||
|
132 | '''Erasing ghost images for just on******************''' | |||
|
133 | ghostfigname = os.path.join(self.save, '{}_{}'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d'))) | |||
|
134 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |||
|
135 | for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures | |||
|
136 | if ghostfigure != figname: | |||
|
137 | os.remove(ghostfigure) | |||
|
138 | print 'Removing GhostFigures:' , figname | |||
|
139 | ||||
95 | def __plot(self): |
|
140 | def __plot(self): | |
96 |
|
141 | |||
97 | print 'plotting...{}'.format(self.CODE) |
|
142 | print 'plotting...{}'.format(self.CODE) | |
98 |
|
143 | if self.ind_plt_ch is False : #standard | ||
99 | if self.show: |
|
144 | if self.show: | |
100 | self.figure.show() |
|
145 | self.figure.show() | |
101 |
|
146 | self.plot() | ||
102 | self.plot() |
|
147 | plt.tight_layout() | |
103 | plt.tight_layout() |
|
148 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), | |
104 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), |
|
|||
105 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) |
|
149 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
|
150 | else : | |||
|
151 | print 'len(self.figurelist): ',len(self.figurelist) | |||
|
152 | for n, eachfigure in enumerate(self.figurelist): | |||
|
153 | if self.show: | |||
|
154 | eachfigure.show() | |||
|
155 | ||||
|
156 | self.plot() | |||
|
157 | eachfigure.tight_layout() # ajuste de cada subplot | |||
|
158 | eachfigure.canvas.manager.set_window_title('{} {} - {}'.format(self.title[n], self.CODE.upper(), | |||
|
159 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |||
|
160 | ||||
|
161 | # if self.save: | |||
|
162 | # if self.ind_plt_ch is False : #standard | |||
|
163 | # figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |||
|
164 | # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |||
|
165 | # print 'Saving figure: {}'.format(figname) | |||
|
166 | # self.figure.savefig(figname) | |||
|
167 | # else : | |||
|
168 | # for n, eachfigure in enumerate(self.figurelist): | |||
|
169 | # #add specific name for each channel in channelList | |||
|
170 | # figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE, | |||
|
171 | # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |||
|
172 | # | |||
|
173 | # print 'Saving figure: {}'.format(figname) | |||
|
174 | # eachfigure.savefig(figname) | |||
|
175 | ||||
|
176 | if self.ind_plt_ch is False : | |||
|
177 | self.figure.canvas.draw() | |||
|
178 | else : | |||
|
179 | for eachfigure in self.figurelist: | |||
|
180 | eachfigure.canvas.draw() | |||
106 |
|
181 | |||
107 | if self.save: |
|
182 | if self.save: | |
108 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, |
|
183 | if self.ind_plt_ch is False : #standard | |
109 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) |
|
184 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
110 | print 'Saving figure: {}'.format(figname) |
|
185 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
111 | self.figure.savefig(figname) |
|
186 | print 'Saving figure: {}'.format(figname) | |
|
187 | self.figure.savefig(figname) | |||
|
188 | else : | |||
|
189 | for n, eachfigure in enumerate(self.figurelist): | |||
|
190 | #add specific name for each channel in channelList | |||
|
191 | figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE, | |||
|
192 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |||
|
193 | ||||
|
194 | print 'Saving figure: {}'.format(figname) | |||
|
195 | eachfigure.savefig(figname) | |||
112 |
|
196 | |||
113 | self.figure.canvas.draw() |
|
|||
114 |
|
197 | |||
115 | def plot(self): |
|
198 | def plot(self): | |
116 |
|
199 | |||
117 | print 'plotting...{}'.format(self.CODE.upper()) |
|
200 | print 'plotting...{}'.format(self.CODE.upper()) | |
118 | return |
|
201 | return | |
119 |
|
202 | |||
120 | def run(self): |
|
203 | def run(self): | |
121 |
|
204 | |||
122 | print '[Starting] {}'.format(self.name) |
|
205 | print '[Starting] {}'.format(self.name) | |
123 |
|
206 | |||
124 | context = zmq.Context() |
|
207 | context = zmq.Context() | |
125 | receiver = context.socket(zmq.SUB) |
|
208 | receiver = context.socket(zmq.SUB) | |
126 | receiver.setsockopt(zmq.SUBSCRIBE, '') |
|
209 | receiver.setsockopt(zmq.SUBSCRIBE, '') | |
127 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) |
|
210 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) | |
128 |
|
211 | |||
129 | if 'server' in self.kwargs['parent']: |
|
212 | if 'server' in self.kwargs['parent']: | |
130 | receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) |
|
213 | receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) | |
131 | else: |
|
214 | else: | |
132 | receiver.connect("ipc:///tmp/zmq.plots") |
|
215 | receiver.connect("ipc:///tmp/zmq.plots") | |
133 |
|
216 | |||
134 | seconds_passed = 0 |
|
217 | seconds_passed = 0 | |
135 |
|
218 | |||
136 | while True: |
|
219 | while True: | |
137 | try: |
|
220 | try: | |
138 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK |
|
221 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK | |
139 | self.started = self.data['STARTED'] |
|
222 | self.started = self.data['STARTED'] | |
140 | self.dataOut = self.data['dataOut'] |
|
223 | self.dataOut = self.data['dataOut'] | |
141 |
|
224 | |||
142 | if (len(self.times) < len(self.data['times']) and not self.started and self.data['ENDED']): |
|
225 | if (len(self.times) < len(self.data['times']) and not self.started and self.data['ENDED']): | |
143 | continue |
|
226 | continue | |
144 |
|
227 | |||
145 | self.times = self.data['times'] |
|
228 | self.times = self.data['times'] | |
146 | self.times.sort() |
|
229 | self.times.sort() | |
147 | self.throttle_value = self.data['throttle'] |
|
230 | self.throttle_value = self.data['throttle'] | |
148 | self.min_time = self.times[0] |
|
231 | self.min_time = self.times[0] | |
149 | self.max_time = self.times[-1] |
|
232 | self.max_time = self.times[-1] | |
150 |
|
233 | |||
151 | if self.isConfig is False: |
|
234 | if self.isConfig is False: | |
152 | print 'setting up' |
|
235 | print 'setting up' | |
153 | self.setup() |
|
236 | self.setup() | |
154 | self.isConfig = True |
|
237 | self.isConfig = True | |
155 | self.__plot() |
|
238 | self.__plot() | |
156 |
|
239 | |||
157 | if self.data['ENDED'] is True: |
|
240 | if self.data['ENDED'] is True: | |
158 | print '********GRAPHIC ENDED********' |
|
241 | print '********GRAPHIC ENDED********' | |
159 | self.ended = True |
|
242 | self.ended = True | |
160 | self.isConfig = False |
|
243 | self.isConfig = False | |
161 | self.__plot() |
|
244 | self.__plot() | |
|
245 | self.deleteanotherfiles() #CLPDG | |||
162 | elif seconds_passed >= self.data['throttle']: |
|
246 | elif seconds_passed >= self.data['throttle']: | |
163 | print 'passed', seconds_passed |
|
247 | print 'passed', seconds_passed | |
164 | self.__plot() |
|
248 | self.__plot() | |
165 | seconds_passed = 0 |
|
249 | seconds_passed = 0 | |
166 |
|
250 | |||
167 | except zmq.Again as e: |
|
251 | except zmq.Again as e: | |
168 | print 'Waiting for data...' |
|
252 | print 'Waiting for data...' | |
169 | plt.pause(2) |
|
253 | plt.pause(2) | |
170 | seconds_passed += 2 |
|
254 | seconds_passed += 2 | |
171 |
|
255 | |||
172 | def close(self): |
|
256 | def close(self): | |
173 | if self.dataOut: |
|
257 | if self.dataOut: | |
174 | self.__plot() |
|
258 | self.__plot() | |
175 |
|
259 | |||
176 |
|
260 | |||
177 | class PlotSpectraData(PlotData): |
|
261 | class PlotSpectraData(PlotData): | |
178 |
|
262 | |||
179 | CODE = 'spc' |
|
263 | CODE = 'spc' | |
180 | colormap = 'jro' |
|
264 | colormap = 'jro' | |
181 | CONFLATE = False |
|
265 | CONFLATE = False | |
182 |
|
266 | |||
183 | def setup(self): |
|
267 | def setup(self): | |
184 |
|
268 | |||
185 | ncolspan = 1 |
|
269 | ncolspan = 1 | |
186 | colspan = 1 |
|
270 | colspan = 1 | |
187 | self.ncols = int(numpy.sqrt(self.dataOut.nChannels)+0.9) |
|
271 | self.ncols = int(numpy.sqrt(self.dataOut.nChannels)+0.9) | |
188 | self.nrows = int(self.dataOut.nChannels*1./self.ncols + 0.9) |
|
272 | self.nrows = int(self.dataOut.nChannels*1./self.ncols + 0.9) | |
189 | self.width = 3.6*self.ncols |
|
273 | self.width = 3.6*self.ncols | |
190 | self.height = 3.2*self.nrows |
|
274 | self.height = 3.2*self.nrows | |
191 | if self.showprofile: |
|
275 | if self.showprofile: | |
192 | ncolspan = 3 |
|
276 | ncolspan = 3 | |
193 | colspan = 2 |
|
277 | colspan = 2 | |
194 | self.width += 1.2*self.ncols |
|
278 | self.width += 1.2*self.ncols | |
195 |
|
279 | |||
196 | self.ylabel = 'Range [Km]' |
|
280 | self.ylabel = 'Range [Km]' | |
197 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] |
|
281 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] | |
198 |
|
282 | |||
199 | if self.figure is None: |
|
283 | if self.figure is None: | |
200 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
284 | self.figure = plt.figure(figsize=(self.width, self.height), | |
201 | edgecolor='k', |
|
285 | edgecolor='k', | |
202 | facecolor='w') |
|
286 | facecolor='w') | |
203 | else: |
|
287 | else: | |
204 | self.figure.clf() |
|
288 | self.figure.clf() | |
205 |
|
289 | |||
206 | n = 0 |
|
290 | n = 0 | |
207 | for y in range(self.nrows): |
|
291 | for y in range(self.nrows): | |
208 | for x in range(self.ncols): |
|
292 | for x in range(self.ncols): | |
209 | if n >= self.dataOut.nChannels: |
|
293 | if n >= self.dataOut.nChannels: | |
210 | break |
|
294 | break | |
211 | ax = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan), 1, colspan) |
|
295 | ax = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan), 1, colspan) | |
212 | if self.showprofile: |
|
296 | if self.showprofile: | |
213 | ax.ax_profile = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan+colspan), 1, 1) |
|
297 | ax.ax_profile = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan+colspan), 1, 1) | |
214 |
|
298 | |||
215 | ax.firsttime = True |
|
299 | ax.firsttime = True | |
216 | self.axes.append(ax) |
|
300 | self.axes.append(ax) | |
217 | n += 1 |
|
301 | n += 1 | |
218 |
|
302 | |||
219 | def plot(self): |
|
303 | def plot(self): | |
220 |
|
304 | |||
221 | if self.xaxis == "frequency": |
|
305 | if self.xaxis == "frequency": | |
222 | x = self.dataOut.getFreqRange(1)/1000. |
|
306 | x = self.dataOut.getFreqRange(1)/1000. | |
223 | xlabel = "Frequency (kHz)" |
|
307 | xlabel = "Frequency (kHz)" | |
224 | elif self.xaxis == "time": |
|
308 | elif self.xaxis == "time": | |
225 | x = self.dataOut.getAcfRange(1) |
|
309 | x = self.dataOut.getAcfRange(1) | |
226 | xlabel = "Time (ms)" |
|
310 | xlabel = "Time (ms)" | |
227 | else: |
|
311 | else: | |
228 | x = self.dataOut.getVelRange(1) |
|
312 | x = self.dataOut.getVelRange(1) | |
229 | xlabel = "Velocity (m/s)" |
|
313 | xlabel = "Velocity (m/s)" | |
230 |
|
314 | |||
231 | y = self.dataOut.getHeiRange() |
|
315 | y = self.dataOut.getHeiRange() | |
232 | z = self.data[self.CODE] |
|
316 | z = self.data[self.CODE] | |
233 |
|
317 | |||
234 | for n, ax in enumerate(self.axes): |
|
318 | for n, ax in enumerate(self.axes): | |
235 |
|
||||
236 | if ax.firsttime: |
|
319 | if ax.firsttime: | |
237 | self.xmax = self.xmax if self.xmax else np.nanmax(x) |
|
320 | self.xmax = self.xmax if self.xmax else np.nanmax(x) | |
238 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
321 | self.xmin = self.xmin if self.xmin else -self.xmax | |
239 | self.ymin = self.ymin if self.ymin else np.nanmin(y) |
|
322 | self.ymin = self.ymin if self.ymin else np.nanmin(y) | |
240 | self.ymax = self.ymax if self.ymax else np.nanmax(y) |
|
323 | self.ymax = self.ymax if self.ymax else np.nanmax(y) | |
241 | self.zmin = self.zmin if self.zmin else np.nanmin(z) |
|
324 | self.zmin = self.zmin if self.zmin else np.nanmin(z) | |
242 | self.zmax = self.zmax if self.zmax else np.nanmax(z) |
|
325 | self.zmax = self.zmax if self.zmax else np.nanmax(z) | |
243 | ax.plot = ax.pcolormesh(x, y, z[n].T, |
|
326 | ax.plot = ax.pcolormesh(x, y, z[n].T, | |
244 | vmin=self.zmin, |
|
327 | vmin=self.zmin, | |
245 | vmax=self.zmax, |
|
328 | vmax=self.zmax, | |
246 | cmap=plt.get_cmap(self.colormap) |
|
329 | cmap=plt.get_cmap(self.colormap) | |
247 | ) |
|
330 | ) | |
248 | divider = make_axes_locatable(ax) |
|
331 | divider = make_axes_locatable(ax) | |
249 | cax = divider.new_horizontal(size='3%', pad=0.05) |
|
332 | cax = divider.new_horizontal(size='3%', pad=0.05) | |
250 | self.figure.add_axes(cax) |
|
333 | self.figure.add_axes(cax) | |
251 | plt.colorbar(ax.plot, cax) |
|
334 | plt.colorbar(ax.plot, cax) | |
252 |
|
335 | |||
253 | ax.set_xlim(self.xmin, self.xmax) |
|
336 | ax.set_xlim(self.xmin, self.xmax) | |
254 | ax.set_ylim(self.ymin, self.ymax) |
|
337 | ax.set_ylim(self.ymin, self.ymax) | |
255 |
|
338 | |||
256 | ax.set_ylabel(self.ylabel) |
|
339 | ax.set_ylabel(self.ylabel) | |
257 | ax.set_xlabel(xlabel) |
|
340 | ax.set_xlabel(xlabel) | |
258 |
|
341 | |||
259 | ax.firsttime = False |
|
342 | ax.firsttime = False | |
260 |
|
343 | |||
261 | if self.showprofile: |
|
344 | if self.showprofile: | |
262 | ax.plot_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0] |
|
345 | ax.plot_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0] | |
263 | ax.ax_profile.set_xlim(self.zmin, self.zmax) |
|
346 | ax.ax_profile.set_xlim(self.zmin, self.zmax) | |
264 | ax.ax_profile.set_ylim(self.ymin, self.ymax) |
|
347 | ax.ax_profile.set_ylim(self.ymin, self.ymax) | |
265 | ax.ax_profile.set_xlabel('dB') |
|
348 | ax.ax_profile.set_xlabel('dB') | |
266 | ax.ax_profile.grid(b=True, axis='x') |
|
349 | ax.ax_profile.grid(b=True, axis='x') | |
267 | ax.plot_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y, |
|
350 | ax.plot_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y, | |
268 | color="k", linestyle="dashed", lw=2)[0] |
|
351 | color="k", linestyle="dashed", lw=2)[0] | |
269 | [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()] |
|
352 | [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()] | |
270 | else: |
|
353 | else: | |
271 | ax.plot.set_array(z[n].T.ravel()) |
|
354 | ax.plot.set_array(z[n].T.ravel()) | |
272 | if self.showprofile: |
|
355 | if self.showprofile: | |
273 | ax.plot_profile.set_data(self.data['rti'][self.max_time][n], y) |
|
356 | ax.plot_profile.set_data(self.data['rti'][self.max_time][n], y) | |
274 | ax.plot_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y) |
|
357 | ax.plot_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y) | |
275 |
|
358 | |||
276 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), |
|
359 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), | |
277 | size=8) |
|
360 | size=8) | |
278 | self.saveTime = self.max_time |
|
361 | self.saveTime = self.max_time | |
279 |
|
362 | |||
280 |
|
363 | |||
281 | class PlotCrossSpectraData(PlotData): |
|
364 | class PlotCrossSpectraData(PlotData): | |
282 |
|
365 | |||
283 | CODE = 'cspc' |
|
366 | CODE = 'cspc' | |
284 | zmin_coh = None |
|
367 | zmin_coh = None | |
285 | zmax_coh = None |
|
368 | zmax_coh = None | |
286 | zmin_phase = None |
|
369 | zmin_phase = None | |
287 | zmax_phase = None |
|
370 | zmax_phase = None | |
288 | CONFLATE = False |
|
371 | CONFLATE = False | |
289 |
|
372 | |||
290 | def setup(self): |
|
373 | def setup(self): | |
291 |
|
374 | |||
292 | ncolspan = 1 |
|
375 | ncolspan = 1 | |
293 | colspan = 1 |
|
376 | colspan = 1 | |
294 | self.ncols = 2 |
|
377 | self.ncols = 2 | |
295 | self.nrows = self.dataOut.nPairs |
|
378 | self.nrows = self.dataOut.nPairs | |
296 | self.width = 3.6*self.ncols |
|
379 | self.width = 3.6*self.ncols | |
297 | self.height = 3.2*self.nrows |
|
380 | self.height = 3.2*self.nrows | |
298 |
|
381 | |||
299 | self.ylabel = 'Range [Km]' |
|
382 | self.ylabel = 'Range [Km]' | |
300 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] |
|
383 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] | |
301 |
|
384 | |||
302 | if self.figure is None: |
|
385 | if self.figure is None: | |
303 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
386 | self.figure = plt.figure(figsize=(self.width, self.height), | |
304 | edgecolor='k', |
|
387 | edgecolor='k', | |
305 | facecolor='w') |
|
388 | facecolor='w') | |
306 | else: |
|
389 | else: | |
307 | self.figure.clf() |
|
390 | self.figure.clf() | |
308 |
|
391 | |||
309 | for y in range(self.nrows): |
|
392 | for y in range(self.nrows): | |
310 | for x in range(self.ncols): |
|
393 | for x in range(self.ncols): | |
311 | ax = plt.subplot2grid((self.nrows, self.ncols), (y, x), 1, 1) |
|
394 | ax = plt.subplot2grid((self.nrows, self.ncols), (y, x), 1, 1) | |
312 | ax.firsttime = True |
|
395 | ax.firsttime = True | |
313 | self.axes.append(ax) |
|
396 | self.axes.append(ax) | |
314 |
|
397 | |||
315 | def plot(self): |
|
398 | def plot(self): | |
316 |
|
399 | |||
317 | if self.xaxis == "frequency": |
|
400 | if self.xaxis == "frequency": | |
318 | x = self.dataOut.getFreqRange(1)/1000. |
|
401 | x = self.dataOut.getFreqRange(1)/1000. | |
319 | xlabel = "Frequency (kHz)" |
|
402 | xlabel = "Frequency (kHz)" | |
320 | elif self.xaxis == "time": |
|
403 | elif self.xaxis == "time": | |
321 | x = self.dataOut.getAcfRange(1) |
|
404 | x = self.dataOut.getAcfRange(1) | |
322 | xlabel = "Time (ms)" |
|
405 | xlabel = "Time (ms)" | |
323 | else: |
|
406 | else: | |
324 | x = self.dataOut.getVelRange(1) |
|
407 | x = self.dataOut.getVelRange(1) | |
325 | xlabel = "Velocity (m/s)" |
|
408 | xlabel = "Velocity (m/s)" | |
326 |
|
409 | |||
327 | y = self.dataOut.getHeiRange() |
|
410 | y = self.dataOut.getHeiRange() | |
328 | z_coh = self.data['cspc_coh'] |
|
411 | z_coh = self.data['cspc_coh'] | |
329 | z_phase = self.data['cspc_phase'] |
|
412 | z_phase = self.data['cspc_phase'] | |
330 |
|
413 | |||
331 | for n in range(self.nrows): |
|
414 | for n in range(self.nrows): | |
332 | ax = self.axes[2*n] |
|
415 | ax = self.axes[2*n] | |
333 | ax1 = self.axes[2*n+1] |
|
416 | ax1 = self.axes[2*n+1] | |
334 | if ax.firsttime: |
|
417 | if ax.firsttime: | |
335 | self.xmax = self.xmax if self.xmax else np.nanmax(x) |
|
418 | self.xmax = self.xmax if self.xmax else np.nanmax(x) | |
336 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
419 | self.xmin = self.xmin if self.xmin else -self.xmax | |
337 | self.ymin = self.ymin if self.ymin else np.nanmin(y) |
|
420 | self.ymin = self.ymin if self.ymin else np.nanmin(y) | |
338 | self.ymax = self.ymax if self.ymax else np.nanmax(y) |
|
421 | self.ymax = self.ymax if self.ymax else np.nanmax(y) | |
339 | self.zmin_coh = self.zmin_coh if self.zmin_coh else 0.0 |
|
422 | self.zmin_coh = self.zmin_coh if self.zmin_coh else 0.0 | |
340 | self.zmax_coh = self.zmax_coh if self.zmax_coh else 1.0 |
|
423 | self.zmax_coh = self.zmax_coh if self.zmax_coh else 1.0 | |
341 | self.zmin_phase = self.zmin_phase if self.zmin_phase else -180 |
|
424 | self.zmin_phase = self.zmin_phase if self.zmin_phase else -180 | |
342 | self.zmax_phase = self.zmax_phase if self.zmax_phase else 180 |
|
425 | self.zmax_phase = self.zmax_phase if self.zmax_phase else 180 | |
343 |
|
426 | |||
344 | ax.plot = ax.pcolormesh(x, y, z_coh[n].T, |
|
427 | ax.plot = ax.pcolormesh(x, y, z_coh[n].T, | |
345 | vmin=self.zmin_coh, |
|
428 | vmin=self.zmin_coh, | |
346 | vmax=self.zmax_coh, |
|
429 | vmax=self.zmax_coh, | |
347 | cmap=plt.get_cmap(self.colormap_coh) |
|
430 | cmap=plt.get_cmap(self.colormap_coh) | |
348 | ) |
|
431 | ) | |
349 | divider = make_axes_locatable(ax) |
|
432 | divider = make_axes_locatable(ax) | |
350 | cax = divider.new_horizontal(size='3%', pad=0.05) |
|
433 | cax = divider.new_horizontal(size='3%', pad=0.05) | |
351 | self.figure.add_axes(cax) |
|
434 | self.figure.add_axes(cax) | |
352 | plt.colorbar(ax.plot, cax) |
|
435 | plt.colorbar(ax.plot, cax) | |
353 |
|
436 | |||
354 | ax.set_xlim(self.xmin, self.xmax) |
|
437 | ax.set_xlim(self.xmin, self.xmax) | |
355 | ax.set_ylim(self.ymin, self.ymax) |
|
438 | ax.set_ylim(self.ymin, self.ymax) | |
356 |
|
439 | |||
357 | ax.set_ylabel(self.ylabel) |
|
440 | ax.set_ylabel(self.ylabel) | |
358 | ax.set_xlabel(xlabel) |
|
441 | ax.set_xlabel(xlabel) | |
359 | ax.firsttime = False |
|
442 | ax.firsttime = False | |
360 |
|
443 | |||
361 | ax1.plot = ax1.pcolormesh(x, y, z_phase[n].T, |
|
444 | ax1.plot = ax1.pcolormesh(x, y, z_phase[n].T, | |
362 | vmin=self.zmin_phase, |
|
445 | vmin=self.zmin_phase, | |
363 | vmax=self.zmax_phase, |
|
446 | vmax=self.zmax_phase, | |
364 | cmap=plt.get_cmap(self.colormap_phase) |
|
447 | cmap=plt.get_cmap(self.colormap_phase) | |
365 | ) |
|
448 | ) | |
366 | divider = make_axes_locatable(ax1) |
|
449 | divider = make_axes_locatable(ax1) | |
367 | cax = divider.new_horizontal(size='3%', pad=0.05) |
|
450 | cax = divider.new_horizontal(size='3%', pad=0.05) | |
368 | self.figure.add_axes(cax) |
|
451 | self.figure.add_axes(cax) | |
369 | plt.colorbar(ax1.plot, cax) |
|
452 | plt.colorbar(ax1.plot, cax) | |
370 |
|
453 | |||
371 | ax1.set_xlim(self.xmin, self.xmax) |
|
454 | ax1.set_xlim(self.xmin, self.xmax) | |
372 | ax1.set_ylim(self.ymin, self.ymax) |
|
455 | ax1.set_ylim(self.ymin, self.ymax) | |
373 |
|
456 | |||
374 | ax1.set_ylabel(self.ylabel) |
|
457 | ax1.set_ylabel(self.ylabel) | |
375 | ax1.set_xlabel(xlabel) |
|
458 | ax1.set_xlabel(xlabel) | |
376 | ax1.firsttime = False |
|
459 | ax1.firsttime = False | |
377 | else: |
|
460 | else: | |
378 | ax.plot.set_array(z_coh[n].T.ravel()) |
|
461 | ax.plot.set_array(z_coh[n].T.ravel()) | |
379 | ax1.plot.set_array(z_phase[n].T.ravel()) |
|
462 | ax1.plot.set_array(z_phase[n].T.ravel()) | |
380 |
|
463 | |||
381 | ax.set_title('Coherence Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8) |
|
464 | ax.set_title('Coherence Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8) | |
382 | ax1.set_title('Phase Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8) |
|
465 | ax1.set_title('Phase Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8) | |
383 | self.saveTime = self.max_time |
|
466 | self.saveTime = self.max_time | |
384 |
|
467 | |||
385 |
|
468 | |||
386 | class PlotSpectraMeanData(PlotSpectraData): |
|
469 | class PlotSpectraMeanData(PlotSpectraData): | |
387 |
|
470 | |||
388 | CODE = 'spc_mean' |
|
471 | CODE = 'spc_mean' | |
389 | colormap = 'jet' |
|
472 | colormap = 'jet' | |
390 |
|
473 | |||
391 | def plot(self): |
|
474 | def plot(self): | |
392 |
|
475 | |||
393 | if self.xaxis == "frequency": |
|
476 | if self.xaxis == "frequency": | |
394 | x = self.dataOut.getFreqRange(1)/1000. |
|
477 | x = self.dataOut.getFreqRange(1)/1000. | |
395 | xlabel = "Frequency (kHz)" |
|
478 | xlabel = "Frequency (kHz)" | |
396 | elif self.xaxis == "time": |
|
479 | elif self.xaxis == "time": | |
397 | x = self.dataOut.getAcfRange(1) |
|
480 | x = self.dataOut.getAcfRange(1) | |
398 | xlabel = "Time (ms)" |
|
481 | xlabel = "Time (ms)" | |
399 | else: |
|
482 | else: | |
400 | x = self.dataOut.getVelRange(1) |
|
483 | x = self.dataOut.getVelRange(1) | |
401 | xlabel = "Velocity (m/s)" |
|
484 | xlabel = "Velocity (m/s)" | |
402 |
|
485 | |||
403 | y = self.dataOut.getHeiRange() |
|
486 | y = self.dataOut.getHeiRange() | |
404 | z = self.data['spc'] |
|
487 | z = self.data['spc'] | |
405 | mean = self.data['mean'][self.max_time] |
|
488 | mean = self.data['mean'][self.max_time] | |
406 |
|
489 | |||
407 | for n, ax in enumerate(self.axes): |
|
490 | for n, ax in enumerate(self.axes): | |
408 |
|
491 | |||
409 | if ax.firsttime: |
|
492 | if ax.firsttime: | |
410 | self.xmax = self.xmax if self.xmax else np.nanmax(x) |
|
493 | self.xmax = self.xmax if self.xmax else np.nanmax(x) | |
411 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
494 | self.xmin = self.xmin if self.xmin else -self.xmax | |
412 | self.ymin = self.ymin if self.ymin else np.nanmin(y) |
|
495 | self.ymin = self.ymin if self.ymin else np.nanmin(y) | |
413 | self.ymax = self.ymax if self.ymax else np.nanmax(y) |
|
496 | self.ymax = self.ymax if self.ymax else np.nanmax(y) | |
414 | self.zmin = self.zmin if self.zmin else np.nanmin(z) |
|
497 | self.zmin = self.zmin if self.zmin else np.nanmin(z) | |
415 | self.zmax = self.zmax if self.zmax else np.nanmax(z) |
|
498 | self.zmax = self.zmax if self.zmax else np.nanmax(z) | |
416 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
499 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
417 | vmin=self.zmin, |
|
500 | vmin=self.zmin, | |
418 | vmax=self.zmax, |
|
501 | vmax=self.zmax, | |
419 | cmap=plt.get_cmap(self.colormap) |
|
502 | cmap=plt.get_cmap(self.colormap) | |
420 | ) |
|
503 | ) | |
421 | ax.plt_dop = ax.plot(mean[n], y, |
|
504 | ax.plt_dop = ax.plot(mean[n], y, | |
422 | color='k')[0] |
|
505 | color='k')[0] | |
423 |
|
506 | |||
424 | divider = make_axes_locatable(ax) |
|
507 | divider = make_axes_locatable(ax) | |
425 | cax = divider.new_horizontal(size='3%', pad=0.05) |
|
508 | cax = divider.new_horizontal(size='3%', pad=0.05) | |
426 | self.figure.add_axes(cax) |
|
509 | self.figure.add_axes(cax) | |
427 | plt.colorbar(ax.plt, cax) |
|
510 | plt.colorbar(ax.plt, cax) | |
428 |
|
511 | |||
429 | ax.set_xlim(self.xmin, self.xmax) |
|
512 | ax.set_xlim(self.xmin, self.xmax) | |
430 | ax.set_ylim(self.ymin, self.ymax) |
|
513 | ax.set_ylim(self.ymin, self.ymax) | |
431 |
|
514 | |||
432 | ax.set_ylabel(self.ylabel) |
|
515 | ax.set_ylabel(self.ylabel) | |
433 | ax.set_xlabel(xlabel) |
|
516 | ax.set_xlabel(xlabel) | |
434 |
|
517 | |||
435 | ax.firsttime = False |
|
518 | ax.firsttime = False | |
436 |
|
519 | |||
437 | if self.showprofile: |
|
520 | if self.showprofile: | |
438 | ax.plt_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0] |
|
521 | ax.plt_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0] | |
439 | ax.ax_profile.set_xlim(self.zmin, self.zmax) |
|
522 | ax.ax_profile.set_xlim(self.zmin, self.zmax) | |
440 | ax.ax_profile.set_ylim(self.ymin, self.ymax) |
|
523 | ax.ax_profile.set_ylim(self.ymin, self.ymax) | |
441 | ax.ax_profile.set_xlabel('dB') |
|
524 | ax.ax_profile.set_xlabel('dB') | |
442 | ax.ax_profile.grid(b=True, axis='x') |
|
525 | ax.ax_profile.grid(b=True, axis='x') | |
443 | ax.plt_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y, |
|
526 | ax.plt_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y, | |
444 | color="k", linestyle="dashed", lw=2)[0] |
|
527 | color="k", linestyle="dashed", lw=2)[0] | |
445 | [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()] |
|
528 | [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()] | |
446 | else: |
|
529 | else: | |
447 | ax.plt.set_array(z[n].T.ravel()) |
|
530 | ax.plt.set_array(z[n].T.ravel()) | |
448 | ax.plt_dop.set_data(mean[n], y) |
|
531 | ax.plt_dop.set_data(mean[n], y) | |
449 | if self.showprofile: |
|
532 | if self.showprofile: | |
450 | ax.plt_profile.set_data(self.data['rti'][self.max_time][n], y) |
|
533 | ax.plt_profile.set_data(self.data['rti'][self.max_time][n], y) | |
451 | ax.plt_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y) |
|
534 | ax.plt_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y) | |
452 |
|
535 | |||
453 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), |
|
536 | ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]), | |
454 | size=8) |
|
537 | size=8) | |
455 | self.saveTime = self.max_time |
|
538 | self.saveTime = self.max_time | |
456 |
|
539 | |||
457 |
|
540 | |||
458 | class PlotRTIData(PlotData): |
|
541 | class PlotRTIData(PlotData): | |
459 |
|
542 | |||
460 | CODE = 'rti' |
|
543 | CODE = 'rti' | |
461 | colormap = 'jro' |
|
544 | colormap = 'jro' | |
462 |
|
545 | |||
463 | def setup(self): |
|
546 | def setup(self): | |
464 | self.ncols = 1 |
|
547 | self.ncols = 1 | |
465 | self.nrows = self.dataOut.nChannels |
|
548 | self.nrows = self.dataOut.nChannels | |
466 | self.width = 10 |
|
549 | self.width = 10 | |
467 | self.height = 2.2*self.nrows if self.nrows<6 else 12 |
|
550 | #TODO : arreglar la altura de la figura, esta hardcodeada. | |
|
551 | #Se arreglo, testear! | |||
|
552 | if self.ind_plt_ch: | |||
|
553 | self.height = 3.2#*self.nrows if self.nrows<6 else 12 | |||
|
554 | else: | |||
|
555 | self.height = 2.2*self.nrows if self.nrows<6 else 12 | |||
|
556 | ||||
|
557 | ''' | |||
468 | if self.nrows==1: |
|
558 | if self.nrows==1: | |
469 | self.height += 1 |
|
559 | self.height += 1 | |
|
560 | ''' | |||
470 | self.ylabel = 'Range [Km]' |
|
561 | self.ylabel = 'Range [Km]' | |
471 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] |
|
562 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] | |
472 |
|
563 | |||
473 | if self.figure is None: |
|
564 | ''' | |
474 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
565 | Logica: | |
475 | edgecolor='k', |
|
566 | 1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura | |
476 | facecolor='w') |
|
567 | 2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el | |
477 | else: |
|
568 | axis dentro de "Figures" como un diccionario. | |
478 | self.figure.clf() |
|
569 | ''' | |
479 | self.axes = [] |
|
570 | if self.ind_plt_ch is False: #standard mode | |
480 |
|
571 | |||
481 | for n in range(self.nrows): |
|
572 | if self.figure is None: #solo para la priemra vez | |
482 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) |
|
573 | self.figure = plt.figure(figsize=(self.width, self.height), | |
483 | ax.firsttime = True |
|
574 | edgecolor='k', | |
484 | self.axes.append(ax) |
|
575 | facecolor='w') | |
485 |
|
||||
486 | def plot(self): |
|
|||
487 |
|
||||
488 | self.x = np.array(self.times) |
|
|||
489 | self.y = self.dataOut.getHeiRange() |
|
|||
490 | self.z = [] |
|
|||
491 |
|
||||
492 | for ch in range(self.nrows): |
|
|||
493 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) |
|
|||
494 |
|
||||
495 | self.z = np.array(self.z) |
|
|||
496 | for n, ax in enumerate(self.axes): |
|
|||
497 | x, y, z = self.fill_gaps(*self.decimate()) |
|
|||
498 | if self.xmin is None: |
|
|||
499 | xmin = self.min_time |
|
|||
500 | else: |
|
|||
501 | xmin = fromtimestamp(int(self.xmin), self.min_time) |
|
|||
502 | if self.xmax is None: |
|
|||
503 | xmax = xmin + self.xrange*60*60 |
|
|||
504 | else: |
|
576 | else: | |
505 | xmax = xmin + (self.xmax - self.xmin) * 60 * 60 |
|
577 | self.figure.clf() | |
506 | self.zmin = self.zmin if self.zmin else np.min(self.z) |
|
578 | self.axes = [] | |
507 | self.zmax = self.zmax if self.zmax else np.max(self.z) |
|
|||
508 | if ax.firsttime: |
|
|||
509 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) |
|
|||
510 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) |
|
|||
511 | plot = ax.pcolormesh(x, y, z[n].T, |
|
|||
512 | vmin=self.zmin, |
|
|||
513 | vmax=self.zmax, |
|
|||
514 | cmap=plt.get_cmap(self.colormap) |
|
|||
515 | ) |
|
|||
516 | divider = make_axes_locatable(ax) |
|
|||
517 | cax = divider.new_horizontal(size='2%', pad=0.05) |
|
|||
518 | self.figure.add_axes(cax) |
|
|||
519 | plt.colorbar(plot, cax) |
|
|||
520 | ax.set_ylim(self.ymin, self.ymax) |
|
|||
521 |
|
579 | |||
522 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
|||
523 | ax.xaxis.set_major_locator(LinearLocator(6)) |
|
|||
524 |
|
580 | |||
525 | ax.set_ylabel(self.ylabel) |
|
581 | for n in range(self.nrows): | |
|
582 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |||
|
583 | #ax = self.figure(n+1) | |||
|
584 | ax.firsttime = True | |||
|
585 | self.axes.append(ax) | |||
|
586 | ||||
|
587 | else : #append one figure foreach channel in channelList | |||
|
588 | if self.figurelist == None: | |||
|
589 | self.figurelist = [] | |||
|
590 | for n in range(self.nrows): | |||
|
591 | self.figure = plt.figure(figsize=(self.width, self.height), | |||
|
592 | edgecolor='k', | |||
|
593 | facecolor='w') | |||
|
594 | #add always one subplot | |||
|
595 | self.figurelist.append(self.figure) | |||
|
596 | ||||
|
597 | else : # cada dia nuevo limpia el axes, pero mantiene el figure | |||
|
598 | for eachfigure in self.figurelist: | |||
|
599 | eachfigure.clf() # eliminaria todas las figuras de la lista? | |||
|
600 | self.axes = [] | |||
|
601 | ||||
|
602 | for eachfigure in self.figurelist: | |||
|
603 | ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura | |||
|
604 | #ax = self.figure(n+1) | |||
|
605 | ax.firsttime = True | |||
|
606 | #Cada figura tiene un distinto puntero | |||
|
607 | self.axes.append(ax) | |||
|
608 | #plt.close(eachfigure) | |||
526 |
|
609 | |||
527 | # if self.xmin is None: |
|
|||
528 | # xmin = self.min_time |
|
|||
529 | # else: |
|
|||
530 | # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), |
|
|||
531 | # datetime.time(self.xmin, 0, 0))-d1970).total_seconds() |
|
|||
532 |
|
610 | |||
533 | ax.set_xlim(xmin, xmax) |
|
611 | def plot(self): | |
534 | ax.firsttime = False |
|
|||
535 | else: |
|
|||
536 | ax.collections.remove(ax.collections[0]) |
|
|||
537 | ax.set_xlim(xmin, xmax) |
|
|||
538 | plot = ax.pcolormesh(x, y, z[n].T, |
|
|||
539 | vmin=self.zmin, |
|
|||
540 | vmax=self.zmax, |
|
|||
541 | cmap=plt.get_cmap(self.colormap) |
|
|||
542 | ) |
|
|||
543 | ax.set_title('{} {}'.format(self.titles[n], |
|
|||
544 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), |
|
|||
545 | size=8) |
|
|||
546 |
|
612 | |||
547 | self.saveTime = self.min_time |
|
613 | if self.ind_plt_ch is False: #standard mode | |
|
614 | self.x = np.array(self.times) | |||
|
615 | self.y = self.dataOut.getHeiRange() | |||
|
616 | self.z = [] | |||
|
617 | ||||
|
618 | for ch in range(self.nrows): | |||
|
619 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |||
|
620 | ||||
|
621 | self.z = np.array(self.z) | |||
|
622 | for n, ax in enumerate(self.axes): | |||
|
623 | x, y, z = self.fill_gaps(*self.decimate()) | |||
|
624 | if self.xmin is None: | |||
|
625 | xmin = self.min_time | |||
|
626 | else: | |||
|
627 | xmin = fromtimestamp(int(self.xmin), self.min_time) | |||
|
628 | if self.xmax is None: | |||
|
629 | xmax = xmin + self.xrange*60*60 | |||
|
630 | else: | |||
|
631 | xmax = xmin + (self.xmax - self.xmin) * 60 * 60 | |||
|
632 | self.zmin = self.zmin if self.zmin else np.min(self.z) | |||
|
633 | self.zmax = self.zmax if self.zmax else np.max(self.z) | |||
|
634 | if ax.firsttime: | |||
|
635 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |||
|
636 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |||
|
637 | plot = ax.pcolormesh(x, y, z[n].T, | |||
|
638 | vmin=self.zmin, | |||
|
639 | vmax=self.zmax, | |||
|
640 | cmap=plt.get_cmap(self.colormap) | |||
|
641 | ) | |||
|
642 | divider = make_axes_locatable(ax) | |||
|
643 | cax = divider.new_horizontal(size='2%', pad=0.05) | |||
|
644 | self.figure.add_axes(cax) | |||
|
645 | plt.colorbar(plot, cax) | |||
|
646 | ax.set_ylim(self.ymin, self.ymax) | |||
|
647 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |||
|
648 | ax.xaxis.set_major_locator(LinearLocator(6)) | |||
|
649 | ax.set_ylabel(self.ylabel) | |||
|
650 | # if self.xmin is None: | |||
|
651 | # xmin = self.min_time | |||
|
652 | # else: | |||
|
653 | # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |||
|
654 | # datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |||
|
655 | ||||
|
656 | ax.set_xlim(xmin, xmax) | |||
|
657 | ax.firsttime = False | |||
|
658 | else: | |||
|
659 | ax.collections.remove(ax.collections[0]) | |||
|
660 | ax.set_xlim(xmin, xmax) | |||
|
661 | plot = ax.pcolormesh(x, y, z[n].T, | |||
|
662 | vmin=self.zmin, | |||
|
663 | vmax=self.zmax, | |||
|
664 | cmap=plt.get_cmap(self.colormap) | |||
|
665 | ) | |||
|
666 | ax.set_title('{} {}'.format(self.titles[n], | |||
|
667 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |||
|
668 | size=8) | |||
|
669 | ||||
|
670 | self.saveTime = self.min_time | |||
|
671 | else : | |||
|
672 | self.x = np.array(self.times) | |||
|
673 | self.y = self.dataOut.getHeiRange() | |||
|
674 | self.z = [] | |||
|
675 | ||||
|
676 | for ch in range(self.nrows): | |||
|
677 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |||
|
678 | ||||
|
679 | self.z = np.array(self.z) | |||
|
680 | for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes | |||
|
681 | ||||
|
682 | x, y, z = self.fill_gaps(*self.decimate()) | |||
|
683 | xmin = self.min_time | |||
|
684 | xmax = xmin+self.xrange*60*60 | |||
|
685 | self.zmin = self.zmin if self.zmin else np.min(self.z) | |||
|
686 | self.zmax = self.zmax if self.zmax else np.max(self.z) | |||
|
687 | if self.axes[n].firsttime: | |||
|
688 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |||
|
689 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |||
|
690 | plot = self.axes[n].pcolormesh(x, y, z[n].T, | |||
|
691 | vmin=self.zmin, | |||
|
692 | vmax=self.zmax, | |||
|
693 | cmap=plt.get_cmap(self.colormap) | |||
|
694 | ) | |||
|
695 | divider = make_axes_locatable(self.axes[n]) | |||
|
696 | cax = divider.new_horizontal(size='2%', pad=0.05) | |||
|
697 | eachfigure.add_axes(cax) | |||
|
698 | #self.figure2.add_axes(cax) | |||
|
699 | plt.colorbar(plot, cax) | |||
|
700 | self.axes[n].set_ylim(self.ymin, self.ymax) | |||
|
701 | ||||
|
702 | self.axes[n].xaxis.set_major_formatter(FuncFormatter(func)) | |||
|
703 | self.axes[n].xaxis.set_major_locator(LinearLocator(6)) | |||
|
704 | ||||
|
705 | self.axes[n].set_ylabel(self.ylabel) | |||
|
706 | ||||
|
707 | if self.xmin is None: | |||
|
708 | xmin = self.min_time | |||
|
709 | else: | |||
|
710 | xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |||
|
711 | datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |||
|
712 | ||||
|
713 | self.axes[n].set_xlim(xmin, xmax) | |||
|
714 | self.axes[n].firsttime = False | |||
|
715 | else: | |||
|
716 | self.axes[n].collections.remove(self.axes[n].collections[0]) | |||
|
717 | self.axes[n].set_xlim(xmin, xmax) | |||
|
718 | plot = self.axes[n].pcolormesh(x, y, z[n].T, | |||
|
719 | vmin=self.zmin, | |||
|
720 | vmax=self.zmax, | |||
|
721 | cmap=plt.get_cmap(self.colormap) | |||
|
722 | ) | |||
|
723 | self.axes[n].set_title('{} {}'.format(self.titles[n], | |||
|
724 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |||
|
725 | size=8) | |||
|
726 | ||||
|
727 | self.saveTime = self.min_time | |||
548 |
|
728 | |||
549 |
|
729 | |||
550 | class PlotCOHData(PlotRTIData): |
|
730 | class PlotCOHData(PlotRTIData): | |
551 |
|
731 | |||
552 | CODE = 'coh' |
|
732 | CODE = 'coh' | |
553 |
|
733 | |||
554 | def setup(self): |
|
734 | def setup(self): | |
555 |
|
735 | |||
556 | self.ncols = 1 |
|
736 | self.ncols = 1 | |
557 | self.nrows = self.dataOut.nPairs |
|
737 | self.nrows = self.dataOut.nPairs | |
558 | self.width = 10 |
|
738 | self.width = 10 | |
559 | self.height = 2.2*self.nrows if self.nrows<6 else 12 |
|
739 | self.height = 2.2*self.nrows if self.nrows<6 else 12 | |
|
740 | self.ind_plt_ch = False #just for coherence and phase | |||
560 | if self.nrows==1: |
|
741 | if self.nrows==1: | |
561 | self.height += 1 |
|
742 | self.height += 1 | |
562 | self.ylabel = 'Range [Km]' |
|
743 | self.ylabel = 'Range [Km]' | |
563 | self.titles = ['{} Ch{} * Ch{}'.format(self.CODE.upper(), x[0], x[1]) for x in self.dataOut.pairsList] |
|
744 | self.titles = ['{} Ch{} * Ch{}'.format(self.CODE.upper(), x[0], x[1]) for x in self.dataOut.pairsList] | |
564 |
|
745 | |||
565 | if self.figure is None: |
|
746 | if self.figure is None: | |
566 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
747 | self.figure = plt.figure(figsize=(self.width, self.height), | |
567 | edgecolor='k', |
|
748 | edgecolor='k', | |
568 | facecolor='w') |
|
749 | facecolor='w') | |
569 | else: |
|
750 | else: | |
570 | self.figure.clf() |
|
751 | self.figure.clf() | |
571 | self.axes = [] |
|
752 | self.axes = [] | |
572 |
|
753 | |||
573 | for n in range(self.nrows): |
|
754 | for n in range(self.nrows): | |
574 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) |
|
755 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
575 | ax.firsttime = True |
|
756 | ax.firsttime = True | |
576 | self.axes.append(ax) |
|
757 | self.axes.append(ax) | |
577 |
|
758 | |||
578 |
|
759 | |||
579 | class PlotNoiseData(PlotData): |
|
760 | class PlotNoiseData(PlotData): | |
580 | CODE = 'noise' |
|
761 | CODE = 'noise' | |
581 |
|
762 | |||
582 | def setup(self): |
|
763 | def setup(self): | |
583 |
|
764 | |||
584 | self.ncols = 1 |
|
765 | self.ncols = 1 | |
585 | self.nrows = 1 |
|
766 | self.nrows = 1 | |
586 | self.width = 10 |
|
767 | self.width = 10 | |
587 | self.height = 3.2 |
|
768 | self.height = 3.2 | |
588 | self.ylabel = 'Intensity [dB]' |
|
769 | self.ylabel = 'Intensity [dB]' | |
589 | self.titles = ['Noise'] |
|
770 | self.titles = ['Noise'] | |
590 |
|
771 | |||
591 | if self.figure is None: |
|
772 | if self.figure is None: | |
592 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
773 | self.figure = plt.figure(figsize=(self.width, self.height), | |
593 | edgecolor='k', |
|
774 | edgecolor='k', | |
594 | facecolor='w') |
|
775 | facecolor='w') | |
595 | else: |
|
776 | else: | |
596 | self.figure.clf() |
|
777 | self.figure.clf() | |
597 | self.axes = [] |
|
778 | self.axes = [] | |
598 |
|
779 | |||
599 | self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1) |
|
780 | self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1) | |
600 | self.ax.firsttime = True |
|
781 | self.ax.firsttime = True | |
601 |
|
782 | |||
602 | def plot(self): |
|
783 | def plot(self): | |
603 |
|
784 | |||
604 | x = self.times |
|
785 | x = self.times | |
605 | xmin = self.min_time |
|
786 | xmin = self.min_time | |
606 | xmax = xmin+self.xrange*60*60 |
|
787 | xmax = xmin+self.xrange*60*60 | |
607 | if self.ax.firsttime: |
|
788 | if self.ax.firsttime: | |
608 | for ch in self.dataOut.channelList: |
|
789 | for ch in self.dataOut.channelList: | |
609 | y = [self.data[self.CODE][t][ch] for t in self.times] |
|
790 | y = [self.data[self.CODE][t][ch] for t in self.times] | |
610 | self.ax.plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
791 | self.ax.plot(x, y, lw=1, label='Ch{}'.format(ch)) | |
611 | self.ax.firsttime = False |
|
792 | self.ax.firsttime = False | |
612 | self.ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
793 | self.ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
613 | self.ax.xaxis.set_major_locator(LinearLocator(6)) |
|
794 | self.ax.xaxis.set_major_locator(LinearLocator(6)) | |
614 | self.ax.set_ylabel(self.ylabel) |
|
795 | self.ax.set_ylabel(self.ylabel) | |
615 | plt.legend() |
|
796 | plt.legend() | |
616 | else: |
|
797 | else: | |
617 | for ch in self.dataOut.channelList: |
|
798 | for ch in self.dataOut.channelList: | |
618 | y = [self.data[self.CODE][t][ch] for t in self.times] |
|
799 | y = [self.data[self.CODE][t][ch] for t in self.times] | |
619 | self.ax.lines[ch].set_data(x, y) |
|
800 | self.ax.lines[ch].set_data(x, y) | |
620 |
|
801 | |||
621 | self.ax.set_xlim(xmin, xmax) |
|
802 | self.ax.set_xlim(xmin, xmax) | |
622 | self.ax.set_ylim(min(y)-5, max(y)+5) |
|
803 | self.ax.set_ylim(min(y)-5, max(y)+5) | |
623 | self.saveTime = self.min_time |
|
804 | self.saveTime = self.min_time | |
624 |
|
805 | |||
625 |
|
806 | |||
626 | class PlotWindProfilerData(PlotRTIData): |
|
807 | class PlotWindProfilerData(PlotRTIData): | |
627 |
|
808 | |||
628 | CODE = 'wind' |
|
809 | CODE = 'wind' | |
629 | colormap = 'seismic' |
|
810 | colormap = 'seismic' | |
630 |
|
811 | |||
631 | def setup(self): |
|
812 | def setup(self): | |
632 | self.ncols = 1 |
|
813 | self.ncols = 1 | |
633 | self.nrows = self.dataOut.data_output.shape[0] |
|
814 | self.nrows = self.dataOut.data_output.shape[0] | |
634 | self.width = 10 |
|
815 | self.width = 10 | |
635 | self.height = 2.2*self.nrows |
|
816 | self.height = 2.2*self.nrows | |
636 | self.ylabel = 'Height [Km]' |
|
817 | self.ylabel = 'Height [Km]' | |
637 | self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind'] |
|
818 | self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind'] | |
638 | self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
819 | self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | |
639 | self.windFactor = [1, 1, 100] |
|
820 | self.windFactor = [1, 1, 100] | |
640 |
|
821 | |||
641 | if self.figure is None: |
|
822 | if self.figure is None: | |
642 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
823 | self.figure = plt.figure(figsize=(self.width, self.height), | |
643 | edgecolor='k', |
|
824 | edgecolor='k', | |
644 | facecolor='w') |
|
825 | facecolor='w') | |
645 | else: |
|
826 | else: | |
646 | self.figure.clf() |
|
827 | self.figure.clf() | |
647 | self.axes = [] |
|
828 | self.axes = [] | |
648 |
|
829 | |||
649 | for n in range(self.nrows): |
|
830 | for n in range(self.nrows): | |
650 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) |
|
831 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
651 | ax.firsttime = True |
|
832 | ax.firsttime = True | |
652 | self.axes.append(ax) |
|
833 | self.axes.append(ax) | |
653 |
|
834 | |||
654 | def plot(self): |
|
835 | def plot(self): | |
655 |
|
836 | |||
656 | self.x = np.array(self.times) |
|
837 | self.x = np.array(self.times) | |
657 | self.y = self.dataOut.heightList |
|
838 | self.y = self.dataOut.heightList | |
658 | self.z = [] |
|
839 | self.z = [] | |
659 |
|
840 | |||
660 | for ch in range(self.nrows): |
|
841 | for ch in range(self.nrows): | |
661 | self.z.append([self.data['output'][t][ch] for t in self.times]) |
|
842 | self.z.append([self.data['output'][t][ch] for t in self.times]) | |
662 |
|
843 | |||
663 | self.z = np.array(self.z) |
|
844 | self.z = np.array(self.z) | |
664 | self.z = numpy.ma.masked_invalid(self.z) |
|
845 | self.z = numpy.ma.masked_invalid(self.z) | |
665 |
|
846 | |||
666 | cmap=plt.get_cmap(self.colormap) |
|
847 | cmap=plt.get_cmap(self.colormap) | |
667 | cmap.set_bad('black', 1.) |
|
848 | cmap.set_bad('black', 1.) | |
668 |
|
849 | |||
669 | for n, ax in enumerate(self.axes): |
|
850 | for n, ax in enumerate(self.axes): | |
670 | x, y, z = self.fill_gaps(*self.decimate()) |
|
851 | x, y, z = self.fill_gaps(*self.decimate()) | |
671 | xmin = self.min_time |
|
852 | xmin = self.min_time | |
672 | xmax = xmin+self.xrange*60*60 |
|
853 | xmax = xmin+self.xrange*60*60 | |
673 | if ax.firsttime: |
|
854 | if ax.firsttime: | |
674 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) |
|
855 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
675 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) |
|
856 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
676 | self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :])) |
|
857 | self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :])) | |
677 | self.zmin = self.zmin if self.zmin else -self.zmax |
|
858 | self.zmin = self.zmin if self.zmin else -self.zmax | |
678 |
|
859 | |||
679 | plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n], |
|
860 | plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n], | |
680 | vmin=self.zmin, |
|
861 | vmin=self.zmin, | |
681 | vmax=self.zmax, |
|
862 | vmax=self.zmax, | |
682 | cmap=cmap |
|
863 | cmap=cmap | |
683 | ) |
|
864 | ) | |
684 | divider = make_axes_locatable(ax) |
|
865 | divider = make_axes_locatable(ax) | |
685 | cax = divider.new_horizontal(size='2%', pad=0.05) |
|
866 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
686 | self.figure.add_axes(cax) |
|
867 | self.figure.add_axes(cax) | |
687 | cb = plt.colorbar(plot, cax) |
|
868 | cb = plt.colorbar(plot, cax) | |
688 | cb.set_label(self.clabels[n]) |
|
869 | cb.set_label(self.clabels[n]) | |
689 | ax.set_ylim(self.ymin, self.ymax) |
|
870 | ax.set_ylim(self.ymin, self.ymax) | |
690 |
|
871 | |||
691 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
872 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
692 | ax.xaxis.set_major_locator(LinearLocator(6)) |
|
873 | ax.xaxis.set_major_locator(LinearLocator(6)) | |
693 |
|
874 | |||
694 | ax.set_ylabel(self.ylabel) |
|
875 | ax.set_ylabel(self.ylabel) | |
695 |
|
876 | |||
696 | ax.set_xlim(xmin, xmax) |
|
877 | ax.set_xlim(xmin, xmax) | |
697 | ax.firsttime = False |
|
878 | ax.firsttime = False | |
698 | else: |
|
879 | else: | |
699 | ax.collections.remove(ax.collections[0]) |
|
880 | ax.collections.remove(ax.collections[0]) | |
700 | ax.set_xlim(xmin, xmax) |
|
881 | ax.set_xlim(xmin, xmax) | |
701 | plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n], |
|
882 | plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n], | |
702 | vmin=self.zmin, |
|
883 | vmin=self.zmin, | |
703 | vmax=self.zmax, |
|
884 | vmax=self.zmax, | |
704 | cmap=plt.get_cmap(self.colormap) |
|
885 | cmap=plt.get_cmap(self.colormap) | |
705 | ) |
|
886 | ) | |
706 | ax.set_title('{} {}'.format(self.titles[n], |
|
887 | ax.set_title('{} {}'.format(self.titles[n], | |
707 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), |
|
888 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
708 | size=8) |
|
889 | size=8) | |
709 |
|
890 | |||
710 | self.saveTime = self.min_time |
|
891 | self.saveTime = self.min_time | |
711 |
|
892 | |||
712 |
|
893 | |||
713 | class PlotSNRData(PlotRTIData): |
|
894 | class PlotSNRData(PlotRTIData): | |
714 | CODE = 'snr' |
|
895 | CODE = 'snr' | |
715 | colormap = 'jet' |
|
896 | colormap = 'jet' | |
716 |
|
897 | |||
717 | class PlotDOPData(PlotRTIData): |
|
898 | class PlotDOPData(PlotRTIData): | |
718 | CODE = 'dop' |
|
899 | CODE = 'dop' | |
719 | colormap = 'jet' |
|
900 | colormap = 'jet' | |
720 |
|
901 | |||
721 |
|
902 | |||
722 | class PlotPHASEData(PlotCOHData): |
|
903 | class PlotPHASEData(PlotCOHData): | |
723 | CODE = 'phase' |
|
904 | CODE = 'phase' | |
724 | colormap = 'seismic' |
|
905 | colormap = 'seismic' | |
725 |
|
906 | |||
726 |
|
907 | |||
727 | class PlotSkyMapData(PlotData): |
|
908 | class PlotSkyMapData(PlotData): | |
728 |
|
909 | |||
729 | CODE = 'met' |
|
910 | CODE = 'met' | |
730 |
|
911 | |||
731 | def setup(self): |
|
912 | def setup(self): | |
732 |
|
913 | |||
733 | self.ncols = 1 |
|
914 | self.ncols = 1 | |
734 | self.nrows = 1 |
|
915 | self.nrows = 1 | |
735 | self.width = 7.2 |
|
916 | self.width = 7.2 | |
736 | self.height = 7.2 |
|
917 | self.height = 7.2 | |
737 |
|
918 | |||
738 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
919 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
739 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
920 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
740 |
|
921 | |||
741 | if self.figure is None: |
|
922 | if self.figure is None: | |
742 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
923 | self.figure = plt.figure(figsize=(self.width, self.height), | |
743 | edgecolor='k', |
|
924 | edgecolor='k', | |
744 | facecolor='w') |
|
925 | facecolor='w') | |
745 | else: |
|
926 | else: | |
746 | self.figure.clf() |
|
927 | self.figure.clf() | |
747 |
|
928 | |||
748 | self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True) |
|
929 | self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True) | |
749 | self.ax.firsttime = True |
|
930 | self.ax.firsttime = True | |
750 |
|
931 | |||
751 |
|
932 | |||
752 | def plot(self): |
|
933 | def plot(self): | |
753 |
|
934 | |||
754 | arrayParameters = np.concatenate([self.data['param'][t] for t in self.times]) |
|
935 | arrayParameters = np.concatenate([self.data['param'][t] for t in self.times]) | |
755 | error = arrayParameters[:,-1] |
|
936 | error = arrayParameters[:,-1] | |
756 | indValid = numpy.where(error == 0)[0] |
|
937 | indValid = numpy.where(error == 0)[0] | |
757 | finalMeteor = arrayParameters[indValid,:] |
|
938 | finalMeteor = arrayParameters[indValid,:] | |
758 | finalAzimuth = finalMeteor[:,3] |
|
939 | finalAzimuth = finalMeteor[:,3] | |
759 | finalZenith = finalMeteor[:,4] |
|
940 | finalZenith = finalMeteor[:,4] | |
760 |
|
941 | |||
761 | x = finalAzimuth*numpy.pi/180 |
|
942 | x = finalAzimuth*numpy.pi/180 | |
762 | y = finalZenith |
|
943 | y = finalZenith | |
763 |
|
944 | |||
764 | if self.ax.firsttime: |
|
945 | if self.ax.firsttime: | |
765 | self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] |
|
946 | self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] | |
766 | self.ax.set_ylim(0,90) |
|
947 | self.ax.set_ylim(0,90) | |
767 | self.ax.set_yticks(numpy.arange(0,90,20)) |
|
948 | self.ax.set_yticks(numpy.arange(0,90,20)) | |
768 | self.ax.set_xlabel(self.xlabel) |
|
949 | self.ax.set_xlabel(self.xlabel) | |
769 | self.ax.set_ylabel(self.ylabel) |
|
950 | self.ax.set_ylabel(self.ylabel) | |
770 | self.ax.yaxis.labelpad = 40 |
|
951 | self.ax.yaxis.labelpad = 40 | |
771 | self.ax.firsttime = False |
|
952 | self.ax.firsttime = False | |
772 | else: |
|
953 | else: | |
773 | self.ax.plot.set_data(x, y) |
|
954 | self.ax.plot.set_data(x, y) | |
774 |
|
955 | |||
775 |
|
956 | |||
776 | dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
957 | dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') | |
777 | dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
958 | dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') | |
778 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
959 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
779 | dt2, |
|
960 | dt2, | |
780 | len(x)) |
|
961 | len(x)) | |
781 | self.ax.set_title(title, size=8) |
|
962 | self.ax.set_title(title, size=8) | |
782 |
|
963 | |||
783 | self.saveTime = self.max_time |
|
964 | self.saveTime = self.max_time |
@@ -1,1 +1,1 | |||||
1 | <Project description="JASMET Meteor Detection" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/home/nanosat/data/jasmet" /><Parameter format="date" id="2113" name="startDate" value="2010/08/29" /><Parameter format="date" id="2114" name="endDate" value="2017/09/11" /><Parameter format="time" id="2115" name="startTime" value="00:00:00" /><Parameter format="time" id="2116" name="endTime" value="23:59:59" /><Parameter format="int" id="2118" name="delay" value="30" /><Parameter format="int" id="2119" name="blocktime" value="100" /><Parameter format="int" id="2120" name="getblock" value="1" /><Parameter format="int" id="2121" name="walk" value="1" /><Parameter format="int" id="2122" name="online" value="0" /></Operation><Operation id="212" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="22" inputId="21" name="VoltageProc"><Operation id="221" name="run" priority="1" type="self" /><Operation id="222" name="selectChannels" priority="2" type="self"><Parameter format="intlist" id="2221" name="channelList" value="0,1,2,3,4" /></Operation><Operation id="223" name="setRadarFrequency" priority="3" type="self"><Parameter format="float" id="2231" name="frequency" value="30.e6" /></Operation><Operation id="224" name="interpolateHeights" priority="4" type="self"><Parameter format="int" id="2241" name="topLim" value="73" /><Parameter format="int" id="2242" name="botLim" value="71" /></Operation><Operation id="225" name="Decoder" priority="5" type="other" /><Operation id="226" name="CohInt" priority="6" type="other"><Parameter format="int" id="2261" name="n" value="2" /></Operation></ProcUnit><ProcUnit datatype="ParametersProc" id="23" inputId="22" name="ParametersProc"><Operation id="231" name="run" priority="1" type="self" /><Operation id="232" name="SMDetection" priority="2" type="other"><Parameter format="float" id="2321" name="azimuth" value="45" /><Parameter format="float" id="2322" name="hmin" value="60" /><Parameter format="float" id="2323" name="hmax" value="120" /></Operation><Operation id="233" name="ParamWriter" priority="3" type="other"><Parameter format="str" id="2331" name="path" value="/home/nanosat/Pictures/JASMET30/201608/meteor" /><Parameter format="int" id="2332" name="blocksPerFile" value="1000" /><Parameter format="list" id="2333" name="metadataList" value="type,heightList,paramInterval,timeZone" /><Parameter format="list" id="2334" name="dataList" value="data_param,utctime" /><Parameter format="int" id="2335" name="mode" value="2" /></Operation></ProcUnit></Project> No newline at end of file |
|
1 | <Project description="Claire" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/media/nanosat/0BDE10E00BDE10E0/CLAIRE" /><Parameter format="date" id="2113" name="startDate" value="2017/07/26" /><Parameter format="date" id="2114" name="endDate" value="2017/07/26" /><Parameter format="time" id="2115" name="startTime" value="9:30:0" /><Parameter format="time" id="2116" name="endTime" value="23:59:59" /><Parameter format="int" id="2118" name="online" value="0" /><Parameter format="int" id="2119" name="walk" value="1" /></Operation><Operation id="212" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="22" inputId="21" name="VoltageProc"><Operation id="221" name="run" priority="1" type="self" /></ProcUnit><ProcUnit datatype="SpectraProc" id="23" inputId="22" name="SpectraProc"><Operation id="231" name="run" priority="1" type="self"><Parameter format="int" id="2311" name="nFFTPoints" value="128" /><Parameter format="int" id="2312" name="nProfiles" value="128" /><Parameter format="pairslist" id="2313" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="232" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="2321" name="frequency" value="445000000.0" /></Operation><Operation id="233" name="IncohInt" priority="3" type="other"><Parameter format="float" id="2331" name="timeInterval" value="2" /></Operation><Operation id="234" name="removeDC" priority="4" type="self"><Parameter format="int" id="2341" name="mode" value="2" /></Operation><Operation id="235" name="PublishData" priority="5" type="other"><Parameter format="int" id="2351" name="zeromq" value="1" /><Parameter format="bool" id="2352" name="verbose" value="0" /></Operation></ProcUnit></Project> No newline at end of file |
@@ -1,65 +1,64 | |||||
1 | """. |
|
1 | """. | |
2 |
|
2 | |||
3 | Created on Jul 16, 2014 |
|
3 | Created on Jul 16, 2014 | |
4 |
|
4 | |||
5 | @author: Miguel Urco |
|
5 | @author: Miguel Urco | |
6 | """ |
|
6 | """ | |
7 |
|
7 | |||
8 | from schainpy import __version__ |
|
8 | import numpy | |
9 | from setuptools import setup, Extension |
|
9 | from setuptools import setup, Extension | |
10 | import numpy |
|
10 | import numpy | |
11 |
|
11 | |||
12 | setup(name="schainpy", |
|
12 | setup(name="schainpy", | |
13 | version=__version__, |
|
13 | version=__version__, | |
14 | description="Python tools to read, write and process Jicamarca data", |
|
14 | description="Python tools to read, write and process Jicamarca data", | |
15 | author="Miguel Urco", |
|
15 | author="Miguel Urco", | |
16 | author_email="miguel.urco@jro.igp.gob.pe", |
|
16 | author_email="miguel.urco@jro.igp.gob.pe", | |
17 | url="http://jro.igp.gob.pe", |
|
17 | url="http://jro.igp.gob.pe", | |
18 | packages={'schainpy', |
|
18 | packages={'schainpy', | |
19 | 'schainpy.model', |
|
19 | 'schainpy.model', | |
20 | 'schainpy.model.data', |
|
20 | 'schainpy.model.data', | |
21 | 'schainpy.model.graphics', |
|
21 | 'schainpy.model.graphics', | |
22 | 'schainpy.model.io', |
|
22 | 'schainpy.model.io', | |
23 | 'schainpy.model.proc', |
|
23 | 'schainpy.model.proc', | |
24 | 'schainpy.model.serializer', |
|
24 | 'schainpy.model.serializer', | |
25 | 'schainpy.model.utils', |
|
25 | 'schainpy.model.utils', | |
26 | 'schainpy.gui', |
|
26 | 'schainpy.gui', | |
27 | 'schainpy.gui.figures', |
|
27 | 'schainpy.gui.figures', | |
28 | 'schainpy.gui.viewcontroller', |
|
28 | 'schainpy.gui.viewcontroller', | |
29 | 'schainpy.gui.viewer', |
|
29 | 'schainpy.gui.viewer', | |
30 | 'schainpy.gui.viewer.windows'}, |
|
30 | 'schainpy.gui.viewer.windows'}, | |
31 | ext_package='schainpy', |
|
31 | ext_package='schainpy', | |
32 | py_modules=[''], |
|
32 | py_modules=[''], | |
33 | package_data={'': ['schain.conf.template'], |
|
33 | package_data={'': ['schain.conf.template'], | |
34 | 'schainpy.gui.figures': ['*.png', '*.jpg'], |
|
34 | 'schainpy.gui.figures': ['*.png', '*.jpg'], | |
35 | }, |
|
35 | }, | |
36 | include_package_data=False, |
|
36 | include_package_data=False, | |
37 | entry_points={ |
|
37 | entry_points={ | |
38 | 'console_scripts': [ |
|
38 | 'console_scripts': [ | |
39 | 'schain = schaincli.cli:main', |
|
39 | 'schain = schaincli.cli:main', | |
40 | ], |
|
40 | ], | |
41 | }, |
|
41 | }, | |
42 | scripts=['schainpy/gui/schainGUI'], |
|
42 | scripts=['schainpy/gui/schainGUI'], | |
43 | ext_modules=[ |
|
43 | ext_modules=[ | |
44 | Extension("cSchain", |
|
44 | Extension("cSchain", | |
45 | ["schainpy/model/proc/extensions.c"], |
|
45 | ["schainpy/model/proc/extensions.c"], | |
46 | include_dirs=[numpy.get_include()], |
|
46 | include_dirs=[numpy.get_include()], | |
47 | #extra_compile_args=['-Werror'], |
|
47 | #extra_compile_args=['-Werror'], | |
48 | ) |
|
48 | ) | |
49 | ], |
|
49 | ], | |
50 | install_requires=[ |
|
50 | install_requires=[ | |
51 | "scipy >= 0.14.0", |
|
51 | "scipy >= 0.14.0", | |
52 | "h5py >= 2.2.1", |
|
52 | "h5py >= 2.2.1", | |
53 | "matplotlib >= 1.4.2", |
|
53 | "matplotlib >= 1.4.2", | |
54 | "pyfits >= 3.4", |
|
54 | "pyfits >= 3.4", | |
55 | "numpy >= 1.11.2", |
|
|||
56 | "paramiko >= 2.1.2", |
|
55 | "paramiko >= 2.1.2", | |
57 | "paho-mqtt >= 1.2", |
|
56 | "paho-mqtt >= 1.2", | |
58 | "zmq", |
|
57 | "zmq", | |
59 | "fuzzywuzzy", |
|
58 | "fuzzywuzzy", | |
60 | "click", |
|
59 | "click", | |
61 | "colorama", |
|
60 | "colorama", | |
62 | "python-Levenshtein" |
|
61 | "python-Levenshtein" | |
63 | ], |
|
62 | ], | |
64 | ) |
|
63 | ) | |
65 |
|
64 |
General Comments 0
You need to be logged in to leave comments.
Login now