##// END OF EJS Templates
updates real multiprocess, save hdf5, utils_Io
joabAM -
r1559:6d931be610e9
parent child
Show More
@@ -17,9 +17,9 import json
17 17
18 18 import schainpy.admin
19 19 from schainpy.utils import log
20 from .jroheaderIO import SystemHeader, RadarControllerHeader
20 from .jroheaderIO import SystemHeader, RadarControllerHeader,ProcessingHeader
21 21 from schainpy.model.data import _noise
22
22 SPEED_OF_LIGHT = 3e8
23 23
24 24 def getNumpyDtype(dataTypeCode):
25 25
@@ -190,7 +190,7 class JROData(GenericData):
190 190 blocknow = None
191 191 azimuth = None
192 192 zenith = None
193 beam = Beam()
193
194 194 profileIndex = None
195 195 error = None
196 196 data = None
@@ -200,10 +200,17 class JROData(GenericData):
200 200 azimuthList = []
201 201 elevationList = []
202 202 last_noise = None
203 radar_ipp = None
203 __ipp = None
204 __ippSeconds = None
204 205 sampled_heightsFFT = None
205 206 pulseLength_TxA = None
206 207 deltaHeight = None
208 code = None
209 nCode = None
210 nBaud = None
211 unitsDescription = "The units of the parameters are according to the International System of units (Seconds, Meter, Hertz, ...), except \
212 the parameters related to distances such as heightList, or heightResolution wich are in Km"
213
207 214
208 215 def __str__(self):
209 216
@@ -268,7 +275,7 class JROData(GenericData):
268 275 return fmax
269 276
270 277 def getFmax(self):
271 PRF = 1. / (self.ippSeconds * self.nCohInt)
278 PRF = 1. / (self.__ippSeconds * self.nCohInt)
272 279
273 280 fmax = PRF
274 281 return fmax
@@ -285,61 +292,67 class JROData(GenericData):
285 292 def ippSeconds(self):
286 293 '''
287 294 '''
288 return self.radarControllerHeaderObj.ippSeconds
295 #return self.radarControllerHeaderObj.ippSeconds
296 return self.__ippSeconds
289 297
290 298 @ippSeconds.setter
291 299 def ippSeconds(self, ippSeconds):
292 300 '''
293 301 '''
294 self.radarControllerHeaderObj.ippSeconds = ippSeconds
295
296 @property
297 def code(self):
298 '''
299 '''
300 return self.radarControllerHeaderObj.code
301
302 @code.setter
303 def code(self, code):
304 '''
305 '''
306 self.radarControllerHeaderObj.code = code
302 #self.radarControllerHeaderObj.ippSeconds = ippSeconds
303 self.__ippSeconds = ippSeconds
304 self.__ipp = ippSeconds*SPEED_OF_LIGHT/2000.0
307 305
308 @property
309 def nCode(self):
310 '''
311 '''
312 return self.radarControllerHeaderObj.nCode
313
314 @nCode.setter
315 def nCode(self, ncode):
316 '''
317 '''
318 self.radarControllerHeaderObj.nCode = ncode
319
320 @property
321 def nBaud(self):
322 '''
323 '''
324 return self.radarControllerHeaderObj.nBaud
325 306
326 @nBaud.setter
327 def nBaud(self, nbaud):
328 '''
329 '''
330 self.radarControllerHeaderObj.nBaud = nbaud
307 # @property
308 # def code(self):
309 # '''
310 # '''
311 # return self.radarControllerHeaderObj.code
312 #
313 # @code.setter
314 # def code(self, code):
315 # '''
316 # '''
317 # self.radarControllerHeaderObj.code = code
318 #
319 # @property
320 # def nCode(self):
321 # '''
322 # '''
323 # return self.radarControllerHeaderObj.nCode
324 #
325 # @nCode.setter
326 # def nCode(self, ncode):
327 # '''
328 # '''
329 # self.radarControllerHeaderObj.nCode = ncode
330 #
331 # @property
332 # def nBaud(self):
333 # '''
334 # '''
335 # return self.radarControllerHeaderObj.nBaud
336 #
337 # @nBaud.setter
338 # def nBaud(self, nbaud):
339 # '''
340 # '''
341 # self.radarControllerHeaderObj.nBaud = nbaud
331 342
332 343 @property
333 344 def ipp(self):
334 345 '''
335 346 '''
336 return self.radarControllerHeaderObj.ipp
347 return self.__ipp
348 #return self.radarControllerHeaderObj.ipp
337 349
338 350 @ipp.setter
339 351 def ipp(self, ipp):
340 352 '''
341 353 '''
342 self.radarControllerHeaderObj.ipp = ipp
354 self.__ipp = ipp
355 #self.radarControllerHeaderObj.ipp = ipp
343 356
344 357 @property
345 358 def metadata(self):
@@ -364,6 +377,7 class Voltage(JROData):
364 377 self.useLocalTime = True
365 378 self.radarControllerHeaderObj = RadarControllerHeader()
366 379 self.systemHeaderObj = SystemHeader()
380 self.processingHeaderObj = ProcessingHeader()
367 381 self.type = "Voltage"
368 382 self.data = None
369 383 self.nProfiles = None
@@ -456,6 +470,7 class Spectra(JROData):
456 470 self.useLocalTime = True
457 471 self.radarControllerHeaderObj = RadarControllerHeader()
458 472 self.systemHeaderObj = SystemHeader()
473 self.processingHeaderObj = ProcessingHeader()
459 474 self.type = "Spectra"
460 475 self.timeZone = 0
461 476 self.nProfiles = None
@@ -924,12 +939,15 class Parameters(Spectra):
924 939 noise_estimation = None
925 940 GauSPC = None # Fit gaussian SPC
926 941
942
943
927 944 def __init__(self):
928 945 '''
929 946 Constructor
930 947 '''
931 948 self.radarControllerHeaderObj = RadarControllerHeader()
932 949 self.systemHeaderObj = SystemHeader()
950 self.processingHeaderObj = ProcessingHeader()
933 951 self.type = "Parameters"
934 952 self.timeZone = 0
935 953
@@ -279,6 +279,7 class SystemHeader(Header):
279 279 class RadarControllerHeader(Header):
280 280
281 281 expType = None
282 dtype = ""
282 283 nTx = None
283 284 ipp = None
284 285 txA = None
@@ -291,19 +292,32 class RadarControllerHeader(Header):
291 292 fClock = None
292 293 prePulseBefore = None
293 294 prePulseAfter = None
294 rangeIpp = None
295 rangeIpp = None #variables innecesarias?
295 296 rangeTxA = None
296 297 rangeTxB = None
297 298 structure = RADAR_STRUCTURE
298 299 __size = None
300 ################################################
301 ippSeconds = None
302 frequency = None
303 sampleRate = None
304 nOsamp = None
305 channelList = []
306 azimuthList = []
307 elevationList =[]
308 codeList = []
309 nChannels = 1
310 heightList = []
311 heightResolution = None
312
299 313
300 314 def __init__(self, expType=2, nTx=1,
301 315 ipp=None, txA=0, txB=0,
302 316 nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None,
303 317 numTaus=0, line6Function=0, line5Function=0, fClock=None,
304 318 prePulseBefore=0, prePulseAfter=0,
305 codeType=0, nCode=0, nBaud=0, code=[],
306 flip1=0, flip2=0):
319 codeType=0, nCode=0, nBaud=0, code=[],nOsamp = None, frequency = None,sampleRate=None,
320 flip1=0, flip2=0, nChannels=1):
307 321
308 322 # self.size = 116
309 323 self.expType = expType
@@ -314,7 +328,8 class RadarControllerHeader(Header):
314 328 self.rangeIpp = ipp
315 329 self.rangeTxA = txA
316 330 self.rangeTxB = txB
317
331 self.frequency = frequency
332 self.sampleRate = sampleRate
318 333 self.nWindows = nWindows
319 334 self.numTaus = numTaus
320 335 self.codeType = codeType
@@ -332,6 +347,7 class RadarControllerHeader(Header):
332 347 self.nCode = nCode
333 348 self.nBaud = nBaud
334 349 self.code = code
350 self.nOsamp = nOsamp
335 351 self.flip1 = flip1
336 352 self.flip2 = flip2
337 353
@@ -578,6 +594,7 class RadarControllerHeader(Header):
578 594 class ProcessingHeader(Header):
579 595
580 596 # size = None
597
581 598 dtype = None
582 599 blockSize = None
583 600 profilesPerBlock = None
@@ -590,6 +607,21 class ProcessingHeader(Header):
590 607 structure = PROCESSING_STRUCTURE
591 608 flag_dc = None
592 609 flag_cspc = None
610 #########################################################
611 nFFTPoints = None
612 nSamplesFFT = None
613 channelList = []
614 azimuthList = []
615 elevationList =[]
616 codeList = []
617 nChannels = 1
618 heightList = []
619 ipp = None
620 ippSeconds = None
621 timeIncohInt = None
622 #################
623 rangeIpp = None
624 heightResolution = None
593 625
594 626 def __init__(self, dtype=0, blockSize=0, profilesPerBlock=0, dataBlocksPerFile=0, nWindows=0, processFlags=0, nCohInt=0,
595 627 nIncohInt=0, totalSpectra=0, nHeights=0, firstHeight=0, deltaHeight=0, samplesWin=0, spectraComb=0, nCode=0,
@@ -623,6 +655,7 class ProcessingHeader(Header):
623 655 self.flag_deflip = False
624 656 self.length = 0
625 657
658
626 659 def read(self, fp):
627 660 self.length = 0
628 661 try:
@@ -77,7 +77,7 class SpectraPlot(Plot):
77 77 spc = 10*numpy.log10(z)
78 78
79 79 data['spc'] = spc
80 print(spc[0].shape)
80 #print(spc[0].shape)
81 81 data['rti'] = spc.mean(axis=1)
82 82 data['noise'] = noise
83 83 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
@@ -309,16 +309,19 class RTIPlot(Plot):
309 309 try:
310 310 if self.channelList != None:
311 311 if len(self.elevationList) > 0 and len(self.azimuthList) > 0:
312 self.titles = ['{} Channel {} ({:2.1f} Elev, {:2.1f} Azth)'.format(
312 self.titles = ['{} Channel {} ({:2.1f} Elev, {:2.1f} Azth)'.format(
313 313 self.CODE.upper(), x, self.elevationList[x], self.azimuthList[x]) for x in self.channelList]
314 314 else:
315 self.titles = ['{} Channel {}'.format(
315 self.titles = ['{} Channel {}'.format(
316 316 self.CODE.upper(), x) for x in self.channelList]
317 317 except:
318 318 if self.channelList.any() != None:
319
320 self.titles = ['{} Channel {}'.format(
321 self.CODE.upper(), x) for x in self.channelList]
319 if len(self.elevationList) > 0 and len(self.azimuthList) > 0:
320 self.titles = ['{} Channel {} ({:2.1f} Elev, {:2.1f} Azth)'.format(
321 self.CODE.upper(), x, self.elevationList[x], self.azimuthList[x]) for x in self.channelList]
322 else:
323 self.titles = ['{} Channel {}'.format(
324 self.CODE.upper(), x) for x in self.channelList]
322 325
323 326 if self.decimation is None:
324 327 x, y, z = self.fill_gaps(self.x, self.y, self.z)
@@ -1002,6 +1005,7 class NoiselessRTIPlot(Plot):
1002 1005 def update(self, dataOut):
1003 1006 if len(self.channelList) == 0:
1004 1007 self.update_list(dataOut)
1008
1005 1009 data = {}
1006 1010 meta = {}
1007 1011 #print(dataOut.max_nIncohInt, dataOut.nIncohInt)
@@ -1037,9 +1041,12 class NoiselessRTIPlot(Plot):
1037 1041 self.CODE.upper(), x) for x in self.channelList]
1038 1042 except:
1039 1043 if self.channelList.any() != None:
1040
1041 self.titles = ['{} Channel {}'.format(
1042 self.CODE.upper(), x) for x in self.channelList]
1044 if len(self.elevationList) > 0 and len(self.azimuthList) > 0:
1045 self.titles = ['{} Channel {} ({:2.1f} Elev, {:2.1f} Azth)'.format(
1046 self.CODE.upper(), x, self.elevationList[x], self.azimuthList[x]) for x in self.channelList]
1047 else:
1048 self.titles = ['{} Channel {}'.format(
1049 self.CODE.upper(), x) for x in self.channelList]
1043 1050
1044 1051
1045 1052 if self.decimation is None:
@@ -21,7 +21,7 try:
21 21 except:
22 22 from time import sleep
23 23
24 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
24 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader,ProcessingHeader
25 25 from schainpy.model.data.jrodata import Voltage
26 26 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
27 27 from numpy import imag
@@ -94,10 +94,11 class AMISRReader(ProcessingUnit):
94 94 code = None,
95 95 nCode = 1,
96 96 nBaud = 0,
97 nOsamp = None,
97 98 online=False,
98 99 old_beams=False,
99 100 margin_days=1,
100 nFFT = 1,
101 nFFT = None,
101 102 nChannels = None,
102 103 ):
103 104
@@ -110,6 +111,7 class AMISRReader(ProcessingUnit):
110 111 self.code = code
111 112 self.nCode = int(nCode)
112 113 self.nBaud = int(nBaud)
114 self.nOsamp = int(nOsamp)
113 115 self.margin_days = margin_days
114 116 self.__sampleRate = None
115 117
@@ -154,7 +156,7 class AMISRReader(ProcessingUnit):
154 156
155 157 header = 'Raw11/Data/RadacHeader'
156 158 if self.nChannels == None:
157 expFile = fp['Setup/ExperimentFile'][()].decode()
159 expFile = fp['Setup/Experimentfile'][()].decode()
158 160 linesExp = expFile.split("\n")
159 161 a = [line for line in linesExp if "nbeamcodes" in line]
160 162 self.nChannels = int(a[0][11:])
@@ -164,6 +166,8 class AMISRReader(ProcessingUnit):
164 166 self.beamcodeFile = fp['Setup/Beamcodefile'][()].decode()
165 167 self.trueBeams = self.beamcodeFile.split("\n")
166 168 self.trueBeams.pop()#remove last
169 if self.nFFT == None:
170 log.error("FFT or number of repetitions per channels is needed",self.name)
167 171 beams_idx = [k*self.nFFT for k in range(self.nChannels)]
168 172 beams = [self.trueBeams[b] for b in beams_idx]
169 173 self.beamCode = [int(x, 16) for x in beams]
@@ -191,7 +195,7 class AMISRReader(ProcessingUnit):
191 195 self.timeStatus = fp.get(header+'/TimeStatus')# NOT USE FOR THIS
192 196 self.rangeFromFile = fp.get('Raw11/Data/Samples/Range')
193 197 self.frequency = fp.get('Rx/Frequency')
194 txAus = fp.get('Raw11/Data/Pulsewidth')
198 txAus = fp.get('Raw11/Data/Pulsewidth') #seconds
195 199 self.baud = fp.get('Raw11/Data/TxBaud')
196 200 sampleRate = fp.get('Rx/SampleRate')
197 201 self.__sampleRate = sampleRate[()]
@@ -207,7 +211,9 class AMISRReader(ProcessingUnit):
207 211
208 212 #filling radar controller header parameters
209 213 self.__ippKm = self.ippSeconds *.15*1e6 # in km
210 self.__txA = (txAus[()])*.15 #(ipp[us]*.15km/1us) in km
214 #self.__txA = txAus[()]*.15 #(ipp[us]*.15km/1us) in km
215 self.__txA = txAus[()] #seconds
216 self.__txAKm = self.__txA*1e6*.15
211 217 self.__txB = 0
212 218 nWindows=1
213 219 self.__nSamples = self.nsa
@@ -224,6 +230,7 class AMISRReader(ProcessingUnit):
224 230 self.__codeType = 1
225 231 self.__nCode = self.nCode
226 232 self.__nBaud = self.nBaud
233 self.__baudTX = self.__txA/(self.nBaud)
227 234 #self.__code = 0
228 235
229 236 #filling system header parameters
@@ -493,10 +500,12 class AMISRReader(ProcessingUnit):
493 500 new_block = numpy.empty((nblocks, nchan, numpy.int_(self.newProfiles), nsamples), dtype="complex64")
494 501 ############################################
495 502 profPerCH = int(self.profPerBlockRAW / (self.nFFT* self.nChannels))
496
503 #profPerCH = int(self.profPerBlockRAW / self.nChannels)
497 504 for thisChannel in range(nchan):
498 505
499 idx_ch = [thisChannel+(k*nchan*self.nFFT) for k in range(profPerCH)]
506
507 idx_ch = [self.nFFT*(thisChannel + nchan*k) for k in range(profPerCH)]
508 #print(idx_ch)
500 509 if self.nFFT > 1:
501 510 aux = [numpy.arange(i, i+self.nFFT) for i in idx_ch]
502 511 idx_ch = None
@@ -522,17 +531,7 class AMISRReader(ProcessingUnit):
522 531 def fillJROHeader(self):
523 532
524 533 #fill radar controller header
525 self.dataOut.radarControllerHeaderObj = RadarControllerHeader(ipp=self.__ippKm,
526 txA=self.__txA,
527 txB=0,
528 nWindows=1,
529 nHeights=self.__nSamples,
530 firstHeight=self.__firstHeight,
531 deltaHeight=self.__deltaHeight,
532 codeType=self.__codeType,
533 nCode=self.__nCode, nBaud=self.__nBaud,
534 code = self.__code,
535 fClock=self.__sampleRate)
534
536 535 #fill system header
537 536 self.dataOut.systemHeaderObj = SystemHeader(nSamples=self.__nSamples,
538 537 nProfiles=self.newProfiles,
@@ -552,6 +551,7 class AMISRReader(ProcessingUnit):
552 551 ranges = numpy.reshape(self.rangeFromFile[()],(-1))
553 552 self.dataOut.heightList = ranges/1000.0 #km
554 553 self.dataOut.channelList = self.__channelList
554
555 555 self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights
556 556
557 557 # self.dataOut.channelIndexList = None
@@ -560,6 +560,10 class AMISRReader(ProcessingUnit):
560 560 self.dataOut.azimuthList = numpy.array(self.azimuthList)
561 561 self.dataOut.elevationList = numpy.array(self.elevationList)
562 562 self.dataOut.codeList = numpy.array(self.beamCode)
563
564
565
566
563 567 #print(self.dataOut.elevationList)
564 568 self.dataOut.flagNoData = True
565 569
@@ -581,14 +585,37 class AMISRReader(ProcessingUnit):
581 585 self.dataOut.flagDeflipData = False #asumo que la data esta sin flip
582 586 self.dataOut.flagShiftFFT = False
583 587 self.dataOut.ippSeconds = self.ippSeconds
584 self.dataOut.radar_ipp = self.ippSeconds
585 self.dataOut.pulseLength_TxA = self.__txA/0.15
586 self.dataOut.deltaHeight = self.__deltaHeight
587 #Time interval between profiles
588 #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt
588 self.dataOut.ipp = self.__ippKm
589
589 590
590 591 self.dataOut.frequency = self.__frequency
591 592 self.dataOut.realtime = self.online
593
594 self.dataOut.radarControllerHeaderObj = RadarControllerHeader(ipp=self.__ippKm,
595 txA=self.__txAKm,
596 txB=0,
597 nWindows=1,
598 nHeights=self.__nSamples,
599 firstHeight=self.__firstHeight,
600 codeType=self.__codeType,
601 nCode=self.__nCode, nBaud=self.__nBaud,
602 code = self.__code,
603 nOsamp=self.nOsamp,
604 frequency = self.__frequency,
605 sampleRate= self.__sampleRate,
606 fClock=self.__sampleRate)
607
608
609 self.dataOut.radarControllerHeaderObj.heightList = ranges/1000.0 #km
610 self.dataOut.radarControllerHeaderObj.heightResolution = self.__deltaHeight
611 self.dataOut.radarControllerHeaderObj.rangeIpp = self.__ippKm #km
612 self.dataOut.radarControllerHeaderObj.rangeTxA = self.__txA*1e6*.15 #km
613 self.dataOut.radarControllerHeaderObj.nChannels = self.nchannels
614 self.dataOut.radarControllerHeaderObj.channelList = self.__channelList
615 self.dataOut.radarControllerHeaderObj.azimuthList = self.azimuthList
616 self.dataOut.radarControllerHeaderObj.elevationList = self.elevationList
617 self.dataOut.radarControllerHeaderObj.dtype = "Voltage"
618 self.dataOut.ippSeconds = self.ippSeconds
592 619 pass
593 620
594 621 def readNextFile(self,online=False):
@@ -94,7 +94,7 class HDFReader(Reader, ProcessingUnit):
94 94 self.filefmt = "*%Y%j***"
95 95 self.folderfmt = "*%Y%j"
96 96 self.utcoffset = 0
97
97 self.flagUpdateDataOut = False
98 98 self.dataOut = Parameters()
99 99 self.dataOut.error=False ## NOTE: Importante definir esto antes inicio
100 100 self.dataOut.flagNoData = True
@@ -147,19 +147,57 class HDFReader(Reader, ProcessingUnit):
147 147
148 148
149 149
150 # def readFirstHeader(self):
151 # '''Read metadata and data'''
152 #
153 # self.__readMetadata2()
154 # self.__readData()
155 # self.__setBlockList()
156 #
157 # for attr in self.meta:
158 # setattr(self.dataOut, attr, self.meta[attr])
159 # self.blockIndex = 0
160 #
161 # return
162
150 163 def readFirstHeader(self):
151 164 '''Read metadata and data'''
152 165
153 self.__readMetadata()
166 self.__readMetadata2()
154 167 self.__readData()
155 168 self.__setBlockList()
156
157 169 for attr in self.meta:
158 setattr(self.dataOut, attr, self.meta[attr])
170 if "processingHeaderObj" in attr:
171 self.flagUpdateDataOut=True
172 at = attr.split('.')
173 if len(at) > 1:
174 setattr(eval("self.dataOut."+at[0]),at[1], self.meta[attr])
175 else:
176 setattr(self.dataOut, attr, self.meta[attr])
159 177 self.blockIndex = 0
160 178
179 if self.flagUpdateDataOut:
180 self.updateDataOut()
181
161 182 return
162 183
184 def updateDataOut(self):
185 self.dataOut.azimuthList = self.dataOut.processingHeaderObj.azimuthList
186 self.dataOut.elevationList = self.dataOut.processingHeaderObj.elevationList
187 self.dataOut.heightList = self.dataOut.processingHeaderObj.heightList
188 self.dataOut.ippSeconds = self.dataOut.processingHeaderObj.ipp
189 self.dataOut.elevationList = self.dataOut.processingHeaderObj.elevationList
190 self.dataOut.channelList = self.dataOut.processingHeaderObj.channelList
191 self.dataOut.nCohInt = self.dataOut.processingHeaderObj.nCohInt
192 self.dataOut.nFFTPoints = self.dataOut.processingHeaderObj.nFFTPoints
193 self.flagUpdateDataOut = False
194 self.dataOut.frequency = self.dataOut.radarControllerHeaderObj.frequency
195 #self.dataOut.heightList = self.dataOut.processingHeaderObj.heightList
196
197
198 return
199
200
163 201 def __setBlockList(self):
164 202 '''
165 203 Selects the data within the times defined
@@ -214,6 +252,38 class HDFReader(Reader, ProcessingUnit):
214 252 return
215 253
216 254
255 def __readMetadata2(self):
256 '''
257 Reads Metadata
258 '''
259
260 meta = {}
261
262 if self.description:
263 for key, value in self.description['Metadata'].items():
264 meta[key] = self.fp[value][()]
265 else:
266 grp = self.fp['Metadata']
267 for item in grp.values():
268 name = item.name
269 if isinstance(item, h5py.Dataset):
270 name = name.split("/")[-1]
271 meta[name] = item[()]
272 else:
273 grp2 = self.fp[name]
274 Obj = name.split("/")[-1]
275
276 for item2 in grp2.values():
277 name2 = Obj+"."+item2.name.split("/")[-1]
278 meta[name2] = item2[()]
279
280 if self.extras:
281 for key, value in self.extras.items():
282 meta[key] = value
283 self.meta = meta
284 #print(meta)
285 return
286
217 287
218 288 def checkForRealPath(self, nextFile, nextDay):
219 289
@@ -406,6 +476,8 class HDFWriter(Operation):
406 476 if self.metadataList is None:
407 477 self.metadataList = self.dataOut.metadata_list
408 478
479 self.metadataList = list(set(self.metadataList))
480
409 481 tableList = []
410 482 dsList = []
411 483
@@ -587,6 +659,56 class HDFWriter(Operation):
587 659 grp.create_dataset(self.getLabel(self.metadataList[i]), data=value)
588 660 return
589 661
662 def writeMetadata2(self, fp):
663
664 if self.description:
665 if 'Metadata' in self.description:
666 grp = fp.create_group('Metadata')
667 else:
668 grp = fp
669 else:
670 grp = fp.create_group('Metadata')
671
672
673 for i in range(len(self.metadataList)):
674
675 attribute = self.metadataList[i]
676 attr = attribute.split('.')
677 if len(attr) > 1:
678 if not hasattr(eval("self.dataOut."+attr[0]),attr[1]):
679 log.warning('Metadata: {}.{} not found'.format(attr[0],attr[1]), self.name)
680 continue
681 value = getattr(eval("self.dataOut."+attr[0]),attr[1])
682 if isinstance(value, bool):
683 if value is True:
684 value = 1
685 else:
686 value = 0
687 if isinstance(value,type(None)):
688 log.warning("Invalid value detected, {} is None".format(attribute), self.name)
689 value = 0
690 grp2 = None
691 if not 'Metadata/'+attr[0] in fp:
692 grp2 = fp.create_group('Metadata/'+attr[0])
693 else:
694 grp2 = fp['Metadata/'+attr[0]]
695 #print("attribute: ", attribute, value)
696 grp2.create_dataset(attr[1], data=value)
697
698 else:
699 if not hasattr(self.dataOut, attr[0] ):
700 log.warning('Metadata: `{}` not found'.format(attribute), self.name)
701 continue
702 value = getattr(self.dataOut, attr[0])
703 if isinstance(value, bool):
704 if value is True:
705 value = 1
706 else:
707 value = 0
708 grp.create_dataset(self.getLabel(attribute), data=value)
709
710 return
711
590 712 def writeData(self, fp):
591 713
592 714 if self.description:
@@ -649,7 +771,7 class HDFWriter(Operation):
649 771 #Setting HDF5 File
650 772 self.fp = h5py.File(self.filename, 'w')
651 773 #write metadata
652 self.writeMetadata(self.fp)
774 self.writeMetadata2(self.fp)
653 775 #Write data
654 776 self.writeData(self.fp)
655 777 log.log('Block No. {}/{} --> {}'.format(self.blockIndex+1, self.blocksPerFile,self.dataOut.datatime.ctime()), self.name)
@@ -123,6 +123,12 class MergeH5(object):
123 123 self.filefmt = "*%Y%j***"
124 124 self.folderfmt = "*%Y%j"
125 125
126 self.flag_spc = False
127 self.flag_pow = False
128 self.flag_snr = False
129 self.flag_nIcoh = False
130 self.flagProcessingHeader = False
131 self.flagControllerHeader = False
126 132
127 133 def setup(self):
128 134
@@ -187,12 +193,25 class MergeH5(object):
187 193
188 194 '''Read metadata and data'''
189 195
190 self.readMetadata(fp)
196 self.readMetadata(fp,ch)
197 #print(self.metadataList)
191 198 data = self.readData(fp)
192 199
193 200
194 201 for attr in self.meta:
195 setattr(self.ch_dataIn[ch], attr, self.meta[attr])
202
203 if "processingHeaderObj" in attr:
204 self.flagProcessingHeader=True
205
206 if "radarControllerHeaderObj" in attr:
207 self.flagControllerHeader=True
208
209 at = attr.split('.')
210 #print("AT ", at)
211 if len(at) > 1:
212 setattr(eval("self.ch_dataIn[ch]."+at[0]),at[1], self.meta[attr])
213 else:
214 setattr(self.ch_dataIn[ch], attr, self.meta[attr])
196 215
197 216 self.fill_dataIn(data, self.ch_dataIn[ch])
198 217
@@ -200,33 +219,57 class MergeH5(object):
200 219 return
201 220
202 221
203 def readMetadata(self, fp):
222 def readMetadata(self, fp, ch):
204 223 '''
205 224 Reads Metadata
206 225 '''
207 226 meta = {}
208 227 self.metadataList = []
209 228 grp = fp['Metadata']
210 for name in grp:
211 meta[name] = grp[name][()]
212 self.metadataList.append(name)
229 for item in grp.values():
230 name = item.name
231
232 if isinstance(item, h5py.Dataset):
233 name = name.split("/")[-1]
234 if 'List' in name:
235 meta[name] = item[()].tolist()
236 else:
237 meta[name] = item[()]
238 self.metadataList.append(name)
239 else:
240 grp2 = fp[name]
241 Obj = name.split("/")[-1]
242 #print(Obj)
243 for item2 in grp2.values():
244 name2 = Obj+"."+item2.name.split("/")[-1]
245 if 'List' in name2:
246 meta[name2] = item2[()].tolist()
247 else:
248 meta[name2] = item2[()]
249 self.metadataList.append(name2)
250
251
213 252
214 for k in meta:
215 if ('List' in k):
216 meta[k] = meta[k].tolist()
217 253 if not self.meta:
218 self.meta = meta
219 self.meta["channelList"] =[n for n in range(self.nChannels)]
254 self.meta = meta.copy()
255 for key in list(self.meta.keys()):
256 if "channelList" in key:
257 self.meta["channelList"] =[n for n in range(self.nChannels)]
258 if "processingHeaderObj" in key:
259 self.meta["processingHeaderObj.channelList"] =[n for n in range(self.nChannels)]
260 if "radarControllerHeaderObj" in key:
261 self.meta["radarControllerHeaderObj.channelList"] =[n for n in range(self.nChannels)]
220 262 return 1
263
221 264 else:
222 if len(self.meta) == len(meta):
223 for k in meta:
224 if 'List' in k and 'channel' not in k and "height" not in k:
225 self.meta[k] += meta[k]
226 265
227 return 1
228 else:
229 return 0
266 for k in list(self.meta.keys()):
267 if 'List' in k and 'channel' not in k and "height" not in k and "radarControllerHeaderObj" not in k:
268 self.meta[k] += meta[k]
269
270 #print("Metadata: ",self.meta)
271 return 1
272
230 273
231 274
232 275
@@ -237,17 +280,23 class MergeH5(object):
237 280 setattr(dataIn, attr, data[attr][:])
238 281 else:
239 282 setattr(dataIn, attr, numpy.squeeze(data[attr][:,:]))
240 print("shape in", dataIn.data_spc.shape, len(dataIn.data_spc))
241 if dataIn.data_spc.ndim > 3:
242 dataIn.data_spc = dataIn.data_spc[0]
243 #print("shape in", dataIn.data_spc.shape)
283 #print("shape in", dataIn.data_spc.shape, len(dataIn.data_spc))
284 if self.flag_spc:
285 if dataIn.data_spc.ndim > 3:
286 dataIn.data_spc = dataIn.data_spc[0]
287 #print("shape in", dataIn.data_spc.shape)
244 288
245 289
246 290
247 291 def getBlocksPerFile(self):
248 292 b = numpy.zeros(self.nChannels)
249 293 for i in range(self.nChannels):
250 b[i] = self.ch_dataIn[i].data_spc.shape[0] #number of blocks
294 if self.flag_spc:
295 b[i] = self.ch_dataIn[i].data_spc.shape[0] #number of blocks
296 elif self.flag_pow:
297 b[i] = self.ch_dataIn[i].data_pow.shape[0] #number of blocks
298 elif self.flag_snr:
299 b[i] = self.ch_dataIn[i].data_snr.shape[0] #number of blocks
251 300
252 301 self.blocksPerFile = int(b.min())
253 302 iresh_ch = numpy.where(b > self.blocksPerFile)[0]
@@ -307,6 +356,12 class MergeH5(object):
307 356 grp = fp['Data']
308 357
309 358 for name in grp:
359 if "spc" in name:
360 self.flag_spc = True
361 if "pow" in name:
362 self.flag_pow = True
363 if "snr" in name:
364 self.flag_snr = True
310 365 if isinstance(grp[name], h5py.Dataset):
311 366 array = grp[name][()]
312 367 elif isinstance(grp[name], h5py.Group):
@@ -323,70 +378,153 class MergeH5(object):
323 378 def getDataOut(self):
324 379
325 380 self.dataOut = self.ch_dataIn[0].copy() #dataIn #blocks, fft, hei for metadata
326 if self.dataOut.data_spc.ndim < 3:
327 return 0
381 if self.flagProcessingHeader:
382 self.dataOut.processingHeaderObj = self.ch_dataIn[0].processingHeaderObj.copy()
383 self.dataOut.heightList = self.dataOut.processingHeaderObj.heightList
384 self.dataOut.ippSeconds = self.dataOut.processingHeaderObj.ipp
385 self.dataOut.channelList = self.dataOut.processingHeaderObj.channelList
386 self.dataOut.nCohInt = self.dataOut.processingHeaderObj.nCohInt
387 self.dataOut.nFFTPoints = self.dataOut.processingHeaderObj.nFFTPoints
388
389 if self.flagControllerHeader:
390 self.dataOut.radarControllerHeaderObj = self.ch_dataIn[0].radarControllerHeaderObj.copy()
391 self.dataOut.frequency = self.dataOut.radarControllerHeaderObj.frequency
392 #--------------------------------------------------------------------
393
394
395 #--------------------------------------------------------------------
396 if self.flag_spc:
397 if self.dataOut.data_spc.ndim < 3:
398 print("shape spc in: ",self.dataOut.data_spc.shape )
399 return 0
400 if self.flag_pow:
401 if self.dataOut.data_pow.ndim < 2:
402 print("shape pow in: ",self.dataOut.data_pow.shape )
403 return 0
404 if self.flag_snr:
405 if self.dataOut.data_snr.ndim < 2:
406 print("shape snr in: ",self.dataOut.data_snr.shape )
407 return 0
408
328 409 self.dataOut.data_spc = None
410 self.dataOut.data_cspc = None
411 self.dataOut.data_pow = None
412 self.dataOut.data_snr = None
329 413 self.dataOut.utctim = None
330 414 self.dataOut.nIncohInt = None
331 #print(self.ch_dataIn[0].data_spc.shape)
332 spc = [data.data_spc for data in self.ch_dataIn]
333 self.dataOut.data_spc = numpy.stack(spc, axis=1) #blocks, ch, fft, hei
415 #--------------------------------------------------------------------
416 if self.flag_spc:
417 spc = [data.data_spc for data in self.ch_dataIn]
418 self.dataOut.data_spc = numpy.stack(spc, axis=1) #blocks, ch, fft, hei
419 #--------------------------------------------------------------------
420 if self.flag_pow:
421 pow = [data.data_pow for data in self.ch_dataIn]
422 self.dataOut.data_pow = numpy.stack(pow, axis=1) #blocks, ch, fft, hei
423 #--------------------------------------------------------------------
424 if self.flag_snr:
425 snr = [data.data_snr for data in self.ch_dataIn]
426 self.dataOut.data_snr = numpy.stack(snr, axis=1) #blocks, ch, fft, hei
427
428 #--------------------------------------------------------------------
334 429 time = [data.utctime for data in self.ch_dataIn]
335 430 time = numpy.asarray(time).mean(axis=0)
336 #time = numpy.reshape(time, (len(time),1))
337 431 time = numpy.squeeze(time)
338 432 self.dataOut.utctime = time
339 ints = [data.nIncohInt for data in self.ch_dataIn]
340 self.dataOut.nIncohInt = numpy.stack(ints, axis=1)
341
342
343 if self.dataOut.nIncohInt.ndim > 3:
344 aux = self.dataOut.nIncohInt
345 self.dataOut.nIncohInt = None
346 self.dataOut.nIncohInt = aux[0]
347
433 #--------------------------------------------------------------------
434 if self.flag_nIcoh:
435 ints = [data.nIncohInt for data in self.ch_dataIn]
436 self.dataOut.nIncohInt = numpy.stack(ints, axis=1)
437
438 if self.dataOut.nIncohInt.ndim > 3:
439 aux = self.dataOut.nIncohInt
440 self.dataOut.nIncohInt = None
441 self.dataOut.nIncohInt = aux[0]
442
443 if self.dataOut.nIncohInt.ndim < 3:
444 nIncohInt = numpy.repeat(self.dataOut.nIncohInt, self.dataOut.nHeights).reshape(self.blocksPerFile,self.nChannels, self.dataOut.nHeights)
445 #nIncohInt = numpy.reshape(nIncohInt, (self.blocksPerFile,self.nChannels, self.dataOut.nHeights))
446 self.dataOut.nIncohInt = None
447 self.dataOut.nIncohInt = nIncohInt
448
449 if (self.dataOut.nIncohInt.shape)[0]==self.nChannels: ## ch,blocks, hei
450 self.dataOut.nIncohInt = numpy.swapaxes(self.dataOut.nIncohInt, 0, 1) ## blocks,ch, hei
451 #--------------------------------------------------------------------
452 #print("utcTime: ", time.shape)
453 #print("data_spc ",self.dataOut.data_spc.shape)
454 if "data_cspc" in self.dataList:
455 pairsList = [pair for pair in itertools.combinations(self.channelList, 2)]
456 #print("PairsList: ", pairsList)
457 self.dataOut.pairsList = pairsList
458 cspc = []
348 459
349 if self.dataOut.nIncohInt.ndim < 3:
350 nIncohInt = numpy.repeat(self.dataOut.nIncohInt, self.dataOut.nHeights).reshape(self.blocksPerFile,self.nChannels, self.dataOut.nHeights)
351 #nIncohInt = numpy.reshape(nIncohInt, (self.blocksPerFile,self.nChannels, self.dataOut.nHeights))
352 self.dataOut.nIncohInt = None
353 self.dataOut.nIncohInt = nIncohInt
460 for i, j in pairsList:
461 cspc.append(self.ch_dataIn[i].data_spc*numpy.conjugate(self.ch_dataIn[j].data_spc)) #blocks, fft, hei
354 462
355 if (self.dataOut.nIncohInt.shape)[0]==self.nChannels: ## ch,blocks, hei
356 self.dataOut.nIncohInt = numpy.swapaxes(self.dataOut.nIncohInt, 0, 1) ## blocks,ch, hei
463 cspc = numpy.asarray(cspc) # # pairs, blocks, fft, hei
464 #print("cspc: ",cspc.shape)
465 self.dataOut.data_cspc = numpy.swapaxes(cspc, 0, 1) ## blocks, pairs, fft, hei
466 #print("dataOut.data_cspc: ",self.dataOut.data_cspc.shape)
467 #if "data_pow" in self.dataList:
357 468
358 #print("utcTime: ", time.shape)
359 #print("data_spc ",self.dataOut.data_spc.shape)
360 pairsList = [pair for pair in itertools.combinations(self.channelList, 2)]
361 #print("PairsList: ", pairsList)
362 self.dataOut.pairsList = pairsList
363 cspc = []
364
365 for i, j in pairsList:
366 cspc.append(self.ch_dataIn[i].data_spc*numpy.conjugate(self.ch_dataIn[j].data_spc)) #blocks, fft, hei
367
368 cspc = numpy.asarray(cspc) # # pairs, blocks, fft, hei
369 #print("cspc: ",cspc.shape)
370 self.dataOut.data_cspc = numpy.swapaxes(cspc, 0, 1) ## blocks, pairs, fft, hei
371 #print("dataOut.data_cspc: ",self.dataOut.data_cspc.shape)
372 469 return 1
373 470
471 # def writeMetadata(self, fp):
472 #
473 #
474 # grp = fp.create_group('Metadata')
475 #
476 # for i in range(len(self.metadataList)):
477 # if not hasattr(self.dataOut, self.metadataList[i]):
478 # print('Metadata: `{}` not found'.format(self.metadataList[i]))
479 # continue
480 # value = getattr(self.dataOut, self.metadataList[i])
481 # if isinstance(value, bool):
482 # if value is True:
483 # value = 1
484 # else:
485 # value = 0
486 # grp.create_dataset(self.getLabel(self.metadataList[i]), data=value)
487 # return
374 488 def writeMetadata(self, fp):
375 489
376 490
377 491 grp = fp.create_group('Metadata')
378 492
379 493 for i in range(len(self.metadataList)):
380 if not hasattr(self.dataOut, self.metadataList[i]):
381 print('Metadata: `{}` not found'.format(self.metadataList[i]))
382 continue
383 value = getattr(self.dataOut, self.metadataList[i])
384 if isinstance(value, bool):
385 if value is True:
386 value = 1
494 attribute = self.metadataList[i]
495 attr = attribute.split('.')
496 if '' in attr:
497 attr.remove('')
498 #print(attr)
499 if len(attr) > 1:
500 if not hasattr(eval("self.dataOut."+attr[0]),attr[1]):
501 print('Metadata: {}.{} not found'.format(attr[0],attr[1]))
502 continue
503 value = getattr(eval("self.dataOut."+attr[0]),attr[1])
504 if isinstance(value, bool):
505 if value is True:
506 value = 1
507 else:
508 value = 0
509 grp2 = None
510 if not 'Metadata/'+attr[0] in fp:
511 grp2 = fp.create_group('Metadata/'+attr[0])
387 512 else:
388 value = 0
389 grp.create_dataset(self.getLabel(self.metadataList[i]), data=value)
513 grp2 = fp['Metadata/'+attr[0]]
514
515 grp2.create_dataset(attr[1], data=value)
516
517 else:
518 if not hasattr(self.dataOut, attr[0] ):
519 print('Metadata: `{}` not found'.format(attribute))
520 continue
521 value = getattr(self.dataOut, attr[0])
522 if isinstance(value, bool):
523 if value is True:
524 value = 1
525 else:
526 value = 0
527 grp.create_dataset(self.getLabel(attribute), data=value)
390 528 return
391 529
392 530 def getDsList(self):
@@ -69,14 +69,14 class ParametersProc(ProcessingUnit):
69 69 self.dataOut.dstFlag = self.dataIn.dstFlag
70 70 self.dataOut.errorCount = self.dataIn.errorCount
71 71 self.dataOut.useLocalTime = self.dataIn.useLocalTime
72 self.dataOut.radar_ipp = self.dataIn.radar_ipp
72
73 73 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
74 #self.dataOut.radarControllerHeaderTxt = self.dataOut.radarControllerHeaderObj.toString()
74 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
75 75 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
76 76 self.dataOut.channelList = self.dataIn.channelList
77 77 self.dataOut.heightList = self.dataIn.heightList
78 self.dataOut.sampled_heightsFFT = self.dataIn.sampled_heightsFFT
79 self.dataOut.pulseLength_TxA = self.dataIn.pulseLength_TxA
78 self.dataOut.ipp = self.dataIn.ipp
79 self.dataOut.ippSeconds = self.dataIn.ippSeconds
80 80 self.dataOut.deltaHeight = self.dataIn.deltaHeight
81 81 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
82 82 # self.dataOut.nHeights = self.dataIn.nHeights
@@ -103,7 +103,7 class ParametersProc(ProcessingUnit):
103 103 self.dataOut.elevationList = self.dataIn.elevationList
104 104
105 105 def run(self):
106 # print("run parameter proc")
106 #print("run parameter proc")
107 107 #---------------------- Voltage Data ---------------------------
108 108 #print(self.dataIn.flagNoData)
109 109 if self.dataIn.type == "Voltage":
@@ -141,12 +141,8 class ParametersProc(ProcessingUnit):
141 141 self.dataOut.nIncohInt = self.dataIn.nIncohInt
142 142 self.dataOut.nFFTPoints = self.dataIn.nFFTPoints
143 143 self.dataOut.ippFactor = self.dataIn.ippFactor
144 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
145 #self.dataOut.radarControllerHeaderTxt = self.dataOut.radarControllerHeaderObj.toString()
146 self.dataOut.ipp = self.dataIn.ipp
147 self.dataOut.radar_ipp = self.dataIn.radar_ipp
148 self.dataOut.sampled_heightsFFT = self.dataIn.sampled_heightsFFT
149 self.dataOut.pulseLength_TxA = self.dataIn.pulseLength_TxA
144
145
150 146 self.dataOut.deltaHeight = self.dataIn.deltaHeight
151 147 self.dataOut.abscissaList = self.dataIn.getVelRange(1)
152 148 self.dataOut.spc_noise = self.dataIn.getNoise()
@@ -202,6 +198,7 class ParametersProc(ProcessingUnit):
202 198 return True
203 199
204 200 self.__updateObjFromInput()
201
205 202 self.dataOut.utctimeInit = self.dataIn.utctime
206 203 self.dataOut.paramInterval = self.dataIn.timeInterval
207 204
@@ -37,6 +37,7 class SpectraProc(ProcessingUnit):
37 37 self.id_min = None
38 38 self.id_max = None
39 39 self.setupReq = False #Agregar a todas las unidades de proc
40 self.nsamplesFFT = 0
40 41
41 42 def __updateSpecFromVoltage(self):
42 43
@@ -46,11 +47,11 class SpectraProc(ProcessingUnit):
46 47 self.dataOut.dstFlag = self.dataIn.dstFlag
47 48 self.dataOut.errorCount = self.dataIn.errorCount
48 49 self.dataOut.useLocalTime = self.dataIn.useLocalTime
49 try:
50 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
51 except:
52 pass
50
51 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
53 52 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
53 self.dataOut.ippSeconds = self.dataIn.ippSeconds
54 self.dataOut.ipp = self.dataIn.ipp
54 55 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
55 56 self.dataOut.channelList = self.dataIn.channelList
56 57 self.dataOut.heightList = self.dataIn.heightList
@@ -63,9 +64,6 class SpectraProc(ProcessingUnit):
63 64 self.dataOut.flagShiftFFT = False
64 65 self.dataOut.nCohInt = self.dataIn.nCohInt
65 66 self.dataOut.nIncohInt = 1
66 self.dataOut.radar_ipp = self.dataIn.radar_ipp
67 self.dataOut.sampled_heightsFFT = self.dataIn.sampled_heightsFFT
68 self.dataOut.pulseLength_TxA = self.dataIn.pulseLength_TxA
69 67 self.dataOut.deltaHeight = self.dataIn.deltaHeight
70 68 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
71 69 self.dataOut.frequency = self.dataIn.frequency
@@ -131,7 +129,7 class SpectraProc(ProcessingUnit):
131 129 self.dataOut.flagShiftFFT = False
132 130
133 131 def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False, zeroPad=False):
134 #print("run spc proc")
132
135 133
136 134 try:
137 135 type = self.dataIn.type.decode("utf-8")
@@ -142,11 +140,15 class SpectraProc(ProcessingUnit):
142 140
143 141 try:
144 142 self.dataOut.copy(self.dataIn)
143 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
144 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
145 145 self.dataOut.nProfiles = self.dataOut.nFFTPoints
146 146 #self.dataOut.nHeights = len(self.dataOut.heightList)
147 147 except Exception as e:
148 148 print("Error dataIn ",e)
149 149
150
151
150 152 if shift_fft:
151 153 #desplaza a la derecha en el eje 2 determinadas posiciones
152 154 shift = int(self.dataOut.nFFTPoints/2)
@@ -162,7 +164,8 class SpectraProc(ProcessingUnit):
162 164 elif self.dataIn.type == "Voltage":
163 165
164 166 self.dataOut.flagNoData = True
165
167 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
168 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
166 169 if nFFTPoints == None:
167 170 raise ValueError("This SpectraProc.run() need nFFTPoints input variable")
168 171
@@ -226,8 +229,16 class SpectraProc(ProcessingUnit):
226 229 self.__getFft()
227 230 self.dataOut.flagNoData = False
228 231 self.firstdatatime = None
232 self.nsamplesFFT = self.profIndex
229 233 self.profIndex = 0
230 234
235 #update Processing Header:
236 self.dataOut.processingHeaderObj.dtype = "Spectra"
237 self.dataOut.processingHeaderObj.nFFTPoints = self.dataOut.nFFTPoints
238 self.dataOut.processingHeaderObj.nSamplesFFT = self.nsamplesFFT
239 self.dataOut.processingHeaderObj.nIncohInt = 1
240
241
231 242 elif self.dataIn.type == "Parameters":
232 243
233 244 self.dataOut.data_spc = self.dataIn.data_spc
@@ -239,6 +250,8 class SpectraProc(ProcessingUnit):
239 250 self.dataOut.ippFactor = self.dataIn.ippFactor
240 251 self.dataOut.max_nIncohInt = self.dataIn.max_nIncohInt
241 252 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
253 self.dataOut.ProcessingHeader = self.dataIn.ProcessingHeader.copy()
254 self.dataOut.ippSeconds = self.dataIn.ippSeconds
242 255 self.dataOut.ipp = self.dataIn.ipp
243 256 #self.dataOut.abscissaList = self.dataIn.getVelRange(1)
244 257 #self.dataOut.spc_noise = self.dataIn.getNoise()
@@ -265,7 +278,13 class SpectraProc(ProcessingUnit):
265 278 else:
266 279 raise ValueError("The type of input object {} is not valid".format(
267 280 self.dataIn.type))
281
282
283
284
268 285 #print("spc proc Done", self.dataOut.data_spc.shape)
286 #print(self.dataOut.data_spc)
287 return
269 288
270 289 def __selectPairs(self, pairsList):
271 290
@@ -1332,6 +1351,7 class IntegrationFaradaySpectra(Operation):
1332 1351 self.n = None
1333 1352 self.__byTime = True
1334 1353
1354
1335 1355 if minHei == None:
1336 1356 minHei = self.dataOut.heightList[0]
1337 1357
@@ -1352,7 +1372,7 class IntegrationFaradaySpectra(Operation):
1352 1372 ind_list2 = numpy.where(self.dataOut.heightList <= maxHei)
1353 1373 self.minHei_ind = ind_list1[0][0]
1354 1374 self.maxHei_ind = ind_list2[0][-1]
1355 #print("setup rem sats done")
1375
1356 1376
1357 1377 def putData(self, data_spc, data_cspc, data_dc):
1358 1378 """
@@ -1607,7 +1627,7 class IntegrationFaradaySpectra(Operation):
1607 1627 self.dataOut = dataOut
1608 1628 if n == 1:
1609 1629 return self.dataOut
1610
1630 self.dataOut.processingHeaderObj.timeIncohInt = timeInterval
1611 1631 #print("nchannels", self.dataOut.nChannels)
1612 1632 if self.dataOut.nChannels == 1:
1613 1633 self.dataOut.data_cspc = None #si es un solo canal no vale la pena acumular DATOS
@@ -1661,6 +1681,11 class IntegrationFaradaySpectra(Operation):
1661 1681
1662 1682 self.dataOut.utctime = avgdatatime
1663 1683 self.dataOut.flagNoData = False
1684
1685 # #update Processing Header:
1686 # self.dataOut.processingHeaderObj.nIncohInt =
1687 # self.dataOut.processingHeaderObj.nFFTPoints = self.dataOut.nFFTPoints
1688
1664 1689 #print("Faraday Integration DONE...", self.dataOut.data_cspc)
1665 1690 #print(self.dataOut.flagNoData)
1666 1691 return self.dataOut
@@ -2008,6 +2033,7 class IncohInt(Operation):
2008 2033 self.n = None
2009 2034 self.__byTime = True
2010 2035
2036
2011 2037 def putData(self, data_spc, data_cspc, data_dc):
2012 2038 """
2013 2039 Add a profile to the __buffer_spc and increase in one the __profileIndex
@@ -2111,11 +2137,12 class IncohInt(Operation):
2111 2137 return dataOut
2112 2138
2113 2139 dataOut.flagNoData = True
2114
2140 dataOut.processingHeaderObj.timeIncohInt = timeInterval
2115 2141 if not self.isConfig:
2116 2142 self.setup(n, timeInterval, overlapping)
2117 2143 self.isConfig = True
2118 2144
2145
2119 2146 avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime,
2120 2147 dataOut.data_spc,
2121 2148 dataOut.data_cspc,
@@ -30,7 +30,23 class VoltageProc(ProcessingUnit):
30 30 if self.dataOut.buffer_empty:
31 31 if self.dataIn.type == 'Voltage':
32 32 self.dataOut.copy(self.dataIn)
33 #print("new volts reading")
33 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
34 self.dataOut.ippSeconds = self.dataIn.ippSeconds
35 self.dataOut.ipp = self.dataIn.ipp
36
37 #update Processing Header:
38 self.dataOut.processingHeaderObj.heightList = self.dataOut.heightList
39 self.dataOut.processingHeaderObj.ipp = self.dataOut.ipp
40 self.dataOut.processingHeaderObj.nCohInt = self.dataOut.nCohInt
41 self.dataOut.processingHeaderObj.dtype = self.dataOut.type
42 self.dataOut.processingHeaderObj.channelList = self.dataOut.channelList
43 self.dataOut.processingHeaderObj.azimuthList = self.dataOut.azimuthList
44 self.dataOut.processingHeaderObj.elevationList = self.dataOut.elevationList
45 self.dataOut.processingHeaderObj.codeList = self.dataOut.nChannels
46 self.dataOut.processingHeaderObj.heightList = self.dataOut.heightList
47 self.dataOut.processingHeaderObj.heightResolution = self.dataOut.heightList[1] - self.dataOut.heightList[0]
48
49
34 50
35 51
36 52 def __updateObjFromAmisrInput(self):
@@ -51,9 +67,7 class VoltageProc(ProcessingUnit):
51 67 self.dataOut.nCohInt = self.dataIn.nCohInt
52 68 self.dataOut.ippSeconds = self.dataIn.ippSeconds
53 69 self.dataOut.frequency = self.dataIn.frequency
54 self.dataOut.radar_ipp = self.dataIn.radar_ipp
55 self.dataOut.pulseLength_TxA = self.dataIn.pulseLength_TxA
56 self.dataOut.deltaHeight = self.dataIn.deltaHeight
70
57 71 self.dataOut.azimuth = self.dataIn.azimuth
58 72 self.dataOut.zenith = self.dataIn.zenith
59 73
@@ -85,6 +99,14 class selectChannels(Operation):
85 99 index = dataOut.channelList.index(channel)
86 100 channelIndexList.append(index)
87 101 dataOut = self.selectChannelsByIndex(dataOut,channelIndexList)
102
103 #update Processing Header:
104 dataOut.processingHeaderObj.channelList = dataOut.channelList
105 dataOut.processingHeaderObj.elevationList = dataOut.elevationList
106 dataOut.processingHeaderObj.azimuthList = dataOut.azimuthList
107 dataOut.processingHeaderObj.codeList = dataOut.codeList
108 dataOut.processingHeaderObj.nChannels = len(dataOut.channelList)
109
88 110 return dataOut
89 111
90 112 def selectChannelsByIndex(self, dataOut, channelIndexList):
@@ -221,6 +243,11 class selectHeights(Operation):
221 243
222 244 self.selectHeightsByIndex(minIndex, maxIndex)
223 245
246 #update Processing Header:
247 dataOut.processingHeaderObj.heightList = dataOut.heightList
248
249
250
224 251 return dataOut
225 252
226 253 def selectHeightsByIndex(self, minIndex, maxIndex):
@@ -324,6 +351,10 class filterByHeights(Operation):
324 351 dataOut.heightList = dataOut.heightList[0] + numpy.arange( newheights )*newdelta
325 352 dataOut.windowOfFilter = window
326 353
354 #update Processing Header:
355 dataOut.processingHeaderObj.heightList = dataOut.heightList
356 dataOut.processingHeaderObj.nWindows = window
357
327 358 return dataOut
328 359
329 360
@@ -340,6 +371,9 class setH0(Operation):
340 371
341 372 dataOut.heightList = newHeiRange
342 373
374 #update Processing Header:
375 dataOut.processingHeaderObj.heightList = dataOut.heightList
376
343 377 return dataOut
344 378
345 379
@@ -770,6 +804,11 class CohInt(Operation):
770 804 # raise
771 805 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
772 806 dataOut.flagNoData = False
807
808 #update Processing Header:
809 dataOut.processingHeaderObj.nCohInt = dataOut.nCohInt
810
811
773 812 return dataOut
774 813
775 814 class Decoder(Operation):
@@ -959,9 +998,16 class Decoder(Operation):
959 998
960 999 self.__profIndex += 1
961 1000
962 return dataOut
963 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
1001 #update Processing Header:
1002 dataOut.radarControllerHeaderObj.code = self.code
1003 dataOut.radarControllerHeaderObj.nCode = self.nCode
1004 dataOut.radarControllerHeaderObj.nBaud = self.nBaud
1005 dataOut.radarControllerHeaderObj.nOsamp = osamp
1006 #update Processing Header:
1007 dataOut.processingHeaderObj.heightList = dataOut.heightList
1008 dataOut.processingHeaderObj.heightResolution = dataOut.heightList[1]-dataOut.heightList[0]
964 1009
1010 return dataOut
965 1011
966 1012 class ProfileConcat(Operation):
967 1013
@@ -1011,6 +1057,11 class ProfileConcat(Operation):
1011 1057 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
1012 1058 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
1013 1059 dataOut.ippSeconds *= m
1060
1061 #update Processing Header:
1062 dataOut.processingHeaderObj.heightList = dataOut.heightList
1063 dataOut.processingHeaderObj.ipp = dataOut.ippSeconds
1064
1014 1065 return dataOut
1015 1066
1016 1067 class ProfileSelector(Operation):
@@ -1961,6 +2012,12 class SSheightProfiles2(Operation):
1961 2012
1962 2013 #print("new data shape:", dataOut.data.shape, dataOut.utctime)
1963 2014
2015 #update Processing Header:
2016 dataOut.processingHeaderObj.heightList = dataOut.heightList
2017 dataOut.processingHeaderObj.ipp = ippSeconds
2018 dataOut.processingHeaderObj.heightResolution = dataOut.deltaHeight
2019 #dataOut.processingHeaderObj.profilesPerBlock = nProfiles
2020
1964 2021 return dataOut
1965 2022
1966 2023
@@ -3165,6 +3222,7 class RemoveProfileSats2(Operation):
3165 3222 Escrito: Joab Apaza
3166 3223
3167 3224 Omite los perfiles contaminados con señal de satélites, usando una altura de referencia
3225 promedia todas las alturas para los cálculos
3168 3226 In: minHei = min_sat_range
3169 3227 max_sat_range
3170 3228 min_hei_ref
General Comments 0
You need to be logged in to leave comments. Login now