@@ -0,0 +1,34 | |||
|
1 | from schainpy.controller import Project | |
|
2 | ||
|
3 | desc = "A schain project" | |
|
4 | ||
|
5 | controller = Project() | |
|
6 | controller.setup(id='191', name="project", description=desc) | |
|
7 | ||
|
8 | readUnitConf = controller.addReadUnit(datatype='VoltageReader', | |
|
9 | path="/home/nanosat/schain", | |
|
10 | startDate="1970/01/01", | |
|
11 | endDate="2017/12/31", | |
|
12 | startTime="00:00:00", | |
|
13 | endTime="23:59:59", | |
|
14 | online=0, | |
|
15 | verbose=1, | |
|
16 | walk=1, | |
|
17 | ) | |
|
18 | ||
|
19 | procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) | |
|
20 | ||
|
21 | opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') | |
|
22 | opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') | |
|
23 | ||
|
24 | opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') | |
|
25 | opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') | |
|
26 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
|
27 | opObj11.addParameter(name='xmin', value='0', format='int') | |
|
28 | opObj11.addParameter(name='xmax', value='24', format='int') | |
|
29 | opObj11.addParameter(name='figpath', value="/home/nanosat/schain/figs", format='str') | |
|
30 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
31 | opObj11.addParameter(name='exp_code', value='22', format='int') | |
|
32 | ||
|
33 | ||
|
34 | controller.start() |
@@ -0,0 +1,1 | |||
|
1 | <Project description="A schain project" id="191" name="project"><ReadUnit datatype="Voltage" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/schain" /><Parameter format="date" id="191113" name="startDate" value="1970/01/01" /><Parameter format="date" id="191114" name="endDate" value="2017/12/31" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="walk" value="1" /><Parameter format="int" id="191119" name="verbose" value="1" /><Parameter format="int" id="191120" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Voltage" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="ProfileSelector" priority="2" type="other"><Parameter format="intlist" id="191221" name="profileRangeList" value="120,183" /></Operation><Operation id="19123" name="RTIPlot" priority="3" type="plotter"><Parameter format="str" id="191231" name="wintitle" value="Jicamarca Radio Observatory" /><Parameter format="int" id="191232" name="showprofile" value="0" /><Parameter format="int" id="191233" name="xmin" value="0" /><Parameter format="int" id="191234" name="xmax" value="24" /><Parameter format="str" id="191235" name="figpath" value="/home/nanosat/schain/figs" /><Parameter format="int" id="191236" name="wr_period" value="5" /><Parameter format="int" id="191237" name="exp_code" value="22" /></Operation></ProcUnit></Project> No newline at end of file |
@@ -0,0 +1,9 | |||
|
1 | # schaing | |
|
2 | ||
|
3 | Command Line Interface for SIGNAL CHAIN - jro | |
|
4 | ||
|
5 | # Usage | |
|
6 | ||
|
7 | To use it: | |
|
8 | ||
|
9 | $ schain-cli --help |
|
1 | NO CONTENT: new file 100644 |
@@ -0,0 +1,34 | |||
|
1 | from schainpy.controller import Project | |
|
2 | ||
|
3 | desc = "asdasddsad" | |
|
4 | ||
|
5 | controller = Project() | |
|
6 | controller.setup(id='191', name="asdasd", description=desc) | |
|
7 | ||
|
8 | readUnitConf = controller.addReadUnit(datatype='VoltageReader', | |
|
9 | path="/home/nanosat/schain/schain-cli", | |
|
10 | startDate="1970/01/01", | |
|
11 | endDate="2017/12/31", | |
|
12 | startTime="00:00:00", | |
|
13 | endTime="23:59:59", | |
|
14 | online=0, | |
|
15 | verbose=1, | |
|
16 | walk=1, | |
|
17 | ) | |
|
18 | ||
|
19 | procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) | |
|
20 | ||
|
21 | opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') | |
|
22 | opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') | |
|
23 | ||
|
24 | opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') | |
|
25 | opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') | |
|
26 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
|
27 | opObj11.addParameter(name='xmin', value='0', format='int') | |
|
28 | opObj11.addParameter(name='xmax', value='24', format='int') | |
|
29 | opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schain-cli/figs", format='str') | |
|
30 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
31 | opObj11.addParameter(name='exp_code', value='22', format='int') | |
|
32 | ||
|
33 | ||
|
34 | controller.start() |
@@ -0,0 +1,188 | |||
|
1 | import click | |
|
2 | import schainpy | |
|
3 | import subprocess | |
|
4 | import os | |
|
5 | import sys | |
|
6 | import glob | |
|
7 | save_stdout = sys.stdout | |
|
8 | sys.stdout = open('trash', 'w') | |
|
9 | from multiprocessing import cpu_count | |
|
10 | from schaincli import templates | |
|
11 | from schainpy import controller_api | |
|
12 | from schainpy.model import Operation, ProcessingUnit | |
|
13 | from schainpy.utils import log | |
|
14 | from importlib import import_module | |
|
15 | from pydoc import locate | |
|
16 | from fuzzywuzzy import process | |
|
17 | sys.stdout = save_stdout | |
|
18 | ||
|
19 | ||
|
20 | def print_version(ctx, param, value): | |
|
21 | if not value or ctx.resilient_parsing: | |
|
22 | return | |
|
23 | click.echo(schainpy.__version__) | |
|
24 | ctx.exit() | |
|
25 | ||
|
26 | ||
|
27 | cliLogger = log.makelogger('schain cli') | |
|
28 | PREFIX = 'experiment' | |
|
29 | ||
|
30 | ||
|
31 | @click.command() | |
|
32 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) | |
|
33 | @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True)) | |
|
34 | @click.argument('command', default='run', required=True) | |
|
35 | @click.argument('nextcommand', default=None, required=False, type=str) | |
|
36 | def main(command, nextcommand, version, xml): | |
|
37 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n | |
|
38 | Available commands.\n | |
|
39 | --xml: runs a schain XML generated file\n | |
|
40 | run: runs any python script starting 'experiment_'\n | |
|
41 | generate: generates a template schain script\n | |
|
42 | search: return avilable operations, procs or arguments of the give operation/proc\n""" | |
|
43 | if xml is not None: | |
|
44 | runFromXML(xml) | |
|
45 | elif command == 'generate': | |
|
46 | generate() | |
|
47 | elif command == 'test': | |
|
48 | test() | |
|
49 | elif command == 'run': | |
|
50 | runschain(nextcommand) | |
|
51 | elif command == 'search': | |
|
52 | search(nextcommand) | |
|
53 | else: | |
|
54 | log.error('Command {} is not defined'.format(command)) | |
|
55 | ||
|
56 | def check_module(possible, instance): | |
|
57 | def check(x): | |
|
58 | try: | |
|
59 | instancia = locate('schainpy.model.{}'.format(x)) | |
|
60 | return isinstance(instancia(), instance) | |
|
61 | except Exception as e: | |
|
62 | return False | |
|
63 | clean = clean_modules(possible) | |
|
64 | return [x for x in clean if check(x)] | |
|
65 | ||
|
66 | ||
|
67 | def clean_modules(module): | |
|
68 | noEndsUnder = [x for x in module if not x.endswith('__')] | |
|
69 | noStartUnder = [x for x in noEndsUnder if not x.startswith('__')] | |
|
70 | noFullUpper = [x for x in noStartUnder if not x.isupper()] | |
|
71 | return noFullUpper | |
|
72 | ||
|
73 | ||
|
74 | def search(nextcommand): | |
|
75 | if nextcommand is None: | |
|
76 | log.error('There is no Operation/ProcessingUnit to search') | |
|
77 | elif nextcommand == 'procs': | |
|
78 | module = dir(import_module('schainpy.model')) | |
|
79 | procs = check_module(module, ProcessingUnit) | |
|
80 | try: | |
|
81 | procs.remove('ProcessingUnit') | |
|
82 | except Exception as e: | |
|
83 | pass | |
|
84 | log.success('Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs))) | |
|
85 | ||
|
86 | elif nextcommand == 'operations': | |
|
87 | module = dir(import_module('schainpy.model')) | |
|
88 | noProcs = [x for x in module if not x.endswith('Proc')] | |
|
89 | operations = check_module(noProcs, Operation) | |
|
90 | try: | |
|
91 | operations.remove('Operation') | |
|
92 | except Exception as e: | |
|
93 | pass | |
|
94 | log.success('Current Operations are:\n\033[1m{}\033[0m'.format('\n'.join(operations))) | |
|
95 | else: | |
|
96 | try: | |
|
97 | module = locate('schainpy.model.{}'.format(nextcommand)) | |
|
98 | args = module().getAllowedArgs() | |
|
99 | log.warning('Use this feature with caution. It may not return all the allowed arguments') | |
|
100 | try: | |
|
101 | args.remove('self') | |
|
102 | except Exception as e: | |
|
103 | pass | |
|
104 | try: | |
|
105 | args.remove('dataOut') | |
|
106 | except Exception as e: | |
|
107 | pass | |
|
108 | if len(args) == 0: | |
|
109 | log.success('{} has no arguments'.format(nextcommand)) | |
|
110 | else: | |
|
111 | log.success('Showing arguments of {} are:\n\033[1m{}\033[0m'.format(nextcommand, '\n'.join(args))) | |
|
112 | except Exception as e: | |
|
113 | log.error('Module {} does not exists'.format(nextcommand)) | |
|
114 | allModules = dir(import_module('schainpy.model')) | |
|
115 | module = check_module(allModules, Operation) | |
|
116 | module.extend(check_module(allModules, ProcessingUnit)) | |
|
117 | similar = process.extractOne(nextcommand, module)[0] | |
|
118 | log.success('Searching {} instead'.format(similar)) | |
|
119 | search(similar) | |
|
120 | ||
|
121 | ||
|
122 | def runschain(nextcommand): | |
|
123 | if nextcommand is None: | |
|
124 | currentfiles = glob.glob('./{}_*.py'.format(PREFIX)) | |
|
125 | numberfiles = len(currentfiles) | |
|
126 | if numberfiles > 1: | |
|
127 | log.error('There is more than one file to run') | |
|
128 | elif numberfiles == 1: | |
|
129 | subprocess.call(['python ' + currentfiles[0]], shell=True) | |
|
130 | else: | |
|
131 | log.error('There is no file to run') | |
|
132 | else: | |
|
133 | try: | |
|
134 | subprocess.call(['python ' + nextcommand], shell=True) | |
|
135 | except Exception as e: | |
|
136 | log.error("I cannot run the file. Does it exists?") | |
|
137 | ||
|
138 | ||
|
139 | def basicInputs(): | |
|
140 | inputs = {} | |
|
141 | inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str) | |
|
142 | inputs['name'] = click.prompt('Name of the project', default="project", type=str) | |
|
143 | inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True)) | |
|
144 | inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str) | |
|
145 | inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str) | |
|
146 | inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str) | |
|
147 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) | |
|
148 | inputs['figpath'] = inputs['path'] + '/figs' | |
|
149 | return inputs | |
|
150 | ||
|
151 | ||
|
152 | def generate(): | |
|
153 | inputs = basicInputs() | |
|
154 | inputs['multiprocess'] = click.confirm('Is this a multiprocess script?') | |
|
155 | if inputs['multiprocess']: | |
|
156 | inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int) | |
|
157 | current = templates.multiprocess.format(**inputs) | |
|
158 | else: | |
|
159 | current = templates.basic.format(**inputs) | |
|
160 | scriptname = '{}_{}.py'.format(PREFIX, inputs['name']) | |
|
161 | script = open(scriptname, 'w') | |
|
162 | try: | |
|
163 | script.write(current) | |
|
164 | log.success('Script {} generated'.format(scriptname)) | |
|
165 | except Exception as e: | |
|
166 | log.error('I cannot create the file. Do you have writing permissions?') | |
|
167 | ||
|
168 | ||
|
169 | def test(): | |
|
170 | log.warning('testing') | |
|
171 | ||
|
172 | ||
|
173 | def runFromXML(filename): | |
|
174 | controller = controller_api.ControllerThread() | |
|
175 | if not controller.readXml(filename): | |
|
176 | return | |
|
177 | ||
|
178 | plotterObj = controller.useExternalPlotter() | |
|
179 | ||
|
180 | controller.start() | |
|
181 | plotterObj.start() | |
|
182 | ||
|
183 | cliLogger("Finishing all processes") | |
|
184 | ||
|
185 | controller.join(5) | |
|
186 | ||
|
187 | cliLogger("End of script") | |
|
188 | return |
@@ -0,0 +1,75 | |||
|
1 | basic = '''from schainpy.controller import Project | |
|
2 | ||
|
3 | desc = "{desc}" | |
|
4 | ||
|
5 | controller = Project() | |
|
6 | controller.setup(id='191', name="{name}", description=desc) | |
|
7 | ||
|
8 | readUnitConf = controller.addReadUnit(datatype='VoltageReader', | |
|
9 | path="{path}", | |
|
10 | startDate="{startDate}", | |
|
11 | endDate="{endDate}", | |
|
12 | startTime="{startHour}", | |
|
13 | endTime="{endHour}", | |
|
14 | online=0, | |
|
15 | verbose=1, | |
|
16 | walk=1, | |
|
17 | ) | |
|
18 | ||
|
19 | procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) | |
|
20 | ||
|
21 | opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') | |
|
22 | opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') | |
|
23 | ||
|
24 | opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') | |
|
25 | opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') | |
|
26 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
|
27 | opObj11.addParameter(name='xmin', value='0', format='int') | |
|
28 | opObj11.addParameter(name='xmax', value='24', format='int') | |
|
29 | opObj11.addParameter(name='figpath', value="{figpath}", format='str') | |
|
30 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
31 | opObj11.addParameter(name='exp_code', value='22', format='int') | |
|
32 | ||
|
33 | ||
|
34 | controller.start() | |
|
35 | ''' | |
|
36 | ||
|
37 | multiprocess = '''from schainpy.controller import Project, multiSchain | |
|
38 | ||
|
39 | desc = "{desc}" | |
|
40 | ||
|
41 | def fiber(cursor, skip, q, day): | |
|
42 | controller = Project() | |
|
43 | controller.setup(id='191', name="{name}", description=desc) | |
|
44 | ||
|
45 | readUnitConf = controller.addReadUnit(datatype='SpectraReader', | |
|
46 | path="{path}", | |
|
47 | startDate=day, | |
|
48 | endDate=day, | |
|
49 | startTime="{startHour}", | |
|
50 | endTime="{endHour}", | |
|
51 | online=0, | |
|
52 | queue=q, | |
|
53 | cursor=cursor, | |
|
54 | skip=skip, | |
|
55 | verbose=1, | |
|
56 | walk=1, | |
|
57 | ) | |
|
58 | ||
|
59 | procUnitConf1 = controller.addProcUnit(datatype='Spectra', inputId=readUnitConf.getId()) | |
|
60 | ||
|
61 | procUnitConf2 = controller.addProcUnit(datatype='ParametersProc', inputId=readUnitConf.getId()) | |
|
62 | opObj11 = procUnitConf2.addOperation(name='SpectralMoments', optype='other') | |
|
63 | ||
|
64 | opObj12 = procUnitConf2.addOperation(name='PublishData', optype='other') | |
|
65 | opObj12.addParameter(name='zeromq', value=1, format='int') | |
|
66 | opObj12.addParameter(name='verbose', value=0, format='bool') | |
|
67 | ||
|
68 | controller.start() | |
|
69 | ||
|
70 | ||
|
71 | if __name__ == '__main__': | |
|
72 | multiSchain(fiber, nProcess={nProcess}, startDate="{startDate}", endDate="{endDate}") | |
|
73 | ||
|
74 | ||
|
75 | ''' |
@@ -0,0 +1,1 | |||
|
1 |
@@ -0,0 +1,29 | |||
|
1 | import pytest | |
|
2 | from click.testing import CliRunner | |
|
3 | from schaincli import cli | |
|
4 | ||
|
5 | ||
|
6 | @pytest.fixture | |
|
7 | def runner(): | |
|
8 | return CliRunner() | |
|
9 | ||
|
10 | ||
|
11 | def test_cli(runner): | |
|
12 | result = runner.invoke(cli.main) | |
|
13 | assert result.exit_code == 0 | |
|
14 | assert not result.exception | |
|
15 | assert result.output.strip() == 'Hello, world.' | |
|
16 | ||
|
17 | ||
|
18 | def test_cli_with_option(runner): | |
|
19 | result = runner.invoke(cli.main, ['--as-cowboy']) | |
|
20 | assert not result.exception | |
|
21 | assert result.exit_code == 0 | |
|
22 | assert result.output.strip() == 'Howdy, world.' | |
|
23 | ||
|
24 | ||
|
25 | def test_cli_with_arg(runner): | |
|
26 | result = runner.invoke(cli.main, ['Jicamarca']) | |
|
27 | assert result.exit_code == 0 | |
|
28 | assert not result.exception | |
|
29 | assert result.output.strip() == 'Hello, Jicamarca.' |
@@ -0,0 +1,34 | |||
|
1 | from schainpy.controller import Project | |
|
2 | ||
|
3 | desc = "A schain project" | |
|
4 | ||
|
5 | controller = Project() | |
|
6 | controller.setup(id='191', name="project", description=desc) | |
|
7 | ||
|
8 | readUnitConf = controller.addReadUnit(datatype='VoltageReader', | |
|
9 | path="/home/nanosat/schain/schainpy", | |
|
10 | startDate="1970/01/01", | |
|
11 | endDate="2017/12/31", | |
|
12 | startTime="00:00:00", | |
|
13 | endTime="23:59:59", | |
|
14 | online=0, | |
|
15 | verbose=1, | |
|
16 | walk=1, | |
|
17 | ) | |
|
18 | ||
|
19 | procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) | |
|
20 | ||
|
21 | opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') | |
|
22 | opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') | |
|
23 | ||
|
24 | opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') | |
|
25 | opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') | |
|
26 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
|
27 | opObj11.addParameter(name='xmin', value='0', format='int') | |
|
28 | opObj11.addParameter(name='xmax', value='24', format='int') | |
|
29 | opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schainpy/figs", format='str') | |
|
30 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
31 | opObj11.addParameter(name='exp_code', value='22', format='int') | |
|
32 | ||
|
33 | ||
|
34 | controller.start() |
@@ -0,0 +1,33 | |||
|
1 | from schainpy.controller import Project | |
|
2 | ||
|
3 | desc = "A schain project" | |
|
4 | ||
|
5 | controller = Project() | |
|
6 | controller.setup(id='191', name="project", description=desc) | |
|
7 | ||
|
8 | readUnitConf = controller.addReadUnit(datatype='VoltageReader', | |
|
9 | path="/home/nanosat/schain/schainpy/scripts", | |
|
10 | startDate="1970/01/01", | |
|
11 | endDate="2017/12/31", | |
|
12 | startTime="00:00:00", | |
|
13 | endTime="23:59:59", | |
|
14 | online=0, | |
|
15 | walk=1, | |
|
16 | ) | |
|
17 | ||
|
18 | procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) | |
|
19 | ||
|
20 | opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') | |
|
21 | opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') | |
|
22 | ||
|
23 | opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') | |
|
24 | opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') | |
|
25 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
|
26 | opObj11.addParameter(name='xmin', value='0', format='int') | |
|
27 | opObj11.addParameter(name='xmax', value='24', format='int') | |
|
28 | opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schainpy/scripts/figs", format='str') | |
|
29 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
30 | opObj11.addParameter(name='exp_code', value='22', format='int') | |
|
31 | ||
|
32 | ||
|
33 | controller.start() |
|
1 | NO CONTENT: new file 100644 |
@@ -0,0 +1,45 | |||
|
1 | """. | |
|
2 | SCHAINPY - LOG | |
|
3 | Simple helper for log standarization | |
|
4 | Usage: | |
|
5 | from schainpy.utils import log | |
|
6 | log.error('A kitten died beacuse of you') | |
|
7 | log.warning('You are doing it wrong but what the heck, I'll allow it) | |
|
8 | log.succes('YOU ROCK!') | |
|
9 | To create your own logger inside your class do it like this: | |
|
10 | from schainpy.utils import log | |
|
11 | awesomeLogger = log.makelogger("never gonna", bg="red", fg="white") | |
|
12 | awesomeLogger('give you up') | |
|
13 | which will look like this: | |
|
14 | [NEVER GONNA] - give you up | |
|
15 | with color red as background and white as foreground. | |
|
16 | """ | |
|
17 | ||
|
18 | import click | |
|
19 | ||
|
20 | ||
|
21 | def warning(message): | |
|
22 | click.echo(click.style('[WARNING] - ' + message, fg='yellow')) | |
|
23 | pass | |
|
24 | ||
|
25 | ||
|
26 | def error(message): | |
|
27 | click.echo(click.style('[ERROR] - ' + message, fg='red')) | |
|
28 | pass | |
|
29 | ||
|
30 | ||
|
31 | def success(message): | |
|
32 | click.echo(click.style(message, fg='green')) | |
|
33 | pass | |
|
34 | ||
|
35 | ||
|
36 | def log(message): | |
|
37 | click.echo('[LOG] - ' + message) | |
|
38 | pass | |
|
39 | ||
|
40 | ||
|
41 | def makelogger(topic, bg='reset', fg='reset'): | |
|
42 | def func(message): | |
|
43 | click.echo(click.style('[{}] - '.format(topic.upper()) + message, | |
|
44 | bg=bg, fg=fg)) | |
|
45 | return func |
@@ -0,0 +1,1 | |||
|
1 | You should install "digital_rf_hdf5" module if you want to read USRP data |
@@ -61,7 +61,7 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_da | |||
|
61 | 61 | process.terminate() |
|
62 | 62 | process.join() |
|
63 | 63 | print traceback.print_tb(trace) |
|
64 | ||
|
64 | ||
|
65 | 65 | sys.excepthook = beforeExit |
|
66 | 66 | |
|
67 | 67 | for process in processes: |
@@ -1315,9 +1315,9 class Project(): | |||
|
1315 | 1315 | |
|
1316 | 1316 | print "Process finished" |
|
1317 | 1317 | |
|
1318 | def start(self): | |
|
1318 | def start(self, filename=None): | |
|
1319 | 1319 | |
|
1320 | self.writeXml() | |
|
1320 | self.writeXml(filename) | |
|
1321 | 1321 | self.createObjects() |
|
1322 | 1322 | self.connectObjects() |
|
1323 | 1323 | self.run() |
@@ -5,175 +5,175 from schainpy.controller import Project | |||
|
5 | 5 | from schainpy.model.graphics.jroplotter import PlotManager |
|
6 | 6 | |
|
7 | 7 | class ControllerThread(threading.Thread, Project): |
|
8 | ||
|
8 | ||
|
9 | 9 | def __init__(self, plotter_queue=None): |
|
10 | ||
|
10 | ||
|
11 | 11 | threading.Thread.__init__(self) |
|
12 | 12 | Project.__init__(self, plotter_queue) |
|
13 | ||
|
13 | ||
|
14 | 14 | self.setDaemon(True) |
|
15 | ||
|
15 | ||
|
16 | 16 | self.lock = threading.Lock() |
|
17 | 17 | self.control = {'stop':False, 'pause':False} |
|
18 | ||
|
18 | ||
|
19 | 19 | def __del__(self): |
|
20 | ||
|
20 | ||
|
21 | 21 | self.control['stop'] = True |
|
22 | ||
|
22 | ||
|
23 | 23 | def stop(self): |
|
24 | ||
|
24 | ||
|
25 | 25 | self.lock.acquire() |
|
26 | ||
|
26 | ||
|
27 | 27 | self.control['stop'] = True |
|
28 | ||
|
28 | ||
|
29 | 29 | self.lock.release() |
|
30 | ||
|
30 | ||
|
31 | 31 | def pause(self): |
|
32 | ||
|
32 | ||
|
33 | 33 | self.lock.acquire() |
|
34 | ||
|
34 | ||
|
35 | 35 | self.control['pause'] = not(self.control['pause']) |
|
36 | 36 | paused = self.control['pause'] |
|
37 | ||
|
37 | ||
|
38 | 38 | self.lock.release() |
|
39 | ||
|
39 | ||
|
40 | 40 | return paused |
|
41 | ||
|
41 | ||
|
42 | 42 | def isPaused(self): |
|
43 | ||
|
43 | ||
|
44 | 44 | self.lock.acquire() |
|
45 | 45 | paused = self.control['pause'] |
|
46 | 46 | self.lock.release() |
|
47 | ||
|
47 | ||
|
48 | 48 | return paused |
|
49 | ||
|
49 | ||
|
50 | 50 | def isStopped(self): |
|
51 | ||
|
51 | ||
|
52 | 52 | self.lock.acquire() |
|
53 | 53 | stopped = self.control['stop'] |
|
54 | 54 | self.lock.release() |
|
55 | ||
|
55 | ||
|
56 | 56 | return stopped |
|
57 | ||
|
57 | ||
|
58 | 58 | def run(self): |
|
59 | 59 | self.control['stop'] = False |
|
60 | 60 | self.control['pause'] = False |
|
61 | ||
|
61 | ||
|
62 | 62 | self.writeXml() |
|
63 | ||
|
63 | ||
|
64 | 64 | self.createObjects() |
|
65 | 65 | self.connectObjects() |
|
66 | 66 | Project.run(self) |
|
67 | ||
|
67 | ||
|
68 | 68 | def isRunning(self): |
|
69 | ||
|
69 | ||
|
70 | 70 | return self.is_alive() |
|
71 | ||
|
71 | ||
|
72 | 72 | def isFinished(self): |
|
73 | ||
|
73 | ||
|
74 | 74 | return not self.is_alive() |
|
75 | 75 | |
|
76 | 76 | def setPlotters(self): |
|
77 | ||
|
77 | ||
|
78 | 78 | plotterList = PlotManager.plotterList |
|
79 | ||
|
79 | ||
|
80 | 80 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
81 | ||
|
81 | ||
|
82 | 82 | inputId = thisPUConfObj.getInputId() |
|
83 | ||
|
83 | ||
|
84 | 84 | if int(inputId) == 0: |
|
85 | 85 | continue |
|
86 | ||
|
86 | ||
|
87 | 87 | for thisOpObj in thisPUConfObj.getOperationObjList(): |
|
88 | ||
|
88 | ||
|
89 | 89 | if thisOpObj.type == "self": |
|
90 | 90 | continue |
|
91 | ||
|
91 | ||
|
92 | 92 | if thisOpObj.name in plotterList: |
|
93 | 93 | thisOpObj.type = "plotter" |
|
94 | 94 | |
|
95 | 95 | def setPlotterQueue(self, plotter_queue): |
|
96 | ||
|
96 | ||
|
97 | 97 | self.plotterQueue = plotter_queue |
|
98 | ||
|
98 | ||
|
99 | 99 | def getPlotterQueue(self): |
|
100 | ||
|
100 | ||
|
101 | 101 | return self.plotterQueue |
|
102 | 102 | |
|
103 | 103 | def useExternalPlotter(self): |
|
104 | ||
|
104 | ||
|
105 | 105 | self.plotterQueue = Queue(10) |
|
106 | 106 | self.setPlotters() |
|
107 | ||
|
107 | ||
|
108 | 108 | plotManagerObj = PlotManager(self.plotterQueue) |
|
109 | 109 | plotManagerObj.setController(self) |
|
110 | ||
|
110 | ||
|
111 | 111 | return plotManagerObj |
|
112 | ||
|
112 | ||
|
113 | 113 | # from PyQt4 import QtCore |
|
114 | 114 | # from PyQt4.QtCore import SIGNAL |
|
115 |
# |
|
|
115 | # | |
|
116 | 116 | # class ControllerQThread(QtCore.QThread, Project): |
|
117 | # | |
|
117 | # | |
|
118 | 118 | # def __init__(self, filename): |
|
119 | # | |
|
119 | # | |
|
120 | 120 | # QtCore.QThread.__init__(self) |
|
121 | 121 | # Project.__init__(self) |
|
122 | # | |
|
122 | # | |
|
123 | 123 | # self.filename = filename |
|
124 | # | |
|
124 | # | |
|
125 | 125 | # self.lock = threading.Lock() |
|
126 | 126 | # self.control = {'stop':False, 'pause':False} |
|
127 | # | |
|
127 | # | |
|
128 | 128 | # def __del__(self): |
|
129 | # | |
|
129 | # | |
|
130 | 130 | # self.control['stop'] = True |
|
131 | 131 | # self.wait() |
|
132 | # | |
|
132 | # | |
|
133 | 133 | # def stop(self): |
|
134 | # | |
|
134 | # | |
|
135 | 135 | # self.lock.acquire() |
|
136 | # | |
|
136 | # | |
|
137 | 137 | # self.control['stop'] = True |
|
138 | # | |
|
138 | # | |
|
139 | 139 | # self.lock.release() |
|
140 | # | |
|
140 | # | |
|
141 | 141 | # def pause(self): |
|
142 | # | |
|
142 | # | |
|
143 | 143 | # self.lock.acquire() |
|
144 | # | |
|
144 | # | |
|
145 | 145 | # self.control['pause'] = not(self.control['pause']) |
|
146 | 146 | # paused = self.control['pause'] |
|
147 | # | |
|
147 | # | |
|
148 | 148 | # self.lock.release() |
|
149 | # | |
|
149 | # | |
|
150 | 150 | # return paused |
|
151 | # | |
|
151 | # | |
|
152 | 152 | # def isPaused(self): |
|
153 | # | |
|
153 | # | |
|
154 | 154 | # self.lock.acquire() |
|
155 | 155 | # paused = self.control['pause'] |
|
156 | 156 | # self.lock.release() |
|
157 | # | |
|
157 | # | |
|
158 | 158 | # return paused |
|
159 | # | |
|
159 | # | |
|
160 | 160 | # def isStopped(self): |
|
161 | # | |
|
161 | # | |
|
162 | 162 | # self.lock.acquire() |
|
163 | 163 | # stopped = self.control['stop'] |
|
164 | 164 | # self.lock.release() |
|
165 | # | |
|
165 | # | |
|
166 | 166 | # return stopped |
|
167 | # | |
|
167 | # | |
|
168 | 168 | # def run(self): |
|
169 | # | |
|
169 | # | |
|
170 | 170 | # self.control['stop'] = False |
|
171 | 171 | # self.control['pause'] = False |
|
172 | # | |
|
172 | # | |
|
173 | 173 | # self.readXml(self.filename) |
|
174 | 174 | # self.createObjects() |
|
175 | 175 | # self.connectObjects() |
|
176 | 176 | # self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) |
|
177 | 177 | # Project.run(self) |
|
178 | 178 | # self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) |
|
179 | # No newline at end of file | |
|
179 | # |
@@ -114,10 +114,6 class GenericData(object): | |||
|
114 | 114 | |
|
115 | 115 | flagNoData = True |
|
116 | 116 | |
|
117 | def __init__(self): | |
|
118 | ||
|
119 | raise NotImplementedError | |
|
120 | ||
|
121 | 117 | def copy(self, inputObj=None): |
|
122 | 118 | |
|
123 | 119 | if inputObj == None: |
@@ -231,10 +227,6 class JROData(GenericData): | |||
|
231 | 227 | |
|
232 | 228 | profileIndex = None |
|
233 | 229 | |
|
234 | def __init__(self): | |
|
235 | ||
|
236 | raise NotImplementedError | |
|
237 | ||
|
238 | 230 | def getNoise(self): |
|
239 | 231 | |
|
240 | 232 | raise NotImplementedError |
@@ -1216,7 +1208,10 class Parameters(Spectra): | |||
|
1216 | 1208 | |
|
1217 | 1209 | def getTimeInterval(self): |
|
1218 | 1210 | |
|
1219 |
|
|
|
1211 | if hasattr(self, 'timeInterval1'): | |
|
1212 | return self.timeInterval1 | |
|
1213 | else: | |
|
1214 | return self.paramInterval | |
|
1220 | 1215 | |
|
1221 | 1216 | def getNoise(self): |
|
1222 | 1217 |
@@ -14,7 +14,7 from multiprocessing import Process | |||
|
14 | 14 | |
|
15 | 15 | from schainpy.model.proc.jroproc_base import Operation |
|
16 | 16 | |
|
17 |
plt.io |
|
|
17 | plt.ion() | |
|
18 | 18 | |
|
19 | 19 | func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) |
|
20 | 20 | |
@@ -58,6 +58,8 class PlotData(Operation, Process): | |||
|
58 | 58 | self.__MAXNUMY = kwargs.get('decimation', 80) |
|
59 | 59 | self.throttle_value = 5 |
|
60 | 60 | self.times = [] |
|
61 | #self.interactive = self.kwargs['parent'] | |
|
62 | ||
|
61 | 63 | |
|
62 | 64 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
63 | 65 | |
@@ -94,16 +96,22 class PlotData(Operation, Process): | |||
|
94 | 96 | print 'plotting...{}'.format(self.CODE) |
|
95 | 97 | |
|
96 | 98 | if self.show: |
|
97 | print 'showing' | |
|
98 | 99 | self.figure.show() |
|
99 | 100 | self.figure2.show() |
|
100 | 101 | |
|
101 | 102 | self.plot() |
|
102 | 103 | plt.tight_layout() |
|
103 | self.figure.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(), | |
|
104 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) | |
|
105 | self.figure2.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(), | |
|
106 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) | |
|
104 | ||
|
105 | # self.figure.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(), | |
|
106 | # datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) | |
|
107 | # self.figure2.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(), | |
|
108 | # datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S'))) | |
|
109 | # ======= | |
|
110 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), | |
|
111 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
|
112 | self.figure2.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), | |
|
113 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
|
114 | ||
|
107 | 115 | |
|
108 | 116 | if self.save: |
|
109 | 117 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, |
@@ -126,12 +134,19 class PlotData(Operation, Process): | |||
|
126 | 134 | def run(self): |
|
127 | 135 | |
|
128 | 136 | print '[Starting] {}'.format(self.name) |
|
137 | ||
|
129 | 138 | context = zmq.Context() |
|
130 | 139 | receiver = context.socket(zmq.SUB) |
|
131 | 140 | receiver.setsockopt(zmq.SUBSCRIBE, '') |
|
132 | 141 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) |
|
133 | receiver.connect("ipc:///tmp/zmq.plots") | |
|
142 | ||
|
143 | if 'server' in self.kwargs['parent']: | |
|
144 | receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) | |
|
145 | else: | |
|
146 | receiver.connect("ipc:///tmp/zmq.plots") | |
|
147 | ||
|
134 | 148 | seconds_passed = 0 |
|
149 | ||
|
135 | 150 | while True: |
|
136 | 151 | try: |
|
137 | 152 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK |
@@ -637,6 +652,7 class PlotNoiseData(PlotData): | |||
|
637 | 652 | |
|
638 | 653 | |
|
639 | 654 | class PlotWindProfilerData(PlotRTIData): |
|
655 | ||
|
640 | 656 | CODE = 'wind' |
|
641 | 657 | colormap = 'seismic' |
|
642 | 658 | |
@@ -646,7 +662,7 class PlotWindProfilerData(PlotRTIData): | |||
|
646 | 662 | self.width = 10 |
|
647 | 663 | self.height = 2.2*self.nrows |
|
648 | 664 | self.ylabel = 'Height [Km]' |
|
649 | self.titles = ['Zonal' ,'Meridional', 'Vertical'] | |
|
665 | self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind'] | |
|
650 | 666 | self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
651 | 667 | self.windFactor = [1, 1, 100] |
|
652 | 668 | |
@@ -670,13 +686,13 class PlotWindProfilerData(PlotRTIData): | |||
|
670 | 686 | self.z = [] |
|
671 | 687 | |
|
672 | 688 | for ch in range(self.nrows): |
|
673 |
self.z.append([self.data[ |
|
|
689 | self.z.append([self.data['output'][t][ch] for t in self.times]) | |
|
674 | 690 | |
|
675 | 691 | self.z = np.array(self.z) |
|
676 | 692 | self.z = numpy.ma.masked_invalid(self.z) |
|
677 | 693 | |
|
678 | 694 | cmap=plt.get_cmap(self.colormap) |
|
679 |
cmap.set_bad(' |
|
|
695 | cmap.set_bad('black', 1.) | |
|
680 | 696 | |
|
681 | 697 | for n, ax in enumerate(self.axes): |
|
682 | 698 | x, y, z = self.fill_gaps(*self.decimate()) |
@@ -695,9 +711,9 class PlotWindProfilerData(PlotRTIData): | |||
|
695 | 711 | ) |
|
696 | 712 | divider = make_axes_locatable(ax) |
|
697 | 713 | cax = divider.new_horizontal(size='2%', pad=0.05) |
|
698 | cax.set_ylabel(self.clabels[n]) | |
|
699 | 714 | self.figure.add_axes(cax) |
|
700 | plt.colorbar(plot, cax) | |
|
715 | cb = plt.colorbar(plot, cax) | |
|
716 | cb.set_label(self.clabels[n]) | |
|
701 | 717 | ax.set_ylim(self.ymin, self.ymax) |
|
702 | 718 | |
|
703 | 719 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
@@ -734,3 +750,62 class PlotDOPData(PlotRTIData): | |||
|
734 | 750 | class PlotPHASEData(PlotCOHData): |
|
735 | 751 | CODE = 'phase' |
|
736 | 752 | colormap = 'seismic' |
|
753 | ||
|
754 | ||
|
755 | class PlotSkyMapData(PlotData): | |
|
756 | ||
|
757 | CODE = 'met' | |
|
758 | ||
|
759 | def setup(self): | |
|
760 | ||
|
761 | self.ncols = 1 | |
|
762 | self.nrows = 1 | |
|
763 | self.width = 7.2 | |
|
764 | self.height = 7.2 | |
|
765 | ||
|
766 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
|
767 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
|
768 | ||
|
769 | if self.figure is None: | |
|
770 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
771 | edgecolor='k', | |
|
772 | facecolor='w') | |
|
773 | else: | |
|
774 | self.figure.clf() | |
|
775 | ||
|
776 | self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True) | |
|
777 | self.ax.firsttime = True | |
|
778 | ||
|
779 | ||
|
780 | def plot(self): | |
|
781 | ||
|
782 | arrayParameters = np.concatenate([self.data['param'][t] for t in self.times]) | |
|
783 | error = arrayParameters[:,-1] | |
|
784 | indValid = numpy.where(error == 0)[0] | |
|
785 | finalMeteor = arrayParameters[indValid,:] | |
|
786 | finalAzimuth = finalMeteor[:,3] | |
|
787 | finalZenith = finalMeteor[:,4] | |
|
788 | ||
|
789 | x = finalAzimuth*numpy.pi/180 | |
|
790 | y = finalZenith | |
|
791 | ||
|
792 | if self.ax.firsttime: | |
|
793 | self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] | |
|
794 | self.ax.set_ylim(0,90) | |
|
795 | self.ax.set_yticks(numpy.arange(0,90,20)) | |
|
796 | self.ax.set_xlabel(self.xlabel) | |
|
797 | self.ax.set_ylabel(self.ylabel) | |
|
798 | self.ax.yaxis.labelpad = 40 | |
|
799 | self.ax.firsttime = False | |
|
800 | else: | |
|
801 | self.ax.plot.set_data(x, y) | |
|
802 | ||
|
803 | ||
|
804 | dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') | |
|
805 | dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') | |
|
806 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
|
807 | dt2, | |
|
808 | len(x)) | |
|
809 | self.ax.set_title(title, size=8) | |
|
810 | ||
|
811 | self.saveTime = self.max_time |
@@ -204,7 +204,7 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, | |||
|
204 | 204 | |
|
205 | 205 | z = numpy.ma.masked_invalid(z) |
|
206 | 206 | cmap=matplotlib.pyplot.get_cmap(colormap) |
|
207 |
cmap.set_bad(' |
|
|
207 | cmap.set_bad('black', 1.) | |
|
208 | 208 | imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=cmap) |
|
209 | 209 | cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) |
|
210 | 210 | cb.set_label(cblabel) |
@@ -264,7 +264,7 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', col | |||
|
264 | 264 | z = numpy.ma.masked_invalid(z) |
|
265 | 265 | |
|
266 | 266 | cmap=matplotlib.pyplot.get_cmap(colormap) |
|
267 |
cmap.set_bad(' |
|
|
267 | cmap.set_bad('black', 1.) | |
|
268 | 268 | |
|
269 | 269 | |
|
270 | 270 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=cmap) |
@@ -9,6 +9,7 import glob | |||
|
9 | 9 | import time |
|
10 | 10 | import numpy |
|
11 | 11 | import fnmatch |
|
12 | import inspect | |
|
12 | 13 | import time, datetime |
|
13 | 14 | #import h5py |
|
14 | 15 | import traceback |
@@ -536,6 +537,9 class JRODataIO: | |||
|
536 | 537 | |
|
537 | 538 | return dtype_width |
|
538 | 539 | |
|
540 | def getAllowedArgs(self): | |
|
541 | return inspect.getargspec(self.run).args | |
|
542 | ||
|
539 | 543 | class JRODataReader(JRODataIO): |
|
540 | 544 | |
|
541 | 545 | |
@@ -1432,12 +1436,52 class JRODataReader(JRODataIO): | |||
|
1432 | 1436 | self.__printInfo = False |
|
1433 | 1437 | |
|
1434 | 1438 | |
|
1435 |
def run(self, |
|
|
1439 | def run(self, | |
|
1440 | path=None, | |
|
1441 | startDate=None, | |
|
1442 | endDate=None, | |
|
1443 | startTime=datetime.time(0,0,0), | |
|
1444 | endTime=datetime.time(23,59,59), | |
|
1445 | set=None, | |
|
1446 | expLabel = "", | |
|
1447 | ext = None, | |
|
1448 | online = False, | |
|
1449 | delay = 60, | |
|
1450 | walk = True, | |
|
1451 | getblock = False, | |
|
1452 | nTxs = 1, | |
|
1453 | realtime=False, | |
|
1454 | blocksize=None, | |
|
1455 | blocktime=None, | |
|
1456 | queue=None, | |
|
1457 | skip=None, | |
|
1458 | cursor=None, | |
|
1459 | warnings=True, | |
|
1460 | verbose=True, **kwargs): | |
|
1436 | 1461 | |
|
1437 | 1462 | if not(self.isConfig): |
|
1438 | ||
|
1439 | 1463 | # self.dataOut = dataOut |
|
1440 |
self.setup( |
|
|
1464 | self.setup( path=path, | |
|
1465 | startDate=startDate, | |
|
1466 | endDate=endDate, | |
|
1467 | startTime=startTime, | |
|
1468 | endTime=endTime, | |
|
1469 | set=set, | |
|
1470 | expLabel=expLabel, | |
|
1471 | ext=ext, | |
|
1472 | online=online, | |
|
1473 | delay=delay, | |
|
1474 | walk=walk, | |
|
1475 | getblock=getblock, | |
|
1476 | nTxs=nTxs, | |
|
1477 | realtime=realtime, | |
|
1478 | blocksize=blocksize, | |
|
1479 | blocktime=blocktime, | |
|
1480 | queue=queue, | |
|
1481 | skip=skip, | |
|
1482 | cursor=cursor, | |
|
1483 | warnings=warnings, | |
|
1484 | verbose=verbose) | |
|
1441 | 1485 | self.isConfig = True |
|
1442 | 1486 | |
|
1443 | 1487 | self.getData() |
@@ -1740,11 +1784,11 class JRODataWriter(JRODataIO): | |||
|
1740 | 1784 | |
|
1741 | 1785 | return 1 |
|
1742 | 1786 | |
|
1743 | def run(self, dataOut, **kwargs): | |
|
1787 | def run(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4, **kwargs): | |
|
1744 | 1788 | |
|
1745 | 1789 | if not(self.isConfig): |
|
1746 | 1790 | |
|
1747 | self.setup(dataOut, **kwargs) | |
|
1791 | self.setup(dataOut, path, blocksPerFile, profilesPerBlock=profilesPerBlock, set=set, ext=ext, datatype=datatype, **kwargs) | |
|
1748 | 1792 | self.isConfig = True |
|
1749 | 1793 | |
|
1750 | 1794 | self.putData() |
@@ -149,6 +149,7 class ProcessingUnit(object): | |||
|
149 | 149 | self.mp = True |
|
150 | 150 | self.start() |
|
151 | 151 | else: |
|
152 | self.operationKwargs[opId]['parent'] = self.kwargs | |
|
152 | 153 | methodToCall(**self.operationKwargs[opId]) |
|
153 | 154 | else: |
|
154 | 155 | if name=='run': |
@@ -187,6 +188,7 class ProcessingUnit(object): | |||
|
187 | 188 | |
|
188 | 189 | if hasattr(externalProcObj, 'mp'): |
|
189 | 190 | if externalProcObj.mp is False: |
|
191 | externalProcObj.kwargs['parent'] = self.kwargs | |
|
190 | 192 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
191 | 193 | externalProcObj.mp = True |
|
192 | 194 | externalProcObj.start() |
@@ -194,6 +196,7 class ProcessingUnit(object): | |||
|
194 | 196 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) |
|
195 | 197 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
196 | 198 | |
|
199 | ||
|
197 | 200 | return True |
|
198 | 201 | |
|
199 | 202 | def call(self, opType, opName=None, opId=None): |
@@ -1038,7 +1038,7 class WindProfiler(Operation): | |||
|
1038 | 1038 | |
|
1039 | 1039 | return data_output |
|
1040 | 1040 | |
|
1041 | def run(self, dataOut, technique, **kwargs): | |
|
1041 | def run(self, dataOut, technique, hmin=70, hmax=110, nHours=1, **kwargs): | |
|
1042 | 1042 | |
|
1043 | 1043 | param = dataOut.data_param |
|
1044 | 1044 | if dataOut.abscissaList != None: |
@@ -15,6 +15,7 from threading import Thread | |||
|
15 | 15 | from multiprocessing import Process |
|
16 | 16 | |
|
17 | 17 | from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit |
|
18 | from schainpy.model.data.jrodata import JROData | |
|
18 | 19 | |
|
19 | 20 | MAXNUMX = 100 |
|
20 | 21 | MAXNUMY = 100 |
@@ -257,7 +258,44 class PublishData(Operation): | |||
|
257 | 258 | self.client.loop_stop() |
|
258 | 259 | self.client.disconnect() |
|
259 | 260 | |
|
260 | class ReceiverData(ProcessingUnit, Process): | |
|
261 | ||
|
262 | class ReceiverData(ProcessingUnit): | |
|
263 | ||
|
264 | def __init__(self, **kwargs): | |
|
265 | ||
|
266 | ProcessingUnit.__init__(self, **kwargs) | |
|
267 | ||
|
268 | self.isConfig = False | |
|
269 | server = kwargs.get('server', 'zmq.pipe') | |
|
270 | if 'tcp://' in server: | |
|
271 | address = server | |
|
272 | else: | |
|
273 | address = 'ipc:///tmp/%s' % server | |
|
274 | ||
|
275 | self.address = address | |
|
276 | self.dataOut = JROData() | |
|
277 | ||
|
278 | def setup(self): | |
|
279 | ||
|
280 | self.context = zmq.Context() | |
|
281 | self.receiver = self.context.socket(zmq.PULL) | |
|
282 | self.receiver.bind(self.address) | |
|
283 | time.sleep(0.5) | |
|
284 | print '[Starting] ReceiverData from {}'.format(self.address) | |
|
285 | ||
|
286 | ||
|
287 | def run(self): | |
|
288 | ||
|
289 | if not self.isConfig: | |
|
290 | self.setup() | |
|
291 | self.isConfig = True | |
|
292 | ||
|
293 | self.dataOut = self.receiver.recv_pyobj() | |
|
294 | print '[Receiving] {} - {}'.format(self.dataOut.type, | |
|
295 | self.dataOut.datatime.ctime()) | |
|
296 | ||
|
297 | ||
|
298 | class PlotterReceiver(ProcessingUnit, Process): | |
|
261 | 299 | |
|
262 | 300 | throttle_value = 5 |
|
263 | 301 | |
@@ -268,7 +306,7 class ReceiverData(ProcessingUnit, Process): | |||
|
268 | 306 | self.mp = False |
|
269 | 307 | self.isConfig = False |
|
270 | 308 | self.isWebConfig = False |
|
271 | self.plottypes =[] | |
|
309 | self.plottypes = [] | |
|
272 | 310 | self.connections = 0 |
|
273 | 311 | server = kwargs.get('server', 'zmq.pipe') |
|
274 | 312 | plot_server = kwargs.get('plot_server', 'zmq.web') |
@@ -373,8 +411,10 class ReceiverData(ProcessingUnit, Process): | |||
|
373 | 411 | self.data[plottype][t] = self.dataOut.getCoherence() |
|
374 | 412 | if plottype == 'phase': |
|
375 | 413 | self.data[plottype][t] = self.dataOut.getCoherence(phase=True) |
|
376 |
if plottype == ' |
|
|
414 | if plottype == 'output': | |
|
377 | 415 | self.data[plottype][t] = self.dataOut.data_output |
|
416 | if plottype == 'param': | |
|
417 | self.data[plottype][t] = self.dataOut.data_param | |
|
378 | 418 | if self.realtime: |
|
379 | 419 | self.data_web['timestamp'] = t |
|
380 | 420 | if plottype == 'spc': |
@@ -402,8 +442,14 class ReceiverData(ProcessingUnit, Process): | |||
|
402 | 442 | self.sender_web = self.context.socket(zmq.PUB) |
|
403 | 443 | self.sender_web.connect(self.plot_address) |
|
404 | 444 | time.sleep(1) |
|
405 | self.sender.bind("ipc:///tmp/zmq.plots") | |
|
445 | ||
|
446 | if 'server' in self.kwargs: | |
|
447 | self.sender.bind("ipc:///tmp/{}.plots".format(self.kwargs['server'])) | |
|
448 | else: | |
|
449 | self.sender.bind("ipc:///tmp/zmq.plots") | |
|
450 | ||
|
406 | 451 | time.sleep(3) |
|
452 | ||
|
407 | 453 | t = Thread(target=self.event_monitor, args=(monitor,)) |
|
408 | 454 | t.start() |
|
409 | 455 | |
@@ -417,7 +463,6 class ReceiverData(ProcessingUnit, Process): | |||
|
417 | 463 | if self.dataOut.firstdata is True: |
|
418 | 464 | self.data['STARTED'] = True |
|
419 | 465 | |
|
420 | ||
|
421 | 466 | if self.dataOut.finished is True: |
|
422 | 467 | self.send(self.data) |
|
423 | 468 | self.connections -= 1 |
@@ -14,14 +14,16 if __name__ == '__main__': | |||
|
14 | 14 | controllerObj = Project() |
|
15 | 15 | controllerObj.setup(id='191', name='test01', description=desc) |
|
16 | 16 | |
|
17 |
proc1 = controllerObj.addProcUnit(name='Receiver |
|
|
17 | proc1 = controllerObj.addProcUnit(name='PlotterReceiver') | |
|
18 | 18 | # proc1.addParameter(name='realtime', value='0', format='bool') |
|
19 | 19 | #proc1.addParameter(name='plottypes', value='rti,coh,phase,snr,dop', format='str') |
|
20 | 20 | #proc1.addParameter(name='plottypes', value='rti,coh,phase,snr', format='str') |
|
21 | 21 | proc1.addParameter(name='plottypes', value='dop', format='str') |
|
22 | 22 | |
|
23 | proc1.addParameter(name='throttle', value='10', format='int') | |
|
24 | #proc1.addParameter(name='server', value='tcp://10.10.10.82:7000', format='str') | |
|
23 | #proc1.addParameter(name='throttle', value='10', format='int') | |
|
24 | ||
|
25 | proc1.addParameter(name='interactive', value='0', format='bool') # ? PREGUNTAR | |
|
26 | # proc1.addParameter(name='server', value='tcp://10.10.10.82:7000', format='str') | |
|
25 | 27 | ## TODO Agregar direccion de server de publicacion a graficos como variable |
|
26 | 28 | |
|
27 | 29 | """ |
@@ -1,1 +1,1 | |||
|
1 |
<Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1" /><Parameter format="date" id="191113" name="startDate" value="2016/04/2 |
|
|
1 | <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1" /><Parameter format="date" id="191113" name="startDate" value="2016/04/27" /><Parameter format="date" id="191114" name="endDate" value="2016/04/27" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="0" /><Parameter format="int" id="191119" name="skip" value="0" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="removeInterference" priority="2" type="self" /></ProcUnit></Project> No newline at end of file |
@@ -1,49 +1,57 | |||
|
1 | ''' | |
|
1 | """. | |
|
2 | ||
|
2 | 3 | Created on Jul 16, 2014 |
|
3 | 4 | |
|
4 | 5 | @author: Miguel Urco |
|
5 | ''' | |
|
6 | """ | |
|
6 | 7 | |
|
7 | 8 | from schainpy import __version__ |
|
8 | 9 | from setuptools import setup, Extension |
|
9 | 10 | |
|
10 | 11 | setup(name="schainpy", |
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 | scripts =['schainpy/gui/schainGUI', | |
|
36 | 'schainpy/scripts/schain'], | |
|
37 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
|
38 | install_requires=[ | |
|
39 | "scipy >= 0.14.0", | |
|
40 | "h5py >= 2.2.1", | |
|
41 | "matplotlib >= 1.4.2", | |
|
42 | "pyfits >= 3.4", | |
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
12 | version=__version__, | |
|
13 | description="Python tools to read, write and process Jicamarca data", | |
|
14 | author="Miguel Urco", | |
|
15 | author_email="miguel.urco@jro.igp.gob.pe", | |
|
16 | url="http://jro.igp.gob.pe", | |
|
17 | packages={'schainpy', | |
|
18 | 'schainpy.model', | |
|
19 | 'schainpy.model.data', | |
|
20 | 'schainpy.model.graphics', | |
|
21 | 'schainpy.model.io', | |
|
22 | 'schainpy.model.proc', | |
|
23 | 'schainpy.model.serializer', | |
|
24 | 'schainpy.model.utils', | |
|
25 | 'schainpy.gui', | |
|
26 | 'schainpy.gui.figures', | |
|
27 | 'schainpy.gui.viewcontroller', | |
|
28 | 'schainpy.gui.viewer', | |
|
29 | 'schainpy.gui.viewer.windows'}, | |
|
30 | ext_package='schainpy', | |
|
31 | py_modules=[''], | |
|
32 | package_data={'': ['schain.conf.template'], | |
|
33 | 'schainpy.gui.figures': ['*.png', '*.jpg'], | |
|
34 | }, | |
|
35 | include_package_data=False, | |
|
36 | entry_points={ | |
|
37 | 'console_scripts': [ | |
|
38 | 'schain = schaincli.cli:main', | |
|
39 | ], | |
|
40 | }, | |
|
41 | scripts=['schainpy/gui/schainGUI'], | |
|
42 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
|
43 | install_requires=[ | |
|
44 | "scipy >= 0.14.0", | |
|
45 | "h5py >= 2.2.1", | |
|
46 | "matplotlib >= 1.4.2", | |
|
47 | "pyfits >= 3.4", | |
|
48 | "numpy >= 1.11.2", | |
|
49 | "paramiko >= 2.1.2", | |
|
50 | "paho-mqtt >= 1.2", | |
|
51 | "zmq", | |
|
52 | "fuzzywuzzy", | |
|
53 | "click", | |
|
54 | "colorama", | |
|
55 | "python-Levenshtein" | |
|
56 | ], | |
|
49 | 57 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now