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