##// END OF EJS Templates
clean Rayleigh funcionando, tiempo de ejecución elevado usando todos los pares
joabAM -
r1391:fba03565a781
parent child
Show More
@@ -202,6 +202,7 class Plot(Operation):
202 self.figures = []
202 self.figures = []
203 self.axes = []
203 self.axes = []
204 self.cb_axes = []
204 self.cb_axes = []
205 self.pf_axes = []
205 self.localtime = kwargs.pop('localtime', True)
206 self.localtime = kwargs.pop('localtime', True)
206 self.show = kwargs.get('show', True)
207 self.show = kwargs.get('show', True)
207 self.save = kwargs.get('save', False)
208 self.save = kwargs.get('save', False)
@@ -252,6 +253,7 class Plot(Operation):
252 self.__throttle_plot = apply_throttle(self.throttle)
253 self.__throttle_plot = apply_throttle(self.throttle)
253 code = self.attr_data if self.attr_data else self.CODE
254 code = self.attr_data if self.attr_data else self.CODE
254 self.data = PlotterData(self.CODE, self.exp_code, self.localtime)
255 self.data = PlotterData(self.CODE, self.exp_code, self.localtime)
256 self.tmin = kwargs.get('tmin', None)
255
257
256 if self.server:
258 if self.server:
257 if not self.server.startswith('tcp://'):
259 if not self.server.startswith('tcp://'):
@@ -50,7 +50,7 class SnrPlot(RTIPlot):
50 def update(self, dataOut):
50 def update(self, dataOut):
51
51
52 data = {
52 data = {
53 'snr': 10*numpy.log10(dataOut.data_snr)
53 'snr': 10*numpy.log10(dataOut.data_snr)
54 }
54 }
55
55
56 return data, {}
56 return data, {}
@@ -66,7 +66,7 class DopplerPlot(RTIPlot):
66 def update(self, dataOut):
66 def update(self, dataOut):
67
67
68 data = {
68 data = {
69 'dop': 10*numpy.log10(dataOut.data_dop)
69 'dop': 10*numpy.log10(dataOut.data_dop)
70 }
70 }
71
71
72 return data, {}
72 return data, {}
@@ -82,9 +82,9 class PowerPlot(RTIPlot):
82 def update(self, dataOut):
82 def update(self, dataOut):
83
83
84 data = {
84 data = {
85 'pow': 10*numpy.log10(dataOut.data_pow)
85 'pow': 10*numpy.log10(dataOut.data_pow)
86 }
86 }
87
87 print("data",data)
88 return data, {}
88 return data, {}
89
89
90 class SpectralWidthPlot(RTIPlot):
90 class SpectralWidthPlot(RTIPlot):
@@ -166,7 +166,7 class GenericRTIPlot(Plot):
166 self.nrows = self.data.shape('param')[0]
166 self.nrows = self.data.shape('param')[0]
167 self.nplots = self.nrows
167 self.nplots = self.nrows
168 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
168 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
169
169
170 if not self.xlabel:
170 if not self.xlabel:
171 self.xlabel = 'Time'
171 self.xlabel = 'Time'
172
172
@@ -183,7 +183,7 class GenericRTIPlot(Plot):
183 meta = {}
183 meta = {}
184
184
185 return data, meta
185 return data, meta
186
186
187 def plot(self):
187 def plot(self):
188 # self.data.normalize_heights()
188 # self.data.normalize_heights()
189 self.x = self.data.times
189 self.x = self.data.times
@@ -354,4 +354,3 class PolarMapPlot(Plot):
354 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
354 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
355 self.titles = ['{} {}'.format(
355 self.titles = ['{} {}'.format(
356 self.data.parameters[x], title) for x in self.channels]
356 self.data.parameters[x], title) for x in self.channels]
357
@@ -21,7 +21,7 class SpectraPlot(Plot):
21 colormap = 'jet'
21 colormap = 'jet'
22 plot_type = 'pcolor'
22 plot_type = 'pcolor'
23 buffering = False
23 buffering = False
24 channelList = None
24 channelList = []
25
25
26 def setup(self):
26 def setup(self):
27 self.nplots = len(self.data.channels)
27 self.nplots = len(self.data.channels)
@@ -208,11 +208,12 class RTIPlot(Plot):
208 colormap = 'jet'
208 colormap = 'jet'
209 plot_type = 'pcolorbuffer'
209 plot_type = 'pcolorbuffer'
210 titles = None
210 titles = None
211 channelList = None
211 channelList = []
212
212
213 def setup(self):
213 def setup(self):
214 self.xaxis = 'time'
214 self.xaxis = 'time'
215 self.ncols = 1
215 self.ncols = 1
216 print("dataChannels ",self.data.channels)
216 self.nrows = len(self.data.channels)
217 self.nrows = len(self.data.channels)
217 self.nplots = len(self.data.channels)
218 self.nplots = len(self.data.channels)
218 self.ylabel = 'Range [km]'
219 self.ylabel = 'Range [km]'
@@ -221,9 +222,9 class RTIPlot(Plot):
221 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95})
222 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95})
222 self.titles = ['{} Channel {}'.format(
223 self.titles = ['{} Channel {}'.format(
223 self.CODE.upper(), x) for x in range(self.nplots)]
224 self.CODE.upper(), x) for x in range(self.nplots)]
224
225 print("SETUP")
225 def update(self, dataOut):
226 def update(self, dataOut):
226 if self.channelList == None:
227 if len(self.channelList) == 0:
227 self.channelList = dataOut.channelList
228 self.channelList = dataOut.channelList
228 data = {}
229 data = {}
229 meta = {}
230 meta = {}
@@ -585,7 +585,7 class Reader(object):
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
@@ -692,7 +692,7 class Reader(object):
692 startDateTime= datetime.datetime.combine(startDate,startTime)
692 startDateTime= datetime.datetime.combine(startDate,startTime)
693 endDateTime = datetime.datetime.combine(endDate,endTime)
693 endDateTime = datetime.datetime.combine(endDate,endTime)
694 if startDateTime <= dt <= endDateTime:
694 if startDateTime <= dt <= endDateTime:
695 return True
695 return True
696 return False
696 return False
697
697
698 def verifyFile(self, filename):
698 def verifyFile(self, filename):
@@ -646,7 +646,7 class AMISRReader(ProcessingUnit):
646
646
647 self.profileIndex += 1
647 self.profileIndex += 1
648
648
649 #return self.dataOut.data
649 return self.dataOut.data
650
650
651
651
652 def run(self, **kwargs):
652 def run(self, **kwargs):
@@ -659,5 +659,3 class AMISRReader(ProcessingUnit):
659 self.isConfig = True
659 self.isConfig = True
660
660
661 self.getData()
661 self.getData()
662 #return(self.dataOut.data)
663 return(self.dataOut)
@@ -108,8 +108,11 class HDFReader(Reader, ProcessingUnit):
108 fullpath = self.searchFilesOnLine(self.path, self.startDate,
108 fullpath = self.searchFilesOnLine(self.path, self.startDate,
109 self.endDate, self.expLabel, self.ext, self.walk,
109 self.endDate, self.expLabel, self.ext, self.walk,
110 self.filefmt, self.folderfmt)
110 self.filefmt, self.folderfmt)
111 pathname, filename = os.path.split(fullpath)
112 print(pathname,filename)
111 try:
113 try:
112 fullpath = next(fullpath)
114 fullpath = next(fullpath)
115
113 except:
116 except:
114 fullpath = None
117 fullpath = None
115
118
@@ -139,6 +142,7 class HDFReader(Reader, ProcessingUnit):
139
142
140 return
143 return
141
144
145
142 def readFirstHeader(self):
146 def readFirstHeader(self):
143 '''Read metadata and data'''
147 '''Read metadata and data'''
144
148
@@ -150,8 +154,10 class HDFReader(Reader, ProcessingUnit):
150 self.dataOut = eval(self.meta['type'])()
154 self.dataOut = eval(self.meta['type'])()
151
155
152 for attr in self.meta:
156 for attr in self.meta:
157 print("attr: ", attr)
153 setattr(self.dataOut, attr, self.meta[attr])
158 setattr(self.dataOut, attr, self.meta[attr])
154
159
160
155 self.blockIndex = 0
161 self.blockIndex = 0
156
162
157 return
163 return
@@ -173,7 +179,8 class HDFReader(Reader, ProcessingUnit):
173 thisUtcTime = self.data['utctime'] + self.utcoffset
179 thisUtcTime = self.data['utctime'] + self.utcoffset
174 self.interval = numpy.min(thisUtcTime[1:] - thisUtcTime[:-1])
180 self.interval = numpy.min(thisUtcTime[1:] - thisUtcTime[:-1])
175 thisDatetime = datetime.datetime.utcfromtimestamp(thisUtcTime[0])
181 thisDatetime = datetime.datetime.utcfromtimestamp(thisUtcTime[0])
176
182 self.startFileDatetime = thisDatetime
183 print("datee ",self.startFileDatetime)
177 thisDate = thisDatetime.date()
184 thisDate = thisDatetime.date()
178 thisTime = thisDatetime.time()
185 thisTime = thisDatetime.time()
179
186
@@ -184,6 +191,7 class HDFReader(Reader, ProcessingUnit):
184
191
185 self.blockList = ind
192 self.blockList = ind
186 self.blocksPerFile = len(ind)
193 self.blocksPerFile = len(ind)
194 self.blocksPerFile = len(thisUtcTime)
187 return
195 return
188
196
189 def __readMetadata(self):
197 def __readMetadata(self):
@@ -208,6 +216,20 class HDFReader(Reader, ProcessingUnit):
208
216
209 return
217 return
210
218
219
220
221 def checkForRealPath(self, nextFile, nextDay):
222
223 # print("check FRP")
224 # dt = self.startFileDatetime + datetime.timedelta(1)
225 # filename = '{}.{}{}'.format(self.path, dt.strftime('%Y%m%d'), self.ext)
226 # fullfilename = os.path.join(self.path, filename)
227 # print("check Path ",fullfilename,filename)
228 # if os.path.exists(fullfilename):
229 # return fullfilename, filename
230 # return None, filename
231 return None,None
232
211 def __readData(self):
233 def __readData(self):
212
234
213 data = {}
235 data = {}
@@ -250,7 +272,10 class HDFReader(Reader, ProcessingUnit):
250 return
272 return
251
273
252 def getData(self):
274 def getData(self):
253
275 if not self.isDateTimeInRange(self.startFileDatetime, self.startDate, self.endDate, self.startTime, self.endTime):
276 self.dataOut.flagNoData = True
277 self.dataOut.error = True
278 return
254 for attr in self.data:
279 for attr in self.data:
255 if self.data[attr].ndim == 1:
280 if self.data[attr].ndim == 1:
256 setattr(self.dataOut, attr, self.data[attr][self.blockIndex])
281 setattr(self.dataOut, attr, self.data[attr][self.blockIndex])
@@ -60,7 +60,7 class ParametersProc(ProcessingUnit):
60 self.profIndex = 0
60 self.profIndex = 0
61 self.dataOut = Parameters()
61 self.dataOut = Parameters()
62 self.setupReq = False #Agregar a todas las unidades de proc
62 self.setupReq = False #Agregar a todas las unidades de proc
63
63 print("INIT PROC")
64 def __updateObjFromInput(self):
64 def __updateObjFromInput(self):
65
65
66 self.dataOut.inputUnit = self.dataIn.type
66 self.dataOut.inputUnit = self.dataIn.type
@@ -99,8 +99,7 class ParametersProc(ProcessingUnit):
99 self.dataOut.elevationList = self.dataIn.elevationList
99 self.dataOut.elevationList = self.dataIn.elevationList
100
100
101 def run(self):
101 def run(self):
102
102 print("run proc param")
103
104
103
105 #---------------------- Voltage Data ---------------------------
104 #---------------------- Voltage Data ---------------------------
106
105
@@ -185,7 +184,7 class ParametersProc(ProcessingUnit):
185 if self.dataIn.type == "Parameters":
184 if self.dataIn.type == "Parameters":
186 self.dataOut.copy(self.dataIn)
185 self.dataOut.copy(self.dataIn)
187 self.dataOut.flagNoData = False
186 self.dataOut.flagNoData = False
188
187 self.prin("DAta In")
189 return True
188 return True
190
189
191 self.__updateObjFromInput()
190 self.__updateObjFromInput()
@@ -544,7 +544,7 class CleanRayleigh(Operation):
544 self.currentTime = self.__initime
544 self.currentTime = self.__initime
545 self.pairsArray = numpy.array(dataOut.pairsList)
545 self.pairsArray = numpy.array(dataOut.pairsList)
546 self.factor_stdv = factor_stdv
546 self.factor_stdv = factor_stdv
547 print("CHANNELS: ",[x for x in self.channels])
547 #print("CHANNELS: ",[x for x in self.channels])
548
548
549 if n != None :
549 if n != None :
550 self.byProfiles = True
550 self.byProfiles = True
@@ -577,7 +577,7 class CleanRayleigh(Operation):
577 #if (tini.tm_min % 2) == 0 and (tini.tm_sec < 5 and self.fint==0):
577 #if (tini.tm_min % 2) == 0 and (tini.tm_sec < 5 and self.fint==0):
578
578
579 if self.__dataReady:
579 if self.__dataReady:
580 print("Data ready",self.__profIndex)
580 #print("Data ready",self.__profIndex)
581 self.__profIndex = 0
581 self.__profIndex = 0
582 jspc = self.buffer
582 jspc = self.buffer
583 jcspc = self.buffer2
583 jcspc = self.buffer2
@@ -620,14 +620,13 class CleanRayleigh(Operation):
620 # jcspc = jcspc/self.nFFTPoints/self.normFactor
620 # jcspc = jcspc/self.nFFTPoints/self.normFactor
621
621
622
622
623 #dataOut.data_spc,dataOut.data_cspc = self.CleanRayleigh(dataOut,jspc,jcspc,crosspairs,heights,channels,nProf,nHei,nChan,nPairs,nIncohInt,nBlocks=nBlocks)
624 #tmp_spectra,tmp_cspectra,sat_spectra,sat_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.min_hei,self.max_hei)
625 tmp_spectra,tmp_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv)
626 #jspectra = tmp_spectra*len(jspc[:,0,0,0])
627 #jcspectra = tmp_cspectra*len(jspc[:,0,0,0])
628
623
624 tmp_spectra,tmp_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv)
629 dataOut.data_spc = tmp_spectra
625 dataOut.data_spc = tmp_spectra
630 dataOut.data_cspc = tmp_cspectra
626 dataOut.data_cspc = tmp_cspectra
627
628 #dataOut.data_spc,dataOut.data_cspc = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv)
629
631 dataOut.data_dc = self.buffer3
630 dataOut.data_dc = self.buffer3
632 dataOut.nIncohInt *= self.nIntProfiles
631 dataOut.nIncohInt *= self.nIntProfiles
633 dataOut.utctime = self.currentTime #tiempo promediado
632 dataOut.utctime = self.currentTime #tiempo promediado
@@ -641,32 +640,35 class CleanRayleigh(Operation):
641 return dataOut
640 return dataOut
642
641
643 def cleanRayleigh(self,dataOut,spectra,cspectra,factor_stdv):
642 def cleanRayleigh(self,dataOut,spectra,cspectra,factor_stdv):
644 print("OP cleanRayleigh")
643 #print("OP cleanRayleigh")
645 #import matplotlib.pyplot as plt
644 #import matplotlib.pyplot as plt
646 #for k in range(149):
645 #for k in range(149):
647
646
648 rfunc = cspectra.copy() #self.bloques
647 rfunc = cspectra.copy() #self.bloques
649 val_spc = spectra*0.0 #self.bloque0*0.0
648 #rfunc = cspectra
650 val_cspc = cspectra*0.0 #self.bloques*0.0
649 #val_spc = spectra*0.0 #self.bloque0*0.0
651 in_sat_spectra = spectra.copy() #self.bloque0
650 #val_cspc = cspectra*0.0 #self.bloques*0.0
652 in_sat_cspectra = cspectra.copy() #self.bloques
651 #in_sat_spectra = spectra.copy() #self.bloque0
652 #in_sat_cspectra = cspectra.copy() #self.bloques
653
653
654 raxs = math.ceil(math.sqrt(self.nPairs))
654 #raxs = math.ceil(math.sqrt(self.nPairs))
655 caxs = math.ceil(self.nPairs/raxs)
655 #caxs = math.ceil(self.nPairs/raxs)
656
656
657 #print(self.hval)
657 #print(self.hval)
658 #print numpy.absolute(rfunc[:,0,0,14])
658 #print numpy.absolute(rfunc[:,0,0,14])
659 gauss_fit, covariance = None, None
659 for ih in range(self.minAltInd,self.maxAltInd):
660 for ih in range(self.minAltInd,self.maxAltInd):
660 for ifreq in range(self.nFFTPoints):
661 for ifreq in range(self.nFFTPoints):
661 # fig, axs = plt.subplots(raxs, caxs)
662 # fig, axs = plt.subplots(raxs, caxs)
662 # fig2, axs2 = plt.subplots(raxs, caxs)
663 # fig2, axs2 = plt.subplots(raxs, caxs)
663 col_ax = 0
664 # col_ax = 0
664 row_ax = 0
665 # row_ax = 0
666 #print(len(self.nPairs))
665 for ii in range(self.nPairs): #PARES DE CANALES SELF y CROSS
667 for ii in range(self.nPairs): #PARES DE CANALES SELF y CROSS
666 #print("ii: ",ii)
668 #print("ii: ",ii)
667 if (col_ax%caxs==0 and col_ax!=0):
669 # if (col_ax%caxs==0 and col_ax!=0):
668 col_ax = 0
670 # col_ax = 0
669 row_ax += 1
671 # row_ax += 1
670 func2clean = 10*numpy.log10(numpy.absolute(rfunc[:,ii,ifreq,ih])) #Potencia?
672 func2clean = 10*numpy.log10(numpy.absolute(rfunc[:,ii,ifreq,ih])) #Potencia?
671 #print(func2clean.shape)
673 #print(func2clean.shape)
672 val = (numpy.isfinite(func2clean)==True).nonzero()
674 val = (numpy.isfinite(func2clean)==True).nonzero()
@@ -689,8 +691,9 class CleanRayleigh(Operation):
689 mean = numpy.sum(x_dist * y_dist) / numpy.sum(y_dist)
691 mean = numpy.sum(x_dist * y_dist) / numpy.sum(y_dist)
690 sigma = numpy.sqrt(numpy.sum(y_dist * (x_dist - mean)**2) / numpy.sum(y_dist))
692 sigma = numpy.sqrt(numpy.sum(y_dist * (x_dist - mean)**2) / numpy.sum(y_dist))
691 parg = [numpy.amax(y_dist),mean,sigma]
693 parg = [numpy.amax(y_dist),mean,sigma]
692 gauss_fit, covariance = None, None
694
693 newY = None
695 #newY = None
696
694 try :
697 try :
695 gauss_fit, covariance = curve_fit(fit_func, x_dist, y_dist,p0=parg)
698 gauss_fit, covariance = curve_fit(fit_func, x_dist, y_dist,p0=parg)
696 mode = gauss_fit[1]
699 mode = gauss_fit[1]
@@ -708,8 +711,7 class CleanRayleigh(Operation):
708
711
709
712
710 #print(mode,stdv)
713 #print(mode,stdv)
711 #Removing echoes greater than mode + 3*stdv
714 #Removing echoes greater than mode + std_factor*stdv
712 #factor_stdv = 2
713 noval = (abs(func2clean - mode)>=(factor_stdv*stdv)).nonzero()
715 noval = (abs(func2clean - mode)>=(factor_stdv*stdv)).nonzero()
714 #noval tiene los indices que se van a remover
716 #noval tiene los indices que se van a remover
715 #print("Pair ",ii," novals: ",len(noval[0]))
717 #print("Pair ",ii," novals: ",len(noval[0]))
@@ -730,14 +732,12 class CleanRayleigh(Operation):
730 chB = self.channels.index(cross_pairs[1])
732 chB = self.channels.index(cross_pairs[1])
731
733
732 new_a = numpy.delete(cspectra[:,ii,ifreq,ih], noval[0])
734 new_a = numpy.delete(cspectra[:,ii,ifreq,ih], noval[0])
733 mean_cspc = numpy.mean(new_a)
735 cspectra[noval,ii,ifreq,ih] = numpy.mean(new_a) #mean CrossSpectra
734 new_b = numpy.delete(spectra[:,chA,ifreq,ih], noval[0])
736 new_b = numpy.delete(spectra[:,chA,ifreq,ih], noval[0])
735 mean_spc0 = numpy.mean(new_b)
737 spectra[noval,chA,ifreq,ih] = numpy.mean(new_b) #mean Spectra Pair A
736 new_c = numpy.delete(spectra[:,chB,ifreq,ih], noval[0])
738 new_c = numpy.delete(spectra[:,chB,ifreq,ih], noval[0])
737 mean_spc1 = numpy.mean(new_c)
739 spectra[noval,chB,ifreq,ih] = numpy.mean(new_c) #mean Spectra Pair B
738 spectra[noval,chA,ifreq,ih] = mean_spc0
740
739 spectra[noval,chB,ifreq,ih] = mean_spc1
740 cspectra[noval,ii,ifreq,ih] = mean_cspc
741
741
742 '''
742 '''
743 func2clean = 10*numpy.log10(numpy.absolute(cspectra[:,ii,ifreq,ih]))
743 func2clean = 10*numpy.log10(numpy.absolute(cspectra[:,ii,ifreq,ih]))
@@ -747,7 +747,7 class CleanRayleigh(Operation):
747 axs2[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii]))
747 axs2[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii]))
748 '''
748 '''
749
749
750 col_ax += 1 #contador de ploteo columnas
750 #col_ax += 1 #contador de ploteo columnas
751 ##print(col_ax)
751 ##print(col_ax)
752 '''
752 '''
753 title = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km"
753 title = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km"
@@ -778,7 +778,7 class CleanRayleigh(Operation):
778 self.bloques[vcross,ifreq,ih,noval] = numpy.nan
778 self.bloques[vcross,ifreq,ih,noval] = numpy.nan
779 '''
779 '''
780
780
781 print("Getting average of the spectra and cross-spectra from incoherent echoes.")
781 #print("Getting average of the spectra and cross-spectra from incoherent echoes.")
782 out_spectra = numpy.zeros([self.nChan,self.nFFTPoints,self.nHeights], dtype=float) #+numpy.nan
782 out_spectra = numpy.zeros([self.nChan,self.nFFTPoints,self.nHeights], dtype=float) #+numpy.nan
783 out_cspectra = numpy.zeros([self.nPairs,self.nFFTPoints,self.nHeights], dtype=complex) #+numpy.nan
783 out_cspectra = numpy.zeros([self.nPairs,self.nFFTPoints,self.nHeights], dtype=complex) #+numpy.nan
784 for ih in range(self.nHeights):
784 for ih in range(self.nHeights):
General Comments 0
You need to be logged in to leave comments. Login now