Пример #1
0
    def TimeSeries(self,data,npoints,datatype,labels,trajectory_index,linestyle,linewidth,marker,colors,title,xlabel,ylabel,is_legend,legend_location):      
        """        
        Tracks the propensities and/or species over time.

        Input: 
         - *data* (array)
         - *npoints* (integer)
         - *datatype* (list)
         - *labels* (list)
         - *trajectory_index* (integer)
         - *linestyle* (string)
         - *linewidth* (float)
         - *title* (string)
         - *xlabel* (string)
         - *ylabel* (string)
         - *is_legend* (boolean)       
        """
        plt.figure(self.plotnum)       
        datatype_indices = [labels.index(Id) for Id in datatype]
        
        data = getDataForTimeSimPlot(data,npoints,self.quiet)
       
        Arr_time = data[:,0]   
        if len(datatype) == 1:
            j = trajectory_index
        else:
            j=0

        for i in datatype_indices:
            y = data[:,i+1]          
            if colors == None:              
                if j >= len(self.colors):                  
                    j=0
            elif isinstance(colors,list):
                if j >= len(colors):
                    j=0
            elif isinstance(colors,str):
                colors = [colors]
                j=0             

            if colors == None:
                plt.plot(Arr_time,y,marker,ls = linestyle,lw = linewidth,color = self.colors[j])
            else:
                if clr.is_color_like(colors[j]):
                    plt.plot(Arr_time,y,marker,ls = linestyle,lw = linewidth,color = colors[j])
                else:
                    print("*** WARNING ***: '{0}' is not recognized as a valid color code".format(colors[j]) )
                    plt.plot(Arr_time,y,marker,ls = linestyle,lw = linewidth,color = self.colors[j])
                    colors = None
            j+=1
        if is_legend:
            plt.legend(datatype,numpoints=1,frameon=True,loc=legend_location)
        plt.title(title)
        plt.xlabel(xlabel) 
        plt.ylabel(ylabel)      
Пример #2
0
 def Autocorrelations(self,lags,data,datatype,labels,trajectory_index,linestyle,linewidth,marker,colors,title,xlabel,ylabel,is_legend,legend_location):      
     """        
     Input:
      - *lags*
      - *data* (array)      
      - *datatype* (list) 
      - *labels* (list)
      - *trajectory_index* (integer)       
      - *linestyle* (string)
      - *linewidth* (float)
      - *marker* string)
      - *colors* (list)
      - *title* (string)
      - *xlabel* (string)
      - *ylabel* (string)
      - *is_legend* (boolean)
     """
     plt.figure(self.plotnum)
     datatype_indices = [labels.index(Id) for Id in datatype]
     if len(datatype) == 1:
         j = trajectory_index
     else:
         j=0          
     
     for i in datatype_indices:         
         if colors == None:              
             if j >= len(self.colors):                  
                 j=0
         elif isinstance(colors,list):
             if j >= len(colors):
                 j=0
         elif isinstance(colors,str):
             colors = [colors]
             j=0
                                 
         y = data[i][0:len(lags)]          
         if colors == None:
             plt.plot(lags,y,marker,ls = linestyle,lw = linewidth, color = self.colors[j])
         else:   
             if clr.is_color_like(colors[j]):             
                 plt.plot(lags,y,marker,ls = linestyle,lw = linewidth, color = colors[j])
             else:
                 print("*** WARNING ***: '{0}' is not recognized as a valid color code".format(colors[j]) )
                 plt.plot(lags,y,marker,ls = linestyle,lw = linewidth, color = self.colors[j]) 
                 colors = None
         j+=1 
     if is_legend:    
         plt.legend(datatype,numpoints=1,frameon=True,loc=legend_location)      
     plt.title(title)
     plt.xlabel(xlabel) 
     plt.ylabel(ylabel)
Пример #3
0
    def AverageDistributionsCI(self, means, stds, nstd, datatype, labels,
                               colors, title, xlabel, ylabel, is_legend,
                               legend_location):
        """      
        Plots the average and standard deviation.

        Input:
         - *means* (nested list)
         - *stds* (nested list)
         - *nstd* (float)
         - *labels* (list)
         - *linestyle* (string)
         - *linewidth* (float)
         - *marker* (string)
         - *colors* (list)
         - *title* (string)
         - *xlabel* (string)
         - *ylabel* (string)
         - *is_legend* (boolean)
         - *legend_location* [default = 'upper right'] (string/integer)
        """
        assert nstd > 0, "Error: The number of STDs must be a value larger than zero"
        plt.figure(self.plotnum)
        datatype_indices = [labels.index(Id) for Id in datatype]
        for i in datatype_indices:
            L_s_amount = copy.copy(means[i][0])
            L_mu = copy.copy(means[i][1])
            L_sigma = copy.copy(stds[i][1])

            # Add an additional value
            L_s_amount.append(L_s_amount[-1] + 1)
            L_mu.append(L_mu[-1])
            L_sigma.append(L_sigma[-1])

            X_i = []
            Y_i = []
            L_errors = []
            for j in range(len(L_s_amount)):
                if (not L_s_amount[j] == L_s_amount[0]) and (
                        not L_s_amount[j] == L_s_amount[-1]):
                    X_i.append(L_s_amount[j])
                    Y_i.append(L_mu[j - 1])
                    L_errors.append(L_sigma[j - 1])
                X_i.append(L_s_amount[j])
                Y_i.append(L_mu[j])
                L_errors.append(L_sigma[j])
            X_e = np.concatenate([X_i, X_i[::-1]])
            Y_e = np.concatenate([
                np.array(Y_i) - nstd * np.array(L_errors),
                (np.array(Y_i) + nstd * np.array(L_errors))[::-1]
            ])

            if colors == None:
                if j >= len(self.colors):
                    j = 0
            elif isinstance(colors, list):
                if j >= len(colors):
                    j = 0
            elif isinstance(colors, str):
                colors = [colors]
                j = 0
            if colors == None:
                plt.fill(X_e - 0.5,
                         Y_e,
                         alpha=.25,
                         ec='None',
                         label='{0} STD confidence interval'.format(nstd),
                         color=self.colors[j])
                plt.plot(np.array(X_i) - 0.5,
                         np.array(Y_i),
                         color=self.colors[j])
            else:
                if clr.is_color_like(colors[j]):
                    plt.fill(X_e - 0.5,
                             Y_e,
                             alpha=.25,
                             ec='None',
                             label='{0} STD confidence interval'.format(nstd),
                             color=colors[j])
                    plt.plot(np.array(X_i) - 0.5,
                             np.array(Y_i),
                             color=colors[j])
                else:
                    print(
                        "*** WARNING ***: '{0}' is not recognized as a valid color code"
                        .format(colors[j]))
                    plt.fill(X_e - 0.5,
                             Y_e,
                             alpha=.25,
                             ec='None',
                             label='{0} STD confidence interval'.format(nstd),
                             color=self.colors[j])
                    plt.plot(np.array(X_i) - 0.5,
                             np.array(Y_i),
                             color=self.colors[j])
                    colors = None
        if is_legend:
            plt.legend(numpoints=1, frameon=True, loc=legend_location)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        plt.title(title)
Пример #4
0
    def Autocorrelations(self, lags, data, datatype, labels, trajectory_index,
                         linestyle, linewidth, marker, colors, title, xlabel,
                         ylabel, is_legend, legend_location):
        """        
        Input:
         - *lags*
         - *data* (array)      
         - *datatype* (list) 
         - *labels* (list)
         - *trajectory_index* (integer)       
         - *linestyle* (string)
         - *linewidth* (float)
         - *marker* string)
         - *colors* (list)
         - *title* (string)
         - *xlabel* (string)
         - *ylabel* (string)
         - *is_legend* (boolean)
        """
        plt.figure(self.plotnum)
        datatype_indices = [labels.index(Id) for Id in datatype]
        if len(datatype) == 1:
            j = trajectory_index
        else:
            j = 0

        for i in datatype_indices:
            if colors == None:
                if j >= len(self.colors):
                    j = 0
            elif isinstance(colors, list):
                if j >= len(colors):
                    j = 0
            elif isinstance(colors, str):
                colors = [colors]
                j = 0

            y = data[i][0:len(lags)]
            if colors == None:
                plt.plot(lags,
                         y,
                         marker,
                         ls=linestyle,
                         lw=linewidth,
                         color=self.colors[j])
            else:
                if clr.is_color_like(colors[j]):
                    plt.plot(lags,
                             y,
                             marker,
                             ls=linestyle,
                             lw=linewidth,
                             color=colors[j])
                else:
                    print(
                        "*** WARNING ***: '{0}' is not recognized as a valid color code"
                        .format(colors[j]))
                    plt.plot(lags,
                             y,
                             marker,
                             ls=linestyle,
                             lw=linewidth,
                             color=self.colors[j])
                    colors = None
            j += 1
        if is_legend:
            plt.legend(datatype,
                       numpoints=1,
                       frameon=True,
                       loc=legend_location)
        plt.title(title)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
Пример #5
0
    def TimeSeries(self, data, npoints, datatype, labels, trajectory_index,
                   linestyle, linewidth, marker, colors, title, xlabel, ylabel,
                   is_legend, legend_location):
        """        
        Tracks the propensities and/or species over time.

        Input: 
         - *data* (array)
         - *npoints* (integer)
         - *datatype* (list)
         - *labels* (list)
         - *trajectory_index* (integer)
         - *linestyle* (string)
         - *linewidth* (float)
         - *title* (string)
         - *xlabel* (string)
         - *ylabel* (string)
         - *is_legend* (boolean)       
        """
        plt.figure(self.plotnum)
        datatype_indices = [labels.index(Id) for Id in datatype]

        data = getDataForTimeSimPlot(data, npoints, self.quiet)

        Arr_time = data[:, 0]
        if len(datatype) == 1:
            j = trajectory_index
        else:
            j = 0

        for i in datatype_indices:
            y = data[:, i + 1]
            if colors == None:
                if j >= len(self.colors):
                    j = 0
            elif isinstance(colors, list):
                if j >= len(colors):
                    j = 0
            elif isinstance(colors, str):
                colors = [colors]
                j = 0

            if colors == None:
                plt.plot(Arr_time,
                         y,
                         marker,
                         ls=linestyle,
                         lw=linewidth,
                         color=self.colors[j])
            else:
                if clr.is_color_like(colors[j]):
                    plt.plot(Arr_time,
                             y,
                             marker,
                             ls=linestyle,
                             lw=linewidth,
                             color=colors[j])
                else:
                    print(
                        "*** WARNING ***: '{0}' is not recognized as a valid color code"
                        .format(colors[j]))
                    plt.plot(Arr_time,
                             y,
                             marker,
                             ls=linestyle,
                             lw=linewidth,
                             color=self.colors[j])
                    colors = None
            j += 1
        if is_legend:
            plt.legend(datatype,
                       numpoints=1,
                       frameon=True,
                       loc=legend_location)
        plt.title(title)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
Пример #6
0
    def AverageDistributionsCI(self,means,stds,nstd,datatype,labels,colors,title,xlabel,ylabel,is_legend,legend_location):
        """      
        Plots the average and standard deviation.

        Input:
         - *means* (nested list)
         - *stds* (nested list)
         - *nstd* (float)
         - *labels* (list)
         - *linestyle* (string)
         - *linewidth* (float)
         - *marker* (string)
         - *colors* (list)
         - *title* (string)
         - *xlabel* (string)
         - *ylabel* (string)
         - *is_legend* (boolean)
         - *legend_location* [default = 'upper right'] (string/integer)
        """  
        assert nstd > 0, "Error: The number of STDs must be a value larger than zero"      
        plt.figure(self.plotnum)
        datatype_indices = [labels.index(Id) for Id in datatype]           
        for i in datatype_indices:   
            L_s_amount = copy.copy(means[i][0])
            L_mu =  copy.copy(means[i][1])
            L_sigma =  copy.copy(stds[i][1])

            # Add an additional value
            L_s_amount.append(L_s_amount[-1]+1)
            L_mu.append(L_mu[-1])
            L_sigma.append(L_sigma[-1])

            X_i = []
            Y_i = []
            L_errors = []
            for j in range(len(L_s_amount)):
                if (not L_s_amount[j] == L_s_amount[0]) and (not L_s_amount[j] == L_s_amount[-1]):
                    X_i.append(L_s_amount[j])
                    Y_i.append(L_mu[j-1])
                    L_errors.append(L_sigma[j-1])
                X_i.append(L_s_amount[j])
                Y_i.append(L_mu[j])
                L_errors.append(L_sigma[j])
            X_e = np.concatenate([X_i, X_i[::-1]])
            Y_e = np.concatenate([np.array(Y_i) - nstd*np.array(L_errors) ,(np.array(Y_i) + nstd*np.array(L_errors))[::-1]])   
        
            if colors == None:              
                if j >= len(self.colors):                  
                    j=0
            elif isinstance(colors,list):
                if j >= len(colors):
                    j=0
            elif isinstance(colors,str):
                colors = [colors]
                j=0
            if colors == None:                         
                plt.fill(X_e-0.5,Y_e,  alpha=.25, ec='None', label='{0} STD confidence interval'.format(nstd),color = self.colors[j]) 
                plt.plot(np.array(X_i)-0.5,np.array(Y_i),color = self.colors[j])
            else:
                if clr.is_color_like(colors[j]):     
                    plt.fill(X_e-0.5,Y_e,  alpha=.25, ec='None', label='{0} STD confidence interval'.format(nstd),color = colors[j]) 
                    plt.plot(np.array(X_i)-0.5,np.array(Y_i),color = colors[j])
                else:
                    print("*** WARNING ***: '{0}' is not recognized as a valid color code".format(colors[j]) )
                    plt.fill(X_e-0.5,Y_e,  alpha=.25, ec='None', label='{0} STD confidence interval'.format(nstd),color = self.colors[j]) 
                    plt.plot(np.array(X_i)-0.5,np.array(Y_i),color = self.colors[j])      
                    colors = None
        if is_legend:
            plt.legend(numpoints=1,frameon=True,loc=legend_location)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        plt.title(title)