@@ -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 |
@@ -207,8 +256,8 class ParameterConf(): | |||
|
207 | 256 | |
|
208 | 257 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
209 | 258 | |
|
210 | class OperationConf(): | |
|
211 | ||
|
259 | class OperationConf(): | |
|
260 | ||
|
212 | 261 | id = None |
|
213 | 262 | name = None |
|
214 | 263 | priority = 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 | # |
@@ -673,9 +721,9 class ReadUnitConf(ProcUnitConf): | |||
|
673 | 721 | def getElementName(self): |
|
674 | 722 | |
|
675 | 723 | return self.ELEMENTNAME |
|
676 | ||
|
677 | def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs): | |
|
678 | 724 | |
|
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" |
@@ -811,9 +859,8 class ReadUnitConf(ProcUnitConf): | |||
|
811 | 859 | self.endDate = opConfObj.getParameterValue('endDate') |
|
812 | 860 | self.startTime = opConfObj.getParameterValue('startTime') |
|
813 | 861 | self.endTime = opConfObj.getParameterValue('endTime') |
|
814 | ||
|
815 | class Project(): | |
|
816 | ||
|
862 | ||
|
863 | class Project(Process): | |
|
817 | 864 | id = None |
|
818 | 865 | name = None |
|
819 | 866 | description = None |
@@ -824,13 +871,14 class Project(): | |||
|
824 | 871 | ELEMENTNAME = 'Project' |
|
825 | 872 | |
|
826 | 873 | plotterQueue = None |
|
827 | ||
|
828 | def __init__(self, plotter_queue=None): | |
|
829 | ||
|
874 | ||
|
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: |
@@ -1055,9 +1102,9 class Project(): | |||
|
1055 | 1102 | def printattr(self): |
|
1056 | 1103 | |
|
1057 | 1104 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
1058 | self.name, | |
|
1059 | self.description) | |
|
1060 | ||
|
1105 | self.name, | |
|
1106 | self.description) | |
|
1107 | ||
|
1061 | 1108 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
1062 | 1109 | procUnitConfObj.printattr() |
|
1063 | 1110 | |
@@ -1176,9 +1223,14 class Project(): | |||
|
1176 | 1223 | def useExternalPlotter(self): |
|
1177 | 1224 | |
|
1178 | 1225 | raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class" |
|
1179 | ||
|
1180 | def run(self): | |
|
1226 | ||
|
1227 | ||
|
1228 | def run(self, filename=None): | |
|
1181 | 1229 | |
|
1230 | # self.writeXml(filename) | |
|
1231 | self.createObjects() | |
|
1232 | self.connectObjects() | |
|
1233 | ||
|
1182 | 1234 | |
|
1183 | 1235 | print "*"*60 |
|
1184 | 1236 | print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__ |
@@ -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 |
@@ -9,4 +9,4 from data import * | |||
|
9 | 9 | from io import * |
|
10 | 10 | from proc import * |
|
11 | 11 | from graphics import * |
|
12 |
from utils import * |
|
|
12 | from utils import * No newline at end of 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] |
@@ -412,7 +412,7 class RadarControllerHeader(Header): | |||
|
412 | 412 | self.length += self.nBaud.nbytes |
|
413 | 413 | except Exception, e: |
|
414 | 414 | print "RadarControllerHeader: " + str(e) |
|
415 | return 0 | |
|
415 | return 0 | |
|
416 | 416 | code = numpy.empty([self.nCode,self.nBaud],dtype='i1') |
|
417 | 417 | |
|
418 | 418 | for ic in range(self.nCode): |
@@ -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 | ||
|
97 | if self.show: | |
|
98 | self.figure.show() | |
|
99 | ||
|
100 | self.plot() | |
|
101 | plt.tight_layout() | |
|
102 | self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(), | |
|
143 | if self.ind_plt_ch is False : #standard | |
|
144 | if self.show: | |
|
145 | self.figure.show() | |
|
146 | self.plot() | |
|
147 | plt.tight_layout() | |
|
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: |
|
106 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
|
107 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
108 | print 'Saving figure: {}'.format(figname) | |
|
109 | self.figure.savefig(figname) | |
|
183 | if self.ind_plt_ch is False : #standard | |
|
184 | figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE, | |
|
185 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
186 | print 'Saving figure: {}'.format(figname) | |
|
187 | self.figure.savefig(figname) | |
|
188 | else : | |
|
189 | for n, eachfigure in enumerate(self.figurelist): | |
|
190 | #add specific name for each channel in channelList | |
|
191 | figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE, | |
|
192 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S'))) | |
|
193 | ||
|
194 | print 'Saving figure: {}'.format(figname) | |
|
195 | eachfigure.savefig(figname) | |
|
110 | 196 | |
|
111 | self.figure.canvas.draw() | |
|
112 | 197 | |
|
113 | 198 | def plot(self): |
|
114 | 199 | |
@@ -123,7 +208,7 class PlotData(Operation, Process): | |||
|
123 | 208 | receiver = context.socket(zmq.SUB) |
|
124 | 209 | receiver.setsockopt(zmq.SUBSCRIBE, '') |
|
125 | 210 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) |
|
126 | ||
|
211 | ||
|
127 | 212 | if 'server' in self.kwargs['parent']: |
|
128 | 213 | receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) |
|
129 | 214 | else: |
@@ -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,81 +547,184 class PlotRTIData(PlotData): | |||
|
462 | 547 | self.ncols = 1 |
|
463 | 548 | self.nrows = self.dataOut.nChannels |
|
464 | 549 | self.width = 10 |
|
465 | self.height = 2.2*self.nrows if self.nrows<6 else 12 | |
|
550 | #TODO : arreglar la altura de la figura, esta hardcodeada. | |
|
551 | #Se arreglo, testear! | |
|
552 | if self.ind_plt_ch: | |
|
553 | self.height = 3.2#*self.nrows if self.nrows<6 else 12 | |
|
554 | else: | |
|
555 | self.height = 2.2*self.nrows if self.nrows<6 else 12 | |
|
556 | ||
|
557 | ''' | |
|
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: | |
|
472 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
473 | edgecolor='k', | |
|
474 | facecolor='w') | |
|
475 | else: | |
|
476 | self.figure.clf() | |
|
477 | self.axes = [] | |
|
478 | ||
|
479 | for n in range(self.nrows): | |
|
480 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
|
481 | ax.firsttime = True | |
|
482 | self.axes.append(ax) | |
|
483 | ||
|
484 | def plot(self): | |
|
485 | ||
|
486 | self.x = np.array(self.times) | |
|
487 | self.y = self.dataOut.getHeiRange() | |
|
488 | self.z = [] | |
|
489 | ||
|
490 | for ch in range(self.nrows): | |
|
491 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |
|
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 | |
|
573 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
574 | edgecolor='k', | |
|
575 | facecolor='w') | |
|
576 | else: | |
|
577 | self.figure.clf() | |
|
578 | self.axes = [] | |
|
492 | 579 | |
|
493 | self.z = np.array(self.z) | |
|
494 | for n, ax in enumerate(self.axes): | |
|
495 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
496 | xmin = self.min_time | |
|
497 | xmax = xmin+self.xrange*60*60 | |
|
498 | self.zmin = self.zmin if self.zmin else np.min(self.z) | |
|
499 | self.zmax = self.zmax if self.zmax else np.max(self.z) | |
|
500 | if ax.firsttime: | |
|
501 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
|
502 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
|
503 | plot = ax.pcolormesh(x, y, z[n].T, | |
|
504 | vmin=self.zmin, | |
|
505 | vmax=self.zmax, | |
|
506 | cmap=plt.get_cmap(self.colormap) | |
|
507 | ) | |
|
508 | divider = make_axes_locatable(ax) | |
|
509 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
|
510 | self.figure.add_axes(cax) | |
|
511 | plt.colorbar(plot, cax) | |
|
512 | ax.set_ylim(self.ymin, self.ymax) | |
|
513 | 580 | |
|
514 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
|
515 | ax.xaxis.set_major_locator(LinearLocator(6)) | |
|
581 | for n in range(self.nrows): | |
|
582 | ax = self.figure.add_subplot(self.nrows, self.ncols, n+1) | |
|
583 | #ax = self.figure(n+1) | |
|
584 | ax.firsttime = True | |
|
585 | self.axes.append(ax) | |
|
516 | 586 | |
|
517 | ax.set_ylabel(self.ylabel) | |
|
587 | else : #append one figure foreach channel in channelList | |
|
588 | if self.figurelist == None: | |
|
589 | self.figurelist = [] | |
|
590 | for n in range(self.nrows): | |
|
591 | self.figure = plt.figure(figsize=(self.width, self.height), | |
|
592 | edgecolor='k', | |
|
593 | facecolor='w') | |
|
594 | #add always one subplot | |
|
595 | self.figurelist.append(self.figure) | |
|
596 | ||
|
597 | else : # cada dia nuevo limpia el axes, pero mantiene el figure | |
|
598 | for eachfigure in self.figurelist: | |
|
599 | eachfigure.clf() # eliminaria todas las figuras de la lista? | |
|
600 | self.axes = [] | |
|
601 | ||
|
602 | for eachfigure in self.figurelist: | |
|
603 | ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura | |
|
604 | #ax = self.figure(n+1) | |
|
605 | ax.firsttime = True | |
|
606 | #Cada figura tiene un distinto puntero | |
|
607 | self.axes.append(ax) | |
|
608 | #plt.close(eachfigure) | |
|
518 | 609 | |
|
519 | # if self.xmin is None: | |
|
520 | # xmin = self.min_time | |
|
521 | # else: | |
|
522 | # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |
|
523 | # datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |
|
524 | 610 | |
|
525 | ax.set_xlim(xmin, xmax) | |
|
526 | ax.firsttime = False | |
|
527 | else: | |
|
528 | ax.collections.remove(ax.collections[0]) | |
|
529 | ax.set_xlim(xmin, xmax) | |
|
530 | plot = ax.pcolormesh(x, y, z[n].T, | |
|
531 | vmin=self.zmin, | |
|
532 | vmax=self.zmax, | |
|
533 | cmap=plt.get_cmap(self.colormap) | |
|
534 | ) | |
|
535 | ax.set_title('{} {}'.format(self.titles[n], | |
|
536 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
|
537 | size=8) | |
|
611 | def plot(self): | |
|
538 | 612 | |
|
539 | self.saveTime = self.min_time | |
|
613 | if self.ind_plt_ch is False: #standard mode | |
|
614 | self.x = np.array(self.times) | |
|
615 | self.y = self.dataOut.getHeiRange() | |
|
616 | self.z = [] | |
|
617 | ||
|
618 | for ch in range(self.nrows): | |
|
619 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |
|
620 | ||
|
621 | self.z = np.array(self.z) | |
|
622 | for n, ax in enumerate(self.axes): | |
|
623 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
624 | if self.xmin is None: | |
|
625 | xmin = self.min_time | |
|
626 | else: | |
|
627 | xmin = fromtimestamp(int(self.xmin), self.min_time) | |
|
628 | if self.xmax is None: | |
|
629 | xmax = xmin + self.xrange*60*60 | |
|
630 | else: | |
|
631 | xmax = xmin + (self.xmax - self.xmin) * 60 * 60 | |
|
632 | self.zmin = self.zmin if self.zmin else np.min(self.z) | |
|
633 | self.zmax = self.zmax if self.zmax else np.max(self.z) | |
|
634 | if ax.firsttime: | |
|
635 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
|
636 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
|
637 | plot = ax.pcolormesh(x, y, z[n].T, | |
|
638 | vmin=self.zmin, | |
|
639 | vmax=self.zmax, | |
|
640 | cmap=plt.get_cmap(self.colormap) | |
|
641 | ) | |
|
642 | divider = make_axes_locatable(ax) | |
|
643 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
|
644 | self.figure.add_axes(cax) | |
|
645 | plt.colorbar(plot, cax) | |
|
646 | ax.set_ylim(self.ymin, self.ymax) | |
|
647 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
|
648 | ax.xaxis.set_major_locator(LinearLocator(6)) | |
|
649 | ax.set_ylabel(self.ylabel) | |
|
650 | # if self.xmin is None: | |
|
651 | # xmin = self.min_time | |
|
652 | # else: | |
|
653 | # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |
|
654 | # datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |
|
655 | ||
|
656 | ax.set_xlim(xmin, xmax) | |
|
657 | ax.firsttime = False | |
|
658 | else: | |
|
659 | ax.collections.remove(ax.collections[0]) | |
|
660 | ax.set_xlim(xmin, xmax) | |
|
661 | plot = ax.pcolormesh(x, y, z[n].T, | |
|
662 | vmin=self.zmin, | |
|
663 | vmax=self.zmax, | |
|
664 | cmap=plt.get_cmap(self.colormap) | |
|
665 | ) | |
|
666 | ax.set_title('{} {}'.format(self.titles[n], | |
|
667 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
|
668 | size=8) | |
|
669 | ||
|
670 | self.saveTime = self.min_time | |
|
671 | else : | |
|
672 | self.x = np.array(self.times) | |
|
673 | self.y = self.dataOut.getHeiRange() | |
|
674 | self.z = [] | |
|
675 | ||
|
676 | for ch in range(self.nrows): | |
|
677 | self.z.append([self.data[self.CODE][t][ch] for t in self.times]) | |
|
678 | ||
|
679 | self.z = np.array(self.z) | |
|
680 | for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes | |
|
681 | ||
|
682 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
683 | xmin = self.min_time | |
|
684 | xmax = xmin+self.xrange*60*60 | |
|
685 | self.zmin = self.zmin if self.zmin else np.min(self.z) | |
|
686 | self.zmax = self.zmax if self.zmax else np.max(self.z) | |
|
687 | if self.axes[n].firsttime: | |
|
688 | self.ymin = self.ymin if self.ymin else np.nanmin(self.y) | |
|
689 | self.ymax = self.ymax if self.ymax else np.nanmax(self.y) | |
|
690 | plot = self.axes[n].pcolormesh(x, y, z[n].T, | |
|
691 | vmin=self.zmin, | |
|
692 | vmax=self.zmax, | |
|
693 | cmap=plt.get_cmap(self.colormap) | |
|
694 | ) | |
|
695 | divider = make_axes_locatable(self.axes[n]) | |
|
696 | cax = divider.new_horizontal(size='2%', pad=0.05) | |
|
697 | eachfigure.add_axes(cax) | |
|
698 | #self.figure2.add_axes(cax) | |
|
699 | plt.colorbar(plot, cax) | |
|
700 | self.axes[n].set_ylim(self.ymin, self.ymax) | |
|
701 | ||
|
702 | self.axes[n].xaxis.set_major_formatter(FuncFormatter(func)) | |
|
703 | self.axes[n].xaxis.set_major_locator(LinearLocator(6)) | |
|
704 | ||
|
705 | self.axes[n].set_ylabel(self.ylabel) | |
|
706 | ||
|
707 | if self.xmin is None: | |
|
708 | xmin = self.min_time | |
|
709 | else: | |
|
710 | xmin = (datetime.datetime.combine(self.dataOut.datatime.date(), | |
|
711 | datetime.time(self.xmin, 0, 0))-d1970).total_seconds() | |
|
712 | ||
|
713 | self.axes[n].set_xlim(xmin, xmax) | |
|
714 | self.axes[n].firsttime = False | |
|
715 | else: | |
|
716 | self.axes[n].collections.remove(self.axes[n].collections[0]) | |
|
717 | self.axes[n].set_xlim(xmin, xmax) | |
|
718 | plot = self.axes[n].pcolormesh(x, y, z[n].T, | |
|
719 | vmin=self.zmin, | |
|
720 | vmax=self.zmax, | |
|
721 | cmap=plt.get_cmap(self.colormap) | |
|
722 | ) | |
|
723 | self.axes[n].set_title('{} {}'.format(self.titles[n], | |
|
724 | datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')), | |
|
725 | size=8) | |
|
726 | ||
|
727 | self.saveTime = self.min_time | |
|
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 |
@@ -541,8 +541,8 class JRODataIO: | |||
|
541 | 541 | return inspect.getargspec(self.run).args |
|
542 | 542 | |
|
543 | 543 | class JRODataReader(JRODataIO): |
|
544 | ||
|
545 | ||
|
544 | ||
|
545 | firstTime = True | |
|
546 | 546 | online = 0 |
|
547 | 547 | |
|
548 | 548 | realtime = 0 |
@@ -578,8 +578,8 class JRODataReader(JRODataIO): | |||
|
578 | 578 | selBlocksize = None |
|
579 | 579 | |
|
580 | 580 | selBlocktime = None |
|
581 | ||
|
582 | ||
|
581 | ||
|
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 | |
@@ -682,34 +681,35 class JRODataReader(JRODataIO): | |||
|
682 | 681 | print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime()) |
|
683 | 682 | |
|
684 | 683 | self.filenameList = filenameList |
|
685 | self.datetimeList = datetimeList | |
|
686 | ||
|
684 | self.datetimeList = datetimeList | |
|
687 | 685 | return pathList, filenameList |
|
688 | 686 | |
|
689 |
def __searchFilesOnLine(self, path, expLabel |
|
|
690 | ||
|
687 | def __searchFilesOnLine(self, path, expLabel="", ext=None, walk=True, set=None, startDate=None, startTime=None): | |
|
688 | ||
|
691 | 689 |
|
|
692 | Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y | |
|
693 | devuelve el archivo encontrado ademas de otros datos. | |
|
694 | ||
|
695 | Input: | |
|
696 | path : carpeta donde estan contenidos los files que contiene data | |
|
697 | ||
|
698 | expLabel : Nombre del subexperimento (subfolder) | |
|
699 | ||
|
700 |
ext |
|
|
701 | ||
|
702 | walk : Si es habilitado no realiza busquedas dentro de los ubdirectorios (doypath) | |
|
703 | ||
|
704 | Return: | |
|
705 | directory : eL directorio donde esta el file encontrado | |
|
706 | filename : el ultimo file de una determinada carpeta | |
|
707 | year : el anho | |
|
708 | doy : el numero de dia del anho | |
|
709 | set : el set del archivo | |
|
710 | ||
|
711 | ||
|
690 | Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y | |
|
691 | devuelve el archivo encontrado ademas de otros datos. | |
|
692 | ||
|
693 | Input: | |
|
694 | path : carpeta donde estan contenidos los files que contiene data | |
|
695 | ||
|
696 | expLabel : Nombre del subexperimento (subfolder) | |
|
697 | ||
|
698 | ext : extension de los files | |
|
699 | ||
|
700 | walk : Si es habilitado no realiza busquedas dentro de los subdirectorios (doypath) | |
|
701 | ||
|
702 | Return: | |
|
703 | directory : eL directorio donde esta el file encontrado | |
|
704 | filename : el ultimo file de una determinada carpeta | |
|
705 | year : el anho | |
|
706 | doy : el numero de dia del anho | |
|
707 | set : el set del archivo | |
|
708 | ||
|
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 | |
@@ -719,7 +719,7 class JRODataReader(JRODataIO): | |||
|
719 | 719 | fullpath = path |
|
720 | 720 | foldercounter = 0 |
|
721 | 721 | else: |
|
722 | #Filtra solo los directorios | |
|
722 | # Filtra solo los directorios | |
|
723 | 723 | for thisPath in os.listdir(path): |
|
724 | 724 | if not os.path.isdir(os.path.join(path,thisPath)): |
|
725 | 725 | continue |
@@ -755,7 +755,7 class JRODataReader(JRODataIO): | |||
|
755 | 755 | |
|
756 | 756 | year = int( filename[1:5] ) |
|
757 | 757 | doy = int( filename[5:8] ) |
|
758 | set = int( filename[8:11] ) | |
|
758 | set = int( filename[8:11] ) | |
|
759 | 759 | |
|
760 | 760 | return fullpath, foldercounter, filename, year, doy, set |
|
761 | 761 | |
@@ -767,7 +767,7 class JRODataReader(JRODataIO): | |||
|
767 | 767 | idFile += 1 |
|
768 | 768 | if not(idFile < len(self.filenameList)): |
|
769 | 769 | self.flagNoMoreFiles = 1 |
|
770 |
|
|
|
770 | # print "[Reading] No more Files" | |
|
771 | 771 | return 0 |
|
772 | 772 | |
|
773 | 773 | filename = self.filenameList[idFile] |
@@ -785,31 +785,32 class JRODataReader(JRODataIO): | |||
|
785 | 785 | self.fileSize = fileSize |
|
786 | 786 | self.fp = fp |
|
787 | 787 | |
|
788 |
# |
|
|
788 | #print "[Reading] Setting the file: %s"%self.filename | |
|
789 | 789 | |
|
790 | 790 | return 1 |
|
791 | 791 | |
|
792 | 792 | def __setNextFileOnline(self): |
|
793 | 793 | """ |
|
794 | Busca el siguiente file que tenga suficiente data para ser leida, dentro de un folder especifico, si | |
|
795 | no encuentra un file valido espera un tiempo determinado y luego busca en los posibles n files | |
|
796 | siguientes. | |
|
797 | ||
|
798 | Affected: | |
|
799 | self.flagIsNewFile | |
|
800 | self.filename | |
|
801 | self.fileSize | |
|
802 | self.fp | |
|
803 | self.set | |
|
804 | self.flagNoMoreFiles | |
|
805 | ||
|
806 | Return: | |
|
807 | 0 : si luego de una busqueda del siguiente file valido este no pudo ser encontrado | |
|
808 | 1 : si el file fue abierto con exito y esta listo a ser leido | |
|
809 | ||
|
810 | Excepciones: | |
|
811 | Si un determinado file no puede ser abierto | |
|
812 | """ | |
|
794 | Busca el siguiente file que tenga suficiente data para ser leida, dentro de un folder especifico, si | |
|
795 | no encuentra un file valido espera un tiempo determinado y luego busca en los posibles n files | |
|
796 | siguientes. | |
|
797 | ||
|
798 | Affected: | |
|
799 | self.flagIsNewFile | |
|
800 | self.filename | |
|
801 | self.fileSize | |
|
802 | self.fp | |
|
803 | self.set | |
|
804 | self.flagNoMoreFiles | |
|
805 | ||
|
806 | Return: | |
|
807 | 0 : si luego de una busqueda del siguiente file valido este no pudo ser encontrado | |
|
808 | 1 : si el file fue abierto con exito y esta listo a ser leido | |
|
809 | ||
|
810 | Excepciones: | |
|
811 | Si un determinado file no puede ser abierto | |
|
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 | |
@@ -1010,7 +1032,7 class JRODataReader(JRODataIO): | |||
|
1010 | 1032 | if not(self.setNextFile()): |
|
1011 | 1033 | return 0 |
|
1012 | 1034 | else: |
|
1013 | return 1 | |
|
1035 | return 1 | |
|
1014 | 1036 | #if self.server is None: |
|
1015 | 1037 | currentSize = self.fileSize - self.fp.tell() |
|
1016 | 1038 | neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize |
@@ -1042,15 +1064,13 class JRODataReader(JRODataIO): | |||
|
1042 | 1064 | def readNextBlock(self): |
|
1043 | 1065 | |
|
1044 | 1066 | #Skip block out of startTime and endTime |
|
1045 | while True: | |
|
1067 | while True: | |
|
1046 | 1068 | if not(self.__setNewBlock()): |
|
1047 | 1069 | print 'returning' |
|
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, |
@@ -1062,8 +1082,8 class JRODataReader(JRODataIO): | |||
|
1062 | 1082 | |
|
1063 | 1083 | if self.verbose: |
|
1064 | 1084 | print "[Reading] Block No. %d/%d -> %s" %(self.nReadBlocks, |
|
1065 |
|
|
|
1066 |
|
|
|
1085 | self.processingHeaderObj.dataBlocksPerFile, | |
|
1086 | self.dataOut.datatime.ctime()) | |
|
1067 | 1087 | return 1 |
|
1068 | 1088 | |
|
1069 | 1089 | def __readFirstHeader(self): |
@@ -1257,13 +1277,13 class JRODataReader(JRODataIO): | |||
|
1257 | 1277 | |
|
1258 | 1278 | def setup(self, |
|
1259 | 1279 | path=None, |
|
1260 | startDate=None, | |
|
1261 | endDate=None, | |
|
1262 | startTime=datetime.time(0,0,0), | |
|
1263 | endTime=datetime.time(23,59,59), | |
|
1264 | set=None, | |
|
1265 | expLabel = "", | |
|
1266 | ext = None, | |
|
1280 | startDate=None, | |
|
1281 | endDate=None, | |
|
1282 | startTime=datetime.time(0,0,0), | |
|
1283 | endTime=datetime.time(23,59,59), | |
|
1284 | set=None, | |
|
1285 | expLabel = "", | |
|
1286 | ext = None, | |
|
1267 | 1287 | online = False, |
|
1268 | 1288 | delay = 60, |
|
1269 | 1289 | walk = True, |
@@ -1272,80 +1292,137 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 | |
|
1294 | if path == None: | |
|
1295 | raise ValueError, "[Reading] The path is not valid" | |
|
1296 | ||
|
1297 | if ext == None: | |
|
1298 | ext = self.ext | |
|
1299 | ||
|
1300 | if online: | |
|
1301 | print "[Reading] Searching files in online mode..." | |
|
1296 | **kwargs): | |
|
1302 | 1297 | |
|
1303 | for nTries in range( self.nTries ): | |
|
1304 | fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path, expLabel=expLabel, ext=ext, walk=walk, set=set) | |
|
1305 | ||
|
1306 | if fullpath: | |
|
1307 | break | |
|
1308 | ||
|
1309 | print '[Reading] Waiting %0.2f sec for an valid file in %s: try %02d ...' % (self.delay, path, nTries+1) | |
|
1310 | sleep( self.delay ) | |
|
1311 | ||
|
1312 | if not(fullpath): | |
|
1313 | print "[Reading] There 'isn't any valid file in %s" % path | |
|
1314 | return | |
|
1298 | if path == None: | |
|
1299 | raise ValueError, "[Reading] The path is not valid" | |
|
1300 | ||
|
1315 | 1301 | |
|
1316 | self.year = year | |
|
1317 |
|
|
|
1318 | self.set = set - 1 | |
|
1319 | self.path = path | |
|
1320 | self.foldercounter = foldercounter | |
|
1321 | last_set = None | |
|
1322 | else: | |
|
1323 | print "[Reading] Searching files in offline mode ..." | |
|
1324 | pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate, | |
|
1302 | if ext == None: | |
|
1303 | ext = self.ext | |
|
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, | |
|
1325 | 1326 | startTime=startTime, endTime=endTime, |
|
1326 | 1327 | set=set, expLabel=expLabel, ext=ext, |
|
1327 |
walk=walk |
|
|
1328 | skip=skip, queue=queue) | |
|
1329 | ||
|
1330 | if not(pathList): | |
|
1331 | # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path, | |
|
1332 | # datetime.datetime.combine(startDate,startTime).ctime(), | |
|
1333 | # datetime.datetime.combine(endDate,endTime).ctime()) | |
|
1334 | ||
|
1335 | # sys.exit(-1) | |
|
1328 | walk=walk) | |
|
1329 | if filenameList is not None: filenameList = filenameList[:-1] | |
|
1336 | 1330 | |
|
1331 | if pathList is not None and filenameList is not None and online: | |
|
1332 | self.onlineWithDate = True | |
|
1333 | online = False | |
|
1337 | 1334 | self.fileIndex = -1 |
|
1338 |
self.pathList = |
|
|
1339 |
self.filenameList = |
|
|
1340 | return | |
|
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 | ||
|
1341 | if online: | |
|
1342 | print "[Reading] Searching files in online mode..." | |
|
1343 | ||
|
1344 | for nTries in range(self.nTries): | |
|
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) | |
|
1352 | ||
|
1353 | if fullpath: | |
|
1354 | break | |
|
1355 | print '[Reading] Waiting %0.2f sec for an valid file in %s: try %02d ...' % (self.delay, path, nTries+1) | |
|
1356 | sleep( self.delay ) | |
|
1357 | ||
|
1358 | if not(fullpath): | |
|
1359 | print "[Reading] There 'isn't any valid file in %s" % path | |
|
1360 | return | |
|
1361 | ||
|
1362 | self.year = year | |
|
1363 | self.doy = doy | |
|
1364 | self.set = set - 1 | |
|
1365 | self.path = path | |
|
1366 | self.foldercounter = foldercounter | |
|
1367 | last_set = None | |
|
1368 | else: | |
|
1369 | print "[Reading] Searching files in offline mode ..." | |
|
1370 | pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate, | |
|
1371 | startTime=startTime, endTime=endTime, | |
|
1372 | set=set, expLabel=expLabel, ext=ext, | |
|
1373 | walk=walk) | |
|
1374 | ||
|
1375 | if not(pathList): | |
|
1376 | # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path, | |
|
1377 | # datetime.datetime.combine(startDate,startTime).ctime(), | |
|
1378 | # datetime.datetime.combine(endDate,endTime).ctime()) | |
|
1379 | ||
|
1380 | # sys.exit(-1) | |
|
1381 | ||
|
1382 | self.fileIndex = -1 | |
|
1383 | self.pathList = [] | |
|
1384 | self.filenameList = [] | |
|
1385 | return | |
|
1386 | ||
|
1387 | self.fileIndex = -1 | |
|
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:]) | |
|
1341 | 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 | ||
|
1342 | 1419 | self.fileIndex = -1 |
|
1343 | 1420 | self.pathList = [] |
|
1344 | 1421 | self.filenameList = [] |
|
1345 | 1422 | return |
|
1346 | 1423 | |
|
1347 | 1424 | # self.getBasicHeader() |
|
1348 | ||
|
1425 | ||
|
1349 | 1426 | if last_set != None: |
|
1350 | 1427 | self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock |
|
1351 | 1428 | return |
@@ -1365,10 +1442,10 class JRODataReader(JRODataIO): | |||
|
1365 | 1442 | self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime |
|
1366 | 1443 | |
|
1367 | 1444 | self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs |
|
1368 | ||
|
1369 | # self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs | |
|
1370 | ||
|
1371 | ||
|
1445 | ||
|
1446 | # self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs | |
|
1447 | ||
|
1448 | ||
|
1372 | 1449 | def getFirstHeader(self): |
|
1373 | 1450 | |
|
1374 | 1451 | raise NotImplementedError |
@@ -1416,30 +1493,29 class JRODataReader(JRODataIO): | |||
|
1416 | 1493 | |
|
1417 | 1494 | self.__printInfo = False |
|
1418 | 1495 | |
|
1419 | ||
|
1420 | 1496 | def run(self, |
|
1421 |
|
|
|
1422 |
|
|
|
1423 |
|
|
|
1424 |
|
|
|
1425 |
|
|
|
1426 |
|
|
|
1427 |
|
|
|
1428 |
|
|
|
1429 |
|
|
|
1430 |
|
|
|
1431 |
|
|
|
1432 |
|
|
|
1433 |
|
|
|
1434 |
|
|
|
1435 |
|
|
|
1436 |
|
|
|
1437 |
|
|
|
1438 |
|
|
|
1439 |
|
|
|
1440 |
|
|
|
1441 |
|
|
|
1442 |
|
|
|
1497 | path=None, | |
|
1498 | startDate=None, | |
|
1499 | endDate=None, | |
|
1500 | startTime=datetime.time(0,0,0), | |
|
1501 | endTime=datetime.time(23,59,59), | |
|
1502 | set=None, | |
|
1503 | expLabel = "", | |
|
1504 | ext = None, | |
|
1505 | online = False, | |
|
1506 | delay = 60, | |
|
1507 | walk = True, | |
|
1508 | getblock = False, | |
|
1509 | nTxs = 1, | |
|
1510 | realtime=False, | |
|
1511 | blocksize=None, | |
|
1512 | blocktime=None, | |
|
1513 | queue=None, | |
|
1514 | skip=None, | |
|
1515 | cursor=None, | |
|
1516 | warnings=True, | |
|
1517 | server=None, | |
|
1518 | verbose=True, **kwargs): | |
|
1443 | 1519 | |
|
1444 | 1520 | if not(self.isConfig): |
|
1445 | 1521 | # self.dataOut = dataOut |
@@ -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() |
@@ -1587,9 +1663,9 class JRODataWriter(JRODataIO): | |||
|
1587 | 1663 | Return: |
|
1588 | 1664 | None |
|
1589 | 1665 | """ |
|
1590 | ||
|
1591 | # CALCULAR PARAMETROS | |
|
1592 | ||
|
1666 | ||
|
1667 | # CALCULAR PARAMETROS | |
|
1668 | ||
|
1593 | 1669 | sizeLongHeader = self.systemHeaderObj.size + self.radarControllerHeaderObj.size + self.processingHeaderObj.size |
|
1594 | 1670 | self.basicHeaderObj.size = self.basicHeaderSize + sizeLongHeader |
|
1595 | 1671 | |
@@ -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 |
|
622 | ||
|
623 | if kwargs.has_key('mode'): | |
|
624 | mode = kwargs['mode'] | |
|
625 | ||
|
626 | if type(mode) == int: | |
|
627 | mode = numpy.zeros(len(self.dataList)) + mode | |
|
628 | else: | |
|
629 | mode = numpy.ones(len(self.dataList)) | |
|
630 | ||
|
631 | 616 | self.mode = mode |
|
617 | ||
|
618 | if self.mode is not None: | |
|
619 | self.mode = numpy.zeros(len(self.dataList)) + mode | |
|
620 | else: | |
|
621 | self.mode = numpy.ones(len(self.dataList)) | |
|
632 | 622 | |
|
633 | 623 | arrayDim = numpy.zeros((len(self.dataList),5)) |
|
634 | 624 | |
@@ -770,13 +760,20 class ParamWriter(Operation): | |||
|
770 | 760 | else: |
|
771 | 761 | setFile = -1 #inicializo mi contador de seteo |
|
772 | 762 | |
|
773 | setFile += 1 | |
|
774 | ||
|
775 |
file = '%s%4.4d%3.3d% |
|
|
776 | timeTuple.tm_year, | |
|
777 | timeTuple.tm_yday, | |
|
778 | setFile, | |
|
779 | ext ) | |
|
763 | if self.setType is None: | |
|
764 | setFile += 1 | |
|
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, | |
|
773 | timeTuple.tm_year, | |
|
774 | timeTuple.tm_yday, | |
|
775 | setFile, | |
|
776 | ext ) | |
|
780 | 777 | |
|
781 | 778 | filename = os.path.join( path, subfolder, file ) |
|
782 | 779 | self.metaFile = file |
@@ -849,13 +846,20 class ParamWriter(Operation): | |||
|
849 | 846 | os.makedirs(fullpath) |
|
850 | 847 | setFile = -1 #inicializo mi contador de seteo |
|
851 | 848 | |
|
852 | setFile += 1 | |
|
853 | ||
|
854 |
file = '%s%4.4d%3.3d% |
|
|
855 | timeTuple.tm_year, | |
|
856 | timeTuple.tm_yday, | |
|
857 | setFile, | |
|
858 | ext ) | |
|
849 | if self.setType is None: | |
|
850 | setFile += 1 | |
|
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, | |
|
859 | timeTuple.tm_year, | |
|
860 | timeTuple.tm_yday, | |
|
861 | setFile, | |
|
862 | ext ) | |
|
859 | 863 | |
|
860 | 864 | filename = os.path.join( path, subfolder, file ) |
|
861 | 865 | |
@@ -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 |
@@ -177,13 +177,13 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
177 | 177 | |
|
178 | 178 | def getBlockDimension(self): |
|
179 | 179 | """ |
|
180 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
|
181 | ||
|
182 | Affected: | |
|
183 | self.blocksize | |
|
180 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
|
181 | ||
|
182 | Affected: | |
|
183 | self.blocksize | |
|
184 | 184 | |
|
185 | Return: | |
|
186 | None | |
|
185 | Return: | |
|
186 | None | |
|
187 | 187 | """ |
|
188 | 188 | pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels |
|
189 | 189 | self.blocksize = pts2read |
@@ -191,27 +191,37 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
191 | 191 | |
|
192 | 192 | def readBlock(self): |
|
193 | 193 | """ |
|
194 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |
|
195 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos | |
|
196 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |
|
197 | es seteado a 0 | |
|
198 | ||
|
199 | Inputs: | |
|
200 | None | |
|
194 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |
|
195 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos | |
|
196 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |
|
197 | es seteado a 0 | |
|
201 | 198 | |
|
202 | Return: | |
|
203 | None | |
|
204 | ||
|
205 |
|
|
|
206 | self.profileIndex | |
|
207 | self.datablock | |
|
208 | self.flagIsNewFile | |
|
209 | self.flagIsNewBlock | |
|
210 | self.nTotalBlocks | |
|
199 | Inputs: | |
|
200 | None | |
|
201 | ||
|
202 | Return: | |
|
203 | None | |
|
211 | 204 | |
|
212 | Exceptions: | |
|
213 | Si un bloque leido no es un bloque valido | |
|
205 | Affected: | |
|
206 | self.profileIndex | |
|
207 | self.datablock | |
|
208 | self.flagIsNewFile | |
|
209 | self.flagIsNewBlock | |
|
210 | self.nTotalBlocks | |
|
211 | ||
|
212 | Exceptions: | |
|
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 | |
@@ -223,7 +233,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
223 | 233 | if self.waitDataBlock(pointer_location=current_pointer_location): |
|
224 | 234 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
225 | 235 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
226 | # return 0 | |
|
236 | # return 0 | |
|
227 | 237 | |
|
228 | 238 | #Dimensions : nChannels, nProfiles, nSamples |
|
229 | 239 | |
@@ -252,17 +262,17 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
252 | 262 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs |
|
253 | 263 | |
|
254 | 264 | #Time interval and code are propierties of dataOut. Its value depends of radarControllerHeaderObj. |
|
255 | ||
|
256 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt | |
|
257 | # | |
|
258 | # if self.radarControllerHeaderObj.code is not None: | |
|
259 |
|
|
|
260 | # self.dataOut.nCode = self.radarControllerHeaderObj.nCode | |
|
261 |
|
|
|
262 | # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud | |
|
263 |
|
|
|
264 | # self.dataOut.code = self.radarControllerHeaderObj.code | |
|
265 | ||
|
265 | ||
|
266 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt | |
|
267 | # | |
|
268 | # if self.radarControllerHeaderObj.code is not None: | |
|
269 | # | |
|
270 | # self.dataOut.nCode = self.radarControllerHeaderObj.nCode | |
|
271 | # | |
|
272 | # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud | |
|
273 | # | |
|
274 | # self.dataOut.code = self.radarControllerHeaderObj.code | |
|
275 | ||
|
266 | 276 | self.dataOut.dtype = self.dtype |
|
267 | 277 | |
|
268 | 278 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock |
@@ -298,44 +308,135 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
298 | 308 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs |
|
299 | 309 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights/self.nTxs) *self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight |
|
300 | 310 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs |
|
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 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut | |
|
307 | del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos | |
|
308 | en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando | |
|
309 | "readNextBlock" | |
|
310 | ||
|
311 | Ademas incrementa el contador del buffer "self.profileIndex" en 1. | |
|
312 | ||
|
313 | Return: | |
|
314 | ||
|
315 | Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex | |
|
316 | es igual al total de perfiles leidos desde el archivo. | |
|
317 | ||
|
318 | Si self.getByBlock == False: | |
|
407 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut | |
|
408 | del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos | |
|
409 | en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando | |
|
410 | "readNextBlock" | |
|
319 | 411 | |
|
320 | self.dataOut.data = buffer[:, thisProfile, :] | |
|
321 | ||
|
322 | shape = [nChannels, nHeis] | |
|
323 | ||
|
324 | Si self.getByBlock == True: | |
|
412 | Ademas incrementa el contador del buffer "self.profileIndex" en 1. | |
|
325 | 413 | |
|
326 | self.dataOut.data = buffer[:, :, :] | |
|
327 | ||
|
328 | shape = [nChannels, nProfiles, nHeis] | |
|
414 | Return: | |
|
329 | 415 | |
|
330 | Variables afectadas: | |
|
331 | self.dataOut | |
|
332 | self.profileIndex | |
|
416 | Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex | |
|
417 | es igual al total de perfiles leidos desde el archivo. | |
|
333 | 418 | |
|
334 | Affected: | |
|
335 |
|
|
|
336 | self.profileIndex | |
|
337 | self.flagDiscontinuousBlock | |
|
338 | self.flagIsNewBlock | |
|
419 | Si self.getByBlock == False: | |
|
420 | ||
|
421 | self.dataOut.data = buffer[:, thisProfile, :] | |
|
422 | ||
|
423 | shape = [nChannels, nHeis] | |
|
424 | ||
|
425 | Si self.getByBlock == True: | |
|
426 | ||
|
427 | self.dataOut.data = buffer[:, :, :] | |
|
428 | ||
|
429 | shape = [nChannels, nProfiles, nHeis] | |
|
430 | ||
|
431 | Variables afectadas: | |
|
432 | self.dataOut | |
|
433 | self.profileIndex | |
|
434 | ||
|
435 | Affected: | |
|
436 | self.dataOut | |
|
437 | self.profileIndex | |
|
438 | self.flagDiscontinuousBlock | |
|
439 | self.flagIsNewBlock | |
|
339 | 440 | """ |
|
340 | 441 | |
|
341 | 442 | if self.flagNoMoreFiles: |
@@ -362,10 +463,10 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
362 | 463 | if not self.getByBlock: |
|
363 | 464 | |
|
364 | 465 | """ |
|
365 | Return profile by profile | |
|
366 | ||
|
367 | If nTxs > 1 then one profile is divided by nTxs and number of total | |
|
368 | blocks is increased by nTxs (nProfiles *= nTxs) | |
|
466 | Return profile by profile | |
|
467 | ||
|
468 | If nTxs > 1 then one profile is divided by nTxs and number of total | |
|
469 | blocks is increased by nTxs (nProfiles *= nTxs) | |
|
369 | 470 | """ |
|
370 | 471 | self.dataOut.flagDataAsBlock = False |
|
371 | 472 | self.dataOut.data = self.datablock[:,self.profileIndex,:] |
@@ -373,19 +474,19 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
373 | 474 | |
|
374 | 475 | self.profileIndex += 1 |
|
375 | 476 | |
|
376 | # elif self.selBlocksize==None or self.selBlocksize==self.dataOut.nProfiles: | |
|
377 | # """ | |
|
378 | # Return all block | |
|
379 | # """ | |
|
380 | # self.dataOut.flagDataAsBlock = True | |
|
381 | # self.dataOut.data = self.datablock | |
|
382 | # self.dataOut.profileIndex = self.dataOut.nProfiles - 1 | |
|
383 | # | |
|
384 | # self.profileIndex = self.dataOut.nProfiles | |
|
477 | # elif self.selBlocksize==None or self.selBlocksize==self.dataOut.nProfiles: | |
|
478 | # """ | |
|
479 | # Return all block | |
|
480 | # """ | |
|
481 | # self.dataOut.flagDataAsBlock = True | |
|
482 | # self.dataOut.data = self.datablock | |
|
483 | # self.dataOut.profileIndex = self.dataOut.nProfiles - 1 | |
|
484 | # | |
|
485 | # self.profileIndex = self.dataOut.nProfiles | |
|
385 | 486 | |
|
386 | 487 | else: |
|
387 | 488 | """ |
|
388 | Return a block | |
|
489 | Return a block | |
|
389 | 490 | """ |
|
390 | 491 | if self.selBlocksize == None: self.selBlocksize = self.dataOut.nProfiles |
|
391 | 492 | if self.selBlocktime != None: |
@@ -1,12 +1,22 | |||
|
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" }, | |
|
9 | { NULL, NULL, 0, NULL } | |
|
17 | { "correlateByBlock", (PyCFunction)correlateByBlock, METH_VARARGS, "get correlation by block" }, | |
|
18 | { "hildebrand_sekhon", (PyCFunction)hildebrand_sekhon, METH_VARARGS, "get noise with hildebrand_sekhon" }, | |
|
19 | { NULL, NULL, 0, NULL } | |
|
10 | 20 | }; |
|
11 | 21 | |
|
12 | 22 | PyMODINIT_FUNC initcSchain() { |
@@ -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) |
@@ -1017,33 +1017,55 class WindProfiler(Operation): | |||
|
1017 | 1017 | def techniqueNSM_DBS(self, **kwargs): |
|
1018 | 1018 | metArray = kwargs['metArray'] |
|
1019 | 1019 | heightList = kwargs['heightList'] |
|
1020 | timeList = kwargs['timeList'] | |
|
1021 |
z |
|
|
1020 | timeList = kwargs['timeList'] | |
|
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 |
|
|
|
1036 | ||
|
1037 | ||
|
1038 | ||
|
1039 | return data_output | |
|
1045 | thisH = (h1met>=hmin) & (h1met<hmax) & (cmet!=2) & (SNRmet>8) & (vmet<50) & (spcmet<10) | |
|
1046 | indthisH = numpy.where(thisH) | |
|
1047 | ||
|
1048 | if numpy.size(indthisH) > 3: | |
|
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] | |
|
1055 | ||
|
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) | |
|
1060 | ||
|
1061 | return velEst | |
|
1040 | 1062 | |
|
1041 |
def run(self, dataOut, technique, hmin=70, hmax=110, |
|
|
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: |
|
1045 | 1067 | absc = dataOut.abscissaList[:-1] |
|
1046 | #noise = dataOut.noise | |
|
1068 | # noise = dataOut.noise | |
|
1047 | 1069 | heightList = dataOut.heightList |
|
1048 | 1070 | SNR = dataOut.data_SNR |
|
1049 | 1071 | |
@@ -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 = |
|
|
1283 | ||
|
1284 | lamb = self.dataOut.C/self.dataOut.frequency | |
|
1285 | tSamp = self.dataOut.ippSeconds*self.dataOut.nCohInt | |
|
1286 | paramInterval = self.dataOut.paramInterval | |
|
1287 | ||
|
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] | |
|
1310 | ||
|
1311 | lamb = dataOut.C/dataOut.frequency | |
|
1312 | tSamp = dataOut.ippSeconds*dataOut.nCohInt | |
|
1313 | paramInterval = dataOut.paramInterval | |
|
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 = |
|
|
1297 | ||
|
1298 |
|
|
|
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 | |
|
1324 | ||
|
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 |
@@ -2545,8 +2601,8 class SMOperations(): | |||
|
2545 | 2601 | |
|
2546 | 2602 | hCorr = hi[ind_h, :] |
|
2547 | 2603 | ind_hCorr = numpy.where(numpy.logical_and(hi > minHeight, hi < maxHeight)) |
|
2548 | ||
|
2549 | hCorr = hi[ind_hCorr] | |
|
2604 | ||
|
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) |
@@ -345,10 +346,9 class CohInt(Operation): | |||
|
345 | 346 | |
|
346 | 347 | Inputs: |
|
347 | 348 | |
|
348 | n : Number of coherent integrations | |
|
349 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
|
350 | overlapping : | |
|
351 | ||
|
349 | n : Number of coherent integrations | |
|
350 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
|
351 | overlapping : | |
|
352 | 352 | """ |
|
353 | 353 | |
|
354 | 354 | self.__initime = None |
@@ -548,14 +548,13 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) |
|
555 | 554 | |
|
556 | 555 | self.times = None |
|
557 | 556 | self.osamp = None |
|
558 | # self.__setValues = False | |
|
557 | # self.__setValues = False | |
|
559 | 558 | self.isConfig = False |
|
560 | 559 | |
|
561 | 560 | def setup(self, code, osamp, dataOut): |
@@ -624,19 +623,41 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 |
|
630 | ||
|
636 | ||
|
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)) |
|
634 | ||
|
635 | for i in range(self.__nChannels): | |
|
636 | for j in range(self.__nProfiles): | |
|
640 | profilesList = xrange(self.__nProfiles) | |
|
641 | ||
|
642 | # def toVectorize(a,b): | |
|
643 | # return numpy.correlate(a,b, mode='full') | |
|
644 | # vectorized = numpy.vectorize(toVectorize, signature='(n),(m)->(k)') | |
|
645 | for i in range(self.__nChannels): | |
|
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 |
|
660 | ||
|
640 | 661 | |
|
641 | 662 | def __convolutionByBlockInFreq(self, data): |
|
642 | 663 | |
@@ -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) |
@@ -196,7 +196,7 class Remote(Thread): | |||
|
196 | 196 | if self.stopFlag: |
|
197 | 197 | break |
|
198 | 198 | |
|
199 |
|
|
|
199 | # self.bussy = True | |
|
200 | 200 | self.mutex.acquire() |
|
201 | 201 | |
|
202 | 202 | print "[Remote Server] Opening %s" %self.__server |
@@ -211,7 +211,7 class Remote(Thread): | |||
|
211 | 211 | self.close() |
|
212 | 212 | |
|
213 | 213 | self.mutex.release() |
|
214 |
|
|
|
214 | # self.bussy = False | |
|
215 | 215 | |
|
216 | 216 | print "[Remote Server] Thread stopped successfully" |
|
217 | 217 | |
@@ -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: |
@@ -706,7 +707,7 class FTP(object): | |||
|
706 | 707 | self.ftp = ftplib.FTP(self.server) |
|
707 | 708 | self.ftp.login(self.username,self.password) |
|
708 | 709 | self.ftp.cwd(self.remotefolder) |
|
709 |
|
|
|
710 | # print 'Connect to FTP Server: Successfully' | |
|
710 | 711 | |
|
711 | 712 | except ftplib.all_errors: |
|
712 | 713 | print 'Error FTP Service' |
@@ -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()) |
@@ -84,14 +87,9 opObj12.addParameter(name='blocksPerFile', value='1000', format='int') | |||
|
84 | 87 | opObj12.addParameter(name='metadataList',value='type,heightList,paramInterval,timeZone',format='list') |
|
85 | 88 | opObj12.addParameter(name='dataList',value='data_param,utctime',format='list') |
|
86 | 89 | 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 |
@@ -11,20 +11,20 def fiber(cursor, skip, q, dt): | |||
|
11 | 11 | controllerObj.setup(id='191', name='test01', description=desc) |
|
12 | 12 | |
|
13 | 13 | readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader', |
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
14 | path='/home/nanosat/data/sp1_f0', | |
|
15 | startDate=dt, | |
|
16 | endDate=dt, | |
|
17 | startTime="00:00:00", | |
|
18 | endTime="23:59:59", | |
|
19 | online=0, | |
|
20 | #set=1426485881, | |
|
21 | walk=1, | |
|
22 | queue=q, | |
|
23 | cursor=cursor, | |
|
24 | skip=skip, | |
|
25 | verbose=1 | |
|
26 | #timezone=-5*3600 | |
|
27 | ) | |
|
28 | 28 | |
|
29 | 29 | # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
30 | 30 | # |
@@ -11,20 +11,20 def fiber(cursor, skip, q, dt): | |||
|
11 | 11 | controllerObj.setup(id='191', name='test01', description=desc) |
|
12 | 12 | |
|
13 | 13 | readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader', |
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
14 | path='/home/nanosat/data/julia', | |
|
15 | startDate=dt, | |
|
16 | endDate=dt, | |
|
17 | startTime="00:00:00", | |
|
18 | endTime="23:59:59", | |
|
19 | online=0, | |
|
20 | #set=1426485881, | |
|
21 | delay=10, | |
|
22 | walk=1, | |
|
23 | queue=q, | |
|
24 | cursor=cursor, | |
|
25 | skip=skip, | |
|
26 | #timezone=-5*3600 | |
|
27 | ) | |
|
28 | 28 | |
|
29 | 29 | # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
30 | 30 | # |
@@ -1,1 +1,5 | |||
|
1 | <Project description="Claire" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/media/nanosat/0BDE10E00BDE10E0/CLAIRE" /><Parameter format="date" id="2113" name="startDate" value="2017/07/26" /><Parameter format="date" id="2114" name="endDate" value="2017/07/26" /><Parameter format="time" id="2115" name="startTime" value="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> No newline at end of file | |
|
1 | <<<<<<< HEAD | |
|
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 |
@@ -19,43 +18,52 class build_ext(_build_ext): | |||
|
19 | 18 | |
|
20 | 19 | |
|
21 | 20 | setup(name="schainpy", |
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 | 'schainpy/scripts/schain'], | |
|
48 | ext_modules=[ | |
|
49 | Extension("cSchain", ["schainpy/model/proc/extensions.c"] | |
|
50 | )], | |
|
51 | cmdclass={'build_ext':build_ext}, | |
|
52 | setup_requires=["numpy >= 1.11.2"], | |
|
53 | install_requires=[ | |
|
21 | version=__version__, | |
|
22 | description="Python tools to read, write and process Jicamarca data", | |
|
23 | author="Miguel Urco", | |
|
24 | author_email="miguel.urco@jro.igp.gob.pe", | |
|
25 | url="http://jro.igp.gob.pe", | |
|
26 | packages = {'schainpy', | |
|
27 | 'schainpy.model', | |
|
28 | 'schainpy.model.data', | |
|
29 | 'schainpy.model.graphics', | |
|
30 | 'schainpy.model.io', | |
|
31 | 'schainpy.model.proc', | |
|
32 | 'schainpy.model.serializer', | |
|
33 | 'schainpy.model.utils', | |
|
34 | 'schainpy.gui', | |
|
35 | 'schainpy.gui.figures', | |
|
36 | 'schainpy.gui.viewcontroller', | |
|
37 | 'schainpy.gui.viewer', | |
|
38 | 'schainpy.gui.viewer.windows'}, | |
|
39 | ext_package='schainpy', | |
|
40 | py_modules=[''], | |
|
41 | package_data={'': ['schain.conf.template'], | |
|
42 | 'schainpy.gui.figures': ['*.png','*.jpg'], | |
|
43 | }, | |
|
44 | include_package_data=False, | |
|
45 | scripts =['schainpy/gui/schainGUI'], | |
|
46 | ext_modules=[ | |
|
47 | Extension("cSchain", ["schainpy/model/proc/extensions.c"] | |
|
48 | )], | |
|
49 | entry_points={ | |
|
50 | 'console_scripts': [ | |
|
51 | 'schain = schaincli.cli:main', | |
|
52 | ], | |
|
53 | }, | |
|
54 | cmdclass={'build_ext':build_ext}, | |
|
55 | setup_requires=["numpy >= 1.11.2"], | |
|
56 | install_requires=[ | |
|
54 | 57 | "scipy >= 0.14.0", |
|
55 | 58 | "h5py >= 2.2.1", |
|
56 | 59 | "matplotlib >= 1.4.2", |
|
57 | "pyfits >= 3.4", | |
|
60 | "pyfits >= 3.4", | |
|
61 | "paramiko >= 2.1.2", | |
|
58 | 62 | "paho-mqtt >= 1.2", |
|
59 | 63 | "zmq", |
|
60 |
|
|
|
61 | ) | |
|
64 | "fuzzywuzzy", | |
|
65 | "click", | |
|
66 | "colorama", | |
|
67 | "python-Levenshtein" | |
|
68 | ], | |
|
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