@@ -6,6 +6,7 import time | |||||
6 | PATH = '/DATA_RM/DATA' |
|
6 | PATH = '/DATA_RM/DATA' | |
7 | PATH = '/media/jespinoza/Elements' |
|
7 | PATH = '/media/jespinoza/Elements' | |
8 | PATH = '/media/jespinoza/data/SOPHY' |
|
8 | PATH = '/media/jespinoza/data/SOPHY' | |
|
9 | PATH = '/home/soporte/Documents/EVENTO' | |||
9 |
|
10 | |||
10 | PARAM = { |
|
11 | PARAM = { | |
11 | 'S': {'zmin': -45, 'zmax': -25, 'colormap': 'jet', 'label': 'Power', 'wrname': 'power','cb_label': 'dBm', 'ch':0}, |
|
12 | 'S': {'zmin': -45, 'zmax': -25, 'colormap': 'jet', 'label': 'Power', 'wrname': 'power','cb_label': 'dBm', 'ch':0}, | |
@@ -46,8 +47,8 def main(args): | |||||
46 | N = int(1/(speed_axis[0]*ipp)) # 1 GRADO DE RESOLUCION |
|
47 | N = int(1/(speed_axis[0]*ipp)) # 1 GRADO DE RESOLUCION | |
47 | path = os.path.join(PATH, experiment, 'rawdata') |
|
48 | path = os.path.join(PATH, experiment, 'rawdata') | |
48 | path_ped = os.path.join(PATH, experiment, 'position') |
|
49 | path_ped = os.path.join(PATH, experiment, 'position') | |
49 | path_plots = os.path.join(PATH, experiment, 'plots') |
|
50 | path_plots = os.path.join(PATH, experiment, 'plotsC0N'+str(args.range)) | |
50 | path_save = os.path.join(PATH, experiment, 'param') |
|
51 | path_save = os.path.join(PATH, experiment, 'paramC0N'+str(args.range)) | |
51 | RMIX = 1.62 |
|
52 | RMIX = 1.62 | |
52 | H0 = -1.68 |
|
53 | H0 = -1.68 | |
53 | MASK = 0.3 |
|
54 | MASK = 0.3 | |
@@ -101,6 +102,8 def main(args): | |||||
101 |
|
102 | |||
102 | op = voltage.addOperation(name='PulsePair_vRF', optype='other') |
|
103 | op = voltage.addOperation(name='PulsePair_vRF', optype='other') | |
103 | op.addParameter(name='n', value=int(N)/ncode, format='int') |
|
104 | op.addParameter(name='n', value=int(N)/ncode, format='int') | |
|
105 | #op.addParameter(name='removeDC', value=1, format='int') | |||
|
106 | ||||
104 |
|
107 | |||
105 | proc = project.addProcUnit(datatype='ParametersProc', inputId=voltage.getId()) |
|
108 | proc = project.addProcUnit(datatype='ParametersProc', inputId=voltage.getId()) | |
106 |
|
109 | |||
@@ -203,6 +206,8 def main(args): | |||||
203 |
|
206 | |||
204 | op = voltage1.addOperation(name='PulsePair_vRF', optype='other') |
|
207 | op = voltage1.addOperation(name='PulsePair_vRF', optype='other') | |
205 | op.addParameter(name='n', value=int(conf['usrp_tx']['repetitions_1'])/2, format='int') |
|
208 | op.addParameter(name='n', value=int(conf['usrp_tx']['repetitions_1'])/2, format='int') | |
|
209 | #op.addParameter(name='removeDC', value=1, format='int') | |||
|
210 | ||||
206 |
|
211 | |||
207 | proc1 = project.addProcUnit(datatype='ParametersProc', inputId=voltage1.getId()) |
|
212 | proc1 = project.addProcUnit(datatype='ParametersProc', inputId=voltage1.getId()) | |
208 | proc1.addParameter(name='runNextUnit', value=True) |
|
213 | proc1.addParameter(name='runNextUnit', value=True) | |
@@ -253,6 +258,8 def main(args): | |||||
253 |
|
258 | |||
254 | op = voltage2.addOperation(name='PulsePair_vRF', optype='other') |
|
259 | op = voltage2.addOperation(name='PulsePair_vRF', optype='other') | |
255 | op.addParameter(name='n', value=int(conf['usrp_tx']['repetitions_2'])/ncode, format='int') |
|
260 | op.addParameter(name='n', value=int(conf['usrp_tx']['repetitions_2'])/ncode, format='int') | |
|
261 | #op.addParameter(name='removeDC', value=1, format='int') | |||
|
262 | ||||
256 |
|
263 | |||
257 | proc2 = project.addProcUnit(datatype='ParametersProc', inputId=voltage2.getId()) |
|
264 | proc2 = project.addProcUnit(datatype='ParametersProc', inputId=voltage2.getId()) | |
258 | proc2.addParameter(name='runNextUnit', value=True) |
|
265 | proc2.addParameter(name='runNextUnit', value=True) | |
@@ -364,3 +371,5 if __name__ == '__main__': | |||||
364 | args = parser.parse_args() |
|
371 | args = parser.parse_args() | |
365 |
|
372 | |||
366 | main(args) |
|
373 | main(args) | |
|
374 | ||||
|
375 | # python sophy_proc.py HYO_PM@2022-06-09T15-05-12 --parameters V --plot --save --show --range 36 |
@@ -16,10 +16,10 for name, cb_table in sophy_cb_tables: | |||||
16 | #LINUX bash: export WRADLIB_DATA=/path/to/wradlib-data |
|
16 | #LINUX bash: export WRADLIB_DATA=/path/to/wradlib-data | |
17 | warnings.filterwarnings('ignore') |
|
17 | warnings.filterwarnings('ignore') | |
18 | PARAM = { |
|
18 | PARAM = { | |
19 |
'S': {'var': ' |
|
19 | 'S': {'var': 'power','vmin': -45, 'vmax': -15, 'cmap': 'jet', 'label': 'Power','unit': 'dBm'}, | |
20 |
'V': {'var': 'vel |
|
20 | 'V': {'var': 'velocity', 'vmin': -10, 'vmax': 10 , 'cmap': 'sophy_v', 'label': 'Velocity','unit': 'm/s'}, | |
21 |
'Z': {'var': ' |
|
21 | 'Z': {'var': 'reflectivity','vmin': -30, 'vmax': 80 , 'cmap': 'sophy_r','label': 'Reflectivity','unit': 'dBZ'}, | |
22 |
'W': {'var': ' |
|
22 | 'W': {'var': 'spectral_width', 'vmin': 0 , 'vmax': 12 , 'cmap': 'sophy_w','label': 'Spectral Width','unit': 'hz'} | |
23 | } |
|
23 | } | |
24 | class Readsophy(): |
|
24 | class Readsophy(): | |
25 | def __init__(self): |
|
25 | def __init__(self): | |
@@ -27,6 +27,7 class Readsophy(): | |||||
27 | self.grado = None |
|
27 | self.grado = None | |
28 | self.variable = None |
|
28 | self.variable = None | |
29 | self.save = None |
|
29 | self.save = None | |
|
30 | self.range = None | |||
30 |
|
31 | |||
31 | def read_files(self,path_file,grado=None, variable=None): |
|
32 | def read_files(self,path_file,grado=None, variable=None): | |
32 | filter= "_E"+str(grado)+".0_"+variable |
|
33 | filter= "_E"+str(grado)+".0_"+variable | |
@@ -40,13 +41,53 class Readsophy(): | |||||
40 | validFilelist.sort() |
|
41 | validFilelist.sort() | |
41 | return validFilelist |
|
42 | return validFilelist | |
42 |
|
43 | |||
43 | def setup(self, path_file,grado,variable,save): |
|
44 | def setup(self, path_file,grado,range,variable,save): | |
44 | self.path_file = path_file |
|
45 | self.path_file = path_file | |
|
46 | self.range = range | |||
45 | self.grado = grado |
|
47 | self.grado = grado | |
46 | self.variable = variable |
|
48 | self.variable = variable | |
47 | self.save = save |
|
49 | self.save = save | |
48 | self.list_file = self.read_files(path_file=self.path_file,grado=self.grado, variable=self.variable) |
|
50 | self.list_file = self.read_files(path_file=self.path_file,grado=self.grado, variable=self.variable) | |
49 |
|
51 | |||
|
52 | def selectHeights(self,heightList,minHei,maxHei): | |||
|
53 | ||||
|
54 | if minHei and maxHei: | |||
|
55 | if (minHei < heightList[0]): | |||
|
56 | minHei = heightList[0] | |||
|
57 | if (maxHei > heightList[-1]): | |||
|
58 | maxHei = heightList[-1] | |||
|
59 | minIndex = 0 | |||
|
60 | maxIndex = 0 | |||
|
61 | heights = heightList | |||
|
62 | ||||
|
63 | inda = numpy.where(heights >= minHei) | |||
|
64 | indb = numpy.where(heights <= maxHei) | |||
|
65 | ||||
|
66 | try: | |||
|
67 | minIndex = inda[0][0] | |||
|
68 | except: | |||
|
69 | minIndex = 0 | |||
|
70 | ||||
|
71 | try: | |||
|
72 | maxIndex = indb[0][-1] | |||
|
73 | except: | |||
|
74 | maxIndex = len(heights) | |||
|
75 | ||||
|
76 | new_heightList= self.selectHeightsByIndex(heightList=heightList,minIndex=minIndex, maxIndex=maxIndex) | |||
|
77 | ||||
|
78 | return new_heightList, minIndex,maxIndex | |||
|
79 | ||||
|
80 | def selectHeightsByIndex(self,heightList,minIndex, maxIndex): | |||
|
81 | ||||
|
82 | if (minIndex < 0) or (minIndex > maxIndex): | |||
|
83 | raise ValueError("Height index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |||
|
84 | ||||
|
85 | if (maxIndex >= len(heightList)): | |||
|
86 | maxIndex = len(heightList) | |||
|
87 | ||||
|
88 | new_h = heightList[minIndex:maxIndex] | |||
|
89 | return new_h | |||
|
90 | ||||
50 | def run(self): |
|
91 | def run(self): | |
51 | count= 0 |
|
92 | count= 0 | |
52 | len_files = len(self.list_file) |
|
93 | len_files = len(self.list_file) | |
@@ -63,19 +104,27 class Readsophy(): | |||||
63 | vmin = PARAM[self.variable]['vmin'] |
|
104 | vmin = PARAM[self.variable]['vmin'] | |
64 | vmax = PARAM[self.variable]['vmax'] |
|
105 | vmax = PARAM[self.variable]['vmax'] | |
65 | label = PARAM[self.variable]['label'] |
|
106 | label = PARAM[self.variable]['label'] | |
66 |
var_ = 'Data/'+var+'/ |
|
107 | var_ = 'Data/'+var+'/H' | |
67 | data_arr = numpy.array(test_hdf5[var_]['data']) # data |
|
108 | data_arr = numpy.array(test_hdf5[var_]['data']) # data | |
68 |
utc_time = numpy.array(test_hdf5['Data/ |
|
109 | utc_time = numpy.array(test_hdf5['Data/time']['data']) | |
69 |
data_azi = numpy.array(test_hdf5['Metadata/ |
|
110 | data_azi = numpy.array(test_hdf5['Metadata/azimuth']['data']) # th | |
70 |
data_ele = numpy.array(test_hdf5["Metadata/ |
|
111 | data_ele = numpy.array(test_hdf5["Metadata/elevation"]['data']) | |
71 |
heightList = numpy.array(test_hdf5["Metadata/ |
|
112 | heightList = numpy.array(test_hdf5["Metadata/range"]['data']) # r | |
|
113 | ||||
|
114 | if self.range==0: | |||
|
115 | self.range == heightList[-1] | |||
|
116 | else: | |||
|
117 | print(self.range) | |||
|
118 | new_heightList,minIndex,maxIndex = self.selectHeights(heightList,0.06,self.range) | |||
|
119 | ||||
|
120 | ||||
72 | my_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(utc_time[0])) |
|
121 | my_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(utc_time[0])) | |
73 | time_save = time.strftime('%Y%m%d_%H%M%S',time.localtime(utc_time[0])) |
|
122 | time_save = time.strftime('%Y%m%d_%H%M%S',time.localtime(utc_time[0])) | |
74 |
|
123 | |||
75 | # PLOT DATA WITH ANNOTATION |
|
124 | # PLOT DATA WITH ANNOTATION | |
76 | if count ==1: |
|
125 | if count ==1: | |
77 | fig = pl.figure(figsize=(10,8)) |
|
126 | fig = pl.figure(figsize=(10,8)) | |
78 |
cgax, pm = wradlib.vis.plot_ppi(data_arr,r=heightList,az=data_azi,rf=1 |
|
127 | cgax, pm = wradlib.vis.plot_ppi(data_arr[:,minIndex:maxIndex],r=new_heightList,az=data_azi,rf=1,fig=fig, ax=111,proj='cg',cmap=cmap,vmin=vmin, vmax=vmax) | |
79 | caax = cgax.parasites[0] |
|
128 | caax = cgax.parasites[0] | |
80 | title = 'Simple PPI'+"-"+ my_time |
|
129 | title = 'Simple PPI'+"-"+ my_time | |
81 | t = pl.title(title, fontsize=12,y=1.05) |
|
130 | t = pl.title(title, fontsize=12,y=1.05) | |
@@ -84,7 +133,7 class Readsophy(): | |||||
84 | cbar.set_label(label+'[' + unit + ']') |
|
133 | cbar.set_label(label+'[' + unit + ']') | |
85 | gh = cgax.get_grid_helper() |
|
134 | gh = cgax.get_grid_helper() | |
86 | else: |
|
135 | else: | |
87 |
cgax, pm = wradlib.vis.plot_ppi(data_arr,r=heightList,az=data_azi,rf=1 |
|
136 | cgax, pm = wradlib.vis.plot_ppi(data_arr[:,minIndex:maxIndex],r=new_heightList,az=data_azi,rf=1,fig=fig, ax=111,proj='cg',cmap=cmap,vmin=vmin, vmax=vmax) | |
88 | caax = cgax.parasites[0] |
|
137 | caax = cgax.parasites[0] | |
89 | title = 'Simple PPI'+"-"+my_time |
|
138 | title = 'Simple PPI'+"-"+my_time | |
90 | t = pl.title(title, fontsize=12,y=1.05) |
|
139 | t = pl.title(title, fontsize=12,y=1.05) | |
@@ -97,26 +146,33 class Readsophy(): | |||||
97 | filename = "SOPHY"+"_"+time_save+"_"+"E."+self.grado+"_"+self.variable+".png" |
|
146 | filename = "SOPHY"+"_"+time_save+"_"+"E."+self.grado+"_"+self.variable+".png" | |
98 | dir =self.variable+"_"+"E."+self.grado+"CH0/" |
|
147 | dir =self.variable+"_"+"E."+self.grado+"CH0/" | |
99 | filesavepath = os.path.join(self.path_file,dir) |
|
148 | filesavepath = os.path.join(self.path_file,dir) | |
100 |
|
|
149 | try: | |
|
150 | os.mkdir(filesavepath) | |||
|
151 | except: | |||
|
152 | pass | |||
101 | else: |
|
153 | else: | |
102 | filename = "SOPHY"+"_"+time_save+"_"+"E."+self.grado+"_"+self.variable+".png" |
|
154 | filename = "SOPHY"+"_"+time_save+"_"+"E."+self.grado+"_"+self.variable+".png" | |
103 | pl.savefig(filesavepath+filename) |
|
155 | pl.savefig(filesavepath+filename) | |
104 |
|
156 | |||
105 |
pl.pause( |
|
157 | pl.pause(1) | |
106 | pl.clf() |
|
158 | pl.clf() | |
107 | if count==len_files: |
|
159 | if count==len_files: | |
108 | pl.close() |
|
160 | pl.close() | |
109 | pl.show() |
|
161 | pl.show() | |
110 |
|
162 | |||
111 |
PATH = "/home/soporte/Documents/EVENTO/HYO_PM@2022-06-09T15-05-12/paramC0 |
|
163 | PATH = "/home/soporte/Documents/EVENTO/HYO_PM@2022-06-09T15-05-12/paramC0N36.0/2022-06-09T18-00-00/" | |
|
164 | PATH = "/home/soporte/Documents/EVENTO/HYO_PM@2022-06-09T15-05-12/paramC0N36.0/2022-06-09T19-00-00/" | |||
|
165 | ||||
|
166 | #PATH = "/home/soporte/Documents/EVENTO/HYO_PM@2022-05-31T12-00-17/paramC0N36.0/2022-05-31T16-00-00/" | |||
112 |
|
167 | |||
113 | def main(args): |
|
168 | def main(args): | |
114 | grado = args.grado |
|
169 | grado = args.grado | |
115 | parameters = args.parameters |
|
170 | parameters = args.parameters | |
116 | save = args.save |
|
171 | save = args.save | |
|
172 | range = args.range | |||
117 | obj = Readsophy() |
|
173 | obj = Readsophy() | |
118 | for param in parameters: |
|
174 | for param in parameters: | |
119 | obj.setup(path_file = PATH,grado = grado, variable=param,save=int(save)) |
|
175 | obj.setup(path_file = PATH,grado = grado,range=range, variable=param,save=int(save)) | |
120 | obj.run() |
|
176 | obj.run() | |
121 |
|
177 | |||
122 | if __name__ == '__main__': |
|
178 | if __name__ == '__main__': | |
@@ -128,11 +184,13 if __name__ == '__main__': | |||||
128 | help='Angle in Elev to plot') |
|
184 | help='Angle in Elev to plot') | |
129 | parser.add_argument('--save', default=0, |
|
185 | parser.add_argument('--save', default=0, | |
130 | help='Save plot') |
|
186 | help='Save plot') | |
|
187 | parser.add_argument('--range', default=0, type=float, | |||
|
188 | help='Max range to plot') | |||
131 | args = parser.parse_args() |
|
189 | args = parser.parse_args() | |
132 |
|
190 | |||
133 | main(args) |
|
191 | main(args) | |
134 |
|
192 | |||
135 |
|
193 | #python sophy_proc_rev006.py --parameters Z --grado 8 --save 1 --range 28 | ||
136 | ''' |
|
194 | ''' | |
137 | def read_and_overview(filename): |
|
195 | def read_and_overview(filename): | |
138 | """Read HDF5 using read_generic_hdf5 and print upper level dictionary keys |
|
196 | """Read HDF5 using read_generic_hdf5 and print upper level dictionary keys |
General Comments 0
You need to be logged in to leave comments.
Login now