@@ -0,0 +1,68 | |||
|
1 | import os, sys | |
|
2 | ||
|
3 | path = os.path.split(os.getcwd())[0] | |
|
4 | path = os.path.split(path)[0] | |
|
5 | ||
|
6 | sys.path.insert(0, path) | |
|
7 | ||
|
8 | from schainpy.controller import Project | |
|
9 | ||
|
10 | controllerObj = Project() | |
|
11 | controllerObj.setup(id = '004', name='script04', description="JASMET Phase Calibration") | |
|
12 | ||
|
13 | #-------------------------------------- Setup ----------------------------------------- | |
|
14 | #Verificar estas variables | |
|
15 | ||
|
16 | #Path donde estan los archivos HDF5 de meteoros | |
|
17 | path = os.path.join(os.environ['HOME'],'Pictures/JASMET30_mp/201608/meteor') | |
|
18 | ||
|
19 | #Path para los graficos | |
|
20 | pathfig = os.path.join(os.environ['HOME'],'Pictures/JASMET30_mp/201608/graphics') | |
|
21 | ||
|
22 | #Path donde se almacenaran las fases calculadas | |
|
23 | pathfile = os.path.join(os.environ['HOME'],'Pictures/JASMET30_mp/201608/phase') | |
|
24 | ||
|
25 | #Fechas para busqueda de archivos | |
|
26 | startDate = '2016/08/29' | |
|
27 | endDate = '2016/09/11' | |
|
28 | #Horas para busqueda de archivos | |
|
29 | startTime = '00:00:00' | |
|
30 | endTime = '23:59:59' | |
|
31 | ||
|
32 | #------------------------------------------------------------------------------------------------ | |
|
33 | readUnitConfObj = controllerObj.addReadUnit(datatype='ParamReader', | |
|
34 | path=path, | |
|
35 | startDate=startDate, | |
|
36 | endDate=endDate, | |
|
37 | startTime=startTime, | |
|
38 | endTime=endTime, | |
|
39 | walk=1) | |
|
40 | ||
|
41 | #-------------------------------------------------------------------------------------------------- | |
|
42 | ||
|
43 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId()) | |
|
44 | # # | |
|
45 | opObj31 = procUnitConfObj1.addOperation(name='SMPhaseCalibration', optype='other') | |
|
46 | opObj31.addParameter(name='nHours', value='1', format='float') | |
|
47 | opObj31.addParameter(name='hmin', value='60', format='float') | |
|
48 | opObj31.addParameter(name='hmax', value='120', format='float') | |
|
49 | # opObj31.addParameter(name='channelPositions', value='(2.5,0),(0,2.5),(0,0),(0,4.5),(-2,0)', format='pairslist') | |
|
50 | ||
|
51 | opObj32 = procUnitConfObj1.addOperation(name='PhasePlot', optype='other') | |
|
52 | opObj32.addParameter(name='id', value='201', format='int') | |
|
53 | opObj32.addParameter(name='wintitle', value='PhaseCalibration', format='str') | |
|
54 | opObj32.addParameter(name='save', value='1', format='bool') | |
|
55 | opObj32.addParameter(name='xmin', value='0', format='float') | |
|
56 | opObj32.addParameter(name='xmax', value='24', format='float') | |
|
57 | opObj32.addParameter(name='ymin', value='-180', format='float') | |
|
58 | opObj32.addParameter(name='ymax', value='180', format='float') | |
|
59 | opObj32.addParameter(name='figpath', value=pathfig, format='str') | |
|
60 | # # | |
|
61 | opObj33 = procUnitConfObj1.addOperation(name='ParamWriter', optype='other') | |
|
62 | opObj33.addParameter(name='path', value=pathfile) | |
|
63 | opObj33.addParameter(name='blocksPerFile', value='1000', format='int') | |
|
64 | opObj33.addParameter(name='metadataList',value='type,outputInterval,timeZone',format='list') | |
|
65 | opObj33.addParameter(name='dataList',value='data_output,utctime',format='list') | |
|
66 | # # opObj25.addParameter(name='mode',value='1,0,0',format='intlist') | |
|
67 | ||
|
68 | controllerObj.start() No newline at end of file |
@@ -0,0 +1,85 | |||
|
1 | import os, sys | |
|
2 | ||
|
3 | path = os.path.split(os.getcwd())[0] | |
|
4 | path = os.path.split(path)[0] | |
|
5 | ||
|
6 | sys.path.insert(0, path) | |
|
7 | ||
|
8 | from schainpy.controller import Project | |
|
9 | ||
|
10 | controllerObj = Project() | |
|
11 | controllerObj.setup(id = '005', name='script05', description="JASMET Wind Estimation") | |
|
12 | ||
|
13 | #-------------------------------------- Setup ----------------------------------------- | |
|
14 | #Verificar estas variables | |
|
15 | ||
|
16 | #Path donde estan los archivos HDF5 de meteoros | |
|
17 | path = os.path.join(os.environ['HOME'],'Pictures/JASMET30_mp/201608/meteor') | |
|
18 | ||
|
19 | #Path para los graficos | |
|
20 | pathfig = os.path.join(os.environ['HOME'],'Pictures/JASMET30_mp/201608/graphics') | |
|
21 | ||
|
22 | #Path donde se almacenaran las estimaciones de vientos | |
|
23 | pathfile = os.path.join(os.environ['HOME'],'Pictures/JASMET30_mp/201608/phase') | |
|
24 | ||
|
25 | #Fechas para busqueda de archivos | |
|
26 | startDate = '2016/08/29' | |
|
27 | endDate = '2016/09/11' | |
|
28 | #Horas para busqueda de archivos | |
|
29 | startTime = '00:00:00' | |
|
30 | endTime = '23:59:59' | |
|
31 | ||
|
32 | #Offsets optimos obtenidos con OptimumOffset.py | |
|
33 | phaseOffsets = '-2.84, -1.77, 11.94, 9.71' | |
|
34 | phaseOffsets = '-5.86, -0.93, -7.29, 23.35' | |
|
35 | #------------------------------------------------------------------------------------------------ | |
|
36 | readUnitConfObj = controllerObj.addReadUnit(datatype='ParamReader', | |
|
37 | path=path, | |
|
38 | startDate=startDate, | |
|
39 | endDate=endDate, | |
|
40 | startTime=startTime, | |
|
41 | endTime=endTime, | |
|
42 | walk=1) | |
|
43 | #-------------------------------------------------------------------------------------------------- | |
|
44 | ||
|
45 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId()) | |
|
46 | opObj10 = procUnitConfObj1.addOperation(name='CorrectSMPhases',optype='other') | |
|
47 | opObj10.addParameter(name='phaseOffsets', value=phaseOffsets, format='floatlist') | |
|
48 | ||
|
49 | opObj13 = procUnitConfObj1.addOperation(name='SkyMapPlot', optype='other') | |
|
50 | opObj13.addParameter(name='id', value='1', format='int') | |
|
51 | opObj13.addParameter(name='wintitle', value='Sky Map', format='str') | |
|
52 | opObj13.addParameter(name='save', value='1', format='bool') | |
|
53 | opObj13.addParameter(name='figpath', value=pathfig, format='str') | |
|
54 | opObj13.addParameter(name='ftp', value='1', format='int') | |
|
55 | opObj13.addParameter(name='exp_code', value='15', format='int') | |
|
56 | opObj13.addParameter(name='sub_exp_code', value='1', format='int') | |
|
57 | opObj13.addParameter(name='tmin', value='0', format='int') | |
|
58 | opObj13.addParameter(name='tmax', value='24', format='int') | |
|
59 | ||
|
60 | opObj22 = procUnitConfObj1.addOperation(name='WindProfiler', optype='other') | |
|
61 | opObj22.addParameter(name='technique', value='Meteors', format='str') | |
|
62 | opObj22.addParameter(name='nHours', value='1', format='float') | |
|
63 | opObj22.addParameter(name='hmin', value='70', format='float') | |
|
64 | opObj22.addParameter(name='hmax', value='120', format='float') | |
|
65 | ||
|
66 | opObj23 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other') | |
|
67 | opObj23.addParameter(name='id', value='2', format='int') | |
|
68 | opObj23.addParameter(name='wintitle', value='Wind Profiler', format='str') | |
|
69 | opObj23.addParameter(name='save', value='1', format='bool') | |
|
70 | opObj23.addParameter(name='figpath', value = pathfig, format='str') | |
|
71 | opObj23.addParameter(name='zmin', value='-140', format='int') | |
|
72 | opObj23.addParameter(name='zmax', value='140', format='int') | |
|
73 | opObj23.addParameter(name='xmin', value='0', format='float') | |
|
74 | opObj23.addParameter(name='xmax', value='24', format='float') | |
|
75 | opObj23.addParameter(name='ymin', value='70', format='float') | |
|
76 | opObj23.addParameter(name='ymax', value='110', format='float') | |
|
77 | ||
|
78 | opObj33 = procUnitConfObj1.addOperation(name='ParamWriter', optype='other') | |
|
79 | opObj33.addParameter(name='path', value=pathfile) | |
|
80 | opObj33.addParameter(name='blocksPerFile', value='1000', format='int') | |
|
81 | opObj33.addParameter(name='metadataList',value='type,outputInterval,timeZone',format='list') | |
|
82 | opObj33.addParameter(name='dataList',value='data_output,utctime',format='list') | |
|
83 | #-------------------------------------------------------------------------------------------------- | |
|
84 | ||
|
85 | controllerObj.start() No newline at end of file |
@@ -0,0 +1,117 | |||
|
1 | import h5py | |
|
2 | import numpy | |
|
3 | import matplotlib.pyplot as plt | |
|
4 | import glob | |
|
5 | import os | |
|
6 | ||
|
7 | #---------------------- Functions --------------------- | |
|
8 | ||
|
9 | def findFiles(path): | |
|
10 | ||
|
11 | dirList = [] | |
|
12 | fileList = [] | |
|
13 | ||
|
14 | for thisPath in os.listdir(path): | |
|
15 | dirList.append(os.path.join(path,thisPath)) | |
|
16 | dirList.sort() | |
|
17 | ||
|
18 | for thisDirectory in dirList: | |
|
19 | files = glob.glob1(thisDirectory, "*.hdf5") | |
|
20 | files.sort() | |
|
21 | for thisFile in files: | |
|
22 | fileList.append(os.path.join(thisDirectory,thisFile)) | |
|
23 | ||
|
24 | return fileList | |
|
25 | ||
|
26 | def readFiles(fileList): | |
|
27 | ||
|
28 | meteors_array = numpy.zeros((1,4)) | |
|
29 | ||
|
30 | for thisFile in fileList: | |
|
31 | ||
|
32 | #Leer | |
|
33 | f1 = h5py.File(thisFile,'r') | |
|
34 | grp1 = f1['Data'] | |
|
35 | grp2 = grp1['data_output'] | |
|
36 | meteors1 = grp2['table0'][:] | |
|
37 | meteors_array = numpy.vstack((meteors_array,meteors1)) | |
|
38 | #cerrar | |
|
39 | f1.close() | |
|
40 | ||
|
41 | meteors_array = numpy.delete(meteors_array, 0, axis=0) | |
|
42 | meteors_list = [meteors_array[:,0],meteors_array[:,1],meteors_array[:,2],meteors_array[:,3]] | |
|
43 | return meteors_list | |
|
44 | ||
|
45 | def estimateMean(offset_list): | |
|
46 | ||
|
47 | mean_off = [] | |
|
48 | axisY_off = [] | |
|
49 | axisX_off = [] | |
|
50 | ||
|
51 | for thisOffset in offset_list: | |
|
52 | mean_aux = numpy.mean(thisOffset, axis = 0) | |
|
53 | mean_off.append(mean_aux) | |
|
54 | axisX_off.append(numpy.array([0,numpy.size(thisOffset)])) | |
|
55 | axisY_off.append(numpy.array([mean_aux,mean_aux])) | |
|
56 | ||
|
57 | return mean_off, axisY_off, axisX_off | |
|
58 | ||
|
59 | def plotPhases(offset0, axisY0, axisX0, title): | |
|
60 | f, axarr = plt.subplots(4, sharey=True) | |
|
61 | color = ['b','g','r','c'] | |
|
62 | # plt.grid() | |
|
63 | for i in range(len(offset0)): | |
|
64 | thisMeteor = offset0[i] | |
|
65 | thisY = axisY0[i] | |
|
66 | thisX = axisX0[i] | |
|
67 | thisColor = color[i] | |
|
68 | ||
|
69 | opt = thisColor + 'o' | |
|
70 | axarr[i].plot(thisMeteor,opt) | |
|
71 | axarr[i].plot(thisX, thisY, thisColor) | |
|
72 | axarr[i].set_ylabel('Offset ' + str(i)) | |
|
73 | ||
|
74 | plt.ylim((-180,180)) | |
|
75 | axarr[0].set_title(title + ' Offsets') | |
|
76 | axarr[3].set_xlabel('Number of estimations') | |
|
77 | ||
|
78 | return | |
|
79 | ||
|
80 | def filterOffsets(offsets0, stdvLimit): | |
|
81 | offsets1 = [] | |
|
82 | ||
|
83 | for thisOffset in offsets0: | |
|
84 | pstd = numpy.std(thisOffset)*stdvLimit | |
|
85 | pmean = numpy.mean(thisOffset) | |
|
86 | outlier1 = thisOffset > pmean - pstd | |
|
87 | outlier2 = thisOffset < pmean + pstd | |
|
88 | not_outlier = numpy.logical_and(outlier1,outlier2) | |
|
89 | thisOffset1 = thisOffset[not_outlier] | |
|
90 | offsets1.append(thisOffset1) | |
|
91 | ||
|
92 | return offsets1 | |
|
93 | ||
|
94 | #---------------------- Setup --------------------------- | |
|
95 | ||
|
96 | <<<<<<< HEAD | |
|
97 | path = '/home/nanosat/Pictures/JASMET30_mp/201608/phase' | |
|
98 | ======= | |
|
99 | path = '/home/jespinoza/Pictures/JASMET30/201608/phase' | |
|
100 | >>>>>>> master | |
|
101 | stdvLimit = 0.5 | |
|
102 | ||
|
103 | #---------------------- Script --------------------------- | |
|
104 | ||
|
105 | fileList = findFiles(path) | |
|
106 | offsets0 = readFiles(fileList) | |
|
107 | mean0, axisY0, axisX0 = estimateMean(offsets0) | |
|
108 | plotPhases(offsets0, axisY0, axisX0, 'Original') | |
|
109 | ||
|
110 | offsets1 = filterOffsets(offsets0, stdvLimit) | |
|
111 | mean1, axisY1, axisX1 = estimateMean(offsets1) | |
|
112 | plotPhases(offsets1, axisY1, axisX1, 'Filtered') | |
|
113 | ||
|
114 | print "Original Offsets: %.2f, %.2f, %.2f, %.2f" % (mean0[0],mean0[1],mean0[2],mean0[3]) | |
|
115 | print "Filtered Offsets: %.2f, %.2f, %.2f, %.2f" % (mean1[0],mean1[1],mean1[2],mean1[3]) | |
|
116 | ||
|
117 | plt.show() |
@@ -0,0 +1,6 | |||
|
1 | [Desktop Entry] | |
|
2 | Encoding=UTF-8 | |
|
3 | Name=Link to | |
|
4 | Type=Link | |
|
5 | URL=file:///home/nanosat/schain/schainpy/utils/parameters.txt | |
|
6 | Icon=text-plain |
@@ -0,0 +1,81 | |||
|
1 | import schainpy | |
|
2 | from schainpy.model import Operation, ProcessingUnit | |
|
3 | from importlib import import_module | |
|
4 | from pydoc import locate | |
|
5 | ||
|
6 | def clean_modules(module): | |
|
7 | noEndsUnder = [x for x in module if not x.endswith('__')] | |
|
8 | noStartUnder = [x for x in noEndsUnder if not x.startswith('__')] | |
|
9 | noFullUpper = [x for x in noStartUnder if not x.isupper()] | |
|
10 | return noFullUpper | |
|
11 | ||
|
12 | def check_module(possible, instance): | |
|
13 | def check(x): | |
|
14 | try: | |
|
15 | instancia = locate('schainpy.model.{}'.format(x)) | |
|
16 | return isinstance(instancia(), instance) | |
|
17 | except Exception as e: | |
|
18 | return False | |
|
19 | clean = clean_modules(possible) | |
|
20 | return [x for x in clean if check(x)] | |
|
21 | ||
|
22 | ||
|
23 | def getProcs(): | |
|
24 | module = dir(import_module('schainpy.model')) | |
|
25 | procs = check_module(module, ProcessingUnit) | |
|
26 | try: | |
|
27 | procs.remove('ProcessingUnit') | |
|
28 | except Exception as e: | |
|
29 | pass | |
|
30 | return procs | |
|
31 | ||
|
32 | def getOperations(): | |
|
33 | module = dir(import_module('schainpy.model')) | |
|
34 | noProcs = [x for x in module if not x.endswith('Proc')] | |
|
35 | operations = check_module(noProcs, Operation) | |
|
36 | try: | |
|
37 | operations.remove('Operation') | |
|
38 | except Exception as e: | |
|
39 | pass | |
|
40 | return operations | |
|
41 | ||
|
42 | def getArgs(op): | |
|
43 | module = locate('schainpy.model.{}'.format(op)) | |
|
44 | args = module().getAllowedArgs() | |
|
45 | try: | |
|
46 | args.remove('self') | |
|
47 | except Exception as e: | |
|
48 | pass | |
|
49 | try: | |
|
50 | args.remove('dataOut') | |
|
51 | except Exception as e: | |
|
52 | pass | |
|
53 | return args | |
|
54 | ||
|
55 | def getAll(): | |
|
56 | allModules = dir(import_module('schainpy.model')) | |
|
57 | modules = check_module(allModules, Operation) | |
|
58 | modules.extend(check_module(allModules, ProcessingUnit)) | |
|
59 | return modules | |
|
60 | ||
|
61 | def formatArgs(op): | |
|
62 | args = getArgs(op) | |
|
63 | ||
|
64 | argsAsKey = ["\t'{}'".format(x) for x in args] | |
|
65 | argsFormatted = ": 'string',\n".join(argsAsKey) | |
|
66 | ||
|
67 | print op | |
|
68 | print "parameters = { \n" + argsFormatted + ": 'string',\n }" | |
|
69 | print '\n' | |
|
70 | ||
|
71 | ||
|
72 | if __name__ == "__main__": | |
|
73 | getAll() | |
|
74 | [formatArgs(x) for x in getAll()] | |
|
75 | ||
|
76 | ''' | |
|
77 | parameters = { | |
|
78 | 'id': , | |
|
79 | 'wintitle': , | |
|
80 | } | |
|
81 | ''' No newline at end of file |
@@ -101,6 +101,9 ENV/ | |||
|
101 | 101 | .project |
|
102 | 102 | .pydevproject |
|
103 | 103 | <<<<<<< HEAD |
|
104 | <<<<<<< HEAD | |
|
105 | ======= | |
|
106 | >>>>>>> v2.3 | |
|
104 | 107 | |
|
105 | 108 | # vscode |
|
106 | 109 | |
@@ -108,6 +111,7 ENV/ | |||
|
108 | 111 | |
|
109 | 112 | schaingui/node_modules/ |
|
110 | 113 | schainpy/scripts/ |
|
114 | <<<<<<< HEAD | |
|
111 | 115 | ======= |
|
112 | 116 | .svn/ |
|
113 | 117 | *.png |
@@ -117,3 +121,12 schainpy/scripts | |||
|
117 | 121 | schaingui/node_modules |
|
118 | 122 | trash |
|
119 | 123 | >>>>>>> master |
|
124 | ======= | |
|
125 | schaingui/node_modules/ | |
|
126 | .svn/ | |
|
127 | *.png | |
|
128 | *.pyc | |
|
129 | *.xml | |
|
130 | *.log | |
|
131 | trash | |
|
132 | >>>>>>> v2.3 |
@@ -8,12 +8,13 save_stdout = sys.stdout | |||
|
8 | 8 | sys.stdout = open('trash', 'w') |
|
9 | 9 | from multiprocessing import cpu_count |
|
10 | 10 | from schaincli import templates |
|
11 |
from schainpy import |
|
|
11 | from schainpy.controller import Project | |
|
12 | 12 | from schainpy.model import Operation, ProcessingUnit |
|
13 | 13 | from schainpy.utils import log |
|
14 | 14 | from importlib import import_module |
|
15 | 15 | from pydoc import locate |
|
16 | 16 | from fuzzywuzzy import process |
|
17 | from schainpy.utils import paramsFinder | |
|
17 | 18 | sys.stdout = save_stdout |
|
18 | 19 | |
|
19 | 20 | |
@@ -75,47 +76,25 def search(nextcommand): | |||
|
75 | 76 | if nextcommand is None: |
|
76 | 77 | log.error('There is no Operation/ProcessingUnit to search') |
|
77 | 78 | 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 | |
|
79 | procs = paramsFinder.getProcs() | |
|
84 | 80 | log.success('Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs))) |
|
85 | 81 | |
|
86 | 82 | 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 | |
|
83 | operations = paramsFinder.getOperations() | |
|
94 | 84 | log.success('Current Operations are:\n\033[1m{}\033[0m'.format('\n'.join(operations))) |
|
95 | 85 | else: |
|
96 | 86 | try: |
|
97 |
|
|
|
98 | args = module().getAllowedArgs() | |
|
87 | args = paramsFinder.getArgs(nextcommand) | |
|
99 | 88 | 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 | 89 | if len(args) == 0: |
|
109 | 90 | log.success('{} has no arguments'.format(nextcommand)) |
|
110 | 91 | else: |
|
111 | 92 | log.success('Showing arguments of {} are:\n\033[1m{}\033[0m'.format(nextcommand, '\n'.join(args))) |
|
112 | 93 | except Exception as e: |
|
113 | 94 | log.error('Module {} does not exists'.format(nextcommand)) |
|
114 |
allModules = |
|
|
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)) | |
|
95 | allModules = paramsFinder.getAll() | |
|
96 | similar = process.extractOne(nextcommand, allModules)[0] | |
|
97 | log.success('Showing {} instead'.format(similar)) | |
|
119 | 98 | search(similar) |
|
120 | 99 | |
|
121 | 100 | |
@@ -171,18 +150,8 def test(): | |||
|
171 | 150 | |
|
172 | 151 | |
|
173 | 152 | def runFromXML(filename): |
|
174 |
controller = |
|
|
153 | controller = Project() | |
|
175 | 154 | if not controller.readXml(filename): |
|
176 | 155 | return |
|
177 | ||
|
178 | plotterObj = controller.useExternalPlotter() | |
|
179 | ||
|
180 | 156 | controller.start() |
|
181 | plotterObj.start() | |
|
182 | ||
|
183 | cliLogger("Finishing all processes") | |
|
184 | ||
|
185 | controller.join(5) | |
|
186 | ||
|
187 | cliLogger("End of script") | |
|
188 | 157 | return |
@@ -5,16 +5,17 | |||
|
5 | 5 | * Added two new Processing Units `PublishData` and `ReceiverData` for receiving and sending dataOut through multiple ways (tcp, ipc, inproc). |
|
6 | 6 | * Added a new graphics Processing Unit `PlotterReceiver`. It is decoupled from normal processing sequence with support for data generated by multiprocessing scripts. |
|
7 | 7 | * Added support for sending realtime graphic to web server. |
|
8 |
* |
|
|
8 | * GUI command `schain` is now `schainGUI`. | |
|
9 | 9 | * Added a CLI tool named `schain`. |
|
10 | 10 | * Scripts templates can be now generated with `schain generate`. |
|
11 | 11 | * Now it is possible to search Processing Units and Operations with `schain search [module]` to get the right name and its allowed parameters. |
|
12 | * `schain xml` to run xml scripts. | |
|
12 | 13 | * Added suggestions when parameters are poorly written. |
|
13 | 14 | * `Controller.start()` now runs in a different process than the process calling it. |
|
14 | 15 | * Added `schainpy.utils.log` for log standarization. |
|
15 | 16 | * Running script on online mode no longer ignores date and hour. Issue #1109. |
|
16 | 17 | * Added support for receving voltage data directly from JARS (tcp, ipc). |
|
17 |
* Updated README for |
|
|
18 | * Updated README for MAC OS GUI installation. | |
|
18 | 19 | * Setup now installs numpy. |
|
19 | 20 | |
|
20 | 21 | ### 2.2.6 |
@@ -4,5 +4,4 Created on Feb 7, 2012 | |||
|
4 | 4 | @author $Author$ |
|
5 | 5 | @version $Id$ |
|
6 | 6 | ''' |
|
7 | ||
|
8 | 7 | __version__ = "2.3" |
@@ -9,6 +9,7 import datetime | |||
|
9 | 9 | import traceback |
|
10 | 10 | import schainpy |
|
11 | 11 | import schainpy.admin |
|
12 | from schainpy.utils.log import logToFile | |
|
12 | 13 | |
|
13 | 14 | from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring |
|
14 | 15 | from xml.dom import minidom |
@@ -16,6 +17,8 from xml.dom import minidom | |||
|
16 | 17 | from schainpy.model import * |
|
17 | 18 | from time import sleep |
|
18 | 19 | |
|
20 | ||
|
21 | ||
|
19 | 22 | def prettify(elem): |
|
20 | 23 | """Return a pretty-printed XML string for the Element. |
|
21 | 24 | """ |
@@ -23,6 +26,52 def prettify(elem): | |||
|
23 | 26 | reparsed = minidom.parseString(rough_string) |
|
24 | 27 | return reparsed.toprettyxml(indent=" ") |
|
25 | 28 | |
|
29 | def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False): | |
|
30 | skip = 0 | |
|
31 | cursor = 0 | |
|
32 | nFiles = None | |
|
33 | processes = [] | |
|
34 | dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d') | |
|
35 | dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d') | |
|
36 | days = (dt2 - dt1).days | |
|
37 | ||
|
38 | for day in range(days+1): | |
|
39 | skip = 0 | |
|
40 | cursor = 0 | |
|
41 | q = Queue() | |
|
42 | processes = [] | |
|
43 | dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d') | |
|
44 | firstProcess = Process(target=child, args=(cursor, skip, q, dt)) | |
|
45 | firstProcess.start() | |
|
46 | if by_day: | |
|
47 | continue | |
|
48 | nFiles = q.get() | |
|
49 | if nFiles==0: | |
|
50 | continue | |
|
51 | firstProcess.terminate() | |
|
52 | skip = int(math.ceil(nFiles/nProcess)) | |
|
53 | while True: | |
|
54 | processes.append(Process(target=child, args=(cursor, skip, q, dt))) | |
|
55 | processes[cursor].start() | |
|
56 | if nFiles < cursor*skip: | |
|
57 | break | |
|
58 | cursor += 1 | |
|
59 | ||
|
60 | def beforeExit(exctype, value, trace): | |
|
61 | for process in processes: | |
|
62 | process.terminate() | |
|
63 | process.join() | |
|
64 | print traceback.print_tb(trace) | |
|
65 | ||
|
66 | sys.excepthook = beforeExit | |
|
67 | ||
|
68 | for process in processes: | |
|
69 | process.join() | |
|
70 | process.terminate() | |
|
71 | ||
|
72 | time.sleep(3) | |
|
73 | ||
|
74 | ||
|
26 | 75 | class ParameterConf(): |
|
27 | 76 | |
|
28 | 77 | id = None |
@@ -623,8 +672,7 class ProcUnitConf(): | |||
|
623 | 672 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
624 | 673 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
625 | 674 | opName = opConfObj.name, |
|
626 |
opId = opConfObj.id |
|
|
627 | **kwargs) | |
|
675 | opId = opConfObj.id) | |
|
628 | 676 | |
|
629 | 677 | # total_time = time.time() - ini |
|
630 | 678 | # |
@@ -674,8 +722,8 class ReadUnitConf(ProcUnitConf): | |||
|
674 | 722 | |
|
675 | 723 | return self.ELEMENTNAME |
|
676 | 724 | |
|
677 |
def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", |
|
|
678 | ||
|
725 | def setup(self, id, name, datatype, path='', startDate="", endDate="", startTime="", | |
|
726 | endTime="", parentId=None, queue=None, server=None, **kwargs): | |
|
679 | 727 | #Compatible with old signal chain version |
|
680 | 728 | if datatype==None and name==None: |
|
681 | 729 | raise ValueError, "datatype or name should be defined" |
@@ -812,8 +860,7 class ReadUnitConf(ProcUnitConf): | |||
|
812 | 860 | self.startTime = opConfObj.getParameterValue('startTime') |
|
813 | 861 | self.endTime = opConfObj.getParameterValue('endTime') |
|
814 | 862 | |
|
815 | class Project(): | |
|
816 | ||
|
863 | class Project(Process): | |
|
817 | 864 | id = None |
|
818 | 865 | name = None |
|
819 | 866 | description = None |
@@ -825,12 +872,13 class Project(): | |||
|
825 | 872 | |
|
826 | 873 | plotterQueue = None |
|
827 | 874 | |
|
828 | def __init__(self, plotter_queue=None): | |
|
829 | ||
|
875 | def __init__(self, plotter_queue=None, logfile=None): | |
|
876 | Process.__init__(self) | |
|
830 | 877 | self.id = None |
|
831 | 878 | self.name = None |
|
832 | 879 | self.description = None |
|
833 | ||
|
880 | if logfile is not None: | |
|
881 | logToFile(logfile) | |
|
834 | 882 | self.plotterQueue = plotter_queue |
|
835 | 883 | |
|
836 | 884 | self.procUnitConfObjDict = {} |
@@ -892,7 +940,6 class Project(): | |||
|
892 | 940 | self.description = description |
|
893 | 941 | |
|
894 | 942 | def addReadUnit(self, id=None, datatype=None, name=None, **kwargs): |
|
895 | ||
|
896 | 943 | if id is None: |
|
897 | 944 | idReadUnit = self.__getNewId() |
|
898 | 945 | else: |
@@ -1177,7 +1224,12 class Project(): | |||
|
1177 | 1224 | |
|
1178 | 1225 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" |
|
1179 | 1226 | |
|
1180 | def run(self): | |
|
1227 | ||
|
1228 | def run(self, filename=None): | |
|
1229 | ||
|
1230 | # self.writeXml(filename) | |
|
1231 | self.createObjects() | |
|
1232 | self.connectObjects() | |
|
1181 | 1233 | |
|
1182 | 1234 | |
|
1183 | 1235 | print "*"*60 |
@@ -1226,69 +1278,3 class Project(): | |||
|
1226 | 1278 | for procKey in keyList: |
|
1227 | 1279 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1228 | 1280 | procUnitConfObj.close() |
|
1229 | ||
|
1230 | print "Process finished" | |
|
1231 | ||
|
1232 | def start(self): | |
|
1233 | ||
|
1234 | self.writeXml() | |
|
1235 | ||
|
1236 | self.createObjects() | |
|
1237 | self.connectObjects() | |
|
1238 | self.run() | |
|
1239 | ||
|
1240 | if __name__ == '__main__': | |
|
1241 | ||
|
1242 | desc = "Segundo Test" | |
|
1243 | filename = "schain.xml" | |
|
1244 | ||
|
1245 | controllerObj = Project() | |
|
1246 | ||
|
1247 | controllerObj.setup(id = '191', name='test01', description=desc) | |
|
1248 | ||
|
1249 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
|
1250 | path='data/rawdata/', | |
|
1251 | startDate='2011/01/01', | |
|
1252 | endDate='2012/12/31', | |
|
1253 | startTime='00:00:00', | |
|
1254 | endTime='23:59:59', | |
|
1255 | online=1, | |
|
1256 | walk=1) | |
|
1257 | ||
|
1258 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
|
1259 | ||
|
1260 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
|
1261 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
|
1262 | ||
|
1263 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
|
1264 | opObj10.addParameter(name='minHei', value='90', format='float') | |
|
1265 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
|
1266 | ||
|
1267 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
|
1268 | opObj12.addParameter(name='n', value='10', format='int') | |
|
1269 | ||
|
1270 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
|
1271 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
|
1272 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') | |
|
1273 | ||
|
1274 | ||
|
1275 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
|
1276 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
|
1277 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
|
1278 | opObj11.addParameter(name='zmin', value='40', format='int') | |
|
1279 | opObj11.addParameter(name='zmax', value='90', format='int') | |
|
1280 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
|
1281 | ||
|
1282 | print "Escribiendo el archivo XML" | |
|
1283 | ||
|
1284 | controllerObj.writeXml(filename) | |
|
1285 | ||
|
1286 | print "Leyendo el archivo XML" | |
|
1287 | controllerObj.readXml(filename) | |
|
1288 | #controllerObj.printattr() | |
|
1289 | ||
|
1290 | controllerObj.createObjects() | |
|
1291 | controllerObj.connectObjects() | |
|
1292 | controllerObj.run() | |
|
1293 | ||
|
1294 | No newline at end of file |
|
1 | NO CONTENT: modified file |
@@ -401,9 +401,9 class RadarControllerHeader(Header): | |||
|
401 | 401 | |
|
402 | 402 | try: |
|
403 | 403 | if hasattr(fp, 'read'): |
|
404 | self.nCode = numpy.fromfile(fp, '<u4', 1) | |
|
404 | self.nCode = numpy.fromfile(fp, '<u4', 1)[0] | |
|
405 | 405 | self.length += self.nCode.nbytes |
|
406 | self.nBaud = numpy.fromfile(fp, '<u4', 1) | |
|
406 | self.nBaud = numpy.fromfile(fp, '<u4', 1)[0] | |
|
407 | 407 | self.length += self.nBaud.nbytes |
|
408 | 408 | else: |
|
409 | 409 | self.nCode = numpy.fromstring(fp[self.length:], '<u4', 1)[0] |
@@ -61,7 +61,7 class Figure(Operation): | |||
|
61 | 61 | figfile = None |
|
62 | 62 | |
|
63 | 63 | created = False |
|
64 | ||
|
64 | parameters = {} | |
|
65 | 65 | def __init__(self, **kwargs): |
|
66 | 66 | |
|
67 | 67 | Operation.__init__(self, **kwargs) |
@@ -2,11 +2,10 import os | |||
|
2 | 2 | import datetime |
|
3 | 3 | import numpy |
|
4 | 4 | import copy |
|
5 | ||
|
5 | from schainpy.model import * | |
|
6 | 6 | from figure import Figure, isRealtime |
|
7 | 7 | |
|
8 | 8 | class CorrelationPlot(Figure): |
|
9 | ||
|
10 | 9 | isConfig = None |
|
11 | 10 | __nsubplots = None |
|
12 | 11 |
@@ -6,6 +6,7 import numpy | |||
|
6 | 6 | import datetime |
|
7 | 7 | import numpy as np |
|
8 | 8 | import matplotlib |
|
9 | import glob | |
|
9 | 10 | matplotlib.use('TkAgg') |
|
10 | 11 | import matplotlib.pyplot as plt |
|
11 | 12 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
@@ -17,6 +18,8 from schainpy.model.proc.jroproc_base import Operation | |||
|
17 | 18 | plt.ion() |
|
18 | 19 | |
|
19 | 20 | func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) |
|
21 | fromtimestamp = lambda x, mintime : (datetime.datetime.utcfromtimestamp(mintime).replace(hour=(x + 5), minute=0) - d1970).total_seconds() | |
|
22 | ||
|
20 | 23 | |
|
21 | 24 | d1970 = datetime.datetime(1970,1,1) |
|
22 | 25 | |
@@ -54,11 +57,20 class PlotData(Operation, Process): | |||
|
54 | 57 | self.xrange = kwargs.get('xrange', 24) |
|
55 | 58 | self.ymin = kwargs.get('ymin', None) |
|
56 | 59 | self.ymax = kwargs.get('ymax', None) |
|
57 |
self.__MAXNUMY = kwargs.get('decimation', |
|
|
60 | self.__MAXNUMY = kwargs.get('decimation', 5000) | |
|
58 | 61 | self.throttle_value = 5 |
|
59 | 62 | self.times = [] |
|
60 | 63 | #self.interactive = self.kwargs['parent'] |
|
61 | 64 | |
|
65 | ''' | |
|
66 | this new parameter is created to plot data from varius channels at different figures | |
|
67 | 1. crear una lista de figuras donde se puedan plotear las figuras, | |
|
68 | 2. dar las opciones de configuracion a cada figura, estas opciones son iguales para ambas figuras | |
|
69 | 3. probar? | |
|
70 | ''' | |
|
71 | self.ind_plt_ch = kwargs.get('ind_plt_ch', False) | |
|
72 | self.figurelist = None | |
|
73 | ||
|
62 | 74 | |
|
63 | 75 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
64 | 76 | |
@@ -90,25 +102,98 class PlotData(Operation, Process): | |||
|
90 | 102 | |
|
91 | 103 | return x, y, z |
|
92 | 104 | |
|
105 | ''' | |
|
106 | JM: | |
|
107 | elimana las otras imagenes generadas debido a que lso workers no llegan en orden y le pueden | |
|
108 | poner otro tiempo a la figura q no necesariamente es el ultimo. | |
|
109 | Solo se realiza cuando termina la imagen. | |
|
110 | Problemas: | |
|
111 | ||
|
112 | File "/home/ci-81/workspace/schainv2.3/schainpy/model/graphics/jroplot_data.py", line 145, in __plot | |
|
113 | for n, eachfigure in enumerate(self.figurelist): | |
|
114 | TypeError: 'NoneType' object is not iterable | |
|
115 | ||
|
116 | ''' | |
|
117 | def deleteanotherfiles(self): | |
|
118 | figurenames=[] | |
|
119 | if self.figurelist != None: | |
|
120 | for n, eachfigure in enumerate(self.figurelist): | |
|
121 | #add specific name for each channel in channelList | |
|
122 | ghostfigname = os.path.join(self.save, '{}_{}_{}'.format(self.titles[n].replace(' ',''),self.CODE, | |
|
123 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d'))) | |
|
124 | figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE, | |
|
125 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
126 | ||
|
127 | for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures | |
|
128 | if ghostfigure != figname: | |
|
129 | os.remove(ghostfigure) | |
|
130 | print 'Removing GhostFigures:' , figname | |
|
131 | else : | |
|
132 | '''Erasing ghost images for just on******************''' | |
|
133 | ghostfigname = os.path.join(self.save, '{}_{}'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d'))) | |
|
134 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
135 | for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures | |
|
136 | if ghostfigure != figname: | |
|
137 | os.remove(ghostfigure) | |
|
138 | print 'Removing GhostFigures:' , figname | |
|
139 | ||
|
93 | 140 | def __plot(self): |
|
94 | 141 | |
|
95 | 142 | print 'plotting...{}'.format(self.CODE) |
|
96 | ||
|
143 | if self.ind_plt_ch is False : #standard | |
|
97 | 144 | if self.show: |
|
98 | 145 | self.figure.show() |
|
99 | ||
|
100 | 146 | self.plot() |
|
101 | 147 | plt.tight_layout() |
|
102 | 148 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), |
|
103 | 149 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) |
|
150 | else : | |
|
151 | print 'len(self.figurelist): ',len(self.figurelist) | |
|
152 | for n, eachfigure in enumerate(self.figurelist): | |
|
153 | if self.show: | |
|
154 | eachfigure.show() | |
|
155 | ||
|
156 | self.plot() | |
|
157 | eachfigure.tight_layout() # ajuste de cada subplot | |
|
158 | eachfigure.canvas.manager.set_window_title('{} {} - {}'.format(self.title[n], self.CODE.upper(), | |
|
159 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
|
160 | ||
|
161 | # if self.save: | |
|
162 | # if self.ind_plt_ch is False : #standard | |
|
163 | # figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
|
164 | # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
165 | # print 'Saving figure: {}'.format(figname) | |
|
166 | # self.figure.savefig(figname) | |
|
167 | # else : | |
|
168 | # for n, eachfigure in enumerate(self.figurelist): | |
|
169 | # #add specific name for each channel in channelList | |
|
170 | # figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE, | |
|
171 | # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
172 | # | |
|
173 | # print 'Saving figure: {}'.format(figname) | |
|
174 | # eachfigure.savefig(figname) | |
|
175 | ||
|
176 | if self.ind_plt_ch is False : | |
|
177 | self.figure.canvas.draw() | |
|
178 | else : | |
|
179 | for eachfigure in self.figurelist: | |
|
180 | eachfigure.canvas.draw() | |
|
104 | 181 | |
|
105 | 182 | if self.save: |
|
183 | if self.ind_plt_ch is False : #standard | |
|
106 | 184 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, |
|
107 | 185 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) |
|
108 | 186 | print 'Saving figure: {}'.format(figname) |
|
109 | 187 | self.figure.savefig(figname) |
|
188 | else : | |
|
189 | for n, eachfigure in enumerate(self.figurelist): | |
|
190 | #add specific name for each channel in channelList | |
|
191 | figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE, | |
|
192 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
193 | ||
|
194 | print 'Saving figure: {}'.format(figname) | |
|
195 | eachfigure.savefig(figname) | |
|
110 | 196 | |
|
111 | self.figure.canvas.draw() | |
|
112 | 197 | |
|
113 | 198 | def plot(self): |
|
114 | 199 | |
@@ -157,6 +242,7 class PlotData(Operation, Process): | |||
|
157 | 242 | self.ended = True |
|
158 | 243 | self.isConfig = False |
|
159 | 244 | self.__plot() |
|
245 | self.deleteanotherfiles() #CLPDG | |
|
160 | 246 | elif seconds_passed >= self.data['throttle']: |
|
161 | 247 | print 'passed', seconds_passed |
|
162 | 248 | self.__plot() |
@@ -230,7 +316,6 class PlotSpectraData(PlotData): | |||
|
230 | 316 | z = self.data[self.CODE] |
|
231 | 317 | |
|
232 | 318 | for n, ax in enumerate(self.axes): |
|
233 | ||
|
234 | 319 | if ax.firsttime: |
|
235 | 320 | self.xmax = self.xmax if self.xmax else np.nanmax(x) |
|
236 | 321 | self.xmin = self.xmin if self.xmin else -self.xmax |
@@ -462,13 +547,29 class PlotRTIData(PlotData): | |||
|
462 | 547 | self.ncols = 1 |
|
463 | 548 | self.nrows = self.dataOut.nChannels |
|
464 | 549 | self.width = 10 |
|
550 | #TODO : arreglar la altura de la figura, esta hardcodeada. | |
|
551 | #Se arreglo, testear! | |
|
552 | if self.ind_plt_ch: | |
|
553 | self.height = 3.2#*self.nrows if self.nrows<6 else 12 | |
|
554 | else: | |
|
465 | 555 | self.height = 2.2*self.nrows if self.nrows<6 else 12 |
|
556 | ||
|
557 | ''' | |
|
466 | 558 | if self.nrows==1: |
|
467 | 559 | self.height += 1 |
|
560 | ''' | |
|
468 | 561 | self.ylabel = 'Range [Km]' |
|
469 | 562 | self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList] |
|
470 | 563 | |
|
471 | if self.figure is None: | |
|
564 | ''' | |
|
565 | Logica: | |
|
566 | 1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura | |
|
567 | 2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el | |
|
568 | axis dentro de "Figures" como un diccionario. | |
|
569 | ''' | |
|
570 | if self.ind_plt_ch is False: #standard mode | |
|
571 | ||
|
572 | if self.figure is None: #solo para la priemra vez | |
|
472 | 573 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
473 | 574 | edgecolor='k', |
|
474 | 575 | facecolor='w') |
@@ -476,13 +577,40 class PlotRTIData(PlotData): | |||
|
476 | 577 | self.figure.clf() |
|
477 | 578 | self.axes = [] |
|
478 | 579 | |
|
580 | ||
|
479 | 581 | for n in range(self.nrows): |
|
480 | 582 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) |
|
583 | #ax = self.figure(n+1) | |
|
584 | ax.firsttime = True | |
|
585 | self.axes.append(ax) | |
|
586 | ||
|
587 | else : #append one figure foreach channel in channelList | |
|
588 | if self.figurelist == None: | |
|
589 | self.figurelist = [] | |
|
590 | for n in range(self.nrows): | |
|
591 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
592 | edgecolor='k', | |
|
593 | facecolor='w') | |
|
594 | #add always one subplot | |
|
595 | self.figurelist.append(self.figure) | |
|
596 | ||
|
597 | else : # cada dia nuevo limpia el axes, pero mantiene el figure | |
|
598 | for eachfigure in self.figurelist: | |
|
599 | eachfigure.clf() # eliminaria todas las figuras de la lista? | |
|
600 | self.axes = [] | |
|
601 | ||
|
602 | for eachfigure in self.figurelist: | |
|
603 | ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura | |
|
604 | #ax = self.figure(n+1) | |
|
481 | 605 | ax.firsttime = True |
|
606 | #Cada figura tiene un distinto puntero | |
|
482 | 607 | self.axes.append(ax) |
|
608 | #plt.close(eachfigure) | |
|
609 | ||
|
483 | 610 | |
|
484 | 611 | def plot(self): |
|
485 | 612 | |
|
613 | if self.ind_plt_ch is False: #standard mode | |
|
486 | 614 | self.x = np.array(self.times) |
|
487 | 615 | self.y = self.dataOut.getHeiRange() |
|
488 | 616 | self.z = [] |
@@ -493,8 +621,14 class PlotRTIData(PlotData): | |||
|
493 | 621 | self.z = np.array(self.z) |
|
494 | 622 | for n, ax in enumerate(self.axes): |
|
495 | 623 | x, y, z = self.fill_gaps(*self.decimate()) |
|
624 | if self.xmin is None: | |
|
496 | 625 | xmin = self.min_time |
|
626 | else: | |
|
627 | xmin = fromtimestamp(int(self.xmin), self.min_time) | |
|
628 | if self.xmax is None: | |
|
497 | 629 | xmax = xmin+self.xrange*60*60 |
|
630 | else: | |
|
631 | xmax = xmin + (self.xmax - self.xmin) * 60 * 60 | |
|
498 | 632 | self.zmin = self.zmin if self.zmin else np.min(self.z) |
|
499 | 633 | self.zmax = self.zmax if self.zmax else np.max(self.z) |
|
500 | 634 | if ax.firsttime: |
@@ -510,12 +644,9 class PlotRTIData(PlotData): | |||
|
510 | 644 | self.figure.add_axes(cax) |
|
511 | 645 | plt.colorbar(plot, cax) |
|
512 | 646 | ax.set_ylim(self.ymin, self.ymax) |
|
513 | ||
|
514 | 647 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
515 | 648 | ax.xaxis.set_major_locator(LinearLocator(6)) |
|
516 | ||
|
517 | 649 | ax.set_ylabel(self.ylabel) |
|
518 | ||
|
519 | 650 | # if self.xmin is None: |
|
520 | 651 | # xmin = self.min_time |
|
521 | 652 | # else: |
@@ -537,6 +668,63 class PlotRTIData(PlotData): | |||
|
537 | 668 | size=8) |
|
538 | 669 | |
|
539 | 670 | self.saveTime = self.min_time |
|
671 | else : | |
|
672 | self.x = np.array(self.times) | |
|
673 | self.y = self.dataOut.getHeiRange() | |
|
674 | self.z = [] | |
|
675 | ||
|
676 | for ch in range(self.nrows): | |
|
677 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |
|
678 | ||
|
679 | self.z = np.array(self.z) | |
|
680 | for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes | |
|
681 | ||
|
682 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
683 | xmin = self.min_time | |
|
684 | xmax = xmin+self.xrange*60*60 | |
|
685 | self.zmin = self.zmin if self.zmin else np.min(self.z) | |
|
686 | self.zmax = self.zmax if self.zmax else np.max(self.z) | |
|
687 | if self.axes[n].firsttime: | |
|
688 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
|
689 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
|
690 | plot = self.axes[n].pcolormesh(x, y, z[n].T, | |
|
691 | vmin=self.zmin, | |
|
692 | vmax=self.zmax, | |
|
693 | cmap=plt.get_cmap(self.colormap) | |
|
694 | ) | |
|
695 | divider = make_axes_locatable(self.axes[n]) | |
|
696 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
|
697 | eachfigure.add_axes(cax) | |
|
698 | #self.figure2.add_axes(cax) | |
|
699 | plt.colorbar(plot, cax) | |
|
700 | self.axes[n].set_ylim(self.ymin, self.ymax) | |
|
701 | ||
|
702 | self.axes[n].xaxis.set_major_formatter(FuncFormatter(func)) | |
|
703 | self.axes[n].xaxis.set_major_locator(LinearLocator(6)) | |
|
704 | ||
|
705 | self.axes[n].set_ylabel(self.ylabel) | |
|
706 | ||
|
707 | if self.xmin is None: | |
|
708 | xmin = self.min_time | |
|
709 | else: | |
|
710 | xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |
|
711 | datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |
|
712 | ||
|
713 | self.axes[n].set_xlim(xmin, xmax) | |
|
714 | self.axes[n].firsttime = False | |
|
715 | else: | |
|
716 | self.axes[n].collections.remove(self.axes[n].collections[0]) | |
|
717 | self.axes[n].set_xlim(xmin, xmax) | |
|
718 | plot = self.axes[n].pcolormesh(x, y, z[n].T, | |
|
719 | vmin=self.zmin, | |
|
720 | vmax=self.zmax, | |
|
721 | cmap=plt.get_cmap(self.colormap) | |
|
722 | ) | |
|
723 | self.axes[n].set_title('{} {}'.format(self.titles[n], | |
|
724 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
|
725 | size=8) | |
|
726 | ||
|
727 | self.saveTime = self.min_time | |
|
540 | 728 | |
|
541 | 729 | |
|
542 | 730 | class PlotCOHData(PlotRTIData): |
@@ -549,6 +737,7 class PlotCOHData(PlotRTIData): | |||
|
549 | 737 | self.nrows = self.dataOut.nPairs |
|
550 | 738 | self.width = 10 |
|
551 | 739 | self.height = 2.2*self.nrows if self.nrows<6 else 12 |
|
740 | self.ind_plt_ch = False #just for coherence and phase | |
|
552 | 741 | if self.nrows==1: |
|
553 | 742 | self.height += 1 |
|
554 | 743 | self.ylabel = 'Range [Km]' |
@@ -14,7 +14,6 class MomentsPlot(Figure): | |||
|
14 | 14 | WIDTHPROF = None |
|
15 | 15 | HEIGHTPROF = None |
|
16 | 16 | PREFIX = 'prm' |
|
17 | ||
|
18 | 17 | def __init__(self, **kwargs): |
|
19 | 18 | Figure.__init__(self, **kwargs) |
|
20 | 19 | self.isConfig = False |
@@ -1417,6 +1416,7 class PhasePlot(Figure): | |||
|
1417 | 1416 | |
|
1418 | 1417 | PREFIX = 'mphase' |
|
1419 | 1418 | |
|
1419 | ||
|
1420 | 1420 | def __init__(self, **kwargs): |
|
1421 | 1421 | Figure.__init__(self, **kwargs) |
|
1422 | 1422 | self.timerange = 24*60*60 |
@@ -10,6 +10,7 import numpy | |||
|
10 | 10 | from figure import Figure, isRealtime, isTimeInHourRange |
|
11 | 11 | from plotting_codes import * |
|
12 | 12 | |
|
13 | ||
|
13 | 14 | class SpectraPlot(Figure): |
|
14 | 15 | |
|
15 | 16 | isConfig = None |
@@ -542,7 +542,7 class JRODataIO: | |||
|
542 | 542 | |
|
543 | 543 | class JRODataReader(JRODataIO): |
|
544 | 544 | |
|
545 | ||
|
545 | firstTime = True | |
|
546 | 546 | online = 0 |
|
547 | 547 | |
|
548 | 548 | realtime = 0 |
@@ -579,7 +579,7 class JRODataReader(JRODataIO): | |||
|
579 | 579 | |
|
580 | 580 | selBlocktime = None |
|
581 | 581 | |
|
582 | ||
|
582 | onlineWithDate = False | |
|
583 | 583 | def __init__(self): |
|
584 | 584 | |
|
585 | 585 | """ |
@@ -616,7 +616,6 class JRODataReader(JRODataIO): | |||
|
616 | 616 | cursor=None, |
|
617 | 617 | skip=None, |
|
618 | 618 | walk=True): |
|
619 | ||
|
620 | 619 | self.filenameList = [] |
|
621 | 620 | self.datetimeList = [] |
|
622 | 621 | |
@@ -683,10 +682,9 class JRODataReader(JRODataIO): | |||
|
683 | 682 | |
|
684 | 683 | self.filenameList = filenameList |
|
685 | 684 | self.datetimeList = datetimeList |
|
686 | ||
|
687 | 685 | return pathList, filenameList |
|
688 | 686 | |
|
689 |
def __searchFilesOnLine(self, path, expLabel |
|
|
687 | def __searchFilesOnLine(self, path, expLabel="", ext=None, walk=True, set=None, startDate=None, startTime=None): | |
|
690 | 688 | |
|
691 | 689 |
|
|
692 | 690 | Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y |
@@ -699,7 +697,7 class JRODataReader(JRODataIO): | |||
|
699 | 697 | |
|
700 | 698 |
ext |
|
701 | 699 | |
|
702 | walk : Si es habilitado no realiza busquedas dentro de los ubdirectorios (doypath) | |
|
700 | walk : Si es habilitado no realiza busquedas dentro de los subdirectorios (doypath) | |
|
703 | 701 | |
|
704 | 702 | Return: |
|
705 | 703 | directory : eL directorio donde esta el file encontrado |
@@ -710,6 +708,8 class JRODataReader(JRODataIO): | |||
|
710 | 708 | |
|
711 | 709 | |
|
712 | 710 | """ |
|
711 | pathList = None | |
|
712 | filenameList = None | |
|
713 | 713 | if not os.path.isdir(path): |
|
714 | 714 | return None, None, None, None, None, None |
|
715 | 715 | |
@@ -810,6 +810,7 class JRODataReader(JRODataIO): | |||
|
810 | 810 | Excepciones: |
|
811 | 811 | Si un determinado file no puede ser abierto |
|
812 | 812 | """ |
|
813 | ||
|
813 | 814 | nFiles = 0 |
|
814 | 815 | fileOk_flag = False |
|
815 | 816 | firstTime_flag = True |
@@ -882,13 +883,34 class JRODataReader(JRODataIO): | |||
|
882 | 883 | def setNextFile(self): |
|
883 | 884 | if self.fp != None: |
|
884 | 885 | self.fp.close() |
|
885 | ||
|
886 | 886 | if self.online: |
|
887 | 887 | newFile = self.__setNextFileOnline() |
|
888 | 888 | else: |
|
889 | 889 | newFile = self.__setNextFileOffline() |
|
890 | ||
|
891 | 890 | if not(newFile): |
|
891 | if self.onlineWithDate is True: | |
|
892 | self.onlineWithDate=False | |
|
893 | self.online = True | |
|
894 | self.firstTime = False | |
|
895 | self.setup( | |
|
896 | path=self.path, | |
|
897 | startDate=self.startDate, | |
|
898 | endDate=self.endDate, | |
|
899 | startTime=self.startTime , | |
|
900 | endTime=self.endTime, | |
|
901 | set=self.set, | |
|
902 | expLabel=self.expLabel, | |
|
903 | ext=self.ext, | |
|
904 | online=self.online, | |
|
905 | delay=self.delay, | |
|
906 | walk=self.walk, | |
|
907 | getblock=self.getblock, | |
|
908 | nTxs=self.nTxs, | |
|
909 | realtime=self.realtime, | |
|
910 | blocksize=self.blocksize, | |
|
911 | blocktime=self.blocktime | |
|
912 | ) | |
|
913 | return 1 | |
|
892 | 914 | print '[Reading] No more files to read' |
|
893 | 915 | return 0 |
|
894 | 916 | |
@@ -1048,9 +1070,7 class JRODataReader(JRODataIO): | |||
|
1048 | 1070 | return 0 |
|
1049 | 1071 | if not(self.readBlock()): |
|
1050 | 1072 | return 0 |
|
1051 | ||
|
1052 | 1073 | self.getBasicHeader() |
|
1053 | ||
|
1054 | 1074 | if not isTimeInRange(self.dataOut.datatime.time(), self.startTime, self.endTime): |
|
1055 | 1075 | |
|
1056 | 1076 | print "[Reading] Block No. %d/%d -> %s [Skipping]" %(self.nReadBlocks, |
@@ -1272,40 +1292,66 class JRODataReader(JRODataIO): | |||
|
1272 | 1292 | realtime=False, |
|
1273 | 1293 | blocksize=None, |
|
1274 | 1294 | blocktime=None, |
|
1275 | queue=None, | |
|
1276 | skip=None, | |
|
1277 | cursor=None, | |
|
1278 | warnings=True, | |
|
1279 | 1295 | verbose=True, |
|
1280 |
|
|
|
1281 | if server is not None: | |
|
1282 | if 'tcp://' in server: | |
|
1283 | address = server | |
|
1284 | else: | |
|
1285 | address = 'ipc:///tmp/%s' % server | |
|
1286 | self.server = address | |
|
1287 | self.context = zmq.Context() | |
|
1288 | self.receiver = self.context.socket(zmq.PULL) | |
|
1289 | self.receiver.connect(self.server) | |
|
1290 | time.sleep(0.5) | |
|
1291 | print '[Starting] ReceiverData from {}'.format(self.server) | |
|
1292 | else: | |
|
1293 | self.server = None | |
|
1296 | **kwargs): | |
|
1297 | ||
|
1294 | 1298 |
|
|
1295 | 1299 |
|
|
1296 | 1300 | |
|
1301 | ||
|
1297 | 1302 |
|
|
1298 | 1303 |
|
|
1299 | 1304 | |
|
1305 | self.verbose=verbose | |
|
1306 | self.path = path | |
|
1307 | self.startDate = startDate | |
|
1308 | self.endDate = endDate | |
|
1309 | self.startTime = startTime | |
|
1310 | self.endTime = endTime | |
|
1311 | self.set = set | |
|
1312 | self.expLabel = expLabel | |
|
1313 | self.ext = ext | |
|
1314 | self.online = online | |
|
1315 | self.delay = delay | |
|
1316 | self.walk = walk | |
|
1317 | self.getblock = getblock | |
|
1318 | self.nTxs = nTxs | |
|
1319 | self.realtime = realtime | |
|
1320 | self.blocksize = blocksize | |
|
1321 | self.blocktime = blocktime | |
|
1322 | ||
|
1323 | ||
|
1324 | if self.firstTime is True: | |
|
1325 | pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate, | |
|
1326 | startTime=startTime, endTime=endTime, | |
|
1327 | set=set, expLabel=expLabel, ext=ext, | |
|
1328 | walk=walk) | |
|
1329 | if filenameList is not None: filenameList = filenameList[:-1] | |
|
1330 | ||
|
1331 | if pathList is not None and filenameList is not None and online: | |
|
1332 | self.onlineWithDate = True | |
|
1333 | online = False | |
|
1334 | self.fileIndex = -1 | |
|
1335 | self.pathList = pathList | |
|
1336 | self.filenameList = filenameList | |
|
1337 | file_name = os.path.basename(filenameList[-1]) | |
|
1338 | basename, ext = os.path.splitext(file_name) | |
|
1339 | last_set = int(basename[-3:]) | |
|
1340 | ||
|
1300 | 1341 |
|
|
1301 | 1342 |
|
|
1302 | 1343 | |
|
1303 | 1344 |
|
|
1304 |
|
|
|
1345 | fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path, | |
|
1346 | expLabel=expLabel, | |
|
1347 | ext=ext, | |
|
1348 | walk=walk, | |
|
1349 | startDate=startDate, | |
|
1350 | startTime=startTime, | |
|
1351 | set=set) | |
|
1305 | 1352 | |
|
1306 | 1353 |
|
|
1307 | 1354 |
|
|
1308 | ||
|
1309 | 1355 |
|
|
1310 | 1356 |
|
|
1311 | 1357 | |
@@ -1324,8 +1370,7 class JRODataReader(JRODataIO): | |||
|
1324 | 1370 |
|
|
1325 | 1371 |
|
|
1326 | 1372 |
|
|
1327 |
|
|
|
1328 | skip=skip, queue=queue) | |
|
1373 | walk=walk) | |
|
1329 | 1374 | |
|
1330 | 1375 |
|
|
1331 | 1376 | # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path, |
@@ -1340,6 +1385,38 class JRODataReader(JRODataIO): | |||
|
1340 | 1385 |
|
|
1341 | 1386 | |
|
1342 | 1387 |
|
|
1388 | self.pathList = pathList | |
|
1389 | self.filenameList = filenameList | |
|
1390 | file_name = os.path.basename(filenameList[-1]) | |
|
1391 | basename, ext = os.path.splitext(file_name) | |
|
1392 | last_set = int(basename[-3:]) | |
|
1393 | ||
|
1394 | ||
|
1395 | self.online = online | |
|
1396 | self.realtime = realtime | |
|
1397 | self.delay = delay | |
|
1398 | ext = ext.lower() | |
|
1399 | self.ext = ext | |
|
1400 | self.getByBlock = getblock | |
|
1401 | self.nTxs = nTxs | |
|
1402 | self.startTime = startTime | |
|
1403 | self.endTime = endTime | |
|
1404 | ||
|
1405 | ||
|
1406 | #Added----------------- | |
|
1407 | self.selBlocksize = blocksize | |
|
1408 | self.selBlocktime = blocktime | |
|
1409 | ||
|
1410 | ||
|
1411 | if not(self.setNextFile()): | |
|
1412 | if (startDate!=None) and (endDate!=None): | |
|
1413 | print "[Reading] No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime()) | |
|
1414 | elif startDate != None: | |
|
1415 | print "[Reading] No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime()) | |
|
1416 | else: | |
|
1417 | print "[Reading] No files" | |
|
1418 | ||
|
1419 | self.fileIndex = -1 | |
|
1343 | 1420 | self.pathList = [] |
|
1344 | 1421 | self.filenameList = [] |
|
1345 | 1422 | return |
@@ -1416,7 +1493,6 class JRODataReader(JRODataIO): | |||
|
1416 | 1493 | |
|
1417 | 1494 | self.__printInfo = False |
|
1418 | 1495 | |
|
1419 | ||
|
1420 | 1496 | def run(self, |
|
1421 | 1497 |
|
|
1422 | 1498 |
|
@@ -1464,7 +1540,7 class JRODataReader(JRODataIO): | |||
|
1464 | 1540 | cursor=cursor, |
|
1465 | 1541 | warnings=warnings, |
|
1466 | 1542 | server=server, |
|
1467 | verbose=verbose) | |
|
1543 | verbose=verbose, **kwargs) | |
|
1468 | 1544 | self.isConfig = True |
|
1469 | 1545 | if server is None: |
|
1470 | 1546 | self.getData() |
@@ -1716,7 +1792,7 class JRODataWriter(JRODataIO): | |||
|
1716 | 1792 | |
|
1717 | 1793 | return 1 |
|
1718 | 1794 | |
|
1719 | def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4): | |
|
1795 | def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4, verbose=True): | |
|
1720 | 1796 | """ |
|
1721 | 1797 | Setea el tipo de formato en la cual sera guardada la data y escribe el First Header |
|
1722 | 1798 |
@@ -119,7 +119,6 class Metadata(object): | |||
|
119 | 119 | self.parmConfObjList.append(parmConfObj) |
|
120 | 120 | |
|
121 | 121 | class FitsWriter(Operation): |
|
122 | ||
|
123 | 122 | def __init__(self, **kwargs): |
|
124 | 123 | Operation.__init__(self, **kwargs) |
|
125 | 124 | self.isConfig = False |
@@ -276,9 +275,9 class FitsWriter(Operation): | |||
|
276 | 275 | self.setNextFile() |
|
277 | 276 | self.writeNextBlock() |
|
278 | 277 | |
|
279 | def run(self, dataOut, **kwargs): | |
|
278 | def run(self, dataOut, path, dataBlocksPerFile=100, metadatafile=None, **kwargs): | |
|
280 | 279 | if not(self.isConfig): |
|
281 | self.setup(dataOut, **kwargs) | |
|
280 | self.setup(dataOut, path, dataBlocksPerFile=dataBlocksPerFile, metadatafile=metadatafile, **kwargs) | |
|
282 | 281 | self.isConfig = True |
|
283 | 282 | self.putData() |
|
284 | 283 |
@@ -607,28 +607,18 class ParamWriter(Operation): | |||
|
607 | 607 | self.isConfig = False |
|
608 | 608 | return |
|
609 | 609 | |
|
610 | def setup(self, dataOut, **kwargs): | |
|
611 | ||
|
612 | self.path = kwargs['path'] | |
|
613 | ||
|
614 | if kwargs.has_key('blocksPerFile'): | |
|
615 | self.blocksPerFile = kwargs['blocksPerFile'] | |
|
616 | else: | |
|
617 | self.blocksPerFile = 10 | |
|
618 | ||
|
619 | self.metadataList = kwargs['metadataList'] | |
|
620 | self.dataList = kwargs['dataList'] | |
|
610 | def setup(self, dataOut, path=None, blocksPerFile=10, metadataList=None, dataList=None, mode=None, **kwargs): | |
|
611 | self.path = path | |
|
612 | self.blocksPerFile = blocksPerFile | |
|
613 | self.metadataList = metadataList | |
|
614 | self.dataList = dataList | |
|
621 | 615 | self.dataOut = dataOut |
|
616 | self.mode = mode | |
|
622 | 617 | |
|
623 | if kwargs.has_key('mode'): | |
|
624 | mode = kwargs['mode'] | |
|
625 | ||
|
626 | if type(mode) == int: | |
|
627 | mode = numpy.zeros(len(self.dataList)) + mode | |
|
618 | if self.mode is not None: | |
|
619 | self.mode = numpy.zeros(len(self.dataList)) + mode | |
|
628 | 620 | else: |
|
629 | mode = numpy.ones(len(self.dataList)) | |
|
630 | ||
|
631 | self.mode = mode | |
|
621 | self.mode = numpy.ones(len(self.dataList)) | |
|
632 | 622 | |
|
633 | 623 | arrayDim = numpy.zeros((len(self.dataList),5)) |
|
634 | 624 | |
@@ -770,9 +760,16 class ParamWriter(Operation): | |||
|
770 | 760 | else: |
|
771 | 761 | setFile = -1 #inicializo mi contador de seteo |
|
772 | 762 | |
|
763 | if self.setType is None: | |
|
773 | 764 | setFile += 1 |
|
774 | ||
|
775 | file = '%s%4.4d%3.3d%3.3d%s' % (self.metaoptchar, | |
|
765 | file = '%s%4.4d%3.3d%03d%s' % (self.metaoptchar, | |
|
766 | timeTuple.tm_year, | |
|
767 | timeTuple.tm_yday, | |
|
768 | setFile, | |
|
769 | ext ) | |
|
770 | else: | |
|
771 | setFile = timeTuple.tm_hour*60+timeTuple.tm_min | |
|
772 | file = '%s%4.4d%3.3d%04d%s' % (self.metaoptchar, | |
|
776 | 773 | timeTuple.tm_year, |
|
777 | 774 | timeTuple.tm_yday, |
|
778 | 775 | setFile, |
@@ -849,9 +846,16 class ParamWriter(Operation): | |||
|
849 | 846 | os.makedirs(fullpath) |
|
850 | 847 | setFile = -1 #inicializo mi contador de seteo |
|
851 | 848 | |
|
849 | if self.setType is None: | |
|
852 | 850 | setFile += 1 |
|
853 | ||
|
854 | file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar, | |
|
851 | file = '%s%4.4d%3.3d%03d%s' % (self.metaoptchar, | |
|
852 | timeTuple.tm_year, | |
|
853 | timeTuple.tm_yday, | |
|
854 | setFile, | |
|
855 | ext ) | |
|
856 | else: | |
|
857 | setFile = timeTuple.tm_hour*60+timeTuple.tm_min | |
|
858 | file = '%s%4.4d%3.3d%04d%s' % (self.metaoptchar, | |
|
855 | 859 | timeTuple.tm_year, |
|
856 | 860 | timeTuple.tm_yday, |
|
857 | 861 | setFile, |
@@ -1074,10 +1078,11 class ParamWriter(Operation): | |||
|
1074 | 1078 | self.fp.close() |
|
1075 | 1079 | return |
|
1076 | 1080 | |
|
1077 | def run(self, dataOut, **kwargs): | |
|
1081 | def run(self, dataOut, path=None, blocksPerFile=10, metadataList=None, dataList=None, mode=None, **kwargs): | |
|
1078 | 1082 | |
|
1079 | 1083 | if not(self.isConfig): |
|
1080 |
flagdata = self.setup(dataOut, |
|
|
1084 | flagdata = self.setup(dataOut, path=path, blocksPerFile=blocksPerFile, | |
|
1085 | metadataList=metadataList, dataList=dataList, mode=mode, **kwargs) | |
|
1081 | 1086 | |
|
1082 | 1087 | if not(flagdata): |
|
1083 | 1088 | return |
@@ -212,6 +212,16 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
212 | 212 | Exceptions: |
|
213 | 213 | Si un bloque leido no es un bloque valido |
|
214 | 214 | """ |
|
215 | ||
|
216 | # if self.server is not None: | |
|
217 | # self.zBlock = self.receiver.recv() | |
|
218 | # self.zHeader = self.zBlock[:24] | |
|
219 | # self.zDataBlock = self.zBlock[24:] | |
|
220 | # junk = numpy.fromstring(self.zDataBlock, numpy.dtype([('real','<i4'),('imag','<i4')])) | |
|
221 | # self.processingHeaderObj.profilesPerBlock = 240 | |
|
222 | # self.processingHeaderObj.nHeights = 248 | |
|
223 | # self.systemHeaderObj.nChannels | |
|
224 | # else: | |
|
215 | 225 | current_pointer_location = self.fp.tell() |
|
216 | 226 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
217 | 227 | |
@@ -301,6 +311,97 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
301 | 311 | |
|
302 | 312 | return |
|
303 | 313 | |
|
314 | def readFirstHeaderFromServer(self): | |
|
315 | ||
|
316 | self.getFirstHeader() | |
|
317 | ||
|
318 | self.firstHeaderSize = self.basicHeaderObj.size | |
|
319 | ||
|
320 | datatype = int(numpy.log2((self.processingHeaderObj.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) | |
|
321 | if datatype == 0: | |
|
322 | datatype_str = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
|
323 | elif datatype == 1: | |
|
324 | datatype_str = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
|
325 | elif datatype == 2: | |
|
326 | datatype_str = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
|
327 | elif datatype == 3: | |
|
328 | datatype_str = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
|
329 | elif datatype == 4: | |
|
330 | datatype_str = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
|
331 | elif datatype == 5: | |
|
332 | datatype_str = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
|
333 | else: | |
|
334 | raise ValueError, 'Data type was not defined' | |
|
335 | ||
|
336 | self.dtype = datatype_str | |
|
337 | #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c | |
|
338 | self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.processingHeaderObj.dataBlocksPerFile - 1) | |
|
339 | # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels) | |
|
340 | # self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels) | |
|
341 | self.getBlockDimension() | |
|
342 | ||
|
343 | ||
|
344 | def getFromServer(self): | |
|
345 | self.flagDiscontinuousBlock = 0 | |
|
346 | self.profileIndex = 0 | |
|
347 | self.flagIsNewBlock = 1 | |
|
348 | self.dataOut.flagNoData = False | |
|
349 | self.nTotalBlocks += 1 | |
|
350 | self.nReadBlocks += 1 | |
|
351 | self.blockPointer = 0 | |
|
352 | ||
|
353 | block = self.receiver.recv() | |
|
354 | ||
|
355 | self.basicHeaderObj.read(block[self.blockPointer:]) | |
|
356 | self.blockPointer += self.basicHeaderObj.length | |
|
357 | self.systemHeaderObj.read(block[self.blockPointer:]) | |
|
358 | self.blockPointer += self.systemHeaderObj.length | |
|
359 | self.radarControllerHeaderObj.read(block[self.blockPointer:]) | |
|
360 | self.blockPointer += self.radarControllerHeaderObj.length | |
|
361 | self.processingHeaderObj.read(block[self.blockPointer:]) | |
|
362 | self.blockPointer += self.processingHeaderObj.length | |
|
363 | self.readFirstHeaderFromServer() | |
|
364 | ||
|
365 | timestamp = self.basicHeaderObj.get_datatime() | |
|
366 | print '[Reading] - Block {} - {}'.format(self.nTotalBlocks, timestamp) | |
|
367 | current_pointer_location = self.blockPointer | |
|
368 | junk = numpy.fromstring( block[self.blockPointer:], self.dtype, self.blocksize ) | |
|
369 | ||
|
370 | try: | |
|
371 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
|
372 | except: | |
|
373 | #print "The read block (%3d) has not enough data" %self.nReadBlocks | |
|
374 | if self.waitDataBlock(pointer_location=current_pointer_location): | |
|
375 | junk = numpy.fromstring( block[self.blockPointer:], self.dtype, self.blocksize ) | |
|
376 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
|
377 | # return 0 | |
|
378 | ||
|
379 | #Dimensions : nChannels, nProfiles, nSamples | |
|
380 | ||
|
381 | junk = numpy.transpose(junk, (2,0,1)) | |
|
382 | self.datablock = junk['real'] + junk['imag'] * 1j | |
|
383 | self.profileIndex = 0 | |
|
384 | if self.selBlocksize == None: self.selBlocksize = self.dataOut.nProfiles | |
|
385 | if self.selBlocktime != None: | |
|
386 | if self.dataOut.nCohInt is not None: | |
|
387 | nCohInt = self.dataOut.nCohInt | |
|
388 | else: | |
|
389 | nCohInt = 1 | |
|
390 | self.selBlocksize = int(self.dataOut.nProfiles*round(self.selBlocktime/(nCohInt*self.dataOut.ippSeconds*self.dataOut.nProfiles))) | |
|
391 | self.dataOut.data = self.datablock[:,self.profileIndex:self.profileIndex+self.selBlocksize,:] | |
|
392 | datasize = self.dataOut.data.shape[1] | |
|
393 | if datasize < self.selBlocksize: | |
|
394 | buffer = numpy.zeros((self.dataOut.data.shape[0], self.selBlocksize, self.dataOut.data.shape[2]), dtype = 'complex') | |
|
395 | buffer[:,:datasize,:] = self.dataOut.data | |
|
396 | self.dataOut.data = buffer | |
|
397 | self.profileIndex = blockIndex | |
|
398 | ||
|
399 | self.dataOut.flagDataAsBlock = True | |
|
400 | self.flagIsNewBlock = 1 | |
|
401 | self.dataOut.realtime = self.online | |
|
402 | ||
|
403 | return self.dataOut.data | |
|
404 | ||
|
304 | 405 | def getData(self): |
|
305 | 406 | """ |
|
306 | 407 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut |
@@ -1,11 +1,21 | |||
|
1 | #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION | |
|
2 | #define NUM_CPY_THREADS 8 | |
|
1 | 3 | #include <Python.h> |
|
2 | 4 | #include <numpy/arrayobject.h> |
|
3 | 5 | #include <math.h> |
|
6 | #include <complex.h> | |
|
7 | #include <time.h> | |
|
4 | 8 | |
|
9 | // void printArr(int *array); | |
|
5 | 10 | static PyObject *hildebrand_sekhon(PyObject *self, PyObject *args); |
|
11 | static PyObject *correlateByBlock(PyObject *self, PyObject *args); | |
|
12 | #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ | |
|
13 | #define PyMODINIT_FUNC void | |
|
14 | #endif | |
|
6 | 15 | |
|
7 | 16 | static PyMethodDef extensionsMethods[] = { |
|
8 | { "hildebrand_sekhon", (PyCFunction)hildebrand_sekhon, METH_VARARGS, "get noise with" }, | |
|
17 | { "correlateByBlock", (PyCFunction)correlateByBlock, METH_VARARGS, "get correlation by block" }, | |
|
18 | { "hildebrand_sekhon", (PyCFunction)hildebrand_sekhon, METH_VARARGS, "get noise with hildebrand_sekhon" }, | |
|
9 | 19 |
|
|
10 | 20 | }; |
|
11 | 21 | |
@@ -14,13 +24,83 PyMODINIT_FUNC initcSchain() { | |||
|
14 | 24 | import_array(); |
|
15 | 25 | } |
|
16 | 26 | |
|
27 | static PyObject *correlateByBlock(PyObject *self, PyObject *args) { | |
|
28 | ||
|
29 | // int *x = (int*) malloc(4000000 * 216 * sizeof(int));; | |
|
30 | // int a = 5; | |
|
31 | // x = &a; | |
|
32 | // int b = 6; | |
|
33 | // x = &b; | |
|
34 | // printf("Antes de imprimir x \n"); | |
|
35 | // printf("%d \n", x[0]); | |
|
36 | ||
|
37 | PyObject *data_obj1, *data_obj2; | |
|
38 | PyArrayObject *data_array1, *data_array2, *correlateRow, *out, *dataRow, *codeRow; //, , | |
|
39 | int mode; | |
|
40 | ||
|
41 | if (!PyArg_ParseTuple(args, "OOi", &data_obj1, &data_obj2, &mode)) return NULL; | |
|
42 | ||
|
43 | data_array1 = (PyArrayObject *) PyArray_FROM_OTF(data_obj1, NPY_COMPLEX128, NPY_ARRAY_DEFAULT); | |
|
44 | data_array2 = (PyArrayObject *) PyArray_FROM_OTF(data_obj2, NPY_FLOAT64, NPY_ARRAY_DEFAULT); | |
|
45 | ||
|
46 | npy_intp dims[1]; | |
|
47 | dims[0] = 200; | |
|
48 | npy_intp dims_code[1]; | |
|
49 | dims_code[0] = 16; | |
|
50 | ||
|
51 | double complex * dataRaw; | |
|
52 | double * codeRaw; | |
|
53 | dataRaw = (double complex*) PyArray_DATA(data_array1); | |
|
54 | codeRaw = (double *) PyArray_DATA(data_array2); | |
|
55 | double complex ** outC = malloc(40000*200*sizeof(double complex)); | |
|
56 | int i; | |
|
57 | ||
|
58 | clock_t start = clock(); | |
|
59 | for(i=0; i<40000; i++){ | |
|
60 | // codeRow = PyArray_SimpleNewFromData(1, dims_code, NPY_FLOAT64, codeRaw + 16 * i); | |
|
61 | // dataRow = PyArray_SimpleNewFromData(1, dims, NPY_COMPLEX128, dataRaw + 200 * i); | |
|
62 | // Py_INCREF(codeRow); | |
|
63 | // Py_INCREF(dataRow); | |
|
64 | // PyArray_ENABLEFLAGS(codeRow, NPY_ARRAY_OWNDATA); | |
|
65 | // PyArray_ENABLEFLAGS(dataRow, NPY_ARRAY_OWNDATA); | |
|
66 | correlateRow = (PyArrayObject *) PyArray_Correlate2(PyArray_SimpleNewFromData(1, dims_code, NPY_FLOAT64, codeRaw + 16 * i), PyArray_SimpleNewFromData(1, dims, NPY_COMPLEX128, dataRaw + 200 * i), (npy_intp) 2); | |
|
67 | //Py_INCREF(correlateRow); | |
|
68 | // PyArray_ENABLEFLAGS(correlateRow, NPY_ARRAY_OWNDATA); | |
|
69 | memcpy(outC + 200*i, (double complex*) PyArray_DATA(correlateRow), 200 * sizeof(double complex)); | |
|
70 | ||
|
71 | Py_DECREF(correlateRow); | |
|
72 | // Py_DECREF(codeRow); | |
|
73 | // Py_DECREF(dataRow); | |
|
74 | } | |
|
75 | clock_t end = clock(); | |
|
76 | float seconds = (float)(end - start) / CLOCKS_PER_SEC; | |
|
77 | printf("%f", seconds); | |
|
78 | // | |
|
79 | npy_intp dimsret[2]; | |
|
80 | dimsret[0] = 40000; | |
|
81 | dimsret[1] = 200; | |
|
82 | out = PyArray_SimpleNewFromData(2, dimsret, NPY_COMPLEX128, outC); | |
|
83 | PyArray_ENABLEFLAGS(out, NPY_ARRAY_OWNDATA); | |
|
84 | //Py_INCREF(out); | |
|
85 | Py_DECREF(data_array1); | |
|
86 | Py_DECREF(data_array2); | |
|
87 | // PyArray_DebugPrint(out); | |
|
88 | // Py_DECREF(data_obj2); | |
|
89 | // Py_DECREF(data_obj1); | |
|
90 | // Py_DECREF(codeRow); | |
|
91 | // Py_DECREF(dataRow); | |
|
92 | // free(dataRaw); | |
|
93 | // free(codeRaw); | |
|
94 | ||
|
95 | return PyArray_Return(out); | |
|
96 | } | |
|
97 | ||
|
17 | 98 | static PyObject *hildebrand_sekhon(PyObject *self, PyObject *args) { |
|
18 | /* Do your stuff here. */ | |
|
19 | 99 | double navg; |
|
20 | 100 | PyObject *data_obj, *data_array; |
|
21 | 101 | |
|
22 | 102 | if (!PyArg_ParseTuple(args, "Od", &data_obj, &navg)) return NULL; |
|
23 |
data_array = PyArray_FROM_OTF(data_obj, NPY_FLOAT64, NPY_ |
|
|
103 | data_array = PyArray_FROM_OTF(data_obj, NPY_FLOAT64, NPY_ARRAY_DEFAULT); | |
|
24 | 104 | if (data_array == NULL) { |
|
25 | 105 | Py_XDECREF(data_array); |
|
26 | 106 | Py_XDECREF(data_obj); |
@@ -56,3 +136,4 static PyObject *hildebrand_sekhon(PyObject *self, PyObject *args) { | |||
|
56 | 136 | |
|
57 | 137 | return Py_BuildValue("d", lnoise); |
|
58 | 138 | } |
|
139 |
@@ -200,7 +200,6 class ProcessingUnit(object): | |||
|
200 | 200 | return True |
|
201 | 201 | |
|
202 | 202 | def call(self, opType, opName=None, opId=None): |
|
203 | ||
|
204 | 203 | """ |
|
205 | 204 | Return True si ejecuta la operacion interna nombrada "opName" o la operacion externa |
|
206 | 205 | identificada con el id "opId"; con los argumentos "**kwargs". |
@@ -174,5 +174,5 class CorrelationProc(ProcessingUnit): | |||
|
174 | 174 | self.dataOut.lagRange = numpy.array(lags)*delta |
|
175 | 175 | # self.dataOut.nCohInt = self.dataIn.nCohInt*nAvg |
|
176 | 176 | self.dataOut.flagNoData = False |
|
177 | a = self.dataOut.normFactor | |
|
177 | # a = self.dataOut.normFactor | |
|
178 | 178 | return |
@@ -163,7 +163,6 class IncohInt4SpectraHeis(Operation): | |||
|
163 | 163 | |
|
164 | 164 | n = None |
|
165 | 165 | |
|
166 | ||
|
167 | 166 | def __init__(self, **kwargs): |
|
168 | 167 | |
|
169 | 168 | Operation.__init__(self, **kwargs) |
@@ -324,10 +323,10 class IncohInt4SpectraHeis(Operation): | |||
|
324 | 323 | |
|
325 | 324 | return avgdata, avgdatatime |
|
326 | 325 | |
|
327 | def run(self, dataOut, **kwargs): | |
|
326 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False, **kwargs): | |
|
328 | 327 | |
|
329 | 328 | if not self.isConfig: |
|
330 | self.setup(**kwargs) | |
|
329 | self.setup(n=n, timeInterval=timeInterval, overlapping=overlapping) | |
|
331 | 330 | self.isConfig = True |
|
332 | 331 | |
|
333 | 332 | avgdata, avgdatatime = self.integrate(dataOut.data_spc, dataOut.utctime) |
@@ -1018,27 +1018,49 class WindProfiler(Operation): | |||
|
1018 | 1018 | metArray = kwargs['metArray'] |
|
1019 | 1019 | heightList = kwargs['heightList'] |
|
1020 | 1020 | timeList = kwargs['timeList'] |
|
1021 |
z |
|
|
1021 | azimuth = kwargs['azimuth'] | |
|
1022 | theta_x = numpy.array(kwargs['theta_x']) | |
|
1023 | theta_y = numpy.array(kwargs['theta_y']) | |
|
1024 | ||
|
1025 | utctime = metArray[:,0] | |
|
1026 | cmet = metArray[:,1].astype(int) | |
|
1027 | hmet = metArray[:,3].astype(int) | |
|
1028 | SNRmet = metArray[:,4] | |
|
1029 | vmet = metArray[:,5] | |
|
1030 | spcmet = metArray[:,6] | |
|
1031 | ||
|
1022 | 1032 | nChan = numpy.max(cmet) + 1 |
|
1023 | 1033 | nHeights = len(heightList) |
|
1024 | 1034 | |
|
1025 | utctime = metArray[:,0] | |
|
1026 |
|
|
|
1027 | hmet = metArray1[:,3].astype(int) | |
|
1028 | h1met = heightList[hmet]*zenithList[cmet] | |
|
1029 | vmet = metArray1[:,5] | |
|
1035 | azimuth_arr, zenith_arr, dir_cosu, dir_cosv, dir_cosw = self.__calculateAngles(theta_x, theta_y, azimuth) | |
|
1036 | hmet = heightList[hmet] | |
|
1037 | h1met = hmet*numpy.cos(zenith_arr[cmet]) #Corrected heights | |
|
1038 | ||
|
1039 | velEst = numpy.zeros((heightList.size,2))*numpy.nan | |
|
1030 | 1040 | |
|
1031 | 1041 | for i in range(nHeights - 1): |
|
1032 | 1042 | hmin = heightList[i] |
|
1033 | 1043 | hmax = heightList[i + 1] |
|
1034 | 1044 | |
|
1035 |
|
|
|
1045 | thisH = (h1met>=hmin) & (h1met<hmax) & (cmet!=2) & (SNRmet>8) & (vmet<50) & (spcmet<10) | |
|
1046 | indthisH = numpy.where(thisH) | |
|
1036 | 1047 | |
|
1048 | if numpy.size(indthisH) > 3: | |
|
1037 | 1049 | |
|
1050 | vel_aux = vmet[thisH] | |
|
1051 | chan_aux = cmet[thisH] | |
|
1052 | cosu_aux = dir_cosu[chan_aux] | |
|
1053 | cosv_aux = dir_cosv[chan_aux] | |
|
1054 | cosw_aux = dir_cosw[chan_aux] | |
|
1038 | 1055 | |
|
1039 | return data_output | |
|
1056 | nch = numpy.size(numpy.unique(chan_aux)) | |
|
1057 | if nch > 1: | |
|
1058 | A = self.__calculateMatA(cosu_aux, cosv_aux, cosw_aux, True) | |
|
1059 | velEst[i,:] = numpy.dot(A,vel_aux) | |
|
1040 | 1060 | |
|
1041 | def run(self, dataOut, technique, hmin=70, hmax=110, nHours=1, **kwargs): | |
|
1061 | return velEst | |
|
1062 | ||
|
1063 | def run(self, dataOut, technique, nHours=1, hmin=70, hmax=110, **kwargs): | |
|
1042 | 1064 | |
|
1043 | 1065 | param = dataOut.data_param |
|
1044 | 1066 | if dataOut.abscissaList != None: |
@@ -1153,11 +1175,15 class WindProfiler(Operation): | |||
|
1153 | 1175 | else: rx_location = [(0,1),(1,1),(1,0)] |
|
1154 | 1176 | if kwargs.has_key('azimuth'): |
|
1155 | 1177 | azimuth = kwargs['azimuth'] |
|
1156 | else: azimuth = 51 | |
|
1178 | else: azimuth = 51.06 | |
|
1157 | 1179 | if kwargs.has_key('dfactor'): |
|
1158 | 1180 | dfactor = kwargs['dfactor'] |
|
1159 | 1181 | if kwargs.has_key('mode'): |
|
1160 | 1182 | mode = kwargs['mode'] |
|
1183 | if kwargs.has_key('theta_x'): | |
|
1184 | theta_x = kwargs['theta_x'] | |
|
1185 | if kwargs.has_key('theta_y'): | |
|
1186 | theta_y = kwargs['theta_y'] | |
|
1161 | 1187 | else: mode = 'SA' |
|
1162 | 1188 | |
|
1163 | 1189 | #Borrar luego esto |
@@ -1200,7 +1226,7 class WindProfiler(Operation): | |||
|
1200 | 1226 | if mode == 'SA': |
|
1201 | 1227 | dataOut.data_output = self.techniqueNSM_SA(rx_location=rx_location, groupList=groupList, azimuth=azimuth, dfactor=dfactor, k=k,metArray=metArray, heightList=heightList,timeList=timeList) |
|
1202 | 1228 | elif mode == 'DBS': |
|
1203 | dataOut.data_output = self.techniqueNSM_DBS(metArray=metArray,heightList=heightList,timeList=timeList) | |
|
1229 | dataOut.data_output = self.techniqueNSM_DBS(metArray=metArray,heightList=heightList,timeList=timeList, azimuth=azimuth, theta_x=theta_x, theta_y=theta_y) | |
|
1204 | 1230 | dataOut.data_output = dataOut.data_output.T |
|
1205 | 1231 | dataOut.flagNoData = False |
|
1206 | 1232 | self.__buffer = None |
@@ -1277,25 +1303,26 class EWDriftsEstimation(Operation): | |||
|
1277 | 1303 | |
|
1278 | 1304 | class NonSpecularMeteorDetection(Operation): |
|
1279 | 1305 | |
|
1280 | def run(self, mode, SNRthresh=8, phaseDerThresh=0.5, cohThresh=0.8, allData = False): | |
|
1281 |
data_acf = |
|
|
1282 |
data_ccf = |
|
|
1306 | def run(self, dataOut, mode, SNRthresh=8, phaseDerThresh=0.5, cohThresh=0.8, allData = False): | |
|
1307 | data_acf = dataOut.data_pre[0] | |
|
1308 | data_ccf = dataOut.data_pre[1] | |
|
1309 | pairsList = dataOut.groupList[1] | |
|
1283 | 1310 | |
|
1284 |
lamb = |
|
|
1285 |
tSamp = |
|
|
1286 |
paramInterval = |
|
|
1311 | lamb = dataOut.C/dataOut.frequency | |
|
1312 | tSamp = dataOut.ippSeconds*dataOut.nCohInt | |
|
1313 | paramInterval = dataOut.paramInterval | |
|
1287 | 1314 | |
|
1288 | 1315 | nChannels = data_acf.shape[0] |
|
1289 | 1316 | nLags = data_acf.shape[1] |
|
1290 | 1317 | nProfiles = data_acf.shape[2] |
|
1291 |
nHeights = |
|
|
1292 |
nCohInt = |
|
|
1293 |
sec = numpy.round(nProfiles/ |
|
|
1294 |
heightList = |
|
|
1295 |
ippSeconds = |
|
|
1296 |
utctime = |
|
|
1318 | nHeights = dataOut.nHeights | |
|
1319 | nCohInt = dataOut.nCohInt | |
|
1320 | sec = numpy.round(nProfiles/dataOut.paramInterval) | |
|
1321 | heightList = dataOut.heightList | |
|
1322 | ippSeconds = dataOut.ippSeconds*dataOut.nCohInt*dataOut.nAvg | |
|
1323 | utctime = dataOut.utctime | |
|
1297 | 1324 | |
|
1298 |
|
|
|
1325 | dataOut.abscissaList = numpy.arange(0,paramInterval+ippSeconds,ippSeconds) | |
|
1299 | 1326 | |
|
1300 | 1327 | #------------------------ SNR -------------------------------------- |
|
1301 | 1328 | power = data_acf[:,0,:,:].real |
@@ -1308,6 +1335,7 class NonSpecularMeteorDetection(Operation): | |||
|
1308 | 1335 | SNRdB = 10*numpy.log10(SNR) |
|
1309 | 1336 | |
|
1310 | 1337 | if mode == 'SA': |
|
1338 | dataOut.groupList = dataOut.groupList[1] | |
|
1311 | 1339 | nPairs = data_ccf.shape[0] |
|
1312 | 1340 | #---------------------- Coherence and Phase -------------------------- |
|
1313 | 1341 | phase = numpy.zeros(data_ccf[:,0,:,:].shape) |
@@ -1315,8 +1343,8 class NonSpecularMeteorDetection(Operation): | |||
|
1315 | 1343 | coh1 = numpy.zeros(data_ccf[:,0,:,:].shape) |
|
1316 | 1344 | |
|
1317 | 1345 | for p in range(nPairs): |
|
1318 |
ch0 = |
|
|
1319 |
ch1 = |
|
|
1346 | ch0 = pairsList[p][0] | |
|
1347 | ch1 = pairsList[p][1] | |
|
1320 | 1348 | ccf = data_ccf[p,0,:,:]/numpy.sqrt(data_acf[ch0,0,:,:]*data_acf[ch1,0,:,:]) |
|
1321 | 1349 | phase[p,:,:] = ndimage.median_filter(numpy.angle(ccf), size = (5,1)) #median filter |
|
1322 | 1350 | # phase1[p,:,:] = numpy.angle(ccf) #median filter |
@@ -1388,16 +1416,18 class NonSpecularMeteorDetection(Operation): | |||
|
1388 | 1416 | data_param[:,6:] = phase[:,tmet,hmet].T |
|
1389 | 1417 | |
|
1390 | 1418 | elif mode == 'DBS': |
|
1391 |
|
|
|
1419 | dataOut.groupList = numpy.arange(nChannels) | |
|
1392 | 1420 | |
|
1393 | 1421 | #Radial Velocities |
|
1394 |
|
|
|
1395 | phase = ndimage.median_filter(numpy.angle(data_acf[:,1,:,:]), size = (1,5,1)) | |
|
1422 | phase = numpy.angle(data_acf[:,1,:,:]) | |
|
1423 | # phase = ndimage.median_filter(numpy.angle(data_acf[:,1,:,:]), size = (1,5,1)) | |
|
1396 | 1424 | velRad = phase*lamb/(4*numpy.pi*tSamp) |
|
1397 | 1425 | |
|
1398 | 1426 | #Spectral width |
|
1399 | acf1 = ndimage.median_filter(numpy.abs(data_acf[:,1,:,:]), size = (1,5,1)) | |
|
1400 | acf2 = ndimage.median_filter(numpy.abs(data_acf[:,2,:,:]), size = (1,5,1)) | |
|
1427 | # acf1 = ndimage.median_filter(numpy.abs(data_acf[:,1,:,:]), size = (1,5,1)) | |
|
1428 | # acf2 = ndimage.median_filter(numpy.abs(data_acf[:,2,:,:]), size = (1,5,1)) | |
|
1429 | acf1 = data_acf[:,1,:,:] | |
|
1430 | acf2 = data_acf[:,2,:,:] | |
|
1401 | 1431 | |
|
1402 | 1432 | spcWidth = (lamb/(2*numpy.sqrt(6)*numpy.pi*tSamp))*numpy.sqrt(numpy.log(acf1/acf2)) |
|
1403 | 1433 | # velRad = ndimage.median_filter(velRad, size = (1,5,1)) |
@@ -1409,7 +1439,7 class NonSpecularMeteorDetection(Operation): | |||
|
1409 | 1439 | boolMet1 = ndimage.median_filter(boolMet1, size=(1,5,5)) |
|
1410 | 1440 | |
|
1411 | 1441 | #Radial velocity |
|
1412 |
boolMet2 = numpy.abs(velRad) < |
|
|
1442 | boolMet2 = numpy.abs(velRad) < 20 | |
|
1413 | 1443 | boolMet2 = ndimage.median_filter(boolMet2, (1,5,5)) |
|
1414 | 1444 | |
|
1415 | 1445 | #Spectral Width |
@@ -1436,9 +1466,9 class NonSpecularMeteorDetection(Operation): | |||
|
1436 | 1466 | |
|
1437 | 1467 | # self.dataOut.data_param = data_int |
|
1438 | 1468 | if len(data_param) == 0: |
|
1439 |
|
|
|
1469 | dataOut.flagNoData = True | |
|
1440 | 1470 | else: |
|
1441 |
|
|
|
1471 | dataOut.data_param = data_param | |
|
1442 | 1472 | |
|
1443 | 1473 | def __erase_small(self, binArray, threshX, threshY): |
|
1444 | 1474 | labarray, numfeat = ndimage.measurements.label(binArray) |
@@ -2245,10 +2275,10 class SMPhaseCalibration(Operation): | |||
|
2245 | 2275 | |
|
2246 | 2276 | pairi = pairs[i] |
|
2247 | 2277 | |
|
2248 |
phip3 = phases[:,pairi[ |
|
|
2249 |
d3 = d[pairi[ |
|
|
2250 |
phip2 = phases[:,pairi[ |
|
|
2251 |
d2 = d[pairi[ |
|
|
2278 | phip3 = phases[:,pairi[0]] | |
|
2279 | d3 = d[pairi[0]] | |
|
2280 | phip2 = phases[:,pairi[1]] | |
|
2281 | d2 = d[pairi[1]] | |
|
2252 | 2282 | #Calculating gamma |
|
2253 | 2283 | # jdcos = alp1/(k*d1) |
|
2254 | 2284 | # jgamma = numpy.angle(numpy.exp(1j*(d0*alp1/d1 - alp0))) |
@@ -2261,7 +2291,7 class SMPhaseCalibration(Operation): | |||
|
2261 | 2291 | jgammaArray = numpy.hstack((jgamma,jgamma+0.5*numpy.pi,jgamma-0.5*numpy.pi)) |
|
2262 | 2292 | |
|
2263 | 2293 | #Histogram |
|
2264 |
nBins = 64 |
|
|
2294 | nBins = 64 | |
|
2265 | 2295 | rmin = -0.5*numpy.pi |
|
2266 | 2296 | rmax = 0.5*numpy.pi |
|
2267 | 2297 | phaseHisto = numpy.histogram(jgammaArray, bins=nBins, range=(rmin,rmax)) |
@@ -2303,15 +2333,15 class SMPhaseCalibration(Operation): | |||
|
2303 | 2333 | def __getPhases(self, azimuth, h, pairsList, d, gammas, meteorsArray): |
|
2304 | 2334 | meteorOps = SMOperations() |
|
2305 | 2335 | nchan = 4 |
|
2306 | pairx = pairsList[0] | |
|
2307 | pairy = pairsList[1] | |
|
2336 | pairx = pairsList[0] #x es 0 | |
|
2337 | pairy = pairsList[1] #y es 1 | |
|
2308 | 2338 | center_xangle = 0 |
|
2309 | 2339 | center_yangle = 0 |
|
2310 | 2340 | range_angle = numpy.array([10*numpy.pi,numpy.pi,numpy.pi/2,numpy.pi/4]) |
|
2311 | 2341 | ntimes = len(range_angle) |
|
2312 | 2342 | |
|
2313 |
nstepsx = 20 |
|
|
2314 |
nstepsy = 20 |
|
|
2343 | nstepsx = 20 | |
|
2344 | nstepsy = 20 | |
|
2315 | 2345 | |
|
2316 | 2346 | for iz in range(ntimes): |
|
2317 | 2347 | min_xangle = -range_angle[iz]/2 + center_xangle |
@@ -2331,14 +2361,28 class SMPhaseCalibration(Operation): | |||
|
2331 | 2361 | # Iterations looking for the offset |
|
2332 | 2362 | for iy in range(int(nstepsy)): |
|
2333 | 2363 | for ix in range(int(nstepsx)): |
|
2334 |
|
|
|
2335 | jph[pairy[0]] = -gammas[1] - alpha_y[iy]*d[pairy[1]]/d[pairy[0]] | |
|
2336 | ||
|
2337 |
|
|
|
2338 | jph[pairx[0]] = -gammas[0] - alpha_x[ix]*d[pairx[1]]/d[pairx[0]] | |
|
2339 | ||
|
2364 | d3 = d[pairsList[1][0]] | |
|
2365 | d2 = d[pairsList[1][1]] | |
|
2366 | d5 = d[pairsList[0][0]] | |
|
2367 | d4 = d[pairsList[0][1]] | |
|
2368 | ||
|
2369 | alp2 = alpha_y[iy] #gamma 1 | |
|
2370 | alp4 = alpha_x[ix] #gamma 0 | |
|
2371 | ||
|
2372 | alp3 = -alp2*d3/d2 - gammas[1] | |
|
2373 | alp5 = -alp4*d5/d4 - gammas[0] | |
|
2374 | # jph[pairy[1]] = alpha_y[iy] | |
|
2375 | # jph[pairy[0]] = -gammas[1] - alpha_y[iy]*d[pairy[1]]/d[pairy[0]] | |
|
2376 | ||
|
2377 | # jph[pairx[1]] = alpha_x[ix] | |
|
2378 | # jph[pairx[0]] = -gammas[0] - alpha_x[ix]*d[pairx[1]]/d[pairx[0]] | |
|
2379 | jph[pairsList[0][1]] = alp4 | |
|
2380 | jph[pairsList[0][0]] = alp5 | |
|
2381 | jph[pairsList[1][0]] = alp3 | |
|
2382 | jph[pairsList[1][1]] = alp2 | |
|
2340 | 2383 | jph_array[:,ix,iy] = jph |
|
2341 | ||
|
2384 | # d = [2.0,2.5,2.5,2.0] | |
|
2385 | #falta chequear si va a leer bien los meteoros | |
|
2342 | 2386 | meteorsArray1 = meteorOps.getMeteorParams(meteorsArray, azimuth, h, pairsList, d, jph) |
|
2343 | 2387 | error = meteorsArray1[:,-1] |
|
2344 | 2388 | ind1 = numpy.where(error==0)[0] |
@@ -2387,7 +2431,8 class SMPhaseCalibration(Operation): | |||
|
2387 | 2431 | k = 2*numpy.pi/lamb |
|
2388 | 2432 | azimuth = 0 |
|
2389 | 2433 | h = (hmin, hmax) |
|
2390 | pairs = ((0,1),(2,3)) | |
|
2434 | # pairs = ((0,1),(2,3)) #Estrella | |
|
2435 | # pairs = ((1,0),(2,3)) #T | |
|
2391 | 2436 | |
|
2392 | 2437 | if channelPositions is None: |
|
2393 | 2438 | # channelPositions = [(2.5,0), (0,2.5), (0,0), (0,4.5), (-2,0)] #T |
@@ -2395,6 +2440,17 class SMPhaseCalibration(Operation): | |||
|
2395 | 2440 | meteorOps = SMOperations() |
|
2396 | 2441 | pairslist0, distances = meteorOps.getPhasePairs(channelPositions) |
|
2397 | 2442 | |
|
2443 | #Checking correct order of pairs | |
|
2444 | pairs = [] | |
|
2445 | if distances[1] > distances[0]: | |
|
2446 | pairs.append((1,0)) | |
|
2447 | else: | |
|
2448 | pairs.append((0,1)) | |
|
2449 | ||
|
2450 | if distances[3] > distances[2]: | |
|
2451 | pairs.append((3,2)) | |
|
2452 | else: | |
|
2453 | pairs.append((2,3)) | |
|
2398 | 2454 | # distances1 = [-distances[0]*lamb, distances[1]*lamb, -distances[2]*lamb, distances[3]*lamb] |
|
2399 | 2455 | |
|
2400 | 2456 | meteorsArray = self.__buffer |
@@ -2546,7 +2602,7 class SMOperations(): | |||
|
2546 | 2602 | hCorr = hi[ind_h, :] |
|
2547 | 2603 | ind_hCorr = numpy.where(numpy.logical_and(hi > minHeight, hi < maxHeight)) |
|
2548 | 2604 | |
|
2549 | hCorr = hi[ind_hCorr] | |
|
2605 | hCorr = hi[ind_hCorr][:len(ind_h)] | |
|
2550 | 2606 | heights[ind_h] = hCorr |
|
2551 | 2607 | |
|
2552 | 2608 | #Setting Error |
@@ -1,9 +1,11 | |||
|
1 | 1 | import sys |
|
2 | 2 | import numpy |
|
3 | from profilehooks import profile | |
|
3 | 4 | from scipy import interpolate |
|
4 | ||
|
5 | from schainpy import cSchain | |
|
5 | 6 | from jroproc_base import ProcessingUnit, Operation |
|
6 | 7 | from schainpy.model.data.jrodata import Voltage |
|
8 | from time import time | |
|
7 | 9 | |
|
8 | 10 | class VoltageProc(ProcessingUnit): |
|
9 | 11 | |
@@ -332,7 +334,6 class CohInt(Operation): | |||
|
332 | 334 | |
|
333 | 335 | n = None |
|
334 | 336 | |
|
335 | ||
|
336 | 337 | def __init__(self, **kwargs): |
|
337 | 338 | |
|
338 | 339 | Operation.__init__(self, **kwargs) |
@@ -348,7 +349,6 class CohInt(Operation): | |||
|
348 | 349 | n : Number of coherent integrations |
|
349 | 350 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
350 | 351 | overlapping : |
|
351 | ||
|
352 | 352 | """ |
|
353 | 353 | |
|
354 | 354 | self.__initime = None |
@@ -548,7 +548,6 class Decoder(Operation): | |||
|
548 | 548 | nCode = None |
|
549 | 549 | nBaud = None |
|
550 | 550 | |
|
551 | ||
|
552 | 551 | def __init__(self, **kwargs): |
|
553 | 552 | |
|
554 | 553 | Operation.__init__(self, **kwargs) |
@@ -624,6 +623,13 class Decoder(Operation): | |||
|
624 | 623 | |
|
625 | 624 | return self.datadecTime |
|
626 | 625 | |
|
626 | #@profile | |
|
627 | def oldCorrelate(self, i, data, code_block): | |
|
628 | profilesList = xrange(self.__nProfiles) | |
|
629 | for j in profilesList: | |
|
630 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] | |
|
631 | ||
|
632 | #@profile | |
|
627 | 633 | def __convolutionByBlockInTime(self, data): |
|
628 | 634 | |
|
629 | 635 | repetitions = self.__nProfiles / self.nCode |
@@ -631,13 +637,28 class Decoder(Operation): | |||
|
631 | 637 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) |
|
632 | 638 | junk = junk.flatten() |
|
633 | 639 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) |
|
640 | profilesList = xrange(self.__nProfiles) | |
|
634 | 641 | |
|
642 | # def toVectorize(a,b): | |
|
643 | # return numpy.correlate(a,b, mode='full') | |
|
644 | # vectorized = numpy.vectorize(toVectorize, signature='(n),(m)->(k)') | |
|
635 | 645 | for i in range(self.__nChannels): |
|
636 | for j in range(self.__nProfiles): | |
|
646 | # self.datadecTime[i,:,:] = numpy.array([numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] for j in profilesList ]) | |
|
647 | # def func(i, j): | |
|
648 | # self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] | |
|
649 | # map(lambda j: func(i, j), range(self.__nProfiles)) | |
|
650 | #print data[i,:,:].shape | |
|
651 | # self.datadecTime[i,:,:] = vectorized(data[i,:,:], code_block[:,:])[:,self.nBaud-1:] | |
|
652 | for j in profilesList: | |
|
637 | 653 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] |
|
638 | ||
|
654 | # print data[i,:,:] | |
|
655 | # print cSchain.correlateByBlock(data[i,:,:], code_block, 2) | |
|
656 | # self.datadecTime[i,:,:] = cSchain.correlateByBlock(data[i,:,:], code_block, 2) | |
|
657 | # print self.datadecTime[i,:,:] | |
|
658 | #print self.datadecTime[i,:,:].shape | |
|
639 | 659 | return self.datadecTime |
|
640 | 660 | |
|
661 | ||
|
641 | 662 | def __convolutionByBlockInFreq(self, data): |
|
642 | 663 | |
|
643 | 664 | raise NotImplementedError, "Decoder by frequency fro Blocks not implemented" |
@@ -653,6 +674,7 class Decoder(Operation): | |||
|
653 | 674 | |
|
654 | 675 | return data |
|
655 | 676 | |
|
677 | ||
|
656 | 678 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): |
|
657 | 679 | |
|
658 | 680 | if dataOut.flagDecodeData: |
@@ -682,7 +704,9 class Decoder(Operation): | |||
|
682 | 704 | print "Fail decoding: Code is not defined." |
|
683 | 705 | return |
|
684 | 706 | |
|
707 | self.__nProfiles = dataOut.nProfiles | |
|
685 | 708 | datadec = None |
|
709 | ||
|
686 | 710 | if mode == 3: |
|
687 | 711 | mode = 0 |
|
688 | 712 | |
@@ -1085,7 +1109,6 class SplitProfiles(Operation): | |||
|
1085 | 1109 | dataOut.ippSeconds /= n |
|
1086 | 1110 | |
|
1087 | 1111 | class CombineProfiles(Operation): |
|
1088 | ||
|
1089 | 1112 | def __init__(self, **kwargs): |
|
1090 | 1113 | |
|
1091 | 1114 | Operation.__init__(self, **kwargs) |
@@ -619,6 +619,7 class SendToServer(ProcessingUnit): | |||
|
619 | 619 | filenameList = glob.glob1(thisFolder, '*%s' %self.ext) |
|
620 | 620 | |
|
621 | 621 | if len(filenameList) < 1: |
|
622 | ||
|
622 | 623 | continue |
|
623 | 624 | |
|
624 | 625 | for thisFile in filenameList: |
@@ -1,11 +1,6 | |||
|
1 | 1 | |
|
2 | 2 | import os, sys |
|
3 | 3 | |
|
4 | path = os.path.split(os.getcwd())[0] | |
|
5 | path = os.path.split(path)[0] | |
|
6 | ||
|
7 | sys.path.insert(0, path) | |
|
8 | ||
|
9 | 4 | from schainpy.controller import Project |
|
10 | 5 | |
|
11 | 6 | controllerObj = Project() |
@@ -18,7 +13,7 controllerObj.setup(id = '002', name='script02', description="JASMET Meteor Dete | |||
|
18 | 13 | # path = '/mnt/jars/2016_08/NOCHE' |
|
19 | 14 | # path = '/media/joscanoa/DATA_JASMET/JASMET/2016_08/DIA' |
|
20 | 15 | # path = '/media/joscanoa/DATA_JASMET/JASMET/2016_08/NOCHE' |
|
21 | path = '/media/nanosat/NewVolumen/JASMET/2016_08/DIA' | |
|
16 | path = '/home/nanosat/data/jasmet' | |
|
22 | 17 | |
|
23 | 18 | #Path para los graficos |
|
24 | 19 | pathfig = os.path.join(os.environ['HOME'],'Pictures/JASMET30/201608/graphics') |
@@ -27,8 +22,8 pathfig = os.path.join(os.environ['HOME'],'Pictures/JASMET30/201608/graphics') | |||
|
27 | 22 | pathfile = os.path.join(os.environ['HOME'],'Pictures/JASMET30/201608/meteor') |
|
28 | 23 | |
|
29 | 24 | #Fechas para busqueda de archivos |
|
30 |
startDate = '201 |
|
|
31 |
endDate = '201 |
|
|
25 | startDate = '2010/08/29' | |
|
26 | endDate = '2017/09/11' | |
|
32 | 27 | #Horas para busqueda de archivos |
|
33 | 28 | startTime = '00:00:00' |
|
34 | 29 | endTime = '23:59:59' |
@@ -60,15 +55,23 opObj00.addParameter(name='channelList', value='0,1,2,3,4', format='intlist') | |||
|
60 | 55 | opObj01 = procUnitConfObj0.addOperation(name='setRadarFrequency') |
|
61 | 56 | opObj01.addParameter(name='frequency', value='30.e6', format='float') |
|
62 | 57 | |
|
63 | opObj01 = procUnitConfObj0.addOperation(name='interpolateHeights') | |
|
64 | opObj01.addParameter(name='topLim', value='73', format='int') | |
|
65 | opObj01.addParameter(name='botLim', value='71', format='int') | |
|
58 | # opObj01 = procUnitConfObj0.addOperation(name='interpolateHeights') | |
|
59 | # opObj01.addParameter(name='topLim', value='73', format='int') | |
|
60 | # opObj01.addParameter(name='botLim', value='71', format='int') | |
|
66 | 61 | |
|
67 | 62 | opObj02 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
68 | 63 | |
|
69 | 64 | opObj03 = procUnitConfObj0.addOperation(name='CohInt', optype='other') |
|
70 | 65 | opObj03.addParameter(name='n', value='2', format='int') |
|
71 | 66 | |
|
67 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
|
68 | opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
|
69 | opObj11.addParameter(name='id', value='237', format='int') | |
|
70 | opObj11.addParameter(name='xmin', value='9.0', format='float') | |
|
71 | opObj11.addParameter(name='xmax', value='16.0', format='float') | |
|
72 | opObj11.addParameter(name='zmin', value='15.0', format='float') | |
|
73 | opObj11.addParameter(name='zmax', value='50.0', format='float') | |
|
74 | ||
|
72 | 75 | #--------------------------- Parameters Processing Unit ------------------------------------ |
|
73 | 76 | |
|
74 | 77 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj0.getId()) |
@@ -87,11 +90,6 opObj12.addParameter(name='mode',value='2',format='int') | |||
|
87 | 90 | |
|
88 | 91 | #-------------------------------------------------------------------------------------------------- |
|
89 | 92 | |
|
90 | print "Escribiendo el archivo XML" | |
|
91 | controllerObj.writeXml("JASMET02.xml") | |
|
92 | print "Leyendo el archivo XML" | |
|
93 | controllerObj.readXml("JASMET02.xml") | |
|
93 | controllerObj.start() | |
|
94 | ||
|
94 | 95 | |
|
95 | controllerObj.createObjects() | |
|
96 | controllerObj.connectObjects() | |
|
97 | controllerObj.run() No newline at end of file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -1,1 +1,5 | |||
|
1 | <<<<<<< HEAD | |
|
1 | 2 | <Project description="Claire" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/media/nanosat/0BDE10E00BDE10E0/CLAIRE" /><Parameter format="date" id="2113" name="startDate" value="2017/07/26" /><Parameter format="date" id="2114" name="endDate" value="2017/07/26" /><Parameter format="time" id="2115" name="startTime" value="15:00:00" /><Parameter format="time" id="2116" name="endTime" value="16:00:00" /><Parameter format="int" id="2117" name="delay" value="30" /><Parameter format="int" id="2118" name="walk" value="1" /><Parameter format="int" id="2119" name="online" value="0" /></Operation><Operation id="212" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="22" inputId="21" name="VoltageProc"><Operation id="221" name="run" priority="1" type="self" /></ProcUnit><ProcUnit datatype="SpectraProc" id="23" inputId="22" name="SpectraProc"><Operation id="231" name="run" priority="1" type="self"><Parameter format="int" id="2311" name="nFFTPoints" value="128" /><Parameter format="int" id="2312" name="nProfiles" value="128" /><Parameter format="pairslist" id="2313" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="232" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="2321" name="frequency" value="445000000.0" /></Operation><Operation id="233" name="IncohInt" priority="3" type="other"><Parameter format="float" id="2331" name="timeInterval" value="128" /></Operation><Operation id="234" name="removeDC" priority="4" type="self"><Parameter format="int" id="2341" name="mode" value="2" /></Operation><Operation id="235" name="SpectraPlot" priority="5" type="external"><Parameter format="int" id="2351" name="id" value="235" /><Parameter format="str" id="2352" name="wintitle" value="SpectraPlot" /><Parameter format="str" id="2353" name="xaxis" value="frequency" /><Parameter format="float" id="2354" name="zmin" value="15.0" /><Parameter format="float" id="2355" name="zmax" value="50.0" /><Parameter format="int" id="2356" name="exp_code" value="21" /><Parameter format="int" id="2357" name="ftp_wei" value="0" /><Parameter format="int" id="2358" name="plot_pos" value="0" /></Operation></ProcUnit></Project> |
|
3 | ======= | |
|
4 | <Project description="Claire" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/media/nanosat/0BDE10E00BDE10E0/CLAIRE" /><Parameter format="date" id="2113" name="startDate" value="2017/07/26" /><Parameter format="date" id="2114" name="endDate" value="2017/07/26" /><Parameter format="time" id="2115" name="startTime" value="15:00:00" /><Parameter format="time" id="2116" name="endTime" value="16:00:00" /><Parameter format="int" id="2118" name="delay" value="30" /><Parameter format="int" id="2119" name="walk" value="1" /><Parameter format="int" id="2120" name="online" value="0" /></Operation><Operation id="212" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="22" inputId="21" name="VoltageProc"><Operation id="221" name="run" priority="1" type="self" /></ProcUnit><ProcUnit datatype="SpectraProc" id="23" inputId="22" name="SpectraProc"><Operation id="231" name="run" priority="1" type="self"><Parameter format="int" id="2311" name="nFFTPoints" value="128" /><Parameter format="int" id="2312" name="nProfiles" value="128" /><Parameter format="pairslist" id="2313" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="232" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="2321" name="frequency" value="445000000.0" /></Operation><Operation id="233" name="IncohInt" priority="3" type="other"><Parameter format="float" id="2331" name="timeInterval" value="128" /></Operation><Operation id="234" name="removeDC" priority="4" type="self"><Parameter format="int" id="2341" name="mode" value="2" /></Operation><Operation id="235" name="RTIPlot" priority="5" type="other"><Parameter format="int" id="2351" name="id" value="237" /><Parameter format="float" id="2352" name="xmin" value="9.0" /><Parameter format="float" id="2353" name="xmax" value="16.0" /><Parameter format="float" id="2354" name="zmin" value="15.0" /><Parameter format="float" id="2355" name="zmax" value="50.0" /></Operation></ProcUnit></Project> | |
|
5 | >>>>>>> v2.3 |
@@ -1,4 +1,4 | |||
|
1 |
""" |
|
|
1 | """ | |
|
2 | 2 | SCHAINPY - LOG |
|
3 | 3 | Simple helper for log standarization |
|
4 | 4 | Usage: |
@@ -14,32 +14,46 SCHAINPY - LOG | |||
|
14 | 14 | [NEVER GONNA] - give you up |
|
15 | 15 | with color red as background and white as foreground. |
|
16 | 16 | """ |
|
17 | ||
|
17 | import os | |
|
18 | import sys | |
|
18 | 19 | import click |
|
19 | 20 | |
|
20 | ||
|
21 | 21 | def warning(message): |
|
22 | 22 | click.echo(click.style('[WARNING] - ' + message, fg='yellow')) |
|
23 | pass | |
|
24 | 23 | |
|
25 | 24 | |
|
26 | 25 | def error(message): |
|
27 | click.echo(click.style('[ERROR] - ' + message, fg='red')) | |
|
28 | pass | |
|
26 | click.echo(click.style('[ERROR] - ' + message, fg='red', bg='black')) | |
|
29 | 27 | |
|
30 | 28 | |
|
31 | 29 | def success(message): |
|
32 | 30 | click.echo(click.style(message, fg='green')) |
|
33 | pass | |
|
34 | 31 | |
|
35 | 32 | |
|
36 | def log(message): | |
|
37 |
click.echo('[ |
|
|
38 | pass | |
|
39 | ||
|
33 | def log(message, topic='LOG'): | |
|
34 | click.echo('[{}] - {}'.format(topic, message)) | |
|
40 | 35 | |
|
41 | 36 | def makelogger(topic, bg='reset', fg='reset'): |
|
42 | 37 | def func(message): |
|
43 | 38 | click.echo(click.style('[{}] - '.format(topic.upper()) + message, |
|
44 | 39 | bg=bg, fg=fg)) |
|
45 | 40 | return func |
|
41 | ||
|
42 | class LoggerForFile(): | |
|
43 | def __init__(self, filename): | |
|
44 | self.old_stdout=sys.stdout | |
|
45 | cwd = os.getcwd() | |
|
46 | self.log_file = open(os.path.join(cwd, filename), 'w+') | |
|
47 | def write(self, text): | |
|
48 | text = text.rstrip() | |
|
49 | if not text: | |
|
50 | return | |
|
51 | self.log_file.write(text + '\n') | |
|
52 | self.old_stdout.write(text + '\n') | |
|
53 | def flush(self): | |
|
54 | self.old_stdout.flush() | |
|
55 | ||
|
56 | def logToFile(filename='log.log'): | |
|
57 | logger = LoggerForFile(filename) | |
|
58 | sys.stdout = logger | |
|
59 |
|
1 | NO CONTENT: file renamed from schainpy/trash to schainpy/utils/trash |
@@ -1,9 +1,8 | |||
|
1 | """. | |
|
2 | ||
|
1 | ''' | |
|
3 | 2 | Created on Jul 16, 2014 |
|
4 | 3 | |
|
5 | 4 | @author: Miguel Urco |
|
6 | """ | |
|
5 | ''' | |
|
7 | 6 | |
|
8 | 7 | from setuptools import setup, Extension |
|
9 | 8 | from setuptools.command.build_ext import build_ext as _build_ext |
@@ -43,11 +42,15 setup(name="schainpy", | |||
|
43 | 42 |
|
|
44 | 43 |
|
|
45 | 44 |
|
|
46 |
|
|
|
47 | 'schainpy/scripts/schain'], | |
|
45 | scripts =['schainpy/gui/schainGUI'], | |
|
48 | 46 |
|
|
49 | 47 |
|
|
50 | 48 |
|
|
49 | entry_points={ | |
|
50 | 'console_scripts': [ | |
|
51 | 'schain = schaincli.cli:main', | |
|
52 | ], | |
|
53 | }, | |
|
51 | 54 |
|
|
52 | 55 |
|
|
53 | 56 |
|
@@ -55,7 +58,12 setup(name="schainpy", | |||
|
55 | 58 | "h5py >= 2.2.1", |
|
56 | 59 | "matplotlib >= 1.4.2", |
|
57 | 60 | "pyfits >= 3.4", |
|
61 | "paramiko >= 2.1.2", | |
|
58 | 62 | "paho-mqtt >= 1.2", |
|
59 | 63 | "zmq", |
|
64 | "fuzzywuzzy", | |
|
65 | "click", | |
|
66 | "colorama", | |
|
67 | "python-Levenshtein" | |
|
60 | 68 |
|
|
61 | 69 |
|
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now