@@ -5,8 +5,8 | |||||
5 | # from schainpy.model.utils.jroutils import * |
|
5 | # from schainpy.model.utils.jroutils import * | |
6 | # from schainpy.serializer import * |
|
6 | # from schainpy.serializer import * | |
7 |
|
7 | |||
|
8 | from graphics import * | |||
8 | from data import * |
|
9 | from data import * | |
9 | from io import * |
|
10 | from io import * | |
10 | from proc import * |
|
11 | from proc import * | |
11 | from graphics import * |
|
|||
12 | from utils import * |
|
12 | from utils import * |
@@ -4,7 +4,7 import sys | |||||
4 | import matplotlib |
|
4 | import matplotlib | |
5 |
|
5 | |||
6 | if 'linux' in sys.platform: |
|
6 | if 'linux' in sys.platform: | |
7 |
matplotlib.use("T |
|
7 | matplotlib.use("TkAgg") | |
8 |
|
8 | |||
9 | if 'darwin' in sys.platform: |
|
9 | if 'darwin' in sys.platform: | |
10 | matplotlib.use('TKAgg') |
|
10 | matplotlib.use('TKAgg') | |
@@ -21,15 +21,19 from matplotlib.ticker import FuncFormatter, LinearLocator | |||||
21 | # create jro colormap |
|
21 | # create jro colormap | |
22 |
|
22 | |||
23 | jet_values = matplotlib.pyplot.get_cmap("jet", 100)(numpy.arange(100))[10:90] |
|
23 | jet_values = matplotlib.pyplot.get_cmap("jet", 100)(numpy.arange(100))[10:90] | |
24 |
blu_values = matplotlib.pyplot.get_cmap( |
|
24 | blu_values = matplotlib.pyplot.get_cmap( | |
25 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list("jro", numpy.vstack((blu_values, jet_values))) |
|
25 | "seismic_r", 20)(numpy.arange(20))[10:15] | |
|
26 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list( | |||
|
27 | "jro", numpy.vstack((blu_values, jet_values))) | |||
26 | matplotlib.pyplot.register_cmap(cmap=ncmap) |
|
28 | matplotlib.pyplot.register_cmap(cmap=ncmap) | |
27 |
|
29 | |||
|
30 | ||||
28 |
def createFigure(id, wintitle, width, height, facecolor="w", show=True, dpi |
|
31 | def createFigure(id, wintitle, width, height, facecolor="w", show=True, dpi=80): | |
29 |
|
32 | |||
30 | matplotlib.pyplot.ioff() |
|
33 | matplotlib.pyplot.ioff() | |
31 |
|
34 | |||
32 |
fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor, figsize=( |
|
35 | fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor, figsize=( | |
|
36 | 1.0 * width / dpi, 1.0 * height / dpi)) | |||
33 | fig.canvas.manager.set_window_title(wintitle) |
|
37 | fig.canvas.manager.set_window_title(wintitle) | |
34 | # fig.canvas.manager.resize(width, height) |
|
38 | # fig.canvas.manager.resize(width, height) | |
35 | matplotlib.pyplot.ion() |
|
39 | matplotlib.pyplot.ion() | |
@@ -39,6 +43,7 def createFigure(id, wintitle, width, height, facecolor="w", show=True, dpi = 80 | |||||
39 |
|
43 | |||
40 | return fig |
|
44 | return fig | |
41 |
|
45 | |||
|
46 | ||||
42 | def closeFigure(show=False, fig=None): |
|
47 | def closeFigure(show=False, fig=None): | |
43 |
|
48 | |||
44 | # matplotlib.pyplot.ioff() |
|
49 | # matplotlib.pyplot.ioff() | |
@@ -60,24 +65,29 def closeFigure(show=False, fig=None): | |||||
60 |
|
65 | |||
61 | return |
|
66 | return | |
62 |
|
67 | |||
|
68 | ||||
63 | def saveFigure(fig, filename): |
|
69 | def saveFigure(fig, filename): | |
64 |
|
70 | |||
65 | # matplotlib.pyplot.ioff() |
|
71 | # matplotlib.pyplot.ioff() | |
66 | fig.savefig(filename, dpi=matplotlib.pyplot.gcf().dpi) |
|
72 | fig.savefig(filename, dpi=matplotlib.pyplot.gcf().dpi) | |
67 | # matplotlib.pyplot.ion() |
|
73 | # matplotlib.pyplot.ion() | |
68 |
|
74 | |||
|
75 | ||||
69 | def clearFigure(fig): |
|
76 | def clearFigure(fig): | |
70 |
|
77 | |||
71 | fig.clf() |
|
78 | fig.clf() | |
72 |
|
79 | |||
|
80 | ||||
73 | def setWinTitle(fig, title): |
|
81 | def setWinTitle(fig, title): | |
74 |
|
82 | |||
75 | fig.canvas.manager.set_window_title(title) |
|
83 | fig.canvas.manager.set_window_title(title) | |
76 |
|
84 | |||
|
85 | ||||
77 | def setTitle(fig, title): |
|
86 | def setTitle(fig, title): | |
78 |
|
87 | |||
79 | fig.suptitle(title) |
|
88 | fig.suptitle(title) | |
80 |
|
89 | |||
|
90 | ||||
81 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False): |
|
91 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False): | |
82 |
|
92 | |||
83 | matplotlib.pyplot.ioff() |
|
93 | matplotlib.pyplot.ioff() | |
@@ -91,6 +101,7 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False): | |||||
91 | matplotlib.pyplot.ion() |
|
101 | matplotlib.pyplot.ion() | |
92 | return axes |
|
102 | return axes | |
93 |
|
103 | |||
|
104 | ||||
94 | def setAxesText(ax, text): |
|
105 | def setAxesText(ax, text): | |
95 |
|
106 | |||
96 | ax.annotate(text, |
|
107 | ax.annotate(text, | |
@@ -100,17 +111,18 def setAxesText(ax, text): | |||||
100 |
verticalalignment |
|
111 | verticalalignment='top', | |
101 |
fontsize |
|
112 | fontsize=10) | |
102 |
|
113 | |||
|
114 | ||||
103 | def printLabels(ax, xlabel, ylabel, title): |
|
115 | def printLabels(ax, xlabel, ylabel, title): | |
104 |
|
116 | |||
105 | ax.set_xlabel(xlabel, size=11) |
|
117 | ax.set_xlabel(xlabel, size=11) | |
106 | ax.set_ylabel(ylabel, size=11) |
|
118 | ax.set_ylabel(ylabel, size=11) | |
107 | ax.set_title(title, size=8) |
|
119 | ax.set_title(title, size=8) | |
108 |
|
120 | |||
|
121 | ||||
109 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', |
|
122 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', | |
110 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
123 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
111 | nxticks=4, nyticks=10, |
|
124 | nxticks=4, nyticks=10, | |
112 | grid=None,color='blue'): |
|
125 | grid=None, color='blue'): | |
113 |
|
||||
114 | """ |
|
126 | """ | |
115 |
|
127 | |||
116 | Input: |
|
128 | Input: | |
@@ -130,7 +142,8 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='' | |||||
130 | xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos]) |
|
142 | xtickspos = numpy.array([float("%.1f" % i) for i in xtickspos]) | |
131 | ax.set_xticks(xtickspos) |
|
143 | ax.set_xticks(xtickspos) | |
132 | else: |
|
144 | else: | |
133 |
xtickspos = numpy.arange(nxticks)* |
|
145 | xtickspos = numpy.arange(nxticks) * \ | |
|
146 | int((xmax - xmin) / (nxticks)) + int(xmin) | |||
134 | # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin) |
|
147 | # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin) | |
135 | ax.set_xticks(xtickspos) |
|
148 | ax.set_xticks(xtickspos) | |
136 |
|
149 | |||
@@ -168,10 +181,12 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='' | |||||
168 |
|
181 | |||
169 | return iplot |
|
182 | return iplot | |
170 |
|
183 | |||
|
184 | ||||
171 | def set_linedata(ax, x, y, idline): |
|
185 | def set_linedata(ax, x, y, idline): | |
172 |
|
186 | |||
173 | ax.lines[idline].set_data(x,y) |
|
187 | ax.lines[idline].set_data(x, y) | |
174 |
|
188 | |||
|
189 | ||||
175 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
190 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): | |
176 |
|
191 | |||
177 | ax = iplot.axes |
|
192 | ax = iplot.axes | |
@@ -180,6 +195,7 def pline(iplot, x, y, xlabel='', ylabel='', title=''): | |||||
180 |
|
195 | |||
181 | set_linedata(ax, x, y, idline=0) |
|
196 | set_linedata(ax, x, y, idline=0) | |
182 |
|
197 | |||
|
198 | ||||
183 | def addpline(ax, x, y, color, linestyle, lw): |
|
199 | def addpline(ax, x, y, color, linestyle, lw): | |
184 |
|
200 | |||
185 | ax.plot(x,y,color=color,linestyle=linestyle,lw=lw) |
|
201 | ax.plot(x, y, color=color, linestyle=linestyle, lw=lw) | |
@@ -235,13 +251,15 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, | |||||
235 |
|
251 | |||
236 | if XAxisAsTime: |
|
252 | if XAxisAsTime: | |
237 |
|
253 | |||
238 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
254 | def func(x, pos): return ('%s') % ( | |
|
255 | datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) | |||
239 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
256 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
240 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
257 | ax.xaxis.set_major_locator(LinearLocator(7)) | |
241 |
|
258 | |||
242 | matplotlib.pyplot.ion() |
|
259 | matplotlib.pyplot.ion() | |
243 | return imesh |
|
260 | return imesh | |
244 |
|
261 | |||
|
262 | ||||
245 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): |
|
263 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): | |
246 |
|
264 | |||
247 | z = z.T |
|
265 | z = z.T | |
@@ -249,11 +267,14 def pcolor(imesh, z, xlabel='', ylabel='', title=''): | |||||
249 | printLabels(ax, xlabel, ylabel, title) |
|
267 | printLabels(ax, xlabel, ylabel, title) | |
250 | imesh.set_array(z.ravel()) |
|
268 | imesh.set_array(z.ravel()) | |
251 |
|
269 | |||
|
270 | ||||
252 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): |
|
271 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): | |
253 |
|
272 | |||
254 | printLabels(ax, xlabel, ylabel, title) |
|
273 | printLabels(ax, xlabel, ylabel, title) | |
255 |
|
274 | |||
256 |
ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, |
|
275 | ax.pcolormesh(x, y, z.T, vmin=zmin, vmax=zmax, | |
|
276 | cmap=matplotlib.pyplot.get_cmap(colormap)) | |||
|
277 | ||||
257 |
|
278 | |||
258 | def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): |
|
279 | def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): | |
259 |
|
280 | |||
@@ -266,14 +287,13 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', col | |||||
266 | cmap=matplotlib.pyplot.get_cmap(colormap) |
|
287 | cmap = matplotlib.pyplot.get_cmap(colormap) | |
267 | cmap.set_bad('black', 1.) |
|
288 | cmap.set_bad('black', 1.) | |
268 |
|
289 | |||
269 |
|
||||
270 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=cmap) |
|
290 | ax.pcolormesh(x, y, z.T, vmin=zmin, vmax=zmax, cmap=cmap) | |
271 |
|
291 | |||
|
292 | ||||
272 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
293 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, | |
273 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
294 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
274 | nxticks=4, nyticks=10, |
|
295 | nxticks=4, nyticks=10, | |
275 | grid=None): |
|
296 | grid=None): | |
276 |
|
||||
277 | """ |
|
297 | """ | |
278 |
|
298 | |||
279 | Input: |
|
299 | Input: | |
@@ -289,7 +309,8 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', tit | |||||
289 | ax.set_ylim([ymin,ymax]) |
|
309 | ax.set_ylim([ymin, ymax]) | |
290 | printLabels(ax, xlabel, ylabel, title) |
|
310 | printLabels(ax, xlabel, ylabel, title) | |
291 |
|
311 | |||
292 |
xtickspos = numpy.arange(nxticks)* |
|
312 | xtickspos = numpy.arange(nxticks) * \ | |
|
313 | int((xmax - xmin) / (nxticks)) + int(xmin) | |||
293 | ax.set_xticks(xtickspos) |
|
314 | ax.set_xticks(xtickspos) | |
294 |
|
315 | |||
295 | for tick in ax.get_xticklabels(): |
|
316 | for tick in ax.get_xticklabels(): | |
@@ -334,11 +355,11 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): | |||||
334 | line = ax.lines[i] |
|
355 | line = ax.lines[i] | |
335 | line.set_data(x[i,:],y) |
|
356 | line.set_data(x[i, :], y) | |
336 |
|
357 | |||
|
358 | ||||
337 | def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
359 | def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, | |
338 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
360 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
339 | nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None", |
|
361 | nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None", | |
340 | grid=None, XAxisAsTime=False): |
|
362 | grid=None, XAxisAsTime=False): | |
341 |
|
||||
342 | """ |
|
363 | """ | |
343 |
|
364 | |||
344 | Input: |
|
365 | Input: | |
@@ -355,7 +376,8 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='' | |||||
355 | leg = ax.legend(lines, legendlabels, |
|
376 | leg = ax.legend(lines, legendlabels, | |
356 | loc='upper right', bbox_to_anchor=(1.16, 1), borderaxespad=0) |
|
377 | loc='upper right', bbox_to_anchor=(1.16, 1), borderaxespad=0) | |
357 |
|
378 | |||
358 |
for label in leg.get_texts(): |
|
379 | for label in leg.get_texts(): | |
|
380 | label.set_fontsize(9) | |||
359 |
|
381 | |||
360 | ax.set_xlim([xmin,xmax]) |
|
382 | ax.set_xlim([xmin, xmax]) | |
361 | ax.set_ylim([ymin,ymax]) |
|
383 | ax.set_ylim([ymin, ymax]) | |
@@ -393,7 +415,8 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='' | |||||
393 |
|
415 | |||
394 | if XAxisAsTime: |
|
416 | if XAxisAsTime: | |
395 |
|
417 | |||
396 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
418 | def func(x, pos): return ('%s') % ( | |
|
419 | datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) | |||
397 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
420 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
398 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
421 | ax.xaxis.set_major_locator(LinearLocator(7)) | |
399 |
|
422 | |||
@@ -401,6 +424,7 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='' | |||||
401 |
|
424 | |||
402 | return iplot |
|
425 | return iplot | |
403 |
|
426 | |||
|
427 | ||||
404 | def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''): |
|
428 | def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''): | |
405 |
|
429 | |||
406 | ax = iplot.axes |
|
430 | ax = iplot.axes | |
@@ -411,6 +435,7 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''): | |||||
411 | line = ax.lines[i] |
|
435 | line = ax.lines[i] | |
412 | line.set_data(x,y[i,:]) |
|
436 | line.set_data(x, y[i, :]) | |
413 |
|
437 | |||
|
438 | ||||
414 | def createPolar(ax, x, y, |
|
439 | def createPolar(ax, x, y, | |
415 |
xlabel='', ylabel='', title='', ticksize |
|
440 | xlabel='', ylabel='', title='', ticksize=9, | |
416 |
|
|
441 | colormap='jet', cblabel='', cbsize="5%", | |
@@ -444,9 +469,9 def createPolar(ax, x, y, | |||||
444 |
|
469 | |||
445 | matplotlib.pyplot.ion() |
|
470 | matplotlib.pyplot.ion() | |
446 |
|
471 | |||
447 |
|
||||
448 | return iplot |
|
472 | return iplot | |
449 |
|
473 | |||
|
474 | ||||
450 | def polar(iplot, x, y, xlabel='', ylabel='', title=''): |
|
475 | def polar(iplot, x, y, xlabel='', ylabel='', title=''): | |
451 |
|
476 | |||
452 | ax = iplot.axes |
|
477 | ax = iplot.axes | |
@@ -456,6 +481,7 def polar(iplot, x, y, xlabel='', ylabel='', title=''): | |||||
456 |
|
481 | |||
457 | set_linedata(ax, x, y, idline=0) |
|
482 | set_linedata(ax, x, y, idline=0) | |
458 |
|
483 | |||
|
484 | ||||
459 | def draw(fig): |
|
485 | def draw(fig): | |
460 |
|
486 | |||
461 | if type(fig) == 'int': |
|
487 | if type(fig) == 'int': | |
@@ -463,6 +489,7 def draw(fig): | |||||
463 |
|
489 | |||
464 | fig.canvas.draw() |
|
490 | fig.canvas.draw() | |
465 |
|
491 | |||
|
492 | ||||
466 | def pause(interval=0.000001): |
|
493 | def pause(interval=0.000001): | |
467 |
|
494 | |||
468 | matplotlib.pyplot.pause(interval) |
|
495 | matplotlib.pyplot.pause(interval) |
@@ -1,4 +1,5 | |||||
1 |
import os |
|
1 | import os | |
|
2 | import sys | |||
2 | import glob |
|
3 | import glob | |
3 | import fnmatch |
|
4 | import fnmatch | |
4 | import datetime |
|
5 | import datetime | |
@@ -6,9 +7,7 import time | |||||
6 | import re |
|
7 | import re | |
7 | import h5py |
|
8 | import h5py | |
8 | import numpy |
|
9 | import numpy | |
9 | import matplotlib.pyplot as plt |
|
|||
10 |
|
10 | |||
11 | import pylab as plb |
|
|||
12 | from scipy.optimize import curve_fit |
|
11 | from scipy.optimize import curve_fit | |
13 | from scipy import asarray as ar,exp |
|
12 | from scipy import asarray as ar, exp | |
14 | from scipy import stats |
|
13 | from scipy import stats | |
@@ -31,15 +30,20 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |||||
31 | from numpy import imag, shape, NaN |
|
30 | from numpy import imag, shape, NaN | |
32 |
|
31 | |||
33 |
|
32 | |||
34 | startFp = open('/home/erick/Documents/MIRA35C/20160117/20160117_0000.zspc',"rb") |
|
33 | startFp = open( | |
|
34 | '/home/erick/Documents/MIRA35C/20160117/20160117_0000.zspc', "rb") | |||
35 |
|
35 | |||
36 |
|
36 | |||
37 |
FILE_HEADER = numpy.dtype([ |
|
37 | FILE_HEADER = numpy.dtype([ # HEADER 1024bytes | |
38 |
('Hname',numpy.str_,32), |
|
38 | ('Hname', numpy.str_, 32), # Original file name | |
39 |
|
|
39 | # Date and time when the file was created | |
40 |
('H |
|
40 | ('Htime', numpy.str_, 32), | |
41 | ('Hplace',numpy.str_,128), #Place where the measurements was carried out |
|
41 | # Name of operator who created the file | |
42 |
('H |
|
42 | ('Hoper', numpy.str_, 64), | |
|
43 | # Place where the measurements was carried out | |||
|
44 | ('Hplace', numpy.str_, 128), | |||
|
45 | # Description of measurements | |||
|
46 | ('Hdescr', numpy.str_, 256), | |||
43 |
('Hdummy',numpy.str_,512), |
|
47 | ('Hdummy', numpy.str_, 512), # Reserved space | |
44 | #Main chunk |
|
48 | # Main chunk | |
45 |
('Msign','<i4'), |
|
49 | ('Msign', '<i4'), # Main chunk signature FZKF or NUIG | |
@@ -50,19 +54,28 FILE_HEADER = numpy.dtype([ #HEADER 1024bytes | |||||
50 |
('PPARprf','<i4'), |
|
54 | ('PPARprf', '<i4'), # Pulse repetition frequency | |
51 |
('PPARpdr','<i4'), |
|
55 | ('PPARpdr', '<i4'), # Pulse duration | |
52 |
('PPARsft','<i4'), |
|
56 | ('PPARsft', '<i4'), # FFT length | |
53 |
|
|
57 | # Number of spectral (in-coherent) averages | |
54 | ('PPARihp','<i4'), #Number of lowest range gate for moment estimation |
|
58 | ('PPARavc', '<i4'), | |
55 |
|
|
59 | # Number of lowest range gate for moment estimation | |
56 | ('PPARpol','<i4'), #switch on/off polarimetric measurements. Should be 1. |
|
60 | ('PPARihp', '<i4'), | |
|
61 | # Count for gates for moment estimation | |||
|
62 | ('PPARchg', '<i4'), | |||
|
63 | # switch on/off polarimetric measurements. Should be 1. | |||
|
64 | ('PPARpol', '<i4'), | |||
57 | #Service DSP parameters |
|
65 | # Service DSP parameters | |
58 |
|
|
66 | # STC attenuation on the lowest ranges on/off | |
|
67 | ('SPARatt', '<i4'), | |||
59 |
('SPARtx','<i4'), |
|
68 | ('SPARtx', '<i4'), # OBSOLETE | |
60 | ('SPARaddGain0','<f4'), #OBSOLETE |
|
69 | ('SPARaddGain0', '<f4'), # OBSOLETE | |
61 | ('SPARaddGain1','<f4'), #OBSOLETE |
|
70 | ('SPARaddGain1', '<f4'), # OBSOLETE | |
62 |
|
|
71 | # Debug only. It normal mode it is 0. | |
63 | ('SPARpos','<i4'), #Delay between sync pulse and tx pulse for phase corr, ns |
|
72 | ('SPARwnd', '<i4'), | |
64 | ('SPARadd','<i4'), #"add to pulse" to compensate for delay between the leading edge of driver pulse and envelope of the RF signal. |
|
73 | # Delay between sync pulse and tx pulse for phase corr, ns | |
65 | ('SPARlen','<i4'), #Time for measuring txn pulse phase. OBSOLETE |
|
74 | ('SPARpos', '<i4'), | |
|
75 | # "add to pulse" to compensate for delay between the leading edge of driver pulse and envelope of the RF signal. | |||
|
76 | ('SPARadd', '<i4'), | |||
|
77 | # Time for measuring txn pulse phase. OBSOLETE | |||
|
78 | ('SPARlen', '<i4'), | |||
66 |
('SPARcal','<i4'), |
|
79 | ('SPARcal', '<i4'), # OBSOLETE | |
67 |
('SPARnos','<i4'), |
|
80 | ('SPARnos', '<i4'), # OBSOLETE | |
68 |
('SPARof0','<i4'), |
|
81 | ('SPARof0', '<i4'), # detection threshold | |
@@ -73,19 +86,23 FILE_HEADER = numpy.dtype([ #HEADER 1024bytes | |||||
73 |
('SPARtst','<i4'), |
|
86 | ('SPARtst', '<i4'), # OBSOLETE | |
74 |
('SPARcor','<i4'), |
|
87 | ('SPARcor', '<i4'), # OBSOLETE | |
75 |
('SPARofs','<i4'), |
|
88 | ('SPARofs', '<i4'), # OBSOLETE | |
76 |
|
|
89 | # Hildebrand div noise detection on noise gate | |
77 |
('SPARhs |
|
90 | ('SPARhsn', '<i4'), | |
|
91 | # Hildebrand div noise detection on all gates | |||
|
92 | ('SPARhsa', '<f4'), | |||
78 |
('SPARcalibPow_M','<f4'), |
|
93 | ('SPARcalibPow_M', '<f4'), # OBSOLETE | |
79 |
('SPARcalibSNR_M','<f4'), |
|
94 | ('SPARcalibSNR_M', '<f4'), # OBSOLETE | |
80 |
('SPARcalibPow_S','<f4'), |
|
95 | ('SPARcalibPow_S', '<f4'), # OBSOLETE | |
81 |
('SPARcalibSNR_S','<f4'), |
|
96 | ('SPARcalibSNR_S', '<f4'), # OBSOLETE | |
82 |
|
|
97 | # Lowest range gate for spectra saving Raw_Gate1 >=5 | |
83 |
('SPARrawGate |
|
98 | ('SPARrawGate1', '<i4'), | |
84 | ('SPARraw','<i4'), #flag - IQ or spectra saving on/off |
|
99 | # Number of range gates with atmospheric signal | |
|
100 | ('SPARrawGate2', '<i4'), | |||
|
101 | # flag - IQ or spectra saving on/off | |||
|
102 | ('SPARraw', '<i4'), | |||
85 |
('SPARprc','<i4'),]) |
|
103 | ('SPARprc', '<i4'), ]) # flag - Moment estimation switched on/off | |
86 |
|
104 | |||
87 |
|
105 | |||
88 |
|
||||
89 |
self.Hname= None |
|
106 | self.Hname = None | |
90 | self.Htime= None |
|
107 | self.Htime = None | |
91 | self.Hoper= None |
|
108 | self.Hoper = None | |
@@ -136,7 +153,6 self.SPARraw=None | |||||
136 |
self.SPARprc=None |
|
153 | self.SPARprc = None | |
137 |
|
154 | |||
138 |
|
155 | |||
139 |
|
||||
140 | header = numpy.fromfile(fp, FILE_HEADER,1) |
|
156 | header = numpy.fromfile(fp, FILE_HEADER, 1) | |
141 | ''' numpy.fromfile(file, dtype, count, sep='') |
|
157 | ''' numpy.fromfile(file, dtype, count, sep='') | |
142 | file : file or str |
|
158 | file : file or str | |
@@ -207,9 +223,8 SPARraw=header['SPARraw'][0] | |||||
207 | SPARprc=header['SPARprc'][0] |
|
223 | SPARprc = header['SPARprc'][0] | |
208 |
|
224 | |||
209 |
|
225 | |||
210 |
|
||||
211 |
SRVI_STRUCTURE = numpy.dtype([ |
|
226 | SRVI_STRUCTURE = numpy.dtype([ | |
212 |
('frame_cnt','<u4'), |
|
227 | ('frame_cnt', '<u4'), | |
213 | ('time_t','<u4'), # |
|
228 | ('time_t', '<u4'), # | |
214 | ('tpow','<f4'), # |
|
229 | ('tpow', '<f4'), # | |
215 | ('npw1','<f4'), # |
|
230 | ('npw1', '<f4'), # | |
@@ -225,19 +240,18 SRVI_STRUCTURE = numpy.dtype([ | |||||
225 | ('azivel','<f4'), # |
|
240 | ('azivel', '<f4'), # | |
226 | ('elvpos','<f4'), # |
|
241 | ('elvpos', '<f4'), # | |
227 | ('elvvel','<f4'), # |
|
242 | ('elvvel', '<f4'), # | |
228 |
('northAngle','<f4'), |
|
243 | ('northAngle', '<f4'), | |
229 | ('microsec','<u4'), # |
|
244 | ('microsec', '<u4'), # | |
230 | ('azisetvel','<f4'), # |
|
245 | ('azisetvel', '<f4'), # | |
231 | ('elvsetpos','<f4'), # |
|
246 | ('elvsetpos', '<f4'), # | |
232 |
('RadarConst','<f4'),]) # |
|
247 | ('RadarConst', '<f4'), ]) # | |
233 |
|
248 | |||
234 |
JUMP_STRUCTURE = numpy.dtype([ |
|
249 | JUMP_STRUCTURE = numpy.dtype([ | |
235 |
('jump','<u140'), |
|
250 | ('jump', '<u140'), | |
236 |
('SizeOfDataBlock1',numpy.str_,32), |
|
251 | ('SizeOfDataBlock1', numpy.str_, 32), | |
237 |
('jump','<i4'), |
|
252 | ('jump', '<i4'), | |
238 |
('DataBlockTitleSRVI1',numpy.str_,32), |
|
253 | ('DataBlockTitleSRVI1', numpy.str_, 32), | |
239 |
('SizeOfSRVI1','<i4'),]) |
|
254 | ('SizeOfSRVI1', '<i4'), ]) | |
240 |
|
||||
241 |
|
255 | |||
242 |
|
256 | |||
243 |
#frame_cnt=0, time_t= 0, tpow=0, npw1=0, npw2=0, |
|
257 | # frame_cnt=0, time_t= 0, tpow=0, npw1=0, npw2=0, | |
@@ -269,7 +283,6 elvsetpos = elvsetpos | |||||
269 | RadarConst5 = RadarConst |
|
283 | RadarConst5 = RadarConst | |
270 |
|
284 | |||
271 |
|
285 | |||
272 |
|
||||
273 | #print fp |
|
286 | # print fp | |
274 | #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file. |
|
287 | # startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file. | |
275 | #startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file. |
|
288 | # startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file. | |
@@ -283,7 +296,7 print 'Posicion del bloque: ',OffRHeader | |||||
283 |
|
296 | |||
284 | header = numpy.fromfile(startFp,SRVI_STRUCTURE,1) |
|
297 | header = numpy.fromfile(startFp, SRVI_STRUCTURE, 1) | |
285 |
|
298 | |||
286 |
self.frame_cnt = header['frame_cnt'][0] |
|
299 | self.frame_cnt = header['frame_cnt'][0] | |
287 | self.time_t = header['frame_cnt'][0] # |
|
300 | self.time_t = header['frame_cnt'][0] # | |
288 | self.tpow = header['frame_cnt'][0] # |
|
301 | self.tpow = header['frame_cnt'][0] # | |
289 | self.npw1 = header['frame_cnt'][0] # |
|
302 | self.npw1 = header['frame_cnt'][0] # | |
@@ -316,6 +329,3 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec | |||||
316 | print '==============================================' |
|
329 | print '==============================================' | |
317 |
|
330 | |||
318 | print '==============================================' |
|
331 | print '==============================================' | |
319 |
|
||||
320 |
|
||||
321 | No newline at end of file |
|
@@ -1,4 +1,5 | |||||
1 |
import os |
|
1 | import os | |
|
2 | import sys | |||
2 | import glob |
|
3 | import glob | |
3 | import fnmatch |
|
4 | import fnmatch | |
4 | import datetime |
|
5 | import datetime | |
@@ -6,7 +7,6 import time | |||||
6 | import re |
|
7 | import re | |
7 | import h5py |
|
8 | import h5py | |
8 | import numpy |
|
9 | import numpy | |
9 | import matplotlib.pyplot as plt |
|
|||
10 |
|
10 | |||
11 | import pylab as plb |
|
11 | import pylab as plb | |
12 | from scipy.optimize import curve_fit |
|
12 | from scipy.optimize import curve_fit | |
@@ -37,7 +37,6 class Header(object): | |||||
37 | def __init__(self): |
|
37 | def __init__(self): | |
38 | raise NotImplementedError |
|
38 | raise NotImplementedError | |
39 |
|
39 | |||
40 |
|
||||
41 | def read(self): |
|
40 | def read(self): | |
42 |
|
41 | |||
43 | raise NotImplementedError |
|
42 | raise NotImplementedError | |
@@ -67,23 +66,23 class Header(object): | |||||
67 | #print message |
|
66 | # print message | |
68 |
|
67 | |||
69 |
|
68 | |||
70 |
|
||||
71 |
|
||||
72 |
|
||||
73 |
FILE_STRUCTURE = numpy.dtype([ |
|
69 | FILE_STRUCTURE = numpy.dtype([ # HEADER 48bytes | |
74 |
|
|
70 | ('FileMgcNumber', '<u4'), # 0x23020100 | |
75 |
|
|
71 | # No Of FDT data records in this file (0 or more) | |
|
72 | ('nFDTdataRecors', '<u4'), | |||
76 |
|
|
73 | ('OffsetStartHeader', '<u4'), | |
77 |
|
|
74 | ('RadarUnitId', '<u4'), | |
78 |
|
|
75 | ('SiteName', numpy.str_, 32), # Null terminated | |
79 | ]) |
|
76 | ]) | |
80 |
|
77 | |||
|
78 | ||||
81 | class FileHeaderBLTR(Header): |
|
79 | class FileHeaderBLTR(Header): | |
82 |
|
80 | |||
83 | def __init__(self): |
|
81 | def __init__(self): | |
84 |
|
82 | |||
85 |
self.FileMgcNumber= 0 |
|
83 | self.FileMgcNumber = 0 # 0x23020100 | |
86 |
|
|
84 | # No Of FDT data records in this file (0 or more) | |
|
85 | self.nFDTdataRecors = 0 | |||
87 | self.RadarUnitId= 0 |
|
86 | self.RadarUnitId = 0 | |
88 | self.OffsetStartHeader=0 |
|
87 | self.OffsetStartHeader = 0 | |
89 | self.SiteName= "" |
|
88 | self.SiteName = "" | |
@@ -99,7 +98,6 class FileHeaderBLTR(Header): | |||||
99 | print 'puntero file header', startFp.tell() |
|
98 | print 'puntero file header', startFp.tell() | |
100 | print ' ' |
|
99 | print ' ' | |
101 |
|
100 | |||
102 |
|
||||
103 | ''' numpy.fromfile(file, dtype, count, sep='') |
|
101 | ''' numpy.fromfile(file, dtype, count, sep='') | |
104 | file : file or str |
|
102 | file : file or str | |
105 | Open file object or filename. |
|
103 | Open file object or filename. | |
@@ -119,23 +117,20 class FileHeaderBLTR(Header): | |||||
119 |
|
117 | |||
120 | ''' |
|
118 | ''' | |
121 |
|
119 | |||
122 |
|
||||
123 |
|
||||
124 | self.FileMgcNumber= hex(header['FileMgcNumber'][0]) |
|
120 | self.FileMgcNumber = hex(header['FileMgcNumber'][0]) | |
125 |
|
|
121 | # No Of FDT data records in this file (0 or more) | |
|
122 | self.nFDTdataRecors = int(header['nFDTdataRecors'][0]) | |||
126 | self.RadarUnitId= int(header['RadarUnitId'][0]) |
|
123 | self.RadarUnitId = int(header['RadarUnitId'][0]) | |
127 | self.OffsetStartHeader= int(header['OffsetStartHeader'][0]) |
|
124 | self.OffsetStartHeader = int(header['OffsetStartHeader'][0]) | |
128 | self.SiteName= str(header['SiteName'][0]) |
|
125 | self.SiteName = str(header['SiteName'][0]) | |
129 |
|
126 | |||
130 | #print 'Numero de bloques', self.nFDTdataRecors |
|
127 | # print 'Numero de bloques', self.nFDTdataRecors | |
131 |
|
128 | |||
132 |
|
||||
133 | if self.size <48: |
|
129 | if self.size < 48: | |
134 | return 0 |
|
130 | return 0 | |
135 |
|
131 | |||
136 | return 1 |
|
132 | return 1 | |
137 |
|
133 | |||
138 |
|
||||
139 | def write(self, fp): |
|
134 | def write(self, fp): | |
140 |
|
135 | |||
141 | headerTuple = (self.FileMgcNumber, |
|
136 | headerTuple = (self.FileMgcNumber, | |
@@ -144,7 +139,6 class FileHeaderBLTR(Header): | |||||
144 | self.SiteName, |
|
139 | self.SiteName, | |
145 | self.size) |
|
140 | self.size) | |
146 |
|
141 | |||
147 |
|
||||
148 | header = numpy.array(headerTuple, FILE_STRUCTURE) |
|
142 | header = numpy.array(headerTuple, FILE_STRUCTURE) | |
149 | # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) |
|
143 | # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) | |
150 | header.tofile(fp) |
|
144 | header.tofile(fp) | |
@@ -166,56 +160,92 class FileHeaderBLTR(Header): | |||||
166 | return 1 |
|
160 | return 1 | |
167 |
|
161 | |||
168 |
|
162 | |||
169 |
|
||||
170 |
|
||||
171 |
|
||||
172 |
RECORD_STRUCTURE = numpy.dtype([ |
|
163 | RECORD_STRUCTURE = numpy.dtype([ # RECORD HEADER 180+20N bytes | |
173 |
|
|
164 | ('RecMgcNumber', '<u4'), # 0x23030001 | |
174 |
|
|
165 | ('RecCounter', '<u4'), # Record counter(0,1, ...) | |
175 |
|
|
166 | # Offset to start of next record form start of this record | |
176 | ('Off2StartData','<u4'), #Offset to start of data from start of this record |
|
167 | ('Off2StartNxtRec', '<u4'), | |
177 | ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds) |
|
168 | # Offset to start of data from start of this record | |
178 | ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999) |
|
169 | ('Off2StartData', '<u4'), | |
179 | ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated) |
|
170 | # Epoch time stamp of start of acquisition (seconds) | |
180 | ('ExpComment',numpy.str_,32), #Experiment comment (null terminated) |
|
171 | ('nUtime', '<i4'), | |
181 | ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North) |
|
172 | # Millisecond component of time stamp (0,...,999) | |
182 | ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East) |
|
173 | ('nMilisec', '<u4'), | |
183 | ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE) |
|
174 | # Experiment tag name (null terminated) | |
|
175 | ('ExpTagName', numpy.str_, 32), | |||
|
176 | # Experiment comment (null terminated) | |||
|
177 | ('ExpComment', numpy.str_, 32), | |||
|
178 | # Site latitude (from GPS) in degrees (positive implies North) | |||
|
179 | ('SiteLatDegrees', '<f4'), | |||
|
180 | # Site longitude (from GPS) in degrees (positive implies East) | |||
|
181 | ('SiteLongDegrees', '<f4'), | |||
|
182 | # RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE) | |||
|
183 | ('RTCgpsStatus', '<u4'), | |||
184 |
('TransmitFrec','<u4'), |
|
184 | ('TransmitFrec', '<u4'), # Transmit frequency (Hz) | |
185 |
('ReceiveFrec','<u4'), |
|
185 | ('ReceiveFrec', '<u4'), # Receive frequency | |
186 |
|
|
186 | # First local oscillator frequency (Hz) | |
187 | ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2") |
|
187 | ('FirstOsciFrec', '<u4'), | |
188 | ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3) |
|
188 | # (0="O", 1="E", 2="linear 1", 3="linear2") | |
189 | ('nModesInUse','<u4'), #Number of modes in use (1 or 2) |
|
189 | ('Polarisation', '<u4'), | |
190 | ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1) |
|
190 | # Receiver filter settings (0,1,2,3) | |
191 | ('DualModeRange','<u4'), #Dual Mode range correction for these data (m) |
|
191 | ('ReceiverFiltSett', '<u4'), | |
192 |
|
|
192 | # Number of modes in use (1 or 2) | |
193 |
(' |
|
193 | ('nModesInUse', '<u4'), | |
194 | ('nHeights','<u4'), #Number of range gates sampled |
|
194 | # Dual Mode index number for these data (0 or 1) | |
195 | ('StartRangeSamp','<u4'), #Start range of sampling (meters) |
|
195 | ('DualModeIndex', '<u4'), | |
|
196 | # Dual Mode range correction for these data (m) | |||
|
197 | ('DualModeRange', '<u4'), | |||
|
198 | # Number of digital channels acquired (2*N) | |||
|
199 | ('nDigChannels', '<u4'), | |||
|
200 | # Sampling resolution (meters) | |||
|
201 | ('SampResolution', '<u4'), | |||
|
202 | # Number of range gates sampled | |||
|
203 | ('nHeights', '<u4'), | |||
|
204 | # Start range of sampling (meters) | |||
|
205 | ('StartRangeSamp', '<u4'), | |||
196 |
('PRFhz','<u4'), |
|
206 | ('PRFhz', '<u4'), # PRF (Hz) | |
197 |
('nCohInt','<u4'), |
|
207 | ('nCohInt', '<u4'), # Integrations | |
198 |
|
|
208 | # Number of data points transformed | |
199 | ('nChannels','<u4'), #Number of receive beams stored in file (1 or N) |
|
209 | ('nProfiles', '<u4'), | |
|
210 | # Number of receive beams stored in file (1 or N) | |||
|
211 | ('nChannels', '<u4'), | |||
200 |
('nIncohInt','<u4'), |
|
212 | ('nIncohInt', '<u4'), # Number of spectral averages | |
201 |
|
|
213 | # FFT windowing index (0 = no window) | |
202 | ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North) |
|
214 | ('FFTwindowingInd', '<u4'), | |
203 |
|
|
215 | # Beam steer angle (azimuth) in degrees (clockwise from true North) | |
204 | ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
216 | ('BeamAngleAzim', '<f4'), | |
205 | ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
217 | # Beam steer angle (zenith) in degrees (0=> vertical) | |
206 | ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
218 | ('BeamAngleZen', '<f4'), | |
207 |
|
|
219 | # Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs | |
208 | ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
220 | ('AntennaCoord0', '<f4'), | |
209 |
|
|
221 | # Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs | |
210 | ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values |
|
222 | ('AntennaAngl0', '<f4'), | |
211 | ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values |
|
223 | # Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs | |
212 | ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values |
|
224 | ('AntennaCoord1', '<f4'), | |
213 | ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values |
|
225 | # Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs | |
214 | ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values |
|
226 | ('AntennaAngl1', '<f4'), | |
215 | ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values |
|
227 | # Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs | |
216 | ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values |
|
228 | ('AntennaCoord2', '<f4'), | |
217 | ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values |
|
229 | # Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs | |
218 |
(' |
|
230 | ('AntennaAngl2', '<f4'), | |
|
231 | # Receiver phase calibration (degrees) - N values | |||
|
232 | ('RecPhaseCalibr0', '<f4'), | |||
|
233 | # Receiver phase calibration (degrees) - N values | |||
|
234 | ('RecPhaseCalibr1', '<f4'), | |||
|
235 | # Receiver phase calibration (degrees) - N values | |||
|
236 | ('RecPhaseCalibr2', '<f4'), | |||
|
237 | # Receiver amplitude calibration (ratio relative to receiver one) - N values | |||
|
238 | ('RecAmpCalibr0', '<f4'), | |||
|
239 | # Receiver amplitude calibration (ratio relative to receiver one) - N values | |||
|
240 | ('RecAmpCalibr1', '<f4'), | |||
|
241 | # Receiver amplitude calibration (ratio relative to receiver one) - N values | |||
|
242 | ('RecAmpCalibr2', '<f4'), | |||
|
243 | # Receiver gains in dB - N values | |||
|
244 | ('ReceiverGaindB0', '<i4'), | |||
|
245 | # Receiver gains in dB - N values | |||
|
246 | ('ReceiverGaindB1', '<i4'), | |||
|
247 | # Receiver gains in dB - N values | |||
|
248 | ('ReceiverGaindB2', '<i4'), | |||
219 | ]) |
|
249 | ]) | |
220 |
|
250 | |||
221 |
|
251 | |||
@@ -285,12 +315,11 class RecordHeaderBLTR(Header): | |||||
285 |
self.ReceiverGaindB2 = ReceiverGaindB2 |
|
315 | self.ReceiverGaindB2 = ReceiverGaindB2 | |
286 |
self.OffsetStartHeader = |
|
316 | self.OffsetStartHeader = 48 | |
287 |
|
317 | |||
288 |
|
||||
289 |
|
||||
290 | def RHread(self, fp): |
|
318 | def RHread(self, fp): | |
291 | #print fp |
|
319 | # print fp | |
292 | #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file. |
|
320 | # startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file. | |
293 |
|
|
321 | # The method tell() returns the current position of the file read/write pointer within the file. | |
|
322 | startFp = open(fp, "rb") | |||
294 | #RecCounter=0 |
|
323 | # RecCounter=0 | |
295 | #Off2StartNxtRec=811248 |
|
324 | # Off2StartNxtRec=811248 | |
296 | OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec |
|
325 | OffRHeader = self.OffsetStartHeader + self.RecCounter * self.Off2StartNxtRec | |
@@ -298,7 +327,6 class RecordHeaderBLTR(Header): | |||||
298 | print 'puntero Record Header', startFp.tell() |
|
327 | print 'puntero Record Header', startFp.tell() | |
299 | print ' ' |
|
328 | print ' ' | |
300 |
|
329 | |||
301 |
|
||||
302 | startFp.seek(OffRHeader, os.SEEK_SET) |
|
330 | startFp.seek(OffRHeader, os.SEEK_SET) | |
303 |
|
331 | |||
304 | print ' ' |
|
332 | print ' ' | |
@@ -416,11 +444,13 class RecordHeaderBLTR(Header): | |||||
416 | print '==============================================' |
|
444 | print '==============================================' | |
417 |
|
445 | |||
418 | if OffRHeader > endFp: |
|
446 | if OffRHeader > endFp: | |
419 | sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp) |
|
447 | sys.stderr.write( | |
|
448 | "Warning %s: Size value read from System Header is lower than it has to be\n" % fp) | |||
420 | return 0 |
|
449 | return 0 | |
421 |
|
450 | |||
422 | if OffRHeader < endFp: |
|
451 | if OffRHeader < endFp: | |
423 | sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp) |
|
452 | sys.stderr.write( | |
|
453 | "Warning %s: Size value read from System Header size is greater than it has to be\n" % fp) | |||
424 | return 0 |
|
454 | return 0 | |
425 |
|
455 | |||
426 | return 1 |
|
456 | return 1 | |
@@ -436,7 +466,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
436 | walk = None |
|
466 | walk = None | |
437 | isConfig = False |
|
467 | isConfig = False | |
438 |
|
468 | |||
439 |
|
||||
440 | fileList= None |
|
469 | fileList = None | |
441 |
|
470 | |||
442 | #metadata |
|
471 | # metadata | |
@@ -448,8 +477,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
448 | data= None |
|
477 | data = None | |
449 | utctime= None |
|
478 | utctime = None | |
450 |
|
479 | |||
451 |
|
||||
452 |
|
||||
453 | def __init__(self, **kwargs): |
|
480 | def __init__(self, **kwargs): | |
454 |
|
481 | |||
455 | #Eliminar de la base la herencia |
|
482 | # Eliminar de la base la herencia | |
@@ -494,8 +521,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
494 | self.dataOut.velocityY=[] |
|
521 | self.dataOut.velocityY = [] | |
495 | self.dataOut.velocityV=[] |
|
522 | self.dataOut.velocityV = [] | |
496 |
|
523 | |||
497 |
|
||||
498 |
|
||||
499 | def Files2Read(self, fp): |
|
524 | def Files2Read(self, fp): | |
500 | ''' |
|
525 | ''' | |
501 | Function that indicates the number of .fdt files that exist in the folder to be read. |
|
526 | Function that indicates the number of .fdt files that exist in the folder to be read. | |
@@ -503,8 +528,10 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
503 | ''' |
|
528 | ''' | |
504 | #self.__checkPath() |
|
529 | # self.__checkPath() | |
505 |
|
530 | |||
506 |
|
|
531 | # Gets the list of files within the fp address | |
507 | ListaData=sorted(ListaData) #Sort the list of files from least to largest by names |
|
532 | ListaData = os.listdir(fp) | |
|
533 | # Sort the list of files from least to largest by names | |||
|
534 | ListaData = sorted(ListaData) | |||
508 |
nFiles=0 |
|
535 | nFiles = 0 # File Counter | |
509 |
FileList=[] |
|
536 | FileList = [] # A list is created that will contain the .fdt files | |
510 |
for IndexFile in ListaData |
|
537 | for IndexFile in ListaData: | |
@@ -517,7 +544,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
517 |
|
544 | |||
518 | self.filenameList=FileList #List of files from least to largest by names |
|
545 | self.filenameList = FileList # List of files from least to largest by names | |
519 |
|
546 | |||
520 |
|
||||
521 | def run(self, **kwargs): |
|
547 | def run(self, **kwargs): | |
522 | ''' |
|
548 | ''' | |
523 | This method will be the one that will initiate the data entry, will be called constantly. |
|
549 | This method will be the one that will initiate the data entry, will be called constantly. | |
@@ -531,7 +557,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
531 | self.getData() |
|
557 | self.getData() | |
532 | #print 'running' |
|
558 | # print 'running' | |
533 |
|
559 | |||
534 |
|
||||
535 | def setup(self, path=None, |
|
560 | def setup(self, path=None, | |
536 |
|
|
561 | startDate=None, | |
537 |
|
|
562 | endDate=None, | |
@@ -556,7 +581,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
556 |
|
581 | |||
557 | pass |
|
582 | pass | |
558 |
|
583 | |||
559 |
|
||||
560 | def getData(self): |
|
584 | def getData(self): | |
561 | ''' |
|
585 | ''' | |
562 | Before starting this function, you should check that there is still an unread file, |
|
586 | Before starting this function, you should check that there is still an unread file, | |
@@ -583,7 +607,6 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
583 | #self.removeDC() |
|
607 | # self.removeDC() | |
584 |
return self.dataOut.data_spc |
|
608 | return self.dataOut.data_spc | |
585 |
|
609 | |||
586 |
|
||||
587 | def readFile(self,fp): |
|
610 | def readFile(self, fp): | |
588 | ''' |
|
611 | ''' | |
589 | You must indicate if you are reading in Online or Offline mode and load the |
|
612 | You must indicate if you are reading in Online or Offline mode and load the | |
@@ -600,7 +623,8 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
600 |
|
623 | |||
601 | if self.fileSelector < len(self.filenameList): |
|
624 | if self.fileSelector < len(self.filenameList): | |
602 |
|
625 | |||
603 |
self.fpFile=str(fp)+'/'+ |
|
626 | self.fpFile = str(fp) + '/' + \ | |
|
627 | str(self.filenameList[self.fileSelector]) | |||
604 | #print self.fpFile |
|
628 | # print self.fpFile | |
605 | fheader = FileHeaderBLTR() |
|
629 | fheader = FileHeaderBLTR() | |
606 |
fheader.FHread(self.fpFile) |
|
630 | fheader.FHread(self.fpFile) # Bltr FileHeader Reading | |
@@ -615,12 +639,15 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
615 |
|
639 | |||
616 | def getVelRange(self, extrapoints=0): |
|
640 | def getVelRange(self, extrapoints=0): | |
617 |
|
|
641 | Lambda = SPEED_OF_LIGHT / 50000000 | |
618 |
|
|
642 | # 1./(self.dataOut.ippSeconds * self.dataOut.nCohInt) | |
|
643 | PRF = self.dataOut.PRF | |||
619 |
|
|
644 | Vmax = -Lambda / (4. * (1. / PRF) * self.dataOut.nCohInt * 2.) | |
620 |
|
|
645 | deltafreq = PRF / (self.nProfiles) | |
621 |
|
|
646 | deltavel = (Vmax * 2) / (self.nProfiles) | |
622 | freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2 |
|
647 | freqrange = deltafreq * \ | |
623 |
|
|
648 | (numpy.arange(self.nProfiles) - self.nProfiles / 2.) - deltafreq / 2 | |
|
649 | velrange = deltavel * \ | |||
|
650 | (numpy.arange(self.nProfiles) - self.nProfiles / 2.) | |||
624 |
|
|
651 | return velrange | |
625 |
|
652 | |||
626 |
def readBlock(self): |
|
653 | def readBlock(self): | |
@@ -661,7 +688,8 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
661 |
|
688 | |||
662 | self.__firstHeigth=rheader.StartRangeSamp |
|
689 | self.__firstHeigth = rheader.StartRangeSamp | |
663 | self.__deltaHeigth=rheader.SampResolution |
|
690 | self.__deltaHeigth = rheader.SampResolution | |
664 |
self.dataOut.heightList= self.__firstHeigth + |
|
691 | self.dataOut.heightList = self.__firstHeigth + \ | |
|
692 | numpy.array(range(self.nHeights)) * self.__deltaHeigth | |||
665 | self.dataOut.channelList = range(self.nChannels) |
|
693 | self.dataOut.channelList = range(self.nChannels) | |
666 | self.dataOut.nProfiles=rheader.nProfiles |
|
694 | self.dataOut.nProfiles = rheader.nProfiles | |
667 | self.dataOut.nIncohInt=rheader.nIncohInt |
|
695 | self.dataOut.nIncohInt = rheader.nIncohInt | |
@@ -671,8 +699,10 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
671 | self.dataOut.nFFTPoints=rheader.nProfiles |
|
699 | self.dataOut.nFFTPoints = rheader.nProfiles | |
672 | self.dataOut.utctime=rheader.nUtime |
|
700 | self.dataOut.utctime = rheader.nUtime | |
673 | self.dataOut.timeZone=0 |
|
701 | self.dataOut.timeZone = 0 | |
674 |
self.dataOut.normFactor= self.dataOut.nProfiles* |
|
702 | self.dataOut.normFactor = self.dataOut.nProfiles * \ | |
675 | self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles |
|
703 | self.dataOut.nIncohInt * self.dataOut.nCohInt | |
|
704 | self.dataOut.outputInterval = self.dataOut.ippSeconds * \ | |||
|
705 | self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles | |||
676 |
|
706 | |||
677 | self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN |
|
707 | self.data_output = numpy.ones([3, rheader.nHeights]) * numpy.NaN | |
678 | print 'self.data_output', shape(self.data_output) |
|
708 | print 'self.data_output', shape(self.data_output) | |
@@ -686,7 +716,8 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
686 |
|
716 | |||
687 | #Procedure to take the pointer to where the date block starts |
|
717 | # Procedure to take the pointer to where the date block starts | |
688 | startDATA = open(self.fpFile,"rb") |
|
718 | startDATA = open(self.fpFile, "rb") | |
689 |
OffDATA= self.OffsetStartHeader + self.RecCounter* |
|
719 | OffDATA = self.OffsetStartHeader + self.RecCounter * \ | |
|
720 | self.Off2StartNxtRec + self.Off2StartData | |||
690 | startDATA.seek(OffDATA, os.SEEK_SET) |
|
721 | startDATA.seek(OffDATA, os.SEEK_SET) | |
691 |
|
722 | |||
692 | def moving_average(x, N=2): |
|
723 | def moving_average(x, N=2): | |
@@ -705,27 +736,26 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
705 | y = rho * numpy.sin(phi) |
|
736 | y = rho * numpy.sin(phi) | |
706 | return(x, y) |
|
737 | return(x, y) | |
707 |
|
738 | |||
708 |
|
||||
709 |
|
||||
710 |
|
||||
711 | if self.DualModeIndex==self.ReadMode: |
|
739 | if self.DualModeIndex == self.ReadMode: | |
712 |
|
740 | |||
713 | self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights ) |
|
741 | self.data_fft = numpy.fromfile( | |
|
742 | startDATA, [('complex', '<c8')], self.nProfiles * self.nChannels * self.nHeights) | |||
714 |
|
743 | |||
715 | self.data_fft=self.data_fft.astype(numpy.dtype('complex')) |
|
744 | self.data_fft = self.data_fft.astype(numpy.dtype('complex')) | |
716 |
|
745 | |||
717 | self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles )) |
|
746 | self.data_block = numpy.reshape( | |
|
747 | self.data_fft, (self.nHeights, self.nChannels, self.nProfiles)) | |||
718 |
|
748 | |||
719 | self.data_block = numpy.transpose(self.data_block, (1,2,0)) |
|
749 | self.data_block = numpy.transpose(self.data_block, (1, 2, 0)) | |
720 |
|
750 | |||
721 | copy = self.data_block.copy() |
|
751 | copy = self.data_block.copy() | |
722 |
spc = copy * numpy.conjugate(copy) |
|
752 | spc = copy * numpy.conjugate(copy) | |
723 |
|
753 | |||
724 |
self.data_spc = numpy.absolute( |
|
754 | self.data_spc = numpy.absolute( | |
|
755 | spc) # valor absoluto o magnitud | |||
725 |
|
756 | |||
726 | factor = self.dataOut.normFactor |
|
757 | factor = self.dataOut.normFactor | |
727 |
|
758 | |||
728 |
|
||||
729 | z = self.data_spc.copy()#/factor |
|
759 | z = self.data_spc.copy() # /factor | |
730 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
760 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
731 | #zdB = 10*numpy.log10(z) |
|
761 | #zdB = 10*numpy.log10(z) | |
@@ -737,13 +767,14 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
737 |
|
767 | |||
738 | self.dataOut.data_spc=self.data_spc |
|
768 | self.dataOut.data_spc = self.data_spc | |
739 |
|
769 | |||
740 |
self.noise = self.dataOut.getNoise( |
|
770 | self.noise = self.dataOut.getNoise( | |
|
771 | ymin_index=80, ymax_index=132) # /factor | |||
741 | #noisedB = 10*numpy.log10(self.noise) |
|
772 | #noisedB = 10*numpy.log10(self.noise) | |
742 |
|
773 | |||
743 |
|
||||
744 | ySamples=numpy.ones([3,self.nProfiles]) |
|
774 | ySamples = numpy.ones([3, self.nProfiles]) | |
745 | phase=numpy.ones([3,self.nProfiles]) |
|
775 | phase = numpy.ones([3, self.nProfiles]) | |
746 |
CSPCSamples=numpy.ones( |
|
776 | CSPCSamples = numpy.ones( | |
|
777 | [3, self.nProfiles], dtype=numpy.complex_) | |||
747 | coherence=numpy.ones([3,self.nProfiles]) |
|
778 | coherence = numpy.ones([3, self.nProfiles]) | |
748 | PhaseSlope=numpy.ones(3) |
|
779 | PhaseSlope = numpy.ones(3) | |
749 | PhaseInter=numpy.ones(3) |
|
780 | PhaseInter = numpy.ones(3) | |
@@ -766,13 +797,16 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
766 | chan_index0 = self.dataOut.pairsList[i][0] |
|
797 | chan_index0 = self.dataOut.pairsList[i][0] | |
767 | chan_index1 = self.dataOut.pairsList[i][1] |
|
798 | chan_index1 = self.dataOut.pairsList[i][1] | |
768 |
|
799 | |||
769 |
self.data_cspc[i,:,:]=cspc[chan_index0,:, |
|
800 | self.data_cspc[i, :, :] = cspc[chan_index0, :, | |
770 |
|
801 | :] * numpy.conjugate(cspc[chan_index1, :, :]) | ||
771 |
|
802 | |||
772 | '''Getting Eij and Nij''' |
|
803 | '''Getting Eij and Nij''' | |
773 |
(AntennaX0,AntennaY0)=pol2cart( |
|
804 | (AntennaX0, AntennaY0) = pol2cart( | |
774 |
|
|
805 | rheader.AntennaCoord0, rheader.AntennaAngl0 * numpy.pi / 180) | |
775 |
(AntennaX |
|
806 | (AntennaX1, AntennaY1) = pol2cart( | |
|
807 | rheader.AntennaCoord1, rheader.AntennaAngl1 * numpy.pi / 180) | |||
|
808 | (AntennaX2, AntennaY2) = pol2cart( | |||
|
809 | rheader.AntennaCoord2, rheader.AntennaAngl2 * numpy.pi / 180) | |||
776 |
|
810 | |||
777 | E01=AntennaX0-AntennaX1 |
|
811 | E01 = AntennaX0 - AntennaX1 | |
778 | N01=AntennaY0-AntennaY1 |
|
812 | N01 = AntennaY0 - AntennaY1 | |
@@ -783,7 +817,8 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
783 | E12=AntennaX1-AntennaX2 |
|
817 | E12 = AntennaX1 - AntennaX2 | |
784 | N12=AntennaY1-AntennaY2 |
|
818 | N12 = AntennaY1 - AntennaY2 | |
785 |
|
819 | |||
786 |
self.ChanDist= numpy.array( |
|
820 | self.ChanDist = numpy.array( | |
|
821 | [[E01, N01], [E02, N02], [E12, N12]]) | |||
787 |
|
822 | |||
788 | self.dataOut.ChanDist = self.ChanDist |
|
823 | self.dataOut.ChanDist = self.ChanDist | |
789 |
|
824 | |||
@@ -1139,16 +1174,9 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||||
1139 | # |
|
1174 | # | |
1140 |
# print ' ' |
|
1175 | # print ' ' | |
1141 |
|
1176 | |||
1142 |
|
||||
1143 |
|
||||
1144 | self.BlockCounter+=2 |
|
1177 | self.BlockCounter += 2 | |
1145 |
|
1178 | |||
1146 | else: |
|
1179 | else: | |
1147 |
self.fileSelector+=1 |
|
1180 | self.fileSelector += 1 | |
1148 | self.BlockCounter=0 |
|
1181 | self.BlockCounter = 0 | |
1149 | print "Next File" |
|
1182 | print "Next File" | |
1150 |
|
||||
1151 |
|
||||
1152 |
|
||||
1153 |
|
||||
1154 |
|
@@ -1,4 +1,5 | |||||
1 |
import os |
|
1 | import os | |
|
2 | import sys | |||
2 | import glob |
|
3 | import glob | |
3 | import fnmatch |
|
4 | import fnmatch | |
4 | import datetime |
|
5 | import datetime | |
@@ -6,9 +7,7 import time | |||||
6 | import re |
|
7 | import re | |
7 | import h5py |
|
8 | import h5py | |
8 | import numpy |
|
9 | import numpy | |
9 | import matplotlib.pyplot as plt |
|
|||
10 |
|
10 | |||
11 | import pylab as plb |
|
|||
12 | from scipy.optimize import curve_fit |
|
11 | from scipy.optimize import curve_fit | |
13 | from scipy import asarray as ar,exp |
|
12 | from scipy import asarray as ar, exp | |
14 | from scipy import stats |
|
13 | from scipy import stats | |
@@ -30,13 +29,11 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |||||
30 | from numpy import imag, shape, NaN, empty |
|
29 | from numpy import imag, shape, NaN, empty | |
31 |
|
30 | |||
32 |
|
31 | |||
33 |
|
||||
34 | class Header(object): |
|
32 | class Header(object): | |
35 |
|
33 | |||
36 | def __init__(self): |
|
34 | def __init__(self): | |
37 | raise NotImplementedError |
|
35 | raise NotImplementedError | |
38 |
|
36 | |||
39 |
|
||||
40 | def read(self): |
|
37 | def read(self): | |
41 |
|
38 | |||
42 | raise NotImplementedError |
|
39 | raise NotImplementedError | |
@@ -68,13 +65,18 class Header(object): | |||||
68 |
|
65 | |||
69 |
FILE_HEADER = numpy.dtype([ |
|
66 | FILE_HEADER = numpy.dtype([ # HEADER 1024bytes | |
70 |
('Hname','a32'), |
|
67 | ('Hname', 'a32'), # Original file name | |
71 |
|
|
68 | # Date and time when the file was created | |
72 |
('H |
|
69 | ('Htime', numpy.str_, 32), | |
73 | ('Hplace',numpy.str_,128), #Place where the measurements was carried out |
|
70 | # Name of operator who created the file | |
74 |
('H |
|
71 | ('Hoper', numpy.str_, 64), | |
|
72 | # Place where the measurements was carried out | |||
|
73 | ('Hplace', numpy.str_, 128), | |||
|
74 | # Description of measurements | |||
|
75 | ('Hdescr', numpy.str_, 256), | |||
75 |
('Hdummy',numpy.str_,512), |
|
76 | ('Hdummy', numpy.str_, 512), # Reserved space | |
76 | #Main chunk 8bytes |
|
77 | # Main chunk 8bytes | |
77 |
|
|
78 | # Main chunk signature FZKF or NUIG | |
|
79 | ('Msign', numpy.str_, 4), | |||
78 |
('MsizeData','<i4'), |
|
80 | ('MsizeData', '<i4'), # Size of data block main chunk | |
79 | #Processing DSP parameters 36bytes |
|
81 | # Processing DSP parameters 36bytes | |
80 |
('PPARsign',numpy.str_,4), |
|
82 | ('PPARsign', numpy.str_, 4), # PPAR signature | |
@@ -82,19 +84,28 FILE_HEADER = numpy.dtype([ #HEADER 1024bytes | |||||
82 |
('PPARprf','<i4'), |
|
84 | ('PPARprf', '<i4'), # Pulse repetition frequency | |
83 |
('PPARpdr','<i4'), |
|
85 | ('PPARpdr', '<i4'), # Pulse duration | |
84 |
('PPARsft','<i4'), |
|
86 | ('PPARsft', '<i4'), # FFT length | |
85 |
|
|
87 | # Number of spectral (in-coherent) averages | |
86 | ('PPARihp','<i4'), #Number of lowest range gate for moment estimation |
|
88 | ('PPARavc', '<i4'), | |
87 |
|
|
89 | # Number of lowest range gate for moment estimation | |
88 | ('PPARpol','<i4'), #switch on/off polarimetric measurements. Should be 1. |
|
90 | ('PPARihp', '<i4'), | |
|
91 | # Count for gates for moment estimation | |||
|
92 | ('PPARchg', '<i4'), | |||
|
93 | # switch on/off polarimetric measurements. Should be 1. | |||
|
94 | ('PPARpol', '<i4'), | |||
89 | #Service DSP parameters 112bytes |
|
95 | # Service DSP parameters 112bytes | |
90 |
|
|
96 | # STC attenuation on the lowest ranges on/off | |
|
97 | ('SPARatt', '<i4'), | |||
91 |
('SPARtx','<i4'), |
|
98 | ('SPARtx', '<i4'), # OBSOLETE | |
92 | ('SPARaddGain0','<f4'), #OBSOLETE |
|
99 | ('SPARaddGain0', '<f4'), # OBSOLETE | |
93 | ('SPARaddGain1','<f4'), #OBSOLETE |
|
100 | ('SPARaddGain1', '<f4'), # OBSOLETE | |
94 |
|
|
101 | # Debug only. It normal mode it is 0. | |
95 | ('SPARpos','<i4'), #Delay between sync pulse and tx pulse for phase corr, ns |
|
102 | ('SPARwnd', '<i4'), | |
96 | ('SPARadd','<i4'), #"add to pulse" to compensate for delay between the leading edge of driver pulse and envelope of the RF signal. |
|
103 | # Delay between sync pulse and tx pulse for phase corr, ns | |
97 | ('SPARlen','<i4'), #Time for measuring txn pulse phase. OBSOLETE |
|
104 | ('SPARpos', '<i4'), | |
|
105 | # "add to pulse" to compensate for delay between the leading edge of driver pulse and envelope of the RF signal. | |||
|
106 | ('SPARadd', '<i4'), | |||
|
107 | # Time for measuring txn pulse phase. OBSOLETE | |||
|
108 | ('SPARlen', '<i4'), | |||
98 |
('SPARcal','<i4'), |
|
109 | ('SPARcal', '<i4'), # OBSOLETE | |
99 |
('SPARnos','<i4'), |
|
110 | ('SPARnos', '<i4'), # OBSOLETE | |
100 |
('SPARof0','<i4'), |
|
111 | ('SPARof0', '<i4'), # detection threshold | |
@@ -105,19 +116,23 FILE_HEADER = numpy.dtype([ #HEADER 1024bytes | |||||
105 |
('SPARtst','<i4'), |
|
116 | ('SPARtst', '<i4'), # OBSOLETE | |
106 |
('SPARcor','<i4'), |
|
117 | ('SPARcor', '<i4'), # OBSOLETE | |
107 |
('SPARofs','<i4'), |
|
118 | ('SPARofs', '<i4'), # OBSOLETE | |
108 |
|
|
119 | # Hildebrand div noise detection on noise gate | |
109 |
('SPARhs |
|
120 | ('SPARhsn', '<i4'), | |
|
121 | # Hildebrand div noise detection on all gates | |||
|
122 | ('SPARhsa', '<f4'), | |||
110 |
('SPARcalibPow_M','<f4'), |
|
123 | ('SPARcalibPow_M', '<f4'), # OBSOLETE | |
111 |
('SPARcalibSNR_M','<f4'), |
|
124 | ('SPARcalibSNR_M', '<f4'), # OBSOLETE | |
112 |
('SPARcalibPow_S','<f4'), |
|
125 | ('SPARcalibPow_S', '<f4'), # OBSOLETE | |
113 |
('SPARcalibSNR_S','<f4'), |
|
126 | ('SPARcalibSNR_S', '<f4'), # OBSOLETE | |
114 |
|
|
127 | # Lowest range gate for spectra saving Raw_Gate1 >=5 | |
115 |
('SPARrawGate |
|
128 | ('SPARrawGate1', '<i4'), | |
116 | ('SPARraw','<i4'), #flag - IQ or spectra saving on/off |
|
129 | # Number of range gates with atmospheric signal | |
|
130 | ('SPARrawGate2', '<i4'), | |||
|
131 | # flag - IQ or spectra saving on/off | |||
|
132 | ('SPARraw', '<i4'), | |||
117 |
('SPARprc','<i4'),]) |
|
133 | ('SPARprc', '<i4'), ]) # flag - Moment estimation switched on/off | |
118 |
|
134 | |||
119 |
|
135 | |||
120 |
|
||||
121 | class FileHeaderMIRA35c(Header): |
|
136 | class FileHeaderMIRA35c(Header): | |
122 |
|
137 | |||
123 | def __init__(self): |
|
138 | def __init__(self): | |
@@ -195,7 +210,6 class FileHeaderMIRA35c(Header): | |||||
195 |
|
210 | |||
196 | ''' |
|
211 | ''' | |
197 |
|
212 | |||
198 |
|
||||
199 |
self.Hname= str(header['Hname'][0]) |
|
213 | self.Hname = str(header['Hname'][0]) | |
200 | self.Htime= str(header['Htime'][0]) |
|
214 | self.Htime = str(header['Htime'][0]) | |
201 | self.Hoper= str(header['Hoper'][0]) |
|
215 | self.Hoper = str(header['Hoper'][0]) | |
@@ -272,7 +286,6 class FileHeaderMIRA35c(Header): | |||||
272 | self.Hdescr, |
|
286 | self.Hdescr, | |
273 | self.Hdummy) |
|
287 | self.Hdummy) | |
274 |
|
288 | |||
275 |
|
||||
276 | header = numpy.array(headerTuple, FILE_HEADER) |
|
289 | header = numpy.array(headerTuple, FILE_HEADER) | |
277 | # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) |
|
290 | # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) | |
278 | header.tofile(fp) |
|
291 | header.tofile(fp) | |
@@ -293,11 +306,13 class FileHeaderMIRA35c(Header): | |||||
293 |
|
306 | |||
294 | return 1 |
|
307 | return 1 | |
295 |
|
308 | |||
|
309 | ||||
296 |
SRVI_HEADER = numpy.dtype([ |
|
310 | SRVI_HEADER = numpy.dtype([ | |
297 |
('SignatureSRVI1',numpy.str_,4), |
|
311 | ('SignatureSRVI1', numpy.str_, 4), | |
298 |
('SizeOfDataBlock1','<i4'), |
|
312 | ('SizeOfDataBlock1', '<i4'), | |
299 |
('DataBlockTitleSRVI1',numpy.str_,4), |
|
313 | ('DataBlockTitleSRVI1', numpy.str_, 4), | |
300 |
('SizeOfSRVI1','<i4'),]) |
|
314 | ('SizeOfSRVI1', '<i4'), ]) | |
|
315 | ||||
301 |
|
316 | |||
302 |
class SRVIHeader(Header): |
|
317 | class SRVIHeader(Header): | |
303 | def __init__(self, SignatureSRVI1=0, SizeOfDataBlock1=0, DataBlockTitleSRVI1=0, SizeOfSRVI1=0): |
|
318 | def __init__(self, SignatureSRVI1=0, SizeOfDataBlock1=0, DataBlockTitleSRVI1=0, SizeOfSRVI1=0): | |
@@ -322,7 +337,7 class SRVIHeader(Header): | |||||
322 |
|
337 | |||
323 |
|
338 | |||
324 |
SRVI_STRUCTURE = numpy.dtype([ |
|
339 | SRVI_STRUCTURE = numpy.dtype([ | |
325 |
('frame_cnt','<u4'), |
|
340 | ('frame_cnt', '<u4'), | |
326 | ('time_t','<u4'), # |
|
341 | ('time_t', '<u4'), # | |
327 | ('tpow','<f4'), # |
|
342 | ('tpow', '<f4'), # | |
328 | ('npw1','<f4'), # |
|
343 | ('npw1', '<f4'), # | |
@@ -338,24 +353,20 SRVI_STRUCTURE = numpy.dtype([ | |||||
338 | ('azivel','<f4'), # |
|
353 | ('azivel', '<f4'), # | |
339 | ('elvpos','<f4'), # |
|
354 | ('elvpos', '<f4'), # | |
340 | ('elvvel','<f4'), # |
|
355 | ('elvvel', '<f4'), # | |
341 |
('northAngle','<f4'), |
|
356 | ('northAngle', '<f4'), | |
342 | ('microsec','<u4'), # |
|
357 | ('microsec', '<u4'), # | |
343 | ('azisetvel','<f4'), # |
|
358 | ('azisetvel', '<f4'), # | |
344 | ('elvsetpos','<f4'), # |
|
359 | ('elvsetpos', '<f4'), # | |
345 |
('RadarConst','<f4'),]) # |
|
360 | ('RadarConst', '<f4'), ]) # | |
346 |
|
361 | |||
347 |
|
362 | |||
348 |
|
||||
349 |
|
||||
350 | class RecordHeader(Header): |
|
363 | class RecordHeader(Header): | |
351 |
|
364 | |||
352 |
|
||||
353 |
def __init__(self, frame_cnt=0, time_t= |
|
365 | def __init__(self, frame_cnt=0, time_t=0, tpow=0, npw1=0, npw2=0, | |
354 |
cpw1=0, pcw2=0, ps_err=0, te_err=0, rc_err=0, grs1=0, |
|
366 | cpw1=0, pcw2=0, ps_err=0, te_err=0, rc_err=0, grs1=0, | |
355 |
grs2=0, azipos=0, azivel=0, elvpos=0, elvvel=0, northangle=0, |
|
367 | grs2=0, azipos=0, azivel=0, elvpos=0, elvvel=0, northangle=0, | |
356 |
microsec=0, azisetvel=0, elvsetpos=0, RadarConst=0 |
|
368 | microsec=0, azisetvel=0, elvsetpos=0, RadarConst=0, RecCounter=0, Off2StartNxtRec=0): | |
357 |
|
369 | |||
358 |
|
||||
359 | self.frame_cnt = frame_cnt |
|
370 | self.frame_cnt = frame_cnt | |
360 | self.dwell = time_t |
|
371 | self.dwell = time_t | |
361 | self.tpow = tpow |
|
372 | self.tpow = tpow | |
@@ -392,7 +403,7 class RecordHeader(Header): | |||||
392 |
|
403 | |||
393 | header = numpy.fromfile(fp,SRVI_STRUCTURE,1) |
|
404 | header = numpy.fromfile(fp, SRVI_STRUCTURE, 1) | |
394 |
|
405 | |||
395 |
self.frame_cnt = header['frame_cnt'][0] |
|
406 | self.frame_cnt = header['frame_cnt'][0] | |
396 | self.time_t = header['time_t'][0] # |
|
407 | self.time_t = header['time_t'][0] # | |
397 | self.tpow = header['tpow'][0] # |
|
408 | self.tpow = header['tpow'][0] # | |
398 | self.npw1 = header['npw1'][0] # |
|
409 | self.npw1 = header['npw1'][0] # | |
@@ -428,9 +439,9 class RecordHeader(Header): | |||||
428 |
|
439 | |||
429 | print '==============================================' |
|
440 | print '==============================================' | |
430 |
|
441 | |||
431 |
|
||||
432 | return 1 |
|
442 | return 1 | |
433 |
|
443 | |||
|
444 | ||||
434 | class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): |
|
445 | class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader): | |
435 |
|
446 | |||
436 | path = None |
|
447 | path = None | |
@@ -441,7 +452,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
441 | walk = None |
|
452 | walk = None | |
442 | isConfig = False |
|
453 | isConfig = False | |
443 |
|
454 | |||
444 |
|
||||
445 | fileList= None |
|
455 | fileList = None | |
446 |
|
456 | |||
447 | #metadata |
|
457 | # metadata | |
@@ -453,8 +463,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
453 | data= None |
|
463 | data = None | |
454 | utctime= None |
|
464 | utctime = None | |
455 |
|
465 | |||
456 |
|
||||
457 |
|
||||
458 |
def __init__(self, **kwargs): |
|
466 | def __init__(self, **kwargs): | |
459 |
|
467 | |||
460 | #Eliminar de la base la herencia |
|
468 | # Eliminar de la base la herencia | |
@@ -498,7 +506,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
498 | self.dataOut.COFA = [] |
|
506 | self.dataOut.COFA = [] | |
499 | self.dataOut.noise = 0 |
|
507 | self.dataOut.noise = 0 | |
500 |
|
508 | |||
501 |
|
||||
502 | def Files2Read(self, fp): |
|
509 | def Files2Read(self, fp): | |
503 | ''' |
|
510 | ''' | |
504 | Function that indicates the number of .fdt files that exist in the folder to be read. |
|
511 | Function that indicates the number of .fdt files that exist in the folder to be read. | |
@@ -506,8 +513,10 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
506 | ''' |
|
513 | ''' | |
507 | #self.__checkPath() |
|
514 | # self.__checkPath() | |
508 |
|
515 | |||
509 |
|
|
516 | # Gets the list of files within the fp address | |
510 | ListaData=sorted(ListaData) #Sort the list of files from least to largest by names |
|
517 | ListaData = os.listdir(fp) | |
|
518 | # Sort the list of files from least to largest by names | |||
|
519 | ListaData = sorted(ListaData) | |||
511 |
nFiles=0 |
|
520 | nFiles = 0 # File Counter | |
512 |
FileList=[] |
|
521 | FileList = [] # A list is created that will contain the .fdt files | |
513 |
for IndexFile in ListaData |
|
522 | for IndexFile in ListaData: | |
@@ -520,7 +529,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
520 |
|
529 | |||
521 | self.filenameList=FileList #List of files from least to largest by names |
|
530 | self.filenameList = FileList # List of files from least to largest by names | |
522 |
|
531 | |||
523 |
|
||||
524 | def run(self, **kwargs): |
|
532 | def run(self, **kwargs): | |
525 | ''' |
|
533 | ''' | |
526 | This method will be the one that will initiate the data entry, will be called constantly. |
|
534 | This method will be the one that will initiate the data entry, will be called constantly. | |
@@ -533,7 +541,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
533 |
|
541 | |||
534 | self.getData() |
|
542 | self.getData() | |
535 |
|
543 | |||
536 |
|
||||
537 | def setup(self, path=None, |
|
544 | def setup(self, path=None, | |
538 |
|
|
545 | startDate=None, | |
539 |
|
|
546 | endDate=None, | |
@@ -557,7 +564,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
557 |
|
564 | |||
558 | pass |
|
565 | pass | |
559 |
|
566 | |||
560 |
|
||||
561 | def getData(self): |
|
567 | def getData(self): | |
562 | ''' |
|
568 | ''' | |
563 | Before starting this function, you should check that there is still an unread file, |
|
569 | Before starting this function, you should check that there is still an unread file, | |
@@ -584,10 +590,8 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
584 | self.dataOut.data_spc = self.dataOut.data_spc+self.dataOut.noise |
|
590 | self.dataOut.data_spc = self.dataOut.data_spc + self.dataOut.noise | |
585 |
#print 'self.dataOut.noise',self.dataOut.noise |
|
591 | # print 'self.dataOut.noise',self.dataOut.noise | |
586 |
|
592 | |||
587 |
|
||||
588 | return self.dataOut.data_spc |
|
593 | return self.dataOut.data_spc | |
589 |
|
594 | |||
590 |
|
||||
591 | def readFile(self,fp): |
|
595 | def readFile(self, fp): | |
592 | ''' |
|
596 | ''' | |
593 | You must indicate if you are reading in Online or Offline mode and load the |
|
597 | You must indicate if you are reading in Online or Offline mode and load the | |
@@ -604,7 +608,8 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
604 |
|
608 | |||
605 | if self.fileSelector < len(self.filenameList): |
|
609 | if self.fileSelector < len(self.filenameList): | |
606 |
|
610 | |||
607 |
self.fpFile=str(fp)+'/'+ |
|
611 | self.fpFile = str(fp) + '/' + \ | |
|
612 | str(self.filenameList[self.fileSelector]) | |||
608 |
|
613 | |||
609 | if self.nextfileflag==True: |
|
614 | if self.nextfileflag == True: | |
610 | self.fp = open(self.fpFile,"rb") |
|
615 | self.fp = open(self.fpFile, "rb") | |
@@ -612,18 +617,15 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
612 |
|
617 | |||
613 | '''HERE STARTING THE FILE READING''' |
|
618 | '''HERE STARTING THE FILE READING''' | |
614 |
|
619 | |||
615 |
|
||||
616 | self.fheader = FileHeaderMIRA35c() |
|
620 | self.fheader = FileHeaderMIRA35c() | |
617 |
self.fheader.FHread(self.fp) |
|
621 | self.fheader.FHread(self.fp) # Bltr FileHeader Reading | |
618 |
|
622 | |||
619 |
|
||||
620 | self.SPARrawGate1 = self.fheader.SPARrawGate1 |
|
623 | self.SPARrawGate1 = self.fheader.SPARrawGate1 | |
621 | self.SPARrawGate2 = self.fheader.SPARrawGate2 |
|
624 | self.SPARrawGate2 = self.fheader.SPARrawGate2 | |
622 | self.Num_Hei = self.SPARrawGate2 - self.SPARrawGate1 |
|
625 | self.Num_Hei = self.SPARrawGate2 - self.SPARrawGate1 | |
623 | self.Num_Bins = self.fheader.PPARsft |
|
626 | self.Num_Bins = self.fheader.PPARsft | |
624 | self.dataOut.nFFTPoints = self.fheader.PPARsft |
|
627 | self.dataOut.nFFTPoints = self.fheader.PPARsft | |
625 |
|
628 | |||
626 |
|
||||
627 | self.Num_inCoh = self.fheader.PPARavc |
|
629 | self.Num_inCoh = self.fheader.PPARavc | |
628 | self.dataOut.PRF = self.fheader.PPARprf |
|
630 | self.dataOut.PRF = self.fheader.PPARprf | |
629 | self.dataOut.frequency = 34.85*10**9 |
|
631 | self.dataOut.frequency = 34.85 * 10**9 | |
@@ -633,14 +635,12 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
633 |
pulse_width = self.fheader.PPARpdr * 10**-9 |
|
635 | pulse_width = self.fheader.PPARpdr * 10**-9 | |
634 | self.__deltaHeigth = 0.5 * SPEED_OF_LIGHT * pulse_width |
|
636 | self.__deltaHeigth = 0.5 * SPEED_OF_LIGHT * pulse_width | |
635 |
|
637 | |||
636 |
self.data_spc = numpy.zeros((self.Num_Hei, self.Num_Bins,2)) |
|
638 | self.data_spc = numpy.zeros((self.Num_Hei, self.Num_Bins, 2)) | |
637 | self.dataOut.HSDV = numpy.zeros((self.Num_Hei, 2)) |
|
639 | self.dataOut.HSDV = numpy.zeros((self.Num_Hei, 2)) | |
638 |
|
640 | |||
639 | self.Ze = numpy.zeros(self.Num_Hei) |
|
641 | self.Ze = numpy.zeros(self.Num_Hei) | |
640 | self.ETA = numpy.zeros(([2,self.Num_Hei])) |
|
642 | self.ETA = numpy.zeros(([2, self.Num_Hei])) | |
641 |
|
643 | |||
642 |
|
||||
643 |
|
||||
644 |
self.readBlock() |
|
644 | self.readBlock() # Block reading | |
645 |
|
645 | |||
646 | else: |
|
646 | else: | |
@@ -650,8 +650,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
650 | self.FileHeaderFlag == True |
|
650 | self.FileHeaderFlag == True | |
651 |
return 0 |
|
651 | return 0 | |
652 |
|
652 | |||
653 |
|
||||
654 |
|
||||
655 |
def readBlock(self): |
|
653 | def readBlock(self): | |
656 | ''' |
|
654 | ''' | |
657 | It should be checked if the block has data, if it is not passed to the next file. |
|
655 | It should be checked if the block has data, if it is not passed to the next file. | |
@@ -670,8 +668,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
670 |
else |
|
668 | else: | |
671 | self.FirstPoint = 1180 |
|
669 | self.FirstPoint = 1180 | |
672 |
|
670 | |||
673 |
|
||||
674 |
|
||||
675 | self.srviHeader = SRVIHeader() |
|
671 | self.srviHeader = SRVIHeader() | |
676 |
|
672 | |||
677 | self.srviHeader.SRVIread(self.fp) #Se obtiene la cabecera del SRVI |
|
673 | self.srviHeader.SRVIread(self.fp) # Se obtiene la cabecera del SRVI | |
@@ -682,7 +678,8 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
682 | print 'blocksize == 148 bug' |
|
678 | print 'blocksize == 148 bug' | |
683 |
jump = numpy.fromfile(self.fp,[('jump',numpy.str_,140)] |
|
679 | jump = numpy.fromfile(self.fp, [('jump', numpy.str_, 140)], 1) | |
684 |
|
680 | |||
685 |
|
|
681 | # Se obtiene la cabecera del SRVI | |
|
682 | self.srviHeader.SRVIread(self.fp) | |||
686 |
|
683 | |||
687 | if not self.srviHeader.SizeOfSRVI1: |
|
684 | if not self.srviHeader.SizeOfSRVI1: | |
688 |
self.fileSelector+=1 |
|
685 | self.fileSelector += 1 | |
@@ -696,7 +693,6 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
696 | npw1 = self.recordheader.npw1 |
|
693 | npw1 = self.recordheader.npw1 | |
697 | npw2 = self.recordheader.npw2 |
|
694 | npw2 = self.recordheader.npw2 | |
698 |
|
695 | |||
699 |
|
||||
700 | self.dataOut.channelList = range(1) |
|
696 | self.dataOut.channelList = range(1) | |
701 |
self.dataOut.nIncohInt = self.Num_inCoh |
|
697 | self.dataOut.nIncohInt = self.Num_inCoh | |
702 | self.dataOut.nProfiles = self.Num_Bins |
|
698 | self.dataOut.nProfiles = self.Num_Bins | |
@@ -706,53 +702,65 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
706 | self.dataOut.timeZone=0 |
|
702 | self.dataOut.timeZone = 0 | |
707 |
|
703 | |||
708 | self.dataOut.outputInterval = self.dataOut.getTimeInterval() |
|
704 | self.dataOut.outputInterval = self.dataOut.getTimeInterval() | |
709 |
self.dataOut.heightList = self.SPARrawGate1*self.__deltaHeigth + |
|
705 | self.dataOut.heightList = self.SPARrawGate1 * self.__deltaHeigth + \ | |
710 |
|
706 | numpy.array(range(self.Num_Hei)) * self.__deltaHeigth | ||
711 |
|
||||
712 |
|
707 | |||
713 |
self.HSDVsign = numpy.fromfile( |
|
708 | self.HSDVsign = numpy.fromfile(self.fp, [('HSDV', numpy.str_, 4)], 1) | |
714 |
self.SizeHSDV = numpy.fromfile( |
|
709 | self.SizeHSDV = numpy.fromfile(self.fp, [('SizeHSDV', '<i4')], 1) | |
715 |
self.HSDV_Co = numpy.fromfile( |
|
710 | self.HSDV_Co = numpy.fromfile( | |
716 |
|
|
711 | self.fp, [('HSDV_Co', '<f4')], self.Num_Hei) | |
|
712 | self.HSDV_Cx = numpy.fromfile( | |||
|
713 | self.fp, [('HSDV_Cx', '<f4')], self.Num_Hei) | |||
717 |
|
714 | |||
718 |
self.COFAsign = numpy.fromfile( |
|
715 | self.COFAsign = numpy.fromfile(self.fp, [('COFA', numpy.str_, 4)], 1) | |
719 |
self.SizeCOFA = numpy.fromfile( |
|
716 | self.SizeCOFA = numpy.fromfile(self.fp, [('SizeCOFA', '<i4')], 1) | |
720 |
self.COFA_Co = numpy.fromfile( |
|
717 | self.COFA_Co = numpy.fromfile( | |
721 |
|
|
718 | self.fp, [('COFA_Co', '<f4')], self.Num_Hei) | |
|
719 | self.COFA_Cx = numpy.fromfile( | |||
|
720 | self.fp, [('COFA_Cx', '<f4')], self.Num_Hei) | |||
722 |
|
721 | |||
723 |
self.ZSPCsign = numpy.fromfile( |
|
722 | self.ZSPCsign = numpy.fromfile( | |
|
723 | self.fp, [('ZSPCsign', numpy.str_, 4)], 1) | |||
724 |
self.SizeZSPC = numpy.fromfile(self.fp, [('SizeZSPC','<i4')],1) |
|
724 | self.SizeZSPC = numpy.fromfile(self.fp, [('SizeZSPC', '<i4')], 1) | |
725 |
|
725 | |||
726 | self.dataOut.HSDV[0]=self.HSDV_Co[:][0] |
|
726 | self.dataOut.HSDV[0] = self.HSDV_Co[:][0] | |
727 | self.dataOut.HSDV[1]=self.HSDV_Cx[:][0] |
|
727 | self.dataOut.HSDV[1] = self.HSDV_Cx[:][0] | |
728 |
|
728 | |||
729 | for irg in range(self.Num_Hei): |
|
729 | for irg in range(self.Num_Hei): | |
730 |
|
|
730 | # Number of spectral sub pieces containing significant power | |
|
731 | nspc = numpy.fromfile(self.fp, [('nspc', 'int16')], 1)[0][0] | |||
731 |
|
732 | |||
732 | for k in range(nspc): |
|
733 | for k in range(nspc): | |
733 |
|
|
734 | # Index of the spectral bin where the piece is beginning | |
734 | nbins = numpy.fromfile(self.fp, [('nbins','int16')],1)[0][0] # Number of bins of the piece |
|
735 | binIndex = numpy.fromfile( | |
|
736 | self.fp, [('binIndex', 'int16')], 1)[0][0] | |||
|
737 | nbins = numpy.fromfile(self.fp, [('nbins', 'int16')], 1)[ | |||
|
738 | 0][0] # Number of bins of the piece | |||
735 |
|
739 | |||
736 | #Co_Channel |
|
740 | # Co_Channel | |
737 |
jbin = numpy.fromfile(self.fp, [('jbin','uint16')],nbins)[ |
|
741 | jbin = numpy.fromfile(self.fp, [('jbin', 'uint16')], nbins)[ | |
738 | jmax = numpy.fromfile(self.fp, [('jmax','float32')],1)[0][0] # Maximun piece to be normaliced |
|
742 | 0][0] # Spectrum piece to be normaliced | |
739 |
|
743 | jmax = numpy.fromfile(self.fp, [('jmax', 'float32')], 1)[ | ||
|
744 | 0][0] # Maximun piece to be normaliced | |||
740 |
|
745 | |||
741 |
self.data_spc[irg,binIndex:binIndex+nbins,0] = self.data_spc[irg, |
|
746 | self.data_spc[irg, binIndex:binIndex + nbins, 0] = self.data_spc[irg, | |
|
747 | binIndex:binIndex + nbins, 0] + jbin / 65530. * jmax | |||
742 |
|
748 | |||
743 | #Cx_Channel |
|
749 | # Cx_Channel | |
744 |
jbin = numpy.fromfile( |
|
750 | jbin = numpy.fromfile( | |
|
751 | self.fp, [('jbin', 'uint16')], nbins)[0][0] | |||
745 | jmax = numpy.fromfile(self.fp, [('jmax','float32')],1)[0][0] |
|
752 | jmax = numpy.fromfile(self.fp, [('jmax', 'float32')], 1)[0][0] | |
746 |
|
753 | |||
747 |
|
754 | self.data_spc[irg, binIndex:binIndex + nbins, 1] = self.data_spc[irg, | ||
748 | self.data_spc[irg,binIndex:binIndex+nbins,1] = self.data_spc[irg,binIndex:binIndex+nbins,1]+jbin/65530.*jmax |
|
755 | binIndex:binIndex + nbins, 1] + jbin / 65530. * jmax | |
749 |
|
756 | |||
750 |
for bin in range(self.Num_Bins): |
|
757 | for bin in range(self.Num_Bins): | |
751 |
|
758 | |||
752 |
self.data_spc[:,bin,0] = self.data_spc[:, |
|
759 | self.data_spc[:, bin, 0] = self.data_spc[:, | |
753 |
|
760 | bin, 0] - self.dataOut.HSDV[:, 0] | ||
754 | self.data_spc[:,bin,1] = self.data_spc[:,bin,1] - self.dataOut.HSDV[:,1] |
|
|||
755 |
|
761 | |||
|
762 | self.data_spc[:, bin, 1] = self.data_spc[:, | |||
|
763 | bin, 1] - self.dataOut.HSDV[:, 1] | |||
756 |
|
764 | |||
757 | numpy.set_printoptions(threshold='nan') |
|
765 | numpy.set_printoptions(threshold='nan') | |
758 |
|
766 | |||
@@ -787,17 +795,8 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader): | |||||
787 | #shift = self.Num_Bins/2 + fix |
|
795 | #shift = self.Num_Bins/2 + fix | |
788 | #self.data_spc = numpy.array([ self.data_spc[: , self.Num_Bins-shift+1: , :] , self.data_spc[: , 0:self.Num_Bins-shift , :]]) |
|
796 | #self.data_spc = numpy.array([ self.data_spc[: , self.Num_Bins-shift+1: , :] , self.data_spc[: , 0:self.Num_Bins-shift , :]]) | |
789 |
|
797 | |||
790 |
|
||||
791 |
|
||||
792 | '''Block Reading, the Block Data is received and Reshape is used to give it |
|
798 | '''Block Reading, the Block Data is received and Reshape is used to give it | |
793 | shape. |
|
799 | shape. | |
794 | ''' |
|
800 | ''' | |
795 |
|
801 | |||
796 | self.PointerReader = self.fp.tell() |
|
802 | self.PointerReader = self.fp.tell() | |
797 |
|
||||
798 |
|
||||
799 |
|
||||
800 |
|
||||
801 |
|
||||
802 |
|
||||
803 | No newline at end of file |
|
@@ -17,7 +17,6 from functools import partial | |||||
17 | import time |
|
17 | import time | |
18 | #from sklearn.cluster import KMeans |
|
18 | #from sklearn.cluster import KMeans | |
19 |
|
19 | |||
20 | import matplotlib.pyplot as plt |
|
|||
21 |
|
20 | |||
22 | from scipy.optimize import fmin_l_bfgs_b #optimize with bounds on state papameters |
|
21 | from scipy.optimize import fmin_l_bfgs_b #optimize with bounds on state papameters | |
23 | from jroproc_base import ProcessingUnit, Operation |
|
22 | from jroproc_base import ProcessingUnit, Operation |
General Comments 0
You need to be logged in to leave comments.
Login now