##// END OF EJS Templates
19 DE AGOSTO 2021 RM
avaldez -
r1367:42e9a23049f5
parent child
Show More
@@ -0,0 +1,31
1 import os,sys
2 import datetime
3 import time
4 from schainpy.controller import Project
5 path='/DATA_RM/TEST_HDF5'
6 path_adq=path
7 path_ped='/DATA_RM/TEST_PEDESTAL/P2021200'
8 figpath = '/home/soporte/Pictures'
9 desc = "Simulator Test"
10
11 controllerObj = Project()
12 controllerObj.setup(id='10',name='Test Simulator',description=desc)
13 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader',
14 path=path,
15 startDate="2021/01/01", #"2020/01/01",#today,
16 endDate= "2021/12/01", #"2020/12/30",#today,
17 startTime='00:00:00',
18 endTime='23:59:59',
19 t_Interval_p=0.01,
20 n_Muestras_p=100,
21 delay=5,
22 #set=0,
23 online=0,
24 walk=1)#1
25
26 procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId())
27
28
29 controllerObj.start()
30 #online 1 utc_adq 1617490240.48
31 #online 0 utc_adq 1617489815.4804
@@ -0,0 +1,92
1 import numpy
2 import sys
3 import zmq
4 import time
5 import h5py
6 import os
7
8 timetuple=time.localtime()
9 meta='P'
10 dir="%s%4.4d%3.3d"%(meta,timetuple.tm_year,timetuple.tm_yday)
11
12 path="/home/soporte/Downloads/PEDESTAL/"+dir
13
14 ext=".hdf5"
15
16 port ="5556"
17 if len(sys.argv)>1:
18 port = sys.argv[1]
19 int(port)
20
21 if len(sys.argv)>2:
22 port1 = sys.argv[2]
23 int(port1)
24
25 #Socket to talk to server
26 context = zmq.Context()
27 socket = context.socket(zmq.SUB)
28
29 print("Collecting updates from weather server...")
30 socket.connect("tcp://localhost:%s"%port)
31
32 if len(sys.argv)>2:
33 socket.connect("tcp://localhost:%s"%port1)
34
35 #Subscribe to zipcode, default is NYC,10001
36 topicfilter = "10001"
37 socket.setsockopt_string(zmq.SUBSCRIBE,topicfilter)
38 #Process 5 updates
39 total_value=0
40 count= -1
41 azi= []
42 elev=[]
43 time0=[]
44 #for update_nbr in range(250):
45 while(True):
46 string= socket.recv()
47 topic,ang_elev,ang_elev_dec,ang_azi,ang_azi_dec,seconds,seconds_dec= string.split()
48 ang_azi =float(ang_azi)+1e-3*float(ang_azi_dec)
49 ang_elev =float(ang_elev)+1e-3*float(ang_elev_dec)
50 seconds =float(seconds) +1e-6*float(seconds_dec)
51 azi.append(ang_azi)
52 elev.append(ang_elev)
53 time0.append(seconds)
54 count +=1
55 if count == 100:
56 timetuple=time.localtime()
57 epoc = time.mktime(timetuple)
58 #print(epoc)
59 fullpath = path + ("/" if path[-1]!="/" else "")
60
61 if not os.path.exists(fullpath):
62 os.mkdir(fullpath)
63
64 azi_array = numpy.array(azi)
65 elev_array = numpy.array(elev)
66 time0_array= numpy.array(time0)
67 pedestal_array=numpy.array([azi,elev,time0])
68 count=0
69 azi= []
70 elev=[]
71 time0=[]
72 #print(pedestal_array[0])
73 #print(pedestal_array[1])
74
75 meta='PE'
76 filex="%s%4.4d%3.3d%10.4d%s"%(meta,timetuple.tm_year,timetuple.tm_yday,epoc,ext)
77 filename = os.path.join(fullpath,filex)
78 fp = h5py.File(filename,'w')
79 #print("Escribiendo HDF5...",epoc)
80 #·················· Data·....······································
81 grp = fp.create_group("Data")
82 dset = grp.create_dataset("azimuth" , data=pedestal_array[0])
83 dset = grp.create_dataset("elevacion", data=pedestal_array[1])
84 dset = grp.create_dataset("utc" , data=pedestal_array[2])
85 #·················· Metadata·······································
86 grp = fp.create_group("Metadata")
87 dset = grp.create_dataset("utctimeInit", data=pedestal_array[2][0])
88 timeInterval = pedestal_array[2][1]-pedestal_array[2][0]
89 dset = grp.create_dataset("timeInterval", data=timeInterval)
90 fp.close()
91
92 #print ("Average messagedata value for topic '%s' was %dF" % ( topicfilter,total_value / update_nbr))
@@ -0,0 +1,48
1 ###########################################################################
2 ############################### SERVIDOR###################################
3 ######################### SIMULADOR DE PEDESTAL############################
4 ###########################################################################
5 import time
6 import math
7 import numpy
8 import struct
9 from time import sleep
10 import zmq
11 import pickle
12 port="5556"
13 context = zmq.Context()
14 socket = context.socket(zmq.PUB)
15 socket.bind("tcp://*:%s"%port)
16 ###### PARAMETROS DE ENTRADA################################
17 print("PEDESTAL RESOLUCION 0.01")
18 print("MAXIMA VELOCIDAD DEL PEDESTAL")
19 ang_elev = 4.12
20 ang_azi = 30
21 velocidad= input ("Ingresa velocidad:")
22 velocidad= float(velocidad)
23 print (velocidad)
24 ############################################################
25 sleep(3)
26 print("Start program")
27 t1 = time.time()
28 count=0
29 while(True):
30 tmp_vuelta = int(360/velocidad)
31 t1=t1+tmp_vuelta*count
32 count= count+1
33 muestras_seg = 100
34 t2 = time.time()
35 for i in range(tmp_vuelta):
36 for j in range(muestras_seg):
37 tmp_variable = (i+j/100.0)
38 ang_azi = (tmp_variable)*float(velocidad)
39 seconds = t1+ tmp_variable
40 topic=10001
41 print ("Azim°: ","%.4f"%ang_azi,"Time:" ,"%.5f"%seconds)
42 seconds_dec=(seconds-int(seconds))*1e6
43 ang_azi_dec= (ang_azi-int(ang_azi))*1e3
44 ang_elev_dec=(ang_elev-int(ang_elev))*1e3
45 sleep(0.0088)
46 socket.send_string("%d %d %d %d %d %d %d"%(topic,ang_elev,ang_elev_dec,ang_azi,ang_azi_dec,seconds,seconds_dec))
47 t3 = time.time()
48 print ("Total time for 1 vuelta in Seconds",t3-t2)
@@ -0,0 +1,275
1 #!python
2 '''
3 '''
4
5 import os, sys
6 import datetime
7 import time
8
9 #path = os.path.dirname(os.getcwd())
10 #path = os.path.dirname(path)
11 #sys.path.insert(0, path)
12
13 from schainpy.controller import Project
14
15 desc = "USRP_test"
16 filename = "USRP_processing.xml"
17 controllerObj = Project()
18 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
19
20 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
21
22 #######################################################################
23 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
24 #######################################################################
25 #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman'
26 #path = '/DATA_RM/TEST_INTEGRACION'
27 #path = '/DATA_RM/PRUEBA_USRP_RP'
28 path = '/DATA_RM/PRUEBA_USRP_RP'
29
30 figpath = '/home/soporte/Pictures/TEST_RP_0001'
31 figpath = '/home/soporte/Pictures/TEST_RP_6000'
32 figpath = '/home/soporte/Pictures/USRP'
33 #remotefolder = "/home/wmaster/graficos"
34 #######################################################################
35 ################# RANGO DE PLOTEO######################################
36 #######################################################################
37 dBmin = '-5'
38 dBmax = '20'
39 xmin = '0'
40 xmax ='24'
41 ymin = '0'
42 ymax = '600'
43 #######################################################################
44 ########################FECHA##########################################
45 #######################################################################
46 str = datetime.date.today()
47 today = str.strftime("%Y/%m/%d")
48 str2 = str - datetime.timedelta(days=1)
49 yesterday = str2.strftime("%Y/%m/%d")
50 #######################################################################
51 ######################## UNIDAD DE LECTURA#############################
52 #######################################################################
53 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
54 path=path,
55 startDate="2021/07/02",#today,
56 endDate="2021/07/02",#today,
57 startTime='14:50:00',# inicio libre
58 #startTime='00:00:00',
59 endTime='14:55:59',
60 delay=0,
61 #set=0,
62 online=0,
63 walk=1,
64 ippKm = 6000)
65
66 opObj11 = readUnitConfObj.addOperation(name='printInfo')
67 #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
68 #######################################################################
69 ################ OPERACIONES DOMINIO DEL TIEMPO########################
70 #######################################################################
71
72 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
73
74 opObj11 = procUnitConfObjA.addOperation(name='selectHeights')
75 opObj11.addParameter(name='minIndex', value='1', format='int')
76 # opObj11.addParameter(name='maxIndex', value='10000', format='int')
77 opObj11.addParameter(name='maxIndex', value='39980', format='int')
78
79 #
80 # codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\
81 # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1'
82
83 #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency')
84 #opObj11.addParameter(name='frequency', value='49920000')
85
86 '''
87 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
88 opObj11.addParameter(name='n', value='625', format='int')#10
89 opObj11.addParameter(name='removeDC', value=1, format='int')
90 '''
91
92 # Ploteo TEST
93 '''
94 opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')
95 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other')
96 opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other')
97 #opObj11.addParameter(name='xmax', value=8)
98 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other')
99 '''
100 # OJO SCOPE
101 #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external')
102 #opObj10.addParameter(name='id', value='10', format='int')
103 ##opObj10.addParameter(name='xmin', value='0', format='int')
104 ##opObj10.addParameter(name='xmax', value='50', format='int')
105 #opObj10.addParameter(name='type', value='iq')
106 ##opObj10.addParameter(name='ymin', value='-5000', format='int')
107 ##opObj10.addParameter(name='ymax', value='8500', format='int')
108 #opObj11.addParameter(name='save', value=figpath, format='str')
109 #opObj11.addParameter(name='save_period', value=10, format='int')
110
111 #opObj10 = procUnitConfObjA.addOperation(name='setH0')
112 #opObj10.addParameter(name='h0', value='-5000', format='float')
113
114 #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights')
115 #opObj11.addParameter(name='window', value='1', format='int')
116
117 #codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1'
118 #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other')
119 #opObj11.addParameter(name='code', value=codigo, format='floatlist')
120 #opObj11.addParameter(name='nCode', value='1', format='int')
121 #opObj11.addParameter(name='nBaud', value='28', format='int')
122
123 #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other')
124 #opObj11.addParameter(name='n', value='100', format='int')
125
126 #######################################################################
127 ########## OPERACIONES ParametersProc########################
128 #######################################################################
129 ###procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
130 '''
131
132 opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation')
133 opObj11.addParameter(name='path_ped', value=path_ped)
134 opObj11.addParameter(name='path_adq', value=path_adq)
135 opObj11.addParameter(name='t_Interval_p', value='0.01', format='float')
136 opObj11.addParameter(name='n_Muestras_p', value='100', format='float')
137 opObj11.addParameter(name='blocksPerfile', value='100', format='int')
138 opObj11.addParameter(name='f_a_p', value='25', format='int')
139 opObj11.addParameter(name='online', value='0', format='int')
140
141 opObj11 = procUnitConfObjA.addOperation(name='Block360')
142 opObj11.addParameter(name='n', value='40', format='int')
143
144 opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other')
145 opObj11.addParameter(name='save', value=figpath)
146 opObj11.addParameter(name='save_period', value=1)
147
148 8
149 '''
150
151 #######################################################################
152 ########## OPERACIONES DOMINIO DE LA FRECUENCIA########################
153 #######################################################################
154
155 #procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId())
156 #procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int')
157 #procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int')
158
159 procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId())
160 #procUnitConfObjB.addParameter(name='nFFTPoints', value='64', format='int')
161 #procUnitConfObjB.addParameter(name='nProfiles', value='64', format='int')
162 opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other')
163 #opObj11.addParameter(name='timeInterval', value='4', format='int')
164 opObj11.addParameter(name='n', value='100', format='int')
165
166 #procUnitConfObjB.addParameter(name='pairsList', value='(0,0),(1,1),(0,1)', format='pairsList')
167
168 #opObj13 = procUnitConfObjB.addOperation(name='removeDC')
169 #opObj13.addParameter(name='mode', value='2', format='int')
170
171 #opObj11 = procUnitConfObjB.addOperation(name='IncohInt', optype='other')
172 #opObj11.addParameter(name='n', value='8', format='float')
173 #######################################################################
174 ########## PLOTEO DOMINIO DE LA FRECUENCIA#############################
175 #######################################################################
176 #----
177
178 opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot')
179 opObj11.addParameter(name='id', value='10', format='int')
180 opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str')
181 #opObj11.addParameter(name='xmin', value=-100000, format='float')
182 #opObj11.addParameter(name='xmax', value=100000, format='float')
183 opObj11.addParameter(name='oneFigure', value=False,format='bool')
184 #opObj11.addParameter(name='zmin', value=-10, format='int')
185 #opObj11.addParameter(name='zmax', value=40, format='int')
186 opObj11.addParameter(name='ymin', value=10, format='int')
187 opObj11.addParameter(name='ymax', value=55, format='int')
188 opObj11.addParameter(name='grid', value=True, format='bool')
189 #opObj11.addParameter(name='showprofile', value='1', format='int')
190 opObj11.addParameter(name='save', value=figpath, format='str')
191 #opObj11.addParameter(name='save_period', value=10, format='int')
192
193 '''
194 opObj11 = procUnitConfObjC.addOperation(name='RTIHeisPlot')
195 opObj11.addParameter(name='id', value='10', format='int')
196 opObj11.addParameter(name='wintitle', value='RTI_Alturas', format='str')
197 opObj11.addParameter(name='xmin', value=11.0, format='float')
198 opObj11.addParameter(name='xmax', value=18.0, format='float')
199 opObj11.addParameter(name='zmin', value=10, format='int')
200 opObj11.addParameter(name='zmax', value=30, format='int')
201 opObj11.addParameter(name='ymin', value=5, format='int')
202 opObj11.addParameter(name='ymax', value=28, format='int')
203 opObj11.addParameter(name='showprofile', value='1', format='int')
204 opObj11.addParameter(name='save', value=figpath, format='str')
205 opObj11.addParameter(name='save_period', value=10, format='int')
206 '''
207 '''
208 #SpectraPlot
209
210 opObj11 = procUnitConfObjB.addOperation(name='SpectraPlot', optype='external')
211 opObj11.addParameter(name='id', value='1', format='int')
212 opObj11.addParameter(name='wintitle', value='Spectra', format='str')
213 #opObj11.addParameter(name='xmin', value=-0.01, format='float')
214 #opObj11.addParameter(name='xmax', value=0.01, format='float')
215 opObj11.addParameter(name='zmin', value=dBmin, format='int')
216 opObj11.addParameter(name='zmax', value=dBmax, format='int')
217 #opObj11.addParameter(name='ymin', value=ymin, format='int')
218 #opObj11.addParameter(name='ymax', value=ymax, format='int')
219 opObj11.addParameter(name='showprofile', value='1', format='int')
220 opObj11.addParameter(name='save', value=figpath, format='str')
221 opObj11.addParameter(name='save_period', value=10, format='int')
222
223 #RTIPLOT
224
225 opObj11 = procUnitConfObjB.addOperation(name='RTIPlot', optype='external')
226 opObj11.addParameter(name='id', value='2', format='int')
227 opObj11.addParameter(name='wintitle', value='RTIPlot', format='str')
228 opObj11.addParameter(name='zmin', value=dBmin, format='int')
229 opObj11.addParameter(name='zmax', value=dBmax, format='int')
230 #opObj11.addParameter(name='ymin', value=ymin, format='int')
231 #opObj11.addParameter(name='ymax', value=ymax, format='int')
232 #opObj11.addParameter(name='xmin', value=15, format='int')
233 #opObj11.addParameter(name='xmax', value=16, format='int')
234
235 opObj11.addParameter(name='showprofile', value='1', format='int')
236 opObj11.addParameter(name='save', value=figpath, format='str')
237 opObj11.addParameter(name='save_period', value=10, format='int')
238
239 '''
240 # opObj11 = procUnitConfObjB.addOperation(name='CrossSpectraPlot', optype='other')
241 # opObj11.addParameter(name='id', value='3', format='int')
242 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
243 # opObj11.addParameter(name='ymin', value=ymin, format='int')
244 # opObj11.addParameter(name='ymax', value=ymax, format='int')
245 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
246 # opObj11.addParameter(name='zmin', value=dBmin, format='int')
247 # opObj11.addParameter(name='zmax', value=dBmax, format='int')
248 # opObj11.addParameter(name='figpath', value=figures_path, format='str')
249 # opObj11.addParameter(name='save', value=0, format='bool')
250 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList')
251 # #
252 # opObj11 = procUnitConfObjB.addOperation(name='CoherenceMap', optype='other')
253 # opObj11.addParameter(name='id', value='4', format='int')
254 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
255 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
256 # opObj11.addParameter(name='xmin', value=xmin, format='float')
257 # opObj11.addParameter(name='xmax', value=xmax, format='float')
258 # opObj11.addParameter(name='figpath', value=figures_path, format='str')
259 # opObj11.addParameter(name='save', value=0, format='bool')
260 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList')
261 #
262
263 '''
264 #######################################################################
265 ############### UNIDAD DE ESCRITURA ###################################
266 #######################################################################
267 #opObj11 = procUnitConfObjB.addOperation(name='SpectraWriter', optype='other')
268 #opObj11.addParameter(name='path', value=wr_path)
269 #opObj11.addParameter(name='blocksPerFile', value='50', format='int')
270 print ("Escribiendo el archivo XML")
271 print ("Leyendo el archivo XML")
272 '''
273
274
275 controllerObj.start()
@@ -0,0 +1,126
1 #!python
2 '''
3 '''
4
5 import os, sys
6 import datetime
7 import time
8
9 #path = os.path.dirname(os.getcwd())
10 #path = os.path.dirname(path)
11 #sys.path.insert(0, path)
12
13 from schainpy.controller import Project
14
15 desc = "USRP_test"
16 filename = "USRP_processing.xml"
17 controllerObj = Project()
18 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
19
20 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
21
22 #######################################################################
23 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
24 #######################################################################
25 #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman'
26 #path = '/DATA_RM/TEST_INTEGRACION'
27 path = '/DATA_RM/TEST_ONLINE'
28 path_pp = '/DATA_RM/TEST_HDF5'
29
30 figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG'
31 #remotefolder = "/home/wmaster/graficos"
32 #######################################################################
33 ################# RANGO DE PLOTEO######################################
34 #######################################################################
35 dBmin = '-5'
36 dBmax = '20'
37 xmin = '0'
38 xmax ='24'
39 ymin = '0'
40 ymax = '600'
41 #######################################################################
42 ########################FECHA##########################################
43 #######################################################################
44 str = datetime.date.today()
45 today = str.strftime("%Y/%m/%d")
46 str2 = str - datetime.timedelta(days=1)
47 yesterday = str2.strftime("%Y/%m/%d")
48 #######################################################################
49 ######################## UNIDAD DE LECTURA#############################
50 #######################################################################
51 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
52 path=path,
53 startDate="2021/01/01",#today,
54 endDate="2021/12/30",#today,
55 startTime='00:00:00',
56 endTime='23:59:59',
57 delay=0,
58 #set=0,
59 online=1,
60 walk=1,
61 ippKm = 60)
62
63 opObj11 = readUnitConfObj.addOperation(name='printInfo')
64 #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
65 #######################################################################
66 ################ OPERACIONES DOMINIO DEL TIEMPO########################
67 #######################################################################
68
69 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
70
71 #
72 # codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\
73 # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1'
74
75 #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency')
76 #opObj11.addParameter(name='frequency', value='70312500')
77 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
78 opObj11.addParameter(name='n', value='625', format='int')#10
79 opObj11.addParameter(name='removeDC', value=1, format='int')
80 # Ploteo TEST
81 '''
82 opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')
83 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other')
84 opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other')
85 #opObj11.addParameter(name='xmax', value=8)
86 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other')
87 '''
88 # OJO SCOPE
89 #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external')
90 #opObj10.addParameter(name='id', value='10', format='int')
91 ##opObj10.addParameter(name='xmin', value='0', format='int')
92 ##opObj10.addParameter(name='xmax', value='50', format='int')
93 #opObj10.addParameter(name='type', value='iq')
94 ##opObj10.addParameter(name='ymin', value='-5000', format='int')
95 ##opObj10.addParameter(name='ymax', value='8500', format='int')
96 #opObj11.addParameter(name='save', value=figpath, format='str')
97 #opObj11.addParameter(name='save_period', value=10, format='int')
98
99 #opObj10 = procUnitConfObjA.addOperation(name='setH0')
100 #opObj10.addParameter(name='h0', value='-5000', format='float')
101
102 #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights')
103 #opObj11.addParameter(name='window', value='1', format='int')
104
105 #codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1'
106 #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other')
107 #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist')
108 #opObj11.addParameter(name='nCode', value='1', format='int')
109 #opObj11.addParameter(name='nBaud', value='28', format='int')
110
111 #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other')
112 #opObj11.addParameter(name='n', value='100', format='int')
113
114 #######################################################################
115 ########## OPERACIONES ParametersProc########################
116 #######################################################################
117
118 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
119 opObj10 = procUnitConfObjB.addOperation(name='HDFWriter')
120 opObj10.addParameter(name='path',value=path_pp)
121 #opObj10.addParameter(name='mode',value=0)
122 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
123 opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list')
124 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list'
125
126 controllerObj.start()
@@ -0,0 +1,126
1 #!python
2 '''
3 '''
4
5 import os, sys
6 import datetime
7 import time
8
9 #path = os.path.dirname(os.getcwd())
10 #path = os.path.dirname(path)
11 #sys.path.insert(0, path)
12
13 from schainpy.controller import Project
14
15 desc = "USRP_test"
16 filename = "USRP_processing.xml"
17 controllerObj = Project()
18 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
19
20 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
21
22 #######################################################################
23 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
24 #######################################################################
25 #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman'
26 #path = '/DATA_RM/TEST_INTEGRACION'
27 path = '/DATA_RM/TEST_ONLINE'
28 path_pp = '/DATA_RM/TEST_HDF5'
29
30 figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG'
31 #remotefolder = "/home/wmaster/graficos"
32 #######################################################################
33 ################# RANGO DE PLOTEO######################################
34 #######################################################################
35 dBmin = '-5'
36 dBmax = '20'
37 xmin = '0'
38 xmax ='24'
39 ymin = '0'
40 ymax = '600'
41 #######################################################################
42 ########################FECHA##########################################
43 #######################################################################
44 str = datetime.date.today()
45 today = str.strftime("%Y/%m/%d")
46 str2 = str - datetime.timedelta(days=1)
47 yesterday = str2.strftime("%Y/%m/%d")
48 #######################################################################
49 ######################## UNIDAD DE LECTURA#############################
50 #######################################################################
51 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
52 path=path,
53 startDate="2021/01/01",#today,
54 endDate="2021/12/30",#today,
55 startTime='00:00:00',
56 endTime='23:59:59',
57 delay=0,
58 #set=0,
59 online=1,
60 walk=1,
61 ippKm = 60)
62
63 opObj11 = readUnitConfObj.addOperation(name='printInfo')
64 #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
65 #######################################################################
66 ################ OPERACIONES DOMINIO DEL TIEMPO########################
67 #######################################################################
68
69 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
70
71 #
72 # codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\
73 # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1'
74
75 #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency')
76 #opObj11.addParameter(name='frequency', value='70312500')
77 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
78 opObj11.addParameter(name='n', value='625', format='int')#10
79 opObj11.addParameter(name='removeDC', value=1, format='int')
80 # Ploteo TEST
81 '''
82 opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')
83 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other')
84 opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other')
85 #opObj11.addParameter(name='xmax', value=8)
86 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other')
87 '''
88 # OJO SCOPE
89 #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external')
90 #opObj10.addParameter(name='buffer_sizeid', value='10', format='int')
91 ##opObj10.addParameter(name='xmin', value='0', format='int')
92 ##opObj10.addParameter(name='xmax', value='50', format='int')
93 #opObj10.addParameter(name='type', value='iq')
94 ##opObj10.addParameter(name='ymin', value='-5000', format='int')
95 ##opObj10.addParameter(name='ymax', value='8500', format='int')
96 #opObj11.addParameter(name='save', value=figpath, format='str')
97 #opObj11.addParameter(name='save_period', value=10, format='int')
98
99 #opObj10 = procUnitConfObjA.addOperation(name='setH0')
100 #opObj10.addParameter(name='h0', value='-5000', format='float')
101
102 #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights')
103 #opObj11.addParameter(name='window', value='1', format='int')
104
105 #codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1'
106 #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other')
107 #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist')
108 #opObj11.addParameter(name='nCode', value='1', format='int')
109 #opObj11.addParameter(name='nBaud', value='28', format='int')
110
111 #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other')
112 #opObj11.addParameter(name='n', value='100', format='int')
113
114 #######################################################################
115 ########## OPERACIONES ParametersProc########################
116 #######################################################################
117
118 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
119 opObj10 = procUnitConfObjB.addOperation(name='HDFWriter')
120 opObj10.addParameter(name='path',value=path_pp)
121 #opObj10.addParameter(name='mode',value=0)
122 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
123 opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list')
124 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list'
125
126 controllerObj.start()
@@ -0,0 +1,52
1 import os,sys
2 import datetime
3 import time
4 from schainpy.controller import Project
5 #path='/DATA_RM/TEST_HDF5/d2021200'
6 #path='/DATA_RM/TEST_HDF5/d2021200'
7 path='/DATA_RM/TEST_HDF5/d2021203'
8
9 path_adq=path
10 #path_ped='/DATA_RM/TEST_PEDESTAL/P2021200'
11 path_ped='/DATA_RM/TEST_PEDESTAL/P2021203'
12
13 figpath = '/home/soporte/Pictures'
14 desc = "Simulator Test"
15
16 controllerObj = Project()
17 controllerObj.setup(id='10',name='Test Simulator',description=desc)
18 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader',
19 path=path,
20 startDate="2021/01/01", #"2020/01/01",#today,
21 endDate= "2021/12/01", #"2020/12/30",#today,
22 startTime='00:00:00',
23 endTime='23:59:59',
24 t_Interval_p=0.01,
25 n_Muestras_p=100,
26 delay=5,
27 #set=0,
28 online=0,
29 walk=0)#1
30
31 procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId())
32
33 opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation')
34 opObj11.addParameter(name='path_ped', value=path_ped)
35 opObj11.addParameter(name='path_adq', value=path_adq)
36 opObj11.addParameter(name='t_Interval_p', value='0.01', format='float')
37 opObj11.addParameter(name='n_Muestras_p', value='100', format='float')
38 opObj11.addParameter(name='blocksPerfile', value='100', format='int')
39 opObj11.addParameter(name='f_a_p', value='25', format='int')
40 opObj11.addParameter(name='online', value='0', format='int')
41
42
43 opObj11 = procUnitConfObjA.addOperation(name='Block360')
44 opObj11.addParameter(name='n', value='40', format='int')
45
46 opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other')
47 opObj11.addParameter(name='save', value=figpath)
48 opObj11.addParameter(name='save_period', value=1)
49
50 controllerObj.start()
51 #online 1 utc_adq 1617490240.48
52 #online 0 utc_adq 1617489815.4804
@@ -0,0 +1,59
1 import os,sys
2 import datetime
3 import time
4 from schainpy.controller import Project
5 #path='/DATA_RM/TEST_HDF5/d2021200'
6 #path='/DATA_RM/TEST_HDF5/d2021200'
7 #path='/DATA_RM/TEST_HDF5/d2021214'
8 #path='/DATA_RM/TEST_HDF5/d2021229'
9
10 path='/DATA_RM/TEST_HDF5/d2021231'
11
12
13 path_adq=path
14 #path_ped='/DATA_RM/TEST_PEDESTAL/P2021200'
15 #path_ped='/DATA_RM/TEST_PEDESTAL/P2021214'
16 #path_ped='/DATA_RM/TEST_PEDESTAL/P2021230'
17 path_ped='/DATA_RM/TEST_PEDESTAL/P20210819'
18 figpath = '/home/soporte/Pictures'
19 desc = "Simulator Test"
20
21 controllerObj = Project()
22 controllerObj.setup(id='10',name='Test Simulator',description=desc)
23 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader',
24 path=path,
25 startDate="2021/01/01", #"2020/01/01",#today,
26 endDate= "2021/12/01", #"2020/12/30",#today,
27 startTime='00:00:00',
28 endTime='23:59:59',
29 t_Interval_p=0.01,
30 n_Muestras_p=100,
31 delay=30,
32 #set=0,
33 online=1,
34 walk=0,
35 nTries=6)#1
36
37 procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId())
38
39 opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation')
40 opObj11.addParameter(name='path_ped', value=path_ped)
41 opObj11.addParameter(name='path_adq', value=path_adq)
42 opObj11.addParameter(name='t_Interval_p', value='0.01', format='float')
43 opObj11.addParameter(name='n_Muestras_p', value='100', format='float')
44 opObj11.addParameter(name='blocksPerfile', value='100', format='int')
45 opObj11.addParameter(name='f_a_p', value='25', format='int')
46 opObj11.addParameter(name='online', value='1', format='int')# habilitar el enable aqui tambien
47
48
49 opObj11 = procUnitConfObjA.addOperation(name='Block360')
50 opObj11.addParameter(name='n', value='40', format='int')
51 # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180
52
53 opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other')
54 opObj11.addParameter(name='save', value=figpath)
55 opObj11.addParameter(name='save_period', value=1)
56
57 controllerObj.start()
58 #online 1 utc_adq 1617490240.48
59 #online 0 utc_adq 1617489815.4804
@@ -0,0 +1,35
1 #*******************************************************************************
2 #*************ARCHIVO DE CONFIGURACION - RADAR METEOROLOGICO********************
3 #*******************************************************************************
4 # 1-Resolucion_angular(Grados º)-F
5 1.0
6 # 2-Velocidad_Pedestal Azimuth(º/s)-F
7 4.0
8 # 3-Posicion_Pedestal Azimuth(º/s)-F
9 0.0
10 # 4-Posicion_Pedestal Elevacion(º/s)-F
11 30.0
12 # 5-IPP(useg)-F
13 400
14 # n-PulsePair-nFFTPoints-R
15 625
16 # 6-Cantidad_Muestras_archivo_pedestal-F
17 100
18 # 7-Tiempo_por_muestra_pedestal-F
19 0.01
20 # Tiempo_archivo_por_pedestal-R
21 1.0
22 # 8-Bloques_por_arhivo_adquisicion-F
23 100.0
24 # tiempo_por_archivo_adquisicion-R
25 25.0
26 # mode Time Domain(T , 1) or Frequency Domain(F , 0)
27 1
28 # path_p
29 /home/developer/Downloads/Pedestal/P2021093
30 # path_a
31 /home/developer/Downloads/HDF5_TESTPP2V3/d2021093
32 # online
33 0
34 # Directorio final
35 /home/developer/Downloads/HDF5_WR/
@@ -0,0 +1,70
1 print("LECTURA DE ARCHIVOS DE CONFIGURACION")
2 class ReadfileWR():
3 def __init__(self,filename):
4 f = open(filename, "r")
5 i=0
6 self.dict={'paht_ped':None,'path_adq':None,'path_res':None,'resolution':None,'vel_ped_azi':None,'pos_ped_azi':None,'pos_ped_ele':None,'ipp':None,'n':None,'len_ped':None,\
7 't_s_ped':None,'t_f_ped':None,'b_f_adq':None,'t_f_adq':None,'mode':None,'online':None}
8 while(True):
9 ##print(i)
10 linea = f.readline()
11 if i==4:
12 resolution=float(linea)
13 self.dict['resolution']=resolution
14 if i==6:
15 vel_pedestal_a=float(linea)
16 self.dict['vel_ped_azi']=vel_pedestal_a
17 if i==8:
18 pos_pedestal_a=float(linea)
19 self.dict['pos_ped_azi']=pos_pedestal_a
20 if i==10:
21 pos_pedestal_e=float(linea)
22 self.dict['pos_ped_ele']=pos_pedestal_e
23 if i==12:
24 ipp = float(linea)
25 self.dict['ipp']= round(ipp,5)
26 if i==14:
27 n = float(linea)
28 self.dict['n']= n
29 if i==16:
30 len_pedestal= float(linea)
31 self.dict['len_ped']= len_pedestal
32 if i==18:
33 time_x_sample_ped=float(linea)
34 self.dict['t_s_ped']= time_x_sample_ped
35 if i==20:
36 time_x_file_ped = float(linea)
37 self.dict['t_f_ped']= time_x_file_ped
38 if i==22:
39 bloques_x_file_adq= float(linea)
40 self.dict['b_f_adq']=bloques_x_file_adq
41 if i==24:
42 time_x_file_adq = float(linea)
43 self.dict['t_f_adq'] = time_x_file_adq
44 if i==26:
45 mode= int(linea)
46 self.dict['mode'] = mode
47 if i==28:
48 path_p= str(linea)
49 self.dict['path_ped'] = path_p
50 if i==30:
51 path_a= str(linea)
52 self.dict['path_adq'] = path_a
53 if i==32:
54 online= int(linea)
55 self.dict['online'] = online
56 if i==34:
57 path_r= str(linea)
58 self.dict['path_res'] = path_r
59 #print(linea)
60 if not linea:
61 break
62 i+=1
63 f.close()
64 def getDict(self):
65 return self.dict
66
67
68 #filename= "/home/developer/Downloads/config_WR.txt"
69 #dict= ReadfileWR(filename).getDict()
70 #print(dict)
@@ -0,0 +1,118
1 #!python
2 '''
3 '''
4
5 import os, sys
6 import datetime
7 import time
8
9
10 from schainpy.controller import Project
11
12 desc = "USRP_test"
13 filename = "USRP_processing.xml"
14 controllerObj = Project()
15 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
16
17 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
18
19 #######################################################################
20 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
21 #######################################################################
22 # path IVAN
23 path = '/home/soporte/jarsjuliahigh/high'
24
25 figpath = '/home/soporte/Pictures/IVAN'
26 #remotefolder = "/home/wmaster/graficos"
27 #######################################################################
28 ################# RANGO DE PLOTEO######################################
29 #######################################################################
30 dBmin = '10'
31 dBmax = '55'
32 xmin = '0'
33 xmax ='24'
34 ymin = '0'
35 ymax = '600'
36 #######################################################################
37 ########################FECHA##########################################
38 #######################################################################
39 str = datetime.date.today()
40 today = str.strftime("%Y/%m/%d")
41 str2 = str - datetime.timedelta(days=1)
42 yesterday = str2.strftime("%Y/%m/%d")
43 #######################################################################
44 ######################## UNIDAD DE LECTURA#############################
45 #######################################################################
46 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
47 path=path,
48 startDate="2021/07/02",#today,
49 endDate="2021/07/02",#today,
50 startTime='14:50:01',# inicio libre
51 endTime='14:55:59',
52 delay=0,
53 #set=0,
54 online=0,
55 walk=0)
56
57 opObj11 = readUnitConfObj.addOperation(name='printInfo')
58 #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
59 #######################################################################
60 ################ OPERACIONES DOMINIO DEL TIEMPO########################
61 #######################################################################
62
63 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
64
65 #opObj10 = procUnitConfObjA.addOperation(name='selectChannels')
66 #opObj10.addParameter(name='channelList', value=[0])
67
68 '''
69 opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external')
70 opObj10.addParameter(name='id', value='10', format='int')
71 #opObj10.addParameter(name='xmin', value='0', format='int')
72 ##opObj10.addParameter(name='xmax', value='50', format='int')
73 opObj10.addParameter(name='type', value='iq')
74 ##opObj10.addParameter(name='ymin', value='-5000', format='int')
75 ##opObj10.addParameter(name='ymax', value='8500', format='int')
76 #opObj11.addParameter(name='save', value=figpath, format='str')
77 #opObj11.addParameter(name='save_period', value=10, format='int')
78 '''
79 ###opObj11 = procUnitConfObjA.addOperation(name='selectHeights')
80 ###opObj11.addParameter(name='minIndex', value='1', format='int')
81 #### opObj11.addParameter(name='maxIndex', value='10000', format='int')
82 ####opObj11.addParameter(name='maxIndex', value='39980', format='int')
83
84 #######################################################################
85 ########## OPERACIONES DOMINIO DE LA FRECUENCIA########################
86 #######################################################################
87
88 #procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId())
89 #procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int')
90 #procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int')
91
92 procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId())
93
94 opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other')
95 #opObj11.addParameter(name='timeInterval', value='4', format='int')
96 opObj11.addParameter(name='n', value='100', format='int')
97
98 #opObj11.addParameter(name='overlapping', value=True, format='bool')
99
100 opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot')
101 opObj11.addParameter(name='id', value='10', format='int')
102 opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str')
103
104 #opObj11.addParameter(name='xmin', value=-100000, format='float')
105 #opObj11.addParameter(name='xmax', value=100000, format='float')
106 opObj11.addParameter(name='oneFigure', value=False,format='bool')
107 #opObj11.addParameter(name='zmin', value=-10, format='int')
108 #opObj11.addParameter(name='zmax', value=40, format='int')
109 opObj11.addParameter(name='ymin', value=dBmin, format='int')
110 opObj11.addParameter(name='ymax', value=dBmax, format='int')
111 opObj11.addParameter(name='grid', value=True, format='bool')
112 #opObj11.addParameter(name='showprofile', value='1', format='int')
113 opObj11.addParameter(name='save', value=figpath, format='str')
114 #opObj11.addParameter(name='save_period', value=10, format='int')
115
116
117
118 controllerObj.start()
@@ -0,0 +1,103
1 #!python
2 '''
3 '''
4
5 import os, sys
6 import datetime
7 import time
8
9
10 from schainpy.controller import Project
11
12 desc = "USRP_test"
13 filename = "USRP_processing.xml"
14 controllerObj = Project()
15 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
16
17 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
18
19 #######################################################################
20 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
21 #######################################################################
22 # path JHON
23 path = '/home/soporte/jars2'
24
25 figpath = '/home/soporte/Pictures/JHON'
26 #remotefolder = "/home/wmaster/graficos"
27 #######################################################################
28 ################# RANGO DE PLOTEO######################################
29 #######################################################################
30 dBmin = '0'
31 dBmax = '50'
32 xmin = '0'
33 xmax ='24'
34 ymin = '0'
35 ymax = '600'
36 #######################################################################
37 ########################FECHA##########################################
38 #######################################################################
39 str = datetime.date.today()
40 today = str.strftime("%Y/%m/%d")
41 str2 = str - datetime.timedelta(days=1)
42 yesterday = str2.strftime("%Y/%m/%d")
43 #######################################################################
44 ######################## UNIDAD DE LECTURA#############################
45 #######################################################################
46 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
47 path=path,
48 startDate="2021/07/02",#today,
49 endDate="2021/07/02",#today,
50 startTime='19:45:00',# inicio libre
51 endTime='19:50:59',
52 delay=0,
53 #set=0,
54 online=0,
55 walk=0)
56
57 opObj11 = readUnitConfObj.addOperation(name='printInfo')
58 #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
59 #######################################################################
60 ################ OPERACIONES DOMINIO DEL TIEMPO########################
61 #######################################################################
62
63 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
64
65 opObj11 = procUnitConfObjA.addOperation(name='selectHeights')
66 opObj11.addParameter(name='minIndex', value='1', format='int')
67 # opObj11.addParameter(name='maxIndex', value='10000', format='int')
68 opObj11.addParameter(name='maxIndex', value='39980', format='int')
69
70
71 #######################################################################
72 ########## OPERACIONES DOMINIO DE LA FRECUENCIA########################
73 #######################################################################
74
75 #procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId())
76 #procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int')
77 #procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int')
78
79 procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId())
80
81 #opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other')
82 #opObj11.addParameter(name='timeInterval', value='4', format='int')
83 opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other')
84 #opObj11.addParameter(name='timeInterval', value='4', format='int')
85 opObj11.addParameter(name='n', value='100', format='int')
86
87
88 opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot')
89 opObj11.addParameter(name='id', value='10', format='int')
90 opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str')
91 #opObj11.addParameter(name='xmin', value=-100000, format='float')
92 #opObj11.addParameter(name='xmax', value=100000, format='float')
93 opObj11.addParameter(name='oneFigure', value=False,format='bool')
94 #opObj11.addParameter(name='zmin', value=-10, format='int')
95 #opObj11.addParameter(name='zmax', value=40, format='int')
96 opObj11.addParameter(name='ymin', value=dBmin, format='int')
97 opObj11.addParameter(name='ymax', value=dBmax, format='int')
98 opObj11.addParameter(name='grid', value=True, format='bool')
99 #opObj11.addParameter(name='showprofile', value='1', format='int')
100 opObj11.addParameter(name='save', value=figpath, format='str')
101 #opObj11.addParameter(name='save_period', value=10, format='int')
102
103 controllerObj.start()
@@ -0,0 +1,47
1 import os,sys
2 import datetime
3 import time
4 from schainpy.controller import Project
5 '''
6 NOTA:
7 Este script de prueba.
8 - Unidad del lectura 'HDFReader'.
9 - Unidad de procesamiento VoltageProc
10 - Unidad de procesamiento SpectraProc
11 - Operacion removeDC.
12 - Unidad de procesamiento ParametersProc
13 - Operacion SpectralMoments
14 - Operacion SpectralMomentsPlot
15 - Unidad de escrituda 'HDFWriter'.
16 '''
17 path='/home/developer/Downloads/HDF5_WR'
18 figpath = path
19 desc = "Simulator Test"
20
21 controllerObj = Project()
22
23 controllerObj.setup(id='10',name='Test Simulator',description=desc)
24
25 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader',
26 path=path,
27 startDate="2021/01/01", #"2020/01/01",#today,
28 endDate= "2021/12/01", #"2020/12/30",#today,
29 startTime='00:00:00',
30 endTime='23:59:59',
31 delay=0,
32 #set=0,
33 online=0,
34 walk=0)#1
35
36 procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId())
37
38 opObj11 = procUnitConfObjA.addOperation(name='Block360')
39 opObj11.addParameter(name='n', value='40', format='int')
40
41 opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other')
42 opObj11.addParameter(name='save', value=figpath)
43 opObj11.addParameter(name='save_period', value=1)
44 #opObj11 = procUnitConfObjA.addOperation(name='PowerPlot', optype='other')#PulsepairPowerPlot
45 #opObj11 = procUnitConfObjA.addOperation(name='PPSignalPlot', optype='other')
46
47 controllerObj.start()
@@ -0,0 +1,51
1 import os,sys,json
2 import datetime
3 import time
4 from schainpy.controller import Project
5 '''
6 NOTA:
7 Este script de prueba.
8 - Unidad del lectura 'HDFReader'.
9 - Unidad de procesamiento ParametersProc
10 - Operacion SpectralMomentsPlot
11
12 '''
13 path = '/home/soporte/Downloads/RAWDATA_PP'
14 path='/DATA_RM/TEST_HDF5/d2021203'
15 figpath = '/home/soporte/Downloads/IMAGE'
16 desc = "Simulator Test"
17 desc_data = {
18 'Data': {
19 'dataPP_POW': 'Data/dataPP_POW/channel00',
20 'utctime':'Data/utctime'
21 },
22 'Metadata': {
23 'heightList' :'Metadata/heightList',
24 'flagDataAsBlock':'Metadata/flagDataAsBlock',
25 'profileIndex':'Metadata/profileIndex'
26 }
27 }
28
29 controllerObj = Project()
30
31 controllerObj.setup(id='10',name='Test Simulator',description=desc)
32
33 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader',
34 path=path,
35 startDate="2021/01/01", #"2020/01/01",#today,
36 endDate= "2021/12/01", #"2020/12/30",#today,
37 startTime='00:00:00',
38 endTime='23:59:59',
39 delay=0,
40 #set=0,
41 online=0,
42 walk=0,
43 description= json.dumps(desc_data))#1
44
45 procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId())
46
47 #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')#PulsepairPowerPlot
48 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other')
49
50
51 controllerObj.start()
@@ -0,0 +1,56
1 import os,sys,json
2 import datetime
3 import time
4 from schainpy.controller import Project
5 '''
6 NOTA:
7 Este script de prueba.
8 - Unidad del lectura 'HDFReader'.
9 - Unidad de procesamiento ParametersProc
10 - Operacion SpectralMomentsPlot
11
12 '''
13 path = '/home/soporte/Downloads/RAWDATA'
14 figpath = '/home/soporte/Downloads/IMAGE'
15 desc = "Simulator Test"
16 desc_data = {
17 'Data': {
18 'data_pow': 'Data/data_pow/channel00',
19 'data_dop': 'Data/data_dop/channel00',
20 'utctime':'Data/utctime'
21 },
22 'Metadata': {
23 'heightList':'Metadata/heightList',
24 'nIncohInt' :'Metadata/nIncohInt',
25 'nCohInt' :'Metadata/nCohInt',
26 'nProfiles' :'Metadata/nProfiles',
27 'channelList' :'Metadata/channelList'
28 }
29 }
30
31 controllerObj = Project()
32
33 controllerObj.setup(id='10',name='Test Simulator',description=desc)
34
35 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader',
36 path=path,
37 startDate="2021/01/01", #"2020/01/01",#today,
38 endDate= "2021/12/01", #"2020/12/30",#today,
39 startTime='00:00:00',
40 endTime='23:59:59',
41 delay=0,
42 #set=0,
43 online=0,
44 walk=1,
45 description= json.dumps(desc_data))#1
46
47 procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId())
48 '''
49 opObj11 = procUnitConfObjA.addOperation(name='DopplerPlot',optype='external')
50 #opObj11.addParameter(name='xmin', value=0)
51 #opObj11.addParameter(name='xmax', value=23)
52 opObj11.addParameter(name='save', value=figpath)
53 opObj11.addParameter(name='showprofile', value=0)
54 opObj11.addParameter(name='save_period', value=10)
55 '''
56 controllerObj.start()
@@ -0,0 +1,55
1 import os,sys
2 import datetime
3 import time
4 from schainpy.controller import Project
5
6 #*************************************************************************
7 #**************************LECTURA config_WR.txt**************************
8 #*************************************************************************
9 from readFileconfig import ReadfileWR
10 filename= "/home/soporte/schainv3/schain/schainpy/scripts/config_WR.txt"
11 dict= ReadfileWR(filename).getDict()
12
13 FixRCP_IPP = dict['ipp']*0.15 #equivalencia
14 dataBlocksPerFile= dict['b_f_adq']
15 profilesPerBlock= int(dict['n'])
16 pulsepair = int(dict['n'])
17 #*************************************************************************
18 path = '/home/soporte/Downloads/RAWDATA_PP_C'
19 figpath = path
20 desc = "Simulator Test"
21 controllerObj = Project()
22 controllerObj.setup(id='10',name='Test Simulator',description=desc)
23 readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader',
24 frequency=9.345e9,
25 FixRCP_IPP= FixRCP_IPP,
26 Tau_0 = 30,
27 AcqH0_0=0,
28 samples=330,
29 AcqDH_0=0.15,
30 FixRCP_TXA=0.15,
31 FixRCP_TXB=0.15,
32 Fdoppler=600.0,
33 Hdoppler=36,
34 Adoppler=300,#300
35 delay=0,
36 online=0,
37 walk=0,
38 profilesPerBlock=profilesPerBlock,
39 dataBlocksPerFile=dataBlocksPerFile)#,#nTotalReadFiles=2)
40 #opObj11 = readUnitConfObj.addOperation(name='printInfo')
41 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
42
43 opObj11 = procUnitConfObjA.addOperation(name='PulsePair')
44 opObj11.addParameter(name='n', value=pulsepair, format='int')#10
45
46 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
47
48 opObj10 = procUnitConfObjB.addOperation(name='HDFWriter')
49 opObj10.addParameter(name='path',value=figpath)
50 #opObj10.addParameter(name='mode',value=2)
51 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
52 opObj10.addParameter(name='metadataList',value='utctimeInit,paramInterval,heightList,profileIndex,flagDataAsBlock',format='list')
53 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list'
54
55 controllerObj.start()
@@ -0,0 +1,50
1 import os,sys
2 import datetime
3 import time
4 from schainpy.controller import Project
5 path = '/home/soporte/Downloads/RAWDATA_PP_Z'
6 figpath = path
7 desc = "Simulator Test"
8
9 controllerObj = Project()
10
11 controllerObj.setup(id='10',name='Test Simulator',description=desc)
12
13 readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader',
14 frequency=9.345e9,
15 FixRCP_IPP= 60,
16 Tau_0 = 30,
17 AcqH0_0=0,
18 samples=330,
19 AcqDH_0=0.15,
20 FixRCP_TXA=0.15,
21 FixRCP_TXB=0.15,
22 Fdoppler=600.0,
23 Hdoppler=36,
24 Adoppler=300,#300
25 delay=0,
26 online=0,
27 walk=0,
28 profilesPerBlock=625,
29 dataBlocksPerFile=360)#,#nTotalReadFiles=2)
30
31 ### opObj11 = readUnitConfObj.addOperation(name='printInfo')
32
33 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
34
35 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
36 opObj11.addParameter(name='n', value='625', format='int')#10
37 opObj11.addParameter(name='removeDC', value=1, format='int')
38
39 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
40
41 opObj10 = procUnitConfObjB.addOperation(name="WeatherRadar")
42
43 opObj10 = procUnitConfObjB.addOperation(name='HDFWriter')
44 opObj10.addParameter(name='path',value=figpath)
45 #opObj10.addParameter(name='mode',value=0)
46 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
47 opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list')
48 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH,factor_Zeh,utctime')#,format='list'
49
50 controllerObj.start()
@@ -273,13 +273,13 class JROData(GenericData):
273 '''
273 '''
274 '''
274 '''
275 return self.radarControllerHeaderObj.ippSeconds
275 return self.radarControllerHeaderObj.ippSeconds
276
276
277 @ippSeconds.setter
277 @ippSeconds.setter
278 def ippSeconds(self, ippSeconds):
278 def ippSeconds(self, ippSeconds):
279 '''
279 '''
280 '''
280 '''
281 self.radarControllerHeaderObj.ippSeconds = ippSeconds
281 self.radarControllerHeaderObj.ippSeconds = ippSeconds
282
282
283 @property
283 @property
284 def code(self):
284 def code(self):
285 '''
285 '''
@@ -370,7 +370,7 class Voltage(JROData):
370 self.flagShiftFFT = False
370 self.flagShiftFFT = False
371 self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil
371 self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil
372 self.profileIndex = 0
372 self.profileIndex = 0
373 self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt',
373 self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt',
374 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp']
374 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp']
375
375
376 def getNoisebyHildebrand(self, channel=None):
376 def getNoisebyHildebrand(self, channel=None):
@@ -461,7 +461,7 class Spectra(JROData):
461 self.ippFactor = 1
461 self.ippFactor = 1
462 self.beacon_heiIndexList = []
462 self.beacon_heiIndexList = []
463 self.noise_estimation = None
463 self.noise_estimation = None
464 self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt',
464 self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt',
465 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp','nIncohInt', 'nFFTPoints', 'nProfiles']
465 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp','nIncohInt', 'nFFTPoints', 'nProfiles']
466
466
467 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
467 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
@@ -611,7 +611,7 class Spectra(JROData):
611 print("This property should not be initialized")
611 print("This property should not be initialized")
612
612
613 return
613 return
614
614
615 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
615 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
616
616
617
617
@@ -708,7 +708,7 class Fits(JROData):
708 return self.ipp_sec
708 return self.ipp_sec
709
709
710 noise = property(getNoise, "I'm the 'nHeights' property.")
710 noise = property(getNoise, "I'm the 'nHeights' property.")
711
711
712
712
713 class Correlation(JROData):
713 class Correlation(JROData):
714
714
@@ -966,7 +966,7 class PlotterData(object):
966 '''
966 '''
967
967
968 self.data[tm] = data
968 self.data[tm] = data
969
969
970 for key, value in meta.items():
970 for key, value in meta.items():
971 setattr(self, key, value)
971 setattr(self, key, value)
972
972
@@ -1012,7 +1012,7 class PlotterData(object):
1012 meta['xrange'] = self.roundFloats(self.xrange[2][::dx].tolist())
1012 meta['xrange'] = self.roundFloats(self.xrange[2][::dx].tolist())
1013 else:
1013 else:
1014 data = self.roundFloats(self.data[tm][self.key].tolist())
1014 data = self.roundFloats(self.data[tm][self.key].tolist())
1015
1015
1016 ret = {
1016 ret = {
1017 'plot': plot_name,
1017 'plot': plot_name,
1018 'code': self.exp_code,
1018 'code': self.exp_code,
@@ -252,7 +252,7 class Plot(Operation):
252 self.__throttle_plot = apply_throttle(self.throttle)
252 self.__throttle_plot = apply_throttle(self.throttle)
253 code = self.attr_data if self.attr_data else self.CODE
253 code = self.attr_data if self.attr_data else self.CODE
254 self.data = PlotterData(self.CODE, self.exp_code, self.localtime)
254 self.data = PlotterData(self.CODE, self.exp_code, self.localtime)
255
255
256 if self.server:
256 if self.server:
257 if not self.server.startswith('tcp://'):
257 if not self.server.startswith('tcp://'):
258 self.server = 'tcp://{}'.format(self.server)
258 self.server = 'tcp://{}'.format(self.server)
@@ -271,7 +271,7 class Plot(Operation):
271
271
272 self.setup()
272 self.setup()
273
273
274 self.time_label = 'LT' if self.localtime else 'UTC'
274 self.time_label = 'LT' if self.localtime else 'UTC'
275
275
276 if self.width is None:
276 if self.width is None:
277 self.width = 8
277 self.width = 8
@@ -376,7 +376,7 class Plot(Operation):
376 '''
376 '''
377 Set min and max values, labels, ticks and titles
377 Set min and max values, labels, ticks and titles
378 '''
378 '''
379
379
380 for n, ax in enumerate(self.axes):
380 for n, ax in enumerate(self.axes):
381 if ax.firsttime:
381 if ax.firsttime:
382 if self.xaxis != 'time':
382 if self.xaxis != 'time':
@@ -459,14 +459,14 class Plot(Operation):
459
459
460 self.plot()
460 self.plot()
461 self.format()
461 self.format()
462
462
463 for n, fig in enumerate(self.figures):
463 for n, fig in enumerate(self.figures):
464 if self.nrows == 0 or self.nplots == 0:
464 if self.nrows == 0 or self.nplots == 0:
465 log.warning('No data', self.name)
465 log.warning('No data', self.name)
466 fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center')
466 fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center')
467 fig.canvas.manager.set_window_title(self.CODE)
467 fig.canvas.manager.set_window_title(self.CODE)
468 continue
468 continue
469
469
470 fig.canvas.manager.set_window_title('{} - {}'.format(self.title,
470 fig.canvas.manager.set_window_title('{} - {}'.format(self.title,
471 self.getDateTime(self.data.max_time).strftime('%Y/%m/%d')))
471 self.getDateTime(self.data.max_time).strftime('%Y/%m/%d')))
472 fig.canvas.draw()
472 fig.canvas.draw()
@@ -476,7 +476,7 class Plot(Operation):
476
476
477 if self.save:
477 if self.save:
478 self.save_figure(n)
478 self.save_figure(n)
479
479
480 if self.server:
480 if self.server:
481 self.send_to_server()
481 self.send_to_server()
482
482
@@ -489,33 +489,44 class Plot(Operation):
489 'interval': dataOut.timeInterval,
489 'interval': dataOut.timeInterval,
490 'channels': dataOut.channelList
490 'channels': dataOut.channelList
491 }
491 }
492
492
493 data, meta = self.update(dataOut)
493 data, meta = self.update(dataOut)
494 metadata.update(meta)
494 metadata.update(meta)
495 self.data.update(data, timestamp, metadata)
495 self.data.update(data, timestamp, metadata)
496
496
497 def save_figure(self, n):
497 def save_figure(self, n):
498 '''
498 '''
499 '''
499 '''
500
500 if self.oneFigure:
501 if (self.data.max_time - self.save_time) <= self.save_period:
501 if (self.data.max_time - self.save_time) <= self.save_period:
502 return
502 return
503
503
504 self.save_time = self.data.max_time
504 self.save_time = self.data.max_time
505
505
506 fig = self.figures[n]
506 fig = self.figures[n]
507
508 if self.throttle == 0:
507 if self.throttle == 0:
509 figname = os.path.join(
508 if self.oneFigure:
510 self.save,
509 figname = os.path.join(
511 self.save_code,
510 self.save,
512 '{}_{}.png'.format(
513 self.save_code,
511 self.save_code,
514 self.getDateTime(self.data.max_time).strftime(
512 '{}_{}.png'.format(
515 '%Y%m%d_%H%M%S'
513 self.save_code,
516 ),
514 self.getDateTime(self.data.max_time).strftime(
515 '%Y%m%d_%H%M%S'
516 ),
517 )
518 )
519 else:
520 figname = os.path.join(
521 self.save,
522 self.save_code,
523 '{}_ch{}_{}.png'.format(
524 self.save_code,n,
525 self.getDateTime(self.data.max_time).strftime(
526 '%Y%m%d_%H%M%S'
527 ),
528 )
517 )
529 )
518 )
519 log.log('Saving figure: {}'.format(figname), self.name)
530 log.log('Saving figure: {}'.format(figname), self.name)
520 if not os.path.isdir(os.path.dirname(figname)):
531 if not os.path.isdir(os.path.dirname(figname)):
521 os.makedirs(os.path.dirname(figname))
532 os.makedirs(os.path.dirname(figname))
@@ -530,6 +541,7 class Plot(Operation):
530 ),
541 ),
531 )
542 )
532 )
543 )
544
533 log.log('Saving figure: {}'.format(figname), self.name)
545 log.log('Saving figure: {}'.format(figname), self.name)
534 if not os.path.isdir(os.path.dirname(figname)):
546 if not os.path.isdir(os.path.dirname(figname)):
535 os.makedirs(os.path.dirname(figname))
547 os.makedirs(os.path.dirname(figname))
@@ -541,14 +553,14 class Plot(Operation):
541
553
542 if self.exp_code == None:
554 if self.exp_code == None:
543 log.warning('Missing `exp_code` skipping sending to server...')
555 log.warning('Missing `exp_code` skipping sending to server...')
544
556
545 last_time = self.data.max_time
557 last_time = self.data.max_time
546 interval = last_time - self.sender_time
558 interval = last_time - self.sender_time
547 if interval < self.sender_period:
559 if interval < self.sender_period:
548 return
560 return
549
561
550 self.sender_time = last_time
562 self.sender_time = last_time
551
563
552 attrs = ['titles', 'zmin', 'zmax', 'tag', 'ymin', 'ymax']
564 attrs = ['titles', 'zmin', 'zmax', 'tag', 'ymin', 'ymax']
553 for attr in attrs:
565 for attr in attrs:
554 value = getattr(self, attr)
566 value = getattr(self, attr)
@@ -565,7 +577,7 class Plot(Operation):
565 self.data.meta['interval'] = int(interval)
577 self.data.meta['interval'] = int(interval)
566
578
567 self.sender_queue.append(last_time)
579 self.sender_queue.append(last_time)
568
580
569 while True:
581 while True:
570 try:
582 try:
571 tm = self.sender_queue.popleft()
583 tm = self.sender_queue.popleft()
@@ -604,7 +616,7 class Plot(Operation):
604 self.ncols: number of cols
616 self.ncols: number of cols
605 self.nplots: number of plots (channels or pairs)
617 self.nplots: number of plots (channels or pairs)
606 self.ylabel: label for Y axes
618 self.ylabel: label for Y axes
607 self.titles: list of axes title
619 self.titles: list of axes title
608
620
609 '''
621 '''
610 raise NotImplementedError
622 raise NotImplementedError
@@ -619,14 +631,14 class Plot(Operation):
619 '''
631 '''
620 Must be defined in the child class, update self.data with new data
632 Must be defined in the child class, update self.data with new data
621 '''
633 '''
622
634
623 data = {
635 data = {
624 self.CODE: getattr(dataOut, 'data_{}'.format(self.CODE))
636 self.CODE: getattr(dataOut, 'data_{}'.format(self.CODE))
625 }
637 }
626 meta = {}
638 meta = {}
627
639
628 return data, meta
640 return data, meta
629
641
630 def run(self, dataOut, **kwargs):
642 def run(self, dataOut, **kwargs):
631 '''
643 '''
632 Main plotting routine
644 Main plotting routine
@@ -650,7 +662,7 class Plot(Operation):
650 self.poll.register(self.socket, zmq.POLLIN)
662 self.poll.register(self.socket, zmq.POLLIN)
651
663
652 tm = getattr(dataOut, self.attr_time)
664 tm = getattr(dataOut, self.attr_time)
653
665
654 if self.data and 'time' in self.xaxis and (tm - self.tmin) >= self.xrange*60*60:
666 if self.data and 'time' in self.xaxis and (tm - self.tmin) >= self.xrange*60*60:
655 self.save_time = tm
667 self.save_time = tm
656 self.__plot()
668 self.__plot()
@@ -667,7 +679,7 class Plot(Operation):
667 dt = self.getDateTime(tm)
679 dt = self.getDateTime(tm)
668 if self.xmin is None:
680 if self.xmin is None:
669 self.tmin = tm
681 self.tmin = tm
670 self.xmin = dt.hour
682 self.xmin = dt.hour
671 minutes = (self.xmin-int(self.xmin)) * 60
683 minutes = (self.xmin-int(self.xmin)) * 60
672 seconds = (minutes - int(minutes)) * 60
684 seconds = (minutes - int(minutes)) * 60
673 self.tmin = (dt.replace(hour=int(self.xmin), minute=int(minutes), second=int(seconds)) -
685 self.tmin = (dt.replace(hour=int(self.xmin), minute=int(minutes), second=int(seconds)) -
@@ -690,4 +702,3 class Plot(Operation):
690 self.__plot()
702 self.__plot()
691 if self.data and not self.data.flagNoData and self.pause:
703 if self.data and not self.data.flagNoData and self.pause:
692 figpause(10)
704 figpause(10)
693
@@ -33,14 +33,16 class SpectraHeisPlot(Plot):
33 meta = {}
33 meta = {}
34 spc = 10*numpy.log10(dataOut.data_spc / dataOut.normFactor)
34 spc = 10*numpy.log10(dataOut.data_spc / dataOut.normFactor)
35 data['spc_heis'] = spc
35 data['spc_heis'] = spc
36
36
37 return data, meta
37 return data, meta
38
38
39 def plot(self):
39 def plot(self):
40
40
41 c = 3E8
41 c = 3E8
42 deltaHeight = self.data.yrange[1] - self.data.yrange[0]
42 deltaHeight = self.data.yrange[1] - self.data.yrange[0]
43 x = numpy.arange(-1*len(self.data.yrange)/2., len(self.data.yrange)/2.)*(c/(2*deltaHeight*len(self.data.yrange)*1000))
43 x = numpy.arange(-1*len(self.data.yrange)/2., len(self.data.yrange)/2.)*(c/(2*deltaHeight*len(self.data.yrange)*1000))
44 #x = (1/1000.0)*numpy.arange(-1*len(self.data.yrange)/2., len(self.data.yrange)/2.)*(c/(2*deltaHeight*len(self.data.yrange)*1000))
45
44 self.y = self.data[-1]['spc_heis']
46 self.y = self.data[-1]['spc_heis']
45 self.titles = []
47 self.titles = []
46
48
@@ -80,8 +82,8 class RTIHeisPlot(Plot):
80 spc = dataOut.data_spc / dataOut.normFactor
82 spc = dataOut.data_spc / dataOut.normFactor
81 spc = 10*numpy.log10(numpy.average(spc, axis=1))
83 spc = 10*numpy.log10(numpy.average(spc, axis=1))
82 data['rti_heis'] = spc
84 data['rti_heis'] = spc
83
85
84 return data, meta
86 return data, meta
85
87
86 def plot(self):
88 def plot(self):
87
89
@@ -5,6 +5,8 import numpy
5 from schainpy.model.graphics.jroplot_base import Plot, plt
5 from schainpy.model.graphics.jroplot_base import Plot, plt
6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot
6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot
7 from schainpy.utils import log
7 from schainpy.utils import log
8 # libreria wradlib
9 import wradlib as wrl
8
10
9 EARTH_RADIUS = 6.3710e3
11 EARTH_RADIUS = 6.3710e3
10
12
@@ -63,7 +65,7 class SnrPlot(RTIPlot):
63 def update(self, dataOut):
65 def update(self, dataOut):
64
66
65 data = {
67 data = {
66 'snr': 10*numpy.log10(dataOut.data_snr)
68 'snr': 10*numpy.log10(dataOut.data_snr)
67 }
69 }
68
70
69 return data, {}
71 return data, {}
@@ -79,7 +81,7 class DopplerPlot(RTIPlot):
79 def update(self, dataOut):
81 def update(self, dataOut):
80
82
81 data = {
83 data = {
82 'dop': 10*numpy.log10(dataOut.data_dop)
84 'dop': 10*numpy.log10(dataOut.data_dop)
83 }
85 }
84
86
85 return data, {}
87 return data, {}
@@ -95,7 +97,7 class PowerPlot(RTIPlot):
95 def update(self, dataOut):
97 def update(self, dataOut):
96
98
97 data = {
99 data = {
98 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor)
100 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor)
99 }
101 }
100
102
101 return data, {}
103 return data, {}
@@ -179,7 +181,7 class GenericRTIPlot(Plot):
179 self.nrows = self.data.shape('param')[0]
181 self.nrows = self.data.shape('param')[0]
180 self.nplots = self.nrows
182 self.nplots = self.nrows
181 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
183 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
182
184
183 if not self.xlabel:
185 if not self.xlabel:
184 self.xlabel = 'Time'
186 self.xlabel = 'Time'
185
187
@@ -196,7 +198,7 class GenericRTIPlot(Plot):
196 meta = {}
198 meta = {}
197
199
198 return data, meta
200 return data, meta
199
201
200 def plot(self):
202 def plot(self):
201 # self.data.normalize_heights()
203 # self.data.normalize_heights()
202 self.x = self.data.times
204 self.x = self.data.times
@@ -368,3 +370,216 class PolarMapPlot(Plot):
368 self.titles = ['{} {}'.format(
370 self.titles = ['{} {}'.format(
369 self.data.parameters[x], title) for x in self.channels]
371 self.data.parameters[x], title) for x in self.channels]
370
372
373 class WeatherPlot(Plot):
374 CODE = 'weather'
375 plot_name = 'weather'
376 plot_type = 'ppistyle'
377 buffering = False
378
379 def setup(self):
380 self.ncols = 1
381 self.nrows = 1
382 self.nplots= 1
383 self.ylabel= 'Range [Km]'
384 self.titles= ['Weather']
385 self.colorbar=False
386 self.width =8
387 self.height =8
388 self.ini =0
389 self.len_azi =0
390 self.buffer_ini = None
391 self.buffer_azi = None
392 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
393 self.flag =0
394 self.indicador= 0
395
396 def update(self, dataOut):
397
398 data = {}
399 meta = {}
400 data['weather'] = 10*numpy.log10(dataOut.data_360[0]/(650**2))
401 data['azi'] = dataOut.data_azi
402
403 return data, meta
404
405 def plot(self):
406 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1])
407
408 data = self.data[-1]
409 tmp_h = (data['weather'].shape[1])/10.0
410 stoprange = float(tmp_h*1.5)#stoprange = float(33*1.5) por ahora 400
411 rangestep = float(0.15)
412 r = numpy.arange(0, stoprange, rangestep)
413 self.y = 2*r
414
415 tmp_v = data['weather']
416 print("tmp_v",tmp_v.shape)
417 tmp_z = data['azi']
418 #print("tmp_z",tmp_z.shape)
419 res = 1
420 step = (360/(res*tmp_v.shape[0]))
421 print("step",step)
422 mode = 1
423 if mode==0:
424 #print("self.ini",self.ini)
425 val = numpy.mean(tmp_v[:,0])
426 self.len_azi = len(tmp_z)
427 ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val
428 self.buffer_ini = numpy.vstack((tmp_v,ones))
429
430 n = ((360/res)-len(tmp_z))
431 start = tmp_z[-1]+res
432 end = tmp_z[0]-res
433 if start>end:
434 end = end+360
435 azi_zeros = numpy.linspace(start,end,int(n))
436 azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros)
437 self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros))
438 self.ini = self.ini+1
439
440 if mode==1:
441 #print("self.ini",self.ini)
442 if self.ini==0:
443 res = 1
444 step = (360/(res*tmp_v.shape[0]))
445 val = numpy.mean(tmp_v[:,0])
446 self.len_azi = len(tmp_z)
447 self.buf_tmp = tmp_v
448 ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val
449 self.buffer_ini = numpy.vstack((tmp_v,ones))
450
451 n = ((360/res)-len(tmp_z))
452 start = tmp_z[-1]+res
453 end = tmp_z[0]-res
454 if start>end:
455 end =end+360
456 azi_zeros = numpy.linspace(start,end,int(n))
457 azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros)
458 self.buf_azi = tmp_z
459 self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros))
460 self.ini = self.ini+1
461 elif 0<self.ini<step:
462 '''
463 if self.ini>31:
464 start= tmp_z[0]
465 end =tmp_z[-1]
466 print("start","end",start,end)
467 if self.ini==32:
468 tmp_v=tmp_v+20
469 if self.ini==33:
470 tmp_v=tmp_v+10
471 if self.ini==34:
472 tmp_v=tmp_v+20
473 if self.ini==35:
474 tmp_v=tmp_v+20
475 '''
476 self.buf_tmp= numpy.vstack((self.buf_tmp,tmp_v))
477 print("ERROR_INMINENTE",self.buf_tmp.shape)
478 if self.buf_tmp.shape[0]==360:
479 self.buffer_ini=self.buf_tmp
480 else:
481 val=30.0
482 ones = numpy.ones([(360-self.buf_tmp.shape[0]),self.buf_tmp.shape[1]])*val
483 self.buffer_ini = numpy.vstack((self.buf_tmp,ones))
484
485 self.buf_azi = numpy.hstack((self.buf_azi,tmp_z))
486 n = ((360/res)-len(self.buf_azi))
487 if n==0:
488 self.buffer_ini_azi = self.buf_azi
489 else:
490 start = self.buf_azi[-1]+res
491 end = self.buf_azi[0]-res
492 if start>end:
493 end =end+360
494 azi_zeros = numpy.linspace(start,end,int(n))
495 azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros)
496 if tmp_z[0]<self.buf_azi[0] <tmp_z[-1]:
497 self.indicador=1
498 if self.indicador==1:
499 azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res)
500 # self.indicador = True
501 #if self.indicador==True:
502 # azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res)
503
504 #self.buf_azi = tmp_z
505 self.buffer_ini_azi = numpy.hstack((self.buf_azi,azi_zeros))
506
507 if self.ini==step-1:
508 start= tmp_z[0]
509 end = tmp_z[-1]
510 #print("start","end",start,end)
511 ###print(self.buffer_ini_azi[:80])
512 self.ini = self.ini+1
513
514 else:
515 step = (360/(res*tmp_v.shape[0]))
516 tmp_v=tmp_v+5+(self.ini-step)*1
517
518 start= tmp_z[0]
519 end = tmp_z[-1]
520 #print("start","end",start,end)
521 ###print(self.buffer_ini_azi[:120])
522
523 if step>=2:
524 if self.flag<step-1:
525 limit_i=self.buf_azi[len(tmp_z)*(self.flag+1)]
526 limit_s=self.buf_azi[len(tmp_z)*(self.flag+2)-1]
527 print("flag",self.flag,limit_i,limit_s)
528 if limit_i< tmp_z[-1]< limit_s:
529 index_i=int(numpy.where(tmp_z<=self.buf_azi[len(tmp_z)*(self.flag+1)])[0][-1])
530 tmp_r =int(numpy.where(self.buf_azi[(self.flag+1)*len(tmp_z):(self.flag+2)*len(tmp_z)]>=tmp_z[-1])[0][0])
531 print("tmp_r",tmp_r)
532 index_f=(self.flag+1)*len(tmp_z)+tmp_r
533
534 if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]):
535 final = len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f])
536 else:
537 final= len(tmp_z[index_i:])
538 self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[index_i:index_i+final]
539 self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[index_i:index_i+final,:]
540 if limit_i<tmp_z[0]<limit_s:
541 index_f =int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0])
542 n_p =index_f-len(tmp_z)*(self.flag+1)
543 if n_p>0:
544 self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[-1]*numpy.ones(n_p)
545 self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[-1,:]*numpy.ones([n_p,tmp_v.shape[1]])
546
547 '''
548 if self.buf_azi[len(tmp_z)]<tmp_z[-1]<self.buf_azi[2*len(tmp_z)-1]:
549 index_i= int(numpy.where(tmp_z <= self.buf_azi[len(tmp_z)])[0][-1])
550 index_f= int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0])
551 #print("index",index_i,index_f)
552 if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z):index_f]):
553 final = len(self.buf_azi[len(tmp_z):index_f])
554 else:
555 final = len(tmp_z[index_i:])
556 self.buf_azi[len(tmp_z):index_f]=tmp_z[index_i:index_i+final]
557 self.buf_tmp[len(tmp_z):index_f,:]=tmp_v[index_i:index_i+final,:]
558 '''
559 self.buf_tmp[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1),:]=tmp_v
560 self.buf_azi[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1)] = tmp_z
561 self.buffer_ini=self.buf_tmp
562 self.buffer_ini_azi = self.buf_azi
563 ##print("--------salida------------")
564 start= tmp_z[0]
565 end = tmp_z[-1]
566 ##print("start","end",start,end)
567 ##print(self.buffer_ini_azi[:120])
568 self.ini= self.ini+1
569 self.flag = self.flag +1
570 if self.flag==step:
571 self.flag=0
572
573 for i,ax in enumerate(self.axes):
574 if ax.firsttime:
575 plt.clf()
576 cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=30, vmax=70)
577 else:
578 plt.clf()
579 cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=30, vmax=70)
580 caax = cgax.parasites[0]
581 paax = cgax.parasites[1]
582 cbar = plt.gcf().colorbar(pm, pad=0.075)
583 caax.set_xlabel('x_range [km]')
584 caax.set_ylabel('y_range [km]')
585 plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime), transform=caax.transAxes, va='bottom',ha='right')
@@ -44,7 +44,7 class SpectraPlot(Plot):
44 data['rti'] = dataOut.getPower()
44 data['rti'] = dataOut.getPower()
45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
45 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
46 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
47
47
48 if self.CODE == 'spc_moments':
48 if self.CODE == 'spc_moments':
49 data['moments'] = dataOut.moments
49 data['moments'] = dataOut.moments
50 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
50 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
@@ -53,8 +53,8 class SpectraPlot(Plot):
53 data['gaussfit'] = dataOut.DGauFitParams
53 data['gaussfit'] = dataOut.DGauFitParams
54 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
54 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
55
55
56 return data, meta
56 return data, meta
57
57
58 def plot(self):
58 def plot(self):
59 if self.xaxis == "frequency":
59 if self.xaxis == "frequency":
60 x = self.data.xrange[0]
60 x = self.data.xrange[0]
@@ -82,7 +82,7 class SpectraPlot(Plot):
82 noise = data['noise'][n]
82 noise = data['noise'][n]
83 if self.CODE == 'spc_moments':
83 if self.CODE == 'spc_moments':
84 mean = data['moments'][n, 1]
84 mean = data['moments'][n, 1]
85 if self.CODE == 'gaussian_fit':
85 if self.CODE == 'gaussian_fit':
86 # mean = data['moments'][n, 1]
86 # mean = data['moments'][n, 1]
87 gau0 = data['gaussfit'][n][2,:,0]
87 gau0 = data['gaussfit'][n][2,:,0]
88 gau1 = data['gaussfit'][n][2,:,1]
88 gau1 = data['gaussfit'][n][2,:,1]
@@ -164,8 +164,8 class CrossSpectraPlot(Plot):
164
164
165 data['cspc'] = numpy.array(tmp)
165 data['cspc'] = numpy.array(tmp)
166
166
167 return data, meta
167 return data, meta
168
168
169 def plot(self):
169 def plot(self):
170
170
171 if self.xaxis == "frequency":
171 if self.xaxis == "frequency":
@@ -177,7 +177,7 class CrossSpectraPlot(Plot):
177 else:
177 else:
178 x = self.data.xrange[2]
178 x = self.data.xrange[2]
179 self.xlabel = "Velocity (m/s)"
179 self.xlabel = "Velocity (m/s)"
180
180
181 self.titles = []
181 self.titles = []
182
182
183 y = self.data.yrange
183 y = self.data.yrange
@@ -201,13 +201,13 class CrossSpectraPlot(Plot):
201 ax.plt.set_array(coh.T.ravel())
201 ax.plt.set_array(coh.T.ravel())
202 self.titles.append(
202 self.titles.append(
203 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
203 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
204
204
205 ax = self.axes[2 * n + 1]
205 ax = self.axes[2 * n + 1]
206 if ax.firsttime:
206 if ax.firsttime:
207 ax.plt = ax.pcolormesh(x, y, phase.T,
207 ax.plt = ax.pcolormesh(x, y, phase.T,
208 vmin=-180,
208 vmin=-180,
209 vmax=180,
209 vmax=180,
210 cmap=plt.get_cmap(self.colormap_phase)
210 cmap=plt.get_cmap(self.colormap_phase)
211 )
211 )
212 else:
212 else:
213 ax.plt.set_array(phase.T.ravel())
213 ax.plt.set_array(phase.T.ravel())
@@ -226,6 +226,7 class RTIPlot(Plot):
226 def setup(self):
226 def setup(self):
227 self.xaxis = 'time'
227 self.xaxis = 'time'
228 self.ncols = 1
228 self.ncols = 1
229 print("ch",self.data.channels)
229 self.nrows = len(self.data.channels)
230 self.nrows = len(self.data.channels)
230 self.nplots = len(self.data.channels)
231 self.nplots = len(self.data.channels)
231 self.ylabel = 'Range [km]'
232 self.ylabel = 'Range [km]'
@@ -266,6 +267,7 class RTIPlot(Plot):
266 cmap=plt.get_cmap(self.colormap)
267 cmap=plt.get_cmap(self.colormap)
267 )
268 )
268 if self.showprofile:
269 if self.showprofile:
270 print("test-------------------------------------1")
269 ax.plot_profile = self.pf_axes[n].plot(
271 ax.plot_profile = self.pf_axes[n].plot(
270 data['rti'][n], self.y)[0]
272 data['rti'][n], self.y)[0]
271 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y,
273 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y,
@@ -335,7 +337,7 class PhasePlot(CoherencePlot):
335
337
336 class NoisePlot(Plot):
338 class NoisePlot(Plot):
337 '''
339 '''
338 Plot for noise
340 Plot for noise
339 '''
341 '''
340
342
341 CODE = 'noise'
343 CODE = 'noise'
@@ -380,7 +382,7 class NoisePlot(Plot):
380 y = Y[ch]
382 y = Y[ch]
381 self.axes[0].lines[ch].set_data(x, y)
383 self.axes[0].lines[ch].set_data(x, y)
382
384
383
385
384 class PowerProfilePlot(Plot):
386 class PowerProfilePlot(Plot):
385
387
386 CODE = 'pow_profile'
388 CODE = 'pow_profile'
@@ -412,10 +414,10 class PowerProfilePlot(Plot):
412 self.y = y
414 self.y = y
413
415
414 x = self.data[-1][self.CODE]
416 x = self.data[-1][self.CODE]
415
417
416 if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9
418 if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9
417 if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1
419 if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1
418
420
419 if self.axes[0].firsttime:
421 if self.axes[0].firsttime:
420 for ch in self.data.channels:
422 for ch in self.data.channels:
421 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
423 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
@@ -464,7 +466,7 class SpectraCutPlot(Plot):
464 else:
466 else:
465 x = self.data.xrange[2][:-1]
467 x = self.data.xrange[2][:-1]
466 self.xlabel = "Velocity (m/s)"
468 self.xlabel = "Velocity (m/s)"
467
469
468 if self.CODE == 'cut_gaussian_fit':
470 if self.CODE == 'cut_gaussian_fit':
469 x = self.data.xrange[2][:-1]
471 x = self.data.xrange[2][:-1]
470 self.xlabel = "Velocity (m/s)"
472 self.xlabel = "Velocity (m/s)"
@@ -481,7 +483,7 class SpectraCutPlot(Plot):
481 index = numpy.arange(0, len(y), int((len(y))/9))
483 index = numpy.arange(0, len(y), int((len(y))/9))
482
484
483 for n, ax in enumerate(self.axes):
485 for n, ax in enumerate(self.axes):
484 if self.CODE == 'cut_gaussian_fit':
486 if self.CODE == 'cut_gaussian_fit':
485 gau0 = data['gauss_fit0']
487 gau0 = data['gauss_fit0']
486 gau1 = data['gauss_fit1']
488 gau1 = data['gauss_fit1']
487 if ax.firsttime:
489 if ax.firsttime:
@@ -493,10 +495,10 class SpectraCutPlot(Plot):
493 if self.CODE == 'cut_gaussian_fit':
495 if self.CODE == 'cut_gaussian_fit':
494 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
496 ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.')
495 for i, line in enumerate(ax.plt_gau0):
497 for i, line in enumerate(ax.plt_gau0):
496 line.set_color(ax.plt[i].get_color())
498 line.set_color(ax.plt[i].get_color())
497 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
499 ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--')
498 for i, line in enumerate(ax.plt_gau1):
500 for i, line in enumerate(ax.plt_gau1):
499 line.set_color(ax.plt[i].get_color())
501 line.set_color(ax.plt[i].get_color())
500 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
502 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
501 self.figures[0].legend(ax.plt, labels, loc='center right')
503 self.figures[0].legend(ax.plt, labels, loc='center right')
502 else:
504 else:
@@ -600,7 +602,7 class BeaconPhase(Plot):
600 server=None, folder=None, username=None, password=None,
602 server=None, folder=None, username=None, password=None,
601 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
603 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
602
604
603 if dataOut.flagNoData:
605 if dataOut.flagNoData:
604 return dataOut
606 return dataOut
605
607
606 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
608 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
@@ -740,4 +742,4 class BeaconPhase(Plot):
740 thisDatetime=thisDatetime,
742 thisDatetime=thisDatetime,
741 update_figfile=update_figfile)
743 update_figfile=update_figfile)
742
744
743 return dataOut No newline at end of file
745 return dataOut
@@ -384,7 +384,7 def isRadarFolder(folder):
384
384
385
385
386 def isRadarFile(file):
386 def isRadarFile(file):
387 try:
387 try:
388 year = int(file[1:5])
388 year = int(file[1:5])
389 doy = int(file[5:8])
389 doy = int(file[5:8])
390 set = int(file[8:11])
390 set = int(file[8:11])
@@ -395,10 +395,10 def isRadarFile(file):
395
395
396
396
397 def getDateFromRadarFile(file):
397 def getDateFromRadarFile(file):
398 try:
398 try:
399 year = int(file[1:5])
399 year = int(file[1:5])
400 doy = int(file[5:8])
400 doy = int(file[5:8])
401 set = int(file[8:11])
401 set = int(file[8:11])
402 except:
402 except:
403 return None
403 return None
404
404
@@ -417,7 +417,7 def getDateFromRadarFolder(folder):
417 return thisDate
417 return thisDate
418
418
419 def parse_format(s, fmt):
419 def parse_format(s, fmt):
420
420
421 for i in range(fmt.count('%')):
421 for i in range(fmt.count('%')):
422 x = fmt.index('%')
422 x = fmt.index('%')
423 d = DT_DIRECTIVES[fmt[x:x+2]]
423 d = DT_DIRECTIVES[fmt[x:x+2]]
@@ -484,7 +484,7 class Reader(object):
484
484
485 def run(self):
485 def run(self):
486
486
487 raise NotImplementedError
487 raise NotImplementedError
488
488
489 def getAllowedArgs(self):
489 def getAllowedArgs(self):
490 if hasattr(self, '__attrs__'):
490 if hasattr(self, '__attrs__'):
@@ -496,19 +496,19 class Reader(object):
496
496
497 for key, value in kwargs.items():
497 for key, value in kwargs.items():
498 setattr(self, key, value)
498 setattr(self, key, value)
499
499
500 def find_folders(self, path, startDate, endDate, folderfmt, last=False):
500 def find_folders(self, path, startDate, endDate, folderfmt, last=False):
501
501
502 folders = [x for f in path.split(',')
502 folders = [x for f in path.split(',')
503 for x in os.listdir(f) if os.path.isdir(os.path.join(f, x))]
503 for x in os.listdir(f) if os.path.isdir(os.path.join(f, x))]
504 folders.sort()
504 folders.sort()
505
505
506 if last:
506 if last:
507 folders = [folders[-1]]
507 folders = [folders[-1]]
508
508
509 for folder in folders:
509 for folder in folders:
510 try:
510 try:
511 dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date()
511 dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date()
512 if dt >= startDate and dt <= endDate:
512 if dt >= startDate and dt <= endDate:
513 yield os.path.join(path, folder)
513 yield os.path.join(path, folder)
514 else:
514 else:
@@ -517,38 +517,38 class Reader(object):
517 log.log('Skiping folder {}'.format(folder), self.name)
517 log.log('Skiping folder {}'.format(folder), self.name)
518 continue
518 continue
519 return
519 return
520
520
521 def find_files(self, folders, ext, filefmt, startDate=None, endDate=None,
521 def find_files(self, folders, ext, filefmt, startDate=None, endDate=None,
522 expLabel='', last=False):
522 expLabel='', last=False):
523
523
524 for path in folders:
524 for path in folders:
525 files = glob.glob1(path, '*{}'.format(ext))
525 files = glob.glob1(path, '*{}'.format(ext))
526 files.sort()
526 files.sort()
527 if last:
527 if last:
528 if files:
528 if files:
529 fo = files[-1]
529 fo = files[-1]
530 try:
530 try:
531 dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date()
531 dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date()
532 yield os.path.join(path, expLabel, fo)
532 yield os.path.join(path, expLabel, fo)
533 except Exception as e:
533 except Exception as e:
534 pass
534 pass
535 return
535 return
536 else:
536 else:
537 return
537 return
538
538
539 for fo in files:
539 for fo in files:
540 try:
540 try:
541 dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date()
541 dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date()
542 if dt >= startDate and dt <= endDate:
542 if dt >= startDate and dt <= endDate:
543 yield os.path.join(path, expLabel, fo)
543 yield os.path.join(path, expLabel, fo)
544 else:
544 else:
545 log.log('Skiping file {}'.format(fo), self.name)
545 log.log('Skiping file {}'.format(fo), self.name)
546 except Exception as e:
546 except Exception as e:
547 log.log('Skiping file {}'.format(fo), self.name)
547 log.log('Skiping file {}'.format(fo), self.name)
548 continue
548 continue
549
549
550 def searchFilesOffLine(self, path, startDate, endDate,
550 def searchFilesOffLine(self, path, startDate, endDate,
551 expLabel, ext, walk,
551 expLabel, ext, walk,
552 filefmt, folderfmt):
552 filefmt, folderfmt):
553 """Search files in offline mode for the given arguments
553 """Search files in offline mode for the given arguments
554
554
@@ -561,12 +561,12 class Reader(object):
561 path, startDate, endDate, folderfmt)
561 path, startDate, endDate, folderfmt)
562 else:
562 else:
563 folders = path.split(',')
563 folders = path.split(',')
564
564
565 return self.find_files(
565 return self.find_files(
566 folders, ext, filefmt, startDate, endDate, expLabel)
566 folders, ext, filefmt, startDate, endDate, expLabel)
567
567
568 def searchFilesOnLine(self, path, startDate, endDate,
568 def searchFilesOnLine(self, path, startDate, endDate,
569 expLabel, ext, walk,
569 expLabel, ext, walk,
570 filefmt, folderfmt):
570 filefmt, folderfmt):
571 """Search for the last file of the last folder
571 """Search for the last file of the last folder
572
572
@@ -579,13 +579,13 class Reader(object):
579 Return:
579 Return:
580 generator with the full path of last filename
580 generator with the full path of last filename
581 """
581 """
582
582
583 if walk:
583 if walk:
584 folders = self.find_folders(
584 folders = self.find_folders(
585 path, startDate, endDate, folderfmt, last=True)
585 path, startDate, endDate, folderfmt, last=True)
586 else:
586 else:
587 folders = path.split(',')
587 folders = path.split(',')
588
588
589 return self.find_files(
589 return self.find_files(
590 folders, ext, filefmt, startDate, endDate, expLabel, last=True)
590 folders, ext, filefmt, startDate, endDate, expLabel, last=True)
591
591
@@ -594,13 +594,13 class Reader(object):
594
594
595 while True:
595 while True:
596 if self.fp != None:
596 if self.fp != None:
597 self.fp.close()
597 self.fp.close()
598
598
599 if self.online:
599 if self.online:
600 newFile = self.setNextFileOnline()
600 newFile = self.setNextFileOnline()
601 else:
601 else:
602 newFile = self.setNextFileOffline()
602 newFile = self.setNextFileOffline()
603
603
604 if not(newFile):
604 if not(newFile):
605 if self.online:
605 if self.online:
606 raise schainpy.admin.SchainError('Time to wait for new files reach')
606 raise schainpy.admin.SchainError('Time to wait for new files reach')
@@ -609,10 +609,10 class Reader(object):
609 raise schainpy.admin.SchainWarning('No files found in the given path')
609 raise schainpy.admin.SchainWarning('No files found in the given path')
610 else:
610 else:
611 raise schainpy.admin.SchainWarning('No more files to read')
611 raise schainpy.admin.SchainWarning('No more files to read')
612
612
613 if self.verifyFile(self.filename):
613 if self.verifyFile(self.filename):
614 break
614 break
615
615
616 log.log('Opening file: %s' % self.filename, self.name)
616 log.log('Opening file: %s' % self.filename, self.name)
617
617
618 self.readFirstHeader()
618 self.readFirstHeader()
@@ -625,7 +625,7 class Reader(object):
625 self.filename
625 self.filename
626 self.fp
626 self.fp
627 self.filesize
627 self.filesize
628
628
629 Return:
629 Return:
630 boolean
630 boolean
631
631
@@ -633,7 +633,7 class Reader(object):
633 nextFile = True
633 nextFile = True
634 nextDay = False
634 nextDay = False
635
635
636 for nFiles in range(self.nFiles+1):
636 for nFiles in range(self.nFiles+1):
637 for nTries in range(self.nTries):
637 for nTries in range(self.nTries):
638 fullfilename, filename = self.checkForRealPath(nextFile, nextDay)
638 fullfilename, filename = self.checkForRealPath(nextFile, nextDay)
639 if fullfilename is not None:
639 if fullfilename is not None:
@@ -643,18 +643,18 class Reader(object):
643 self.name)
643 self.name)
644 time.sleep(self.delay)
644 time.sleep(self.delay)
645 nextFile = False
645 nextFile = False
646 continue
646 continue
647
647
648 if fullfilename is not None:
648 if fullfilename is not None:
649 break
649 break
650
650
651 self.nTries = 1
651 self.nTries = 1
652 nextFile = True
652 nextFile = True
653
653
654 if nFiles == (self.nFiles - 1):
654 if nFiles == (self.nFiles - 1):
655 log.log('Trying with next day...', self.name)
655 log.log('Trying with next day...', self.name)
656 nextDay = True
656 nextDay = True
657 self.nTries = 3
657 self.nTries = 3
658
658
659 if fullfilename:
659 if fullfilename:
660 self.fileSize = os.path.getsize(fullfilename)
660 self.fileSize = os.path.getsize(fullfilename)
@@ -666,18 +666,18 class Reader(object):
666 self.flagNoMoreFiles = 0
666 self.flagNoMoreFiles = 0
667 self.fileIndex += 1
667 self.fileIndex += 1
668 return 1
668 return 1
669 else:
669 else:
670 return 0
670 return 0
671
671
672 def setNextFileOffline(self):
672 def setNextFileOffline(self):
673 """Open the next file to be readed in offline mode"""
673 """Open the next file to be readed in offline mode"""
674
674
675 try:
675 try:
676 filename = next(self.filenameList)
676 filename = next(self.filenameList)
677 self.fileIndex +=1
677 self.fileIndex +=1
678 except StopIteration:
678 except StopIteration:
679 self.flagNoMoreFiles = 1
679 self.flagNoMoreFiles = 1
680 return 0
680 return 0
681
681
682 self.filename = filename
682 self.filename = filename
683 self.fileSize = os.path.getsize(filename)
683 self.fileSize = os.path.getsize(filename)
@@ -685,22 +685,22 class Reader(object):
685 self.flagIsNewFile = 1
685 self.flagIsNewFile = 1
686
686
687 return 1
687 return 1
688
688
689 @staticmethod
689 @staticmethod
690 def isDateTimeInRange(dt, startDate, endDate, startTime, endTime):
690 def isDateTimeInRange(dt, startDate, endDate, startTime, endTime):
691 """Check if the given datetime is in range"""
691 """Check if the given datetime is in range"""
692
692
693 if startDate <= dt.date() <= endDate:
693 if startDate <= dt.date() <= endDate:
694 if startTime <= dt.time() <= endTime:
694 if startTime <= dt.time() <= endTime:
695 return True
695 return True
696 return False
696 return False
697
697
698 def verifyFile(self, filename):
698 def verifyFile(self, filename):
699 """Check for a valid file
699 """Check for a valid file
700
700
701 Arguments:
701 Arguments:
702 filename -- full path filename
702 filename -- full path filename
703
703
704 Return:
704 Return:
705 boolean
705 boolean
706 """
706 """
@@ -709,9 +709,43 class Reader(object):
709
709
710 def checkForRealPath(self, nextFile, nextDay):
710 def checkForRealPath(self, nextFile, nextDay):
711 """Check if the next file to be readed exists"""
711 """Check if the next file to be readed exists"""
712 if nextFile:
713 self.set += 1
714 if nextDay:
715 self.set = 0
716 self.doy += 1
717 foldercounter = 0
718 prefixDirList = [None, 'd', 'D']
719 if self.ext.lower() == ".r": # voltage
720 prefixFileList = ['d', 'D']
721 elif self.ext.lower() == ".pdata": # spectra
722 prefixFileList = ['p', 'P']
723 elif self.ext.lower() == ".hdf5": # HDF5
724 prefixFileList = ['D', 'P'] # HDF5
725
726 # barrido por las combinaciones posibles
727 for prefixDir in prefixDirList:
728 thispath = self.path
729 if prefixDir != None:
730 # formo el nombre del directorio xYYYYDDD (x=d o x=D)
731 if foldercounter == 0:
732 thispath = os.path.join(self.path, "%s%04d%03d" %
733 (prefixDir, self.year, self.doy))
734 else:
735 thispath = os.path.join(self.path, "%s%04d%03d_%02d" % (
736 prefixDir, self.year, self.doy, foldercounter))
737 for prefixFile in prefixFileList: # barrido por las dos combinaciones posibles de "D"
738 # formo el nombre del file xYYYYDDDSSS.ext
739 filename = "%s%04d%03d%03d%s" % (prefixFile, self.year, self.doy, self.set, self.ext)
740 fullfilename = os.path.join(
741 thispath, filename)
742
743 if os.path.exists(fullfilename):
744 return fullfilename, filename
745
746 return None, filename
747 #raise NotImplementedError
712
748
713 raise NotImplementedError
714
715 def readFirstHeader(self):
749 def readFirstHeader(self):
716 """Parse the file header"""
750 """Parse the file header"""
717
751
@@ -783,8 +817,8 class JRODataReader(Reader):
783 Return:
817 Return:
784 str -- fullpath of the file
818 str -- fullpath of the file
785 """
819 """
786
820
787
821
788 if nextFile:
822 if nextFile:
789 self.set += 1
823 self.set += 1
790 if nextDay:
824 if nextDay:
@@ -796,7 +830,7 class JRODataReader(Reader):
796 prefixFileList = ['d', 'D']
830 prefixFileList = ['d', 'D']
797 elif self.ext.lower() == ".pdata": # spectra
831 elif self.ext.lower() == ".pdata": # spectra
798 prefixFileList = ['p', 'P']
832 prefixFileList = ['p', 'P']
799
833
800 # barrido por las combinaciones posibles
834 # barrido por las combinaciones posibles
801 for prefixDir in prefixDirList:
835 for prefixDir in prefixDirList:
802 thispath = self.path
836 thispath = self.path
@@ -816,9 +850,9 class JRODataReader(Reader):
816
850
817 if os.path.exists(fullfilename):
851 if os.path.exists(fullfilename):
818 return fullfilename, filename
852 return fullfilename, filename
819
853
820 return None, filename
854 return None, filename
821
855
822 def __waitNewBlock(self):
856 def __waitNewBlock(self):
823 """
857 """
824 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
858 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
@@ -860,9 +894,9 class JRODataReader(Reader):
860 def __setNewBlock(self):
894 def __setNewBlock(self):
861
895
862 if self.fp == None:
896 if self.fp == None:
863 return 0
897 return 0
864
898
865 if self.flagIsNewFile:
899 if self.flagIsNewFile:
866 self.lastUTTime = self.basicHeaderObj.utc
900 self.lastUTTime = self.basicHeaderObj.utc
867 return 1
901 return 1
868
902
@@ -875,12 +909,12 class JRODataReader(Reader):
875
909
876 currentSize = self.fileSize - self.fp.tell()
910 currentSize = self.fileSize - self.fp.tell()
877 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
911 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
878
912
879 if (currentSize >= neededSize):
913 if (currentSize >= neededSize):
880 self.basicHeaderObj.read(self.fp)
914 self.basicHeaderObj.read(self.fp)
881 self.lastUTTime = self.basicHeaderObj.utc
915 self.lastUTTime = self.basicHeaderObj.utc
882 return 1
916 return 1
883
917
884 if self.__waitNewBlock():
918 if self.__waitNewBlock():
885 self.lastUTTime = self.basicHeaderObj.utc
919 self.lastUTTime = self.basicHeaderObj.utc
886 return 1
920 return 1
@@ -966,10 +1000,10 class JRODataReader(Reader):
966 except IOError:
1000 except IOError:
967 log.error("File {} can't be opened".format(filename), self.name)
1001 log.error("File {} can't be opened".format(filename), self.name)
968 return False
1002 return False
969
1003
970 if self.online and self.waitDataBlock(0):
1004 if self.online and self.waitDataBlock(0):
971 pass
1005 pass
972
1006
973 basicHeaderObj = BasicHeader(LOCALTIME)
1007 basicHeaderObj = BasicHeader(LOCALTIME)
974 systemHeaderObj = SystemHeader()
1008 systemHeaderObj = SystemHeader()
975 radarControllerHeaderObj = RadarControllerHeader()
1009 radarControllerHeaderObj = RadarControllerHeader()
@@ -996,7 +1030,7 class JRODataReader(Reader):
996 dt2 = basicHeaderObj.datatime
1030 dt2 = basicHeaderObj.datatime
997 if not self.isDateTimeInRange(dt1, self.startDate, self.endDate, self.startTime, self.endTime) and not \
1031 if not self.isDateTimeInRange(dt1, self.startDate, self.endDate, self.startTime, self.endTime) and not \
998 self.isDateTimeInRange(dt2, self.startDate, self.endDate, self.startTime, self.endTime):
1032 self.isDateTimeInRange(dt2, self.startDate, self.endDate, self.startTime, self.endTime):
999 flag = False
1033 flag = False
1000
1034
1001 fp.close()
1035 fp.close()
1002 return flag
1036 return flag
@@ -1105,11 +1139,11 class JRODataReader(Reader):
1105 return dateList
1139 return dateList
1106
1140
1107 def setup(self, **kwargs):
1141 def setup(self, **kwargs):
1108
1142
1109 self.set_kwargs(**kwargs)
1143 self.set_kwargs(**kwargs)
1110 if not self.ext.startswith('.'):
1144 if not self.ext.startswith('.'):
1111 self.ext = '.{}'.format(self.ext)
1145 self.ext = '.{}'.format(self.ext)
1112
1146
1113 if self.server is not None:
1147 if self.server is not None:
1114 if 'tcp://' in self.server:
1148 if 'tcp://' in self.server:
1115 address = server
1149 address = server
@@ -1131,36 +1165,36 class JRODataReader(Reader):
1131
1165
1132 for nTries in range(self.nTries):
1166 for nTries in range(self.nTries):
1133 fullpath = self.searchFilesOnLine(self.path, self.startDate,
1167 fullpath = self.searchFilesOnLine(self.path, self.startDate,
1134 self.endDate, self.expLabel, self.ext, self.walk,
1168 self.endDate, self.expLabel, self.ext, self.walk,
1135 self.filefmt, self.folderfmt)
1169 self.filefmt, self.folderfmt)
1136
1170
1137 try:
1171 try:
1138 fullpath = next(fullpath)
1172 fullpath = next(fullpath)
1139 except:
1173 except:
1140 fullpath = None
1174 fullpath = None
1141
1175
1142 if fullpath:
1176 if fullpath:
1143 break
1177 break
1144
1178
1145 log.warning(
1179 log.warning(
1146 'Waiting {} sec for a valid file in {}: try {} ...'.format(
1180 'Waiting {} sec for a valid file in {}: try {} ...'.format(
1147 self.delay, self.path, nTries + 1),
1181 self.delay, self.path, nTries + 1),
1148 self.name)
1182 self.name)
1149 time.sleep(self.delay)
1183 time.sleep(self.delay)
1150
1184
1151 if not(fullpath):
1185 if not(fullpath):
1152 raise schainpy.admin.SchainError(
1186 raise schainpy.admin.SchainError(
1153 'There isn\'t any valid file in {}'.format(self.path))
1187 'There isn\'t any valid file in {}'.format(self.path))
1154
1188
1155 pathname, filename = os.path.split(fullpath)
1189 pathname, filename = os.path.split(fullpath)
1156 self.year = int(filename[1:5])
1190 self.year = int(filename[1:5])
1157 self.doy = int(filename[5:8])
1191 self.doy = int(filename[5:8])
1158 self.set = int(filename[8:11]) - 1
1192 self.set = int(filename[8:11]) - 1
1159 else:
1193 else:
1160 log.log("Searching files in {}".format(self.path), self.name)
1194 log.log("Searching files in {}".format(self.path), self.name)
1161 self.filenameList = self.searchFilesOffLine(self.path, self.startDate,
1195 self.filenameList = self.searchFilesOffLine(self.path, self.startDate,
1162 self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt)
1196 self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt)
1163
1197
1164 self.setNextFile()
1198 self.setNextFile()
1165
1199
1166 return
1200 return
@@ -1181,7 +1215,7 class JRODataReader(Reader):
1181 self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime
1215 self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime
1182
1216
1183 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs
1217 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs
1184
1218
1185 def getFirstHeader(self):
1219 def getFirstHeader(self):
1186
1220
1187 raise NotImplementedError
1221 raise NotImplementedError
@@ -1214,8 +1248,8 class JRODataReader(Reader):
1214 """
1248 """
1215
1249
1216 Arguments:
1250 Arguments:
1217 path :
1251 path :
1218 startDate :
1252 startDate :
1219 endDate :
1253 endDate :
1220 startTime :
1254 startTime :
1221 endTime :
1255 endTime :
@@ -1284,7 +1318,7 class JRODataWriter(Reader):
1284 dtype_width = get_dtype_width(dtype_index)
1318 dtype_width = get_dtype_width(dtype_index)
1285
1319
1286 return dtype_width
1320 return dtype_width
1287
1321
1288 def getProcessFlags(self):
1322 def getProcessFlags(self):
1289
1323
1290 processFlags = 0
1324 processFlags = 0
@@ -1322,9 +1356,9 class JRODataWriter(Reader):
1322
1356
1323 self.basicHeaderObj.size = self.basicHeaderSize # bytes
1357 self.basicHeaderObj.size = self.basicHeaderSize # bytes
1324 self.basicHeaderObj.version = self.versionFile
1358 self.basicHeaderObj.version = self.versionFile
1325 self.basicHeaderObj.dataBlock = self.nTotalBlocks
1359 self.basicHeaderObj.dataBlock = self.nTotalBlocks
1326 utc = numpy.floor(self.dataOut.utctime)
1360 utc = numpy.floor(self.dataOut.utctime)
1327 milisecond = (self.dataOut.utctime - utc) * 1000.0
1361 milisecond = (self.dataOut.utctime - utc) * 1000.0
1328 self.basicHeaderObj.utc = utc
1362 self.basicHeaderObj.utc = utc
1329 self.basicHeaderObj.miliSecond = milisecond
1363 self.basicHeaderObj.miliSecond = milisecond
1330 self.basicHeaderObj.timeZone = self.dataOut.timeZone
1364 self.basicHeaderObj.timeZone = self.dataOut.timeZone
@@ -1465,9 +1499,9 class JRODataWriter(Reader):
1465 if self.dataOut.datatime.date() > self.fileDate:
1499 if self.dataOut.datatime.date() > self.fileDate:
1466 setFile = 0
1500 setFile = 0
1467 self.nTotalBlocks = 0
1501 self.nTotalBlocks = 0
1468
1502
1469 filen = '{}{:04d}{:03d}{:03d}{}'.format(
1503 filen = '{}{:04d}{:03d}{:03d}{}'.format(
1470 self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext)
1504 self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext)
1471
1505
1472 filename = os.path.join(path, subfolder, filen)
1506 filename = os.path.join(path, subfolder, filen)
1473
1507
@@ -1515,11 +1549,11 class JRODataWriter(Reader):
1515 self.ext = ext.lower()
1549 self.ext = ext.lower()
1516
1550
1517 self.path = path
1551 self.path = path
1518
1552
1519 if set is None:
1553 if set is None:
1520 self.setFile = -1
1554 self.setFile = -1
1521 else:
1555 else:
1522 self.setFile = set - 1
1556 self.setFile = set - 1
1523
1557
1524 self.blocksPerFile = blocksPerFile
1558 self.blocksPerFile = blocksPerFile
1525 self.profilesPerBlock = profilesPerBlock
1559 self.profilesPerBlock = profilesPerBlock
@@ -113,8 +113,8 class DigitalRFReader(ProcessingUnit):
113 numpy.arange(self.__nSamples, dtype=numpy.float) * \
113 numpy.arange(self.__nSamples, dtype=numpy.float) * \
114 self.__deltaHeigth
114 self.__deltaHeigth
115
115
116 self.dataOut.channelList = list(range(self.__num_subchannels))
116 #self.dataOut.channelList = list(range(self.__num_subchannels))
117
117 self.dataOut.channelList = list(range(len(self.__channelList)))
118 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
118 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
119
119
120 # self.dataOut.channelIndexList = None
120 # self.dataOut.channelIndexList = None
@@ -344,9 +344,12 class DigitalRFReader(ProcessingUnit):
344 endUTCSecond = (endDatetime - datetime.datetime(1970,
344 endUTCSecond = (endDatetime - datetime.datetime(1970,
345 1, 1)).total_seconds() + self.__timezone
345 1, 1)).total_seconds() + self.__timezone
346
346
347
348 print(startUTCSecond,endUTCSecond)
347 start_index, end_index = self.digitalReadObj.get_bounds(
349 start_index, end_index = self.digitalReadObj.get_bounds(
348 channelNameList[channelList[0]])
350 channelNameList[channelList[0]])
349
351
352 print("*****",start_index,end_index)
350 if not startUTCSecond:
353 if not startUTCSecond:
351 startUTCSecond = start_index / self.__sample_rate
354 startUTCSecond = start_index / self.__sample_rate
352
355
@@ -403,8 +406,10 class DigitalRFReader(ProcessingUnit):
403 # por que en el otro metodo lo primero q se hace es sumar samplestoread
406 # por que en el otro metodo lo primero q se hace es sumar samplestoread
404 self.__thisUnixSample = int(startUTCSecond * self.__sample_rate) - self.__samples_to_read
407 self.__thisUnixSample = int(startUTCSecond * self.__sample_rate) - self.__samples_to_read
405
408
406 self.__data_buffer = numpy.zeros(
409 #self.__data_buffer = numpy.zeros(
407 (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex)
410 # (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex)
411 self.__data_buffer = numpy.zeros((int(len(channelList)), self.__samples_to_read), dtype=numpy.complex)
412
408
413
409 self.__setFileHeader()
414 self.__setFileHeader()
410 self.isConfig = True
415 self.isConfig = True
@@ -436,7 +441,7 class DigitalRFReader(ProcessingUnit):
436 try:
441 try:
437 self.digitalReadObj.reload(complete_update=True)
442 self.digitalReadObj.reload(complete_update=True)
438 except:
443 except:
439 self.digitalReadObj = digital_rf.DigitalRFReader(self.path)
444 self.digitalReadObj = digital_rf.DigitalRFReader(self.path)
440
445
441 start_index, end_index = self.digitalReadObj.get_bounds(
446 start_index, end_index = self.digitalReadObj.get_bounds(
442 self.__channelNameList[self.__channelList[0]])
447 self.__channelNameList[self.__channelList[0]])
@@ -476,7 +481,7 class DigitalRFReader(ProcessingUnit):
476 # Set the next data
481 # Set the next data
477 self.__flagDiscontinuousBlock = False
482 self.__flagDiscontinuousBlock = False
478 self.__thisUnixSample += self.__samples_to_read
483 self.__thisUnixSample += self.__samples_to_read
479
484
480 if self.__thisUnixSample + 2 * self.__samples_to_read > self.__endUTCSecond * self.__sample_rate:
485 if self.__thisUnixSample + 2 * self.__samples_to_read > self.__endUTCSecond * self.__sample_rate:
481 print ("[Reading] There are no more data into selected time-range")
486 print ("[Reading] There are no more data into selected time-range")
482 if self.__online:
487 if self.__online:
@@ -492,7 +497,7 class DigitalRFReader(ProcessingUnit):
492 indexChannel = 0
497 indexChannel = 0
493
498
494 dataOk = False
499 dataOk = False
495
500
496 for thisChannelName in self.__channelNameList: # TODO VARIOS CHANNELS?
501 for thisChannelName in self.__channelNameList: # TODO VARIOS CHANNELS?
497 for indexSubchannel in range(self.__num_subchannels):
502 for indexSubchannel in range(self.__num_subchannels):
498 try:
503 try:
@@ -519,8 +524,8 class DigitalRFReader(ProcessingUnit):
519 result.shape[0],
524 result.shape[0],
520 self.__samples_to_read))
525 self.__samples_to_read))
521 break
526 break
522
527
523 self.__data_buffer[indexSubchannel, :] = result * volt_scale
528 self.__data_buffer[indexChannel, :] = result * volt_scale
524 indexChannel+=1
529 indexChannel+=1
525
530
526 dataOk = True
531 dataOk = True
@@ -587,7 +592,7 class DigitalRFReader(ProcessingUnit):
587 return
592 return
588
593
589 print('[Reading] waiting %d seconds to read a new block' % seconds)
594 print('[Reading] waiting %d seconds to read a new block' % seconds)
590 time.sleep(seconds)
595 sleep(seconds)
591
596
592 self.dataOut.data = self.__data_buffer[:, self.__bufferIndex:self.__bufferIndex + self.__nSamples]
597 self.dataOut.data = self.__data_buffer[:, self.__bufferIndex:self.__bufferIndex + self.__nSamples]
593 self.dataOut.utctime = ( self.__thisUnixSample + self.__bufferIndex) / self.__sample_rate
598 self.dataOut.utctime = ( self.__thisUnixSample + self.__bufferIndex) / self.__sample_rate
@@ -624,12 +629,12 class DigitalRFReader(ProcessingUnit):
624 '''
629 '''
625 This method will be called many times so here you should put all your code
630 This method will be called many times so here you should put all your code
626 '''
631 '''
627
632
628 if not self.isConfig:
633 if not self.isConfig:
629 self.setup(**kwargs)
634 self.setup(**kwargs)
630 #self.i = self.i+1
635 #self.i = self.i+1
631 self.getData(seconds=self.__delay)
636 self.getData(seconds=self.__delay)
632
637
633 return
638 return
634
639
635 @MPDecorator
640 @MPDecorator
@@ -89,7 +89,7 class SpectraHeisProc(ProcessingUnit):
89 if self.dataIn.type == "Fits":
89 if self.dataIn.type == "Fits":
90 self.__updateObjFromFits()
90 self.__updateObjFromFits()
91 self.dataOut.flagNoData = False
91 self.dataOut.flagNoData = False
92 return
92 return
93
93
94 if self.dataIn.type == "SpectraHeis":
94 if self.dataIn.type == "SpectraHeis":
95 self.dataOut.copy(self.dataIn)
95 self.dataOut.copy(self.dataIn)
@@ -302,6 +302,9 class IncohInt4SpectraHeis(Operation):
302 if self.__initime == None:
302 if self.__initime == None:
303 self.__initime = datatime
303 self.__initime = datatime
304
304
305 #if self.__profIndex == 0:
306 # self.__initime = datatime
307
305 if self.__byTime:
308 if self.__byTime:
306 avgdata = self.byTime(data, datatime)
309 avgdata = self.byTime(data, datatime)
307 else:
310 else:
@@ -330,6 +333,7 class IncohInt4SpectraHeis(Operation):
330 self.setup(n=n, timeInterval=timeInterval, overlapping=overlapping)
333 self.setup(n=n, timeInterval=timeInterval, overlapping=overlapping)
331 self.isConfig = True
334 self.isConfig = True
332
335
336 #print("utc_time",dataOut.utctime)
333 avgdata, avgdatatime = self.integrate(dataOut.data_spc, dataOut.utctime)
337 avgdata, avgdatatime = self.integrate(dataOut.data_spc, dataOut.utctime)
334
338
335 # dataOut.timeInterval *= n
339 # dataOut.timeInterval *= n
@@ -343,5 +347,5 class IncohInt4SpectraHeis(Operation):
343 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt
347 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt
344 # dataOut.timeInterval = self.__timeInterval*self.n
348 # dataOut.timeInterval = self.__timeInterval*self.n
345 dataOut.flagNoData = False
349 dataOut.flagNoData = False
346
350
347 return dataOut No newline at end of file
351 return dataOut
This diff has been collapsed as it changes many lines, (630 lines changed) Show them Hide them
@@ -1,4 +1,4
1 import numpy
1 import numpy,os,h5py
2 import math
2 import math
3 from scipy import optimize, interpolate, signal, stats, ndimage
3 from scipy import optimize, interpolate, signal, stats, ndimage
4 import scipy
4 import scipy
@@ -45,6 +45,12 def _unpickle_method(func_name, obj, cls):
45 break
45 break
46 return func.__get__(obj, cls)
46 return func.__get__(obj, cls)
47
47
48 def isNumber(str):
49 try:
50 float(str)
51 return True
52 except:
53 return False
48
54
49 class ParametersProc(ProcessingUnit):
55 class ParametersProc(ProcessingUnit):
50
56
@@ -108,6 +114,13 class ParametersProc(ProcessingUnit):
108 self.dataOut.flagNoData = False
114 self.dataOut.flagNoData = False
109 self.dataOut.utctimeInit = self.dataIn.utctime
115 self.dataOut.utctimeInit = self.dataIn.utctime
110 self.dataOut.paramInterval = self.dataIn.nProfiles*self.dataIn.nCohInt*self.dataIn.ippSeconds
116 self.dataOut.paramInterval = self.dataIn.nProfiles*self.dataIn.nCohInt*self.dataIn.ippSeconds
117
118 if hasattr(self.dataIn, 'flagDataAsBlock'):
119 self.dataOut.flagDataAsBlock = self.dataIn.flagDataAsBlock
120
121 if hasattr(self.dataIn, 'profileIndex'):
122 self.dataOut.profileIndex = self.dataIn.profileIndex
123
111 if hasattr(self.dataIn, 'dataPP_POW'):
124 if hasattr(self.dataIn, 'dataPP_POW'):
112 self.dataOut.dataPP_POW = self.dataIn.dataPP_POW
125 self.dataOut.dataPP_POW = self.dataIn.dataPP_POW
113
126
@@ -143,6 +156,9 class ParametersProc(ProcessingUnit):
143 self.dataOut.groupList = self.dataIn.pairsList
156 self.dataOut.groupList = self.dataIn.pairsList
144 self.dataOut.flagNoData = False
157 self.dataOut.flagNoData = False
145
158
159 if hasattr(self.dataIn, 'flagDataAsBlock'):
160 self.dataOut.flagDataAsBlock = self.dataIn.flagDataAsBlock
161
146 if hasattr(self.dataIn, 'ChanDist'): #Distances of receiver channels
162 if hasattr(self.dataIn, 'ChanDist'): #Distances of receiver channels
147 self.dataOut.ChanDist = self.dataIn.ChanDist
163 self.dataOut.ChanDist = self.dataIn.ChanDist
148 else: self.dataOut.ChanDist = None
164 else: self.dataOut.ChanDist = None
@@ -220,7 +236,7 class RemoveWideGC(Operation):
220 self.i = 0
236 self.i = 0
221 self.ich = 0
237 self.ich = 0
222 self.ir = 0
238 self.ir = 0
223
239
224 def run(self, dataOut, ClutterWidth=2.5):
240 def run(self, dataOut, ClutterWidth=2.5):
225 # print ('Entering RemoveWideGC ... ')
241 # print ('Entering RemoveWideGC ... ')
226
242
@@ -247,11 +263,11 class RemoveWideGC(Operation):
247 junk = numpy.append(numpy.insert(numpy.squeeze(self.spc[ich,gc_values,ir]),0,HSn),HSn)
263 junk = numpy.append(numpy.insert(numpy.squeeze(self.spc[ich,gc_values,ir]),0,HSn),HSn)
248 j1index = numpy.squeeze(numpy.where(numpy.diff(junk)>0))
264 j1index = numpy.squeeze(numpy.where(numpy.diff(junk)>0))
249 j2index = numpy.squeeze(numpy.where(numpy.diff(junk)<0))
265 j2index = numpy.squeeze(numpy.where(numpy.diff(junk)<0))
250 if ((numpy.size(j1index)<=1) | (numpy.size(j2index)<=1)) :
266 if ((numpy.size(j1index)<=1) | (numpy.size(j2index)<=1)) :
251 continue
267 continue
252 junk3 = numpy.squeeze(numpy.diff(j1index))
268 junk3 = numpy.squeeze(numpy.diff(j1index))
253 junk4 = numpy.squeeze(numpy.diff(j2index))
269 junk4 = numpy.squeeze(numpy.diff(j2index))
254
270
255 valleyindex = j2index[numpy.where(junk4>1)]
271 valleyindex = j2index[numpy.where(junk4>1)]
256 peakindex = j1index[numpy.where(junk3>1)]
272 peakindex = j1index[numpy.where(junk3>1)]
257
273
@@ -261,7 +277,7 class RemoveWideGC(Operation):
261 if numpy.size(isvalid) >1 :
277 if numpy.size(isvalid) >1 :
262 vindex = numpy.argmax(self.spc[ich,gc_values[peakindex[isvalid]],ir])
278 vindex = numpy.argmax(self.spc[ich,gc_values[peakindex[isvalid]],ir])
263 isvalid = isvalid[vindex]
279 isvalid = isvalid[vindex]
264
280
265 # clutter peak
281 # clutter peak
266 gcpeak = peakindex[isvalid]
282 gcpeak = peakindex[isvalid]
267 vl = numpy.where(valleyindex < gcpeak)
283 vl = numpy.where(valleyindex < gcpeak)
@@ -283,7 +299,7 class RemoveWideGC(Operation):
283 return dataOut
299 return dataOut
284
300
285 class SpectralFilters(Operation):
301 class SpectralFilters(Operation):
286 ''' This class allows to replace the novalid values with noise for each channel
302 ''' This class allows to replace the novalid values with noise for each channel
287 This applies to CLAIRE RADAR
303 This applies to CLAIRE RADAR
288
304
289 PositiveLimit : RightLimit of novalid data
305 PositiveLimit : RightLimit of novalid data
@@ -303,7 +319,7 class SpectralFilters(Operation):
303 def __init__(self):
319 def __init__(self):
304 Operation.__init__(self)
320 Operation.__init__(self)
305 self.i = 0
321 self.i = 0
306
322
307 def run(self, dataOut, ):
323 def run(self, dataOut, ):
308
324
309 self.spc = dataOut.data_pre[0].copy()
325 self.spc = dataOut.data_pre[0].copy()
@@ -311,7 +327,7 class SpectralFilters(Operation):
311 VelRange = dataOut.spc_range[2]
327 VelRange = dataOut.spc_range[2]
312
328
313 # novalid corresponds to data within the Negative and PositiveLimit
329 # novalid corresponds to data within the Negative and PositiveLimit
314
330
315
331
316 # Removing novalid data from the spectra
332 # Removing novalid data from the spectra
317 for i in range(self.Num_Chn):
333 for i in range(self.Num_Chn):
@@ -383,7 +399,7 class GaussianFit(Operation):
383 p1 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][4,:,1]] * self.Num_Bin))
399 p1 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][4,:,1]] * self.Num_Bin))
384 elif method == 'squared':
400 elif method == 'squared':
385 p0 = 2.
401 p0 = 2.
386 p1 = 2.
402 p1 = 2.
387 gau0[iCh] = A0*numpy.exp(-0.5*numpy.abs((x_mtr-v0)/s0)**p0)+N0
403 gau0[iCh] = A0*numpy.exp(-0.5*numpy.abs((x_mtr-v0)/s0)**p0)+N0
388 gau1[iCh] = A1*numpy.exp(-0.5*numpy.abs((x_mtr-v1)/s1)**p1)+N1
404 gau1[iCh] = A1*numpy.exp(-0.5*numpy.abs((x_mtr-v1)/s1)**p1)+N1
389 dataOut.GaussFit0 = gau0
405 dataOut.GaussFit0 = gau0
@@ -445,7 +461,7 class GaussianFit(Operation):
445 # print ('stop 2.1')
461 # print ('stop 2.1')
446 fatspectra=1.0
462 fatspectra=1.0
447 # noise per channel.... we might want to use the noise at each range
463 # noise per channel.... we might want to use the noise at each range
448
464
449 # wnoise = noise_ #/ spc_norm_max #commented by D. Scipión 19.03.2021
465 # wnoise = noise_ #/ spc_norm_max #commented by D. Scipión 19.03.2021
450 #wnoise,stdv,i_max,index =enoise(spc,num_intg) #noise estimate using Hildebrand Sekhon, only wnoise is used
466 #wnoise,stdv,i_max,index =enoise(spc,num_intg) #noise estimate using Hildebrand Sekhon, only wnoise is used
451 #if wnoise>1.1*pnoise: # to be tested later
467 #if wnoise>1.1*pnoise: # to be tested later
@@ -493,7 +509,7 class GaussianFit(Operation):
493 if powerwidth <= 1:
509 if powerwidth <= 1:
494 # print('powerwidth <= 1')
510 # print('powerwidth <= 1')
495 continue
511 continue
496
512
497 # print ('stop 6')
513 # print ('stop 6')
498 firstpeak = powerlo + powerwidth/10.# first gaussian energy location
514 firstpeak = powerlo + powerwidth/10.# first gaussian energy location
499 secondpeak = powerhi - powerwidth/10. #second gaussian energy location
515 secondpeak = powerhi - powerwidth/10. #second gaussian energy location
@@ -531,7 +547,7 class GaussianFit(Operation):
531 noise=lsq1[0][4]
547 noise=lsq1[0][4]
532 #return (numpy.array([shift0,width0,Amplitude0,p0]),
548 #return (numpy.array([shift0,width0,Amplitude0,p0]),
533 # numpy.array([shift1,width1,Amplitude1,p1]),noise,snrdB,chiSq1,6.,sigmas1,[None,]*9,choice)
549 # numpy.array([shift1,width1,Amplitude1,p1]),noise,snrdB,chiSq1,6.,sigmas1,[None,]*9,choice)
534
550
535 # print ('stop 9')
551 # print ('stop 9')
536 ''' two Gaussians '''
552 ''' two Gaussians '''
537 #shift0=numpy.mod(firstpeak+minx,64); shift1=numpy.mod(secondpeak+minx,64)
553 #shift0=numpy.mod(firstpeak+minx,64); shift1=numpy.mod(secondpeak+minx,64)
@@ -628,7 +644,7 class GaussianFit(Operation):
628 if Amplitude1<0.05:
644 if Amplitude1<0.05:
629 shift1,width1,Amplitude1,p1 = 4*[numpy.NaN]
645 shift1,width1,Amplitude1,p1 = 4*[numpy.NaN]
630
646
631 # print ('stop 16 ')
647 # print ('stop 16 ')
632 # SPC_ch1[:,ht] = noise + Amplitude0*numpy.exp(-0.5*(abs(x-shift0)/width0)**p0)
648 # SPC_ch1[:,ht] = noise + Amplitude0*numpy.exp(-0.5*(abs(x-shift0)/width0)**p0)
633 # SPC_ch2[:,ht] = noise + Amplitude1*numpy.exp(-0.5*(abs(x-shift1)/width1)**p1)
649 # SPC_ch2[:,ht] = noise + Amplitude1*numpy.exp(-0.5*(abs(x-shift1)/width1)**p1)
634 # SPCparam = (SPC_ch1,SPC_ch2)
650 # SPCparam = (SPC_ch1,SPC_ch2)
@@ -662,7 +678,7 class GaussianFit(Operation):
662 model0 = amplitude0*numpy.exp(-0.5*abs((x-shift0)/width0)**power0)
678 model0 = amplitude0*numpy.exp(-0.5*abs((x-shift0)/width0)**power0)
663 model0u = amplitude0*numpy.exp(-0.5*abs((x - shift0 - self.Num_Bin)/width0)**power0)
679 model0u = amplitude0*numpy.exp(-0.5*abs((x - shift0 - self.Num_Bin)/width0)**power0)
664 model0d = amplitude0*numpy.exp(-0.5*abs((x - shift0 + self.Num_Bin)/width0)**power0)
680 model0d = amplitude0*numpy.exp(-0.5*abs((x - shift0 + self.Num_Bin)/width0)**power0)
665
681
666 model1 = amplitude1*numpy.exp(-0.5*abs((x - shift1)/width1)**power1)
682 model1 = amplitude1*numpy.exp(-0.5*abs((x - shift1)/width1)**power1)
667 model1u = amplitude1*numpy.exp(-0.5*abs((x - shift1 - self.Num_Bin)/width1)**power1)
683 model1u = amplitude1*numpy.exp(-0.5*abs((x - shift1 - self.Num_Bin)/width1)**power1)
668 model1d = amplitude1*numpy.exp(-0.5*abs((x - shift1 + self.Num_Bin)/width1)**power1)
684 model1d = amplitude1*numpy.exp(-0.5*abs((x - shift1 + self.Num_Bin)/width1)**power1)
@@ -731,7 +747,7 class PrecipitationProc(Operation):
731 self.Lambda = Lambda
747 self.Lambda = Lambda
732 self.aL = aL
748 self.aL = aL
733 self.tauW = tauW
749 self.tauW = tauW
734 self.ThetaT = ThetaT
750 self.ThetaT = ThetaT
735 self.ThetaR = ThetaR
751 self.ThetaR = ThetaR
736 self.GSys = 10**(36.63/10) # Ganancia de los LNA 36.63 dB
752 self.GSys = 10**(36.63/10) # Ganancia de los LNA 36.63 dB
737 self.lt = 10**(1.67/10) # Perdida en cables Tx 1.67 dB
753 self.lt = 10**(1.67/10) # Perdida en cables Tx 1.67 dB
@@ -771,7 +787,7 class PrecipitationProc(Operation):
771 ETAn = (RadarConstant *ExpConstant) * Pr * rMtrx**2 #Reflectivity (ETA)
787 ETAn = (RadarConstant *ExpConstant) * Pr * rMtrx**2 #Reflectivity (ETA)
772 ETAd = ETAn * 6.18 * exp( -0.6 * D_Vz ) * delv_z
788 ETAd = ETAn * 6.18 * exp( -0.6 * D_Vz ) * delv_z
773 # Radar Cross Section
789 # Radar Cross Section
774 sigmaD = Km2 * (D_Vz * 1e-3 )**6 * numpy.pi**5 / Lambda**4
790 sigmaD = Km2 * (D_Vz * 1e-3 )**6 * numpy.pi**5 / Lambda**4
775 # Drop Size Distribution
791 # Drop Size Distribution
776 DSD = ETAn / sigmaD
792 DSD = ETAn / sigmaD
777 # Equivalente Reflectivy
793 # Equivalente Reflectivy
@@ -792,7 +808,7 class PrecipitationProc(Operation):
792 dataOut.data_output = RR[8]
808 dataOut.data_output = RR[8]
793 dataOut.data_param = numpy.ones([3,self.Num_Hei])
809 dataOut.data_param = numpy.ones([3,self.Num_Hei])
794 dataOut.channelList = [0,1,2]
810 dataOut.channelList = [0,1,2]
795
811
796 dataOut.data_param[0]=10*numpy.log10(Ze_org)
812 dataOut.data_param[0]=10*numpy.log10(Ze_org)
797 dataOut.data_param[1]=-W
813 dataOut.data_param[1]=-W
798 dataOut.data_param[2]=RR
814 dataOut.data_param[2]=RR
@@ -868,7 +884,7 class FullSpectralAnalysis(Operation):
868 Parameters affected: Winds, height range, SNR
884 Parameters affected: Winds, height range, SNR
869
885
870 """
886 """
871 def run(self, dataOut, Xi01=None, Xi02=None, Xi12=None, Eta01=None, Eta02=None, Eta12=None, SNRdBlimit=-30,
887 def run(self, dataOut, Xi01=None, Xi02=None, Xi12=None, Eta01=None, Eta02=None, Eta12=None, SNRdBlimit=-30,
872 minheight=None, maxheight=None, NegativeLimit=None, PositiveLimit=None):
888 minheight=None, maxheight=None, NegativeLimit=None, PositiveLimit=None):
873
889
874 spc = dataOut.data_pre[0].copy()
890 spc = dataOut.data_pre[0].copy()
@@ -912,14 +928,14 class FullSpectralAnalysis(Operation):
912
928
913 if Height >= range_min and Height < range_max:
929 if Height >= range_min and Height < range_max:
914 # error_code will be useful in future analysis
930 # error_code will be useful in future analysis
915 [Vzon,Vmer,Vver, error_code] = self.WindEstimation(spc[:,:,Height], cspc[:,:,Height], pairsList,
931 [Vzon,Vmer,Vver, error_code] = self.WindEstimation(spc[:,:,Height], cspc[:,:,Height], pairsList,
916 ChanDist, Height, dataOut.noise, dataOut.spc_range, dbSNR[Height], SNRdBlimit, NegativeLimit, PositiveLimit,dataOut.frequency)
932 ChanDist, Height, dataOut.noise, dataOut.spc_range, dbSNR[Height], SNRdBlimit, NegativeLimit, PositiveLimit,dataOut.frequency)
917
933
918 if abs(Vzon) < 100. and abs(Vmer) < 100.:
934 if abs(Vzon) < 100. and abs(Vmer) < 100.:
919 velocityX[Height] = Vzon
935 velocityX[Height] = Vzon
920 velocityY[Height] = -Vmer
936 velocityY[Height] = -Vmer
921 velocityZ[Height] = Vver
937 velocityZ[Height] = Vver
922
938
923 # Censoring data with SNR threshold
939 # Censoring data with SNR threshold
924 dbSNR [dbSNR < SNRdBlimit] = numpy.NaN
940 dbSNR [dbSNR < SNRdBlimit] = numpy.NaN
925
941
@@ -1019,7 +1035,7 class FullSpectralAnalysis(Operation):
1019 xSamples = xFrec # the frequency range is taken
1035 xSamples = xFrec # the frequency range is taken
1020 delta_x = xSamples[1] - xSamples[0] # delta_f or delta_x
1036 delta_x = xSamples[1] - xSamples[0] # delta_f or delta_x
1021
1037
1022 # only consider velocities with in NegativeLimit and PositiveLimit
1038 # only consider velocities with in NegativeLimit and PositiveLimit
1023 if (NegativeLimit is None):
1039 if (NegativeLimit is None):
1024 NegativeLimit = numpy.min(xVel)
1040 NegativeLimit = numpy.min(xVel)
1025 if (PositiveLimit is None):
1041 if (PositiveLimit is None):
@@ -1034,7 +1050,7 class FullSpectralAnalysis(Operation):
1034 # spwd limit - updated by D. Scipión 30.03.2021
1050 # spwd limit - updated by D. Scipión 30.03.2021
1035 widthlimit = 10
1051 widthlimit = 10
1036 '''************************* SPC is normalized ********************************'''
1052 '''************************* SPC is normalized ********************************'''
1037 spc_norm = spc.copy()
1053 spc_norm = spc.copy()
1038 # For each channel
1054 # For each channel
1039 for i in range(nChan):
1055 for i in range(nChan):
1040 spc_sub = spc_norm[i,:] - noise[i] # only the signal power
1056 spc_sub = spc_norm[i,:] - noise[i] # only the signal power
@@ -1053,9 +1069,9 class FullSpectralAnalysis(Operation):
1053 >= 0, as it is the modulus squared of the signals (complex * it's conjugate)
1069 >= 0, as it is the modulus squared of the signals (complex * it's conjugate)
1054 """
1070 """
1055 # initial conditions
1071 # initial conditions
1056 popt = [1e-10,0,1e-10]
1072 popt = [1e-10,0,1e-10]
1057 # Spectra average
1073 # Spectra average
1058 SPCMean = numpy.average(SPC_Samples,0)
1074 SPCMean = numpy.average(SPC_Samples,0)
1059 # Moments in frequency
1075 # Moments in frequency
1060 SPCMoments = self.Moments(SPCMean[xvalid], xSamples_zoom)
1076 SPCMoments = self.Moments(SPCMean[xvalid], xSamples_zoom)
1061
1077
@@ -1310,7 +1326,7 class SpectralMoments(Operation):
1310
1326
1311 signal_power = ((spec2[valid] - n0) * fwindow[valid]).mean() # D. Scipión added with correct definition
1327 signal_power = ((spec2[valid] - n0) * fwindow[valid]).mean() # D. Scipión added with correct definition
1312 total_power = (spec2[valid] * fwindow[valid]).mean() # D. Scipión added with correct definition
1328 total_power = (spec2[valid] * fwindow[valid]).mean() # D. Scipión added with correct definition
1313 power = ((spec2[valid] - n0) * fwindow[valid]).sum()
1329 power = ((spec2[valid] - n0) * fwindow[valid]).sum()
1314 fd = ((spec2[valid]- n0)*freq[valid] * fwindow[valid]).sum() / power
1330 fd = ((spec2[valid]- n0)*freq[valid] * fwindow[valid]).sum() / power
1315 w = numpy.sqrt(((spec2[valid] - n0)*fwindow[valid]*(freq[valid]- fd)**2).sum() / power)
1331 w = numpy.sqrt(((spec2[valid] - n0)*fwindow[valid]*(freq[valid]- fd)**2).sum() / power)
1316 snr = (spec2.mean()-n0)/n0
1332 snr = (spec2.mean()-n0)/n0
@@ -3884,3 +3900,567 class SMOperations():
3884 # error[indInvalid1] = 13
3900 # error[indInvalid1] = 13
3885 #
3901 #
3886 # return heights, error
3902 # return heights, error
3903
3904
3905 class WeatherRadar(Operation):
3906 '''
3907 Function tat implements Weather Radar operations-
3908 Input:
3909 Output:
3910 Parameters affected:
3911 '''
3912 isConfig = False
3913
3914 def __init__(self):
3915 Operation.__init__(self)
3916
3917 def setup(self,dataOut,Pt=0,Gt=0,Gr=0,lambda_=0, aL=0,
3918 tauW= 0,thetaT=0,thetaR=0,Km =0):
3919 self.nCh = dataOut.nChannels
3920 self.nHeis = dataOut.nHeights
3921 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
3922 self.Range = numpy.arange(dataOut.nHeights)*deltaHeight + dataOut.heightList[0]
3923 self.Range = self.Range.reshape(1,self.nHeis)
3924 self.Range = numpy.tile(self.Range,[self.nCh,1])
3925 '''-----------1 Constante del Radar----------'''
3926 self.Pt = Pt
3927 self.Gt = Gt
3928 self.Gr = Gr
3929 self.lambda_ = lambda_
3930 self.aL = aL
3931 self.tauW = tauW
3932 self.thetaT = thetaT
3933 self.thetaR = thetaR
3934 self.Km = Km
3935 Numerator = ((4*numpy.pi)**3 * aL**2 * 16 *numpy.log(2))
3936 Denominator = (Pt * Gt * Gr * lambda_**2 * SPEED_OF_LIGHT * tauW * numpy.pi*thetaT*thetaR)
3937 self.RadarConstant = Numerator/Denominator
3938 '''-----------2 Reflectividad del Radar y Factor de Reflectividad------'''
3939 self.n_radar = numpy.zeros((self.nCh,self.nHeis))
3940 self.Z_radar = numpy.zeros((self.nCh,self.nHeis))
3941
3942 def setMoments(self,dataOut,i):
3943
3944 type = dataOut.inputUnit
3945 nCh = dataOut.nChannels
3946 nHeis= dataOut.nHeights
3947 data_param = numpy.zeros((nCh,4,nHeis))
3948 if type == "Voltage":
3949 data_param[:,0,:] = dataOut.dataPP_POW/(dataOut.nCohInt**2)
3950 data_param[:,1,:] = dataOut.dataPP_DOP
3951 data_param[:,2,:] = dataOut.dataPP_WIDTH
3952 data_param[:,3,:] = dataOut.dataPP_SNR
3953 if type == "Spectra":
3954 data_param[:,0,:] = dataOut.data_POW
3955 data_param[:,1,:] = dataOut.data_DOP
3956 data_param[:,2,:] = dataOut.data_WIDTH
3957 def setMoments(self,dataOut,i):
3958 data_param[:,3,:] = dataOut.data_SNR
3959
3960 return data_param[:,i,:]
3961
3962
3963 def run(self,dataOut,Pt=25,Gt=200.0,Gr=50.0,lambda_=0.32, aL=2.5118,
3964 tauW= 4.0e-6,thetaT=0.165,thetaR=0.367,Km =0.93):
3965
3966 if not self.isConfig:
3967 self.setup(dataOut= dataOut,Pt=25,Gt=200.0,Gr=50.0,lambda_=0.32, aL=2.5118,
3968 tauW= 4.0e-6,thetaT=0.165,thetaR=0.367,Km =0.93)
3969 self.isConfig = True
3970 '''-----------------------------Potencia de Radar -Signal S-----------------------------'''
3971 Pr = self.setMoments(dataOut,0)
3972
3973 for R in range(self.nHeis):
3974 self.n_radar[:,R] = self.RadarConstant*Pr[:,R]* (self.Range[:,R])**2
3975
3976 self.Z_radar[:,R] = self.n_radar[:,R]* self.lambda_**4/( numpy.pi**5 * self.Km**2)
3977
3978 '''----------- Factor de Reflectividad Equivalente lamda_ < 10 cm , lamda_= 3.2cm-------'''
3979 Zeh = self.Z_radar
3980 dBZeh = 10*numpy.log10(Zeh)
3981 dataOut.factor_Zeh= dBZeh
3982 self.n_radar = numpy.zeros((self.nCh,self.nHeis))
3983 self.Z_radar = numpy.zeros((self.nCh,self.nHeis))
3984
3985 return dataOut
3986
3987 class PedestalInformation(Operation):
3988 path_ped = None
3989 path_adq = None
3990 t_Interval_p = None
3991 n_Muestras_p = None
3992 isConfig = False
3993 blocksPerfile= None
3994 f_a_p = None
3995 online = None
3996 angulo_adq = None
3997 nro_file = None
3998 nro_key_p = None
3999
4000
4001 def __init__(self):
4002 Operation.__init__(self)
4003
4004 def getfirstFilefromPath(self,path,meta,ext):
4005 validFilelist = []
4006 #print("SEARH",path)
4007 try:
4008 fileList = os.listdir(path)
4009 except:
4010 print("check path - fileList")
4011 if len(fileList)<1:
4012 return None
4013 # meta 1234 567 8-18 BCDE
4014 # H,D,PE YYYY DDD EPOC .ext
4015
4016 for thisFile in fileList:
4017 #print("HI",thisFile)
4018 if meta =="PE":
4019 try:
4020 number= int(thisFile[len(meta)+7:len(meta)+17])
4021 except:
4022 print("There is a file or folder with different format")
4023 if meta == "D":
4024 try:
4025 number= int(thisFile[8:11])
4026 except:
4027 print("There is a file or folder with different format")
4028
4029 if not isNumber(str=number):
4030 continue
4031 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
4032 continue
4033 validFilelist.sort()
4034 validFilelist.append(thisFile)
4035 if len(validFilelist)>0:
4036 validFilelist = sorted(validFilelist,key=str.lower)
4037 return validFilelist
4038 return None
4039
4040 def gettimeutcfromDirFilename(self,path,file):
4041 dir_file= path+"/"+file
4042 fp = h5py.File(dir_file,'r')
4043 #epoc = fp['Metadata'].get('utctimeInit')[()]
4044 epoc = fp['Data'].get('utc')[()]
4045 fp.close()
4046 return epoc
4047
4048 def getDatavaluefromDirFilename(self,path,file,value):
4049 dir_file= path+"/"+file
4050 fp = h5py.File(dir_file,'r')
4051 array = fp['Data'].get(value)[()]
4052 fp.close()
4053 return array
4054
4055 def getFile_KeyP(self,list_pedestal,list_adq):
4056 print(list_pedestal)
4057 print(list_adq)
4058
4059 def getNROFile(self,utc_adq,utc_ped_list):
4060 c=0
4061 for i in range(len(utc_ped_list)):
4062 if utc_adq>utc_ped_list[i]:
4063 c +=1
4064
4065 return c-1,utc_ped_list[c-1],utc_ped_list[c]
4066
4067
4068 def setup_offline(self,list_pedestal,list_adq):
4069 print("SETUP OFFLINE")
4070 print(self.path_ped)
4071 print(self.path_adq)
4072 print(len(self.list_pedestal))
4073 print(len(self.list_adq))
4074 utc_ped_list=[]
4075 for i in range(len(self.list_pedestal)):
4076 utc_ped_list.append(self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[i]))
4077
4078 #utc_ped_list= utc_ped_list
4079 utc_adq = self.gettimeutcfromDirFilename(path=self.path_adq,file=self.list_adq[0])
4080 #print("utc_ped_list",utc_ped_list)
4081 print("utc_adq",utc_adq)
4082 nro_file,utc_ped = self.getNROFile(utc_adq=utc_adq, utc_ped_list= utc_ped_list)
4083
4084 print("nro_file",nro_file,"utc_ped",utc_ped)
4085 print("nro_file",i)
4086 nro_key_p = int((utc_adq-utc_ped)/self.t_Interval_p)
4087 print("nro_key_p",nro_key_p)
4088
4089 ff_pedestal = self.list_pedestal[nro_file]
4090 #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth")
4091 angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azi_pos")
4092
4093 print("utc_pedestal_init :",utc_ped+nro_key_p*self.t_Interval_p)
4094 print("angulo_array :",angulo[nro_key_p])
4095 self.nro_file = nro_file
4096 self.nro_key_p = nro_key_p
4097
4098 def setup_online(self,dataOut):
4099 utc_adq =dataOut.utctime
4100 print("Online-utc_adq",utc_adq)
4101 print(len(self.list_pedestal))
4102 utc_ped_list=[]
4103 for i in range(len(self.list_pedestal)):
4104 utc_ped_list.append(self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[i]))
4105 print(utc_ped_list[:20])
4106 #print(utc_ped_list[488:498])
4107 print("ultimo UTC-PEDESTAL",utc_ped_list[-1])
4108 nro_file,utc_ped,utc_ped_1 = self.getNROFile(utc_adq=utc_adq, utc_ped_list= utc_ped_list)
4109 print("nro_file",nro_file,"utc_ped",utc_ped,"utc_ped_1",utc_ped_1)
4110 print("name_PEDESTAL",self.list_pedestal[nro_file])
4111 nro_key_p = int((utc_adq-utc_ped)/self.t_Interval_p)
4112 print("nro_key_p",nro_key_p)
4113 ff_pedestal = self.list_pedestal[nro_file]
4114 #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth")
4115 angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azi_pos")
4116
4117 print("utc_pedestal_init :",utc_ped+nro_key_p*self.t_Interval_p)
4118 print("angulo_array :",angulo[nro_key_p])
4119 self.nro_file = nro_file
4120 self.nro_key_p = nro_key_p
4121
4122
4123 '''
4124 print("############################")
4125 utc_adq = dataOut.utctime
4126 print("ONLINE",dataOut.utctime)
4127 print("utc_adq" , utc_adq)
4128 utc_pedestal= self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[0])
4129 print("utc_pedestal", utc_pedestal)
4130 flag_i = 0
4131 flag = 0
4132 ready = 0
4133 if len(self.list_pedestal)!=0:
4134 enable_p=1
4135 if (enable_p!=0):
4136 while(flag_i==0):
4137 if utc_adq>utc_pedestal:
4138 nro_file = int((utc_adq - utc_pedestal)/(self.t_Interval_p*self.n_Muestras_p))
4139 print("nro_file--------------------",nro_file)
4140 print(len(self.list_pedestal))
4141 if nro_file> len(self.list_pedestal):
4142 nro_file = len(self.list_pedestal)-1
4143 ff_pedestal = self.list_pedestal[nro_file]
4144 print(ff_pedestal)
4145 utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal)
4146 while(flag==0):
4147 print("adq",utc_adq)
4148 print("ped",utc_pedestal)
4149 print("nro_file",nro_file)
4150 if utc_adq >utc_pedestal:
4151 print("DENTRO DEL IF-SETUP")
4152 ff_pedestal = self.list_pedestal[nro_file]
4153 if 0<(utc_adq - utc_pedestal)<(self.t_Interval_p*self.n_Muestras_p):
4154 nro_file= nro_file
4155 ff_pedestal = self.list_pedestal[nro_file]
4156 ready = 1
4157 if (utc_adq-utc_pedestal)>(self.t_Interval_p*self.n_Muestras_p):
4158 nro_tmp= int((utc_adq-utc_pedestal)/(self.n_Muestras_p))
4159 nro_file= nro_file+1*nro_tmp#chsssssssssssssssssssasssddasdas/ equear esta condicion
4160 if nro_tmp==0:
4161 nro_file= nro_file +1
4162 ff_pedestal = self.list_pedestal[nro_file]
4163 print("",ff_pedestal)
4164 utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal)
4165 else:
4166 print("DENTRO DEL ELSE-SETUP")
4167 nro_tmp= int((utc_pedestal-utc_adq)/(self.n_Muestras_p))
4168 if utc_pedestal>utc_adq and nro_tmp==0:
4169 nro_tmp= int((utc_pedestal-utc_adq))
4170 print("nro_tmp",nro_tmp)
4171 if nro_file>nro_tmp:
4172 nro_file = nro_file-1*nro_tmp
4173 else:
4174 nro_file =nro_file -1
4175
4176 ff_pedestal = self.list_pedestal[nro_file]
4177 utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal)
4178
4179 if ready:
4180 angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth")
4181 nro_key_p = int((utc_adq-utc_pedestal)/self.t_Interval_p)
4182 print("nro_file :",nro_file)
4183 print("name_file :",ff_pedestal)
4184 print("utc_pedestal_file :",utc_pedestal)
4185 print("nro_key_p :",nro_key_p)
4186 print("utc_pedestal_init :",utc_pedestal+nro_key_p*self.t_Interval_p)
4187 print("angulo_array :",angulo[nro_key_p])
4188 flag=1
4189 flag_i=1
4190 else:
4191 print("La lista de archivos de pedestal o adq esta vacia")
4192 nro_file=None
4193 nro_key_p=None
4194 self.nro_file = nro_file
4195 self.nro_key_p = nro_key_p
4196 '''
4197
4198 def setup(self,dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online):
4199 self.__dataReady = False
4200 self.path_ped = path_ped
4201 self.path_adq = path_adq
4202 self.t_Interval_p = t_Interval_p
4203 self.n_Muestras_p = n_Muestras_p
4204 self.blocksPerfile= blocksPerfile
4205 self.f_a_p = f_a_p
4206 self.online = online
4207 self.angulo_adq = numpy.zeros(self.blocksPerfile)
4208 self.__profIndex = 0
4209 print(self.path_ped)
4210 print(self.path_adq)
4211 self.list_pedestal = self.getfirstFilefromPath(path=self.path_ped,meta="PE",ext=".hdf5")
4212 print("LIST NEW", self.list_pedestal[:20])
4213 self.list_adq = self.getfirstFilefromPath(path=self.path_adq,meta="D",ext=".hdf5")
4214 print("*************Longitud list pedestal****************",len(self.list_pedestal))
4215
4216 if self.online:
4217 print("Enable Online")
4218 self.setup_online(dataOut)
4219 else:
4220 self.setup_offline(list_pedestal=self.list_pedestal,list_adq=self.list_adq)
4221
4222 def setNextFileP(self,dataOut):
4223 if self.online:
4224 data_pedestal = self.setNextFileonline()
4225 else:
4226 data_pedestal = self.setNextFileoffline()
4227
4228 return data_pedestal
4229
4230
4231 def setNextFileoffline(self):
4232 tmp =0
4233 for j in range(self.blocksPerfile):
4234 #print("NUMERO DEL BLOQUE:",j)
4235 iterador = self.nro_key_p +self.f_a_p*(j-tmp)
4236 #print("iterador",iterador)
4237 if iterador < self.n_Muestras_p:
4238 self.nro_file = self.nro_file
4239 else:
4240 self.nro_file = self.nro_file+1
4241 dif = self.blocksPerfile-(self.nro_key_p+self.f_a_p*(j-tmp-1))
4242 tmp = j
4243 self.nro_key_p= self.f_a_p-dif
4244 iterador = self.nro_key_p
4245 #print("nro_file",self.nro_file)
4246 try:
4247 ff_pedestal = self.list_pedestal[self.nro_file]
4248 except:
4249 return numpy.ones(self.blocksPerfile)*numpy.nan
4250
4251 angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth")
4252 self.angulo_adq[j]= angulo[iterador]
4253
4254 return self.angulo_adq
4255
4256 def setNextFileonline(self):
4257 tmp = 0
4258 self.nTries_p = 3
4259 self.delay = 3
4260 ready = 1
4261 for j in range(self.blocksPerfile):
4262 iterador = self.nro_key_p +self.f_a_p*(j-tmp)
4263 if iterador < self.n_Muestras_p:
4264 self.nro_file = self.nro_file
4265 else:
4266 self.nro_file = self.nro_file+1
4267 dif = self.blocksPerfile-(self.nro_key_p+self.f_a_p*(j-tmp-1))
4268 tmp = j
4269 self.nro_key_p= self.f_a_p-dif
4270 iterador = self.nro_key_p
4271 print("nro_file---------------- :",self.nro_file)
4272 try:
4273 # update list_pedestal
4274 self.list_pedestal = self.getfirstFilefromPath(path=self.path_ped,meta="PE",ext=".hdf5")
4275 ff_pedestal = self.list_pedestal[self.nro_file]
4276 except:
4277 ff_pedestal = None
4278 ready = 0
4279 for nTries_p in range(self.nTries_p):
4280 try:
4281 # update list_pedestal
4282 self.list_pedestal = self.getfirstFilefromPath(path=self.path_ped,meta="PE",ext=".hdf5")
4283 ff_pedestal = self.list_pedestal[self.nro_file]
4284 except:
4285 ff_pedestal = None
4286 if ff_pedestal is not None:
4287 ready=1
4288 break
4289 log.warning("Waiting %0.2f sec for the next file: \"%s\" , try %02d ..." % (self.delay, self.nro_file, nTries_p + 1))
4290 time.sleep(self.delay)
4291 continue
4292 #return numpy.ones(self.blocksPerfile)*numpy.nan
4293
4294 if ready == 1:
4295 #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth")
4296 angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azi_pos")
4297
4298 else:
4299 print("there is no pedestal file")
4300 angulo = numpy.ones(self.n_Muestras_p)*numpy.nan
4301 self.angulo_adq[j]= angulo[iterador]
4302 print("Angulo",self.angulo_adq)
4303 print("Angulo",len(self.angulo_adq))
4304 #self.nro_key_p=iterador + self.f_a_p
4305 #if self.nro_key_p< self.n_Muestras_p:
4306 # self.nro_file = self.nro_file
4307 #else:
4308 # self.nro_file = self.nro_file+1
4309 # self.nro_key_p= self.nro_key_p
4310 return self.angulo_adq
4311
4312
4313 def run(self, dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online):
4314 if not self.isConfig:
4315 self.setup( dataOut, path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online)
4316 self.isConfig = True
4317
4318 dataOut.flagNoData = True
4319 #print("profIndex",self.__profIndex)
4320
4321 if self.__profIndex==0:
4322 angulo_adq = self.setNextFileP(dataOut)
4323 dataOut.azimuth = angulo_adq
4324 self.__dataReady = True
4325 self.__profIndex += 1
4326 if self.__profIndex== blocksPerfile:
4327 self.__profIndex = 0
4328 if self.__dataReady:
4329 #print(self.__profIndex,dataOut.azimuth[:10])
4330 dataOut.flagNoData = False
4331 return dataOut
4332
4333
4334 class Block360(Operation):
4335 '''
4336 '''
4337 isConfig = False
4338 __profIndex = 0
4339 __initime = None
4340 __lastdatatime = None
4341 __buffer = None
4342 __dataReady = False
4343 n = None
4344 __nch = 0
4345 __nHeis = 0
4346 index = 0
4347
4348 def __init__(self,**kwargs):
4349 Operation.__init__(self,**kwargs)
4350
4351 def setup(self, dataOut, n = None):
4352 '''
4353 n= Numero de PRF's de entrada
4354 '''
4355 self.__initime = None
4356 self.__lastdatatime = 0
4357 self.__dataReady = False
4358 self.__buffer = 0
4359 self.__buffer_1D = 0
4360 self.__profIndex = 0
4361 self.index = 0
4362 self.__nch = dataOut.nChannels
4363 self.__nHeis = dataOut.nHeights
4364 ##print("ELVALOR DE n es:", n)
4365 if n == None:
4366 raise ValueError("n should be specified.")
4367
4368 if n != None:
4369 if n<1:
4370 print("n should be greater than 2")
4371 raise ValueError("n should be greater than 2")
4372
4373 self.n = n
4374 #print("nHeights")
4375 self.__buffer = numpy.zeros(( dataOut.nChannels,n, dataOut.nHeights))
4376 self.__buffer2= numpy.zeros(n)
4377
4378 def putData(self,data):
4379 '''
4380 Add a profile to he __buffer and increase in one the __profiel Index
4381 '''
4382 #print("line 4049",data.dataPP_POW.shape,data.dataPP_POW[:10])
4383 #print("line 4049",data.azimuth.shape,data.azimuth)
4384 self.__buffer[:,self.__profIndex,:]= data.dataPP_POW
4385 #print("me casi",self.index,data.azimuth[self.index])
4386 #print(self.__profIndex, self.index , data.azimuth[self.index] )
4387 #print("magic",data.profileIndex)
4388 #print(data.azimuth[self.index])
4389 #print("index",self.index)
4390
4391 self.__buffer2[self.__profIndex] = data.azimuth[self.index]
4392 #print("q pasa")
4393 self.index+=1
4394 #print("index",self.index,data.azimuth[:10])
4395 self.__profIndex += 1
4396 return #················· Remove DC···································
4397
4398 def pushData(self,data):
4399 '''
4400 Return the PULSEPAIR and the profiles used in the operation
4401 Affected : self.__profileIndex
4402 '''
4403 #print("pushData")
4404
4405 data_360 = self.__buffer
4406 data_p = self.__buffer2
4407 n = self.__profIndex
4408
4409 self.__buffer = numpy.zeros((self.__nch, self.n,self.__nHeis))
4410 self.__buffer2 = numpy.zeros(self.n)
4411 self.__profIndex = 0
4412 #print("pushData")
4413 return data_360,n,data_p
4414
4415
4416 def byProfiles(self,dataOut):
4417
4418 self.__dataReady = False
4419 data_360 = None
4420 data_p = None
4421 #print("dataOu",dataOut.dataPP_POW)
4422 self.putData(data=dataOut)
4423 #print("profIndex",self.__profIndex)
4424 if self.__profIndex == self.n:
4425 data_360,n,data_p = self.pushData(data=dataOut)
4426 self.__dataReady = True
4427
4428 return data_360,data_p
4429
4430
4431 def blockOp(self, dataOut, datatime= None):
4432 if self.__initime == None:
4433 self.__initime = datatime
4434 data_360,data_p = self.byProfiles(dataOut)
4435 self.__lastdatatime = datatime
4436
4437 if data_360 is None:
4438 return None, None,None
4439
4440 avgdatatime = self.__initime
4441 deltatime = datatime - self.__lastdatatime
4442 self.__initime = datatime
4443 #print(data_360.shape,avgdatatime,data_p.shape)
4444 return data_360,avgdatatime,data_p
4445
4446 def run(self, dataOut,n = None,**kwargs):
4447
4448 if not self.isConfig:
4449 self.setup(dataOut = dataOut, n = n , **kwargs)
4450 self.index = 0
4451 #print("comova",self.isConfig)
4452 self.isConfig = True
4453 if self.index==dataOut.azimuth.shape[0]:
4454 self.index=0
4455 data_360, avgdatatime,data_p = self.blockOp(dataOut, dataOut.utctime)
4456 dataOut.flagNoData = True
4457
4458 if self.__dataReady:
4459 dataOut.data_360 = data_360 # S
4460 #print("DATAREADY---------------------------------------------")
4461 print("data_360",dataOut.data_360.shape)
4462 dataOut.data_azi = data_p
4463 #print("jroproc_parameters",data_p[0],data_p[-1])#,data_360.shape,avgdatatime)
4464 dataOut.utctime = avgdatatime
4465 dataOut.flagNoData = False
4466 return dataOut
@@ -1287,7 +1287,7 class CombineProfiles(Operation):
1287
1287
1288 return dataOut
1288 return dataOut
1289
1289
1290 class PulsePairVoltage(Operation):
1290 class PulsePair(Operation):
1291 '''
1291 '''
1292 Function PulsePair(Signal Power, Velocity)
1292 Function PulsePair(Signal Power, Velocity)
1293 The real component of Lag[0] provides Intensity Information
1293 The real component of Lag[0] provides Intensity Information
@@ -1324,6 +1324,7 class PulsePairVoltage(Operation):
1324 '''
1324 '''
1325 n= Numero de PRF's de entrada
1325 n= Numero de PRF's de entrada
1326 '''
1326 '''
1327 print("[INICIO]-setup del METODO PULSE PAIR")
1327 self.__initime = None
1328 self.__initime = None
1328 self.__lastdatatime = 0
1329 self.__lastdatatime = 0
1329 self.__dataReady = False
1330 self.__dataReady = False
@@ -1482,6 +1483,7 class PulsePairVoltage(Operation):
1482 dataOut.dataPP_SNR = data_snrPP
1483 dataOut.dataPP_SNR = data_snrPP
1483 dataOut.dataPP_WIDTH = data_specwidth
1484 dataOut.dataPP_WIDTH = data_specwidth
1484 dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo.
1485 dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo.
1486 dataOut.nProfiles = int(dataOut.nProfiles/n)
1485 dataOut.utctime = avgdatatime
1487 dataOut.utctime = avgdatatime
1486 dataOut.flagNoData = False
1488 dataOut.flagNoData = False
1487 return dataOut
1489 return dataOut
@@ -23,17 +23,15 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
23 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
23 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
24 #######################################################################
24 #######################################################################
25 #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman'
25 #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman'
26
26 #path = '/DATA_RM/TEST_INTEGRACION'
27
27 path = '/DATA_RM/TEST_ONLINE'
28 path = '/home/soporte/data_hdf5' #### with clock 35.16 db noise
28 figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG'
29
30 figpath = '/home/soporte/data_hdf5_imag'
31 #remotefolder = "/home/wmaster/graficos"
29 #remotefolder = "/home/wmaster/graficos"
32 #######################################################################
30 #######################################################################
33 ################# RANGO DE PLOTEO######################################
31 ################# RANGO DE PLOTEO######################################
34 #######################################################################
32 #######################################################################
35 dBmin = '30'
33 dBmin = '-5'
36 dBmax = '60'
34 dBmax = '20'
37 xmin = '0'
35 xmin = '0'
38 xmax ='24'
36 xmax ='24'
39 ymin = '0'
37 ymin = '0'
@@ -50,18 +48,18 yesterday = str2.strftime("%Y/%m/%d")
50 #######################################################################
48 #######################################################################
51 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
49 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
52 path=path,
50 path=path,
53 startDate="2019/01/01",#today,
51 startDate="2021/01/01",#today,
54 endDate="2109/12/30",#today,
52 endDate="2021/12/30",#today,
55 startTime='00:00:00',
53 startTime='00:00:00',
56 endTime='23:59:59',
54 endTime='23:59:59',
57 delay=0,
55 delay=0,
58 #set=0,
56 #set=0,
59 online=0,
57 online=0,
60 walk=1,
58 walk=1,
61 ippKm = 1000)
59 ippKm = 60)
62
60
63 opObj11 = readUnitConfObj.addOperation(name='printInfo')
61 opObj11 = readUnitConfObj.addOperation(name='printInfo')
64 opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
62 #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
65 #######################################################################
63 #######################################################################
66 ################ OPERACIONES DOMINIO DEL TIEMPO########################
64 ################ OPERACIONES DOMINIO DEL TIEMPO########################
67 #######################################################################
65 #######################################################################
@@ -72,15 +70,32 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=rea
72 # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1'
70 # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1'
73
71
74 #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency')
72 #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency')
75 #opObj11.addParameter(name='frequency', value='30e6', format='float')
73 #opObj11.addParameter(name='frequency', value='70312500')
74
75 '''
76 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
77 opObj11.addParameter(name='n', value='625', format='int')#10
78 opObj11.addParameter(name='removeDC', value=1, format='int')
79 '''
76
80
77 #opObj10 = procUnitConfObjA.addOperation(name='Scope', optype='external')
81 # Ploteo TEST
82 '''
83 opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')
84 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other')
85 opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other')
86 #opObj11.addParameter(name='xmax', value=8)
87 opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other')
88 '''
89 # OJO SCOPE
90 #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external')
78 #opObj10.addParameter(name='id', value='10', format='int')
91 #opObj10.addParameter(name='id', value='10', format='int')
79 ##opObj10.addParameter(name='xmin', value='0', format='int')
92 ##opObj10.addParameter(name='xmin', value='0', format='int')
80 ##opObj10.addParameter(name='xmax', value='50', format='int')
93 ##opObj10.addParameter(name='xmax', value='50', format='int')
81 #opObj10.addParameter(name='type', value='iq')
94 #opObj10.addParameter(name='type', value='iq')
82 #opObj10.addParameter(name='ymin', value='-5000', format='int')
95 ##opObj10.addParameter(name='ymin', value='-5000', format='int')
83 ##opObj10.addParameter(name='ymax', value='8500', format='int')
96 ##opObj10.addParameter(name='ymax', value='8500', format='int')
97 #opObj11.addParameter(name='save', value=figpath, format='str')
98 #opObj11.addParameter(name='save_period', value=10, format='int')
84
99
85 #opObj10 = procUnitConfObjA.addOperation(name='setH0')
100 #opObj10 = procUnitConfObjA.addOperation(name='setH0')
86 #opObj10.addParameter(name='h0', value='-5000', format='float')
101 #opObj10.addParameter(name='h0', value='-5000', format='float')
@@ -98,55 +113,104 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=rea
98 #opObj11.addParameter(name='n', value='100', format='int')
113 #opObj11.addParameter(name='n', value='100', format='int')
99
114
100 #######################################################################
115 #######################################################################
116 ########## OPERACIONES ParametersProc########################
117 #######################################################################
118 ###procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
119 '''
120
121 opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation')
122 opObj11.addParameter(name='path_ped', value=path_ped)
123 opObj11.addParameter(name='path_adq', value=path_adq)
124 opObj11.addParameter(name='t_Interval_p', value='0.01', format='float')
125 opObj11.addParameter(name='n_Muestras_p', value='100', format='float')
126 opObj11.addParameter(name='blocksPerfile', value='100', format='int')
127 opObj11.addParameter(name='f_a_p', value='25', format='int')
128 opObj11.addParameter(name='online', value='0', format='int')
129
130 opObj11 = procUnitConfObjA.addOperation(name='Block360')
131 opObj11.addParameter(name='n', value='40', format='int')
132
133 opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other')
134 opObj11.addParameter(name='save', value=figpath)
135 opObj11.addParameter(name='save_period', value=1)
136
137
138 '''
139
140 #######################################################################
101 ########## OPERACIONES DOMINIO DE LA FRECUENCIA########################
141 ########## OPERACIONES DOMINIO DE LA FRECUENCIA########################
102 #######################################################################
142 #######################################################################
103 procUnitConfObjSousySpectra = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId())
104 procUnitConfObjSousySpectra.addParameter(name='nFFTPoints', value='100', format='int')
105 procUnitConfObjSousySpectra.addParameter(name='nProfiles', value='100', format='int')
106 #procUnitConfObjSousySpectra.addParameter(name='pairsList', value='(0,0),(1,1),(0,1)', format='pairsList')
107
143
108 #opObj13 = procUnitConfObjSousySpectra.addOperation(name='removeDC')
144 procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId())
145 procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int')
146 procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int')
147
148 procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId())
149 #procUnitConfObjB.addParameter(name='nFFTPoints', value='64', format='int')
150 #procUnitConfObjB.addParameter(name='nProfiles', value='64', format='int')
151 opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other')
152 opObj11.addParameter(name='timeInterval', value='8', format='int')
153
154
155 #procUnitConfObjB.addParameter(name='pairsList', value='(0,0),(1,1),(0,1)', format='pairsList')
156
157 #opObj13 = procUnitConfObjB.addOperation(name='removeDC')
109 #opObj13.addParameter(name='mode', value='2', format='int')
158 #opObj13.addParameter(name='mode', value='2', format='int')
110
159
111 #opObj11 = procUnitConfObjSousySpectra.addOperation(name='IncohInt', optype='other')
160 opObj11 = procUnitConfObjB.addOperation(name='IncohInt', optype='other')
112 #opObj11.addParameter(name='n', value='60', format='float')
161 opObj11.addParameter(name='n', value='8', format='float')
113 #######################################################################
162 #######################################################################
114 ########## PLOTEO DOMINIO DE LA FRECUENCIA#############################
163 ########## PLOTEO DOMINIO DE LA FRECUENCIA#############################
115 #######################################################################
164 #######################################################################
165 #----
166
167 opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot')
168 opObj11.addParameter(name='id', value='10', format='int')
169 opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str')
170 #opObj11.addParameter(name='xmin', value=-100000, format='float')
171 #opObj11.addParameter(name='xmax', value=100000, format='float')
172 #opObj11.addParameter(name='zmin', value=dBmin, format='int')
173 #opObj11.addParameter(name='zmax', value=dBmax, format='int')
174 opObj11.addParameter(name='ymin', value=-20, format='int')
175 opObj11.addParameter(name='ymax', value=50, format='int')
176 opObj11.addParameter(name='showprofile', value='1', format='int')
177 opObj11.addParameter(name='save', value=figpath, format='str')
178 opObj11.addParameter(name='save_period', value=10, format='int')
179
180
116 #SpectraPlot
181 #SpectraPlot
117
182
118 opObj11 = procUnitConfObjSousySpectra.addOperation(name='SpectraPlot', optype='external')
183 opObj11 = procUnitConfObjB.addOperation(name='SpectraPlot', optype='external')
119 opObj11.addParameter(name='id', value='1', format='int')
184 opObj11.addParameter(name='id', value='1', format='int')
120 opObj11.addParameter(name='wintitle', value='Spectra', format='str')
185 opObj11.addParameter(name='wintitle', value='Spectra', format='str')
121 #opObj11.addParameter(name='xmin', value=-0.01, format='float')
186 #opObj11.addParameter(name='xmin', value=-0.01, format='float')
122 #opObj11.addParameter(name='xmax', value=0.01, format='float')
187 #opObj11.addParameter(name='xmax', value=0.01, format='float')
123 #opObj11.addParameter(name='zmin', value=dBmin, format='int')
188 opObj11.addParameter(name='zmin', value=dBmin, format='int')
124 #opObj11.addParameter(name='zmax', value=dBmax, format='int')
189 opObj11.addParameter(name='zmax', value=dBmax, format='int')
125 #opObj11.addParameter(name='ymin', value=ymin, format='int')
190 #opObj11.addParameter(name='ymin', value=ymin, format='int')
126 #opObj11.addParameter(name='ymax', value=ymax, format='int')
191 #opObj11.addParameter(name='ymax', value=ymax, format='int')
127 opObj11.addParameter(name='showprofile', value='1', format='int')
192 opObj11.addParameter(name='showprofile', value='1', format='int')
128 opObj11.addParameter(name='save', value=figpath, format='str')
193 opObj11.addParameter(name='save', value=figpath, format='str')
129 opObj11.addParameter(name='save_period', value=10, format='int')
194 opObj11.addParameter(name='save_period', value=10, format='int')
130
195
131
132 #RTIPLOT
196 #RTIPLOT
133
197
134 opObj11 = procUnitConfObjSousySpectra.addOperation(name='RTIPlot', optype='external')
198 opObj11 = procUnitConfObjB.addOperation(name='RTIPlot', optype='external')
135 opObj11.addParameter(name='id', value='2', format='int')
199 opObj11.addParameter(name='id', value='2', format='int')
136 opObj11.addParameter(name='wintitle', value='RTIPlot', format='str')
200 opObj11.addParameter(name='wintitle', value='RTIPlot', format='str')
137 #opObj11.addParameter(name='zmin', value=dBmin, format='int')
201 opObj11.addParameter(name='zmin', value=dBmin, format='int')
138 #opObj11.addParameter(name='zmax', value=dBmax, format='int')
202 opObj11.addParameter(name='zmax', value=dBmax, format='int')
139 #opObj11.addParameter(name='ymin', value=ymin, format='int')
203 #opObj11.addParameter(name='ymin', value=ymin, format='int')
140 #opObj11.addParameter(name='ymax', value=ymax, format='int')
204 #opObj11.addParameter(name='ymax', value=ymax, format='int')
141 opObj11.addParameter(name='xmin', value=0, format='int')
205 #opObj11.addParameter(name='xmin', value=15, format='int')
142 opObj11.addParameter(name='xmax', value=23, format='int')
206 #opObj11.addParameter(name='xmax', value=16, format='int')
143
207
144 opObj11.addParameter(name='showprofile', value='1', format='int')
208 opObj11.addParameter(name='showprofile', value='1', format='int')
145 opObj11.addParameter(name='save', value=figpath, format='str')
209 opObj11.addParameter(name='save', value=figpath, format='str')
146 opObj11.addParameter(name='save_period', value=10, format='int')
210 opObj11.addParameter(name='save_period', value=10, format='int')
147
211
148
212
149 # opObj11 = procUnitConfObjSousySpectra.addOperation(name='CrossSpectraPlot', optype='other')
213 # opObj11 = procUnitConfObjB.addOperation(name='CrossSpectraPlot', optype='other')
150 # opObj11.addParameter(name='id', value='3', format='int')
214 # opObj11.addParameter(name='id', value='3', format='int')
151 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
215 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
152 # opObj11.addParameter(name='ymin', value=ymin, format='int')
216 # opObj11.addParameter(name='ymin', value=ymin, format='int')
@@ -158,7 +222,7 opObj11.addParameter(name='save_period', value=10, format='int')
158 # opObj11.addParameter(name='save', value=0, format='bool')
222 # opObj11.addParameter(name='save', value=0, format='bool')
159 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList')
223 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList')
160 # #
224 # #
161 # opObj11 = procUnitConfObjSousySpectra.addOperation(name='CoherenceMap', optype='other')
225 # opObj11 = procUnitConfObjB.addOperation(name='CoherenceMap', optype='other')
162 # opObj11.addParameter(name='id', value='4', format='int')
226 # opObj11.addParameter(name='id', value='4', format='int')
163 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
227 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
164 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
228 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
@@ -168,16 +232,17 opObj11.addParameter(name='save_period', value=10, format='int')
168 # opObj11.addParameter(name='save', value=0, format='bool')
232 # opObj11.addParameter(name='save', value=0, format='bool')
169 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList')
233 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList')
170 #
234 #
235
236 '''
171 #######################################################################
237 #######################################################################
172 ############### UNIDAD DE ESCRITURA ###################################
238 ############### UNIDAD DE ESCRITURA ###################################
173 #######################################################################
239 #######################################################################
174 #opObj11 = procUnitConfObjSousySpectra.addOperation(name='SpectraWriter', optype='other')
240 #opObj11 = procUnitConfObjB.addOperation(name='SpectraWriter', optype='other')
175 #opObj11.addParameter(name='path', value=wr_path)
241 #opObj11.addParameter(name='path', value=wr_path)
176 #opObj11.addParameter(name='blocksPerFile', value='50', format='int')
242 #opObj11.addParameter(name='blocksPerFile', value='50', format='int')
177 print ("Escribiendo el archivo XML")
243 print ("Escribiendo el archivo XML")
178 print ("Leyendo el archivo XML")
244 print ("Leyendo el archivo XML")
179
245 '''
180
246
181
247
182 controllerObj.start()
248 controllerObj.start()
183
@@ -2,6 +2,18 import os, sys
2 import datetime
2 import datetime
3 import time
3 import time
4 from schainpy.controller import Project
4 from schainpy.controller import Project
5 '''
6 NOTA:
7 Este script de prueba.
8 - Unidad del lectura 'SimulatorReader'.
9 - Unidad de procesamiento VoltageProc
10 - Unidad de procesamiento SpectraProc (profileIndex no esta en metadata porque se queda en voltage.)
11 - Operacion removeDC.
12 - Unidad de procesamiento ParametersProc
13 - Operacion SpectralMoments
14 - Operacion SpectralMomentsPlot
15 - Unidad de escrituda 'HDFWriter'.
16 '''
5
17
6 desc = "USRP_test"
18 desc = "USRP_test"
7 filename = "USRP_processing.xml"
19 filename = "USRP_processing.xml"
@@ -10,8 +22,8 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
10
22
11 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
23 ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA #############
12 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
24 ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB#################
13 path = '/home/alex/Downloads/test_rawdata'
25 path = '/home/soporte/Downloads/RAWDATA'
14 figpath = '/home/alex/Downloads/hdf5_test'
26 figpath = '/home/soporte/Downloads/IMAGE'
15 ######################## UNIDAD DE LECTURA#############################
27 ######################## UNIDAD DE LECTURA#############################
16 '''
28 '''
17 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
29 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
@@ -63,20 +75,19 procUnitConfObjC= controllerObj.addProcUnit(datatype='ParametersProc',inputId=pr
63 procUnitConfObjC.addOperation(name='SpectralMoments')
75 procUnitConfObjC.addOperation(name='SpectralMoments')
64 #opObj11 = procUnitConfObjC.addOperation(name='PowerPlot')
76 #opObj11 = procUnitConfObjC.addOperation(name='PowerPlot')
65
77
66 '''
78
67 opObj11 = procUnitConfObjC.addOperation(name='SpectralMomentsPlot')
79 opObj11 = procUnitConfObjC.addOperation(name='SpectralMomentsPlot')
68 #opObj11.addParameter(name='xmin', value=14)
80 #opObj11.addParameter(name='xmin', value=14)
69 #opObj11.addParameter(name='xmax', value=15)
81 #opObj11.addParameter(name='xmax', value=15)
70 #opObj11.addParameter(name='save', value=figpath)
82 opObj11.addParameter(name='save', value=figpath)
71 opObj11.addParameter(name='showprofile', value=1)
83 opObj11.addParameter(name='showprofile', value=1)
72 #opObj11.addParameter(name='save_period', value=10)
84 opObj11.addParameter(name='save_period', value=10)
73 '''
74
85
75 opObj10 = procUnitConfObjC.addOperation(name='ParameterWriter')
86 opObj10 = procUnitConfObjC.addOperation(name='HDFWriter')
76 opObj10.addParameter(name='path',value=figpath)
87 opObj10.addParameter(name='path',value=path)
77 #opObj10.addParameter(name='mode',value=0)
88 #opObj10.addParameter(name='mode',value=0)
78 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
89 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
79 opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list')
90 opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex
80 opObj10.addParameter(name='dataList',value='data_POW,data_DOP,data_WIDTH,data_SNR')#,format='list'
91 opObj10.addParameter(name='dataList',value='data_pow,data_dop,utctime',format='list')#,format='list'
81
92
82 controllerObj.start()
93 controllerObj.start()
@@ -2,7 +2,7 import os,sys
2 import datetime
2 import datetime
3 import time
3 import time
4 from schainpy.controller import Project
4 from schainpy.controller import Project
5 path = '/home/alex/Downloads/NEW_WR2/spc16removeDC'
5 path = '/home/soporte/Downloads/RAWDATA_PP'
6 figpath = path
6 figpath = path
7 desc = "Simulator Test"
7 desc = "Simulator Test"
8
8
@@ -63,11 +63,11 opObj11.addParameter(name='removeDC', value=1, format='int')
63 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
63 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
64
64
65
65
66 opObj10 = procUnitConfObjB.addOperation(name='ParameterWriter')
66 opObj10 = procUnitConfObjB.addOperation(name='HDFWriter')
67 opObj10.addParameter(name='path',value=figpath)
67 opObj10.addParameter(name='path',value=figpath)
68 #opObj10.addParameter(name='mode',value=0)
68 #opObj10.addParameter(name='mode',value=0)
69 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
69 opObj10.addParameter(name='blocksPerFile',value='100',format='int')
70 opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list')
70 opObj10.addParameter(name='metadataList',value='utctimeInit,paramInterval,profileIndex,heightList,flagDataAsBlock',format='list')
71 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH')#,format='list'
71 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH,utctime',format='list')#,format='list'
72
72
73 controllerObj.start()
73 controllerObj.start()
General Comments 0
You need to be logged in to leave comments. Login now