@@ -0,0 +1,113 | |||
|
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 | path = '/home/jespinoza/Pictures/JASMET30/201608/phase' | |
|
97 | stdvLimit = 0.5 | |
|
98 | ||
|
99 | #---------------------- Script --------------------------- | |
|
100 | ||
|
101 | fileList = findFiles(path) | |
|
102 | offsets0 = readFiles(fileList) | |
|
103 | mean0, axisY0, axisX0 = estimateMean(offsets0) | |
|
104 | plotPhases(offsets0, axisY0, axisX0, 'Original') | |
|
105 | ||
|
106 | offsets1 = filterOffsets(offsets0, stdvLimit) | |
|
107 | mean1, axisY1, axisX1 = estimateMean(offsets1) | |
|
108 | plotPhases(offsets1, axisY1, axisX1, 'Filtered') | |
|
109 | ||
|
110 | print "Original Offsets: %.2f, %.2f, %.2f, %.2f" % (mean0[0],mean0[1],mean0[2],mean0[3]) | |
|
111 | print "Filtered Offsets: %.2f, %.2f, %.2f, %.2f" % (mean1[0],mean1[1],mean1[2],mean1[3]) | |
|
112 | ||
|
113 | plt.show() |
@@ -1,6 +1,13 | |||
|
1 | 1 | .project |
|
2 | 2 | .pydevproject |
|
3 | 3 | build/ |
|
4 | 4 | *.pyc |
|
5 | 5 | *.so |
|
6 | *.egg-info/ No newline at end of file | |
|
6 | *.egg-info/ | |
|
7 | ||
|
8 | # eclipse | |
|
9 | .project | |
|
10 | .pydevproject | |
|
11 | ||
|
12 | # vscode | |
|
13 | .vscode No newline at end of file |
@@ -1,131 +1,132 | |||
|
1 | 1 | # Signal Chain |
|
2 | 2 | |
|
3 | 3 | ## Introduction |
|
4 | 4 | |
|
5 | 5 | Signal Chain (SCh) is a radar data processing library developed using [Python](www.python.org) at JRO. SCh provides modules to read, write, process and plot data. |
|
6 | 6 | |
|
7 | 7 | ## Installation |
|
8 | 8 | |
|
9 |
Install system dependencies, |
|
|
9 | Install system dependencies, clone the latest version from [git](http://jro-dev.igp.gob.pe/rhodecode/schain/) and install it as a normal python package. | |
|
10 | 10 | |
|
11 | 11 | ``` |
|
12 | 12 | $ sudo apt-get install python-pip python-dev gfortran libpng-dev freetype* libblas-dev liblapack-dev libatlas-base-dev python-qt4 python-tk libssl-dev libhdf5-dev |
|
13 | $ tar xvzf schainpy-2.2.5.tar.gz | |
|
14 | $ cd schainpy-2.2.5 | |
|
13 | $ sudo pip install numpy | |
|
14 | $ git clone http://jro-dev.igp.gob.pe/rhodecode/schain/ | |
|
15 | $ cd schain | |
|
15 | 16 | $ sudo pip install ./ |
|
16 | 17 | ``` |
|
17 | 18 | |
|
18 | 19 | **Its recommended to install schain in a virtual environment** |
|
19 | 20 | |
|
20 | 21 | ``` |
|
21 | 22 | $ sudo pip install virtualenv |
|
22 | 23 | $ virtualenv /path/to/virtual --system-site-packages |
|
23 | 24 | $ source /path/to/virtual/bin/activate |
|
24 |
(virtual) $ cd schain |
|
|
25 | (virtual) $ cd schain | |
|
25 | 26 | (virtual) $ pip install ./ |
|
26 | 27 | ``` |
|
27 | 28 | |
|
28 | 29 | ## First Script |
|
29 | 30 | |
|
30 | 31 | Read Spectra data (.pdata) - remove dc - plot spectra & RTI |
|
31 | 32 | |
|
32 | 33 | Import SCh and creating a project |
|
33 | 34 | |
|
34 | 35 | ```python |
|
35 | 36 | #!/usr/bin/python |
|
36 | 37 | |
|
37 | 38 | from schainpy.controller import Project |
|
38 | 39 | |
|
39 | 40 | controller = Project() |
|
40 | 41 | controller.setup(id = '100', |
|
41 | 42 | name='test', |
|
42 | 43 | description='Basic experiment') |
|
43 | 44 | |
|
44 | 45 | |
|
45 | 46 | ``` |
|
46 | 47 | |
|
47 | 48 | Adding read unit and operations |
|
48 | 49 | |
|
49 | 50 | ```python |
|
50 | 51 | read_unit = controller.addReadUnit(datatype='Spectra', |
|
51 | 52 | path='/path/to/pdata/', |
|
52 | 53 | startDate='2014/01/31', |
|
53 | 54 | endDate='2014/03/31', |
|
54 | 55 | startTime='00:00:00', |
|
55 | 56 | endTime='23:59:59', |
|
56 | 57 | online=0, |
|
57 | 58 | walk=0) |
|
58 | 59 | |
|
59 | 60 | proc_unit = controller.addProcUnit(datatype='Spectra', |
|
60 | 61 | inputId=read_unit.getId()) |
|
61 | 62 | |
|
62 | 63 | op = proc_unit.addOperation(name='selectChannels') |
|
63 | 64 | op.addParameter(name='channelList', value='0,1', format='intlist') |
|
64 | 65 | |
|
65 | 66 | op = proc_unit.addOperation(name='selectHeights') |
|
66 | 67 | op.addParameter(name='minHei', value='80', format='float') |
|
67 | 68 | op.addParameter(name='maxHei', value='200', format='float') |
|
68 | 69 | |
|
69 | 70 | op = proc_unit.addOperation(name='removeDC') |
|
70 | 71 | |
|
71 | 72 | ``` |
|
72 | 73 | |
|
73 | 74 | Plotting data & start project |
|
74 | 75 | |
|
75 | 76 | ```python |
|
76 | 77 | op = proc_unit.addOperation(name='SpectraPlot', optype='other') |
|
77 | 78 | op.addParameter(name='id', value='1', format='int') |
|
78 | 79 | op.addParameter(name='wintitle', value='Spectra', format='str') |
|
79 | 80 | |
|
80 | 81 | op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
81 | 82 | op.addParameter(name='id', value='2', format='int') |
|
82 | 83 | op.addParameter(name='wintitle', value='RTI', format='str') |
|
83 | 84 | |
|
84 | 85 | controller.start() |
|
85 | 86 | |
|
86 | 87 | ``` |
|
87 | 88 | |
|
88 | 89 | Full script |
|
89 | 90 | |
|
90 | 91 | |
|
91 | 92 | ```python |
|
92 | 93 | #!/usr/bin/python |
|
93 | 94 | |
|
94 | 95 | from schainpy.controller import Project |
|
95 | 96 | |
|
96 | 97 | controller = Project() |
|
97 | 98 | controller.setup(id = '100', |
|
98 | 99 | name='test', |
|
99 | 100 | description='Basic experiment') |
|
100 | 101 | read_unit = controller.addReadUnit(datatype='Spectra', |
|
101 | 102 | path='/path/to/pdata/', |
|
102 | 103 | startDate='2014/01/31', |
|
103 | 104 | endDate='2014/03/31', |
|
104 | 105 | startTime='00:00:00', |
|
105 | 106 | endTime='23:59:59', |
|
106 | 107 | online=0, |
|
107 | 108 | walk=0) |
|
108 | 109 | |
|
109 | 110 | proc_unit = controller.addProcUnit(datatype='Spectra', |
|
110 | 111 | inputId=read_unit.getId()) |
|
111 | 112 | |
|
112 | 113 | op = proc_unit.addOperation(name='selectChannels') |
|
113 | 114 | op.addParameter(name='channelList', value='0,1', format='intlist') |
|
114 | 115 | |
|
115 | 116 | op = proc_unit.addOperation(name='selectHeights') |
|
116 | 117 | op.addParameter(name='minHei', value='80', format='float') |
|
117 | 118 | op.addParameter(name='maxHei', value='200', format='float') |
|
118 | 119 | |
|
119 | 120 | op = proc_unit.addOperation(name='removeDC') |
|
120 | 121 | |
|
121 | 122 | op = proc_unit.addOperation(name='SpectraPlot', optype='other') |
|
122 | 123 | op.addParameter(name='id', value='6', format='int') |
|
123 | 124 | op.addParameter(name='wintitle', value='Spectra', format='str') |
|
124 | 125 | |
|
125 | 126 | op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
126 | 127 | op.addParameter(name='id', value='2', format='int') |
|
127 | 128 | op.addParameter(name='wintitle', value='RTI', format='str') |
|
128 | 129 | |
|
129 | 130 | controller.start() |
|
130 | 131 | |
|
131 |
``` |
|
|
132 | ``` No newline at end of file |
@@ -1,48 +1,48 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Jul 16, 2014 |
|
3 | 3 | |
|
4 | 4 | @author: Miguel Urco |
|
5 | 5 | ''' |
|
6 | ||
|
7 | from schainpy import __version__ | |
|
6 | import numpy | |
|
8 | 7 | from setuptools import setup, Extension |
|
8 | from schainpy import __version__ | |
|
9 | 9 | |
|
10 | 10 | setup(name="schainpy", |
|
11 | 11 | version=__version__, |
|
12 | 12 | description="Python tools to read, write and process Jicamarca data", |
|
13 | 13 | author="Miguel Urco", |
|
14 | 14 | author_email="miguel.urco@jro.igp.gob.pe", |
|
15 | 15 | url="http://jro.igp.gob.pe", |
|
16 | 16 | packages = {'schainpy', |
|
17 | 17 | 'schainpy.model', |
|
18 | 18 | 'schainpy.model.data', |
|
19 | 19 | 'schainpy.model.graphics', |
|
20 | 20 | 'schainpy.model.io', |
|
21 | 21 | 'schainpy.model.proc', |
|
22 | 22 | 'schainpy.model.serializer', |
|
23 | 23 | 'schainpy.model.utils', |
|
24 | 24 | 'schainpy.gui', |
|
25 | 25 | 'schainpy.gui.figures', |
|
26 | 26 | 'schainpy.gui.viewcontroller', |
|
27 | 27 | 'schainpy.gui.viewer', |
|
28 | 28 | 'schainpy.gui.viewer.windows'}, |
|
29 | 29 | ext_package='schainpy', |
|
30 | 30 | py_modules=[''], |
|
31 | 31 | package_data={'': ['schain.conf.template'], |
|
32 | 32 | 'schainpy.gui.figures': ['*.png','*.jpg'], |
|
33 | 33 | }, |
|
34 | 34 | include_package_data=False, |
|
35 | 35 | scripts =['schainpy/gui/schainGUI', |
|
36 | 36 | 'schainpy/scripts/schain'], |
|
37 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
|
37 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"], include_dirs=[numpy.get_include()])], | |
|
38 | 38 | install_requires=[ |
|
39 | 39 | "scipy >= 0.14.0", |
|
40 | 40 | "h5py >= 2.2.1", |
|
41 | 41 | "matplotlib >= 1.4.2", |
|
42 | 42 | "pyfits >= 3.4", |
|
43 | 43 | "numpy >= 1.11.2", |
|
44 | 44 | "paramiko >= 2.1.2", |
|
45 | 45 | "paho-mqtt >= 1.2", |
|
46 | 46 | "zmq", |
|
47 | 47 | ], |
|
48 | 48 | ) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now