##// END OF EJS Templates
New templates for CLI (Task #1402)
George Yong -
r1182:78b9f3217839
parent child
Show More
@@ -1,200 +1,208
1 import click
1 import click
2 import schainpy
2 import schainpy
3 import subprocess
3 import subprocess
4 import os
4 import os
5 import sys
5 import sys
6 import glob
6 import glob
7 save_stdout = sys.stdout
7 save_stdout = sys.stdout
8 sys.stdout = open('/dev/null', 'w')
8 sys.stdout = open('/dev/null', 'w')
9 from multiprocessing import cpu_count
9 from multiprocessing import cpu_count
10 from schainpy.controller import Project
10 from schainpy.controller import Project
11 from schainpy.model import Operation, ProcessingUnit
11 from schainpy.model import Operation, ProcessingUnit
12 from schainpy.utils import log
12 from schainpy.utils import log
13 from importlib import import_module
13 from importlib import import_module
14 from pydoc import locate
14 from pydoc import locate
15 from fuzzywuzzy import process
15 from fuzzywuzzy import process
16 from schainpy.cli import templates
16 from schainpy.cli import templates
17 sys.stdout = save_stdout
17 sys.stdout = save_stdout
18
18
19
19
20 def getProcs():
20 def getProcs():
21 modules = dir(schainpy.model)
21 modules = dir(schainpy.model)
22 procs = check_module(modules, ProcessingUnit)
22 procs = check_module(modules, ProcessingUnit)
23 try:
23 try:
24 procs.remove('ProcessingUnit')
24 procs.remove('ProcessingUnit')
25 except Exception as e:
25 except Exception as e:
26 pass
26 pass
27 return procs
27 return procs
28
28
29 def getOperations():
29 def getOperations():
30 module = dir(schainpy.model)
30 module = dir(schainpy.model)
31 noProcs = [x for x in module if not x.endswith('Proc')]
31 noProcs = [x for x in module if not x.endswith('Proc')]
32 operations = check_module(noProcs, Operation)
32 operations = check_module(noProcs, Operation)
33 try:
33 try:
34 operations.remove('Operation')
34 operations.remove('Operation')
35 except Exception as e:
35 except Exception as e:
36 pass
36 pass
37 return operations
37 return operations
38
38
39 def getArgs(op):
39 def getArgs(op):
40 module = locate('schainpy.model.{}'.format(op))
40 module = locate('schainpy.model.{}'.format(op))
41 args = module().getAllowedArgs()
41 args = module().getAllowedArgs()
42 try:
42 try:
43 args.remove('self')
43 args.remove('self')
44 except Exception as e:
44 except Exception as e:
45 pass
45 pass
46 try:
46 try:
47 args.remove('dataOut')
47 args.remove('dataOut')
48 except Exception as e:
48 except Exception as e:
49 pass
49 pass
50 return args
50 return args
51
51
52 def getAll():
52 def getAll():
53 allModules = dir(schainpy.model)
53 allModules = dir(schainpy.model)
54 modules = check_module(allModules, Operation)
54 modules = check_module(allModules, Operation)
55 modules.extend(check_module(allModules, ProcessingUnit))
55 modules.extend(check_module(allModules, ProcessingUnit))
56 return modules
56 return modules
57
57
58
58
59 def print_version(ctx, param, value):
59 def print_version(ctx, param, value):
60 if not value or ctx.resilient_parsing:
60 if not value or ctx.resilient_parsing:
61 return
61 return
62 click.echo(schainpy.__version__)
62 click.echo(schainpy.__version__)
63 ctx.exit()
63 ctx.exit()
64
64
65
65
66 PREFIX = 'experiment'
66 PREFIX = 'experiment'
67
67
68 @click.command()
68 @click.command()
69 @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str)
69 @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str)
70 @click.argument('command', default='run', required=True)
70 @click.argument('command', default='run', required=True)
71 @click.argument('nextcommand', default=None, required=False, type=str)
71 @click.argument('nextcommand', default=None, required=False, type=str)
72 def main(command, nextcommand, version):
72 def main(command, nextcommand, version):
73 """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n
73 """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY V3.0\n
74 Available commands.\n
74 Available commands.\n
75 --xml: runs a schain XML generated file\n
75 xml: runs a schain XML generated file\n
76 run: runs any python script starting 'experiment_'\n
76 run: runs any python script starting 'experiment_'\n
77 generate: generates a template schain script\n
77 generate: generates a template schain script\n
78 search: return avilable operations, procs or arguments of the give operation/proc\n"""
78 search: return avilable operations, procs or arguments of the give operation/proc\n"""
79 if command == 'xml':
79 if command == 'xml':
80 runFromXML(nextcommand)
80 runFromXML(nextcommand)
81 elif command == 'generate':
81 elif command == 'generate':
82 generate()
82 generate()
83 elif command == 'test':
83 elif command == 'test':
84 test()
84 test()
85 elif command == 'run':
85 elif command == 'run':
86 runschain(nextcommand)
86 runschain(nextcommand)
87 elif command == 'search':
87 elif command == 'search':
88 search(nextcommand)
88 search(nextcommand)
89 else:
89 else:
90 log.error('Command {} is not defined'.format(command))
90 log.error('Command {} is not defined'.format(command))
91
91
92
92
93 def check_module(possible, instance):
93 def check_module(possible, instance):
94 def check(x):
94 def check(x):
95 try:
95 try:
96 instancia = locate('schainpy.model.{}'.format(x))
96 instancia = locate('schainpy.model.{}'.format(x))
97 return isinstance(instancia(), instance)
97 return isinstance(instancia(), instance)
98 except Exception as e:
98 except Exception as e:
99 return False
99 return False
100 clean = clean_modules(possible)
100 clean = clean_modules(possible)
101 return [x for x in clean if check(x)]
101 return [x for x in clean if check(x)]
102
102
103
103
104 def clean_modules(module):
104 def clean_modules(module):
105 noEndsUnder = [x for x in module if not x.endswith('__')]
105 noEndsUnder = [x for x in module if not x.endswith('__')]
106 noStartUnder = [x for x in noEndsUnder if not x.startswith('__')]
106 noStartUnder = [x for x in noEndsUnder if not x.startswith('__')]
107 noFullUpper = [x for x in noStartUnder if not x.isupper()]
107 noFullUpper = [x for x in noStartUnder if not x.isupper()]
108 return noFullUpper
108 return noFullUpper
109
109
110
110
111 def search(nextcommand):
111 def search(nextcommand):
112 if nextcommand is None:
112 if nextcommand is None:
113 log.error('There is no Operation/ProcessingUnit to search', '')
113 log.error('There is no Operation/ProcessingUnit to search', '')
114 elif nextcommand == 'procs':
114 elif nextcommand == 'procs':
115 procs = getProcs()
115 procs = getProcs()
116 log.success(
116 log.success(
117 'Current ProcessingUnits are:\n{}'.format('\n'.join(procs)), '')
117 'Current ProcessingUnits are:\n{}'.format('\n'.join(procs)), '')
118
118
119 elif nextcommand == 'operations':
119 elif nextcommand == 'operations':
120 operations = getOperations()
120 operations = getOperations()
121 log.success('Current Operations are:\n{}'.format(
121 log.success('Current Operations are:\n{}'.format(
122 '\n'.join(operations)), '')
122 '\n'.join(operations)), '')
123 else:
123 else:
124 try:
124 try:
125 args = getArgs(nextcommand)
125 args = getArgs(nextcommand)
126 if len(args) == 0:
126 if len(args) == 0:
127 log.success('`{}` has no arguments'.format(nextcommand), '')
127 log.success('`{}` has no arguments'.format(nextcommand), '')
128 else:
128 else:
129 log.success('`{}` arguments: {}'.format(
129 log.success('`{}` arguments: {}'.format(
130 nextcommand, ', '.join(args)), '')
130 nextcommand, ', '.join(args)), '')
131 except Exception as e:
131 except Exception as e:
132 log.error('Module `{}` does not exists'.format(nextcommand), '')
132 log.error('Module `{}` does not exists'.format(nextcommand), '')
133 allModules = getAll()
133 allModules = getAll()
134 similar = [t[0] for t in process.extract(nextcommand, allModules, limit=12) if t[1]>80]
134 similar = [t[0] for t in process.extract(nextcommand, allModules, limit=12) if t[1]>80]
135 log.success('Possible modules are: {}'.format(', '.join(similar)), '')
135 log.success('Possible modules are: {}'.format(', '.join(similar)), '')
136
136
137 def runschain(nextcommand):
137 def runschain(nextcommand):
138 if nextcommand is None:
138 if nextcommand is None:
139 currentfiles = glob.glob('./{}_*.py'.format(PREFIX))
139 currentfiles = glob.glob('./{}_*.py'.format(PREFIX))
140 numberfiles = len(currentfiles)
140 numberfiles = len(currentfiles)
141 if numberfiles > 1:
141 if numberfiles > 1:
142 log.error('There is more than one file to run')
142 log.error('There is more than one file to run')
143 elif numberfiles == 1:
143 elif numberfiles == 1:
144 subprocess.call(['python ' + currentfiles[0]], shell=True)
144 subprocess.call(['python ' + currentfiles[0]], shell=True)
145 else:
145 else:
146 log.error('There is no file to run')
146 log.error('There is no file to run')
147 else:
147 else:
148 try:
148 try:
149 subprocess.call(['python ' + nextcommand], shell=True)
149 subprocess.call(['python ' + nextcommand], shell=True)
150 except Exception as e:
150 except Exception as e:
151 log.error("I cannot run the file. Does it exists?")
151 log.error("I cannot run the file. Does it exists?")
152
152
153
153
154 def basicInputs():
154 def basicInputs():
155 inputs = {}
155 inputs = {}
156 inputs['desc'] = click.prompt(
157 'Enter a description', default="A schain project", type=str)
158 inputs['name'] = click.prompt(
156 inputs['name'] = click.prompt(
159 'Name of the project', default="project", type=str)
157 'Name of the project', default="project", type=str)
158 inputs['desc'] = click.prompt(
159 'Enter a description', default="A schain project", type=str)
160 inputs['multiprocess'] = click.prompt(
161 '''Select data type:
162
163 - Voltage (*.r): [1]
164 - Spectra (*.pdata): [2]
165 - Voltage and Spectra (*.r): [3]
166
167 -->''', type=int)
160 inputs['path'] = click.prompt('Data path', default=os.getcwd(
168 inputs['path'] = click.prompt('Data path', default=os.getcwd(
161 ), type=click.Path(exists=True, resolve_path=True))
169 ), type=click.Path(exists=True, resolve_path=True))
162 inputs['startDate'] = click.prompt(
170 inputs['startDate'] = click.prompt(
163 'Start date', default='1970/01/01', type=str)
171 'Start date', default='1970/01/01', type=str)
164 inputs['endDate'] = click.prompt(
172 inputs['endDate'] = click.prompt(
165 'End date', default='2017/12/31', type=str)
173 'End date', default='2018/12/31', type=str)
166 inputs['startHour'] = click.prompt(
174 inputs['startHour'] = click.prompt(
167 'Start hour', default='00:00:00', type=str)
175 'Start hour', default='00:00:00', type=str)
168 inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str)
176 inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str)
169 inputs['figpath'] = inputs['path'] + '/figs'
177 inputs['figpath'] = inputs['path'] + '/figs'
170 return inputs
178 return inputs
171
179
172
180
173 def generate():
181 def generate():
174 inputs = basicInputs()
182 inputs = basicInputs()
175 inputs['multiprocess'] = click.confirm('Is this a multiprocess script?')
183
176 if inputs['multiprocess']:
184 if inputs['multiprocess'] == 1:
177 inputs['nProcess'] = click.prompt(
185 current = templates.voltage.format(**inputs)
178 'How many process?', default=cpu_count(), type=int)
186 elif inputs['multiprocess'] == 2:
179 current = templates.multiprocess.format(**inputs)
187 current = templates.spectra.format(**inputs)
180 else:
188 elif inputs['multiprocess'] == 3:
181 current = templates.basic.format(**inputs)
189 current = templates.voltagespectra.format(**inputs)
182 scriptname = '{}_{}.py'.format(PREFIX, inputs['name'])
190 scriptname = '{}_{}.py'.format(PREFIX, inputs['name'])
183 script = open(scriptname, 'w')
191 script = open(scriptname, 'w')
184 try:
192 try:
185 script.write(current)
193 script.write(current)
186 log.success('Script {} generated'.format(scriptname))
194 log.success('Script {} generated'.format(scriptname))
187 except Exception as e:
195 except Exception as e:
188 log.error('I cannot create the file. Do you have writing permissions?')
196 log.error('I cannot create the file. Do you have writing permissions?')
189
197
190
198
191 def test():
199 def test():
192 log.warning('testing')
200 log.warning('testing')
193
201
194
202
195 def runFromXML(filename):
203 def runFromXML(filename):
196 controller = Project()
204 controller = Project()
197 if not controller.readXml(filename):
205 if not controller.readXml(filename):
198 return
206 return
199 controller.start()
207 controller.start()
200 return
208 return
@@ -1,90 +1,269
1 basic = '''from schainpy.controller import Project
1 voltage = '''import os, sys, time
2 from schainpy.controller import Project
3
4
5 def main():
6 desc = "{desc}"
7 controller = Project()
8 controller.setup(id='200', name="{name}", description=desc)
9
10 read_unit = controller.addReadUnit(datatype='Voltage',
11 path="{path}",
12 startDate="{startDate}",
13 endDate="{endDate}",
14 startTime="{startHour}",
15 endTime="{endHour}",
16 online=0,
17 verbose=1,
18 walk=0,
19 delay=180,
20 )
21
22 code = '[[1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1]]'
23 nCode = '128'
24 nBaud = '3'
25
26
27 proc_voltage = controller.addProcUnit(name='VoltageProc', inputId=read_unit.getId())
28
29 op1 = proc_voltage.addOperation(name='selectChannels', optype='self')
30 op1.addParameter(name='channelList', value='0, 1, 2, 3', format='intlist')
31
32 op2 = proc_voltage.addOperation(name='filterByHeights', optype='self')
33 op2.addParameter(name='window', value='4', format='int')
34
35 op3 = proc_voltage.addOperation(name='ProfileSelector', optype='other')
36 op3.addParameter(name='profileRangeList', value='32, 159', format='intList')
37
38 op4 = proc_voltage.addOperation(name='Decoder', optype='other')
39 op4.addParameter(name='code', value=code, format='intlist')
40 op4.addParameter(name='nCode', value=nCode, format='int')
41 op4.addParameter(name='nBaud', value=nBaud, format='int')
42 op4.addParameter(name='mode', value='0', format='int')
43
44 op5 = proc_voltage.addOperation(name='Scope', optype='external')
45 op5.addParameter(name='id', value='30', format='int')
46
47
48
49
50
51 controller.start()
52
53 if __name__ == '__main__':
54 import time
55 start_time = time.time()
56 main()
57 print("--- %s seconds ---" % (time.time() - start_time))
2
58
3 desc = "{desc}"
4 project = Project()
5 project.setup(id='200', name="{name}", description=desc)
6
7 voltage_reader = project.addReadUnit(datatype='VoltageReader',
8 path="{path}",
9 startDate="{startDate}",
10 endDate="{endDate}",
11 startTime="{startHour}",
12 endTime="{endHour}",
13 online=0,
14 verbose=1,
15 walk=1,
16 )
17
18 voltage_proc = project.addProcUnit(datatype='VoltageProc', inputId=voltage_reader.getId())
19
20 profile = voltage_proc.addOperation(name='ProfileSelector', optype='other')
21 profile.addParameter(name='profileRangeList', value='120,183', format='intlist')
22
23 rti = voltage_proc.addOperation(name='RTIPlot', optype='other')
24 rti.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str')
25 rti.addParameter(name='showprofile', value='0', format='int')
26 rti.addParameter(name='xmin', value='0', format='int')
27 rti.addParameter(name='xmax', value='24', format='int')
28 rti.addParameter(name='figpath', value="{figpath}", format='str')
29 rti.addParameter(name='wr_period', value='5', format='int')
30 rti.addParameter(name='exp_code', value='22', format='int')
31
32
33 project.start()
34 '''
59 '''
35
60
61
62 spectra = '''import os, sys, time
63 from schainpy.controller import Project
64
65
66 def main():
67 desc = "{desc}"
68 controller = Project()
69 controller.setup(id='300', name="{name}", description=desc)
70
71 read_unit = controller.addReadUnit(datatype='Spectra',
72 path="{path}",
73 startDate="{startDate}",
74 endDate="{endDate}",
75 startTime="{startHour}",
76 endTime="{endHour}",
77 online=0,
78 verbose=1,
79 walk=0,
80 delay=180,
81 )
82
83 proc_spectra = controller.addProcUnit(datatype='Spectra', inputId=read_unit.getId())
84 proc_spectra.addParameter(name='nFFTPoints', value='128', format='int')
85 proc_spectra.addParameter(name='nProfiles', value='128', format='int')
86 proc_spectra.addParameter(name='pairsList', value='(0, 1), (2, 3)', format='pairslist')
87
88 op1 = proc_spectra.addOperation(name='IncohInt', optype='other')
89 op1.addParameter(name='n', value='4', format='int')
90
91 op2 = proc_spectra.addOperation(name='CrossSpectraPlot', optype='external')
92 op2.addParameter(name='id', value='10', format='int')
93 op2.addParameter(name='zmin', value='10.0', format='float')
94 op2.addParameter(name='zmax', value='35.0', format='float')
95
96
97 op3 = proc_spectra.addOperation(name='RTIPlot', optype='external')
98 op3.addParameter(name='id', value='20', format='int')
99 op3.addParameter(name='wintitle', value='RTI', format='str')
100 op3.addParameter(name='xmin', value='0', format='float')
101 op3.addParameter(name='xmax', value='24', format='float')
102 op3.addParameter(name='zmin', value='12', format='int')
103 op3.addParameter(name='zmax', value='32', format='int')
104 op3.addParameter(name='showprofile', value='1', format='int')
105 op3.addParameter(name='timerange', value=str(24*60*60), format='int')
106
107 op4 = proc_spectra.addOperation(name='CoherenceMap', optype='external')
108 op4.addParameter(name='id', value='30', format='int')
109 op4.addParameter(name='xmin', value='0.0', format='float')
110 op4.addParameter(name='xmax', value='24.0', format='float')
111
112
113 controller.start()
114
115 if __name__ == '__main__':
116 import time
117 start_time = time.time()
118 main()
119 print("--- %s seconds ---" % (time.time() - start_time))
120
121 '''
122
123 voltagespectra = '''import os, sys, time
124 from schainpy.controller import Project
125
126
127 def main():
128 desc = "{desc}"
129 controller = Project()
130 controller.setup(id='400', name="{name}", description=desc)
131
132 read_unit = controller.addReadUnit(datatype='Voltage',
133 path="{path}",
134 startDate="{startDate}",
135 endDate="{endDate}",
136 startTime="{startHour}",
137 endTime="{endHour}",
138 online=0,
139 verbose=1,
140 walk=0,
141 delay=180,
142 )
143
144 code = '[[1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, -1, 1], [-1, -1, 1], [1, 1, -1]]'
145 nCode = '128'
146 nBaud = '3'
147
148
149 proc_voltage = controller.addProcUnit(name='VoltageProc', inputId=read_unit.getId())
150
151 op1 = proc_voltage.addOperation(name='selectChannels', optype='self')
152 op1.addParameter(name='channelList', value='0, 1, 2, 3', format='intlist')
153
154 op2 = proc_voltage.addOperation(name='filterByHeights', optype='self')
155 op2.addParameter(name='window', value='4', format='int')
156
157 op3 = proc_voltage.addOperation(name='ProfileSelector', optype='other')
158 op3.addParameter(name='profileRangeList', value='32, 159', format='intList')
159
160 op4 = proc_voltage.addOperation(name='Decoder', optype='other')
161 op4.addParameter(name='code', value=code, format='intlist')
162 op4.addParameter(name='nCode', value=nCode, format='int')
163 op4.addParameter(name='nBaud', value=nBaud, format='int')
164 op4.addParameter(name='mode', value='0', format='int')
165
166
167
168 proc_spectra = controller.addProcUnit(datatype='Spectra', inputId=proc_voltage.getId())
169 proc_spectra.addParameter(name='nFFTPoints', value='128', format='int')
170 proc_spectra.addParameter(name='nProfiles', value='128', format='int')
171 proc_spectra.addParameter(name='pairsList', value='(0, 1), (2, 3)', format='pairslist')
172
173 op5 = proc_spectra.addOperation(name='IncohInt', optype='other')
174 op5.addParameter(name='n', value='4', format='int')
175
176 op6 = proc_spectra.addOperation(name='CrossSpectraPlot', optype='external')
177 op6.addParameter(name='id', value='10', format='int')
178 op6.addParameter(name='zmin', value='10.0', format='float')
179 op6.addParameter(name='zmax', value='35.0', format='float')
180
181
182 op7 = proc_spectra.addOperation(name='RTIPlot', optype='external')
183 op7.addParameter(name='id', value='20', format='int')
184 op7.addParameter(name='wintitle', value='RTI', format='str')
185 op7.addParameter(name='xmin', value='0', format='float')
186 op7.addParameter(name='xmax', value='24', format='float')
187 op7.addParameter(name='zmin', value='12', format='int')
188 op7.addParameter(name='zmax', value='32', format='int')
189 op7.addParameter(name='showprofile', value='1', format='int')
190 op7.addParameter(name='timerange', value=str(24*60*60), format='int')
191
192 op8 = proc_spectra.addOperation(name='CoherenceMap', optype='external')
193 op8.addParameter(name='id', value='30', format='int')
194 op8.addParameter(name='xmin', value='0.0', format='float')
195 op8.addParameter(name='xmax', value='24.0', format='float')
196
197
198 controller.start()
199
200 if __name__ == '__main__':
201 import time
202 start_time = time.time()
203 main()
204 print("--- %s seconds ---" % (time.time() - start_time))
205
206 '''
207
208
209
210
211
212
213
214
36 multiprocess = '''from schainpy.controller import Project, MPProject
215 multiprocess = '''from schainpy.controller import Project, MPProject
37 from time import sleep
216 from time import sleep
38 desc = "{desc}"
217 desc = "{desc}"
39
218
40 ####################
219 ####################
41 # PLOTTER RECEIVER #
220 # PLOTTER RECEIVER #
42 ####################
221 ####################
43 plotter = Project()
222 plotter = Project()
44 plotter.setup(id='100', name='receiver', description=desc)
223 plotter.setup(id='100', name='receiver', description=desc)
45
224
46 receiver_plot = plotter.addProcUnit(name='PlotterReceiver')
225 receiver_plot = plotter.addProcUnit(name='PlotterReceiver')
47 receiver_plot.addParameter(name='throttle', value=20, format='int')
226 receiver_plot.addParameter(name='throttle', value=20, format='int')
48 receiver_plot.addParameter(name='plottypes', value='rti', format='str')
227 receiver_plot.addParameter(name='plottypes', value='rti', format='str')
49
228
50 rti = receiver_plot.addOperation(name='PlotRTIData', optype='other')
229 rti = receiver_plot.addOperation(name='PlotRTIData', optype='other')
51 rti.addParameter(name='zmin', value='-40.0', format='float')
230 rti.addParameter(name='zmin', value='-40.0', format='float')
52 rti.addParameter(name='zmax', value='100.0', format='float')
231 rti.addParameter(name='zmax', value='100.0', format='float')
53 rti.addParameter(name='decimation', value='200', format='int')
232 rti.addParameter(name='decimation', value='200', format='int')
54 rti.addParameter(name='xmin', value='0.0', format='int')
233 rti.addParameter(name='xmin', value='0.0', format='int')
55 rti.addParameter(name='colormap', value='jet', format='str')
234 rti.addParameter(name='colormap', value='jet', format='str')
56
235
57 plotter.start()
236 plotter.start()
58
237
59 sleep(2)
238 sleep(2)
60
239
61 ################
240 ################
62 # DATA EMITTER #
241 # DATA EMITTER #
63 ################
242 ################
64 project = Project()
243 controller = Project()
65 project.setup(id='200', name="{name}", description=desc)
244 controller.setup(id='200', name="{name}", description=desc)
66
245
67 spectra_reader = project.addReadUnit(datatype='SpectraReader',
246 spectra_reader = controller.addReadUnit(datatype='SpectraReader',
68 path="{path}",
247 path="{path}",
69 startDate={startDate},
248 startDate={startDate},
70 endDate={endDate},
249 endDate={endDate},
71 startTime="{startHour}",
250 startTime="{startHour}",
72 endTime="{endHour}",
251 endTime="{endHour}",
73 online=0,
252 online=0,
74 verbose=1,
253 verbose=1,
75 walk=1,
254 walk=1,
76 )
255 )
77
256
78 spectra_proc = project.addProcUnit(datatype='Spectra', inputId=spectra_reader.getId())
257 spectra_proc = controller.addProcUnit(datatype='Spectra', inputId=spectra_reader.getId())
79
258
80 parameters_proc = project.addProcUnit(datatype='ParametersProc', inputId=spectra_proc.getId())
259 parameters_proc = controller.addProcUnit(datatype='ParametersProc', inputId=spectra_proc.getId())
81 moments = parameters_proc.addOperation(name='SpectralMoments', optype='other')
260 moments = parameters_proc.addOperation(name='SpectralMoments', optype='other')
82
261
83 publish = parameters_proc.addOperation(name='PublishData', optype='other')
262 publish = parameters_proc.addOperation(name='PublishData', optype='other')
84 publish.addParameter(name='zeromq', value=1, format='int')
263 publish.addParameter(name='zeromq', value=1, format='int')
85 publish.addParameter(name='verbose', value=0, format='bool')
264 publish.addParameter(name='verbose', value=0, format='bool')
86
265
87 MPProject(project, 16)
266 MPProject(controller, 16)
88
267
89
268
90 '''
269 '''
General Comments 0
You need to be logged in to leave comments. Login now