The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,122 | |||||
|
1 | # Ing. AVP | |||
|
2 | # 04/01/2022 | |||
|
3 | # ARCHIVO DE LECTURA | |||
|
4 | #---- DATA RHI --- 23 DE NOVIEMBRE DEL 2021 --- 23/11/2021--- | |||
|
5 | #---- PEDESTAL ---------------------------------------------- | |||
|
6 | #------- HORA 143826 /DATA_RM/TEST_PEDESTAL/P20211123-143826 14:38-15:10 | |||
|
7 | #---- RADAR ---------------------------------------------- | |||
|
8 | #------- 14:26-15:00 | |||
|
9 | #------- /DATA_RM/DRONE/2MHZ_5V_ELEVACION/ | |||
|
10 | #------- /DATA_RM/DRONE/2MHZ_5V_ELEVACION/ch0/2021-11-23T19-00-00 | |||
|
11 | ||||
|
12 | import os, sys | |||
|
13 | import datetime | |||
|
14 | import time | |||
|
15 | import numpy | |||
|
16 | from ext_met import getfirstFilefromPath,getDatavaluefromDirFilename | |||
|
17 | from schainpy.controller import Project | |||
|
18 | #----------------------------------------------------------------------------------------- | |||
|
19 | print("[SETUP]-RADAR METEOROLOGICO-") | |||
|
20 | path_ped = "/DATA_RM/TEST_PEDESTAL/P20211123-143826" | |||
|
21 | print("PATH PEDESTAL :",path_ped) | |||
|
22 | path_adq = "/DATA_RM/DRONE/2MHZ_5V_ELEVACION/" | |||
|
23 | print("PATH DATA :",path_adq) | |||
|
24 | figpath_pp_rti = "/home/soporte/Pictures/TEST_PP_RHI" | |||
|
25 | print("PATH PP RTI :",figpath_pp_rti) | |||
|
26 | figpath_pp_rhi = "/home/soporte/Pictures/TEST_PP_RHI" | |||
|
27 | print("PATH PP RHI :",figpath_pp_rhi) | |||
|
28 | path_pp_save_int = "/DATA_RM/TEST_SAVE_PP_INT_RHI" | |||
|
29 | print("PATH SAVE PP INT :",path_pp_save_int) | |||
|
30 | print(" ") | |||
|
31 | #------------------------------------------------------------------------------------------- | |||
|
32 | print("SELECCIONAR MODO: PPI (0) O RHI (1)") | |||
|
33 | mode_wr = 1 | |||
|
34 | if mode_wr==0: | |||
|
35 | print("[ ON ] MODE PPI") | |||
|
36 | list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5") | |||
|
37 | ff_pedestal = list_ped[2] | |||
|
38 | azi_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="azi_vel") | |||
|
39 | V = round(azi_vel[0]) | |||
|
40 | print("VELOCIDAD AZI :", int(numpy.mean(azi_vel)),"Β°/seg") | |||
|
41 | else: | |||
|
42 | print("[ ON ] MODE RHI") | |||
|
43 | list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5") | |||
|
44 | ff_pedestal = list_ped[2] | |||
|
45 | ele_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="ele_vel") | |||
|
46 | V = round(ele_vel[0]) | |||
|
47 | V = 10.0 | |||
|
48 | print("VELOCIDAD ELE :", int(numpy.mean(ele_vel)),"Β°/seg") | |||
|
49 | print(" ") | |||
|
50 | #--------------------------------------------------------------------------------------- | |||
|
51 | print("SELECCIONAR MODO: PULSE PAIR (0) O FREQUENCY (1)") | |||
|
52 | mode_proc = 0 | |||
|
53 | if mode_proc==0: | |||
|
54 | print("[ ON ] MODE PULSEPAIR") | |||
|
55 | else: | |||
|
56 | print("[ ON ] MODE FREQUENCY") | |||
|
57 | ipp = 60.0 | |||
|
58 | print("IPP(Km.) : %1.2f"%ipp) | |||
|
59 | ipp_sec = (ipp*1.0e3/150.0)*1.0e-6 | |||
|
60 | print("IPP(useg.) : %1.2f"%(ipp_sec*(1.0e6))) | |||
|
61 | VEL=V | |||
|
62 | n= int(1/(VEL*ipp_sec)) | |||
|
63 | print("NΒ° Profiles : ", n) | |||
|
64 | #-------------------------------------------- | |||
|
65 | plot_rti = 0 | |||
|
66 | plot_rhi = 1 | |||
|
67 | integration = 1 | |||
|
68 | save = 0 | |||
|
69 | #---------------------------RANGO DE PLOTEO---------------------------------- | |||
|
70 | dBmin = '1' | |||
|
71 | dBmax = '85' | |||
|
72 | xmin = '17' | |||
|
73 | xmax = '17.25' | |||
|
74 | ymin = '0' | |||
|
75 | ymax = '600' | |||
|
76 | #---------------------------------------------------------------------------- | |||
|
77 | time.sleep(3) | |||
|
78 | #---------------------SIGNAL CHAIN ------------------------------------ | |||
|
79 | desc = "USRP_WEATHER_RADAR" | |||
|
80 | filename = "USRP_processing.xml" | |||
|
81 | controllerObj = Project() | |||
|
82 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |||
|
83 | #---------------------UNIDAD DE LECTURA-------------------------------- | |||
|
84 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', | |||
|
85 | path=path_adq, | |||
|
86 | startDate="2021/11/10",#today, | |||
|
87 | endDate="2021/12/30",#today, | |||
|
88 | startTime='17:10:25', | |||
|
89 | endTime='23:59:59', | |||
|
90 | delay=0, | |||
|
91 | #set=0, | |||
|
92 | online=0, | |||
|
93 | walk=1, | |||
|
94 | ippKm=ipp) | |||
|
95 | ||||
|
96 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc',inputId=readUnitConfObj.getId()) | |||
|
97 | ||||
|
98 | opObj11 = procUnitConfObjA.addOperation(name='selectHeights') | |||
|
99 | opObj11.addParameter(name='minIndex', value='1', format='int') | |||
|
100 | # opObj11.addParameter(name='maxIndex', value='10000', format='int') | |||
|
101 | opObj11.addParameter(name='maxIndex', value='400', format='int') | |||
|
102 | ||||
|
103 | if mode_proc==0: | |||
|
104 | opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') | |||
|
105 | opObj11.addParameter(name='n', value=int(n), format='int') | |||
|
106 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) | |||
|
107 | ||||
|
108 | if integration==1: | |||
|
109 | opObj11 = procUnitConfObjB.addOperation(name='PedestalInformation') | |||
|
110 | opObj11.addParameter(name='path_ped', value=path_ped) | |||
|
111 | opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') | |||
|
112 | ||||
|
113 | if plot_rhi==1: | |||
|
114 | opObj11 = procUnitConfObjB.addOperation(name='Block360') | |||
|
115 | opObj11.addParameter(name='n', value='10', format='int') | |||
|
116 | opObj11.addParameter(name='mode', value=mode_proc, format='int') | |||
|
117 | # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 | |||
|
118 | opObj11= procUnitConfObjB.addOperation(name='WeatherRHIPlot',optype='other') | |||
|
119 | opObj11.addParameter(name='save', value=figpath_pp_rhi) | |||
|
120 | opObj11.addParameter(name='save_period', value=1) | |||
|
121 | ||||
|
122 | controllerObj.start() |
@@ -0,0 +1,57 | |||||
|
1 | import numpy as np | |||
|
2 | import matplotlib.pyplot as plt | |||
|
3 | import wradlib as wrl | |||
|
4 | import warnings | |||
|
5 | # libreia nueva | |||
|
6 | from mpl_toolkits.axisartist.grid_finder import FixedLocator, DictFormatter | |||
|
7 | warnings.filterwarnings('ignore') | |||
|
8 | # lectura de gaMIC hdf5 file | |||
|
9 | filename = wrl.util.get_wradlib_data_file("/home/soporte/Downloads/2014-06-09--185000.rhi.mvol") | |||
|
10 | data1, metadata = wrl.io.read_gamic_hdf5(filename) | |||
|
11 | print(data1) | |||
|
12 | data1 = data1['SCAN0']['ZH']['data'] | |||
|
13 | print(data1) | |||
|
14 | print("SHAPE Data",np.array(data1).shape) | |||
|
15 | r = metadata['SCAN0']['r'] | |||
|
16 | print("r",r) | |||
|
17 | print("longitud r",len(r)) | |||
|
18 | th = metadata['SCAN0']['el'] | |||
|
19 | print("th",th) | |||
|
20 | print("longitud th",len(th)) | |||
|
21 | az = metadata['SCAN0']['az'] | |||
|
22 | print("az",az) | |||
|
23 | site = (metadata['VOL']['Longitude'], metadata['VOL']['Latitude'], | |||
|
24 | metadata['VOL']['Height']) | |||
|
25 | ||||
|
26 | print("Longitud,Latitud,Altura",site) | |||
|
27 | ma1 = np.array(data1) | |||
|
28 | ''' | |||
|
29 | mask_ind = np.where(data1 <= np.nanmin(data1)) | |||
|
30 | data1[mask_ind] = np.nan | |||
|
31 | ma1 = np.ma.array(data1, mask=np.isnan(data1)) | |||
|
32 | ''' | |||
|
33 | #cgax, pm = wrl.vis.plot_rhi(ma1,r=r,th=th,rf=1e3) | |||
|
34 | fig = plt.figure(figsize=(10,8)) | |||
|
35 | cgax, pm = wrl.vis.plot_rhi(ma1,r=r,th=th,rf=1e3,fig=fig, ax=111,proj='cg') | |||
|
36 | caax = cgax.parasites[0] | |||
|
37 | paax = cgax.parasites[1] | |||
|
38 | cgax.set_ylim(0, 14) | |||
|
39 | #caax = cgax.parasites[0] | |||
|
40 | #paax = cgax.parasites[1] | |||
|
41 | #cgax, pm = wrl.vis.plot_rhi(ma1, r=r, th=th, rf=1e3, fig=fig, ax=111, proj='cg') | |||
|
42 | txt = plt.title('Simple RHI',y=1.05) | |||
|
43 | #cbar = plt.gcf().colorbar(pm, pad=0.05, ax=paax) | |||
|
44 | cbar = plt.gcf().colorbar(pm, pad=0.05) | |||
|
45 | cbar.set_label('reflectivity [dBZ]') | |||
|
46 | caax.set_xlabel('x_range [km]') | |||
|
47 | caax.set_ylabel('y_range [km]') | |||
|
48 | plt.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',ha='right') | |||
|
49 | gh = cgax.get_grid_helper() | |||
|
50 | ||||
|
51 | # set theta to some nice values | |||
|
52 | locs = [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., | |||
|
53 | 15., 16., 17., 18., 20., 22., 25., 30., 35., 40., 50., 60., 70., 80., 90.] | |||
|
54 | gh.grid_finder.grid_locator1 = FixedLocator(locs) | |||
|
55 | gh.grid_finder.tick_formatter1 = DictFormatter(dict([(i, r"${0:.0f}^\circ$".format(i)) for i in locs])) | |||
|
56 | ||||
|
57 | plt.show() |
@@ -1,687 +1,707 | |||||
1 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 |
|
4 | |||
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 |
|
8 | # libreria wradlib | |
9 | import wradlib as wrl |
|
9 | import wradlib as wrl | |
10 |
|
10 | |||
11 | EARTH_RADIUS = 6.3710e3 |
|
11 | EARTH_RADIUS = 6.3710e3 | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | def ll2xy(lat1, lon1, lat2, lon2): |
|
14 | def ll2xy(lat1, lon1, lat2, lon2): | |
15 |
|
15 | |||
16 | p = 0.017453292519943295 |
|
16 | p = 0.017453292519943295 | |
17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ |
|
17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ | |
18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 |
|
18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 | |
19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) |
|
19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) | |
20 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) |
|
20 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) | |
21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) |
|
21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) | |
22 | theta = -theta + numpy.pi/2 |
|
22 | theta = -theta + numpy.pi/2 | |
23 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
23 | return r*numpy.cos(theta), r*numpy.sin(theta) | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | def km2deg(km): |
|
26 | def km2deg(km): | |
27 | ''' |
|
27 | ''' | |
28 | Convert distance in km to degrees |
|
28 | Convert distance in km to degrees | |
29 | ''' |
|
29 | ''' | |
30 |
|
30 | |||
31 | return numpy.rad2deg(km/EARTH_RADIUS) |
|
31 | return numpy.rad2deg(km/EARTH_RADIUS) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 |
|
34 | |||
35 | class SpectralMomentsPlot(SpectraPlot): |
|
35 | class SpectralMomentsPlot(SpectraPlot): | |
36 | ''' |
|
36 | ''' | |
37 | Plot for Spectral Moments |
|
37 | Plot for Spectral Moments | |
38 | ''' |
|
38 | ''' | |
39 | CODE = 'spc_moments' |
|
39 | CODE = 'spc_moments' | |
40 | # colormap = 'jet' |
|
40 | # colormap = 'jet' | |
41 | # plot_type = 'pcolor' |
|
41 | # plot_type = 'pcolor' | |
42 |
|
42 | |||
43 | class DobleGaussianPlot(SpectraPlot): |
|
43 | class DobleGaussianPlot(SpectraPlot): | |
44 | ''' |
|
44 | ''' | |
45 | Plot for Double Gaussian Plot |
|
45 | Plot for Double Gaussian Plot | |
46 | ''' |
|
46 | ''' | |
47 | CODE = 'gaussian_fit' |
|
47 | CODE = 'gaussian_fit' | |
48 | # colormap = 'jet' |
|
48 | # colormap = 'jet' | |
49 | # plot_type = 'pcolor' |
|
49 | # plot_type = 'pcolor' | |
50 |
|
50 | |||
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): |
|
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): | |
52 | ''' |
|
52 | ''' | |
53 | Plot SpectraCut with Double Gaussian Fit |
|
53 | Plot SpectraCut with Double Gaussian Fit | |
54 | ''' |
|
54 | ''' | |
55 | CODE = 'cut_gaussian_fit' |
|
55 | CODE = 'cut_gaussian_fit' | |
56 |
|
56 | |||
57 | class SnrPlot(RTIPlot): |
|
57 | class SnrPlot(RTIPlot): | |
58 | ''' |
|
58 | ''' | |
59 | Plot for SNR Data |
|
59 | Plot for SNR Data | |
60 | ''' |
|
60 | ''' | |
61 |
|
61 | |||
62 | CODE = 'snr' |
|
62 | CODE = 'snr' | |
63 | colormap = 'jet' |
|
63 | colormap = 'jet' | |
64 |
|
64 | |||
65 | def update(self, dataOut): |
|
65 | def update(self, dataOut): | |
66 |
|
66 | |||
67 | data = { |
|
67 | data = { | |
68 | 'snr': 10*numpy.log10(dataOut.data_snr) |
|
68 | 'snr': 10*numpy.log10(dataOut.data_snr) | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | return data, {} |
|
71 | return data, {} | |
72 |
|
72 | |||
73 | class DopplerPlot(RTIPlot): |
|
73 | class DopplerPlot(RTIPlot): | |
74 | ''' |
|
74 | ''' | |
75 | Plot for DOPPLER Data (1st moment) |
|
75 | Plot for DOPPLER Data (1st moment) | |
76 | ''' |
|
76 | ''' | |
77 |
|
77 | |||
78 | CODE = 'dop' |
|
78 | CODE = 'dop' | |
79 | colormap = 'jet' |
|
79 | colormap = 'jet' | |
80 |
|
80 | |||
81 | def update(self, dataOut): |
|
81 | def update(self, dataOut): | |
82 |
|
82 | |||
83 | data = { |
|
83 | data = { | |
84 | 'dop': 10*numpy.log10(dataOut.data_dop) |
|
84 | 'dop': 10*numpy.log10(dataOut.data_dop) | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | return data, {} |
|
87 | return data, {} | |
88 |
|
88 | |||
89 | class PowerPlot(RTIPlot): |
|
89 | class PowerPlot(RTIPlot): | |
90 | ''' |
|
90 | ''' | |
91 | Plot for Power Data (0 moment) |
|
91 | Plot for Power Data (0 moment) | |
92 | ''' |
|
92 | ''' | |
93 |
|
93 | |||
94 | CODE = 'pow' |
|
94 | CODE = 'pow' | |
95 | colormap = 'jet' |
|
95 | colormap = 'jet' | |
96 |
|
96 | |||
97 | def update(self, dataOut): |
|
97 | def update(self, dataOut): | |
98 | data = { |
|
98 | data = { | |
99 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) |
|
99 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) | |
100 | } |
|
100 | } | |
101 | return data, {} |
|
101 | return data, {} | |
102 |
|
102 | |||
103 | class SpectralWidthPlot(RTIPlot): |
|
103 | class SpectralWidthPlot(RTIPlot): | |
104 | ''' |
|
104 | ''' | |
105 | Plot for Spectral Width Data (2nd moment) |
|
105 | Plot for Spectral Width Data (2nd moment) | |
106 | ''' |
|
106 | ''' | |
107 |
|
107 | |||
108 | CODE = 'width' |
|
108 | CODE = 'width' | |
109 | colormap = 'jet' |
|
109 | colormap = 'jet' | |
110 |
|
110 | |||
111 | def update(self, dataOut): |
|
111 | def update(self, dataOut): | |
112 |
|
112 | |||
113 | data = { |
|
113 | data = { | |
114 | 'width': dataOut.data_width |
|
114 | 'width': dataOut.data_width | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | return data, {} |
|
117 | return data, {} | |
118 |
|
118 | |||
119 | class SkyMapPlot(Plot): |
|
119 | class SkyMapPlot(Plot): | |
120 | ''' |
|
120 | ''' | |
121 | Plot for meteors detection data |
|
121 | Plot for meteors detection data | |
122 | ''' |
|
122 | ''' | |
123 |
|
123 | |||
124 | CODE = 'param' |
|
124 | CODE = 'param' | |
125 |
|
125 | |||
126 | def setup(self): |
|
126 | def setup(self): | |
127 |
|
127 | |||
128 | self.ncols = 1 |
|
128 | self.ncols = 1 | |
129 | self.nrows = 1 |
|
129 | self.nrows = 1 | |
130 | self.width = 7.2 |
|
130 | self.width = 7.2 | |
131 | self.height = 7.2 |
|
131 | self.height = 7.2 | |
132 | self.nplots = 1 |
|
132 | self.nplots = 1 | |
133 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
133 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
134 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
134 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
135 | self.polar = True |
|
135 | self.polar = True | |
136 | self.ymin = -180 |
|
136 | self.ymin = -180 | |
137 | self.ymax = 180 |
|
137 | self.ymax = 180 | |
138 | self.colorbar = False |
|
138 | self.colorbar = False | |
139 |
|
139 | |||
140 | def plot(self): |
|
140 | def plot(self): | |
141 |
|
141 | |||
142 | arrayParameters = numpy.concatenate(self.data['param']) |
|
142 | arrayParameters = numpy.concatenate(self.data['param']) | |
143 | error = arrayParameters[:, -1] |
|
143 | error = arrayParameters[:, -1] | |
144 | indValid = numpy.where(error == 0)[0] |
|
144 | indValid = numpy.where(error == 0)[0] | |
145 | finalMeteor = arrayParameters[indValid, :] |
|
145 | finalMeteor = arrayParameters[indValid, :] | |
146 | finalAzimuth = finalMeteor[:, 3] |
|
146 | finalAzimuth = finalMeteor[:, 3] | |
147 | finalZenith = finalMeteor[:, 4] |
|
147 | finalZenith = finalMeteor[:, 4] | |
148 |
|
148 | |||
149 | x = finalAzimuth * numpy.pi / 180 |
|
149 | x = finalAzimuth * numpy.pi / 180 | |
150 | y = finalZenith |
|
150 | y = finalZenith | |
151 |
|
151 | |||
152 | ax = self.axes[0] |
|
152 | ax = self.axes[0] | |
153 |
|
153 | |||
154 | if ax.firsttime: |
|
154 | if ax.firsttime: | |
155 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] |
|
155 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] | |
156 | else: |
|
156 | else: | |
157 | ax.plot.set_data(x, y) |
|
157 | ax.plot.set_data(x, y) | |
158 |
|
158 | |||
159 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
159 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') | |
160 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
160 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') | |
161 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
161 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
162 | dt2, |
|
162 | dt2, | |
163 | len(x)) |
|
163 | len(x)) | |
164 | self.titles[0] = title |
|
164 | self.titles[0] = title | |
165 |
|
165 | |||
166 |
|
166 | |||
167 | class GenericRTIPlot(Plot): |
|
167 | class GenericRTIPlot(Plot): | |
168 | ''' |
|
168 | ''' | |
169 | Plot for data_xxxx object |
|
169 | Plot for data_xxxx object | |
170 | ''' |
|
170 | ''' | |
171 |
|
171 | |||
172 | CODE = 'param' |
|
172 | CODE = 'param' | |
173 | colormap = 'viridis' |
|
173 | colormap = 'viridis' | |
174 | plot_type = 'pcolorbuffer' |
|
174 | plot_type = 'pcolorbuffer' | |
175 |
|
175 | |||
176 | def setup(self): |
|
176 | def setup(self): | |
177 | self.xaxis = 'time' |
|
177 | self.xaxis = 'time' | |
178 | self.ncols = 1 |
|
178 | self.ncols = 1 | |
179 | self.nrows = self.data.shape('param')[0] |
|
179 | self.nrows = self.data.shape('param')[0] | |
180 | self.nplots = self.nrows |
|
180 | self.nplots = self.nrows | |
181 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) |
|
181 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) | |
182 |
|
182 | |||
183 | if not self.xlabel: |
|
183 | if not self.xlabel: | |
184 | self.xlabel = 'Time' |
|
184 | self.xlabel = 'Time' | |
185 |
|
185 | |||
186 | self.ylabel = 'Range [km]' |
|
186 | self.ylabel = 'Range [km]' | |
187 | if not self.titles: |
|
187 | if not self.titles: | |
188 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] |
|
188 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] | |
189 |
|
189 | |||
190 | def update(self, dataOut): |
|
190 | def update(self, dataOut): | |
191 |
|
191 | |||
192 | data = { |
|
192 | data = { | |
193 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) |
|
193 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | meta = {} |
|
196 | meta = {} | |
197 |
|
197 | |||
198 | return data, meta |
|
198 | return data, meta | |
199 |
|
199 | |||
200 | def plot(self): |
|
200 | def plot(self): | |
201 | # self.data.normalize_heights() |
|
201 | # self.data.normalize_heights() | |
202 | self.x = self.data.times |
|
202 | self.x = self.data.times | |
203 | self.y = self.data.yrange |
|
203 | self.y = self.data.yrange | |
204 | self.z = self.data['param'] |
|
204 | self.z = self.data['param'] | |
205 | self.z = 10*numpy.log10(self.z) |
|
205 | self.z = 10*numpy.log10(self.z) | |
206 | self.z = numpy.ma.masked_invalid(self.z) |
|
206 | self.z = numpy.ma.masked_invalid(self.z) | |
207 |
|
207 | |||
208 | if self.decimation is None: |
|
208 | if self.decimation is None: | |
209 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
209 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
210 | else: |
|
210 | else: | |
211 | x, y, z = self.fill_gaps(*self.decimate()) |
|
211 | x, y, z = self.fill_gaps(*self.decimate()) | |
212 |
|
212 | |||
213 | for n, ax in enumerate(self.axes): |
|
213 | for n, ax in enumerate(self.axes): | |
214 |
|
214 | |||
215 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
215 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
216 | self.z[n]) |
|
216 | self.z[n]) | |
217 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
217 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
218 | self.z[n]) |
|
218 | self.z[n]) | |
219 |
|
219 | |||
220 | if ax.firsttime: |
|
220 | if ax.firsttime: | |
221 | if self.zlimits is not None: |
|
221 | if self.zlimits is not None: | |
222 | self.zmin, self.zmax = self.zlimits[n] |
|
222 | self.zmin, self.zmax = self.zlimits[n] | |
223 |
|
223 | |||
224 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
224 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
225 | vmin=self.zmin, |
|
225 | vmin=self.zmin, | |
226 | vmax=self.zmax, |
|
226 | vmax=self.zmax, | |
227 | cmap=self.cmaps[n] |
|
227 | cmap=self.cmaps[n] | |
228 | ) |
|
228 | ) | |
229 | else: |
|
229 | else: | |
230 | if self.zlimits is not None: |
|
230 | if self.zlimits is not None: | |
231 | self.zmin, self.zmax = self.zlimits[n] |
|
231 | self.zmin, self.zmax = self.zlimits[n] | |
232 | ax.collections.remove(ax.collections[0]) |
|
232 | ax.collections.remove(ax.collections[0]) | |
233 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
233 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
234 | vmin=self.zmin, |
|
234 | vmin=self.zmin, | |
235 | vmax=self.zmax, |
|
235 | vmax=self.zmax, | |
236 | cmap=self.cmaps[n] |
|
236 | cmap=self.cmaps[n] | |
237 | ) |
|
237 | ) | |
238 |
|
238 | |||
239 |
|
239 | |||
240 | class PolarMapPlot(Plot): |
|
240 | class PolarMapPlot(Plot): | |
241 | ''' |
|
241 | ''' | |
242 | Plot for weather radar |
|
242 | Plot for weather radar | |
243 | ''' |
|
243 | ''' | |
244 |
|
244 | |||
245 | CODE = 'param' |
|
245 | CODE = 'param' | |
246 | colormap = 'seismic' |
|
246 | colormap = 'seismic' | |
247 |
|
247 | |||
248 | def setup(self): |
|
248 | def setup(self): | |
249 | self.ncols = 1 |
|
249 | self.ncols = 1 | |
250 | self.nrows = 1 |
|
250 | self.nrows = 1 | |
251 | self.width = 9 |
|
251 | self.width = 9 | |
252 | self.height = 8 |
|
252 | self.height = 8 | |
253 | self.mode = self.data.meta['mode'] |
|
253 | self.mode = self.data.meta['mode'] | |
254 | if self.channels is not None: |
|
254 | if self.channels is not None: | |
255 | self.nplots = len(self.channels) |
|
255 | self.nplots = len(self.channels) | |
256 | self.nrows = len(self.channels) |
|
256 | self.nrows = len(self.channels) | |
257 | else: |
|
257 | else: | |
258 | self.nplots = self.data.shape(self.CODE)[0] |
|
258 | self.nplots = self.data.shape(self.CODE)[0] | |
259 | self.nrows = self.nplots |
|
259 | self.nrows = self.nplots | |
260 | self.channels = list(range(self.nplots)) |
|
260 | self.channels = list(range(self.nplots)) | |
261 | if self.mode == 'E': |
|
261 | if self.mode == 'E': | |
262 | self.xlabel = 'Longitude' |
|
262 | self.xlabel = 'Longitude' | |
263 | self.ylabel = 'Latitude' |
|
263 | self.ylabel = 'Latitude' | |
264 | else: |
|
264 | else: | |
265 | self.xlabel = 'Range (km)' |
|
265 | self.xlabel = 'Range (km)' | |
266 | self.ylabel = 'Height (km)' |
|
266 | self.ylabel = 'Height (km)' | |
267 | self.bgcolor = 'white' |
|
267 | self.bgcolor = 'white' | |
268 | self.cb_labels = self.data.meta['units'] |
|
268 | self.cb_labels = self.data.meta['units'] | |
269 | self.lat = self.data.meta['latitude'] |
|
269 | self.lat = self.data.meta['latitude'] | |
270 | self.lon = self.data.meta['longitude'] |
|
270 | self.lon = self.data.meta['longitude'] | |
271 | self.xmin, self.xmax = float( |
|
271 | self.xmin, self.xmax = float( | |
272 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) |
|
272 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) | |
273 | self.ymin, self.ymax = float( |
|
273 | self.ymin, self.ymax = float( | |
274 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) |
|
274 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) | |
275 | # self.polar = True |
|
275 | # self.polar = True | |
276 |
|
276 | |||
277 | def plot(self): |
|
277 | def plot(self): | |
278 |
|
278 | |||
279 | for n, ax in enumerate(self.axes): |
|
279 | for n, ax in enumerate(self.axes): | |
280 | data = self.data['param'][self.channels[n]] |
|
280 | data = self.data['param'][self.channels[n]] | |
281 |
|
281 | |||
282 | zeniths = numpy.linspace( |
|
282 | zeniths = numpy.linspace( | |
283 | 0, self.data.meta['max_range'], data.shape[1]) |
|
283 | 0, self.data.meta['max_range'], data.shape[1]) | |
284 | if self.mode == 'E': |
|
284 | if self.mode == 'E': | |
285 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 |
|
285 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 | |
286 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
286 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
287 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( |
|
287 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( | |
288 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) |
|
288 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) | |
289 | x = km2deg(x) + self.lon |
|
289 | x = km2deg(x) + self.lon | |
290 | y = km2deg(y) + self.lat |
|
290 | y = km2deg(y) + self.lat | |
291 | else: |
|
291 | else: | |
292 | azimuths = numpy.radians(self.data.yrange) |
|
292 | azimuths = numpy.radians(self.data.yrange) | |
293 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
293 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
294 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) |
|
294 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) | |
295 | self.y = zeniths |
|
295 | self.y = zeniths | |
296 |
|
296 | |||
297 | if ax.firsttime: |
|
297 | if ax.firsttime: | |
298 | if self.zlimits is not None: |
|
298 | if self.zlimits is not None: | |
299 | self.zmin, self.zmax = self.zlimits[n] |
|
299 | self.zmin, self.zmax = self.zlimits[n] | |
300 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
300 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), | |
301 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
301 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
302 | vmin=self.zmin, |
|
302 | vmin=self.zmin, | |
303 | vmax=self.zmax, |
|
303 | vmax=self.zmax, | |
304 | cmap=self.cmaps[n]) |
|
304 | cmap=self.cmaps[n]) | |
305 | else: |
|
305 | else: | |
306 | if self.zlimits is not None: |
|
306 | if self.zlimits is not None: | |
307 | self.zmin, self.zmax = self.zlimits[n] |
|
307 | self.zmin, self.zmax = self.zlimits[n] | |
308 | ax.collections.remove(ax.collections[0]) |
|
308 | ax.collections.remove(ax.collections[0]) | |
309 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
309 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), | |
310 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
310 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
311 | vmin=self.zmin, |
|
311 | vmin=self.zmin, | |
312 | vmax=self.zmax, |
|
312 | vmax=self.zmax, | |
313 | cmap=self.cmaps[n]) |
|
313 | cmap=self.cmaps[n]) | |
314 |
|
314 | |||
315 | if self.mode == 'A': |
|
315 | if self.mode == 'A': | |
316 | continue |
|
316 | continue | |
317 |
|
317 | |||
318 | # plot district names |
|
318 | # plot district names | |
319 | f = open('/data/workspace/schain_scripts/distrito.csv') |
|
319 | f = open('/data/workspace/schain_scripts/distrito.csv') | |
320 | for line in f: |
|
320 | for line in f: | |
321 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
321 | label, lon, lat = [s.strip() for s in line.split(',') if s] | |
322 | lat = float(lat) |
|
322 | lat = float(lat) | |
323 | lon = float(lon) |
|
323 | lon = float(lon) | |
324 | # ax.plot(lon, lat, '.b', ms=2) |
|
324 | # ax.plot(lon, lat, '.b', ms=2) | |
325 | ax.text(lon, lat, label.decode('utf8'), ha='center', |
|
325 | ax.text(lon, lat, label.decode('utf8'), ha='center', | |
326 | va='bottom', size='8', color='black') |
|
326 | va='bottom', size='8', color='black') | |
327 |
|
327 | |||
328 | # plot limites |
|
328 | # plot limites | |
329 | limites = [] |
|
329 | limites = [] | |
330 | tmp = [] |
|
330 | tmp = [] | |
331 | for line in open('/data/workspace/schain_scripts/lima.csv'): |
|
331 | for line in open('/data/workspace/schain_scripts/lima.csv'): | |
332 | if '#' in line: |
|
332 | if '#' in line: | |
333 | if tmp: |
|
333 | if tmp: | |
334 | limites.append(tmp) |
|
334 | limites.append(tmp) | |
335 | tmp = [] |
|
335 | tmp = [] | |
336 | continue |
|
336 | continue | |
337 | values = line.strip().split(',') |
|
337 | values = line.strip().split(',') | |
338 | tmp.append((float(values[0]), float(values[1]))) |
|
338 | tmp.append((float(values[0]), float(values[1]))) | |
339 | for points in limites: |
|
339 | for points in limites: | |
340 | ax.add_patch( |
|
340 | ax.add_patch( | |
341 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) |
|
341 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) | |
342 |
|
342 | |||
343 | # plot Cuencas |
|
343 | # plot Cuencas | |
344 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): |
|
344 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): | |
345 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) |
|
345 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) | |
346 | values = [line.strip().split(',') for line in f] |
|
346 | values = [line.strip().split(',') for line in f] | |
347 | points = [(float(s[0]), float(s[1])) for s in values] |
|
347 | points = [(float(s[0]), float(s[1])) for s in values] | |
348 | ax.add_patch(Polygon(points, ec='b', fc='none')) |
|
348 | ax.add_patch(Polygon(points, ec='b', fc='none')) | |
349 |
|
349 | |||
350 | # plot grid |
|
350 | # plot grid | |
351 | for r in (15, 30, 45, 60): |
|
351 | for r in (15, 30, 45, 60): | |
352 | ax.add_artist(plt.Circle((self.lon, self.lat), |
|
352 | ax.add_artist(plt.Circle((self.lon, self.lat), | |
353 | km2deg(r), color='0.6', fill=False, lw=0.2)) |
|
353 | km2deg(r), color='0.6', fill=False, lw=0.2)) | |
354 | ax.text( |
|
354 | ax.text( | |
355 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), |
|
355 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), | |
356 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), |
|
356 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), | |
357 | '{}km'.format(r), |
|
357 | '{}km'.format(r), | |
358 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') |
|
358 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') | |
359 |
|
359 | |||
360 | if self.mode == 'E': |
|
360 | if self.mode == 'E': | |
361 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
|
361 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) | |
362 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) |
|
362 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) | |
363 | else: |
|
363 | else: | |
364 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) |
|
364 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) | |
365 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) |
|
365 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) | |
366 |
|
366 | |||
367 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
367 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] | |
368 | self.titles = ['{} {}'.format( |
|
368 | self.titles = ['{} {}'.format( | |
369 | self.data.parameters[x], title) for x in self.channels] |
|
369 | self.data.parameters[x], title) for x in self.channels] | |
370 |
|
370 | |||
371 | class WeatherPlot(Plot): |
|
371 | class WeatherPlot(Plot): | |
372 | CODE = 'weather' |
|
372 | CODE = 'weather' | |
373 | plot_name = 'weather' |
|
373 | plot_name = 'weather' | |
374 | plot_type = 'ppistyle' |
|
374 | plot_type = 'ppistyle' | |
375 | buffering = False |
|
375 | buffering = False | |
376 |
|
376 | |||
377 | def setup(self): |
|
377 | def setup(self): | |
378 | self.ncols = 1 |
|
378 | self.ncols = 1 | |
379 | self.nrows = 1 |
|
379 | self.nrows = 1 | |
380 | self.nplots= 1 |
|
380 | self.nplots= 1 | |
381 | self.ylabel= 'Range [Km]' |
|
381 | self.ylabel= 'Range [Km]' | |
382 | self.titles= ['Weather'] |
|
382 | self.titles= ['Weather'] | |
383 | self.colorbar=False |
|
383 | self.colorbar=False | |
384 | self.width =8 |
|
384 | self.width =8 | |
385 | self.height =8 |
|
385 | self.height =8 | |
386 | self.ini =0 |
|
386 | self.ini =0 | |
387 | self.len_azi =0 |
|
387 | self.len_azi =0 | |
388 | self.buffer_ini = None |
|
388 | self.buffer_ini = None | |
389 | self.buffer_azi = None |
|
389 | self.buffer_azi = None | |
390 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) |
|
390 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) | |
391 | self.flag =0 |
|
391 | self.flag =0 | |
392 | self.indicador= 0 |
|
392 | self.indicador= 0 | |
393 | self.last_data_azi = None |
|
393 | self.last_data_azi = None | |
394 | self.val_mean = None |
|
394 | self.val_mean = None | |
395 |
|
395 | |||
396 | def update(self, dataOut): |
|
396 | def update(self, dataOut): | |
397 |
|
397 | |||
398 | data = {} |
|
398 | data = {} | |
399 | meta = {} |
|
399 | meta = {} | |
400 | if hasattr(dataOut, 'dataPP_POWER'): |
|
400 | if hasattr(dataOut, 'dataPP_POWER'): | |
401 | factor = 1 |
|
401 | factor = 1 | |
402 |
|
||||
403 | if hasattr(dataOut, 'nFFTPoints'): |
|
402 | if hasattr(dataOut, 'nFFTPoints'): | |
404 | factor = dataOut.normFactor |
|
403 | factor = dataOut.normFactor | |
405 |
|
||||
406 | ####print("factor",factor) |
|
|||
407 | data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor)) |
|
404 | data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor)) | |
408 | ####print("weather",data['weather']) |
|
|||
409 | data['azi'] = dataOut.data_azi |
|
405 | data['azi'] = dataOut.data_azi | |
410 |
|
||||
411 | data['ele'] = dataOut.data_ele |
|
406 | data['ele'] = dataOut.data_ele | |
412 | return data, meta |
|
407 | return data, meta | |
413 |
|
408 | |||
414 | def get2List(self,angulos): |
|
409 | def get2List(self,angulos): | |
415 | list1=[] |
|
410 | list1=[] | |
416 | list2=[] |
|
411 | list2=[] | |
417 | for i in reversed(range(len(angulos))): |
|
412 | for i in reversed(range(len(angulos))): | |
418 | diff_ = angulos[i]-angulos[i-1] |
|
413 | diff_ = angulos[i]-angulos[i-1] | |
419 | if diff_ >1.5: |
|
414 | if diff_ >1.5: | |
420 | list1.append(i-1) |
|
415 | list1.append(i-1) | |
421 | list2.append(diff_) |
|
416 | list2.append(diff_) | |
422 | return list(reversed(list1)),list(reversed(list2)) |
|
417 | return list(reversed(list1)),list(reversed(list2)) | |
423 |
|
418 | |||
424 | def fixData360(self,list_,ang_): |
|
419 | def fixData360(self,list_,ang_): | |
425 | if list_[0]==-1: |
|
420 | if list_[0]==-1: | |
426 | vec = numpy.where(ang_<ang_[0]) |
|
421 | vec = numpy.where(ang_<ang_[0]) | |
427 | ang_[vec] = ang_[vec]+360 |
|
422 | ang_[vec] = ang_[vec]+360 | |
428 | return ang_ |
|
423 | return ang_ | |
429 | return ang_ |
|
424 | return ang_ | |
430 |
|
425 | |||
431 |
|
||||
432 | def fixData360HL(self,angulos): |
|
426 | def fixData360HL(self,angulos): | |
433 | vec = numpy.where(angulos>=360) |
|
427 | vec = numpy.where(angulos>=360) | |
434 | angulos[vec]=angulos[vec]-360 |
|
428 | angulos[vec]=angulos[vec]-360 | |
435 | return angulos |
|
429 | return angulos | |
436 |
|
430 | |||
437 | def search_pos(self,pos,list_): |
|
431 | def search_pos(self,pos,list_): | |
438 | for i in range(len(list_)): |
|
432 | for i in range(len(list_)): | |
439 | if pos == list_[i]: |
|
433 | if pos == list_[i]: | |
440 | return True,i |
|
434 | return True,i | |
441 | i=None |
|
435 | i=None | |
442 | return False,i |
|
436 | return False,i | |
443 |
|
437 | |||
444 | def fixDataComp(self,ang_,list1_,list2_): |
|
438 | def fixDataComp(self,ang_,list1_,list2_): | |
445 | size = len(ang_) |
|
439 | size = len(ang_) | |
446 | size2 = 0 |
|
440 | size2 = 0 | |
447 | for i in range(len(list2_)): |
|
441 | for i in range(len(list2_)): | |
448 | size2=size2+round(list2_[i])-1 |
|
442 | size2=size2+round(list2_[i])-1 | |
449 | new_size= size+size2 |
|
443 | new_size= size+size2 | |
450 | ang_new = numpy.zeros(new_size) |
|
444 | ang_new = numpy.zeros(new_size) | |
451 | ang_new2 = numpy.zeros(new_size) |
|
445 | ang_new2 = numpy.zeros(new_size) | |
452 |
|
446 | |||
453 | tmp = 0 |
|
447 | tmp = 0 | |
454 | c = 0 |
|
448 | c = 0 | |
455 | for i in range(len(ang_)): |
|
449 | for i in range(len(ang_)): | |
456 | ang_new[tmp +c] = ang_[i] |
|
450 | ang_new[tmp +c] = ang_[i] | |
457 | ang_new2[tmp+c] = ang_[i] |
|
451 | ang_new2[tmp+c] = ang_[i] | |
458 | condition , value = self.search_pos(i,list1_) |
|
452 | condition , value = self.search_pos(i,list1_) | |
459 | if condition: |
|
453 | if condition: | |
460 | pos = tmp + c + 1 |
|
454 | pos = tmp + c + 1 | |
461 | for k in range(round(list2_[value])-1): |
|
455 | for k in range(round(list2_[value])-1): | |
462 | ang_new[pos+k] = ang_new[pos+k-1]+1 |
|
456 | ang_new[pos+k] = ang_new[pos+k-1]+1 | |
463 | ang_new2[pos+k] = numpy.nan |
|
457 | ang_new2[pos+k] = numpy.nan | |
464 | tmp = pos +k |
|
458 | tmp = pos +k | |
465 | c = 0 |
|
459 | c = 0 | |
466 | c=c+1 |
|
460 | c=c+1 | |
467 | return ang_new,ang_new2 |
|
461 | return ang_new,ang_new2 | |
468 |
|
462 | |||
469 |
|
||||
470 | def globalCheckPED(self,angulos): |
|
463 | def globalCheckPED(self,angulos): | |
471 | l1,l2 = self.get2List(angulos) |
|
464 | l1,l2 = self.get2List(angulos) | |
472 | if len(l1)>0: |
|
465 | if len(l1)>0: | |
473 | angulos2 = self.fixData360(list_=l1,ang_=angulos) |
|
466 | angulos2 = self.fixData360(list_=l1,ang_=angulos) | |
474 | l1,l2 = self.get2List(angulos2) |
|
467 | l1,l2 = self.get2List(angulos2) | |
475 |
|
468 | |||
476 | ang1_,ang2_ = self.fixDataComp(ang_=angulos2,list1_=l1,list2_=l2) |
|
469 | ang1_,ang2_ = self.fixDataComp(ang_=angulos2,list1_=l1,list2_=l2) | |
477 | ang1_ = self.fixData360HL(ang1_) |
|
470 | ang1_ = self.fixData360HL(ang1_) | |
478 | ang2_ = self.fixData360HL(ang2_) |
|
471 | ang2_ = self.fixData360HL(ang2_) | |
479 |
|
||||
480 | else: |
|
472 | else: | |
481 | ang1_= angulos |
|
473 | ang1_= angulos | |
482 | ang2_= angulos |
|
474 | ang2_= angulos | |
483 | return ang1_,ang2_ |
|
475 | return ang1_,ang2_ | |
484 |
|
476 | |||
485 | def analizeDATA(self,data_azi): |
|
477 | def analizeDATA(self,data_azi): | |
486 | list1 = [] |
|
478 | list1 = [] | |
487 | list2 = [] |
|
479 | list2 = [] | |
488 | dat = data_azi |
|
480 | dat = data_azi | |
489 | for i in reversed(range(1,len(dat))): |
|
481 | for i in reversed(range(1,len(dat))): | |
490 | if dat[i]>dat[i-1]: |
|
482 | if dat[i]>dat[i-1]: | |
491 | diff = int(dat[i])-int(dat[i-1]) |
|
483 | diff = int(dat[i])-int(dat[i-1]) | |
492 | else: |
|
484 | else: | |
493 | diff = 360+int(dat[i])-int(dat[i-1]) |
|
485 | diff = 360+int(dat[i])-int(dat[i-1]) | |
494 | if diff > 1: |
|
486 | if diff > 1: | |
495 | list1.append(i-1) |
|
487 | list1.append(i-1) | |
496 | list2.append(diff-1) |
|
488 | list2.append(diff-1) | |
497 | return list1,list2 |
|
489 | return list1,list2 | |
498 |
|
490 | |||
499 | def fixDATANEW(self,data_azi,data_weather): |
|
491 | def fixDATANEW(self,data_azi,data_weather): | |
500 | list1,list2 = self.analizeDATA(data_azi) |
|
492 | list1,list2 = self.analizeDATA(data_azi) | |
501 | if len(list1)== 0: |
|
493 | if len(list1)== 0: | |
502 | return data_azi,data_weather |
|
494 | return data_azi,data_weather | |
503 | else: |
|
495 | else: | |
504 | resize = 0 |
|
496 | resize = 0 | |
505 | for i in range(len(list2)): |
|
497 | for i in range(len(list2)): | |
506 | resize= resize + list2[i] |
|
498 | resize= resize + list2[i] | |
507 | new_data_azi = numpy.resize(data_azi,resize) |
|
499 | new_data_azi = numpy.resize(data_azi,resize) | |
508 | new_data_weather= numpy.resize(date_weather,resize) |
|
500 | new_data_weather= numpy.resize(date_weather,resize) | |
509 |
|
501 | |||
510 | for i in range(len(list2)): |
|
502 | for i in range(len(list2)): | |
511 | j=0 |
|
503 | j=0 | |
512 | position=list1[i]+1 |
|
504 | position=list1[i]+1 | |
513 | for j in range(list2[i]): |
|
505 | for j in range(list2[i]): | |
514 | new_data_azi[position+j]=new_data_azi[position+j-1]+1 |
|
506 | new_data_azi[position+j]=new_data_azi[position+j-1]+1 | |
515 |
|
||||
516 | return new_data_azi |
|
507 | return new_data_azi | |
517 |
|
508 | |||
518 | def fixDATA(self,data_azi): |
|
509 | def fixDATA(self,data_azi): | |
519 | data=data_azi |
|
510 | data=data_azi | |
520 | for i in range(len(data)): |
|
511 | for i in range(len(data)): | |
521 | if numpy.isnan(data[i]): |
|
512 | if numpy.isnan(data[i]): | |
522 | data[i]=data[i-1]+1 |
|
513 | data[i]=data[i-1]+1 | |
523 | return data |
|
514 | return data | |
524 |
|
515 | |||
525 | def replaceNAN(self,data_weather,data_azi,val): |
|
516 | def replaceNAN(self,data_weather,data_azi,val): | |
526 | data= data_azi |
|
517 | data= data_azi | |
527 | data_T= data_weather |
|
518 | data_T= data_weather | |
528 | if data.shape[0]> data_T.shape[0]: |
|
519 | if data.shape[0]> data_T.shape[0]: | |
529 | data_N = numpy.ones( [data.shape[0],data_T.shape[1]]) |
|
520 | data_N = numpy.ones( [data.shape[0],data_T.shape[1]]) | |
530 | c = 0 |
|
521 | c = 0 | |
531 | for i in range(len(data)): |
|
522 | for i in range(len(data)): | |
532 | if numpy.isnan(data[i]): |
|
523 | if numpy.isnan(data[i]): | |
533 | data_N[i,:]=numpy.ones(data_T.shape[1])*numpy.nan |
|
524 | data_N[i,:]=numpy.ones(data_T.shape[1])*numpy.nan | |
534 | else: |
|
525 | else: | |
535 | data_N[i,:]=data_T[c,:] |
|
526 | data_N[i,:]=data_T[c,:] | |
536 | sc=c+1 |
|
527 | sc=c+1 | |
537 | else: |
|
528 | else: | |
538 | for i in range(len(data)): |
|
529 | for i in range(len(data)): | |
539 | if numpy.isnan(data[i]): |
|
530 | if numpy.isnan(data[i]): | |
540 | data_T[i,:]=numpy.ones(data_T.shape[1])*numpy.nan |
|
531 | data_T[i,:]=numpy.ones(data_T.shape[1])*numpy.nan | |
541 | return data_T |
|
532 | return data_T | |
542 |
|
533 | |||
543 | def const_ploteo(self,data_weather,data_azi,step,res): |
|
534 | def const_ploteo(self,data_weather,data_azi,step,res): | |
544 | if self.ini==0: |
|
535 | if self.ini==0: | |
545 |
#------- |
|
536 | #------- | |
546 | n = (360/res)-len(data_azi) |
|
537 | n = (360/res)-len(data_azi) | |
547 | #--------------------- new ------------------------- |
|
538 | #--------------------- new ------------------------- | |
548 | ####data_azi_old = data_azi |
|
|||
549 | data_azi_new ,data_azi_old= self.globalCheckPED(data_azi) |
|
539 | data_azi_new ,data_azi_old= self.globalCheckPED(data_azi) | |
550 | #------------------------ |
|
540 | #------------------------ | |
551 | ####data_azi_new = self.fixDATA(data_azi) |
|
|||
552 | #ata_azi_new = self.fixDATANEW(data_azi) |
|
|||
553 | start = data_azi_new[-1] + res |
|
541 | start = data_azi_new[-1] + res | |
554 | end = data_azi_new[0] - res |
|
542 | end = data_azi_new[0] - res | |
555 |
# |
|
543 | #------ new | |
556 | self.last_data_azi = end |
|
544 | self.last_data_azi = end | |
557 | if start>end: |
|
545 | if start>end: | |
558 | end = end + 360 |
|
546 | end = end + 360 | |
559 | azi_vacia = numpy.linspace(start,end,int(n)) |
|
547 | azi_vacia = numpy.linspace(start,end,int(n)) | |
560 | azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia) |
|
548 | azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia) | |
561 | data_azi = numpy.hstack((data_azi_new,azi_vacia)) |
|
549 | data_azi = numpy.hstack((data_azi_new,azi_vacia)) | |
562 | # RADAR |
|
550 | # RADAR | |
563 | val_mean = numpy.mean(data_weather[:,-1]) |
|
551 | val_mean = numpy.mean(data_weather[:,-1]) | |
564 | self.val_mean = val_mean |
|
552 | self.val_mean = val_mean | |
565 | data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean |
|
553 | data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean | |
566 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) |
|
554 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) | |
567 | data_weather = numpy.vstack((data_weather,data_weather_cmp)) |
|
555 | data_weather = numpy.vstack((data_weather,data_weather_cmp)) | |
568 | else: |
|
556 | else: | |
569 | # azimuth |
|
557 | # azimuth | |
570 | flag=0 |
|
558 | flag=0 | |
571 | start_azi = self.res_azi[0] |
|
559 | start_azi = self.res_azi[0] | |
572 | #-----------new------------ |
|
560 | #-----------new------------ | |
573 | data_azi ,data_azi_old= self.globalCheckPED(data_azi) |
|
561 | data_azi ,data_azi_old= self.globalCheckPED(data_azi) | |
574 | print("---------------------------------------------------") |
|
|||
575 | print("data_azi",data_azi) |
|
|||
576 | print("data_azi_old",data_azi_old) |
|
|||
577 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) |
|
562 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) | |
578 | #-------------------------- |
|
563 | #-------------------------- | |
579 | ####data_azi_old = data_azi |
|
|||
580 | ### weather ### |
|
|||
581 | ####data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) |
|
|||
582 |
|
||||
583 | ####if numpy.isnan(data_azi[0]): |
|
|||
584 | #### data_azi[0]=self.last_data_azi+1 |
|
|||
585 | ####data_azi = self.fixDATA(data_azi) |
|
|||
586 | start = data_azi[0] |
|
564 | start = data_azi[0] | |
587 | end = data_azi[-1] |
|
565 | end = data_azi[-1] | |
588 | self.last_data_azi= end |
|
566 | self.last_data_azi= end | |
589 | ####print("start",start) |
|
|||
590 | ####print("end",end) |
|
|||
591 | if start< start_azi: |
|
567 | if start< start_azi: | |
592 | start = start +360 |
|
568 | start = start +360 | |
593 | if end <start_azi: |
|
569 | if end <start_azi: | |
594 | end = end +360 |
|
570 | end = end +360 | |
595 | ####print("start",start) |
|
571 | ||
596 | ####print("end",end) |
|
|||
597 | #### AQUI SERA LA MAGIA |
|
|||
598 | pos_ini = int((start-start_azi)/res) |
|
572 | pos_ini = int((start-start_azi)/res) | |
599 | len_azi = len(data_azi) |
|
573 | len_azi = len(data_azi) | |
600 | if (360-pos_ini)<len_azi: |
|
574 | if (360-pos_ini)<len_azi: | |
601 | if pos_ini+1==360: |
|
575 | if pos_ini+1==360: | |
602 | pos_ini=0 |
|
576 | pos_ini=0 | |
603 | else: |
|
577 | else: | |
604 | flag=1 |
|
578 | flag=1 | |
605 | dif= 360-pos_ini |
|
579 | dif= 360-pos_ini | |
606 | comp= len_azi-dif |
|
580 | comp= len_azi-dif | |
607 |
|
||||
608 | #----------------- |
|
581 | #----------------- | |
609 | ####print(pos_ini) |
|
|||
610 | ####print(len_azi) |
|
|||
611 | ####print("shape",self.res_azi.shape) |
|
|||
612 | if flag==0: |
|
582 | if flag==0: | |
613 | # AZIMUTH |
|
583 | # AZIMUTH | |
614 | self.res_azi[pos_ini:pos_ini+len_azi] = data_azi |
|
584 | self.res_azi[pos_ini:pos_ini+len_azi] = data_azi | |
615 | # RADAR |
|
585 | # RADAR | |
616 | self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather |
|
586 | self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather | |
617 | else: |
|
587 | else: | |
618 | # AZIMUTH |
|
588 | # AZIMUTH | |
619 | self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif] |
|
589 | self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif] | |
620 | self.res_azi[0:comp] = data_azi[dif:] |
|
590 | self.res_azi[0:comp] = data_azi[dif:] | |
621 | # RADAR |
|
591 | # RADAR | |
622 | self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:] |
|
592 | self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:] | |
623 | self.res_weather[0:comp,:] = data_weather[dif:,:] |
|
593 | self.res_weather[0:comp,:] = data_weather[dif:,:] | |
624 | flag=0 |
|
594 | flag=0 | |
625 | data_azi = self.res_azi |
|
595 | data_azi = self.res_azi | |
626 | data_weather = self.res_weather |
|
596 | data_weather = self.res_weather | |
627 |
|
597 | |||
628 | return data_weather,data_azi |
|
598 | return data_weather,data_azi | |
629 |
|
599 | |||
630 | def plot(self): |
|
600 | def plot(self): | |
631 | #print("--------------------------------------",self.ini,"-----------------------------------") |
|
|||
632 | #numpy.set_printoptions(suppress=True) |
|
|||
633 | ####print("times: ",self.data.times) |
|
|||
634 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S') |
|
601 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S') | |
635 | #print("times: ",thisDatetime) |
|
|||
636 | data = self.data[-1] |
|
602 | data = self.data[-1] | |
637 | ####ALTURA altura_tmp_h |
|
|||
638 | ###print("Y RANGES",self.data.yrange,len(self.data.yrange)) |
|
|||
639 | ###altura_h = (data['weather'].shape[1])/10.0 |
|
|||
640 | ###stoprange = float(altura_h*0.3)#stoprange = float(33*1.5) por ahora 400 |
|
|||
641 | ###rangestep = float(0.03) |
|
|||
642 | ###r = numpy.arange(0, stoprange, rangestep) |
|
|||
643 | ###print("r",r,len(r)) |
|
|||
644 | #-----------------------------update---------------------- |
|
|||
645 |
r= |
|
603 | r = self.data.yrange | |
646 | delta_height = r[1]-r[0] |
|
604 | delta_height = r[1]-r[0] | |
647 | #print("1",r) |
|
|||
648 | r_mask= numpy.where(r>=0)[0] |
|
605 | r_mask = numpy.where(r>=0)[0] | |
649 | r = numpy.arange(len(r_mask))*delta_height |
|
606 | r = numpy.arange(len(r_mask))*delta_height | |
650 | #print("2",r) |
|
|||
651 | self.y = 2*r |
|
607 | self.y = 2*r | |
652 | ######self.y = self.data.yrange |
|
|||
653 | # RADAR |
|
608 | # RADAR | |
654 | #data_weather = data['weather'] |
|
609 | #data_weather = data['weather'] | |
655 | # PEDESTAL |
|
610 | # PEDESTAL | |
656 | #data_azi = data['azi'] |
|
611 | #data_azi = data['azi'] | |
657 | res = 1 |
|
612 | res = 1 | |
658 | # STEP |
|
613 | # STEP | |
659 | step = (360/(res*data['weather'].shape[0])) |
|
614 | step = (360/(res*data['weather'].shape[0])) | |
660 | #print("shape wr_data", wr_data.shape) |
|
615 | ||
661 | #print("shape wr_azi",wr_azi.shape) |
|
|||
662 | #print("step",step) |
|
|||
663 | ####print("Time---->",self.data.times[-1],thisDatetime) |
|
|||
664 | #print("alturas", len(self.y))numpy.where(r>=0) |
|
|||
665 | self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['azi'],step=step,res=res) |
|
616 | self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['azi'],step=step,res=res) | |
666 | #numpy.set_printoptions(suppress=True) |
|
|||
667 | #print("resultado",self.res_azi) |
|
|||
668 |
self.res_ele |
|
617 | self.res_ele = numpy.mean(data['ele']) | |
669 | ###########################/DATA_RM/10_tmp/ch0############################### |
|
|||
670 | ################# PLOTEO ################### |
|
618 | ################# PLOTEO ################### | |
671 | ########################################################## |
|
|||
672 |
|
619 | |||
673 | for i,ax in enumerate(self.axes): |
|
620 | for i,ax in enumerate(self.axes): | |
674 | if ax.firsttime: |
|
621 | if ax.firsttime: | |
675 | plt.clf() |
|
622 | plt.clf() | |
676 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) |
|
623 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) | |
677 | else: |
|
624 | else: | |
678 | plt.clf() |
|
625 | plt.clf() | |
679 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) |
|
626 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) | |
680 | caax = cgax.parasites[0] |
|
627 | caax = cgax.parasites[0] | |
681 | paax = cgax.parasites[1] |
|
628 | paax = cgax.parasites[1] | |
682 | cbar = plt.gcf().colorbar(pm, pad=0.075) |
|
629 | cbar = plt.gcf().colorbar(pm, pad=0.075) | |
683 | caax.set_xlabel('x_range [km]') |
|
630 | caax.set_xlabel('x_range [km]') | |
684 | caax.set_ylabel('y_range [km]') |
|
631 | caax.set_ylabel('y_range [km]') | |
685 | plt.text(1.0, 1.05, 'Azimuth '+str(thisDatetime)+" Step "+str(self.ini)+ " Elev: "+str(round(self.res_ele,2)), transform=caax.transAxes, va='bottom',ha='right') |
|
632 | plt.text(1.0, 1.05, 'Azimuth '+str(thisDatetime)+" Step "+str(self.ini)+ " Elev: "+str(round(self.res_ele,2)), transform=caax.transAxes, va='bottom',ha='right') | |
686 |
|
633 | |||
687 | self.ini= self.ini+1 |
|
634 | self.ini= self.ini+1 | |
|
635 | ||||
|
636 | ||||
|
637 | class WeatherRHIPlot(Plot): | |||
|
638 | CODE = 'weather' | |||
|
639 | plot_name = 'weather' | |||
|
640 | plot_type = 'rhistyle' | |||
|
641 | buffering = False | |||
|
642 | ||||
|
643 | def setup(self): | |||
|
644 | self.ncols = 1 | |||
|
645 | self.nrows = 1 | |||
|
646 | self.nplots= 1 | |||
|
647 | self.ylabel= 'Range [Km]' | |||
|
648 | self.titles= ['Weather'] | |||
|
649 | self.colorbar=False | |||
|
650 | self.width =8 | |||
|
651 | self.height =8 | |||
|
652 | self.ini =0 | |||
|
653 | self.len_azi =0 | |||
|
654 | self.buffer_ini = None | |||
|
655 | self.buffer_azi = None | |||
|
656 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) | |||
|
657 | self.flag =0 | |||
|
658 | self.indicador= 0 | |||
|
659 | self.last_data_azi = None | |||
|
660 | self.val_mean = None | |||
|
661 | ||||
|
662 | def update(self, dataOut): | |||
|
663 | ||||
|
664 | data = {} | |||
|
665 | meta = {} | |||
|
666 | if hasattr(dataOut, 'dataPP_POWER'): | |||
|
667 | factor = 1 | |||
|
668 | if hasattr(dataOut, 'nFFTPoints'): | |||
|
669 | factor = dataOut.normFactor | |||
|
670 | data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor)) | |||
|
671 | data['azi'] = dataOut.data_azi | |||
|
672 | data['ele'] = dataOut.data_ele | |||
|
673 | return data, meta | |||
|
674 | ||||
|
675 | def plot(self): | |||
|
676 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S') | |||
|
677 | data = self.data[-1] | |||
|
678 | r = self.data.yrange | |||
|
679 | delta_height = r[1]-r[0] | |||
|
680 | r_mask = numpy.where(r>=0)[0] | |||
|
681 | r = numpy.arange(len(r_mask))*delta_height | |||
|
682 | self.y = 2*r | |||
|
683 | ###self.res_weather, self.res_ele = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['ele'],step=step,res=res) | |||
|
684 | ###self.res_azi = numpy.mean(data['azi']) | |||
|
685 | #------------- | |||
|
686 | # 90 angulos en el axis 0 | |||
|
687 | # 1000 step en el axis 1 | |||
|
688 | self.res_weather = numpy.ones([90,1000]) | |||
|
689 | r = numpy.linspace(0,1999,1000) | |||
|
690 | self.res_ele = numpy.arange(0,90) | |||
|
691 | self.res_azi = 240 | |||
|
692 | #------------- | |||
|
693 | for i,ax in enumerate(self.axes): | |||
|
694 | if ax.firsttime: | |||
|
695 | plt.clf() | |||
|
696 | cgax, pm = wrl.vis.plot_rhi(self.res_weather,r=r,th=self.res_ele,fig=self.figures[0], proj='cg') | |||
|
697 | else: | |||
|
698 | plt.clf() | |||
|
699 | cgax, pm = wrl.vis.plot_rhi(self.res_weather,r=r,th=self.res_ele,fig=self.figures[0], proj='cg') | |||
|
700 | caax = cgax.parasites[0] | |||
|
701 | paax = cgax.parasites[1] | |||
|
702 | cbar = plt.gcf().colorbar(pm, pad=0.075) | |||
|
703 | caax.set_xlabel('x_range [km]') | |||
|
704 | caax.set_ylabel('y_range [km]') | |||
|
705 | plt.text(1.0, 1.05, 'Elevacion '+str(thisDatetime)+" Step "+str(self.ini)+ " Azi: "+str(round(self.res_azi,2)), transform=caax.transAxes, va='bottom',ha='right') | |||
|
706 | ||||
|
707 | self.ini= self.ini+1 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,133 +1,133 | |||||
1 | # Ing. AVP |
|
1 | # Ing. AVP | |
2 | # 04/01/2022 |
|
2 | # 04/01/2022 | |
3 | # ARCHIVO DE LECTURA |
|
3 | # ARCHIVO DE LECTURA | |
4 | import os, sys |
|
4 | import os, sys | |
5 | import datetime |
|
5 | import datetime | |
6 | import time |
|
6 | import time | |
7 | import numpy |
|
7 | import numpy | |
8 | from ext_met import getfirstFilefromPath,getDatavaluefromDirFilename |
|
8 | from ext_met import getfirstFilefromPath,getDatavaluefromDirFilename | |
9 | from schainpy.controller import Project |
|
9 | from schainpy.controller import Project | |
10 | #----------------------------------------------------------------------------------------- |
|
10 | #----------------------------------------------------------------------------------------- | |
11 | print("[SETUP]-RADAR METEOROLOGICO-") |
|
11 | print("[SETUP]-RADAR METEOROLOGICO-") | |
12 | path_ped = "/DATA_RM/TEST_PEDESTAL/P20211110-171003" |
|
12 | path_ped = "/DATA_RM/TEST_PEDESTAL/P20211110-171003" | |
13 | print("PATH PEDESTAL :",path_ped) |
|
13 | print("PATH PEDESTAL :",path_ped) | |
14 | path_adq = "/DATA_RM/10" |
|
14 | path_adq = "/DATA_RM/10" | |
15 | print("PATH DATA :",path_adq) |
|
15 | print("PATH DATA :",path_adq) | |
16 | figpath_pp_rti = "/home/soporte/Pictures/TEST_PP_RTI" |
|
16 | figpath_pp_rti = "/home/soporte/Pictures/TEST_PP_RTI" | |
17 | print("PATH PP RTI :",figpath_pp_rti) |
|
17 | print("PATH PP RTI :",figpath_pp_rti) | |
18 | figpath_pp_ppi = "/home/soporte/Pictures/TEST_PP_PPI" |
|
18 | figpath_pp_ppi = "/home/soporte/Pictures/TEST_PP_PPI" | |
19 | print("PATH PP PPI :",figpath_pp_ppi) |
|
19 | print("PATH PP PPI :",figpath_pp_ppi) | |
20 | path_pp_save_int = "/DATA_RM/TEST_SAVE_PP_INT" |
|
20 | path_pp_save_int = "/DATA_RM/TEST_SAVE_PP_INT" | |
21 | print("PATH SAVE PP INT :",path_pp_save_int) |
|
21 | print("PATH SAVE PP INT :",path_pp_save_int) | |
22 | print(" ") |
|
22 | print(" ") | |
23 | #------------------------------------------------------------------------------------------- |
|
23 | #------------------------------------------------------------------------------------------- | |
24 | print("SELECCIONAR MODO: PPI (0) O RHI (1)") |
|
24 | print("SELECCIONAR MODO: PPI (0) O RHI (1)") | |
25 | mode_wr = 0 |
|
25 | mode_wr = 0 | |
26 | if mode_wr==0: |
|
26 | if mode_wr==0: | |
27 | print("[ ON ] MODE PPI") |
|
27 | print("[ ON ] MODE PPI") | |
28 | list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5") |
|
28 | list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5") | |
29 | ff_pedestal = list_ped[2] |
|
29 | ff_pedestal = list_ped[2] | |
30 | azi_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="azi_vel") |
|
30 | azi_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="azi_vel") | |
31 | V = round(azi_vel[0]) |
|
31 | V = round(azi_vel[0]) | |
32 | print("VELOCIDAD AZI :", int(numpy.mean(azi_vel)),"Β°/seg") |
|
32 | print("VELOCIDAD AZI :", int(numpy.mean(azi_vel)),"Β°/seg") | |
33 | else: |
|
33 | else: | |
34 | print("[ ON ] MODE RHI") |
|
34 | print("[ ON ] MODE RHI") | |
35 | list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5") |
|
35 | list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5") | |
36 | ff_pedestal = list_ped[2] |
|
36 | ff_pedestal = list_ped[2] | |
37 | V = round(ele_vel[0]) |
|
37 | V = round(ele_vel[0]) | |
38 | ele_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="ele_vel") |
|
38 | ele_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="ele_vel") | |
39 | print("VELOCIDAD ELE :", int(numpy.mean(ele_vel)),"Β°/seg") |
|
39 | print("VELOCIDAD ELE :", int(numpy.mean(ele_vel)),"Β°/seg") | |
40 | print(" ") |
|
40 | print(" ") | |
41 | #--------------------------------------------------------------------------------------- |
|
41 | #--------------------------------------------------------------------------------------- | |
42 | print("SELECCIONAR MODO: PULSE PAIR (0) O FREQUENCY (1)") |
|
42 | print("SELECCIONAR MODO: PULSE PAIR (0) O FREQUENCY (1)") | |
43 | mode_proc = 0 |
|
43 | mode_proc = 0 | |
44 | if mode_proc==0: |
|
44 | if mode_proc==0: | |
45 | print("[ ON ] MODE PULSEPAIR") |
|
45 | print("[ ON ] MODE PULSEPAIR") | |
46 | else: |
|
46 | else: | |
47 | print("[ ON ] MODE FREQUENCY") |
|
47 | print("[ ON ] MODE FREQUENCY") | |
48 | ipp = 60.0 |
|
48 | ipp = 60.0 | |
49 | print("IPP(Km.) : %1.2f"%ipp) |
|
49 | print("IPP(Km.) : %1.2f"%ipp) | |
50 | ipp_sec = (ipp*1.0e3/150.0)*1.0e-6 |
|
50 | ipp_sec = (ipp*1.0e3/150.0)*1.0e-6 | |
51 | print("IPP(useg.) : %1.2f"%(ipp_sec*(1.0e6))) |
|
51 | print("IPP(useg.) : %1.2f"%(ipp_sec*(1.0e6))) | |
52 | VEL=V |
|
52 | VEL=V | |
53 | n= int(1/(VEL*ipp_sec)) |
|
53 | n= int(1/(VEL*ipp_sec)) | |
54 | print("NΒ° Profiles : ", n) |
|
54 | print("NΒ° Profiles : ", n) | |
55 | #--------------------------------------------------------------------------------------- |
|
55 | #--------------------------------------------------------------------------------------- | |
56 | plot_rti = 0 |
|
56 | plot_rti = 0 | |
57 | plot_ppi = 1 |
|
57 | plot_ppi = 1 | |
58 | integration = 1 |
|
58 | integration = 1 | |
59 | save = 0 |
|
59 | save = 0 | |
60 | #---------------------------RANGO DE PLOTEO---------------------------------- |
|
60 | #---------------------------RANGO DE PLOTEO---------------------------------- | |
61 | dBmin = '1' |
|
61 | dBmin = '1' | |
62 | dBmax = '85' |
|
62 | dBmax = '85' | |
63 | xmin = '17' |
|
63 | xmin = '17' | |
64 | xmax = '17.25' |
|
64 | xmax = '17.25' | |
65 | ymin = '0' |
|
65 | ymin = '0' | |
66 | ymax = '600' |
|
66 | ymax = '600' | |
67 | #---------------------------------------------------------------------------- |
|
67 | #---------------------------------------------------------------------------- | |
68 | time.sleep(3) |
|
68 | time.sleep(3) | |
69 | #---------------------SIGNAL CHAIN ------------------------------------ |
|
69 | #---------------------SIGNAL CHAIN ------------------------------------ | |
70 | desc = "USRP_WEATHER_RADAR" |
|
70 | desc = "USRP_WEATHER_RADAR" | |
71 | filename = "USRP_processing.xml" |
|
71 | filename = "USRP_processing.xml" | |
72 | controllerObj = Project() |
|
72 | controllerObj = Project() | |
73 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) |
|
73 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |
74 | #---------------------UNIDAD DE LECTURA-------------------------------- |
|
74 | #---------------------UNIDAD DE LECTURA-------------------------------- | |
75 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', |
|
75 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', | |
76 | path=path_adq, |
|
76 | path=path_adq, | |
77 | startDate="2021/11/10",#today, |
|
77 | startDate="2021/11/10",#today, | |
78 | endDate="2021/12/30",#today, |
|
78 | endDate="2021/12/30",#today, | |
79 | startTime='17:10:25', |
|
79 | startTime='17:10:25', | |
80 | endTime='23:59:59', |
|
80 | endTime='23:59:59', | |
81 | delay=0, |
|
81 | delay=0, | |
82 | #set=0, |
|
82 | #set=0, | |
83 | online=0, |
|
83 | online=0, | |
84 | walk=1, |
|
84 | walk=1, | |
85 | ippKm=ipp) |
|
85 | ippKm=ipp) | |
86 |
|
86 | |||
87 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc',inputId=readUnitConfObj.getId()) |
|
87 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc',inputId=readUnitConfObj.getId()) | |
88 |
|
88 | |||
89 | opObj11 = procUnitConfObjA.addOperation(name='selectHeights') |
|
89 | opObj11 = procUnitConfObjA.addOperation(name='selectHeights') | |
90 | opObj11.addParameter(name='minIndex', value='1', format='int') |
|
90 | opObj11.addParameter(name='minIndex', value='1', format='int') | |
91 | # opObj11.addParameter(name='maxIndex', value='10000', format='int') |
|
91 | # opObj11.addParameter(name='maxIndex', value='10000', format='int') | |
92 | opObj11.addParameter(name='maxIndex', value='400', format='int') |
|
92 | opObj11.addParameter(name='maxIndex', value='400', format='int') | |
93 |
|
93 | |||
94 | if mode_proc==0: |
|
94 | if mode_proc==0: | |
95 | opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') |
|
95 | opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') | |
96 | opObj11.addParameter(name='n', value=int(n), format='int') |
|
96 | opObj11.addParameter(name='n', value=int(n), format='int') | |
97 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) |
|
97 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) | |
98 |
|
98 | # REVISAR EL test_sim00013.py | ||
99 | if plot_rti==1: |
|
99 | if plot_rti==1: | |
100 | opObj11 = procUnitConfObjB.addOperation(name='GenericRTIPlot',optype='external') |
|
100 | opObj11 = procUnitConfObjB.addOperation(name='GenericRTIPlot',optype='external') | |
101 | opObj11.addParameter(name='attr_data', value='dataPP_POW') |
|
101 | opObj11.addParameter(name='attr_data', value='dataPP_POW') | |
102 | opObj11.addParameter(name='colormap', value='jet') |
|
102 | opObj11.addParameter(name='colormap', value='jet') | |
103 | opObj11.addParameter(name='xmin', value=xmin) |
|
103 | opObj11.addParameter(name='xmin', value=xmin) | |
104 | opObj11.addParameter(name='xmax', value=xmax) |
|
104 | opObj11.addParameter(name='xmax', value=xmax) | |
105 | opObj11.addParameter(name='zmin', value=dBmin) |
|
105 | opObj11.addParameter(name='zmin', value=dBmin) | |
106 | opObj11.addParameter(name='zmax', value=dBmax) |
|
106 | opObj11.addParameter(name='zmax', value=dBmax) | |
107 | opObj11.addParameter(name='save', value=figpath_pp_rti) |
|
107 | opObj11.addParameter(name='save', value=figpath_pp_rti) | |
108 | opObj11.addParameter(name='showprofile', value=0) |
|
108 | opObj11.addParameter(name='showprofile', value=0) | |
109 | opObj11.addParameter(name='save_period', value=50) |
|
109 | opObj11.addParameter(name='save_period', value=50) | |
110 | if integration==1: |
|
110 | if integration==1: | |
111 | opObj11 = procUnitConfObjB.addOperation(name='PedestalInformation') |
|
111 | opObj11 = procUnitConfObjB.addOperation(name='PedestalInformation') | |
112 | opObj11.addParameter(name='path_ped', value=path_ped) |
|
112 | opObj11.addParameter(name='path_ped', value=path_ped) | |
113 | opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') |
|
113 | opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') | |
114 |
|
114 | |||
115 | if plot_ppi==1: |
|
115 | if plot_ppi==1: | |
116 | opObj11 = procUnitConfObjB.addOperation(name='Block360') |
|
116 | opObj11 = procUnitConfObjB.addOperation(name='Block360') | |
117 | opObj11.addParameter(name='n', value='10', format='int') |
|
117 | opObj11.addParameter(name='n', value='10', format='int') | |
118 | opObj11.addParameter(name='mode', value=mode_proc, format='int') |
|
118 | opObj11.addParameter(name='mode', value=mode_proc, format='int') | |
119 | # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 |
|
119 | # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 | |
120 | opObj11= procUnitConfObjB.addOperation(name='WeatherPlot',optype='other') |
|
120 | opObj11= procUnitConfObjB.addOperation(name='WeatherPlot',optype='other') | |
121 | opObj11.addParameter(name='save', value=figpath_pp_ppi) |
|
121 | opObj11.addParameter(name='save', value=figpath_pp_ppi) | |
122 | opObj11.addParameter(name='save_period', value=1) |
|
122 | opObj11.addParameter(name='save_period', value=1) | |
123 |
|
123 | |||
124 | if save==1: |
|
124 | if save==1: | |
125 | opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') |
|
125 | opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') | |
126 | opObj10.addParameter(name='path',value=path_pp_save_int) |
|
126 | opObj10.addParameter(name='path',value=path_pp_save_int) | |
127 | opObj10.addParameter(name='mode',value="weather") |
|
127 | opObj10.addParameter(name='mode',value="weather") | |
128 | opObj10.addParameter(name='blocksPerFile',value='360',format='int') |
|
128 | opObj10.addParameter(name='blocksPerFile',value='360',format='int') | |
129 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') |
|
129 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') | |
130 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,azimuth,elevation,utctime',format='list')#,format='list' |
|
130 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,azimuth,elevation,utctime',format='list')#,format='list' | |
131 |
|
131 | |||
132 |
|
132 | |||
133 | controllerObj.start() |
|
133 | controllerObj.start() |
General Comments 0
You need to be logged in to leave comments.
Login now