##// END OF EJS Templates
Lectura y procesamiento de spectra desde HDF5
joabAM -
r1404:b1b398996ebb
parent child
Show More
@@ -465,6 +465,9 class Spectra(JROData):
465 465 self.ippFactor = 1
466 466 self.beacon_heiIndexList = []
467 467 self.noise_estimation = None
468 self.codeList = []
469 self.azimuthList = []
470 self.elevationList = []
468 471 self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt',
469 472 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp','nIncohInt', 'nFFTPoints', 'nProfiles']
470 473
@@ -866,6 +869,7 class Parameters(Spectra):
866 869 Constructor
867 870 '''
868 871 self.radarControllerHeaderObj = RadarControllerHeader()
872 self.radarControllerHeaderObj.set_ippSeconds(0)
869 873 self.systemHeaderObj = SystemHeader()
870 874 self.type = "Parameters"
871 875 self.timeZone = 0
@@ -497,7 +497,6 class Plot(Operation):
497 497 'interval': dataOut.timeInterval,
498 498 'channels': dataOut.channelList
499 499 }
500
501 500 data, meta = self.update(dataOut)
502 501 metadata.update(meta)
503 502 self.data.update(data, timestamp, metadata)
@@ -84,7 +84,6 class PowerPlot(RTIPlot):
84 84 data = {
85 85 'pow': 10*numpy.log10(dataOut.data_pow)
86 86 }
87 #print("data",data)
88 87 return data, {}
89 88
90 89 class SpectralWidthPlot(RTIPlot):
@@ -12,6 +12,7 import numpy
12 12 from schainpy.model.graphics.jroplot_base import Plot, plt, log
13 13 from itertools import combinations
14 14
15
15 16 class SpectraPlot(Plot):
16 17 '''
17 18 Plot for Spectra data
@@ -36,10 +37,12 class SpectraPlot(Plot):
36 37 self.width = 3.5 * self.ncols
37 38 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
38 39 self.ylabel = 'Range [km]'
40 def update_list(self,dataOut):
41 if len(self.channelList) == 0:
42 self.channelList = dataOut.channelList
39 43
40 44 def update(self, dataOut):
41 if self.channelList == None:
42 self.channelList = dataOut.channelList
45 self.update_list(dataOut)
43 46 data = {}
44 47 meta = {}
45 48 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
@@ -178,9 +181,9 class CrossSpectraPlot(Plot):
178 181
179 182 data = self.data[-1]
180 183 cspc = data['cspc']
181 #print(self.crossPairs)
184
182 185 for n in range(len(self.data.pairs)):
183 #pair = self.data.pairs[n]
186
184 187 pair = self.crossPairs[n]
185 188
186 189 coh = cspc[n*2]
@@ -238,6 +241,7 class RTIPlot(Plot):
238 241 if len(self.channelList) == 0:
239 242 self.channelList = dataOut.channelList
240 243
244
241 245 def update(self, dataOut):
242 246 self.update_list(dataOut)
243 247 data = {}
@@ -691,7 +691,7 class Reader(object):
691 691 """Check if the given datetime is in range"""
692 692 startDateTime= datetime.datetime.combine(startDate,startTime)
693 693 endDateTime = datetime.datetime.combine(endDate,endTime)
694 #print("dt eval: ", dt, startDateTime,endDateTime)
694
695 695 if startDateTime <= dt <= endDateTime:
696 696 return True
697 697 return False
@@ -644,7 +644,7 class AMISRReader(ProcessingUnit):
644 644
645 645 self.profileIndex += 1
646 646
647 return self.dataOut.data
647 return self.dataOut.data #retorno necesario??
648 648
649 649
650 650 def run(self, **kwargs):
@@ -82,7 +82,7 class HDFReader(Reader, ProcessingUnit):
82 82
83 83 def __init__(self):
84 84 ProcessingUnit.__init__(self)
85 self.dataOut = Parameters()
85
86 86 self.ext = ".hdf5"
87 87 self.optchar = "D"
88 88 self.meta = {}
@@ -95,6 +95,10 class HDFReader(Reader, ProcessingUnit):
95 95 self.folderfmt = "*%Y%j"
96 96 self.utcoffset = 0
97 97
98 self.dataOut = Parameters()
99 self.dataOut.error=False ## NOTE: Importante definir esto antes inicio
100 self.dataOut.flagNoData = True
101
98 102 def setup(self, **kwargs):
99 103
100 104 self.set_kwargs(**kwargs)
@@ -109,7 +113,7 class HDFReader(Reader, ProcessingUnit):
109 113 self.endDate, self.expLabel, self.ext, self.walk,
110 114 self.filefmt, self.folderfmt)
111 115 pathname, filename = os.path.split(fullpath)
112 #print(pathname,filename)
116
113 117 try:
114 118 fullpath = next(fullpath)
115 119
@@ -140,7 +144,7 class HDFReader(Reader, ProcessingUnit):
140 144
141 145 self.setNextFile()
142 146
143 return
147
144 148
145 149
146 150 def readFirstHeader(self):
@@ -150,16 +154,12 class HDFReader(Reader, ProcessingUnit):
150 154 self.__readData()
151 155 self.__setBlockList()
152 156
153 if 'type' in self.meta:
154 ##print("Creting dataOut...")
155 self.dataOut = eval(self.meta['type'])()
156 ##print(vars(self.dataOut))
157 157
158 158 for attr in self.meta:
159 ##print("attr: ", attr)
160 ##print(type(self.dataOut).__name__)
161 setattr(self.dataOut, attr, self.meta[attr])
162 159
160 setattr(self.dataOut, attr, self.meta[attr])
161 self.dataOut.error=False
162 self.dataOut.flagNoData = False
163 163 self.blockIndex = 0
164 164
165 165 return
@@ -276,10 +276,10 class HDFReader(Reader, ProcessingUnit):
276 276 if not self.isDateTimeInRange(self.startFileDatetime, self.startDate, self.endDate, self.startTime, self.endTime):
277 277 self.dataOut.flagNoData = True
278 278 self.blockIndex = self.blocksPerFile
279 #self.dataOut.error = True TERMINA EL PROGRAMA, removido
279 self.dataOut.error = True # TERMINA EL PROGRAMA
280 280 return
281 281 for attr in self.data:
282 #print("attr ",attr)
282
283 283 if self.data[attr].ndim == 1:
284 284 setattr(self.dataOut, attr, self.data[attr][self.blockIndex])
285 285 else:
@@ -298,9 +298,11 class HDFReader(Reader, ProcessingUnit):
298 298 self.blockIndex,
299 299 self.blocksPerFile),self.name)
300 300
301 if self.blockIndex == self.blocksPerFile:
302 self.setNextFile()
303
301 304 self.dataOut.flagNoData = False
302 self.dataOut.error = False
303 return
305
304 306
305 307 def run(self, **kwargs):
306 308
@@ -308,13 +310,8 class HDFReader(Reader, ProcessingUnit):
308 310 self.setup(**kwargs)
309 311 self.isConfig = True
310 312
311 if self.blockIndex == self.blocksPerFile:
312 self.setNextFile()
313
314 313 self.getData()
315 314
316 return
317
318 315 @MPDecorator
319 316 class HDFWriter(Operation):
320 317 """Operation to write HDF5 files.
@@ -645,7 +642,6 class HDFWriter(Operation):
645 642 if (self.blockIndex == self.blocksPerFile) or self.timeFlag():
646 643 self.closeFile()
647 644 self.setNextFile()
648 print("breaking file")
649 645
650 646 for i, ds in enumerate(self.ds):
651 647 attr, ch = self.data[i]
@@ -32,6 +32,7 class ProcessingUnit(object):
32 32
33 33 self.dataIn = unit.dataOut
34 34
35
35 36 def getAllowedArgs(self):
36 37 if hasattr(self, '__attrs__'):
37 38 return self.__attrs__
@@ -64,6 +65,7 class ProcessingUnit(object):
64 65 self.dataOut.error = self.dataIn.error
65 66 self.dataOut.flagNoData = True
66 67 except:
68
67 69 err = traceback.format_exc()
68 70 if 'SchainWarning' in err:
69 71 log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name)
@@ -142,6 +142,7 class ParametersProc(ProcessingUnit):
142 142 # self.dataOut.normFactor = self.dataIn.normFactor
143 143 self.dataOut.pairsList = self.dataIn.pairsList
144 144 self.dataOut.groupList = self.dataIn.pairsList
145
145 146 self.dataOut.flagNoData = False
146 147
147 148 if hasattr(self.dataIn, 'ChanDist'): #Distances of receiver channels
@@ -183,7 +184,6 class ParametersProc(ProcessingUnit):
183 184 if self.dataIn.type == "Parameters":
184 185 self.dataOut.copy(self.dataIn)
185 186 self.dataOut.flagNoData = False
186 self.prin("DAta In")
187 187 return True
188 188
189 189 self.__updateObjFromInput()
@@ -20,7 +20,7 from schainpy.model.data.jrodata import hildebrand_sekhon
20 20 from schainpy.utils import log
21 21
22 22 from scipy.optimize import curve_fit
23
23 SPEED_OF_LIGHT = 299792458
24 24
25 25 class SpectraProc(ProcessingUnit):
26 26
@@ -68,6 +68,8 class SpectraProc(ProcessingUnit):
68 68 self.dataOut.azimuthList = self.dataIn.azimuthList
69 69 self.dataOut.elevationList = self.dataIn.elevationList
70 70
71
72
71 73 def __getFft(self):
72 74 """
73 75 Convierte valores de Voltaje a Spectra
@@ -121,7 +123,7 class SpectraProc(ProcessingUnit):
121 123 self.dataOut.flagShiftFFT = False
122 124
123 125 def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False):
124 #print("spectra run")
126
125 127 if self.dataIn.type == "Spectra":
126 128 self.dataOut.copy(self.dataIn)
127 129 if shift_fft:
@@ -135,6 +137,7 class SpectraProc(ProcessingUnit):
135 137 if pairsList:
136 138 self.__selectPairs(pairsList)
137 139
140
138 141 elif self.dataIn.type == "Voltage":
139 142
140 143 self.dataOut.flagNoData = True
@@ -546,7 +549,6 class CleanRayleigh(Operation):
546 549 self.currentTime = self.__initime
547 550 self.pairsArray = numpy.array(dataOut.pairsList)
548 551 self.factor_stdv = factor_stdv
549 #print("CHANNELS: ",[x for x in self.channels])
550 552
551 553 if n != None :
552 554 self.byProfiles = True
@@ -560,11 +562,11 class CleanRayleigh(Operation):
560 562
561 563
562 564 def run(self, dataOut,min_hei=None,max_hei=None, n=None, timeInterval=10,factor_stdv=2.5):
563 #print (dataOut.utctime)
565
564 566 if not self.isConfig :
565 #print("Setting config")
567
566 568 self.setup(dataOut, min_hei,max_hei,n,timeInterval,factor_stdv)
567 #print("Config Done")
569
568 570 tini=dataOut.utctime
569 571
570 572 if self.byProfiles:
@@ -572,14 +574,14 class CleanRayleigh(Operation):
572 574 self.__dataReady = True
573 575 else:
574 576 if (tini - self.__initime) >= self.__integrationtime:
575 #print(tini - self.__initime,self.__profIndex)
577
576 578 self.__dataReady = True
577 579 self.__initime = tini
578 580
579 581 #if (tini.tm_min % 2) == 0 and (tini.tm_sec < 5 and self.fint==0):
580 582
581 583 if self.__dataReady:
582 #print("Data ready",self.__profIndex)
584
583 585 self.__profIndex = 0
584 586 jspc = self.buffer
585 587 jcspc = self.buffer2
@@ -1075,7 +1077,6 class IntegrationFaradaySpectra(Operation):
1075 1077 buffer_cspc=numpy.copy(self.__buffer_cspc[:,:,:,k])
1076 1078 outliers_IDs_cspc=[]
1077 1079 cspc_outliers_exist=False
1078 #print("AQUIII")
1079 1080 for i in range(self.nChannels):#dataOut.nChannels):
1080 1081
1081 1082 buffer1=numpy.copy(self.__buffer_spc[:,i,:,k])
General Comments 0
You need to be logged in to leave comments. Login now