@@ -489,7 +489,7 class Spectra(JROData): | |||||
489 | return noise |
|
489 | return noise | |
490 |
|
490 | |||
491 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
491 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
492 |
|
492 | |||
493 | if self.noise_estimation is not None: |
|
493 | if self.noise_estimation is not None: | |
494 | # this was estimated by getNoise Operation defined in jroproc_spectra.py |
|
494 | # this was estimated by getNoise Operation defined in jroproc_spectra.py | |
495 | return self.noise_estimation |
|
495 | return self.noise_estimation |
@@ -379,7 +379,8 class NoisePlot(Plot): | |||||
379 |
|
379 | |||
380 | data = {} |
|
380 | data = {} | |
381 | meta = {} |
|
381 | meta = {} | |
382 |
|
|
382 | noise = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1) | |
|
383 | data['noise'] = noise | |||
383 | meta['yrange'] = numpy.array([]) |
|
384 | meta['yrange'] = numpy.array([]) | |
384 |
|
385 | |||
385 | return data, meta |
|
386 | return data, meta | |
@@ -392,8 +393,8 class NoisePlot(Plot): | |||||
392 | Y = self.data['noise'] |
|
393 | Y = self.data['noise'] | |
393 |
|
394 | |||
394 | if self.axes[0].firsttime: |
|
395 | if self.axes[0].firsttime: | |
395 | self.ymin = numpy.nanmin(Y) - 5 |
|
396 | if self.ymin is None: self.ymin = numpy.nanmin(Y) - 5 | |
396 | self.ymax = numpy.nanmax(Y) + 5 |
|
397 | if self.ymax is None: self.ymax = numpy.nanmax(Y) + 5 | |
397 | for ch in self.data.channels: |
|
398 | for ch in self.data.channels: | |
398 | y = Y[ch] |
|
399 | y = Y[ch] | |
399 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
400 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
@@ -202,6 +202,7 class SpectraProc(ProcessingUnit): | |||||
202 | self.dataOut.flagNoData = False |
|
202 | self.dataOut.flagNoData = False | |
203 | self.firstdatatime = None |
|
203 | self.firstdatatime = None | |
204 | self.profIndex = 0 |
|
204 | self.profIndex = 0 | |
|
205 | self.dataOut.noise_estimation = None | |||
205 | else: |
|
206 | else: | |
206 | raise ValueError("The type of input object '%s' is not valid".format( |
|
207 | raise ValueError("The type of input object '%s' is not valid".format( | |
207 | self.dataIn.type)) |
|
208 | self.dataIn.type)) | |
@@ -488,6 +489,131 class removeDC(Operation): | |||||
488 |
|
489 | |||
489 | return self.dataOut |
|
490 | return self.dataOut | |
490 |
|
491 | |||
|
492 | class getNoise(Operation): | |||
|
493 | def __init__(self): | |||
|
494 | ||||
|
495 | Operation.__init__(self) | |||
|
496 | ||||
|
497 | def run(self, dataOut, minHei=None, maxHei=None, minVel=None, maxVel=None, minFreq= None, maxFreq=None,): | |||
|
498 | self.dataOut = dataOut.copy() | |||
|
499 | print("1: ",dataOut.noise_estimation, dataOut.normFactor) | |||
|
500 | ||||
|
501 | if minHei == None: | |||
|
502 | minHei = self.dataOut.heightList[0] | |||
|
503 | ||||
|
504 | if maxHei == None: | |||
|
505 | maxHei = self.dataOut.heightList[-1] | |||
|
506 | ||||
|
507 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): | |||
|
508 | print('minHei: %.2f is out of the heights range' % (minHei)) | |||
|
509 | print('minHei is setting to %.2f' % (self.dataOut.heightList[0])) | |||
|
510 | minHei = self.dataOut.heightList[0] | |||
|
511 | ||||
|
512 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): | |||
|
513 | print('maxHei: %.2f is out of the heights range' % (maxHei)) | |||
|
514 | print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1])) | |||
|
515 | maxHei = self.dataOut.heightList[-1] | |||
|
516 | ||||
|
517 | ||||
|
518 | #indices relativos a los puntos de fft, puede ser de acuerdo a velocidad o frecuencia | |||
|
519 | minIndexFFT = 0 | |||
|
520 | maxIndexFFT = 0 | |||
|
521 | # validacion de velocidades | |||
|
522 | indminPoint = None | |||
|
523 | indmaxPoint = None | |||
|
524 | ||||
|
525 | if minVel == None and maxVel == None: | |||
|
526 | ||||
|
527 | freqrange = self.dataOut.getFreqRange(1) | |||
|
528 | ||||
|
529 | if minFreq == None: | |||
|
530 | minFreq = freqrange[0] | |||
|
531 | ||||
|
532 | if maxFreq == None: | |||
|
533 | maxFreq = freqrange[-1] | |||
|
534 | ||||
|
535 | if (minFreq < freqrange[0]) or (minFreq > maxFreq): | |||
|
536 | print('minFreq: %.2f is out of the frequency range' % (minFreq)) | |||
|
537 | print('minFreq is setting to %.2f' % (freqrange[0])) | |||
|
538 | minFreq = freqrange[0] | |||
|
539 | ||||
|
540 | if (maxFreq > freqrange[-1]) or (maxFreq < minFreq): | |||
|
541 | print('maxFreq: %.2f is out of the frequency range' % (maxFreq)) | |||
|
542 | print('maxFreq is setting to %.2f' % (freqrange[-1])) | |||
|
543 | maxFreq = freqrange[-1] | |||
|
544 | ||||
|
545 | indminPoint = numpy.where(freqrange >= minFreq) | |||
|
546 | indmaxPoint = numpy.where(freqrange <= maxFreq) | |||
|
547 | ||||
|
548 | else: | |||
|
549 | velrange = self.dataOut.getVelRange(1) | |||
|
550 | ||||
|
551 | if minVel == None: | |||
|
552 | minVel = velrange[0] | |||
|
553 | ||||
|
554 | if maxVel == None: | |||
|
555 | maxVel = velrange[-1] | |||
|
556 | ||||
|
557 | if (minVel < velrange[0]) or (minVel > maxVel): | |||
|
558 | print('minVel: %.2f is out of the velocity range' % (minVel)) | |||
|
559 | print('minVel is setting to %.2f' % (velrange[0])) | |||
|
560 | minVel = velrange[0] | |||
|
561 | ||||
|
562 | if (maxVel > velrange[-1]) or (maxVel < minVel): | |||
|
563 | print('maxVel: %.2f is out of the velocity range' % (maxVel)) | |||
|
564 | print('maxVel is setting to %.2f' % (velrange[-1])) | |||
|
565 | maxVel = velrange[-1] | |||
|
566 | ||||
|
567 | indminPoint = numpy.where(velrange >= minVel) | |||
|
568 | indmaxPoint = numpy.where(velrange <= maxVel) | |||
|
569 | ||||
|
570 | ||||
|
571 | # seleccion de indices para rango | |||
|
572 | minIndex = 0 | |||
|
573 | maxIndex = 0 | |||
|
574 | heights = self.dataOut.heightList | |||
|
575 | ||||
|
576 | inda = numpy.where(heights >= minHei) | |||
|
577 | indb = numpy.where(heights <= maxHei) | |||
|
578 | ||||
|
579 | try: | |||
|
580 | minIndex = inda[0][0] | |||
|
581 | except: | |||
|
582 | minIndex = 0 | |||
|
583 | ||||
|
584 | try: | |||
|
585 | maxIndex = indb[0][-1] | |||
|
586 | except: | |||
|
587 | maxIndex = len(heights) | |||
|
588 | ||||
|
589 | if (minIndex < 0) or (minIndex > maxIndex): | |||
|
590 | raise ValueError("some value in (%d,%d) is not valid" % ( | |||
|
591 | minIndex, maxIndex)) | |||
|
592 | ||||
|
593 | if (maxIndex >= self.dataOut.nHeights): | |||
|
594 | maxIndex = self.dataOut.nHeights - 1 | |||
|
595 | #############################################################3 | |||
|
596 | # seleccion de indices para velocidades | |||
|
597 | ||||
|
598 | try: | |||
|
599 | minIndexFFT = indminPoint[0][0] | |||
|
600 | except: | |||
|
601 | minIndexFFT = 0 | |||
|
602 | ||||
|
603 | try: | |||
|
604 | maxIndexFFT = indmaxPoint[0][-1] | |||
|
605 | except: | |||
|
606 | maxIndexFFT = len( self.dataOut.getFreqRange(1)) | |||
|
607 | ||||
|
608 | #print(minIndex, maxIndex,minIndexVel, maxIndexVel) | |||
|
609 | noise = self.dataOut.getNoise(xmin_index=minIndexFFT, xmax_index=maxIndexFFT, ymin_index=minIndex, ymax_index=maxIndex) | |||
|
610 | ||||
|
611 | self.dataOut.noise_estimation = noise.copy() | |||
|
612 | #print("2: ",10*numpy.log10(self.dataOut.noise_estimation/64)) | |||
|
613 | return self.dataOut | |||
|
614 | ||||
|
615 | ||||
|
616 | ||||
491 | # import matplotlib.pyplot as plt |
|
617 | # import matplotlib.pyplot as plt | |
492 |
|
618 | |||
493 | def fit_func( x, a0, a1, a2): #, a3, a4, a5): |
|
619 | def fit_func( x, a0, a1, a2): #, a3, a4, a5): |
General Comments 0
You need to be logged in to leave comments.
Login now