コード例 #1
0
from pylab import *
from plot_utils import plot_2x1

# Must Define 
#   data2plot
#   EH
#   EL

#ylims = (2,0.92,1.0)

# Title = r'$SNR = -9$'

plot_2x1(shiftStreams, peakStreams, 
         ['Signal Level', 'Signal Level'], 'Time steps')

fig = gcf()

# dashed lines
fig.axes[0].axvline(x = 300, ls = '--', c = 'k')
fig.axes[0].axvline(x = 600, ls = '--', c = 'k')
fig.axes[1].axvline(x = 300, ls = '--', c = 'k')
fig.axes[1].axvline(x = 600, ls = '--', c = 'k')

#fig.axes[1].axhline(y=EH, ls = '--')
#fig.axes[1].axhline(y=EL, ls = '--')

fig.show()

# Save figure as eps
コード例 #2
0
from pylab import *
from plot_utils import plot_2x1

# Run this script interactively:
# Must first Define
#   data2plot
#   EH
#   EL

ylims = (2, 0.91, 1.0)

Title = ''

plot_2x1(F.res['ht'],
         F.res['e_ratio'], ['Hidden Variables', 'Energy Ratio'],
         'Time Steps',
         Title,
         ylims=ylims)

fig = gcf()

# dashed lines
fig.axes[0].axvline(x=300, ls='--', c='k')
fig.axes[0].axvline(x=600, ls='--', c='k')
fig.axes[1].axvline(x=300, ls='--', c='k')
fig.axes[1].axvline(x=600, ls='--', c='k')

fig.axes[1].axhline(y=EH, ls='--')
fig.axes[1].axhline(y=EL, ls='--')

fig.show()
コード例 #3
0
from pylab import *
from plot_utils import plot_2x1

# Run this script interactively:
# Must first Define 
#   data2plot
#   EH
#   EL

ylims = (2,0.91,1.0)

Title = ''

plot_2x1(F.res['ht'], F.res['e_ratio'], 
         ['Hidden Variables', 'Energy Ratio'], 'Time Steps',Title,  ylims= ylims)

fig = gcf()

# dashed lines
fig.axes[0].axvline(x = 300, ls = '--', c = 'k')
fig.axes[0].axvline(x = 600, ls = '--', c = 'k')
fig.axes[1].axvline(x = 300, ls = '--', c = 'k')
fig.axes[1].axvline(x = 600, ls = '--', c = 'k')

fig.axes[1].axhline(y=EH, ls = '--')
fig.axes[1].axhline(y=EL, ls = '--')

fig.show()

# Save figure as eps
コード例 #4
0
    def plot_res(self, var, xname="time steps", ynames=None, title=None, hline=1, anom=1):

        if ynames is None:
            ynames = [""] * 4

        if title is None:
            title = self.p["version"]

        #  Preprocessing
        if "exp_ht" in var:
            res["exp_ht"][res["exp_ht"] == 0.0] = np.nan

        if "S" in self.A_version:
            thresh = self.p["t_thresh"]
        elif "T" in self.A_version:
            thresh = self.p["x_thresh"]
        elif "eng" in self.A_version:
            thresh = (self.p["e_high"] - self.p["e_low"]) / 2

        num_plots = len(var)

        for i, v in enumerate(var):
            if type(v) == str:
                var[i] = getattr(self, "res")[v]

        if num_plots == 1:
            plt.figure()
            plt.plot(var[0])
            plt.title(title)
            if anom == 1:
                for x in self.res["anomalies"]:
                    plt.axvline(x, ymin=0.25, color="r")

        elif num_plots == 2:
            plot_2x1(var[0], var[1], ynames[:2], xname, main_title=title)

            if hline == 1:
                plt.hlines(-thresh, 0, self.res["ht"].shape[0], linestyles="dashed")
                plt.hlines(+thresh, 0, self.res["ht"].shape[0], linestyles="dashed")
                plt.ylim(-2 * thresh, 2 * thresh)

            if anom == 1:
                f = plt.gcf()
                for ax in f.axes[:-1]:
                    for x in self.res["anomalies"]:
                        ax.axvline(x, ymin=0.25, color="r")

        elif num_plots == 3:
            plot_3x1(var[0], var[1], var[2], ynames[:3], xname, main_title=title)

            if hline == 1:
                plt.hlines(-thresh, 0, self.res["ht"].shape[0], linestyles="dashed")
                plt.hlines(+thresh, 0, self.res["ht"].shape[0], linestyles="dashed")
                plt.ylim(-2 * thresh, 2 * thresh)

            if anom == 1:
                f = plt.gcf()
                for ax in f.axes[:-1]:
                    for x in self.res["anomalies"]:
                        ax.axvline(x, ymin=0.25, color="r")

        elif num_plots == 4:
            plot_4x1(var[0], var[1], var[2], var[3], ynames[:4], xname, main_title=title)
            plt.title(title)

            if hline == 1:
                plt.hlines(-thresh, 0, self.res["ht"].shape[0], linestyles="dashed")
                plt.hlines(+thresh, 0, self.res["ht"].shape[0], linestyles="dashed")
                plt.ylim(-2 * thresh, 2 * thresh)

            if anom == 1:
                f = plt.gcf()
                for ax in f.axes[:-1]:
                    for x in self.res["anomalies"]:
                        ax.axvline(x, ymin=0.25, color="r")
コード例 #5
0
ファイル: CDST_demo.py プロジェクト: MrKriss/CDST-demo
  def plot_res(self, var, xname = 'Time Steps', ynames = None, title = None, hline= 1, anom = 1):
    """Plots each of the elements given in var. 
    
    var = list of  variables. Maximum = 4. if string, will look for them in self.res structure 
        
    hline = whether to plot threshold values on final plot.
    
    anom = whether to plot anomalous time ticks.
        
    """
    
    if ynames is None:
      ynames = ['']*4
      
    if title is None:
      title = (self.p['version'])
        
    if 'SRE' in self.A_version:
      thresh = self.p['t_thresh']
    
    num_plots = len(var)
    
    for i, v in enumerate(var):
      if type(v) == str :
        var[i] = getattr(self, 'res')[v]
    
    if num_plots == 1:
      plt.figure()
      plt.plot(var[0])
      plt.title(title)
      if anom == 1:
        for x in self.res['anomalies']:
          plt.axvline(x, ymin=0.9, color='r')        
      
    elif num_plots == 2:
      plot_2x1(var[0], var[1], ynames[:2], xname, main_title = title)
      
      if hline == 1:
        plt.hlines(-thresh, 0, self.res['ht'].shape[0], linestyles = 'dashed')
        plt.hlines(+thresh, 0, self.res['ht'].shape[0], linestyles = 'dashed')
        plt.ylim(-3*thresh,3*thresh)
        
      if anom == 1:
        f = plt.gcf()
        for ax in f.axes[:-1]:
          for x in self.res['anomalies']:
            ax.axvline(x, ymin=0.9, color='r')              
        
    elif num_plots == 3:
      plot_3x1(var[0], var[1], var[2], ynames[:3] , xname, main_title = title) 

      
      if hline == 1:
        plt.hlines(-thresh, 0, self.res['ht'].shape[0], linestyles = 'dashed')
        plt.hlines(+thresh, 0, self.res['ht'].shape[0], linestyles = 'dashed') 
        plt.ylim(-3*thresh,3*thresh)
        
      if anom == 1:
        f = plt.gcf()
        for ax in f.axes[:-1]:
          for x in self.res['anomalies']:
            ax.axvline(x, ymin=0.9, color='r')         
               
    elif num_plots == 4:
      plot_4x1(var[0], var[1], var[2], var[3], ynames[:4], xname, main_title = title)
      plt.title(title)
      
      if hline == 1:
        plt.hlines(-thresh, 0, self.res['ht'].shape[0], linestyles = 'dashed')
        plt.hlines(+thresh, 0, self.res['ht'].shape[0], linestyles = 'dashed')               
        plt.ylim(-3*thresh,3*thresh)
        
      if anom == 1:
        f = plt.gcf()
        for ax in f.axes[:-1]:
          for x in self.res['anomalies']:
            ax.axvline(x, ymin=0.9, color='r')     
      
    plt.draw()      
コード例 #6
0
from pylab import *
from plot_utils import plot_2x1

# Must Define
#   data2plot
#   EH
#   EL

#ylims = (2,0.92,1.0)

# Title = r'$SNR = -9$'

plot_2x1(shiftStreams, peakStreams, ['Signal Level', 'Signal Level'],
         'Time steps')

fig = gcf()

# dashed lines
fig.axes[0].axvline(x=300, ls='--', c='k')
fig.axes[0].axvline(x=600, ls='--', c='k')
fig.axes[1].axvline(x=300, ls='--', c='k')
fig.axes[1].axvline(x=600, ls='--', c='k')

#fig.axes[1].axhline(y=EH, ls = '--')
#fig.axes[1].axhline(y=EL, ls = '--')

fig.show()

# Save figure as eps

filename = 'Peak and shift inputs'