Пример #1
0
	def plotWave(self):
		"""
		Plot wiggled or filled waveform, which is normalized (if not stacking) and shifted to ybase.
		Fill both plus and negative side of signal but with different transparency.
			If opts.fill == 0: no fill.
			If opts.fill >  0: alpha of negative side is a quarter of plus side.
			If opts.fill <  0: alpha of plus side is a quarter of negative side.
		"""
		opts = self.opts
		ybase = self.ybase
		x = self.time - self.sacdh.reftime
		d = self.sacdh.data
		axpp = self.axpp
		if self.opts.ynorm > 0:
			# normalize data within time window
			if self.opts.ynormtwin_on:
				try:
					indmin, indmax = searchsorted(self.time, self.twindow)
					indmax = min(len(x)-1, indmax)
					thisd = d[indmin:indmax+1]
					dnorm = dataNorm(thisd)
				except:
					dnorm = dataNorm(d)
			else:
				dnorm = dataNorm(d)
			dnorm = 1/dnorm*self.opts.ynorm*.5
		else:
			dnorm = 1
		y = d * dnorm
		# plot
		self.ynorm = [dnorm,]
		line, = axpp.plot(x, y+ybase, ls='-', color=self.color, lw=self.linew, alpha=self.alpha, picker=5)
		self.lines = [line,]
		if opts.fill == 0:
			axpp.axhline(y=ybase, color='k', ls=':')
			self.wvfills = []
		else:
			f = opts.fill
			fplus, fnega, = [], []
			for i in range(len(x)):
				if f*y[i] > 0:
					fplus.append(True)
					fnega.append(False)
				else:
					fplus.append(False)
					fnega.append(True)
			wvfillplus = axpp.fill_between(x, ybase, y+ybase, where=fplus, color=self.color, alpha=self.alpha*0.6)
			wvfillnega = axpp.fill_between(x, ybase, y+ybase, where=fnega, color=self.color, alpha=self.alpha*0.2)
			self.wvfills = [wvfillplus, wvfillnega]
		self.labelStation()
Пример #2
0
    def plotWave(self):
        """
		Plot wiggled or filled waveform, which is normalized (if not stacking) and shifted to ybase.
		Fill both plus and negative side of signal but with different transparency.
			If opts.fill == 0: no fill.
			If opts.fill >  0: alpha of negative side is a quarter of plus side.
			If opts.fill <  0: alpha of plus side is a quarter of negative side.
		"""
        # get x, y
        opts = self.opts
        ybase = self.ybase
        x = self.time - self.sacdh.reftime
        d = self.sacdh.data
        axss = self.axss
        if self.opts.ynorm > 0:
            dnorm = dataNorm(d)
            dnorm = 1 / dnorm * self.opts.ynorm * .5
        else:
            dnorm = 1
        y = d * dnorm
        # plot
        line, = axss.plot(x,
                          y + ybase,
                          ls='-',
                          color=self.color,
                          lw=self.linew,
                          alpha=self.alpha,
                          picker=5)
        self.lines = [
            line,
        ]
        if opts.fill == 0:
            axss.axhline(y=ybase, color='k', ls=':')
            self.wvfills = []
        else:
            f = opts.fill
            fplus, fnega, = [], []
            for i in range(len(x)):
                if f * y[i] > 0:
                    fplus.append(True)
                    fnega.append(False)
                else:
                    fplus.append(False)
                    fnega.append(True)
            wvfillplus = axss.fill_between(x,
                                           ybase,
                                           y + ybase,
                                           where=fplus,
                                           color=self.color,
                                           alpha=self.alpha * 0.6)
            wvfillnega = axss.fill_between(x,
                                           ybase,
                                           y + ybase,
                                           where=fnega,
                                           color=self.color,
                                           alpha=self.alpha * 0.2)
            self.wvfills = [wvfillplus, wvfillnega]
Пример #3
0
    def updateY(self, xxlim):
        """ Update ynorm for wave wiggle from given xlim.
		"""
        x = self.time - self.sacdh.reftime
        d = self.sacdh.data
        indmin, indmax = searchsorted(x, xxlim)
        indmax = min(len(x) - 1, indmax)
        thisd = d[indmin:indmax + 1]
        if len(thisd) > 0 and self.opts.ynorm > 0:
            dnorm = dataNorm(thisd)
            dnorm = 1 / dnorm * self.opts.ynorm * .5
        else:
            dnorm = self.ynorm[-1]
        self.ynorm.append(dnorm)
        setp(self.lines[0], ydata=self.ybase + d * dnorm)
Пример #4
0
	def updateY(self, xxlim):
		""" Update ynorm for wave wiggle from given xlim.
		"""
		x = self.time - self.sacdh.reftime
		d = self.sacdh.data
		indmin, indmax = searchsorted(x, xxlim)
		indmax = min(len(x)-1, indmax)
		thisd = d[indmin:indmax+1]
		if len(thisd) > 0 and self.opts.ynorm > 0:
			dnorm = dataNorm(thisd)
			dnorm = 1/dnorm*self.opts.ynorm*.5
		else:
			dnorm = self.ynorm[-1]
		self.ynorm.append(dnorm)
		setp(self.lines[0], ydata=self.ybase+d*dnorm)
Пример #5
0
	def plotWave(self):
		"""
		Plot wiggled or filled waveform, which is normalized (if not stacking) and shifted to ybase.
		Fill both plus and negative side of signal but with different transparency.
			If opts.fill == 0: no fill.
			If opts.fill >  0: alpha of negative side is a quarter of plus side.
			If opts.fill <  0: alpha of plus side is a quarter of negative side.
		"""
		# get x, y
		opts = self.opts
		ybase = self.ybase
		x = self.time - self.sacdh.reftime
		d = self.sacdh.data
		axss = self.axss
		if self.opts.ynorm > 0:
			dnorm = dataNorm(d)
			dnorm = 1/dnorm*self.opts.ynorm*.5
		else:
			dnorm = 1
		y = d * dnorm
		# plot
		line, = axss.plot(x, y+ybase, ls='-', color=self.color, lw=self.linew, alpha=self.alpha, picker=5)
		self.lines = [line,]
		if opts.fill == 0:
			axss.axhline(y=ybase, color='k', ls=':')
			self.wvfills = []
		else:
			f = opts.fill
			fplus, fnega, = [], []
			for i in range(len(x)):
				if f*y[i] > 0:
					fplus.append(True)
					fnega.append(False)
				else:
					fplus.append(False)
					fnega.append(True)
			wvfillplus = axss.fill_between(x, ybase, y+ybase, where=fplus, color=self.color, alpha=self.alpha*0.6)
			wvfillnega = axss.fill_between(x, ybase, y+ybase, where=fnega, color=self.color, alpha=self.alpha*0.2)
			self.wvfills = [wvfillplus, wvfillnega]
Пример #6
0
    def plotWave(self):
        """
		Plot wiggled or filled waveform, which is normalized (if not stacking) and shifted to ybase.
		Fill both plus and negative side of signal but with different transparency.
			If opts.fill == 0: no fill.
			If opts.fill >  0: alpha of negative side is a quarter of plus side.
			If opts.fill <  0: alpha of plus side is a quarter of negative side.
		"""
        opts = self.opts
        ybase = self.ybase
        x = self.time - self.sacdh.reftime
        d = self.sacdh.data

        # filter time signal d

        if hasattr(opts,
                   'filterParameters') and opts.filterParameters['apply']:
            NYQ = 1.0 / (2 * opts.delta)

            # make filter, default is bandpass
            Wn = [
                opts.filterParameters['lowFreq'] / NYQ,
                opts.filterParameters['highFreq'] / NYQ
            ]
            B, A = signal.butter(opts.filterParameters['order'],
                                 Wn,
                                 analog=False,
                                 btype='bandpass')
            if opts.filterParameters['band'] == 'lowpass':
                Wn = opts.filterParameters['lowFreq'] / NYQ
                B, A = signal.butter(opts.filterParameters['order'],
                                     Wn,
                                     analog=False,
                                     btype='lowpass')
            elif opts.filterParameters['band'] == 'highpass':
                Wn = opts.filterParameters['highFreq'] / NYQ
                B, A = signal.butter(opts.filterParameters['order'],
                                     Wn,
                                     analog=False,
                                     btype='highpass')

            d = signal.lfilter(B, A, d)

        axpp = self.axpp
        if self.opts.ynorm > 0:
            # normalize data within time window
            if self.opts.ynormtwin_on:
                try:
                    indmin, indmax = searchsorted(self.time, self.twindow)
                    indmax = min(len(x) - 1, indmax)
                    thisd = d[indmin:indmax + 1]
                    dnorm = dataNorm(thisd)
                except:
                    dnorm = dataNorm(d)
            else:
                dnorm = dataNorm(d)
            dnorm = 1 / dnorm * self.opts.ynorm * .5
        else:
            dnorm = 1
        y = d * dnorm
        # plot
        self.ynorm = [
            dnorm,
        ]
        line, = axpp.plot(x,
                          y + ybase,
                          ls='-',
                          color=self.color,
                          lw=self.linew,
                          alpha=self.alpha,
                          picker=5)
        self.lines = [
            line,
        ]
        if opts.fill == 0:
            axpp.axhline(y=ybase, color='k', ls=':')
            self.wvfills = []
        else:
            f = opts.fill
            fplus, fnega, = [], []
            for i in range(len(x)):
                if f * y[i] > 0:
                    fplus.append(True)
                    fnega.append(False)
                else:
                    fplus.append(False)
                    fnega.append(True)
            wvfillplus = axpp.fill_between(x,
                                           ybase,
                                           y + ybase,
                                           where=fplus,
                                           color=self.color,
                                           alpha=self.alpha * 0.6)
            wvfillnega = axpp.fill_between(x,
                                           ybase,
                                           y + ybase,
                                           where=fnega,
                                           color=self.color,
                                           alpha=self.alpha * 0.2)
            self.wvfills = [wvfillplus, wvfillnega]
        self.labelStation()
Пример #7
0
	def plotWave(self):
		"""
		Plot wiggled or filled waveform, which is normalized (if not stacking) and shifted to ybase.
		Fill both plus and negative side of signal but with different transparency.
			If opts.fill == 0: no fill.
			If opts.fill >  0: alpha of negative side is a quarter of plus side.
			If opts.fill <  0: alpha of plus side is a quarter of negative side.
		"""
		opts = self.opts
		ybase = self.ybase
		x = self.time - self.sacdh.reftime
		d = self.sacdh.data

		# filter time signal d

		if hasattr(opts, 'filterParameters') and opts.filterParameters['apply']:
			NYQ = 1.0/(2*opts.delta)
			
			# make filter, default is bandpass
			Wn = [opts.filterParameters['lowFreq']/NYQ, opts.filterParameters['highFreq']/NYQ]
			B, A = signal.butter(opts.filterParameters['order'], Wn, analog=False, btype='bandpass')
			if opts.filterParameters['band']=='lowpass':
				Wn = opts.filterParameters['lowFreq']/NYQ
				B, A = signal.butter(opts.filterParameters['order'], Wn, analog=False, btype='lowpass')
			elif opts.filterParameters['band']=='highpass':
				Wn = opts.filterParameters['highFreq']/NYQ
				B, A = signal.butter(opts.filterParameters['order'], Wn, analog=False, btype='highpass')

			d = signal.lfilter(B, A, d)

		axpp = self.axpp
		if self.opts.ynorm > 0:
			# normalize data within time window
			if self.opts.ynormtwin_on:
				try:
					indmin, indmax = np.searchsorted(self.time, self.twindow)
					indmax = min(len(x)-1, indmax)
					thisd = d[indmin:indmax+1]
					dnorm = dataNorm(thisd)
				except:
					dnorm = dataNorm(d)
			else:
				dnorm = dataNorm(d)
			dnorm = 1/dnorm*self.opts.ynorm*.5
		else:
			dnorm = 1
		y = d * dnorm
		# plot
		self.ynorm = [dnorm,]
		line, = axpp.plot(x, y+ybase, ls='-', color=self.color, lw=self.linew, alpha=self.alpha, picker=5)
		self.lines = [line,]
		if opts.fill == 0:
			axpp.axhline(y=ybase, color='k', ls=':')
			self.wvfills = []
		else:
			f = opts.fill
			fplus, fnega, = [], []
			for i in list(range(len(x))):
				if f*y[i] > 0:
					fplus.append(True)
					fnega.append(False)
				else:
					fplus.append(False)
					fnega.append(True)
			wvfillplus = axpp.fill_between(x, ybase, y+ybase, where=fplus, color=self.color, alpha=self.alpha*0.6)
			wvfillnega = axpp.fill_between(x, ybase, y+ybase, where=fnega, color=self.color, alpha=self.alpha*0.2)
			self.wvfills = [wvfillplus, wvfillnega]
		self.labelStation()