def plotGlobalPower(self, subplot): """ Third sub-plot, the global wavelet and Fourier power spectra and theoretical noise spectra. Note that period scale is logarithmic. """ var = self.wavelet_spectra.feature.amplitude**2 glbl_power = self.wavelet_spectra.get_global_power() glbl_signif = self.wavelet_spectra.get_global_significance( self.alpha, self.threshold) period = self.wavelet_spectra.get_periods() fft_theor = self.wavelet_spectra.get_theoretical_fft( self.alpha, self.threshold) fft_power = self.fourier_spectra.get_power() fft_periods = self.fourier_spectra.get_periods() Yticks = 2**np.arange(np.ceil(np.log2(period.min())), np.ceil(np.log2(period.max()))) return subplot.add( data=None, x=var * fft_power, y=np.log2(fft_periods), plot=plot_action.line(linestyle='-', color='#cccccc', linewidth=1.), xlabel="Power", xlim=[0, fft_power.max() * var], ylim=np.log2([period.min(), period.max()]), tick=dict(labelleft=False, left=False, labelright=True, right=True), ytick={ "locations": np.log2(Yticks), "labels": Yticks }, title='c) Global Wavelet Spectrum', ).add(data=None, x=var * glbl_power, y=np.log2(period), plot=plot_action.line( linestyle='-', color="#1146b3", linewidth=1.5)).add( data=None, x=glbl_signif, y=np.log2(period), plot=plot_action.line( linestyle='--', color="#2196f3")).add( data=None, x=var * fft_theor, y=np.log2(period), plot=plot_action.line(linestyle='--', color='#cccccc'), xscale="log", )
def plotMotherWavelet(self, subplot): t = np.arange(-5, 5, 0.01) return subplot.add( data=None, x=t, y=[self.wavelet_spectra.feature.mother.psi(x) for x in t], plot=plot_action.line(color="k"), tick=dict(bottom=False, left=False, labelbottom=False, labelleft=False), title="Mother wavelet")
def plotAverageScale(self, subplot): return subplot.add( data=None, ypos=self.wavelet_spectra.get_averaged_scale_significance( self.period_filter, self.alpha, self.threshold), plot=plot_action.xband(color='k', linestyle='--', linewidth=1.), xlabel='Time [' + self.wavelet_spectra.feature.time_unit + ']', ylabel='Average variance []', title='d) scale-averaged power', ).add(data=None, x=self.t, y=self.wavelet_spectra.get_averaged_scale(self.period_filter), plot=plot_action.line(color="k", linewidth=1.5))
def plotInversedSignal(self, subplot, style={}): """ plot inversed signal """ st = { "color": [0.5, 0.5, 0.5], "linestyle": "-", "linewidth": 2, "alpha": 1, **style } return subplot.add(data=None, x=self.t, y=self.wavelet_spectra.inverse(), plot=plot_action.line(**st))
def plot_zoning_segment( xs, ys, slope_center_xs, context={}): lasso_res = fusedlasso(ys) fitted_ys = lasso_res["beta"] print(f"lambda: {lasso_res['lambda.1se']}") print(f"MSE: {get_MSE(ys,fitted_ys)}") base = Subplot(context.get("axes_style", {})) data_points = dict( data={"x": xs, "y": ys}, x="x", y="y", plot=plot_action.scatter(context["artists"].get("data_point")) ) fitted_line = dict( data={"x": xs, "y": fitted_ys}, x="x", y="y", plot=plot_action.line(context["artists"].get("estimated_line")) ) segment_boundary = dict( data={"x": slope_center_xs}, xpos="x", plot=plot_action.vband(context["artists"].get("segment_boundary")) ) return base.add( **data_points ).add( **fitted_line ).add( **segment_boundary )
def plotSignal(self, subplot, style={}): """ Plot original signal and inversed signal. """ st = { "color": '#2196f3', "linestyle": "-", "linewidth": 1.5, "alpha": 1, **style } return subplot.add( data=None, x=self.t, y=CWT.detrend(self.signal), plot=plot_action.line(**st), xlim=[self.t.min(), self.t.max()], title='a) Signal', )
def plot(mcmc: MCMCResult, burn_in: int, style={}, label_map={}, lim_map={}): data = mcmc.get_sampled() params = mcmc.get_parameter_group() n_set = mcmc.len_parameter_set() (fig_style, axes_style, plot_style) = classify_plot_style(style) figure = Figure() transition_line = plot_action.line(color="black") fill_burn_in_stage = plot_action.vband( xpos=[[0, burn_in]], alpha=0.3, color="gray") is_last_row = check_last_of(len(params)) for row_i, param in enumerate(params): for column_i in range(n_set): subplot = Subplot(axes_style).add( data=data, x="index", y=f"{param}{column_i}", ylim=lim_map.get(param, [None, None]), plot=[ transition_line, fill_burn_in_stage ], ylabel=f"{label_map.get(param, param)}" if is_first( column_i) else None, tick={ "labelbottom": True if is_last_row(row_i) else False, "labelleft": True if is_first(column_i) else False, "right": True }, title=f"Stage {column_i + 1}" if is_first(row_i) else None, ) figure.add_subplot(subplot) return figure.show(**fig_style, column=n_set)