@@ -0,0 +1,77 | |||||
|
1 | ''' | |||
|
2 | @author: roj-idl71 | |||
|
3 | ''' | |||
|
4 | #USED IN jroplot_spectra.py | |||
|
5 | RTI_CODE = 0 #Range time intensity (RTI). | |||
|
6 | SPEC_CODE = 1 #Spectra (and Cross-spectra) information. | |||
|
7 | CROSS_CODE = 2 #Cross-Correlation information. | |||
|
8 | COH_CODE = 3 #Coherence map. | |||
|
9 | BASE_CODE = 4 #Base lines graphic. | |||
|
10 | ROW_CODE = 5 #Row Spectra. | |||
|
11 | TOTAL_CODE = 6 #Total Power. | |||
|
12 | DRIFT_CODE = 7 #Drifts graphics. | |||
|
13 | HEIGHT_CODE = 8 #Height profile. | |||
|
14 | PHASE_CODE = 9 #Signal Phase. | |||
|
15 | ||||
|
16 | POWER_CODE = 16 | |||
|
17 | NOISE_CODE = 17 | |||
|
18 | BEACON_CODE = 18 | |||
|
19 | ||||
|
20 | #USED IN jroplot_parameters.py | |||
|
21 | WIND_CODE = 22 | |||
|
22 | MSKYMAP_CODE = 23 | |||
|
23 | MPHASE_CODE = 24 | |||
|
24 | ||||
|
25 | MOMENTS_CODE = 25 | |||
|
26 | PARMS_CODE = 26 | |||
|
27 | SPECFIT_CODE = 27 | |||
|
28 | EWDRIFT_CODE = 28 | |||
|
29 | ||||
|
30 | ||||
|
31 | #COLOR TABLES | |||
|
32 | ||||
|
33 | reflectivity = [ | |||
|
34 | "#000000", # -30 | |||
|
35 | "#15191d", # -25 | |||
|
36 | "#2a323b", # -20 | |||
|
37 | "#3f4c59", # -15 | |||
|
38 | "#556576", # -10 | |||
|
39 | "#6a7f94", # -5 | |||
|
40 | "#7f99b2", # 0 | |||
|
41 | "#00ffff", # 5 | |||
|
42 | "#007fff", # 10 | |||
|
43 | "#0000ff", # 15 | |||
|
44 | "#00ff00", # 20 | |||
|
45 | "#00bf00", # 25 | |||
|
46 | "#007f00", # 30 | |||
|
47 | "#ffff00", # 35 | |||
|
48 | "#ffbf00", # 40 | |||
|
49 | "#ff7f00", # 45 | |||
|
50 | "#ff0000", # 50 | |||
|
51 | "#bf0000", # 55 | |||
|
52 | "#7f0000", # 60 | |||
|
53 | "#fe00fe", # 65 | |||
|
54 | "#8e59ff", # 70 | |||
|
55 | "#f0f0f0", # 75 | |||
|
56 | ] | |||
|
57 | ||||
|
58 | velocity = [ | |||
|
59 | "#003300", "#005500", "#007700", "#009900", "#00bb00", "#24ce24", "#6cd26c", "#b4d6b4", | |||
|
60 | "#d6b4b4", "#d26c6c", "#ce2424", "#bb0000", "#980000", "#760000", "#540000", "#330000", | |||
|
61 | ] | |||
|
62 | ||||
|
63 | spc_width = [ | |||
|
64 | "#00ffff", "#00aaf2", "#0055e5", "#0000d8", | |||
|
65 | "#007f00", "#00aa00", "#00d400", "#00ff00", | |||
|
66 | "#ffff00", "#ffd400", "#ffaa00", "#ff7f00", | |||
|
67 | "#ff0000", "#d40000", "#aa0000", "#7f0000", | |||
|
68 | "#ff00ff", "#d400d4", "#aa00aa", "#7f007f", | |||
|
69 | "#9938ff", "#832ed8", "#6e25b2", "#591c8c", | |||
|
70 | "#aaaaaa", "#8e8e8e" | |||
|
71 | ] | |||
|
72 | ||||
|
73 | sophy_cb_tables = [ | |||
|
74 | ('sophy_r', reflectivity), | |||
|
75 | ('sophy_v', velocity), | |||
|
76 | ('sophy_w', spc_width), | |||
|
77 | ] |
@@ -0,0 +1,159 | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | import matplotlib.pyplot as pl | |||
|
3 | import matplotlib | |||
|
4 | import wradlib | |||
|
5 | import numpy | |||
|
6 | import warnings | |||
|
7 | import argparse | |||
|
8 | from wradlib.io import read_generic_hdf5 | |||
|
9 | from wradlib.util import get_wradlib_data_file | |||
|
10 | from plotting_codes import sophy_cb_tables | |||
|
11 | import os,time | |||
|
12 | ||||
|
13 | for name, cb_table in sophy_cb_tables: | |||
|
14 | ncmap = matplotlib.colors.ListedColormap(cb_table, name=name) | |||
|
15 | matplotlib.pyplot.register_cmap(cmap=ncmap) | |||
|
16 | #LINUX bash: export WRADLIB_DATA=/path/to/wradlib-data | |||
|
17 | warnings.filterwarnings('ignore') | |||
|
18 | PARAM = { | |||
|
19 | 'S': {'var': 'dataPP_POWER','vmin': -45, 'vmax': -15, 'cmap': 'jet', 'label': 'Power','unit': 'dBm'}, | |||
|
20 | 'V': {'var': 'velRadial_V', 'vmin': -10, 'vmax': 10 , 'cmap': 'sophy_v', 'label': 'Velocity','unit': 'm/s'}, | |||
|
21 | 'Z': {'var': 'Zdb', 'vmin': -30, 'vmax': 80 , 'cmap': 'sophy_r','label': 'Reflectivity','unit': 'dBZ'}, | |||
|
22 | 'W': {'var': 'Sigmav_W', 'vmin': 0 , 'vmax': 12 , 'cmap': 'sophy_w','label': 'Spectral Width','unit': 'hz'} | |||
|
23 | } | |||
|
24 | class Readsophy(): | |||
|
25 | def __init__(self): | |||
|
26 | self.list_file = None | |||
|
27 | self.grado = None | |||
|
28 | self.variable = None | |||
|
29 | self.save = None | |||
|
30 | ||||
|
31 | def read_files(self,path_file,grado=None, variable=None): | |||
|
32 | filter= "_E"+str(grado)+".0_"+variable | |||
|
33 | validFilelist = [] | |||
|
34 | fileList= os.listdir(path_file) | |||
|
35 | for thisFile in fileList: | |||
|
36 | if (os.path.splitext(thisFile)[0][-7:] != filter): | |||
|
37 | #print("s_:",os.path.splitext(thisFile)[0][-7:]) | |||
|
38 | continue | |||
|
39 | validFilelist.append(thisFile) | |||
|
40 | validFilelist.sort() | |||
|
41 | return validFilelist | |||
|
42 | ||||
|
43 | def setup(self, path_file,grado,variable,save): | |||
|
44 | self.path_file = path_file | |||
|
45 | self.grado = grado | |||
|
46 | self.variable = variable | |||
|
47 | self.save = save | |||
|
48 | self.list_file = self.read_files(path_file=self.path_file,grado=self.grado, variable=self.variable) | |||
|
49 | ||||
|
50 | def run(self): | |||
|
51 | count= 0 | |||
|
52 | len_files = len(self.list_file) | |||
|
53 | ||||
|
54 | for thisFile in self.list_file: | |||
|
55 | count = count +1 | |||
|
56 | fullpathfile = self.path_file + thisFile | |||
|
57 | filename = get_wradlib_data_file(fullpathfile) | |||
|
58 | test_hdf5 = read_generic_hdf5(filename) | |||
|
59 | ||||
|
60 | var = PARAM[self.variable]['var'] | |||
|
61 | unit = PARAM[self.variable]['unit'] | |||
|
62 | cmap = PARAM[self.variable]['cmap'] | |||
|
63 | vmin = PARAM[self.variable]['vmin'] | |||
|
64 | vmax = PARAM[self.variable]['vmax'] | |||
|
65 | label = PARAM[self.variable]['label'] | |||
|
66 | var_ = 'Data/'+var+'/channel00' | |||
|
67 | data_arr = numpy.array(test_hdf5[var_]['data']) # data | |||
|
68 | utc_time = numpy.array(test_hdf5['Data/utctime']['data']) | |||
|
69 | data_azi = numpy.array(test_hdf5['Metadata/data_azi']['data']) # th | |||
|
70 | data_ele = numpy.array(test_hdf5["Metadata/data_ele"]['data']) | |||
|
71 | heightList = numpy.array(test_hdf5["Metadata/heightList"]['data']) # r | |||
|
72 | my_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(utc_time[0])) | |||
|
73 | time_save = time.strftime('%Y%m%d_%H%M%S',time.localtime(utc_time[0])) | |||
|
74 | ||||
|
75 | # PLOT DATA WITH ANNOTATION | |||
|
76 | if count ==1: | |||
|
77 | fig = pl.figure(figsize=(10,8)) | |||
|
78 | cgax, pm = wradlib.vis.plot_ppi(data_arr,r=heightList,az=data_azi,rf=1e3,fig=fig, ax=111,proj='cg',cmap=cmap,vmin=vmin, vmax=vmax) | |||
|
79 | caax = cgax.parasites[0] | |||
|
80 | title = 'Simple PPI'+"-"+ my_time | |||
|
81 | t = pl.title(title, fontsize=12,y=1.05) | |||
|
82 | cbar = pl.gcf().colorbar(pm, pad=0.075) | |||
|
83 | pl.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',ha='right') | |||
|
84 | cbar.set_label(label+'[' + unit + ']') | |||
|
85 | gh = cgax.get_grid_helper() | |||
|
86 | else: | |||
|
87 | cgax, pm = wradlib.vis.plot_ppi(data_arr,r=heightList,az=data_azi,rf=1e3,fig=fig, ax=111,proj='cg',cmap=cmap,vmin=vmin, vmax=vmax) | |||
|
88 | caax = cgax.parasites[0] | |||
|
89 | title = 'Simple PPI'+"-"+my_time | |||
|
90 | t = pl.title(title, fontsize=12,y=1.05) | |||
|
91 | cbar = pl.gcf().colorbar(pm, pad=0.075) | |||
|
92 | pl.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',ha='right') | |||
|
93 | cbar.set_label(label+'[' + unit + ']') | |||
|
94 | gh = cgax.get_grid_helper() | |||
|
95 | if self.save == 1: | |||
|
96 | if count ==1: | |||
|
97 | filename = "SOPHY"+"_"+time_save+"_"+"E."+self.grado+"_"+self.variable+".png" | |||
|
98 | dir =self.variable+"_"+"E."+self.grado+"CH0/" | |||
|
99 | filesavepath = os.path.join(self.path_file,dir) | |||
|
100 | os.mkdir(filesavepath) | |||
|
101 | else: | |||
|
102 | filename = "SOPHY"+"_"+time_save+"_"+"E."+self.grado+"_"+self.variable+".png" | |||
|
103 | pl.savefig(filesavepath+filename) | |||
|
104 | ||||
|
105 | pl.pause(2) | |||
|
106 | pl.clf() | |||
|
107 | if count==len_files: | |||
|
108 | pl.close() | |||
|
109 | pl.show() | |||
|
110 | ||||
|
111 | PATH = "/home/soporte/Documents/EVENTO/HYO_PM@2022-06-09T15-05-12/paramC0_FD_PL_R15.0km/2022-06-09T18-00-00/" | |||
|
112 | ||||
|
113 | def main(args): | |||
|
114 | grado = args.grado | |||
|
115 | parameters = args.parameters | |||
|
116 | save = args.save | |||
|
117 | obj = Readsophy() | |||
|
118 | for param in parameters: | |||
|
119 | obj.setup(path_file = PATH,grado = grado, variable=param,save=int(save)) | |||
|
120 | obj.run() | |||
|
121 | ||||
|
122 | if __name__ == '__main__': | |||
|
123 | ||||
|
124 | parser = argparse.ArgumentParser(description='Script to process SOPHy data.') | |||
|
125 | parser.add_argument('--parameters', nargs='*', default=['S'], | |||
|
126 | help='Variables to process: P, Z, V ,W') | |||
|
127 | parser.add_argument('--grado', default=2, | |||
|
128 | help='Angle in Elev to plot') | |||
|
129 | parser.add_argument('--save', default=0, | |||
|
130 | help='Save plot') | |||
|
131 | args = parser.parse_args() | |||
|
132 | ||||
|
133 | main(args) | |||
|
134 | ||||
|
135 | ||||
|
136 | ''' | |||
|
137 | def read_and_overview(filename): | |||
|
138 | """Read HDF5 using read_generic_hdf5 and print upper level dictionary keys | |||
|
139 | """ | |||
|
140 | test = read_generic_hdf5(filename) | |||
|
141 | print("\nPrint keys for file %s" % os.path.basename(filename)) | |||
|
142 | for key in test.keys(): | |||
|
143 | print("\t%s" % key) | |||
|
144 | return test | |||
|
145 | ||||
|
146 | file__ = "/home/soporte/Documents/EVENTO/HYO_PM@2022-06-09T15-05-12/paramC0_FD_PL_R15.0km/2022-06-09T18-00-00/SOPHY_20220609_180229_E2.0_Z.hdf5" | |||
|
147 | ||||
|
148 | ||||
|
149 | filename = get_wradlib_data_file(file__) | |||
|
150 | ||||
|
151 | print("filename:\n",filename ) | |||
|
152 | ||||
|
153 | test= read_and_overview(filename) | |||
|
154 | # ANADIR INFORMACION | |||
|
155 | # informacion de los pulsos de TX | |||
|
156 | # informacion de los ruidos | |||
|
157 | # informacion de los SNR ¿? | |||
|
158 | # Aumentar la amplitud de la USRP | |||
|
159 | ''' |
General Comments 0
You need to be logged in to leave comments.
Login now