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