@@ -0,0 +1,152 | |||
|
1 | # SOPHY PROC script | |
|
2 | import os, sys, json, argparse | |
|
3 | import datetime | |
|
4 | import time | |
|
5 | ||
|
6 | PATH = '/DATA_RM/DATA' | |
|
7 | # PATH = '/Users/jespinoza/workspace/data/' | |
|
8 | #PATH = '/home/roberto/DATA/data_WR_RHI/RHI' | |
|
9 | PATH = '/home/soporte/Downloads/data_WR_RHI' | |
|
10 | ||
|
11 | ||
|
12 | PARAM = { | |
|
13 | 'P': {'name': 'dataPP_POWER', 'zmin': 35, 'zmax': 60, 'colormap': 'jet', 'label': 'Power', 'cb_label': 'dB'}, | |
|
14 | 'V': {'name': 'dataPP_DOP', 'zmin': -20, 'zmax': 20, 'colormap': 'seismic', 'label': 'Velocity', 'cb_label': 'm/s'}, | |
|
15 | 'RH': {'name': 'RhoHV_R', 'zmin': 0, 'zmax': 1, 'colormap': 'jet', 'label': 'CoeficienteCorrelacion', 'cb_label': '*'}, | |
|
16 | 'FD': {'name': 'PhiD_P', 'zmin': -180, 'zmax': 180, 'colormap': 'RdBu_r', 'label': 'Fase Diferencial', 'cb_label': 'º'}, | |
|
17 | 'ZD': {'name': 'Zdb_D', 'zmin': -20, 'zmax': 80, 'colormap': 'viridis', 'label': 'ReflectividadDiferencial', 'cb_label': 'dBz'}, | |
|
18 | 'Z': {'name': 'Zdb', 'zmin': -20, 'zmax': 60, 'colormap': 'viridis', 'label': 'Reflectividad', 'cb_label': 'dBz'}, | |
|
19 | 'W': {'name': 'Sigmav_W', 'zmin': -20, 'zmax': 60, 'colormap': 'viridis', 'label': 'AnchoEspectral', 'cb_label': 'hz'} | |
|
20 | } | |
|
21 | ||
|
22 | def main(args): | |
|
23 | ||
|
24 | experiment = args.experiment | |
|
25 | fp = open(os.path.join(PATH, experiment, 'experiment.conf')) | |
|
26 | conf = json.loads(fp.read()) | |
|
27 | ||
|
28 | ipp_km = conf['usrp_tx']['ipp'] | |
|
29 | ipp = ipp_km * 2 /300000 | |
|
30 | samp_rate = conf['usrp_rx']['sample_rate'] | |
|
31 | axis = ['0' if x=='elevation' else '1' for x in conf['pedestal']['speed']] # AZIMUTH 1 ELEVACION 0 | |
|
32 | speed_axis = conf['pedestal']['speed'] | |
|
33 | steeps = conf['pedestal']['table'] | |
|
34 | time_offset = args.time_offset | |
|
35 | parameters = args.parameters | |
|
36 | #start_date = experiment.split('@')[1].split('T')[0].replace('-', '/') | |
|
37 | start_date = '2022/04/22' | |
|
38 | end_date = start_date | |
|
39 | #start_time = experiment.split('@')[1].split('T')[1] | |
|
40 | start_time ='17:42:55' | |
|
41 | end_time = '23:59:59' | |
|
42 | max_index = int(samp_rate*ipp*1e6 * args.range / 60) + int(samp_rate*ipp*1e6 * 1.2 / 60) | |
|
43 | N = int(1/(speed_axis[0]*ipp)) # 1 GRADO DE RESOLUCION | |
|
44 | path = os.path.join(PATH, experiment, 'rawdata') | |
|
45 | path_ped = os.path.join(PATH, experiment, 'position') | |
|
46 | path_plots = os.path.join(PATH, experiment, 'plots') | |
|
47 | path_save = os.path.join(PATH, experiment, 'param') | |
|
48 | ||
|
49 | dBmin = 35 | |
|
50 | dBmax = 60 | |
|
51 | Vmin = -20 | |
|
52 | Vmax = 20 | |
|
53 | ||
|
54 | ||
|
55 | from schainpy.controller import Project | |
|
56 | ||
|
57 | project = Project() | |
|
58 | project.setup(id='1', name='Sophy', description='sophy proc') | |
|
59 | ||
|
60 | reader = project.addReadUnit(datatype='DigitalRFReader', | |
|
61 | path=path, | |
|
62 | startDate=start_date, | |
|
63 | endDate=end_date, | |
|
64 | startTime=start_time, | |
|
65 | endTime=end_time, | |
|
66 | delay=0, | |
|
67 | online=0, | |
|
68 | walk=1, | |
|
69 | ippKm = ipp_km, | |
|
70 | getByBlock = 1, | |
|
71 | nProfileBlocks = N, | |
|
72 | ) | |
|
73 | ||
|
74 | voltage = project.addProcUnit(datatype='VoltageProc', inputId=reader.getId()) | |
|
75 | op = voltage.addOperation(name='setH0') | |
|
76 | op.addParameter(name='h0', value='-1.2') | |
|
77 | ||
|
78 | if args.range > 0: | |
|
79 | op = voltage.addOperation(name='selectHeights') | |
|
80 | op.addParameter(name='minIndex', value='0', format='int') | |
|
81 | op.addParameter(name='maxIndex', value=max_index, format='int') | |
|
82 | ||
|
83 | op = voltage.addOperation(name='PulsePair_vRF', optype='other') | |
|
84 | op.addParameter(name='n', value=int(N), format='int') | |
|
85 | ||
|
86 | proc = project.addProcUnit(datatype='ParametersProc', inputId=voltage.getId()) | |
|
87 | #-----------------------new--------- variables polarimetricas--------------- | |
|
88 | opObj10 = proc.addOperation(name="WeatherRadar") | |
|
89 | opObj10.addParameter(name='variableList',value='Reflectividad,ReflectividadDiferencial,CoeficienteCorrelacion,FaseDiferencial,VelocidadRadial,AnchoEspectral') | |
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | op = proc.addOperation(name='PedestalInformation') | |
|
94 | op.addParameter(name='path', value=path_ped, format='str') | |
|
95 | op.addParameter(name='interval', value='0.04', format='float') | |
|
96 | op.addParameter(name='time_offset', value=time_offset) | |
|
97 | #op.addParameter(name='axis', value=','.join(axis)) #Preguntar en pedestal si todos los elementos | |
|
98 | #de aqui son iguales, si lo fueran, que considere | |
|
99 | #el primero dato como el modo (PPI o RHI) y que ya | |
|
100 | #no pregunte por el modo porque este no cambia | |
|
101 | ||
|
102 | for param in parameters: | |
|
103 | op = proc.addOperation(name='Block360_vRF4') | |
|
104 | #op.addParameter(name='axis', value=','.join(axis)) | |
|
105 | op.addParameter(name='runNextOp', value=True) | |
|
106 | op.addParameter(name='attr_data', value=PARAM[param]['name']) | |
|
107 | ||
|
108 | path_fig = '/AUTO{}km'.format(args.range) | |
|
109 | op = proc.addOperation(name='WeatherParamsPlot') | |
|
110 | op.addParameter(name='save', value=path_plots+path_fig, format='str') | |
|
111 | op.addParameter(name='save_period', value=-1) | |
|
112 | op.addParameter(name='show', value=args.show) | |
|
113 | op.addParameter(name='channels', value='(1,)') | |
|
114 | op.addParameter(name='zmin', value=PARAM[param]['zmin']) | |
|
115 | op.addParameter(name='zmax', value=PARAM[param]['zmax']) | |
|
116 | op.addParameter(name='attr_data', value=PARAM[param]['name'], format='str') | |
|
117 | op.addParameter(name='labels', value=[PARAM[param]['label']]) | |
|
118 | op.addParameter(name='save_code', value=param) | |
|
119 | op.addParameter(name='cb_label', value=PARAM[param]['cb_label']) | |
|
120 | op.addParameter(name='colormap', value=PARAM[param]['colormap']) | |
|
121 | ||
|
122 | if args.save: | |
|
123 | opObj10 = proc.addOperation(name='HDFWriter') | |
|
124 | opObj10.addParameter(name='path',value=path_save, format='str') | |
|
125 | opObj10.addParameter(name='Reset',value=True) | |
|
126 | opObj10.addParameter(name='setType',value='weather') | |
|
127 | opObj10.addParameter(name='blocksPerFile',value='1',format='int') | |
|
128 | opObj10.addParameter(name='metadataList',value='heightList,data_azi,data_ele') | |
|
129 | opObj10.addParameter(name='dataList',value=','.join([PARAM[param]['name'],'utctime'])) | |
|
130 | ||
|
131 | project.start() | |
|
132 | ||
|
133 | ||
|
134 | if __name__ == '__main__': | |
|
135 | ||
|
136 | parser = argparse.ArgumentParser(description='Script to process SOPHy data.') | |
|
137 | parser.add_argument('experiment', | |
|
138 | help='Experiment name') | |
|
139 | parser.add_argument('--parameters', nargs='*', default=['P'], | |
|
140 | help='Variables to process: P, Z, V') | |
|
141 | parser.add_argument('--time_offset', default=0, | |
|
142 | help='Fix time offset') | |
|
143 | parser.add_argument('--range', default=0, type=int, | |
|
144 | help='Max range to plot') | |
|
145 | parser.add_argument('--save', action='store_true', | |
|
146 | help='Create output files') | |
|
147 | parser.add_argument('--show', action='store_true', | |
|
148 | help='Show matplotlib plot.') | |
|
149 | ||
|
150 | args = parser.parse_args() | |
|
151 | print (args) | |
|
152 | main(args) |
@@ -558,12 +558,12 class HDFWriter(Operation): | |||
|
558 | 558 | if self.dataOut.flagMode == 1: #'AZI' #PPI |
|
559 | 559 | ang_type = 'El' |
|
560 | 560 | len_aux = int(self.dataOut.data_ele.shape[0]/4) |
|
561 |
mean = numpy.mean(self.dataOut.data_ele[len_aux:-len |
|
|
561 | mean = numpy.mean(self.dataOut.data_ele[len_aux:-len_aux]) | |
|
562 | 562 | ang_ = round(mean,1) |
|
563 | 563 | elif self.dataOut.flagMode == 0: #'ELE' #RHI |
|
564 | 564 | ang_type = 'Az' |
|
565 | 565 | len_aux = int(self.dataOut.data_azi.shape[0]/4) |
|
566 |
mean = numpy.mean(self.dataOut.data_azi[len_aux:-len |
|
|
566 | mean = numpy.mean(self.dataOut.data_azi[len_aux:-len_aux]) | |
|
567 | 567 | ang_ = round(mean,1) |
|
568 | 568 | |
|
569 | 569 | file = '%s%s%s%2.1f%s%2.2d%2.2d%2.2d%s%2.2d%2.2d%2.2d%s' % (wr_type, |
General Comments 0
You need to be logged in to leave comments.
Login now